@forge/runtime 6.0.0-next.0 → 6.0.0-next.1
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 +6 -0
- package/out/index.d.ts +1 -25
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -37
- package/out/request.d.ts +91 -338
- package/out/request.d.ts.map +1 -1
- package/out/request.js +0 -130
- package/out/result.d.ts +1 -2
- package/out/result.d.ts.map +1 -1
- package/out/sandbox/index.d.ts +0 -2
- package/out/sandbox/index.d.ts.map +1 -1
- package/out/sandbox/index.js +0 -2
- package/out/sandbox/invocation-event.d.ts +7 -49
- package/out/sandbox/invocation-event.d.ts.map +1 -1
- package/out/sandbox/invocation-event.js +9 -50
- package/out/sandbox/sandbox.d.ts +2 -10
- package/out/sandbox/sandbox.d.ts.map +1 -1
- package/package.json +2 -34
- package/out/app-manifest.d.ts +0 -71
- package/out/app-manifest.d.ts.map +0 -1
- package/out/app-manifest.js +0 -83
- package/out/config.d.ts +0 -6
- package/out/config.d.ts.map +0 -1
- package/out/config.js +0 -2
- package/out/context.d.ts +0 -37
- package/out/context.d.ts.map +0 -1
- package/out/context.js +0 -48
- package/out/feature-flag.d.ts +0 -15
- package/out/feature-flag.d.ts.map +0 -1
- package/out/feature-flag.js +0 -23
- package/out/limits/index.d.ts +0 -2
- package/out/limits/index.d.ts.map +0 -1
- package/out/limits/index.js +0 -4
- package/out/limits/tracker.d.ts +0 -30
- package/out/limits/tracker.d.ts.map +0 -1
- package/out/limits/tracker.js +0 -34
- package/out/logger.d.ts +0 -65
- package/out/logger.d.ts.map +0 -1
- package/out/logger.js +0 -19
- package/out/metrics/index.d.ts +0 -2
- package/out/metrics/index.d.ts.map +0 -1
- package/out/metrics/index.js +0 -4
- package/out/metrics/metrics.d.ts +0 -29
- package/out/metrics/metrics.d.ts.map +0 -1
- package/out/metrics/metrics.js +0 -78
- package/out/sandbox/inspector.d.ts +0 -39
- package/out/sandbox/inspector.d.ts.map +0 -1
- package/out/sandbox/inspector.js +0 -258
- package/out/sandbox/invocation-request.d.ts +0 -114
- package/out/sandbox/invocation-request.d.ts.map +0 -1
- package/out/sandbox/invocation-request.js +0 -271
- package/out/snapshot.d.ts +0 -16
- package/out/snapshot.d.ts.map +0 -1
- package/out/snapshot.js +0 -6
package/out/request.js
CHANGED
|
@@ -1,132 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvocationType = exports.ExternalRequestBodyType = exports.LicenseType = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const t = tslib_1.__importStar(require("io-ts"));
|
|
6
|
-
const Remote = t.type({
|
|
7
|
-
baseUrl: t.string,
|
|
8
|
-
key: t.string
|
|
9
|
-
});
|
|
10
|
-
const ExternalAuthMetaDataAccount = t.intersection([
|
|
11
|
-
t.type({
|
|
12
|
-
id: t.string,
|
|
13
|
-
externalAccountId: t.string,
|
|
14
|
-
displayName: t.string,
|
|
15
|
-
scopes: t.array(t.string)
|
|
16
|
-
}),
|
|
17
|
-
t.partial({
|
|
18
|
-
avatarUrl: t.string
|
|
19
|
-
})
|
|
20
|
-
]);
|
|
21
|
-
const ExternalAuthMetaData = t.type({
|
|
22
|
-
service: t.string,
|
|
23
|
-
remotes: t.array(Remote),
|
|
24
|
-
accounts: t.array(ExternalAuthMetaDataAccount)
|
|
25
|
-
});
|
|
26
|
-
const XisRequestTokenType = t.intersection([
|
|
27
|
-
t.type({
|
|
28
|
-
id: t.string,
|
|
29
|
-
service: t.string,
|
|
30
|
-
token: t.string
|
|
31
|
-
}),
|
|
32
|
-
t.partial({
|
|
33
|
-
externalAccountId: t.string,
|
|
34
|
-
displayName: t.string,
|
|
35
|
-
avatarUrl: t.union([t.string, t.undefined]),
|
|
36
|
-
scopes: t.array(t.string)
|
|
37
|
-
})
|
|
38
|
-
]);
|
|
39
|
-
exports.LicenseType = t.intersection([
|
|
40
|
-
t.type({
|
|
41
|
-
isActive: t.boolean
|
|
42
|
-
}),
|
|
43
|
-
t.partial({
|
|
44
|
-
billingPeriod: t.union([t.string, t.null]),
|
|
45
|
-
capabilitySet: t.union([t.string, t.null]),
|
|
46
|
-
ccpEntitlementId: t.union([t.string, t.null]),
|
|
47
|
-
ccpEntitlementSlug: t.union([t.string, t.null]),
|
|
48
|
-
isEvaluation: t.union([t.boolean, t.null]),
|
|
49
|
-
subscriptionEndDate: t.union([t.string, t.null]),
|
|
50
|
-
supportEntitlementNumber: t.union([t.string, t.null]),
|
|
51
|
-
trialEndDate: t.union([t.string, t.null]),
|
|
52
|
-
type: t.union([t.string, t.null])
|
|
53
|
-
})
|
|
54
|
-
]);
|
|
55
|
-
const AppContext = t.intersection([
|
|
56
|
-
t.type({
|
|
57
|
-
appId: t.string,
|
|
58
|
-
appVersion: t.string,
|
|
59
|
-
environmentId: t.string,
|
|
60
|
-
environmentType: t.string,
|
|
61
|
-
invocationId: t.string,
|
|
62
|
-
installationId: t.string,
|
|
63
|
-
functionKey: t.string,
|
|
64
|
-
moduleType: t.string,
|
|
65
|
-
moduleKey: t.string
|
|
66
|
-
}),
|
|
67
|
-
t.partial({
|
|
68
|
-
license: exports.LicenseType
|
|
69
|
-
})
|
|
70
|
-
]);
|
|
71
|
-
const MetadataType = t.intersection([
|
|
72
|
-
t.type({
|
|
73
|
-
apiAuth: t.type({
|
|
74
|
-
env: t.string,
|
|
75
|
-
objects: t.string
|
|
76
|
-
}),
|
|
77
|
-
clientId: t.string,
|
|
78
|
-
contextAri: t.string,
|
|
79
|
-
tokens: t.array(XisRequestTokenType),
|
|
80
|
-
appContext: AppContext,
|
|
81
|
-
tracing: t.type({
|
|
82
|
-
traceId: t.string,
|
|
83
|
-
spanId: t.string
|
|
84
|
-
})
|
|
85
|
-
}),
|
|
86
|
-
t.partial({
|
|
87
|
-
aaid: t.string,
|
|
88
|
-
featureFlags: t.array(t.string),
|
|
89
|
-
appToken: t.string,
|
|
90
|
-
proxy: t.intersection([
|
|
91
|
-
t.type({
|
|
92
|
-
token: t.string,
|
|
93
|
-
url: t.string
|
|
94
|
-
}),
|
|
95
|
-
t.partial({
|
|
96
|
-
host: t.string
|
|
97
|
-
})
|
|
98
|
-
]),
|
|
99
|
-
timeout: t.number,
|
|
100
|
-
rms: t.type({
|
|
101
|
-
url: t.string,
|
|
102
|
-
host: t.string
|
|
103
|
-
}),
|
|
104
|
-
limits: t.record(t.string, t.number),
|
|
105
|
-
license: exports.LicenseType,
|
|
106
|
-
fetchAllowList: t.array(t.string),
|
|
107
|
-
externalAuth: t.array(ExternalAuthMetaData)
|
|
108
|
-
})
|
|
109
|
-
]);
|
|
110
|
-
const VariableType = t.type({
|
|
111
|
-
secure: t.boolean,
|
|
112
|
-
key: t.string,
|
|
113
|
-
value: t.union([t.string, t.undefined])
|
|
114
|
-
});
|
|
115
|
-
exports.ExternalRequestBodyType = t.intersection([
|
|
116
|
-
t.type({
|
|
117
|
-
_meta: MetadataType,
|
|
118
|
-
body: t.Dictionary,
|
|
119
|
-
handler: t.string
|
|
120
|
-
}),
|
|
121
|
-
t.partial({
|
|
122
|
-
variables: t.array(VariableType)
|
|
123
|
-
})
|
|
124
|
-
]);
|
|
125
|
-
exports.InvocationType = t.type({
|
|
126
|
-
request: exports.ExternalRequestBodyType,
|
|
127
|
-
ctx: t.type({
|
|
128
|
-
requestId: t.string,
|
|
129
|
-
timeout: t.number,
|
|
130
|
-
traceId: t.string
|
|
131
|
-
})
|
|
132
|
-
});
|
package/out/result.d.ts
CHANGED
package/out/result.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,EAAE,CAAC;IACJ,MAAM,EAAE,MAAM,CAAC;IAGf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE;QACN,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IAEF,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
|
package/out/sandbox/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC"}
|
package/out/sandbox/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./inspector"), exports);
|
|
5
4
|
tslib_1.__exportStar(require("./invocation-event"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./invocation-request"), exports);
|
|
7
5
|
tslib_1.__exportStar(require("./sandbox"), exports);
|
|
@@ -1,63 +1,21 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export declare enum LogLevel {
|
|
4
|
+
DEBUG = 20,
|
|
5
|
+
INFO = 30,
|
|
6
|
+
WARN = 40,
|
|
7
|
+
ERROR = 50,
|
|
8
|
+
FATAL = 60
|
|
9
|
+
}
|
|
5
10
|
declare class InvocationEventEmitter extends EventEmitter {
|
|
6
11
|
}
|
|
7
12
|
export declare const StaticInvocationEventEmitter: InvocationEventEmitter;
|
|
8
13
|
export declare const EVENT_P3_LOG = "p3-log";
|
|
9
|
-
export declare const EVENT_NETWORK_REQUEST_START = "network-request-start";
|
|
10
|
-
export declare const EVENT_NETWORK_REQUEST_FINISH = "network-request-finish";
|
|
11
14
|
export declare type NonEmptyArray = [any, ...any[]];
|
|
12
|
-
export declare function isNonEmptyArray(arr: any[]): arr is NonEmptyArray;
|
|
13
|
-
export interface NetworkStartEventData {
|
|
14
|
-
url: string;
|
|
15
|
-
request: {
|
|
16
|
-
body: ArrayBuffer | null;
|
|
17
|
-
headers: {
|
|
18
|
-
[k: string]: string[];
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export interface NetworkFinishEventData {
|
|
23
|
-
url: string;
|
|
24
|
-
error?: string;
|
|
25
|
-
response?: {
|
|
26
|
-
body: ArrayBuffer;
|
|
27
|
-
headers: {
|
|
28
|
-
[k: string]: string[];
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
export interface NetworkRequestStartEvent {
|
|
33
|
-
invocationId: string;
|
|
34
|
-
hostname: string;
|
|
35
|
-
request: {
|
|
36
|
-
body: ArrayBuffer | null;
|
|
37
|
-
headers: {
|
|
38
|
-
[k: string]: string[];
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export interface NetworkRequestFinishEvent {
|
|
43
|
-
invocationId: string;
|
|
44
|
-
hostname: string;
|
|
45
|
-
error?: string;
|
|
46
|
-
response?: {
|
|
47
|
-
body: ArrayBuffer;
|
|
48
|
-
headers: {
|
|
49
|
-
[k: string]: string[];
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
15
|
export interface P3LogEvent {
|
|
54
16
|
invocationId: string;
|
|
55
17
|
logLevel: number;
|
|
56
18
|
logArguments: NonEmptyArray;
|
|
57
19
|
}
|
|
58
|
-
export declare function getHostname(url: string): string;
|
|
59
|
-
export declare function invokeNetworkRequestStartEvent(invocation: InvocationRequest, networkEvent: NetworkStartEventData): void;
|
|
60
|
-
export declare function invokeNetworkRequestFinishEvent(invocation: InvocationRequest, networkEvent: NetworkFinishEventData): void;
|
|
61
|
-
export declare function p3LogEvent(invocation: InvocationRequest, logLevel: LogLevel, logArguments: NonEmptyArray): void;
|
|
62
20
|
export {};
|
|
63
21
|
//# sourceMappingURL=invocation-event.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invocation-event.d.ts","sourceRoot":"","sources":["../../src/sandbox/invocation-event.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"invocation-event.d.ts","sourceRoot":"","sources":["../../src/sandbox/invocation-event.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,oBAAY,QAAQ;IAClB,KAAK,KAAK;IACV,IAAI,KAAK;IACT,IAAI,KAAK;IACT,KAAK,KAAK;IACV,KAAK,KAAK;CACX;AAED,cAAM,sBAAuB,SAAQ,YAAY;CAAG;AAEpD,eAAO,MAAM,4BAA4B,wBAA+B,CAAC;AAGzE,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,oBAAY,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;AAW5C,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,aAAa,CAAC;CAC7B"}
|
|
@@ -1,57 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.EVENT_P3_LOG = exports.StaticInvocationEventEmitter = exports.LogLevel = void 0;
|
|
4
4
|
const events_1 = require("events");
|
|
5
|
-
|
|
5
|
+
var LogLevel;
|
|
6
|
+
(function (LogLevel) {
|
|
7
|
+
LogLevel[LogLevel["DEBUG"] = 20] = "DEBUG";
|
|
8
|
+
LogLevel[LogLevel["INFO"] = 30] = "INFO";
|
|
9
|
+
LogLevel[LogLevel["WARN"] = 40] = "WARN";
|
|
10
|
+
LogLevel[LogLevel["ERROR"] = 50] = "ERROR";
|
|
11
|
+
LogLevel[LogLevel["FATAL"] = 60] = "FATAL";
|
|
12
|
+
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
|
|
6
13
|
class InvocationEventEmitter extends events_1.EventEmitter {
|
|
7
14
|
}
|
|
8
15
|
exports.StaticInvocationEventEmitter = new InvocationEventEmitter();
|
|
9
16
|
exports.EVENT_P3_LOG = 'p3-log';
|
|
10
|
-
exports.EVENT_NETWORK_REQUEST_START = 'network-request-start';
|
|
11
|
-
exports.EVENT_NETWORK_REQUEST_FINISH = 'network-request-finish';
|
|
12
|
-
function isNonEmptyArray(arr) {
|
|
13
|
-
return arr.length > 0;
|
|
14
|
-
}
|
|
15
|
-
exports.isNonEmptyArray = isNonEmptyArray;
|
|
16
|
-
function getHostname(url) {
|
|
17
|
-
let host;
|
|
18
|
-
try {
|
|
19
|
-
host = new url_1.URL(url).hostname;
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
host = '';
|
|
23
|
-
}
|
|
24
|
-
return host;
|
|
25
|
-
}
|
|
26
|
-
exports.getHostname = getHostname;
|
|
27
|
-
function invokeNetworkRequestStartEvent(invocation, networkEvent) {
|
|
28
|
-
const eventData = {
|
|
29
|
-
invocationId: invocation.getInvocationId(),
|
|
30
|
-
hostname: getHostname(networkEvent.url),
|
|
31
|
-
request: {
|
|
32
|
-
body: networkEvent.request.body,
|
|
33
|
-
headers: networkEvent.request.headers
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
exports.StaticInvocationEventEmitter.emit(exports.EVENT_NETWORK_REQUEST_START, eventData);
|
|
37
|
-
}
|
|
38
|
-
exports.invokeNetworkRequestStartEvent = invokeNetworkRequestStartEvent;
|
|
39
|
-
function invokeNetworkRequestFinishEvent(invocation, networkEvent) {
|
|
40
|
-
const eventData = {
|
|
41
|
-
invocationId: invocation.getInvocationId(),
|
|
42
|
-
hostname: getHostname(networkEvent.url),
|
|
43
|
-
response: networkEvent.response,
|
|
44
|
-
error: networkEvent.error
|
|
45
|
-
};
|
|
46
|
-
exports.StaticInvocationEventEmitter.emit(exports.EVENT_NETWORK_REQUEST_FINISH, eventData);
|
|
47
|
-
}
|
|
48
|
-
exports.invokeNetworkRequestFinishEvent = invokeNetworkRequestFinishEvent;
|
|
49
|
-
function p3LogEvent(invocation, logLevel, logArguments) {
|
|
50
|
-
const eventData = {
|
|
51
|
-
invocationId: invocation.getInvocationId(),
|
|
52
|
-
logLevel,
|
|
53
|
-
logArguments
|
|
54
|
-
};
|
|
55
|
-
exports.StaticInvocationEventEmitter.emit(exports.EVENT_P3_LOG, eventData);
|
|
56
|
-
}
|
|
57
|
-
exports.p3LogEvent = p3LogEvent;
|
package/out/sandbox/sandbox.d.ts
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExternalRequestBody } from '../request';
|
|
2
2
|
import { InvocationResult } from '../result';
|
|
3
|
-
import { LimitsTracker } from '../limits/tracker';
|
|
4
|
-
import { XenInvocationRequest } from './invocation-request';
|
|
5
3
|
export declare type SandboxConfig = {
|
|
6
4
|
modName: string;
|
|
7
5
|
appPath: string;
|
|
8
6
|
handler: string;
|
|
9
7
|
timeout?: number;
|
|
10
|
-
isolateMemory: number;
|
|
11
8
|
debugPort?: number;
|
|
12
9
|
};
|
|
13
|
-
export interface FunctionEvent {
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
}
|
|
16
|
-
export declare type FunctionContext = any;
|
|
17
|
-
export declare type FunctionResult = any;
|
|
18
10
|
export interface Sandbox {
|
|
19
11
|
name: string;
|
|
20
|
-
execute(
|
|
12
|
+
execute(request: ExternalRequestBody): Promise<InvocationResult>;
|
|
21
13
|
stop(): void;
|
|
22
14
|
}
|
|
23
15
|
//# sourceMappingURL=sandbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,oBAAY,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjE,IAAI,IAAI,IAAI,CAAC;CACd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/runtime",
|
|
3
|
-
"version": "6.0.0-next.
|
|
3
|
+
"version": "6.0.0-next.1",
|
|
4
4
|
"description": "A Node.js runtime for Atlassian app functions",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -15,39 +15,7 @@
|
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/jest": "^29.5.12",
|
|
17
17
|
"@types/node": "20.19.0",
|
|
18
|
-
"
|
|
19
|
-
"@types/ws": "^7.4.7",
|
|
20
|
-
"jest": "^29.7.0",
|
|
21
|
-
"jest-junit": "^16.0.0",
|
|
22
|
-
"nock": "13.5.4",
|
|
23
|
-
"tmp": "^0.2.3",
|
|
24
|
-
"ts-jest": "29.1.1",
|
|
25
|
-
"ts-loader": "^9.5.1",
|
|
26
|
-
"typescript": "4.8.4"
|
|
27
|
-
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"@forge/util": "1.4.9",
|
|
30
|
-
"fp-ts": "^2.16.2",
|
|
31
|
-
"io-ts": "^2.2.21",
|
|
32
|
-
"io-ts-reporters": "^2.0.1",
|
|
33
|
-
"node-fetch": "2.7.0",
|
|
34
|
-
"tslib": "^2.6.2",
|
|
35
|
-
"ws": "^7.5.9",
|
|
36
|
-
"yaml": "^2.3.4"
|
|
37
|
-
},
|
|
38
|
-
"jest": {
|
|
39
|
-
"preset": "ts-jest",
|
|
40
|
-
"testEnvironment": "node",
|
|
41
|
-
"roots": [
|
|
42
|
-
"src"
|
|
43
|
-
],
|
|
44
|
-
"reporters": [
|
|
45
|
-
"default",
|
|
46
|
-
"jest-junit"
|
|
47
|
-
]
|
|
48
|
-
},
|
|
49
|
-
"jest-junit": {
|
|
50
|
-
"outputDirectory": "./test-reports"
|
|
18
|
+
"jest": "^29.7.0"
|
|
51
19
|
},
|
|
52
20
|
"publishConfig": {
|
|
53
21
|
"registry": "https://packages.atlassian.com/api/npm/npm-public/"
|
package/out/app-manifest.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import * as t from 'io-ts';
|
|
2
|
-
declare const bearerMethodShorthands: t.UnionC<[t.LiteralC<"authorization-header">, t.LiteralC<"form-encoded">, t.LiteralC<"uri-query">]>;
|
|
3
|
-
export declare type BearerMethods = t.TypeOf<typeof bearerMethodShorthands>;
|
|
4
|
-
declare const bearerMethodOptions: t.IntersectionC<[t.TypeC<{
|
|
5
|
-
type: t.UnionC<[t.LiteralC<"authorization-header">, t.LiteralC<"form-encoded">, t.LiteralC<"uri-query">]>;
|
|
6
|
-
}>, t.PartialC<{
|
|
7
|
-
parameter: t.StringC;
|
|
8
|
-
prefix: t.StringC;
|
|
9
|
-
}>]>;
|
|
10
|
-
declare const bearerMethodFields: t.UnionC<[t.UnionC<[t.LiteralC<"authorization-header">, t.LiteralC<"form-encoded">, t.LiteralC<"uri-query">]>, t.IntersectionC<[t.TypeC<{
|
|
11
|
-
type: t.UnionC<[t.LiteralC<"authorization-header">, t.LiteralC<"form-encoded">, t.LiteralC<"uri-query">]>;
|
|
12
|
-
}>, t.PartialC<{
|
|
13
|
-
parameter: t.StringC;
|
|
14
|
-
prefix: t.StringC;
|
|
15
|
-
}>]>]>;
|
|
16
|
-
export declare type BearerMethodOptions = t.TypeOf<typeof bearerMethodOptions>;
|
|
17
|
-
export declare type DefaultBearerMethodParameters = {
|
|
18
|
-
parameter: string;
|
|
19
|
-
prefix: string;
|
|
20
|
-
};
|
|
21
|
-
export declare type BearerMethodFields = t.TypeOf<typeof bearerMethodFields>;
|
|
22
|
-
declare const AuthProviderCheckedType: t.TypeC<{
|
|
23
|
-
key: t.StringC;
|
|
24
|
-
bearerMethod: t.UnionC<[t.UnionC<[t.LiteralC<"authorization-header">, t.LiteralC<"form-encoded">, t.LiteralC<"uri-query">]>, t.IntersectionC<[t.TypeC<{
|
|
25
|
-
type: t.UnionC<[t.LiteralC<"authorization-header">, t.LiteralC<"form-encoded">, t.LiteralC<"uri-query">]>;
|
|
26
|
-
}>, t.PartialC<{
|
|
27
|
-
parameter: t.StringC;
|
|
28
|
-
prefix: t.StringC;
|
|
29
|
-
}>]>]>;
|
|
30
|
-
remotes: t.ArrayC<t.StringC>;
|
|
31
|
-
}>;
|
|
32
|
-
export declare type AuthProviderType = t.TypeOf<typeof AuthProviderCheckedType>;
|
|
33
|
-
declare const AppManifestType: t.IntersectionC<[t.TypeC<{
|
|
34
|
-
app: t.TypeC<{
|
|
35
|
-
id: t.StringC;
|
|
36
|
-
}>;
|
|
37
|
-
}>, t.PartialC<{
|
|
38
|
-
egress: t.ArrayC<t.StringC>;
|
|
39
|
-
remotes: t.ArrayC<t.TypeC<{
|
|
40
|
-
key: t.StringC;
|
|
41
|
-
baseUrl: t.Type<string, string, unknown>;
|
|
42
|
-
}>>;
|
|
43
|
-
providers: t.TypeC<{
|
|
44
|
-
auth: t.ArrayC<t.TypeC<{
|
|
45
|
-
key: t.StringC;
|
|
46
|
-
bearerMethod: t.UnionC<[t.UnionC<[t.LiteralC<"authorization-header">, t.LiteralC<"form-encoded">, t.LiteralC<"uri-query">]>, t.IntersectionC<[t.TypeC<{
|
|
47
|
-
type: t.UnionC<[t.LiteralC<"authorization-header">, t.LiteralC<"form-encoded">, t.LiteralC<"uri-query">]>;
|
|
48
|
-
}>, t.PartialC<{
|
|
49
|
-
parameter: t.StringC;
|
|
50
|
-
prefix: t.StringC;
|
|
51
|
-
}>]>]>;
|
|
52
|
-
remotes: t.ArrayC<t.StringC>;
|
|
53
|
-
}>>;
|
|
54
|
-
}>;
|
|
55
|
-
}>]>;
|
|
56
|
-
export interface EgressControl {
|
|
57
|
-
getEgressAllowlist(): string[];
|
|
58
|
-
}
|
|
59
|
-
export declare type AppManifestDefinition = t.TypeOf<typeof AppManifestType>;
|
|
60
|
-
export declare class AppManifest implements EgressControl {
|
|
61
|
-
static FILE_NAME: string;
|
|
62
|
-
static fromFile(filePath: string): Promise<AppManifest>;
|
|
63
|
-
manifest: AppManifestDefinition;
|
|
64
|
-
constructor(manifest: AppManifestDefinition);
|
|
65
|
-
getHostForRemote(remote: string): undefined | string;
|
|
66
|
-
getDefaultRemoteForProvider(provider: string): undefined | string;
|
|
67
|
-
getExternalAuthProviderConfig(provider: string): undefined | AuthProviderType;
|
|
68
|
-
getEgressAllowlist(): string[];
|
|
69
|
-
}
|
|
70
|
-
export {};
|
|
71
|
-
//# sourceMappingURL=app-manifest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-manifest.d.ts","sourceRoot":"","sources":["../src/app-manifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAK3B,QAAA,MAAM,sBAAsB,qGAI1B,CAAC;AAEH,oBAAY,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEpE,QAAA,MAAM,mBAAmB;;;;;IAQvB,CAAC;AAEH,QAAA,MAAM,kBAAkB;;;;;MAAyD,CAAC;AAElF,oBAAY,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEvE,oBAAY,6BAA6B,GAAG;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAErE,QAAA,MAAM,uBAAuB;;;;;;;;;EAI3B,CAAC;AAEH,oBAAY,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AA4BxE,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;IAAyE,CAAC;AAE/F,MAAM,WAAW,aAAa;IAC5B,kBAAkB,IAAI,MAAM,EAAE,CAAC;CAChC;AAED,oBAAY,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAErE,qBAAa,WAAY,YAAW,aAAa;IAC/C,OAAc,SAAS,SAAkB;WACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAO7D,QAAQ,EAAE,qBAAqB,CAAC;gBAE3B,QAAQ,EAAE,qBAAqB;IAQpC,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM;IAKpD,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM;IASjE,6BAA6B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,gBAAgB;IAI7E,kBAAkB,IAAI,MAAM,EAAE;CAGtC"}
|
package/out/app-manifest.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppManifest = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const t = tslib_1.__importStar(require("io-ts"));
|
|
7
|
-
const yaml_1 = tslib_1.__importDefault(require("yaml"));
|
|
8
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
|
-
const url_1 = require("url");
|
|
10
|
-
const bearerMethodShorthands = t.union([
|
|
11
|
-
t.literal('authorization-header'),
|
|
12
|
-
t.literal('form-encoded'),
|
|
13
|
-
t.literal('uri-query')
|
|
14
|
-
]);
|
|
15
|
-
const bearerMethodOptions = t.intersection([
|
|
16
|
-
t.type({
|
|
17
|
-
type: bearerMethodShorthands
|
|
18
|
-
}),
|
|
19
|
-
t.partial({
|
|
20
|
-
parameter: t.string,
|
|
21
|
-
prefix: t.string
|
|
22
|
-
})
|
|
23
|
-
]);
|
|
24
|
-
const bearerMethodFields = t.union([bearerMethodShorthands, bearerMethodOptions]);
|
|
25
|
-
const AuthProviderCheckedType = t.type({
|
|
26
|
-
key: t.string,
|
|
27
|
-
bearerMethod: bearerMethodFields,
|
|
28
|
-
remotes: t.array(t.string)
|
|
29
|
-
});
|
|
30
|
-
const urlString = new t.Type('string', (input) => typeof input === 'string' && new url_1.URL(input) && true, (input, context) => (typeof input === 'string' ? t.success(input) : t.failure(input, context)), t.identity);
|
|
31
|
-
const AppManifestOptionalFields = t.partial({
|
|
32
|
-
egress: t.array(t.string),
|
|
33
|
-
remotes: t.array(t.type({
|
|
34
|
-
key: t.string,
|
|
35
|
-
baseUrl: urlString
|
|
36
|
-
})),
|
|
37
|
-
providers: t.type({
|
|
38
|
-
auth: t.array(AuthProviderCheckedType)
|
|
39
|
-
})
|
|
40
|
-
});
|
|
41
|
-
const AppManifestRequiredFields = t.type({
|
|
42
|
-
app: t.type({
|
|
43
|
-
id: t.string
|
|
44
|
-
})
|
|
45
|
-
});
|
|
46
|
-
const AppManifestType = t.intersection([AppManifestRequiredFields, AppManifestOptionalFields]);
|
|
47
|
-
class AppManifest {
|
|
48
|
-
static FILE_NAME = 'manifest.yml';
|
|
49
|
-
static async fromFile(filePath) {
|
|
50
|
-
const fullPath = path_1.default.join(filePath, AppManifest.FILE_NAME);
|
|
51
|
-
const manifestContents = (0, fs_1.readFileSync)(fullPath, 'utf-8');
|
|
52
|
-
const manifest = yaml_1.default.parse(manifestContents);
|
|
53
|
-
return new AppManifest(manifest);
|
|
54
|
-
}
|
|
55
|
-
manifest;
|
|
56
|
-
constructor(manifest) {
|
|
57
|
-
if (!AppManifestType.is(manifest)) {
|
|
58
|
-
throw new Error('invalid manifest');
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
this.manifest = manifest;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
getHostForRemote(remote) {
|
|
65
|
-
const found = this.manifest.remotes?.find(({ key }) => key === remote);
|
|
66
|
-
return found?.baseUrl;
|
|
67
|
-
}
|
|
68
|
-
getDefaultRemoteForProvider(provider) {
|
|
69
|
-
const providerConfig = this.getExternalAuthProviderConfig(provider);
|
|
70
|
-
const remotes = providerConfig?.remotes;
|
|
71
|
-
if (remotes && remotes.length > 0) {
|
|
72
|
-
return remotes[0];
|
|
73
|
-
}
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
getExternalAuthProviderConfig(provider) {
|
|
77
|
-
return this.manifest.providers?.auth.find((v) => v.key === provider);
|
|
78
|
-
}
|
|
79
|
-
getEgressAllowlist() {
|
|
80
|
-
return this.manifest.egress || [];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.AppManifest = AppManifest;
|
package/out/config.d.ts
DELETED
package/out/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,QAAQ,CAAC;CAChB"}
|
package/out/config.js
DELETED
package/out/context.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { RuntimeAPIConfig } from './config';
|
|
2
|
-
import { License } from './request';
|
|
3
|
-
export interface InstallationContext {
|
|
4
|
-
projectId?: string;
|
|
5
|
-
workspaceId?: string;
|
|
6
|
-
installContext: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function createInstallationContext(cfg: RuntimeAPIConfig): InstallationContext;
|
|
9
|
-
export interface Principal {
|
|
10
|
-
accountId: string;
|
|
11
|
-
}
|
|
12
|
-
export declare function isAccountIdDefined(accountId?: string): accountId is string;
|
|
13
|
-
export declare function createPrincipal(cfg: RuntimeAPIConfig): Principal | undefined;
|
|
14
|
-
export interface LicenseContext {
|
|
15
|
-
license: License;
|
|
16
|
-
}
|
|
17
|
-
export declare function createLicenseContext(cfg: RuntimeAPIConfig): LicenseContext | undefined;
|
|
18
|
-
export declare function setupRequestContext(cfg: RuntimeAPIConfig): {
|
|
19
|
-
projectId?: string | undefined;
|
|
20
|
-
workspaceId?: string | undefined;
|
|
21
|
-
installContext: string;
|
|
22
|
-
license?: ({
|
|
23
|
-
isActive: boolean;
|
|
24
|
-
} & {
|
|
25
|
-
billingPeriod?: string | null | undefined;
|
|
26
|
-
capabilitySet?: string | null | undefined;
|
|
27
|
-
ccpEntitlementId?: string | null | undefined;
|
|
28
|
-
ccpEntitlementSlug?: string | null | undefined;
|
|
29
|
-
isEvaluation?: boolean | null | undefined;
|
|
30
|
-
subscriptionEndDate?: string | null | undefined;
|
|
31
|
-
supportEntitlementNumber?: string | null | undefined;
|
|
32
|
-
trialEndDate?: string | null | undefined;
|
|
33
|
-
type?: string | null | undefined;
|
|
34
|
-
}) | undefined;
|
|
35
|
-
principal: Principal | undefined;
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=context.d.ts.map
|
package/out/context.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAMD,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,gBAAgB,GAAG,mBAAmB,CAcpF;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,kBAAkB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,IAAI,MAAM,CAE1E;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,gBAAgB,GAAG,SAAS,GAAG,SAAS,CAG5E;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,gBAAgB,GAAG,cAAc,GAAG,SAAS,CAMtF;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;EAMxD"}
|
package/out/context.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupRequestContext = exports.createLicenseContext = exports.createPrincipal = exports.isAccountIdDefined = exports.createInstallationContext = void 0;
|
|
4
|
-
const ari_1 = require("@forge/util/packages/ari");
|
|
5
|
-
function wrapWithBrackets(value) {
|
|
6
|
-
return value !== undefined ? `{${value}}` : undefined;
|
|
7
|
-
}
|
|
8
|
-
function createInstallationContext(cfg) {
|
|
9
|
-
const { contextAri } = cfg.meta;
|
|
10
|
-
const ari = ari_1.AnyAri.parse(contextAri);
|
|
11
|
-
if (ari.resourceType === 'project') {
|
|
12
|
-
return { projectId: ari.resourceId, installContext: contextAri };
|
|
13
|
-
}
|
|
14
|
-
if (ari.resourceType === 'workspace') {
|
|
15
|
-
let workspaceId = ari.resourceId;
|
|
16
|
-
if (ari.resourceOwner === 'bitbucket') {
|
|
17
|
-
workspaceId = wrapWithBrackets(ari.resourceId);
|
|
18
|
-
}
|
|
19
|
-
return { workspaceId, installContext: contextAri };
|
|
20
|
-
}
|
|
21
|
-
return { installContext: contextAri };
|
|
22
|
-
}
|
|
23
|
-
exports.createInstallationContext = createInstallationContext;
|
|
24
|
-
function isAccountIdDefined(accountId) {
|
|
25
|
-
return accountId !== undefined && accountId !== 'undefined';
|
|
26
|
-
}
|
|
27
|
-
exports.isAccountIdDefined = isAccountIdDefined;
|
|
28
|
-
function createPrincipal(cfg) {
|
|
29
|
-
const accountId = cfg.meta.aaid;
|
|
30
|
-
return isAccountIdDefined(accountId) ? { accountId } : undefined;
|
|
31
|
-
}
|
|
32
|
-
exports.createPrincipal = createPrincipal;
|
|
33
|
-
function createLicenseContext(cfg) {
|
|
34
|
-
const { license } = cfg.meta;
|
|
35
|
-
if (license) {
|
|
36
|
-
const { isActive, ...rest } = license;
|
|
37
|
-
return { license: { isActive: isActive ?? false, ...rest } };
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.createLicenseContext = createLicenseContext;
|
|
41
|
-
function setupRequestContext(cfg) {
|
|
42
|
-
return {
|
|
43
|
-
principal: createPrincipal(cfg),
|
|
44
|
-
...createLicenseContext(cfg),
|
|
45
|
-
...createInstallationContext(cfg)
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
exports.setupRequestContext = setupRequestContext;
|