@forge/api 7.0.3-next.0-experimental-bf21d1e → 7.1.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 +9 -4
- package/out/api/permissions.d.ts +8 -3
- package/out/api/permissions.d.ts.map +1 -1
- package/out/api/permissions.js +27 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
# @forge/api
|
|
2
2
|
|
|
3
|
-
## 7.0
|
|
3
|
+
## 7.1.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 16a4b01: Updated SDK to throw type error
|
|
8
|
+
|
|
9
|
+
## 7.0.3-next.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
6
12
|
|
|
7
|
-
- Updated dependencies [
|
|
8
|
-
-
|
|
9
|
-
- @forge/manifest@12.1.2-next.1-experimental-bf21d1e
|
|
13
|
+
- Updated dependencies [c70bd69]
|
|
14
|
+
- @forge/manifest@12.2.0-next.2
|
|
10
15
|
|
|
11
16
|
## 7.0.3-next.0
|
|
12
17
|
|
package/out/api/permissions.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { PermissionRequirements, MissingPermissions } from './runtime';
|
|
2
|
-
import { External } from '@forge/manifest';
|
|
2
|
+
import { External, Fetch } from '@forge/manifest';
|
|
3
|
+
declare const RESOURCE_TYPES: readonly ["fonts", "styles", "frames", "images", "media", "scripts"];
|
|
4
|
+
export declare type ResourceType = (typeof RESOURCE_TYPES)[number];
|
|
5
|
+
declare const FETCH_TYPES: readonly ["backend", "client"];
|
|
6
|
+
export declare type FetchType = (typeof FETCH_TYPES)[number];
|
|
7
|
+
export declare type ValidatedArrayField = string[] | External[ResourceType] | Fetch[FetchType];
|
|
3
8
|
export declare function extractUrlString(url: string | {
|
|
4
9
|
address: string;
|
|
5
10
|
} | {
|
|
@@ -13,12 +18,12 @@ export interface PermissionResult {
|
|
|
13
18
|
}
|
|
14
19
|
export declare const hasPermission: (requirements: Partial<PermissionRequirements>) => PermissionResult;
|
|
15
20
|
export declare const hasScope: (scope: string) => boolean;
|
|
16
|
-
export declare const canFetchFrom: (type:
|
|
21
|
+
export declare const canFetchFrom: (type: FetchType, url: string) => boolean;
|
|
17
22
|
export declare const canLoadResource: (type: Exclude<keyof External, 'fetch'>, url: string) => boolean;
|
|
18
23
|
export declare const permissions: {
|
|
19
24
|
hasPermission: (requirements: Partial<PermissionRequirements>) => PermissionResult;
|
|
20
25
|
hasScope: (scope: string) => boolean;
|
|
21
|
-
canFetchFrom: (type:
|
|
26
|
+
canFetchFrom: (type: FetchType, url: string) => boolean;
|
|
22
27
|
canLoadResource: (type: Exclude<keyof External, 'fetch'>, url: string) => boolean;
|
|
23
28
|
};
|
|
24
29
|
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/api/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,sBAAsB,EAAE,kBAAkB,EAAgB,MAAM,WAAW,CAAC;AAEpG,OAAO,EAAU,QAAQ,
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/api/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,sBAAsB,EAAE,kBAAkB,EAAgB,MAAM,WAAW,CAAC;AAEpG,OAAO,EAAU,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAM1D,QAAA,MAAM,cAAc,sEAAuE,CAAC;AAC5F,oBAAY,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAK3D,QAAA,MAAM,WAAW,gCAAiC,CAAC;AACnD,oBAAY,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAKrD,oBAAY,mBAAmB,GAAG,MAAM,EAAE,GAAG,QAAQ,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;AAKvF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAQ/F;AAeD,YAAY,EAAE,sBAAsB,EAAE,CAAC;AAKvC,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAOnC,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AA4PD,eAAO,MAAM,aAAa,iBAAkB,QAAQ,sBAAsB,CAAC,KAAG,gBAE7E,CAAC;AAiEF,eAAO,MAAM,QAAQ,UAAW,MAAM,KAAG,OAKxC,CAAC;AAyBF,eAAO,MAAM,YAAY,SAAU,SAAS,OAAO,MAAM,KAAG,OAK3D,CAAC;AAyBF,eAAO,MAAM,eAAe,SAAU,QAAQ,MAAM,QAAQ,EAAE,OAAO,CAAC,OAAO,MAAM,KAAG,OAKrF,CAAC;AAKF,eAAO,MAAM,WAAW;kCAzIoB,QAAQ,sBAAsB,CAAC,KAAG,gBAAgB;sBAmE9D,MAAM,KAAG,OAAO;yBA8Bb,SAAS,OAAO,MAAM,KAAG,OAAO;4BA8B7B,QAAQ,MAAM,QAAQ,EAAE,OAAO,CAAC,OAAO,MAAM,KAAG,OAAO;CAe5F,CAAC"}
|
package/out/api/permissions.js
CHANGED
|
@@ -4,6 +4,8 @@ exports.permissions = exports.canLoadResource = exports.canFetchFrom = exports.h
|
|
|
4
4
|
const runtime_1 = require("./runtime");
|
|
5
5
|
const errors_1 = require("./errors");
|
|
6
6
|
const egress_1 = require("@forge/egress");
|
|
7
|
+
const RESOURCE_TYPES = ['fonts', 'styles', 'frames', 'images', 'media', 'scripts'];
|
|
8
|
+
const FETCH_TYPES = ['backend', 'client'];
|
|
7
9
|
function extractUrlString(url) {
|
|
8
10
|
if (typeof url === 'string') {
|
|
9
11
|
return url;
|
|
@@ -65,12 +67,35 @@ const validateKeys = (obj, validKeys) => {
|
|
|
65
67
|
`Visit https://go.atlassian.com/forge-permissions for more information.`);
|
|
66
68
|
}
|
|
67
69
|
};
|
|
70
|
+
const validateObjectField = (value, fieldPath) => {
|
|
71
|
+
if (value !== undefined) {
|
|
72
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
73
|
+
throw new TypeError(`${fieldPath} should be an object, not ${Array.isArray(value) ? 'an array' : `a ${typeof value}`}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const validateArrayField = (value, fieldPath) => {
|
|
78
|
+
if (value !== undefined && !Array.isArray(value)) {
|
|
79
|
+
throw new TypeError(`${fieldPath} should be an array, not a ${typeof value}`);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
68
82
|
const validatePermissionRequirements = (requirements) => {
|
|
69
83
|
validateKeys(requirements, VALID_REQUIREMENT_KEYS);
|
|
70
|
-
|
|
84
|
+
validateArrayField(requirements.scopes, 'scopes');
|
|
85
|
+
if (requirements.external !== undefined) {
|
|
86
|
+
validateObjectField(requirements.external, 'external');
|
|
71
87
|
validateKeys(requirements.external, VALID_EXTERNAL_TYPES);
|
|
72
|
-
|
|
88
|
+
for (const type of VALID_EXTERNAL_TYPES) {
|
|
89
|
+
if (type !== 'fetch' && type !== 'configurable') {
|
|
90
|
+
validateArrayField(requirements.external[type], `external.${type}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (requirements.external.fetch !== undefined) {
|
|
94
|
+
validateObjectField(requirements.external.fetch, 'external.fetch');
|
|
73
95
|
validateKeys(requirements.external.fetch, VALID_FETCH_TYPES);
|
|
96
|
+
for (const type of VALID_FETCH_TYPES) {
|
|
97
|
+
validateArrayField(requirements.external.fetch[type], `external.fetch.${type}`);
|
|
98
|
+
}
|
|
74
99
|
}
|
|
75
100
|
}
|
|
76
101
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/api",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.1.0-next.2",
|
|
4
4
|
"description": "Forge API methods",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@forge/auth": "0.0.9",
|
|
29
29
|
"@forge/egress": "2.3.1",
|
|
30
30
|
"@forge/i18n": "0.0.7",
|
|
31
|
-
"@forge/manifest": "^12.
|
|
31
|
+
"@forge/manifest": "^12.2.0-next.2",
|
|
32
32
|
"@forge/storage": "2.0.3",
|
|
33
33
|
"headers-utils": "^3.0.2"
|
|
34
34
|
},
|