@forge/cache 0.6.0-next.2 → 0.7.0-next.0
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/out/__test__/cache.test.js +7 -21
- package/out/cache.d.ts +2 -2
- package/out/cache.d.ts.map +1 -1
- package/out/cache.js +5 -1
- package/package.json +2 -2
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
3
5
|
const api_1 = require("@forge/api");
|
|
4
6
|
const cache_1 = require("../cache");
|
|
7
|
+
jest.mock('node-fetch');
|
|
8
|
+
const fetchMock = node_fetch_1.default;
|
|
5
9
|
describe('connect', () => {
|
|
6
|
-
let fetchMock;
|
|
7
10
|
describe('v1', () => {
|
|
8
11
|
beforeEach(() => {
|
|
9
|
-
|
|
12
|
+
jest.resetAllMocks();
|
|
13
|
+
jest.clearAllMocks();
|
|
10
14
|
global['api'] = { requestRmsStore: fetchMock };
|
|
11
15
|
});
|
|
12
16
|
afterAll(() => {
|
|
@@ -18,12 +22,7 @@ describe('connect', () => {
|
|
|
18
22
|
});
|
|
19
23
|
});
|
|
20
24
|
describe('v2', () => {
|
|
21
|
-
let fetchMock;
|
|
22
|
-
let orgFetch;
|
|
23
25
|
beforeEach(() => {
|
|
24
|
-
fetchMock = jest.fn();
|
|
25
|
-
orgFetch = global['fetch'];
|
|
26
|
-
global['fetch'] = fetchMock;
|
|
27
26
|
global['__forge_runtime__'] = {
|
|
28
27
|
proxy: {
|
|
29
28
|
token: 'token',
|
|
@@ -39,9 +38,6 @@ describe('connect', () => {
|
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
40
|
});
|
|
42
|
-
afterAll(() => {
|
|
43
|
-
global['fetch'] = orgFetch;
|
|
44
|
-
});
|
|
45
41
|
it('chooses the v2 fetch based on runtime', async () => {
|
|
46
42
|
const cacheClient = (0, cache_1.connect)();
|
|
47
43
|
await cacheClient['client']('asdf');
|
|
@@ -50,16 +46,6 @@ describe('connect', () => {
|
|
|
50
46
|
});
|
|
51
47
|
});
|
|
52
48
|
describe('createFetch', () => {
|
|
53
|
-
let fetchMock;
|
|
54
|
-
let orgFetch;
|
|
55
|
-
beforeEach(() => {
|
|
56
|
-
fetchMock = jest.fn();
|
|
57
|
-
orgFetch = global['fetch'];
|
|
58
|
-
global['fetch'] = fetchMock;
|
|
59
|
-
});
|
|
60
|
-
afterAll(() => {
|
|
61
|
-
global['fetch'] = orgFetch;
|
|
62
|
-
});
|
|
63
49
|
it('fetch fails when rms config is not available', async () => {
|
|
64
50
|
global['__forge_runtime__'] = {
|
|
65
51
|
proxy: {
|
|
@@ -89,7 +75,7 @@ describe('createFetch', () => {
|
|
|
89
75
|
await fetch('path');
|
|
90
76
|
const [absoluteUrl, options] = (_a = fetchMock.mock.lastCall) !== null && _a !== void 0 ? _a : ['', {}];
|
|
91
77
|
expect(absoluteUrl).toEqual('https://dev.services.atlassian.com/path');
|
|
92
|
-
expect((options === null || options === void 0 ? void 0 : options.agent)['keepAlive']).toBeTruthy();
|
|
78
|
+
expect((options === null || options === void 0 ? void 0 : options.agent)['passthrough']['keepAlive']).toBeTruthy();
|
|
93
79
|
expect(options === null || options === void 0 ? void 0 : options.headers).toMatchObject({
|
|
94
80
|
Authorization: 'Bearer token',
|
|
95
81
|
Host: 'rockmelon-storage.dev.atl-paas.net',
|
package/out/cache.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestInit, Response as nodeFetchResponse } from 'node-fetch';
|
|
2
|
-
export type Response = Pick<nodeFetchResponse, 'text' | 'ok' | 'status'>;
|
|
3
|
-
export type ScanResult = {
|
|
2
|
+
export declare type Response = Pick<nodeFetchResponse, 'text' | 'ok' | 'status'>;
|
|
3
|
+
export declare type ScanResult = {
|
|
4
4
|
cursor: string;
|
|
5
5
|
keys: string[];
|
|
6
6
|
};
|
package/out/cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AACA,OAAkB,EAAE,WAAW,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAInF,
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AACA,OAAkB,EAAE,WAAW,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAInF,oBAAY,QAAQ,GAAG,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC,CAAC;AAEzE,oBAAY,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAGF,wBAAsB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAYtE;AAED,qBAAa,KAAK;IACJ,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC;IAGtF,OAAO,CAAC,YAAY;IAUP,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAM5E,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAO9F,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAOxC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAO3F,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO7C,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO7C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOpC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC;CAMnG;AAED,wBAAgB,oBAAoB,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,CAE/G;AAID,wBAAgB,uBAAuB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CA6BpG;AAED,wBAAgB,OAAO,UAItB"}
|
package/out/cache.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.connect = exports.createFetchRmsRuntimeV2 = exports.getFetchRmsRuntimeV1 = exports.Cache = exports.getResponseBody = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const https_1 = require("https");
|
|
6
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
5
7
|
const api_1 = require("@forge/api");
|
|
6
8
|
async function getResponseBody(response) {
|
|
7
9
|
const responseText = await response.text();
|
|
@@ -83,7 +85,9 @@ function createFetchRmsRuntimeV2() {
|
|
|
83
85
|
throw new Error('RMS config not available.');
|
|
84
86
|
}
|
|
85
87
|
const rmsFullUrl = new URL(rms.url) + path;
|
|
86
|
-
|
|
88
|
+
const rmsAgent = new String('FORGE_PRODUCT_REQUEST');
|
|
89
|
+
rmsAgent['passthrough'] = agent;
|
|
90
|
+
return await (0, node_fetch_1.default)(rmsFullUrl, Object.assign(Object.assign({}, options), { agent: rmsAgent, headers: Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.headers), { Authorization: `Bearer ${proxy.token}`, Host: rms.host, 'x-b3-traceid': tracing.traceId, 'x-b3-spanid': tracing.spanId }) }));
|
|
87
91
|
};
|
|
88
92
|
}
|
|
89
93
|
exports.createFetchRmsRuntimeV2 = createFetchRmsRuntimeV2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/cache",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-next.0",
|
|
4
4
|
"description": "Forge Cache methods",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
"node-fetch": "2.7.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@forge/api": "^3.0.0
|
|
23
|
+
"@forge/api": "^3.0.0"
|
|
24
24
|
}
|
|
25
25
|
}
|