@forge/manifest 11.0.0-next.0 → 11.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @forge/manifest
2
2
 
3
+ ## 11.0.0-next.2
4
+
5
+ ### Major Changes
6
+
7
+ - 260eb24: Adding support for new module fifoConsumer
8
+
9
+ ## 11.0.0-next.1
10
+
11
+ ### Minor Changes
12
+
13
+ - 9a6d346: Add standalone trigger scope validation API (only event name and scopes required)
14
+
3
15
  ## 11.0.0-next.0
4
16
 
5
17
  ### Major Changes
package/README.md CHANGED
@@ -17,6 +17,28 @@ const results = ProcessorBuilder.instance()
17
17
  console.log(`Valid manifest ? ${results.success}`);
18
18
  ```
19
19
 
20
+ ## Simple Trigger Scopes Validation
21
+
22
+ For validating trigger event scopes, use the simple validation API that only requires the event name and scopes:
23
+
24
+ ```typescript
25
+ import { validateTriggerScopes } from '@forge/manifest';
26
+
27
+ // Simple: just pass event and scopes
28
+ const result = await validateTriggerScopes(
29
+ 'avi:jira:assigned:issue',
30
+ ['read:jira-work']
31
+ );
32
+
33
+ if (!result.valid) {
34
+ console.error(`Missing scopes: ${result.missingScopes.join(', ')}`);
35
+ }
36
+ ```
37
+
38
+ This is useful for:
39
+ - External tools that need to verify scope requirements
40
+ - Any service that validates event-scope mappings
41
+
20
42
  ## How to check the errors
21
43
 
22
44
  In case of an invalid `manifest.yml`, the following information will be populated:
@@ -1,3 +1,4 @@
1
+ import { RequiredScopes } from '../scopes';
1
2
  export declare enum ValidationTypes {
2
3
  BASIC = "basic",
3
4
  FULL = "full",
@@ -6,4 +7,10 @@ export declare enum ValidationTypes {
6
7
  FORGE_REMOTE_COMPUTE = "forge-remote-compute",
7
8
  DEPRECATED_EGRESS_PERMISSIONS = "deprecated-egress-permissions"
8
9
  }
10
+ export interface TriggerScopeValidationResult {
11
+ valid: boolean;
12
+ event: string;
13
+ missingScopes: string[];
14
+ requiredScopes: RequiredScopes | null;
15
+ }
9
16
  //# sourceMappingURL=validation-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation-types.d.ts","sourceRoot":"","sources":["../../src/types/validation-types.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACzB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,eAAe,oBAAoB;IACnC,qBAAqB,0BAA0B;IAC/C,oBAAoB,yBAAyB;IAC7C,6BAA6B,kCAAkC;CAChE"}
1
+ {"version":3,"file":"validation-types.d.ts","sourceRoot":"","sources":["../../src/types/validation-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,oBAAY,eAAe;IACzB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,eAAe,oBAAoB;IACnC,qBAAqB,0BAA0B;IAC/C,oBAAoB,yBAAyB;IAC7C,6BAA6B,kCAAkC;CAChE;AAKD,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;CACvC"}
@@ -7,6 +7,7 @@ export * from './validator-interface';
7
7
  export * from './resources-validator';
8
8
  export * from './display-conditions-validator';
9
9
  export * from './product-trigger-scopes-validator';
10
+ export * from './simple-trigger-scope-validator';
10
11
  export * from './providers-validator';
11
12
  export * from './permissions-validator';
12
13
  export * from './connect-remote-validator';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC"}
@@ -10,6 +10,7 @@ tslib_1.__exportStar(require("./validator-interface"), exports);
10
10
  tslib_1.__exportStar(require("./resources-validator"), exports);
11
11
  tslib_1.__exportStar(require("./display-conditions-validator"), exports);
12
12
  tslib_1.__exportStar(require("./product-trigger-scopes-validator"), exports);
13
+ tslib_1.__exportStar(require("./simple-trigger-scope-validator"), exports);
13
14
  tslib_1.__exportStar(require("./providers-validator"), exports);
14
15
  tslib_1.__exportStar(require("./permissions-validator"), exports);
15
16
  tslib_1.__exportStar(require("./connect-remote-validator"), exports);
@@ -1,6 +1,6 @@
1
1
  import { ManifestObject, ManifestValidationResult } from '../types';
2
2
  import { ValidatorInterface } from './validator-interface';
3
- import { ManifestSchema } from '../schema/manifest';
3
+ import { ManifestSchema, Scopes } from '../schema/manifest';
4
4
  import { RequiredScopes } from '../scopes';
5
5
  export interface MappingEntry {
6
6
  productEvent: string;
@@ -9,6 +9,10 @@ export interface MappingEntry {
9
9
  export interface MappingConfig {
10
10
  mapping: MappingEntry[];
11
11
  }
12
+ export declare function validateEventScopes(event: string, scopes: Scopes | undefined, config: MappingConfig): Promise<{
13
+ requiredScopes: RequiredScopes;
14
+ missingScopes: string[];
15
+ }>;
12
16
  export declare class ProductTriggerScopesValidator<T> implements ValidatorInterface<ManifestObject<ManifestSchema> | undefined, ManifestSchema> {
13
17
  private readonly config;
14
18
  constructor(config: MappingConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"product-trigger-scopes-validator.d.ts","sourceRoot":"","sources":["../../src/validators/product-trigger-scopes-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAmB,MAAM,UAAU,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAoB,cAAc,EAAE,MAAM,WAAW,CAAC;AAE7D,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,cAAc,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,qBAAa,6BAA6B,CAAC,CAAC,CAC1C,YAAW,kBAAkB,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,EAAE,cAAc,CAAC;IAE7E,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAE5C,QAAQ,CACZ,QAAQ,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,GACnD,OAAO,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC;CAoDrD"}
1
+ {"version":3,"file":"product-trigger-scopes-validator.d.ts","sourceRoot":"","sources":["../../src/validators/product-trigger-scopes-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAmB,MAAM,UAAU,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5D,OAAO,EAAoB,cAAc,EAAE,MAAM,WAAW,CAAC;AAE7D,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,cAAc,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAcD,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC;IAAE,cAAc,EAAE,cAAc,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAStE;AAED,qBAAa,6BAA6B,CAAC,CAAC,CAC1C,YAAW,kBAAkB,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,EAAE,cAAc,CAAC;IAE7E,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAE5C,QAAQ,CACZ,QAAQ,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,GACnD,OAAO,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC;CA6CrD"}
@@ -1,9 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProductTriggerScopesValidator = void 0;
3
+ exports.ProductTriggerScopesValidator = exports.validateEventScopes = void 0;
4
4
  const text_1 = require("../text");
5
5
  const utils_1 = require("../utils");
6
6
  const scopes_1 = require("../scopes");
7
+ async function validateEventScopes(event, scopes, config) {
8
+ const emptyRequiredScopes = { current: [] };
9
+ const requiredScopes = config.mapping.find((entry) => entry.productEvent === event)?.oAuthScopes || emptyRequiredScopes;
10
+ const missingScopes = await (0, scopes_1.getMissingScopes)(scopes, requiredScopes);
11
+ return { requiredScopes, missingScopes };
12
+ }
13
+ exports.validateEventScopes = validateEventScopes;
7
14
  class ProductTriggerScopesValidator {
8
15
  config;
9
16
  constructor(config) {
@@ -17,10 +24,6 @@ class ProductTriggerScopesValidator {
17
24
  };
18
25
  }
19
26
  const validationErrors = [];
20
- const getRequiredScopes = (productEvent) => {
21
- const emptyRequiredScopes = { current: [] };
22
- return (this.config.mapping.find((value) => value.productEvent == productEvent)?.oAuthScopes || emptyRequiredScopes);
23
- };
24
27
  const addValidationError = (scope, event) => {
25
28
  validationErrors.push({
26
29
  message: text_1.errors.permissions.missingPermissionFromScope(scope, event),
@@ -41,8 +44,7 @@ class ProductTriggerScopesValidator {
41
44
  const manifestScopes = manifest.typedContent.permissions?.scopes || [];
42
45
  for (const element of manifest.typedContent.modules.trigger) {
43
46
  for (const event of element.events) {
44
- const requiredScopes = getRequiredScopes(event);
45
- const missingScopes = await (0, scopes_1.getMissingScopes)(manifestScopes, requiredScopes);
47
+ const { missingScopes } = await validateEventScopes(event, manifestScopes, this.config);
46
48
  missingScopes.forEach((scope) => addValidationError(scope, event));
47
49
  }
48
50
  }
@@ -0,0 +1,3 @@
1
+ import { TriggerScopeValidationResult } from '../types/validation-types';
2
+ export declare function validateTriggerScopes(event: string, scopes: string[]): Promise<TriggerScopeValidationResult>;
3
+ //# sourceMappingURL=simple-trigger-scope-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple-trigger-scope-validator.d.ts","sourceRoot":"","sources":["../../src/validators/simple-trigger-scope-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AA4BzE,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAgBlH"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateTriggerScopes = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const product_trigger_scopes_validator_1 = require("./product-trigger-scopes-validator");
6
+ const EVENT_SCOPE_MAPPING = tslib_1.__importStar(require("../mapping/product-event-to-scope-mapping.json"));
7
+ async function validateTriggerScopes(event, scopes) {
8
+ const { requiredScopes, missingScopes } = await (0, product_trigger_scopes_validator_1.validateEventScopes)(event, scopes, EVENT_SCOPE_MAPPING);
9
+ const hasRequirements = requiredScopes.current.length > 0;
10
+ return {
11
+ valid: missingScopes.length === 0,
12
+ event,
13
+ missingScopes,
14
+ requiredScopes: hasRequirements ? requiredScopes : null
15
+ };
16
+ }
17
+ exports.validateTriggerScopes = validateTriggerScopes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/manifest",
3
- "version": "11.0.0-next.0",
3
+ "version": "11.0.0-next.2",
4
4
  "description": "Definitions and validations of the Forge manifest",
5
5
  "main": "out/index.js",
6
6
  "scripts": {