@forge/manifest 3.1.0-next.2 → 3.1.0-next.3

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,11 @@
1
1
  # @forge/manifest
2
2
 
3
+ ## 3.1.0-next.3
4
+
5
+ ### Patch Changes
6
+
7
+ - debe251: Accept both deprecated scopes and granular scopes when verifying scopes required for product events.
8
+
3
9
  ## 3.1.0-next.2
4
10
 
5
11
  ### Patch Changes
@@ -1,214 +1,449 @@
1
1
  {
2
- "mapping": [
3
- {
2
+ "mapping": [{
4
3
  "productEvent": "avi:jira:assigned:issue",
5
- "oAuthScopes": [
6
- "read:jira-work"
7
- ]
4
+ "oAuthScopes": {
5
+ "current": [
6
+ "read:issue:jira",
7
+ "read:issue-type:jira",
8
+ "read:user:jira",
9
+ "read:project:jira",
10
+ "read:status:jira"
11
+ ],
12
+ "deprecated": [
13
+ "read:jira-work"
14
+ ]
15
+ }
8
16
  },
9
17
  {
10
18
  "productEvent": "avi:jira:commented:issue",
11
- "oAuthScopes": [
12
- "read:jira-work"
13
- ]
19
+ "oAuthScopes": {
20
+ "current": [
21
+ "read:issue:jira",
22
+ "read:issue-type:jira",
23
+ "read:user:jira",
24
+ "read:project:jira",
25
+ "read:status:jira",
26
+ "read:issue.comment:jira"
27
+ ],
28
+ "deprecated": [
29
+ "read:jira-work"
30
+ ]
31
+ }
14
32
  },
15
33
  {
16
34
  "productEvent": "avi:jira:created:issue",
17
- "oAuthScopes": [
18
- "read:jira-work"
19
- ]
35
+ "oAuthScopes": {
36
+ "current": [
37
+ "read:issue:jira",
38
+ "read:issue-type:jira",
39
+ "read:user:jira",
40
+ "read:project:jira",
41
+ "read:status:jira"
42
+ ],
43
+ "deprecated": [
44
+ "read:jira-work"
45
+ ]
46
+ }
20
47
  },
21
48
  {
22
49
  "productEvent": "avi:jira:mentioned:comment",
23
- "oAuthScopes": [
24
- "read:jira-work"
25
- ]
50
+ "oAuthScopes": {
51
+ "current": [
52
+ "read:issue:jira",
53
+ "read:issue-type:jira",
54
+ "read:user:jira",
55
+ "read:project:jira",
56
+ "read:status:jira",
57
+ "read:issue.comment:jira"
58
+ ],
59
+ "deprecated": [
60
+ "read:jira-work"
61
+ ]
62
+ }
26
63
  },
27
64
  {
28
65
  "productEvent": "avi:jira:mentioned:issue",
29
- "oAuthScopes": [
30
- "read:jira-work"
31
- ]
66
+ "oAuthScopes": {
67
+ "current": [
68
+ "read:issue:jira",
69
+ "read:issue-type:jira",
70
+ "read:user:jira",
71
+ "read:project:jira",
72
+ "read:status:jira"
73
+ ],
74
+ "deprecated": [
75
+ "read:jira-work"
76
+ ]
77
+ }
32
78
  },
33
79
  {
34
80
  "productEvent": "avi:jira:updated:issue",
35
- "oAuthScopes": [
36
- "read:jira-work"
37
- ]
81
+ "oAuthScopes": {
82
+ "current": [
83
+ "read:issue:jira",
84
+ "read:issue-type:jira",
85
+ "read:user:jira",
86
+ "read:project:jira",
87
+ "read:status:jira"
88
+ ],
89
+ "deprecated": [
90
+ "read:jira-work"
91
+ ]
92
+ }
38
93
  },
39
94
  {
40
95
  "productEvent": "avi:jira:viewed:issue",
41
- "oAuthScopes": [
42
- "read:jira-work"
43
- ]
96
+ "oAuthScopes": {
97
+ "current": [
98
+ "read:issue:jira",
99
+ "read:issue-type:jira",
100
+ "read:user:jira",
101
+ "read:project:jira",
102
+ "read:status:jira"
103
+ ],
104
+ "deprecated": [
105
+ "read:jira-work"
106
+ ]
107
+ }
44
108
  },
45
109
  {
46
110
  "productEvent": "avi:jira:created:field",
47
- "oAuthScopes": [
48
- "read:field:jira"
49
- ]
111
+ "oAuthScopes": {
112
+ "current": [
113
+ "read:field:jira"
114
+ ],
115
+ "deprecated": [
116
+ "manage:jira-configuration"
117
+ ]
118
+ }
50
119
  },
51
120
  {
52
121
  "productEvent": "avi:jira:updated:field",
53
- "oAuthScopes": [
54
- "read:field:jira"
55
- ]
122
+ "oAuthScopes": {
123
+ "current": [
124
+ "read:field:jira"
125
+ ],
126
+ "deprecated": [
127
+ "manage:jira-configuration"
128
+ ]
129
+ }
56
130
  },
57
131
  {
58
132
  "productEvent": "avi:jira:trashed:field",
59
- "oAuthScopes": [
60
- "read:field:jira"
61
- ]
133
+ "oAuthScopes": {
134
+ "current": [
135
+ "read:field:jira"
136
+ ],
137
+ "deprecated": [
138
+ "manage:jira-configuration"
139
+ ]
140
+ }
62
141
  },
63
142
  {
64
143
  "productEvent": "avi:jira:deleted:field",
65
- "oAuthScopes": [
66
- "read:field:jira"
67
- ]
144
+ "oAuthScopes": {
145
+ "current": [
146
+ "read:field:jira"
147
+ ],
148
+ "deprecated": [
149
+ "manage:jira-configuration"
150
+ ]
151
+ }
68
152
  },
69
153
  {
70
154
  "productEvent": "avi:jira:restored:field",
71
- "oAuthScopes": [
72
- "read:field:jira"
73
- ]
155
+ "oAuthScopes": {
156
+ "current": [
157
+ "read:field:jira"
158
+ ],
159
+ "deprecated": [
160
+ "manage:jira-configuration"
161
+ ]
162
+ }
74
163
  },
75
164
  {
76
165
  "productEvent": "avi:jira:created:field:context",
77
- "oAuthScopes": [
78
- "read:field:jira"
79
- ]
166
+ "oAuthScopes": {
167
+ "current": [
168
+ "read:field:jira"
169
+ ],
170
+ "deprecated": [
171
+ "manage:jira-configuration"
172
+ ]
173
+ }
80
174
  },
81
175
  {
82
176
  "productEvent": "avi:jira:updated:field:context",
83
- "oAuthScopes": [
84
- "read:field:jira"
85
- ]
177
+ "oAuthScopes": {
178
+ "current": [
179
+ "read:field:jira"
180
+ ],
181
+ "deprecated": [
182
+ "manage:jira-configuration"
183
+ ]
184
+ }
86
185
  },
87
186
  {
88
187
  "productEvent": "avi:jira:deleted:field:context",
89
- "oAuthScopes": [
90
- "read:field:jira"
91
- ]
188
+ "oAuthScopes": {
189
+ "current": [
190
+ "read:field:jira"
191
+ ],
192
+ "deprecated": [
193
+ "manage:jira-configuration"
194
+ ]
195
+ }
92
196
  },
93
197
  {
94
198
  "productEvent": "avi:jira:updated:field:context:configuration",
95
- "oAuthScopes": [
96
- "read:custom-field-contextual-configuration:jira"
97
- ]
199
+ "oAuthScopes": {
200
+ "current": [
201
+ "read:custom-field-contextual-configuration:jira"
202
+ ]
203
+ }
98
204
  },
99
205
  {
100
206
  "productEvent": "avi:confluence:updated:blogpost",
101
- "oAuthScopes": [
102
- "read:confluence-content.summary"
103
- ]
207
+ "oAuthScopes": {
208
+ "current": [
209
+ "read:blogpost:confluence",
210
+ "read:space:confluence",
211
+ "read:user:confluence",
212
+ "read:content.metadata:confluence"
213
+ ],
214
+ "deprecated": [
215
+ "read:confluence-content.summary"
216
+ ]
217
+ }
104
218
  },
105
219
  {
106
220
  "productEvent": "avi:confluence:liked:comment",
107
- "oAuthScopes": [
108
- "read:confluence-content.summary"
109
- ]
221
+ "oAuthScopes": {
222
+ "current": [
223
+ "read:comment:confluence",
224
+ "read:page:confluence",
225
+ "read:blogpost:confluence",
226
+ "read:space:confluence",
227
+ "read:user:confluence",
228
+ "read:content.metadata:confluence"
229
+ ],
230
+ "deprecated": [
231
+ "read:confluence-content.summary"
232
+ ]
233
+ }
110
234
  },
111
235
  {
112
236
  "productEvent": "avi:confluence:created:page",
113
- "oAuthScopes": [
114
- "read:confluence-content.summary"
115
- ]
237
+ "oAuthScopes": {
238
+ "current": [
239
+ "read:page:confluence",
240
+ "read:space:confluence",
241
+ "read:user:confluence",
242
+ "read:content.metadata:confluence"
243
+ ],
244
+ "deprecated": [
245
+ "read:confluence-content.summary"
246
+ ]
247
+ }
116
248
  },
117
249
  {
118
250
  "productEvent": "avi:confluence:viewed:page",
119
- "oAuthScopes": [
120
- "read:confluence-content.summary"
121
- ]
251
+ "oAuthScopes": {
252
+ "current": [
253
+ "read:page:confluence",
254
+ "read:space:confluence",
255
+ "read:user:confluence",
256
+ "read:content.metadata:confluence"
257
+ ],
258
+ "deprecated": [
259
+ "read:confluence-content.summary"
260
+ ]
261
+ }
122
262
  },
123
263
  {
124
264
  "productEvent": "avi:confluence:updated:page",
125
- "oAuthScopes": [
126
- "read:confluence-content.summary"
127
- ]
265
+ "oAuthScopes": {
266
+ "current": [
267
+ "read:page:confluence",
268
+ "read:space:confluence",
269
+ "read:user:confluence",
270
+ "read:content.metadata:confluence"
271
+ ],
272
+ "deprecated": [
273
+ "read:confluence-content.summary"
274
+ ]
275
+ }
128
276
  },
129
277
  {
130
278
  "productEvent": "avi:confluence:created:comment",
131
- "oAuthScopes": [
132
- "read:confluence-content.summary"
133
- ]
279
+ "oAuthScopes": {
280
+ "current": [
281
+ "read:comment:confluence",
282
+ "read:page:confluence",
283
+ "read:blogpost:confluence",
284
+ "read:space:confluence",
285
+ "read:user:confluence",
286
+ "read:content.metadata:confluence"
287
+ ],
288
+ "deprecated": [
289
+ "read:confluence-content.summary"
290
+ ]
291
+ }
134
292
  },
135
293
  {
136
294
  "productEvent": "avi:confluence:viewed:blogpost",
137
- "oAuthScopes": [
138
- "read:confluence-content.summary"
139
- ]
295
+ "oAuthScopes": {
296
+ "current": [
297
+ "read:blogpost:confluence",
298
+ "read:space:confluence",
299
+ "read:user:confluence",
300
+ "read:content.metadata:confluence"
301
+ ],
302
+ "deprecated": [
303
+ "read:confluence-content.summary"
304
+ ]
305
+ }
140
306
  },
141
307
  {
142
308
  "productEvent": "avi:confluence:liked:page",
143
- "oAuthScopes": [
144
- "read:confluence-content.summary"
145
- ]
309
+ "oAuthScopes": {
310
+ "current": [
311
+ "read:page:confluence",
312
+ "read:space:confluence",
313
+ "read:user:confluence",
314
+ "read:content.metadata:confluence"
315
+ ],
316
+ "deprecated": [
317
+ "read:confluence-content.summary"
318
+ ]
319
+ }
146
320
  },
147
321
  {
148
322
  "productEvent": "avi:confluence:liked:blogpost",
149
- "oAuthScopes": [
150
- "read:confluence-content.summary"
151
- ]
323
+ "oAuthScopes": {
324
+ "current": [
325
+ "read:blogpost:confluence",
326
+ "read:space:confluence",
327
+ "read:user:confluence",
328
+ "read:content.metadata:confluence"
329
+ ],
330
+ "deprecated": [
331
+ "read:confluence-content.summary"
332
+ ]
333
+ }
152
334
  },
153
335
  {
154
336
  "productEvent": "avi:confluence:created:blogpost",
155
- "oAuthScopes": [
156
- "read:confluence-content.summary"
157
- ]
337
+ "oAuthScopes": {
338
+ "current": [
339
+ "read:blogpost:confluence",
340
+ "read:space:confluence",
341
+ "read:user:confluence",
342
+ "read:content.metadata:confluence"
343
+ ],
344
+ "deprecated": [
345
+ "read:confluence-content.summary"
346
+ ]
347
+ }
158
348
  },
159
349
  {
160
350
  "productEvent": "avi:confluence:created:task",
161
- "oAuthScopes": [
162
- "read:confluence-content.all"
163
- ]
351
+ "oAuthScopes": {
352
+ "current": [
353
+ "read:inlinetask:confluence",
354
+ "read:space:confluence",
355
+ "read:user:confluence",
356
+ "read:content.metadata:confluence"
357
+ ],
358
+ "deprecated": [
359
+ "read:confluence-content.all"
360
+ ]
361
+ }
164
362
  },
165
363
  {
166
364
  "productEvent": "avi:confluence:updated:task",
167
- "oAuthScopes": [
168
- "read:confluence-content.all"
169
- ]
365
+ "oAuthScopes": {
366
+ "current": [
367
+ "read:inlinetask:confluence",
368
+ "read:space:confluence",
369
+ "read:user:confluence",
370
+ "read:content.metadata:confluence"
371
+ ],
372
+ "deprecated": [
373
+ "read:confluence-content.all"
374
+ ]
375
+ }
170
376
  },
171
377
  {
172
378
  "productEvent": "avi:confluence:removed:task",
173
- "oAuthScopes": [
174
- "read:confluence-content.all"
175
- ]
379
+ "oAuthScopes": {
380
+ "current": [
381
+ "read:inlinetask:confluence",
382
+ "read:space:confluence",
383
+ "read:user:confluence",
384
+ "read:content.metadata:confluence"
385
+ ],
386
+ "deprecated": [
387
+ "read:confluence-content.all"
388
+ ]
389
+ }
176
390
  },
177
391
  {
178
392
  "productEvent": "avi:confluence:created:space:V2",
179
- "oAuthScopes": [
180
- "read:confluence-space.summary"
181
- ]
393
+ "oAuthScopes": {
394
+ "current": [
395
+ "read:space:confluence"
396
+ ],
397
+ "deprecated": [
398
+ "read:confluence-space.summary"
399
+ ]
400
+ }
182
401
  },
183
402
  {
184
403
  "productEvent": "avi:confluence:updated:space:V2",
185
- "oAuthScopes": [
186
- "read:confluence-space.summary"
187
- ]
404
+ "oAuthScopes": {
405
+ "current": [
406
+ "read:space:confluence"
407
+ ],
408
+ "deprecated": [
409
+ "read:confluence-space.summary"
410
+ ]
411
+ }
188
412
  },
189
413
  {
190
414
  "productEvent": "avi:confluence:deleted:space:V2",
191
- "oAuthScopes": [
192
- "read:confluence-space.summary"
193
- ]
415
+ "oAuthScopes": {
416
+ "current": [
417
+ "read:space:confluence"
418
+ ],
419
+ "deprecated": [
420
+ "read:confluence-space.summary"
421
+ ]
422
+ }
194
423
  },
195
424
  {
196
425
  "productEvent": "avi:compass:created:component_link",
197
- "oAuthScopes": [
198
- "read:component:compass"
199
- ]
426
+ "oAuthScopes": {
427
+ "current": [
428
+ "read:component:compass"
429
+ ]
430
+ }
200
431
  },
201
432
  {
202
433
  "productEvent": "avi:compass:updated:component_link",
203
- "oAuthScopes": [
204
- "read:component:compass"
205
- ]
434
+ "oAuthScopes": {
435
+ "current": [
436
+ "read:component:compass"
437
+ ]
438
+ }
206
439
  },
207
440
  {
208
441
  "productEvent": "avi:compass:deleted:component_link",
209
- "oAuthScopes": [
210
- "read:component:compass"
211
- ]
442
+ "oAuthScopes": {
443
+ "current": [
444
+ "read:component:compass"
445
+ ]
446
+ }
212
447
  }
213
448
  ]
214
449
  }
@@ -3,7 +3,10 @@ import { ValidatorInterface } from './validator-interface';
3
3
  import { ManifestSchema } from '../schema/manifest';
4
4
  export interface MappingEntry {
5
5
  productEvent: string;
6
- oAuthScopes: string[];
6
+ oAuthScopes: {
7
+ current: string[];
8
+ deprecated?: string[];
9
+ };
7
10
  }
8
11
  export interface MappingConfig {
9
12
  mapping: MappingEntry[];
@@ -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;AAIpD,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;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;IAC7E,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,GAAG,wBAAwB,CAAC,cAAc,CAAC;CAgDzG"}
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;AAIpD,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE;QACX,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACvB,CAAC;CACH;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;IAC7E,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,GAAG,wBAAwB,CAAC,cAAc,CAAC;CAsEzG"}
@@ -16,9 +16,9 @@ class ProductTriggerScopesValidator {
16
16
  };
17
17
  }
18
18
  const validationErrors = [];
19
- const getRequiredScopesForProductEvent = (productEvent) => {
19
+ const getRequiredScopes = (productEvent, status) => {
20
20
  var _a;
21
- return ((_a = this.config.mapping.find((value) => value.productEvent == productEvent)) === null || _a === void 0 ? void 0 : _a.oAuthScopes) || [];
21
+ return (_a = this.config.mapping.find((value) => value.productEvent == productEvent)) === null || _a === void 0 ? void 0 : _a.oAuthScopes[status];
22
22
  };
23
23
  const addValidationError = (scope, event) => {
24
24
  validationErrors.push(Object.assign({ message: text_1.errors.permissions.missingPermissionFromScope(scope, event), reference: text_1.References.MissingScopes, level: 'error', metadata: {
@@ -33,11 +33,27 @@ class ProductTriggerScopesValidator {
33
33
  }
34
34
  const manifestScopes = ((_a = manifest.typedContent.permissions) === null || _a === void 0 ? void 0 : _a.scopes) || [];
35
35
  manifest.typedContent.modules.trigger.forEach((element) => {
36
- element.events.forEach((event) => {
37
- const requiredScopes = getRequiredScopesForProductEvent(event);
38
- const missingScopes = requiredScopes.filter((requiredScope) => !manifestScopes.includes(requiredScope));
39
- missingScopes.forEach((missingScope) => addValidationError(missingScope, event));
40
- });
36
+ for (const event of element.events) {
37
+ const currentScopes = getRequiredScopes(event, 'current');
38
+ if (!currentScopes)
39
+ continue;
40
+ const missingCurrentScopes = currentScopes.filter((scope) => !manifestScopes.includes(scope));
41
+ if (missingCurrentScopes.length === 0)
42
+ continue;
43
+ const deprecatedScopes = getRequiredScopes(event, 'deprecated');
44
+ const missingDeprecatedScopes = deprecatedScopes === null || deprecatedScopes === void 0 ? void 0 : deprecatedScopes.filter((scope) => !manifestScopes.includes(scope));
45
+ if ((missingDeprecatedScopes === null || missingDeprecatedScopes === void 0 ? void 0 : missingDeprecatedScopes.length) === 0)
46
+ continue;
47
+ if (missingCurrentScopes.length < currentScopes.length) {
48
+ missingCurrentScopes.forEach((scope) => addValidationError(scope, event));
49
+ continue;
50
+ }
51
+ if (missingDeprecatedScopes && deprecatedScopes && missingDeprecatedScopes.length < deprecatedScopes.length) {
52
+ missingDeprecatedScopes.forEach((scope) => addValidationError(scope, event));
53
+ continue;
54
+ }
55
+ missingCurrentScopes.forEach((scope) => addValidationError(scope, event));
56
+ }
41
57
  });
42
58
  return {
43
59
  success: validationErrors.length === 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/manifest",
3
- "version": "3.1.0-next.2",
3
+ "version": "3.1.0-next.3",
4
4
  "description": "Definitions and validations of the Forge manifest",
5
5
  "main": "out/index.js",
6
6
  "scripts": {