@forge/bundler 4.11.1-next.2 → 4.11.1-next.20
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 +153 -0
- package/out/config/node.d.ts +1 -0
- package/out/config/node.d.ts.map +1 -1
- package/out/config/node.js +17 -17
- package/out/stubs/http-sandbox-impl.d.ts +6 -2
- package/out/stubs/http-sandbox-impl.d.ts.map +1 -1
- package/out/stubs/http-sandbox-impl.js +26 -12
- package/out/stubs/http-sandbox.d.ts.map +1 -1
- package/out/stubs/http-sandbox.js +1 -2
- package/out/tsconfig-interactor.d.ts.map +1 -1
- package/out/webpack.d.ts.map +1 -1
- package/out/webpack.js +12 -4
- package/package.json +11 -10
- package/out/stubs/console.d.ts +0 -8
- package/out/stubs/console.d.ts.map +0 -1
- package/out/stubs/console.js +0 -98
- package/out/stubs/http-node.d.ts +0 -3
- package/out/stubs/http-node.d.ts.map +0 -1
- package/out/stubs/http-node.js +0 -160
- package/out/stubs/http-shared.d.ts +0 -15
- package/out/stubs/http-shared.d.ts.map +0 -1
- package/out/stubs/http-shared.js +0 -23
- package/out/stubs/log-events.d.ts +0 -6
- package/out/stubs/log-events.d.ts.map +0 -1
- package/out/stubs/log-events.js +0 -37
- package/out/stubs/wrapper.d.ts +0 -2
- package/out/stubs/wrapper.d.ts.map +0 -1
- package/out/stubs/wrapper.js +0 -76
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,158 @@
|
|
|
1
1
|
# @forge/bundler
|
|
2
2
|
|
|
3
|
+
## 4.11.1-next.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [63f3f2db]
|
|
8
|
+
- @forge/node-runtime@0.1.1-next.5
|
|
9
|
+
|
|
10
|
+
## 4.11.1-next.19
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 4941db4a: Fix HTTP error handling in sandbox
|
|
15
|
+
|
|
16
|
+
## 4.11.1-next.18
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 8c4ec99f: Bumping dependencies via Renovate:
|
|
21
|
+
|
|
22
|
+
- @atlassian/xen-test-util
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [8c4ec99f]
|
|
25
|
+
- @forge/cli-shared@3.17.2-next.8
|
|
26
|
+
- @forge/lint@3.6.5-next.9
|
|
27
|
+
|
|
28
|
+
## 4.11.1-next.17
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- a9e43a70: Don't include runtime in sandbox wrapper
|
|
33
|
+
- Updated dependencies [a9e43a70]
|
|
34
|
+
- @forge/node-runtime@0.1.1-next.4
|
|
35
|
+
|
|
36
|
+
## 4.11.1-next.16
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- b9806172: Updated logging headers
|
|
41
|
+
- Updated dependencies [b9806172]
|
|
42
|
+
- @forge/runtime@5.0.0-next.5
|
|
43
|
+
- @forge/node-runtime@0.1.1-next.3
|
|
44
|
+
|
|
45
|
+
## 4.11.1-next.15
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Updated dependencies [39a3fe44]
|
|
50
|
+
- @forge/runtime@5.0.0-next.4
|
|
51
|
+
- @forge/node-runtime@0.1.1-next.2
|
|
52
|
+
|
|
53
|
+
## 4.11.1-next.14
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- Updated dependencies [439098ca]
|
|
58
|
+
- @forge/cli-shared@3.17.2-next.7
|
|
59
|
+
- @forge/lint@3.6.5-next.8
|
|
60
|
+
- @forge/api@2.18.5-next.2
|
|
61
|
+
- @forge/node-runtime@0.1.1-next.1
|
|
62
|
+
|
|
63
|
+
## 4.11.1-next.13
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- cd2b8e51: Bundle wrapper ahead of compilation for node runtime
|
|
68
|
+
- Updated dependencies [cd2b8e51]
|
|
69
|
+
- @forge/node-runtime@0.1.1-next.0
|
|
70
|
+
- @forge/runtime@5.0.0-next.3
|
|
71
|
+
|
|
72
|
+
## 4.11.1-next.12
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- @forge/cli-shared@3.17.2-next.6
|
|
77
|
+
- @forge/lint@3.6.5-next.7
|
|
78
|
+
|
|
79
|
+
## 4.11.1-next.11
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- Updated dependencies [ba548d9]
|
|
84
|
+
- @forge/runtime@4.4.7-next.2
|
|
85
|
+
- @forge/api@2.18.5-next.1
|
|
86
|
+
|
|
87
|
+
## 4.11.1-next.10
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [035116d]
|
|
92
|
+
- @forge/api@2.18.5-next.0
|
|
93
|
+
- @forge/cli-shared@3.17.2-next.5
|
|
94
|
+
- @forge/lint@3.6.5-next.6
|
|
95
|
+
- @forge/runtime@4.4.7-next.1
|
|
96
|
+
|
|
97
|
+
## 4.11.1-next.9
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- Updated dependencies [cdf28f27]
|
|
102
|
+
- @forge/cli-shared@3.17.2-next.4
|
|
103
|
+
- @forge/lint@3.6.5-next.5
|
|
104
|
+
|
|
105
|
+
## 4.11.1-next.8
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- Updated dependencies [30713ea9]
|
|
110
|
+
- @forge/cli-shared@3.17.2-next.3
|
|
111
|
+
- @forge/lint@3.6.5-next.4
|
|
112
|
+
|
|
113
|
+
## 4.11.1-next.7
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- 4be20514: Bumping dependencies via Renovate:
|
|
118
|
+
|
|
119
|
+
- eslint-plugin-prettier
|
|
120
|
+
|
|
121
|
+
## 4.11.1-next.6
|
|
122
|
+
|
|
123
|
+
### Patch Changes
|
|
124
|
+
|
|
125
|
+
- 4769ae06: Bumping dependencies via Renovate:
|
|
126
|
+
|
|
127
|
+
- eslint-config-prettier
|
|
128
|
+
|
|
129
|
+
## 4.11.1-next.5
|
|
130
|
+
|
|
131
|
+
### Patch Changes
|
|
132
|
+
|
|
133
|
+
- 1d4230e6: Bumping dependencies via Renovate:
|
|
134
|
+
|
|
135
|
+
- eslint
|
|
136
|
+
- @types/eslint
|
|
137
|
+
|
|
138
|
+
- Updated dependencies [1d4230e6]
|
|
139
|
+
- @forge/lint@3.6.5-next.3
|
|
140
|
+
|
|
141
|
+
## 4.11.1-next.4
|
|
142
|
+
|
|
143
|
+
### Patch Changes
|
|
144
|
+
|
|
145
|
+
- @forge/cli-shared@3.17.2-next.2
|
|
146
|
+
- @forge/lint@3.6.5-next.2
|
|
147
|
+
|
|
148
|
+
## 4.11.1-next.3
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- 89e0c881: Use \_HANDLER to determine functions to expose on Node runtime
|
|
153
|
+
- Updated dependencies [89e0c881]
|
|
154
|
+
- @forge/runtime@4.4.7-next.0
|
|
155
|
+
|
|
3
156
|
## 4.11.1-next.2
|
|
4
157
|
|
|
5
158
|
### Patch Changes
|
package/out/config/node.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommonWebpackConfig, ConfigBuilder, FunctionsEntryPoint } from './common';
|
|
2
2
|
export declare const NODE_WEBPACK_CONFIG_NAME = "node-runtime";
|
|
3
|
+
export declare const NODE_WEBPACK_USER_CODE_DIR = "bundled";
|
|
3
4
|
export declare const getNodeRuntimeBuildConfig: (entrypoints: FunctionsEntryPoint[], config: ConfigBuilder) => CommonWebpackConfig;
|
|
4
5
|
//# sourceMappingURL=node.d.ts.map
|
package/out/config/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/config/node.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,mBAAmB,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/config/node.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EAGpB,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,0BAA0B,YAAY,CAAC;AAEpD,eAAO,MAAM,yBAAyB,gBACvB,mBAAmB,EAAE,UAC1B,aAAa,KACpB,mBA6CF,CAAC"}
|
package/out/config/node.js
CHANGED
|
@@ -1,31 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNodeRuntimeBuildConfig = exports.NODE_WEBPACK_CONFIG_NAME = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.getNodeRuntimeBuildConfig = exports.NODE_WEBPACK_USER_CODE_DIR = exports.NODE_WEBPACK_CONFIG_NAME = void 0;
|
|
4
|
+
const node_runtime_1 = require("@forge/node-runtime");
|
|
5
5
|
const common_1 = require("./common");
|
|
6
|
+
const promises_1 = require("fs/promises");
|
|
6
7
|
exports.NODE_WEBPACK_CONFIG_NAME = 'node-runtime';
|
|
8
|
+
exports.NODE_WEBPACK_USER_CODE_DIR = 'bundled';
|
|
7
9
|
const getNodeRuntimeBuildConfig = (entrypoints, config) => {
|
|
8
10
|
const webpackConfig = (0, common_1.getCommonWebpackConfig)(entrypoints, config);
|
|
9
|
-
const wrapperPath = (0, common_1.resolveStubPath)('wrapper');
|
|
10
11
|
const newEntries = {};
|
|
11
12
|
for (const [entryKey, entryPath] of Object.entries(webpackConfig.entry)) {
|
|
12
|
-
newEntries[
|
|
13
|
-
newEntries[entryKey] = wrapperPath;
|
|
13
|
+
newEntries[`${exports.NODE_WEBPACK_USER_CODE_DIR}/${entryKey}`] = entryPath;
|
|
14
14
|
}
|
|
15
15
|
webpackConfig.entry = newEntries;
|
|
16
16
|
webpackConfig.target = 'node18';
|
|
17
|
-
const defineExports = ({ filename }) => {
|
|
18
|
-
const entryName = filename.replace(/\.js$/, '');
|
|
19
|
-
const entrypoint = entrypoints.find((e) => e.name === entryName);
|
|
20
|
-
if (entrypoint) {
|
|
21
|
-
return `__BUNDLED_EXPORTS__ = ${JSON.stringify(entrypoint.functions)};`;
|
|
22
|
-
}
|
|
23
|
-
return '';
|
|
24
|
-
};
|
|
25
|
-
webpackConfig.plugins.push(new webpack_1.BannerPlugin({
|
|
26
|
-
banner: defineExports,
|
|
27
|
-
raw: true
|
|
28
|
-
}));
|
|
29
17
|
webpackConfig.name = exports.NODE_WEBPACK_CONFIG_NAME;
|
|
30
18
|
webpackConfig.module.rules.push({
|
|
31
19
|
test: /\.m?js$/,
|
|
@@ -33,6 +21,18 @@ const getNodeRuntimeBuildConfig = (entrypoints, config) => {
|
|
|
33
21
|
fullySpecified: false
|
|
34
22
|
}
|
|
35
23
|
});
|
|
24
|
+
webpackConfig.plugins.push({
|
|
25
|
+
apply: (compiler) => {
|
|
26
|
+
compiler.hooks.make.tapPromise('AfterEmitPlugin', async (compilation) => {
|
|
27
|
+
const { RawSource } = compiler.webpack.sources;
|
|
28
|
+
const wrapper = await (0, promises_1.readFile)(node_runtime_1.WRAPPER_PATH, 'utf-8');
|
|
29
|
+
const source = new RawSource(wrapper);
|
|
30
|
+
for (const entrypoint of entrypoints) {
|
|
31
|
+
compilation.emitAsset(`${entrypoint.name}.js`, source);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
36
|
return webpackConfig;
|
|
37
37
|
};
|
|
38
38
|
exports.getNodeRuntimeBuildConfig = getNodeRuntimeBuildConfig;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import { IncomingMessage } from 'http';
|
|
3
5
|
import { RequestOptions } from 'https';
|
|
4
6
|
import { Writable } from 'readable-stream';
|
|
5
7
|
import { URL } from 'url';
|
|
6
8
|
import { FetchOptions } from '@forge/api';
|
|
7
|
-
|
|
9
|
+
type HttpCallback = (res: IncomingMessage) => void;
|
|
10
|
+
type HttpArg = RequestOptions | string | URL | HttpCallback;
|
|
11
|
+
export declare const isHttpRequestOptions: (options: HttpArg) => options is RequestOptions;
|
|
8
12
|
interface ChainableOptions {
|
|
9
13
|
timeout?: number;
|
|
10
14
|
headers: {
|
|
@@ -14,7 +18,7 @@ interface ChainableOptions {
|
|
|
14
18
|
export declare class Request extends Writable {
|
|
15
19
|
private reqBody;
|
|
16
20
|
private chainableOptions;
|
|
17
|
-
constructor(options: RequestOptions | string | URL, callback?:
|
|
21
|
+
constructor(options: RequestOptions | string | URL, callback?: HttpCallback);
|
|
18
22
|
setHeader(name: string, value: string): Request;
|
|
19
23
|
setTimeout(value: number, callback?: () => void): Request;
|
|
20
24
|
private fetch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-sandbox-impl.d.ts","sourceRoot":"","sources":["../../src/stubs/http-sandbox-impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-sandbox-impl.d.ts","sourceRoot":"","sources":["../../src/stubs/http-sandbox-impl.ts"],"names":[],"mappings":";;;AAGA,OAAO,EAAuB,eAAe,EAAE,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAY,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAe,YAAY,EAAS,MAAM,YAAY,CAAC;AAE9D,KAAK,YAAY,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;AAEnD,KAAK,OAAO,GAAG,cAAc,GAAG,MAAM,GAAG,GAAG,GAAG,YAAY,CAAC;AAQ5D,eAAO,MAAM,oBAAoB,YAAa,OAAO,8BACJ,CAAC;AAYlD,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH;AAED,qBAAa,OAAQ,SAAQ,QAAQ;IACnC,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,YAAY;IAapE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAM/C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO;YAQlD,KAAK;IAqBZ,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI;IAe3F,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM;IAiBvE,MAAM,CAAC,uBAAuB,CAC5B,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EACtC,gBAAgB,EAAE,gBAAgB,GACjC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,YAAY,CAAA;KAAE;IAuBtC,KAAK;CAGN"}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Request = void 0;
|
|
3
|
+
exports.Request = exports.isHttpRequestOptions = void 0;
|
|
4
4
|
const readable_stream_1 = require("readable-stream");
|
|
5
5
|
const api_1 = require("@forge/api");
|
|
6
|
-
const
|
|
6
|
+
const isCallback = (options) => typeof options === 'function';
|
|
7
|
+
const isString = (options) => typeof options === 'string';
|
|
8
|
+
const isURL = (options) => typeof options === 'object' && options.constructor.name === 'URL';
|
|
9
|
+
const isStringOrURL = (options) => isString(options) || isURL(options);
|
|
10
|
+
const isHttpRequestOptions = (options) => !isStringOrURL(options) && !isCallback(options);
|
|
11
|
+
exports.isHttpRequestOptions = isHttpRequestOptions;
|
|
12
|
+
function formatHttpRequestArgsToUrl(options) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const protocol = 'https:';
|
|
15
|
+
const auth = options.auth ? `${options.auth}@` : '';
|
|
16
|
+
const host = (_a = options.hostname) !== null && _a !== void 0 ? _a : options.host;
|
|
17
|
+
const port = options.port ? `:${options.port}` : '';
|
|
18
|
+
const path = (_b = options.path) !== null && _b !== void 0 ? _b : '/';
|
|
19
|
+
return `${protocol}//${auth}${host}${port}${path}`;
|
|
20
|
+
}
|
|
7
21
|
class Request extends readable_stream_1.Writable {
|
|
8
22
|
constructor(options, callback) {
|
|
9
23
|
super();
|
|
@@ -27,25 +41,25 @@ class Request extends readable_stream_1.Writable {
|
|
|
27
41
|
}
|
|
28
42
|
return this;
|
|
29
43
|
}
|
|
30
|
-
fetch(options) {
|
|
44
|
+
async fetch(options) {
|
|
31
45
|
const { url, init } = Request.convertToForgeFetchArgs(options, this.chainableOptions);
|
|
32
46
|
if (init.method && init.method !== 'HEAD' && init.method !== 'GET') {
|
|
33
47
|
init.body = Buffer.concat(this.reqBody);
|
|
34
48
|
}
|
|
35
|
-
|
|
36
|
-
.
|
|
49
|
+
try {
|
|
50
|
+
const response = await (0, api_1.fetch)(url, init);
|
|
37
51
|
const content = await response.arrayBuffer();
|
|
38
52
|
const transformedAPIResponse = new Response(content, response);
|
|
39
53
|
this.emit('response', transformedAPIResponse);
|
|
40
|
-
}
|
|
41
|
-
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
42
56
|
if (err.message.startsWith('network timeout')) {
|
|
43
57
|
this.emit('timeout');
|
|
44
58
|
}
|
|
45
59
|
else {
|
|
46
60
|
this.emit('error', err);
|
|
47
61
|
}
|
|
48
|
-
}
|
|
62
|
+
}
|
|
49
63
|
}
|
|
50
64
|
_write(chunk, encoding, callback) {
|
|
51
65
|
try {
|
|
@@ -65,15 +79,15 @@ class Request extends readable_stream_1.Writable {
|
|
|
65
79
|
}
|
|
66
80
|
}
|
|
67
81
|
static urlFromFetchArgs(options) {
|
|
68
|
-
if (
|
|
82
|
+
if (isString(options)) {
|
|
69
83
|
return options;
|
|
70
84
|
}
|
|
71
|
-
else if (
|
|
85
|
+
else if (isURL(options)) {
|
|
72
86
|
return options.toString();
|
|
73
87
|
}
|
|
74
88
|
else {
|
|
75
89
|
try {
|
|
76
|
-
return (
|
|
90
|
+
return formatHttpRequestArgsToUrl(options);
|
|
77
91
|
}
|
|
78
92
|
catch (err) {
|
|
79
93
|
console.error('Unable to make request with unrecognised URL options:', options);
|
|
@@ -83,7 +97,7 @@ class Request extends readable_stream_1.Writable {
|
|
|
83
97
|
}
|
|
84
98
|
static convertToForgeFetchArgs(options, chainableOptions) {
|
|
85
99
|
const url = Request.urlFromFetchArgs(options);
|
|
86
|
-
if (
|
|
100
|
+
if (isStringOrURL(options)) {
|
|
87
101
|
return { url, init: chainableOptions };
|
|
88
102
|
}
|
|
89
103
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-sandbox.d.ts","sourceRoot":"","sources":["../../src/stubs/http-sandbox.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"http-sandbox.d.ts","sourceRoot":"","sources":["../../src/stubs/http-sandbox.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAwB,MAAM,qBAAqB,CAAC;AAEpE,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAElH;AAED,wBAAgB,GAAG,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAO9G;AAID,qBAAa,KAAK;gBACJ,OAAO,EAAE,YAAY;CAOlC"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Agent = exports.get = exports.request = void 0;
|
|
4
|
-
const http_shared_1 = require("./http-shared");
|
|
5
4
|
const http_sandbox_impl_1 = require("./http-sandbox-impl");
|
|
6
5
|
function request(options, callback) {
|
|
7
6
|
return new http_sandbox_impl_1.Request(options, callback);
|
|
8
7
|
}
|
|
9
8
|
exports.request = request;
|
|
10
9
|
function get(options, callback) {
|
|
11
|
-
if ((0,
|
|
10
|
+
if ((0, http_sandbox_impl_1.isHttpRequestOptions)(options)) {
|
|
12
11
|
options = Object.assign(Object.assign({}, options), { method: 'GET' });
|
|
13
12
|
}
|
|
14
13
|
const result = new http_sandbox_impl_1.Request(options, callback);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsconfig-interactor.d.ts","sourceRoot":"","sources":["../src/tsconfig-interactor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAIrD,eAAO,MAAM,QAAQ,kBAAkB,CAAC;AAExC,eAAO,MAAM,oBAAoB,QAA2C,CAAC;AAE7E,qBAAa,kBAAkB;
|
|
1
|
+
{"version":3,"file":"tsconfig-interactor.d.ts","sourceRoot":"","sources":["../src/tsconfig-interactor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAIrD,eAAO,MAAM,QAAQ,kBAAkB,CAAC;AAExC,eAAO,MAAM,oBAAoB,QAA2C,CAAC;AAE7E,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,MAAM;IAGhC,eAAe,IAAI,MAAM;CAKjC"}
|
package/out/webpack.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,GAAG,EAAU,MAAM,OAAO,CAAC;AACxD,OAAO,OAAO,EAAE,EAAE,QAAQ,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAG5E,OAAO,EACL,OAAO,EAGP,OAAO,EAEP,aAAa,EACb,aAAa,EACb,YAAY,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,gBAAgB,EAGhB,gBAAgB,EAGjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA2B,UAAU,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAKtG,OAAO,EAAE,UAAU,EAAE,CAAC;AAQtB,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAC7B,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,SAAS,GAC/B,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAkChC;
|
|
1
|
+
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,GAAG,EAAU,MAAM,OAAO,CAAC;AACxD,OAAO,OAAO,EAAE,EAAE,QAAQ,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAG5E,OAAO,EACL,OAAO,EAGP,OAAO,EAEP,aAAa,EACb,aAAa,EACb,YAAY,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,gBAAgB,EAGhB,gBAAgB,EAGjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA2B,UAAU,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAKtG,OAAO,EAAE,UAAU,EAAE,CAAC;AAQtB,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAC7B,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,SAAS,GAC/B,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAkChC;AAWD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,GAAG,aAAa,CAmB9F;AAED,UAAU,eAAe;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,WAAW,kBAAmB,aAAa,YAAY,eAAe,KAAG,QAOrF,CAAC;AA6BF,eAAO,MAAM,SAAS,YAEZ,UAAU,+EAGjB,QAAQ,IAAI,CA+Bd,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,OAwBnB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,SAAS,UAAU,GAAG,UAAU,EAC9D,cAAc,EAAE,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,aAAa,KAAK,mBAAmB,GACvF,OAAO,CAAC,EAAE,CAAC,CA8Bb;AAED,eAAO,MAAM,aAAa,EAAE,OAAuD,CAAC;AACpF,eAAO,MAAM,UAAU,EAAE,OAAO,CAAC,mBAAmB,CAA4C,CAAC;AAEjG,eAAO,MAAM,cAAc,EAAE,aAkB5B,CAAC"}
|
package/out/webpack.js
CHANGED
|
@@ -42,16 +42,24 @@ function handleWebpackCompilationResult(logger, err, stats) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
exports.handleWebpackCompilationResult = handleWebpackCompilationResult;
|
|
45
|
+
function tryReadSourceMapSync(fileSystem, sourceMap, entryName) {
|
|
46
|
+
try {
|
|
47
|
+
sourceMap[entryName] = readMemoryFileSync(fileSystem, `${entryName}.js.map`);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
}
|
|
51
|
+
}
|
|
45
52
|
function getInMemoryBundle(config, fileSystem) {
|
|
46
53
|
const output = {}, sourceMap = {};
|
|
47
54
|
const outputFileSystem = fileSystem || compilerOutputFileSystem;
|
|
48
55
|
for (const name in config.entry) {
|
|
49
56
|
output[name] = readMemoryFileSync(outputFileSystem, `/${name}.js`).toString();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
if (config.name === node_1.NODE_WEBPACK_CONFIG_NAME && name.startsWith(node_1.NODE_WEBPACK_USER_CODE_DIR + '/')) {
|
|
58
|
+
const wrapperName = name.slice(node_1.NODE_WEBPACK_USER_CODE_DIR.length + 1);
|
|
59
|
+
output[wrapperName] = readMemoryFileSync(outputFileSystem, `/${wrapperName}.js`).toString();
|
|
60
|
+
tryReadSourceMapSync(outputFileSystem, sourceMap, wrapperName);
|
|
54
61
|
}
|
|
62
|
+
tryReadSourceMapSync(outputFileSystem, sourceMap, name);
|
|
55
63
|
}
|
|
56
64
|
return { output, sourceMap };
|
|
57
65
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bundler",
|
|
3
|
-
"version": "4.11.1-next.
|
|
3
|
+
"version": "4.11.1-next.20",
|
|
4
4
|
"description": "Default bundler for Forge apps",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Atlassian",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"@babel/plugin-transform-optional-chaining": "^7.22.10",
|
|
20
20
|
"@babel/plugin-transform-react-jsx": "^7.22.5",
|
|
21
21
|
"@babel/preset-typescript": "^7.22.5",
|
|
22
|
-
"@forge/api": "2.18.
|
|
22
|
+
"@forge/api": "2.18.5-next.2",
|
|
23
23
|
"@forge/babel-plugin-transform-ui": "1.1.6",
|
|
24
|
-
"@forge/cli-shared": "3.17.2-next.
|
|
25
|
-
"@forge/lint": "3.6.5-next.
|
|
26
|
-
"@forge/runtime": "
|
|
24
|
+
"@forge/cli-shared": "3.17.2-next.8",
|
|
25
|
+
"@forge/lint": "3.6.5-next.9",
|
|
26
|
+
"@forge/node-runtime": "0.1.1-next.5",
|
|
27
27
|
"@forge/util": "1.3.1",
|
|
28
28
|
"assert": "^2.0.0",
|
|
29
29
|
"babel-loader": "^8.3.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"whatwg-url": "^7.1.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@atlassian/xen-test-util": "^
|
|
59
|
+
"@atlassian/xen-test-util": "^3.0.3",
|
|
60
60
|
"@types/jest": "^29.5.3",
|
|
61
61
|
"@types/node": "14.18.54",
|
|
62
62
|
"@types/react": "^17.0.64",
|
|
@@ -64,10 +64,11 @@
|
|
|
64
64
|
"@types/webpack-bundle-analyzer": "^4.6.0",
|
|
65
65
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
66
66
|
"@typescript-eslint/parser": "^5.62.0",
|
|
67
|
-
"eslint": "^
|
|
68
|
-
"eslint-config-prettier": "^
|
|
69
|
-
"eslint-plugin-prettier": "^
|
|
70
|
-
"prettier": "
|
|
67
|
+
"eslint": "^8.47.0",
|
|
68
|
+
"eslint-config-prettier": "^9.0.0",
|
|
69
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
70
|
+
"prettier": "3.0.2",
|
|
71
|
+
"@forge/runtime": "5.0.0-next.6"
|
|
71
72
|
},
|
|
72
73
|
"engines": {
|
|
73
74
|
"node": ">=12.13.1"
|
package/out/stubs/console.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ConsoleMethod, P3LogEvent, LogHeader, HeadedLogLine } from '@forge/runtime';
|
|
2
|
-
export declare function emitTunnelEvent(event: P3LogEvent): void;
|
|
3
|
-
export declare function emitLogEvent(event: HeadedLogLine): void;
|
|
4
|
-
export declare function forgeConsole(consoleMethod: ConsoleMethod, header: LogHeader): (...rawData: unknown[]) => void;
|
|
5
|
-
export declare function replaceConsole(header: LogHeader): void;
|
|
6
|
-
export declare function restoreConsole(): void;
|
|
7
|
-
export declare function sendLogCache(): Promise<void>;
|
|
8
|
-
//# sourceMappingURL=console.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../src/stubs/console.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,aAAa,EACb,UAAU,EAEV,SAAS,EAET,aAAa,EAEd,MAAM,gBAAgB,CAAC;AAWxB,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAEvD;AAOD,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAEvD;AA6BD,wBAAgB,YAAY,CAAC,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,mCAY3E;AAMD,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,QAI/C;AAED,wBAAgB,cAAc,SAI7B;AAED,wBAAsB,YAAY,kBAwCjC"}
|
package/out/stubs/console.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendLogCache = exports.restoreConsole = exports.replaceConsole = exports.forgeConsole = exports.emitLogEvent = exports.emitTunnelEvent = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const api_1 = require("@forge/api");
|
|
6
|
-
const runtime_1 = require("@forge/runtime");
|
|
7
|
-
const util_1 = require("util");
|
|
8
|
-
const https = tslib_1.__importStar(require("https"));
|
|
9
|
-
let logEventCache = [];
|
|
10
|
-
function emitTunnelEvent(event) {
|
|
11
|
-
process.stdout.write(JSON.stringify(event) + '\n');
|
|
12
|
-
}
|
|
13
|
-
exports.emitTunnelEvent = emitTunnelEvent;
|
|
14
|
-
function emitLogEvent(event) {
|
|
15
|
-
logEventCache.push(event);
|
|
16
|
-
}
|
|
17
|
-
exports.emitLogEvent = emitLogEvent;
|
|
18
|
-
function customConsole(logLevel, header) {
|
|
19
|
-
return (...rawData) => {
|
|
20
|
-
var _a;
|
|
21
|
-
const msg = (0, util_1.format)((_a = rawData[0]) !== null && _a !== void 0 ? _a : '');
|
|
22
|
-
const rest = rawData.slice(1).map((val) => (0, util_1.format)(val));
|
|
23
|
-
const invocationId = (0, api_1.getRuntime)().lambdaContext.awsRequestId;
|
|
24
|
-
if (global.__forge_tunnel__) {
|
|
25
|
-
const logEventData = { invocationId, logLevel, logArguments: [msg, ...rest] };
|
|
26
|
-
emitTunnelEvent(logEventData);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
const logLine = Object.assign(Object.assign({}, header), { type: runtime_1.LogType.LOG, id: invocationId, P: 3, ts: Date.now(), lvl: logLevel, msg, '*': rest });
|
|
30
|
-
emitLogEvent(logLine);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function forgeConsole(consoleMethod, header) {
|
|
35
|
-
switch (consoleMethod) {
|
|
36
|
-
case 'debug':
|
|
37
|
-
return customConsole(runtime_1.LogLevel.DEBUG, header);
|
|
38
|
-
case 'warn':
|
|
39
|
-
return customConsole(runtime_1.LogLevel.WARN, header);
|
|
40
|
-
case 'error':
|
|
41
|
-
return customConsole(runtime_1.LogLevel.ERROR, header);
|
|
42
|
-
default:
|
|
43
|
-
return customConsole(runtime_1.LogLevel.INFO, header);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.forgeConsole = forgeConsole;
|
|
47
|
-
const originalConsole = new Map(runtime_1.CONSOLE_METHODS.map((method) => [method, global.console[method]]));
|
|
48
|
-
function replaceConsole(header) {
|
|
49
|
-
for (const method of runtime_1.CONSOLE_METHODS) {
|
|
50
|
-
global.console[method] = forgeConsole(method, header);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.replaceConsole = replaceConsole;
|
|
54
|
-
function restoreConsole() {
|
|
55
|
-
for (const method of runtime_1.CONSOLE_METHODS) {
|
|
56
|
-
global.console[method] = originalConsole.get(method);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.restoreConsole = restoreConsole;
|
|
60
|
-
async function sendLogCache() {
|
|
61
|
-
var _a;
|
|
62
|
-
const options = {
|
|
63
|
-
method: 'POST',
|
|
64
|
-
protocol: 'https',
|
|
65
|
-
host: 'logs',
|
|
66
|
-
path: '',
|
|
67
|
-
headers: {
|
|
68
|
-
'Content-Type': 'application/json'
|
|
69
|
-
},
|
|
70
|
-
agent: 'FORGE_PRODUCT_REQUEST'
|
|
71
|
-
};
|
|
72
|
-
if (logEventCache.length > 0) {
|
|
73
|
-
try {
|
|
74
|
-
const req = https.request(options);
|
|
75
|
-
req.write(JSON.stringify(logEventCache));
|
|
76
|
-
const result = await new Promise((resolve, reject) => {
|
|
77
|
-
req.on('response', ({ statusCode, statusMessage }) => resolve({
|
|
78
|
-
statusCode,
|
|
79
|
-
statusMessage
|
|
80
|
-
}));
|
|
81
|
-
req.on('error', reject);
|
|
82
|
-
req.end();
|
|
83
|
-
});
|
|
84
|
-
if (result.statusCode === 200) {
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
process.stderr.write(`Error returned from proxy when sending logs: status code ${result.statusCode}\n`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
process.stderr.write(`Sending logs to proxy ${(_a = error.stack) !== null && _a !== void 0 ? _a : error}\n`);
|
|
92
|
-
}
|
|
93
|
-
finally {
|
|
94
|
-
logEventCache = [];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
exports.sendLogCache = sendLogCache;
|
package/out/stubs/http-node.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-node.d.ts","sourceRoot":"","sources":["../../src/stubs/http-node.ts"],"names":[],"mappings":"AAsRA,wBAAgB,YAAY,SAG3B;AAED,wBAAgB,YAAY,SAG3B"}
|
package/out/stubs/http-node.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.restoreHttps = exports.replaceHttps = void 0;
|
|
4
|
-
const http_1 = require("http");
|
|
5
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
6
|
-
const url_1 = require("url");
|
|
7
|
-
const http_shared_1 = require("./http-shared");
|
|
8
|
-
const api_1 = require("@forge/api");
|
|
9
|
-
const https = require('https');
|
|
10
|
-
const FORGE_PROXY_UPSTREAM_LATENCY_HEADER = 'forge-proxy-upstream-latency';
|
|
11
|
-
const FORGE_PROXY_RELATIVE_LOCATION_HEADER = 'forge-proxy-relative-location';
|
|
12
|
-
const REDIRECT_STATUS = new Set([300, 301, 302, 303, 307, 308]);
|
|
13
|
-
const originalHttpsRequest = https.request;
|
|
14
|
-
const originalHttpsGet = https.get;
|
|
15
|
-
function parseArgs(args) {
|
|
16
|
-
const result = {
|
|
17
|
-
options: {}
|
|
18
|
-
};
|
|
19
|
-
if (args.length > 0 && (0, http_shared_1.isStringOrURL)(args[0])) {
|
|
20
|
-
const url = (0, http_shared_1.isString)(args[0]) ? new url_1.URL(args[0]) : args[0];
|
|
21
|
-
result.options = (0, url_1.urlToHttpOptions)(url);
|
|
22
|
-
args.shift();
|
|
23
|
-
}
|
|
24
|
-
if (args.length > 0 && (0, http_shared_1.isRequestOptions)(args[0])) {
|
|
25
|
-
result.options = Object.assign(result.options, args[0]);
|
|
26
|
-
args.shift();
|
|
27
|
-
}
|
|
28
|
-
if (args.length > 0 && (0, http_shared_1.isCallback)(args[0])) {
|
|
29
|
-
result.callback = args[0];
|
|
30
|
-
args.shift();
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
const AUTH_PROVIDERS = ['app', 'user', 'none'];
|
|
35
|
-
function isAuthProvider(provider) {
|
|
36
|
-
return AUTH_PROVIDERS.includes(provider);
|
|
37
|
-
}
|
|
38
|
-
const REMOTE_APIS = ['jira', 'confluence', 'stargate', 'bitbucket'];
|
|
39
|
-
function isRemoteAPI(remote) {
|
|
40
|
-
return REMOTE_APIS.includes(remote);
|
|
41
|
-
}
|
|
42
|
-
function getProxyPath(args) {
|
|
43
|
-
switch (args.type) {
|
|
44
|
-
case 'egress':
|
|
45
|
-
return '/egress';
|
|
46
|
-
case 'logs':
|
|
47
|
-
return '/logs';
|
|
48
|
-
case 'fpp':
|
|
49
|
-
return `/fpp/provider/${args.provider}/remote/${args.remote}`;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const providerToMetric = {
|
|
53
|
-
app: 'asApp',
|
|
54
|
-
user: 'asUser'
|
|
55
|
-
};
|
|
56
|
-
const remoteToMetric = {
|
|
57
|
-
jira: 'requestJira',
|
|
58
|
-
confluence: 'requestConfluence',
|
|
59
|
-
bitbucket: 'requestBitbucket',
|
|
60
|
-
stargate: 'requestAtlassian'
|
|
61
|
-
};
|
|
62
|
-
const METRICS_TAGS = { proxy: 'true' };
|
|
63
|
-
function getMetricsName(args) {
|
|
64
|
-
switch (args.type) {
|
|
65
|
-
case 'logs':
|
|
66
|
-
return 'api.log';
|
|
67
|
-
case 'egress':
|
|
68
|
-
return 'api.fetch';
|
|
69
|
-
case 'fpp':
|
|
70
|
-
const { provider, remote } = args;
|
|
71
|
-
if (provider === 'none') {
|
|
72
|
-
return `api.${remoteToMetric[remote]}`;
|
|
73
|
-
}
|
|
74
|
-
return `api.${providerToMetric[provider]}.${remoteToMetric[remote]}`;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function getSingleString(values) {
|
|
78
|
-
if (typeof values === 'string') {
|
|
79
|
-
return values;
|
|
80
|
-
}
|
|
81
|
-
if (Array.isArray(values)) {
|
|
82
|
-
return values[0];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function getSingleHeader(response, header) {
|
|
86
|
-
return getSingleString(response.headers[header]);
|
|
87
|
-
}
|
|
88
|
-
function request(...args) {
|
|
89
|
-
var _a, _b;
|
|
90
|
-
const { options, callback } = parseArgs(args);
|
|
91
|
-
let proxyArgs = { type: 'egress' };
|
|
92
|
-
const host = (_a = options.host) !== null && _a !== void 0 ? _a : options.hostname;
|
|
93
|
-
if ((options === null || options === void 0 ? void 0 : options.agent) === 'FORGE_PRODUCT_REQUEST') {
|
|
94
|
-
delete options.agent;
|
|
95
|
-
if (host && isRemoteAPI(host)) {
|
|
96
|
-
const authorization = getSingleString((_b = options.headers) === null || _b === void 0 ? void 0 : _b.authorization);
|
|
97
|
-
if (authorization === null || authorization === void 0 ? void 0 : authorization.startsWith('Forge ')) {
|
|
98
|
-
const [, provider] = authorization.split(' ');
|
|
99
|
-
if (isAuthProvider(provider)) {
|
|
100
|
-
proxyArgs = { type: 'fpp', provider, remote: host };
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else if (host === 'logs') {
|
|
105
|
-
proxyArgs = { type: 'logs' };
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
const { metrics, proxy } = (0, api_1.getRuntime)();
|
|
109
|
-
const metricsName = getMetricsName(proxyArgs);
|
|
110
|
-
const headers = Object.assign(Object.assign({}, options.headers), { 'forge-proxy-authorization': `Bearer ${proxy.token}` });
|
|
111
|
-
if (proxy.host) {
|
|
112
|
-
headers['Host'] = proxy.host;
|
|
113
|
-
}
|
|
114
|
-
switch (proxyArgs.type) {
|
|
115
|
-
case 'egress':
|
|
116
|
-
headers['forge-proxy-target'] = (0, http_shared_1.formatUrl)(options);
|
|
117
|
-
break;
|
|
118
|
-
case 'fpp':
|
|
119
|
-
headers['forge-proxy-target'] = options.path;
|
|
120
|
-
break;
|
|
121
|
-
case 'logs':
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
const proxyOptions = Object.assign(Object.assign(Object.assign({}, options), (0, url_1.urlToHttpOptions)(new url_1.URL(`${proxy.url}${getProxyPath(proxyArgs)}`))), { headers });
|
|
125
|
-
metrics.counter(metricsName, METRICS_TAGS).incr();
|
|
126
|
-
const originalRequest = proxyOptions.protocol === 'http:' ? http_1.request : originalHttpsRequest;
|
|
127
|
-
const requestStart = perf_hooks_1.performance.now();
|
|
128
|
-
return originalRequest(proxyOptions, (response) => {
|
|
129
|
-
const requestEnd = perf_hooks_1.performance.now();
|
|
130
|
-
metrics.timing(metricsName, METRICS_TAGS).set(requestEnd - requestStart);
|
|
131
|
-
const upstreamLatencyHeader = getSingleHeader(response, FORGE_PROXY_UPSTREAM_LATENCY_HEADER);
|
|
132
|
-
if (upstreamLatencyHeader !== undefined) {
|
|
133
|
-
const proxyUpstreamLatency = parseInt(upstreamLatencyHeader);
|
|
134
|
-
metrics.timing('proxy-success-overhead', METRICS_TAGS).set(requestEnd - requestStart - proxyUpstreamLatency);
|
|
135
|
-
}
|
|
136
|
-
if (response.statusCode && REDIRECT_STATUS.has(response.statusCode)) {
|
|
137
|
-
const relativeLocation = getSingleHeader(response, FORGE_PROXY_RELATIVE_LOCATION_HEADER);
|
|
138
|
-
if (relativeLocation) {
|
|
139
|
-
response.headers['location'] = `https://${host}${relativeLocation}`;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
callback === null || callback === void 0 ? void 0 : callback(response);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
function get(...args) {
|
|
146
|
-
const { options, callback } = parseArgs(args);
|
|
147
|
-
const result = request(Object.assign(Object.assign({}, options), { method: 'GET' }), ...(callback ? [callback] : []));
|
|
148
|
-
result.end();
|
|
149
|
-
return result;
|
|
150
|
-
}
|
|
151
|
-
function replaceHttps() {
|
|
152
|
-
https.request = request;
|
|
153
|
-
https.get = get;
|
|
154
|
-
}
|
|
155
|
-
exports.replaceHttps = replaceHttps;
|
|
156
|
-
function restoreHttps() {
|
|
157
|
-
https.request = originalHttpsRequest;
|
|
158
|
-
https.get = originalHttpsGet;
|
|
159
|
-
}
|
|
160
|
-
exports.restoreHttps = restoreHttps;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
import { IncomingMessage } from 'http';
|
|
5
|
-
import { RequestOptions } from 'https';
|
|
6
|
-
import { URL } from 'url';
|
|
7
|
-
export type Callback = (res: IncomingMessage) => void;
|
|
8
|
-
export type Arg = RequestOptions | string | URL | Callback;
|
|
9
|
-
export declare const isCallback: (options: Arg) => options is Callback;
|
|
10
|
-
export declare const isString: (options: Arg) => options is string;
|
|
11
|
-
export declare const isURL: (options: Arg) => options is URL;
|
|
12
|
-
export declare const isStringOrURL: (options: Arg) => options is string | URL;
|
|
13
|
-
export declare const isRequestOptions: (options: Arg) => options is RequestOptions;
|
|
14
|
-
export declare function formatUrl(options: RequestOptions): string;
|
|
15
|
-
//# sourceMappingURL=http-shared.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-shared.d.ts","sourceRoot":"","sources":["../../src/stubs/http-shared.ts"],"names":[],"mappings":";;;AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;AAEtD,MAAM,MAAM,GAAG,GAAG,cAAc,GAAG,MAAM,GAAG,GAAG,GAAG,QAAQ,CAAC;AAE3D,eAAO,MAAM,UAAU,YAAa,GAAG,wBAAuD,CAAC;AAC/F,eAAO,MAAM,QAAQ,YAAa,GAAG,sBAAmD,CAAC;AACzF,eAAO,MAAM,KAAK,YAAa,GAAG,mBACiC,CAAC;AAEpE,eAAO,MAAM,aAAa,YAAa,GAAG,4BAAiE,CAAC;AAE5G,eAAO,MAAM,gBAAgB,YAAa,GAAG,8BACI,CAAC;AAElD,wBAAgB,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAQzD"}
|
package/out/stubs/http-shared.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatUrl = exports.isRequestOptions = exports.isStringOrURL = exports.isURL = exports.isString = exports.isCallback = void 0;
|
|
4
|
-
const isCallback = (options) => typeof options === 'function';
|
|
5
|
-
exports.isCallback = isCallback;
|
|
6
|
-
const isString = (options) => typeof options === 'string';
|
|
7
|
-
exports.isString = isString;
|
|
8
|
-
const isURL = (options) => typeof options === 'object' && options.constructor.name === 'URL';
|
|
9
|
-
exports.isURL = isURL;
|
|
10
|
-
const isStringOrURL = (options) => (0, exports.isString)(options) || (0, exports.isURL)(options);
|
|
11
|
-
exports.isStringOrURL = isStringOrURL;
|
|
12
|
-
const isRequestOptions = (options) => !(0, exports.isStringOrURL)(options) && !(0, exports.isCallback)(options);
|
|
13
|
-
exports.isRequestOptions = isRequestOptions;
|
|
14
|
-
function formatUrl(options) {
|
|
15
|
-
var _a, _b;
|
|
16
|
-
const protocol = 'https:';
|
|
17
|
-
const auth = options.auth ? `${options.auth}@` : '';
|
|
18
|
-
const host = (_a = options.hostname) !== null && _a !== void 0 ? _a : options.host;
|
|
19
|
-
const port = options.port ? `:${options.port}` : '';
|
|
20
|
-
const path = (_b = options.path) !== null && _b !== void 0 ? _b : '/';
|
|
21
|
-
return `${protocol}//${auth}${host}${port}${path}`;
|
|
22
|
-
}
|
|
23
|
-
exports.formatUrl = formatUrl;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ExternalRequestBody, LogHeader } from '@forge/runtime';
|
|
2
|
-
export declare const AWS_EXECUTION_ENV_PREFIX = "AWS_Lambda_";
|
|
3
|
-
export declare const RUNTIME_NAME_FALLBACK = "node";
|
|
4
|
-
export declare function getRuntimeName(): string;
|
|
5
|
-
export declare function invocationHeaderLogs(lambdaEvent: ExternalRequestBody): LogHeader;
|
|
6
|
-
//# sourceMappingURL=log-events.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log-events.d.ts","sourceRoot":"","sources":["../../src/stubs/log-events.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAW,MAAM,gBAAgB,CAAC;AAEzE,eAAO,MAAM,wBAAwB,gBAAgB,CAAC;AACtD,eAAO,MAAM,qBAAqB,SAAS,CAAC;AAE5C,wBAAgB,cAAc,IAAI,MAAM,CAavC;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,mBAAmB,GAAG,SAAS,CAiBhF"}
|
package/out/stubs/log-events.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invocationHeaderLogs = exports.getRuntimeName = exports.RUNTIME_NAME_FALLBACK = exports.AWS_EXECUTION_ENV_PREFIX = void 0;
|
|
4
|
-
const api_1 = require("@forge/api");
|
|
5
|
-
const runtime_1 = require("@forge/runtime");
|
|
6
|
-
exports.AWS_EXECUTION_ENV_PREFIX = 'AWS_Lambda_';
|
|
7
|
-
exports.RUNTIME_NAME_FALLBACK = 'node';
|
|
8
|
-
function getRuntimeName() {
|
|
9
|
-
const awsRuntime = process.env.AWS_EXECUTION_ENV;
|
|
10
|
-
if (!awsRuntime) {
|
|
11
|
-
return exports.RUNTIME_NAME_FALLBACK;
|
|
12
|
-
}
|
|
13
|
-
if (awsRuntime.startsWith(exports.AWS_EXECUTION_ENV_PREFIX)) {
|
|
14
|
-
return awsRuntime.substring(exports.AWS_EXECUTION_ENV_PREFIX.length);
|
|
15
|
-
}
|
|
16
|
-
return awsRuntime;
|
|
17
|
-
}
|
|
18
|
-
exports.getRuntimeName = getRuntimeName;
|
|
19
|
-
function invocationHeaderLogs(lambdaEvent) {
|
|
20
|
-
const { featureFlags, contextAri, appContext, tracing } = lambdaEvent === null || lambdaEvent === void 0 ? void 0 : lambdaEvent._meta;
|
|
21
|
-
const { appId, environmentId, appVersion, functionKey, moduleKey, moduleType } = appContext !== null && appContext !== void 0 ? appContext : {};
|
|
22
|
-
return {
|
|
23
|
-
id: (0, api_1.getRuntime)().lambdaContext.awsRequestId,
|
|
24
|
-
type: runtime_1.LogType.HEADER,
|
|
25
|
-
appId,
|
|
26
|
-
environmentId,
|
|
27
|
-
appVersion,
|
|
28
|
-
installationContext: contextAri,
|
|
29
|
-
functionKey,
|
|
30
|
-
moduleType,
|
|
31
|
-
moduleKey,
|
|
32
|
-
b3: `${tracing.traceId}-${tracing.spanId}`,
|
|
33
|
-
featureFlags: featureFlags || [],
|
|
34
|
-
runtime: getRuntimeName()
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
exports.invocationHeaderLogs = invocationHeaderLogs;
|
package/out/stubs/wrapper.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../src/stubs/wrapper.ts"],"names":[],"mappings":""}
|
package/out/stubs/wrapper.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a, _b;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const api_1 = require("@forge/api");
|
|
5
|
-
const runtime_1 = require("@forge/runtime");
|
|
6
|
-
const console_1 = require("./console");
|
|
7
|
-
const http_node_1 = require("./http-node");
|
|
8
|
-
const log_events_1 = require("./log-events");
|
|
9
|
-
const wrappedFilename = __filename.replace(/\/[^/]+.js$/, (name) => '/bundled' + name);
|
|
10
|
-
const realRequire = eval('require');
|
|
11
|
-
if (!realRequire) {
|
|
12
|
-
throw new Error(`Unexpected require: ${realRequire}`);
|
|
13
|
-
}
|
|
14
|
-
const bundledExports = eval('__BUNDLED_EXPORTS__');
|
|
15
|
-
if (!bundledExports || bundledExports.length === 0) {
|
|
16
|
-
throw new Error('Expected to find __BUNDLED_EXPORTS__ replaced by Webpack configuration.');
|
|
17
|
-
}
|
|
18
|
-
const adapter = (name) => {
|
|
19
|
-
return async (lambdaEvent, lambdaContext) => {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
const event = lambdaEvent.body;
|
|
22
|
-
const context = (0, runtime_1.setupRequestContext)({ meta: lambdaEvent._meta, handler: lambdaEvent.handler });
|
|
23
|
-
const metricsCollector = new runtime_1.MetricsCollector(new runtime_1.InMemoryMetrics({ runtime: 'nodejs' }));
|
|
24
|
-
const metrics = metricsCollector.metrics();
|
|
25
|
-
const rms = lambdaEvent._meta.rms;
|
|
26
|
-
const runtime = Object.assign(Object.assign({ proxy: lambdaEvent._meta.proxy, contextAri: lambdaEvent._meta.contextAri, appContext: lambdaEvent._meta.appContext, allowedEgress: (_a = lambdaEvent._meta.fetchAllowList) !== null && _a !== void 0 ? _a : [], lambdaContext: lambdaContext, tracing: lambdaEvent._meta.tracing, aaid: lambdaEvent._meta.aaid }, (rms && { rms })), { metrics });
|
|
27
|
-
global.__forge_runtime__ = runtime;
|
|
28
|
-
for (const { key, value } of (_b = lambdaEvent.variables) !== null && _b !== void 0 ? _b : []) {
|
|
29
|
-
process.env[key] = value;
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
const header = (0, log_events_1.invocationHeaderLogs)(lambdaEvent);
|
|
33
|
-
(0, console_1.replaceConsole)(header);
|
|
34
|
-
(0, http_node_1.replaceHttps)();
|
|
35
|
-
const timer = metrics.timing('invoke').measure();
|
|
36
|
-
const bundled = realRequire(wrappedFilename);
|
|
37
|
-
let result;
|
|
38
|
-
try {
|
|
39
|
-
try {
|
|
40
|
-
result = await bundled[name](event, context);
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
console.error(err);
|
|
44
|
-
throw err;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
await (0, console_1.sendLogCache)();
|
|
49
|
-
timer.stop();
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
success: true,
|
|
53
|
-
body: result,
|
|
54
|
-
metrics: metricsCollector.collectMetrics()
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
const errorName = (0, api_1.isForgePlatformError)(err) ? err.name : api_1.FUNCTION_ERR;
|
|
59
|
-
return {
|
|
60
|
-
success: false,
|
|
61
|
-
error: {
|
|
62
|
-
errorMessage: err.message,
|
|
63
|
-
errorType: errorName,
|
|
64
|
-
isHostedCodeError: (0, api_1.isHostedCodeError)(errorName),
|
|
65
|
-
stack: (err.stack || '').split('\n'),
|
|
66
|
-
serviceKey: err.serviceKey
|
|
67
|
-
},
|
|
68
|
-
metrics: metricsCollector.collectMetrics()
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
(_b = (_a = process).setSourceMapsEnabled) === null || _b === void 0 ? void 0 : _b.call(_a, true);
|
|
74
|
-
for (const ownExport of bundledExports) {
|
|
75
|
-
exports[ownExport] = adapter(ownExport);
|
|
76
|
-
}
|