@forge/migrations 0.0.0-experimental-416047f → 0.0.0-experimental-51786e9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,131 @@
1
1
  # @forge/migrations
2
2
 
3
- ## 0.0.0-experimental-416047f
3
+ ## 0.0.0-experimental-51786e9
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [dfab69c]
8
+ - @forge/api@0.0.0-experimental-51786e9
9
+
10
+ ## 0.1.7-next.0
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [dfab69c]
15
+ - @forge/api@2.10.1-next.0
16
+
17
+ ## 0.1.6
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [37f48c5]
22
+ - Updated dependencies [e0e3587]
23
+ - Updated dependencies [ca8551d]
24
+ - @forge/api@2.10.0
25
+
26
+ ## 0.1.6-next.1
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [e0e3587a]
31
+ - @forge/api@2.10.0-next.1
32
+
33
+ ## 0.1.6-next.0
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [ca8551dd]
38
+ - @forge/api@2.9.2-next.0
39
+
40
+ ## 0.1.5
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies [73b929a]
45
+ - Updated dependencies [8d0dc10]
46
+ - Updated dependencies [7a4fa35]
47
+ - @forge/api@2.9.1
48
+
49
+ ## 0.1.5-next.0
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies [7a4fa35]
54
+ - @forge/api@2.9.1-next.0
55
+
56
+ ## 0.1.4
57
+
58
+ ### Patch Changes
59
+
60
+ - Updated dependencies [e5dd325]
61
+ - @forge/api@2.9.0
62
+
63
+ ## 0.1.4-next.0
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies [e5dd325d]
68
+ - @forge/api@2.9.0-next.0
69
+
70
+ ## 0.1.3
71
+
72
+ ### Patch Changes
73
+
74
+ - 8e2a5a6: Update node-fetch version
75
+ - Updated dependencies [8e2a5a6]
76
+ - @forge/api@2.8.1
77
+
78
+ ## 0.1.3-next.0
79
+
80
+ ### Patch Changes
81
+
82
+ - 8e2a5a6: Update node-fetch version
83
+ - Updated dependencies [8e2a5a6]
84
+ - @forge/api@2.8.1-next.0
85
+
86
+ ## 0.1.2
87
+
88
+ ### Patch Changes
89
+
90
+ - 652e9f2: Bump Typescript and ESlint to latest
91
+ - Updated dependencies [95913f6]
92
+ - @forge/api@2.8.0
93
+
94
+ ## 0.1.2-next.1
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [95913f6]
99
+ - @forge/api@2.8.0-next.0
100
+
101
+ ## 0.1.2-next.0
102
+
103
+ ### Patch Changes
104
+
105
+ - 652e9f23: Bump Typescript and ESlint to latest
106
+
107
+ ## 0.1.1
108
+
109
+ ### Patch Changes
110
+
111
+ - cf5eb2a: Added .npmignore file to forge-migrations package
112
+ - Updated dependencies [b3ee297]
113
+ - @forge/api@2.7.0
114
+
115
+ ## 0.1.1-next.1
116
+
117
+ ### Patch Changes
118
+
119
+ - cf5eb2af: Added .npmignore file to forge-migrations package
120
+
121
+ ## 0.1.1-next.0
122
+
123
+ ### Patch Changes
124
+
125
+ - Updated dependencies [b3ee2973]
126
+ - @forge/api@2.7.0-next.0
127
+
128
+ ## 0.1.0
4
129
 
5
130
  ### Minor Changes
6
131
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,eAAO,MAAM,oBAAoB,YAAa,SAAS;+BAExB,MAAM,YAAY,QAAQ;iCACxB,MAAM,aAAa,MAAM,QAAQ,KAAK,CAAC,MAAM,CAAC;iCAE9C,MAAM,YAAY,MAAM;iCACxB,MAAM;+BACR,MAAM;8BACP,MAAM,aAAa,MAAM;gCAEvB,MAAM,iBAAiB,MAAM;CAG5D,CAAC;AAEF,eAAO,MAAM,SAAS;+BACO,MAAM,YAAY,QAAQ;iCAExB,MAAM,aAAa,MAAM,QAAQ,KAAK,CAAC,MAAM,CAAC;iCAE9C,MAAM,YAAY,MAAM;iCAExB,MAAM;+BACR,MAAM;8BACP,MAAM,aAAa,MAAM;gCAEvB,MAAM,iBAAiB,MAAM;CAE1D,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,eAAO,MAAM,oBAAoB,YAAa,SAAS;+BAExB,MAAM,YAAY,QAAQ;iCACxB,MAAM,aAAa,MAAM,QAAQ,MAAM,MAAM,CAAC;iCAE9C,MAAM,YAAY,MAAM;iCACxB,MAAM;+BACR,MAAM;8BACP,MAAM,aAAa,MAAM;gCAEvB,MAAM,iBAAiB,MAAM;CAG5D,CAAC;AAEF,eAAO,MAAM,SAAS;+BACO,MAAM,YAAY,QAAQ;iCAExB,MAAM,aAAa,MAAM,QAAQ,MAAM,MAAM,CAAC;iCAE9C,MAAM,YAAY,MAAM;iCAExB,MAAM;+BACR,MAAM;8BACP,MAAM,aAAa,MAAM;gCAEvB,MAAM,iBAAiB,MAAM;CAE1D,CAAC"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.migration = exports.getMigrationInstance = void 0;
4
4
  const migration_1 = require("./migration");
5
5
  const query_api_1 = require("./query-api");
6
- exports.getMigrationInstance = (adapter) => {
6
+ const getMigrationInstance = (adapter) => {
7
7
  return {
8
8
  sendProgress: (transferId, progress) => adapter.sendProgress(transferId, progress),
9
9
  getMappingById: (transferId, namespace, keys) => adapter.getMappingById(transferId, namespace, keys),
@@ -14,12 +14,13 @@ exports.getMigrationInstance = (adapter) => {
14
14
  getContainers: (transferId, containerType) => new query_api_1.DefaultQueryBuilder(adapter, { transferId: transferId, containerType: containerType })
15
15
  };
16
16
  };
17
+ exports.getMigrationInstance = getMigrationInstance;
17
18
  exports.migration = {
18
- sendProgress: (transferId, progress) => exports.getMigrationInstance(new migration_1.Migration()).sendProgress(transferId, progress),
19
- getMappingById: (transferId, namespace, keys) => exports.getMigrationInstance(new migration_1.Migration()).getMappingById(transferId, namespace, keys),
20
- updateFeedback: (transferId, feedback) => exports.getMigrationInstance(new migration_1.Migration()).updateFeedback(transferId, feedback),
21
- getAppDataList: (transferId) => exports.getMigrationInstance(new migration_1.Migration()).getAppDataList(transferId),
22
- getAppDataPayload: (s3Key) => exports.getMigrationInstance(new migration_1.Migration()).getAppDataPayload(s3Key),
23
- getMappings: (transferId, namespace) => exports.getMigrationInstance(new migration_1.Migration()).getMappings(transferId, namespace),
24
- getContainers: (transferId, containerType) => exports.getMigrationInstance(new migration_1.Migration()).getContainers(transferId, containerType)
19
+ sendProgress: (transferId, progress) => (0, exports.getMigrationInstance)(new migration_1.Migration()).sendProgress(transferId, progress),
20
+ getMappingById: (transferId, namespace, keys) => (0, exports.getMigrationInstance)(new migration_1.Migration()).getMappingById(transferId, namespace, keys),
21
+ updateFeedback: (transferId, feedback) => (0, exports.getMigrationInstance)(new migration_1.Migration()).updateFeedback(transferId, feedback),
22
+ getAppDataList: (transferId) => (0, exports.getMigrationInstance)(new migration_1.Migration()).getAppDataList(transferId),
23
+ getAppDataPayload: (s3Key) => (0, exports.getMigrationInstance)(new migration_1.Migration()).getAppDataPayload(s3Key),
24
+ getMappings: (transferId, namespace) => (0, exports.getMigrationInstance)(new migration_1.Migration()).getMappings(transferId, namespace),
25
+ getContainers: (transferId, containerType) => (0, exports.getMigrationInstance)(new migration_1.Migration()).getContainers(transferId, containerType)
25
26
  };
@@ -7,8 +7,8 @@ export declare class Migration implements MigrationAdapter {
7
7
  getAppDataList: (transferId: string) => Promise<AppDataListResponse>;
8
8
  getAppDataPayload: (s3Key: string) => Promise<Response>;
9
9
  updateFeedback: (transferId: string, feedback: object) => Promise<void>;
10
- getMappings: (transferId: string, namespace?: string | undefined, lastEntity?: string | undefined, pageSize?: number | undefined) => Promise<ListResults>;
11
- getContainers: (transferId: string, containerType?: string | undefined, lastEntity?: string | undefined, pageSize?: number | undefined) => Promise<ListResults>;
12
- list: (options: ListOptions, pageSize?: number | undefined) => Promise<ListResults>;
10
+ getMappings: (transferId: string, namespace?: string, lastEntity?: string, pageSize?: number) => Promise<ListResults>;
11
+ getContainers: (transferId: string, containerType?: string, lastEntity?: string, pageSize?: number) => Promise<ListResults>;
12
+ list: (options: ListOptions, pageSize?: number) => Promise<ListResults>;
13
13
  }
14
14
  //# sourceMappingURL=migration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../src/migration/migration.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EACL,mBAAmB,EAEnB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,WAAW,EAIZ,MAAM,qBAAqB,CAAC;AAI7B,qBAAa,SAAU,YAAW,gBAAgB;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IAEtD,YAAY,eAAsB,MAAM,YAAY,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC,CAG1E;IAEF,cAAc,eAAsB,MAAM,aAAa,MAAM,QAAQ,KAAK,CAAC,MAAM,CAAC,KAAG,OAAO,CAAC,eAAe,CAAC,CAG3G;IAEF,cAAc,eAAsB,MAAM,KAAG,OAAO,CAAC,mBAAmB,CAAC,CAGvE;IAEF,iBAAiB,UAAiB,MAAM,KAAG,OAAO,CAAC,QAAQ,CAAC,CAI1D;IAEF,cAAc,eAAsB,MAAM,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAG1E;IAEF,WAAW,eACG,MAAM,qGAIjB,OAAO,CAAC,WAAW,CAAC,CAuBrB;IAEF,aAAa,eACC,MAAM,yGAIjB,OAAO,CAAC,WAAW,CAAC,CAsBrB;IAEF,IAAI,YAAmB,WAAW,oCAAsB,OAAO,CAAC,WAAW,CAAC,CAI1E;CACH"}
1
+ {"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../src/migration/migration.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EACL,mBAAmB,EAEnB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,WAAW,EAIZ,MAAM,qBAAqB,CAAC;AAI7B,qBAAa,SAAU,YAAW,gBAAgB;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IAEtD,YAAY,eAAsB,MAAM,YAAY,QAAQ,KAAG,QAAQ,IAAI,CAAC,CAG1E;IAEF,cAAc,eAAsB,MAAM,aAAa,MAAM,QAAQ,MAAM,MAAM,CAAC,KAAG,QAAQ,eAAe,CAAC,CAG3G;IAEF,cAAc,eAAsB,MAAM,KAAG,QAAQ,mBAAmB,CAAC,CAGvE;IAEF,iBAAiB,UAAiB,MAAM,KAAG,QAAQ,QAAQ,CAAC,CAI1D;IAEF,cAAc,eAAsB,MAAM,YAAY,MAAM,KAAG,QAAQ,IAAI,CAAC,CAG1E;IAEF,WAAW,eACG,MAAM,cACN,MAAM,eACL,MAAM,aACR,MAAM,KAChB,QAAQ,WAAW,CAAC,CAuBrB;IAEF,aAAa,eACC,MAAM,kBACF,MAAM,eACT,MAAM,aACR,MAAM,KAChB,QAAQ,WAAW,CAAC,CAsBrB;IAEF,IAAI,YAAmB,WAAW,aAAa,MAAM,KAAG,QAAQ,WAAW,CAAC,CAI1E;CACH"}
@@ -8,25 +8,25 @@ class Migration {
8
8
  constructor() {
9
9
  this.basePath = '/app/migration/forge/v1';
10
10
  this.sendProgress = async (transferId, progress) => {
11
- const result = await utils_1.invokePOSTApi(`${this.basePath}/progress/${transferId}`, progress);
12
- return utils_1.getResponseBody(result);
11
+ const result = await (0, utils_1.invokePOSTApi)(`${this.basePath}/progress/${transferId}`, progress);
12
+ return (0, utils_1.getResponseBody)(result);
13
13
  };
14
14
  this.getMappingById = async (transferId, namespace, keys) => {
15
- const result = await utils_1.invokePOSTApi(`${this.basePath}/mapping/${transferId}/find?namespace=${namespace}`, keys);
16
- return utils_1.getResponseBody(result);
15
+ const result = await (0, utils_1.invokePOSTApi)(`${this.basePath}/mapping/${transferId}/find?namespace=${namespace}`, keys);
16
+ return (0, utils_1.getResponseBody)(result);
17
17
  };
18
18
  this.getAppDataList = async (transferId) => {
19
- const result = await utils_1.invokeGETApi(`${this.basePath}/data/${transferId}/all`);
20
- return utils_1.getResponseBody(result);
19
+ const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/data/${transferId}/all`);
20
+ return (0, utils_1.getResponseBody)(result);
21
21
  };
22
22
  this.getAppDataPayload = async (s3Key) => {
23
- const result = await utils_1.invokeGETApi(`${this.basePath}/data/${s3Key}`);
24
- const responseBody = await utils_1.getResponseBody(result);
25
- return node_fetch_1.default(responseBody.url);
23
+ const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/data/${s3Key}`);
24
+ const responseBody = await (0, utils_1.getResponseBody)(result);
25
+ return (0, node_fetch_1.default)(responseBody.url);
26
26
  };
27
27
  this.updateFeedback = async (transferId, feedback) => {
28
- const result = await utils_1.invokePOSTApi(`${this.basePath}/feedback/${transferId}`, feedback);
29
- return utils_1.getResponseBody(result);
28
+ const result = await (0, utils_1.invokePOSTApi)(`${this.basePath}/feedback/${transferId}`, feedback);
29
+ return (0, utils_1.getResponseBody)(result);
30
30
  };
31
31
  this.getMappings = async (transferId, namespace, lastEntity, pageSize) => {
32
32
  let queryParams = `namespace=${namespace}`;
@@ -36,8 +36,8 @@ class Migration {
36
36
  if (lastEntity != undefined) {
37
37
  queryParams = queryParams + `&lastEntity=${lastEntity}`;
38
38
  }
39
- const result = await utils_1.invokeGETApi(`${this.basePath}/mapping/${transferId}/page?${queryParams}`);
40
- const mappingResponse = await utils_1.getResponseBody(result);
39
+ const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/mapping/${transferId}/page?${queryParams}`);
40
+ const mappingResponse = await (0, utils_1.getResponseBody)(result);
41
41
  let results = [];
42
42
  if (mappingResponse.items != null) {
43
43
  results = Object.entries(mappingResponse.items).map((item) => {
@@ -57,8 +57,8 @@ class Migration {
57
57
  if (lastEntity != undefined) {
58
58
  queryParams = queryParams + `&lastEntity=${lastEntity}`;
59
59
  }
60
- const result = await utils_1.invokeGETApi(`${this.basePath}/container/${transferId}/page?${queryParams}`);
61
- const containerResponse = await utils_1.getResponseBody(result);
60
+ const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/container/${transferId}/page?${queryParams}`);
61
+ const containerResponse = await (0, utils_1.getResponseBody)(result);
62
62
  let results = [];
63
63
  if (containerResponse.containers != null) {
64
64
  results = Object.entries(containerResponse.containers).map((item) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/migrations",
3
- "version": "0.0.0-experimental-416047f",
3
+ "version": "0.0.0-experimental-51786e9",
4
4
  "description": "App migration methods for Forge app",
5
5
  "main": "out/index.js",
6
6
  "scripts": {
@@ -13,9 +13,9 @@
13
13
  "devDependencies": {
14
14
  "@types/node": "^12.12.63",
15
15
  "@types/node-fetch": "^2.5.7",
16
- "node-fetch": "2.6.1"
16
+ "node-fetch": "2.6.7"
17
17
  },
18
18
  "dependencies": {
19
- "@forge/api": "^2.6.1"
19
+ "@forge/api": "^0.0.0-experimental-51786e9"
20
20
  }
21
21
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=errors.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.test.d.ts","sourceRoot":"","sources":["../../src/__test__/errors.test.ts"],"names":[],"mappings":""}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const errors_1 = require("../migration/errors");
4
- describe('APIError', () => {
5
- describe('forStatus', () => {
6
- it.each([
7
- [400, 'Bad request'],
8
- [401, 'Unauthorized'],
9
- [403, 'Forbidden'],
10
- [404, 'Not Found'],
11
- [500, 'Internal server error']
12
- ])('should contain the correct error message for a code of %s', (status, message) => {
13
- expect(errors_1.APIError.forStatus(status, message).message).toEqual(message);
14
- });
15
- });
16
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=migration.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migration.test.d.ts","sourceRoot":"","sources":["../../src/__test__/migration.test.ts"],"names":[],"mappings":""}
@@ -1,221 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const errors_1 = require("../migration/errors");
5
- const migration_1 = require("../migration");
6
- const jest_when_1 = require("jest-when");
7
- const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
8
- const utils_1 = require("ts-jest/utils");
9
- let transferId;
10
- let invalidTransferId;
11
- let progress;
12
- let keys;
13
- let invalidKeys;
14
- let namespace;
15
- let mappingByKeyResponseWithKeys;
16
- let mappingByKeyResponseWithInvalidKeys;
17
- let s3Key;
18
- let invalidS3Key;
19
- let feedbackPayload;
20
- let appDataListResponse;
21
- let appDataPayloadResponse;
22
- jest.mock('node-fetch');
23
- describe('migration', () => {
24
- beforeAll(() => {
25
- global.api = {
26
- asApp: jest.fn().mockReturnValue({
27
- __requestAtlassian: jest.fn()
28
- })
29
- };
30
- transferId = '521ee36a-b673-3dc6-b60b-12460332c200';
31
- invalidTransferId = '521ee36a-b673-3dc6-b60b-12460332c001';
32
- });
33
- describe('sendMigrationProgress', () => {
34
- beforeAll(() => {
35
- progress = { status: 'IN_PROGRESS', percent: 10, message: 'reporting' };
36
- jest_when_1.when(global.api.asApp().__requestAtlassian)
37
- .calledWith(`/app/migration/forge/v1/progress/${transferId}`, {
38
- method: 'POST',
39
- headers: {
40
- 'content-type': 'application/json'
41
- },
42
- body: JSON.stringify(progress)
43
- })
44
- .mockReturnValue({
45
- status: 200,
46
- text: jest.fn().mockImplementationOnce(() => Promise.resolve()),
47
- json: jest.fn().mockImplementationOnce(() => Promise.resolve())
48
- })
49
- .calledWith(`/app/migration/forge/v1/progress/${invalidTransferId}`, {
50
- method: 'POST',
51
- headers: {
52
- 'content-type': 'application/json'
53
- },
54
- body: JSON.stringify(progress)
55
- })
56
- .mockReturnValue({
57
- status: 403,
58
- statusText: 'Forbidden'
59
- });
60
- });
61
- it('should update progress when sendProgress method called with valid transferId', async () => {
62
- const returnedValue = migration_1.migration.sendProgress(transferId, progress);
63
- await expect(returnedValue).resolves.toBeUndefined();
64
- });
65
- it('should return 403 when sendProgress method called with invalid transferId', async () => {
66
- const returnedValue = migration_1.migration.sendProgress(invalidTransferId, progress);
67
- await expect(returnedValue).rejects.toThrow(errors_1.APIError.forStatus(403, 'Forbidden'));
68
- });
69
- });
70
- describe('getMappingById', () => {
71
- beforeAll(() => {
72
- keys = ['email/abc@example.com', 'email/admin@example.com'];
73
- invalidKeys = ['email/abc@example.com', 'email/admin@example'];
74
- namespace = 'identity:user';
75
- mappingByKeyResponseWithKeys =
76
- '{"email/abc@example.com":"5a20a4d7c6bd4a32df3a711","email/admin@example.com":"5a29c4ae20cfc31b0dc0e112"}';
77
- mappingByKeyResponseWithInvalidKeys = '{"email/abc@example.com":"5a20a4d7c6bd4a32df3a711"}';
78
- jest_when_1.when(global.api.asApp().__requestAtlassian)
79
- .calledWith(`/app/migration/forge/v1/mapping/${transferId}/find?namespace=${namespace}`, {
80
- method: 'POST',
81
- headers: {
82
- 'content-type': 'application/json'
83
- },
84
- body: JSON.stringify(keys)
85
- })
86
- .mockReturnValue({
87
- status: 200,
88
- text: jest.fn().mockResolvedValue(mappingByKeyResponseWithKeys),
89
- json: jest.fn().mockResolvedValue(JSON.parse(mappingByKeyResponseWithKeys))
90
- })
91
- .calledWith(`/app/migration/forge/v1/mapping/${transferId}/find?namespace=${namespace}`, {
92
- method: 'POST',
93
- headers: {
94
- 'content-type': 'application/json'
95
- },
96
- body: JSON.stringify(invalidKeys)
97
- })
98
- .mockReturnValue({
99
- status: 200,
100
- text: jest.fn().mockResolvedValue(mappingByKeyResponseWithInvalidKeys),
101
- json: jest.fn().mockResolvedValue(JSON.parse(mappingByKeyResponseWithInvalidKeys))
102
- })
103
- .calledWith(`/app/migration/forge/v1/mapping/${invalidTransferId}/find?namespace=${namespace}`, {
104
- method: 'POST',
105
- headers: {
106
- 'content-type': 'application/json'
107
- },
108
- body: JSON.stringify(keys)
109
- })
110
- .mockReturnValue({
111
- status: 403,
112
- statusText: 'Forbidden'
113
- });
114
- });
115
- it('should return MappingResponse when getMappingById method called with valid transferId', async () => {
116
- const returnedValue = await migration_1.migration.getMappingById(transferId, namespace, keys);
117
- expect(JSON.stringify(returnedValue)).toEqual(mappingByKeyResponseWithKeys);
118
- });
119
- it('should return 403 when getMappingById method called with invalid transferId', async () => {
120
- const returnedValue = migration_1.migration.getMappingById(invalidTransferId, namespace, keys);
121
- await expect(returnedValue).rejects.toThrow(errors_1.APIError.forStatus(403, 'Forbidden'));
122
- });
123
- it('should return MappingResponse except for invalid keys when getMappingById method called with valid transferId', async () => {
124
- const returnedValue = await migration_1.migration.getMappingById(transferId, namespace, invalidKeys);
125
- expect(JSON.stringify(returnedValue)).toEqual(mappingByKeyResponseWithInvalidKeys);
126
- });
127
- });
128
- describe('getAppDataList', () => {
129
- beforeAll(() => {
130
- appDataListResponse =
131
- '[{"s3Key":"2ea231e3-ab0d-4236-97f7-26f951df1c11","label":null},{"s3Key":"317a3631-2fef-4940-a418-7096e971eb11","label":null}]';
132
- jest_when_1.when(global.api.asApp().__requestAtlassian)
133
- .calledWith(`/app/migration/forge/v1/data/${transferId}/all`)
134
- .mockReturnValue({
135
- status: 200,
136
- text: jest.fn().mockResolvedValue(appDataListResponse),
137
- json: jest.fn().mockResolvedValue(JSON.parse(appDataListResponse))
138
- })
139
- .calledWith(`/app/migration/forge/v1/data/${invalidTransferId}/all`)
140
- .mockReturnValue({
141
- status: 403,
142
- statusText: 'Forbidden'
143
- });
144
- });
145
- it('should return AppDataListResponse when getAppDataList method called with valid transferId', async () => {
146
- const returnedValue = await migration_1.migration.getAppDataList(transferId);
147
- expect(returnedValue).toEqual(JSON.parse(appDataListResponse));
148
- });
149
- it('should return 403 when getAppDataList method called with invalid transferId', async () => {
150
- const returnedValue = migration_1.migration.getAppDataList(invalidTransferId);
151
- await expect(returnedValue).rejects.toThrow(errors_1.APIError.forStatus(403, 'Forbidden'));
152
- });
153
- });
154
- describe('getAppDataPayload', () => {
155
- beforeAll(() => {
156
- s3Key = '7941b65d-094b-4305-97f2-e2b412c6db0a';
157
- invalidS3Key = '7941b65d-094b-4305-97f2-e2b412c000';
158
- appDataPayloadResponse = '{ "url": "https://rps--stg-east--app-migration-service--ams.s3.amazonaws.com/test"}';
159
- utils_1.mocked(node_fetch_1.default).mockImplementation(() => Promise.resolve({
160
- text: () => Promise.resolve('Sample app data')
161
- }));
162
- jest_when_1.when(global.api.asApp().__requestAtlassian)
163
- .calledWith(`/app/migration/forge/v1/data/${s3Key}`)
164
- .mockReturnValue({
165
- status: 200,
166
- text: jest.fn().mockResolvedValue(JSON.stringify(appDataPayloadResponse)),
167
- json: jest.fn().mockResolvedValue(JSON.parse(appDataPayloadResponse))
168
- })
169
- .calledWith(`/app/migration/forge/v1/data/${invalidS3Key}`)
170
- .mockReturnValue({
171
- status: 403,
172
- statusText: 'Forbidden'
173
- });
174
- });
175
- it('should return Response when getAppDataPayload method called with valid S3Key', async () => {
176
- const returnedValue = await migration_1.migration.getAppDataPayload(s3Key);
177
- await expect(returnedValue.text()).resolves.toBe('Sample app data');
178
- });
179
- it('should return 403 when getAppDataPayload method called with invalid S3Key', async () => {
180
- const returnedValue = migration_1.migration.getAppDataPayload(invalidS3Key);
181
- await expect(returnedValue).rejects.toThrow(errors_1.APIError.forStatus(403, 'Forbidden'));
182
- });
183
- });
184
- describe('updateFeedback', () => {
185
- beforeAll(() => {
186
- feedbackPayload = { transferId: transferId, msg: 'Current Data processed, send next' };
187
- jest_when_1.when(global.api.asApp().__requestAtlassian)
188
- .calledWith(`/app/migration/forge/v1/feedback/${transferId}`, {
189
- method: 'POST',
190
- headers: {
191
- 'content-type': 'application/json'
192
- },
193
- body: JSON.stringify(feedbackPayload)
194
- })
195
- .mockReturnValue({
196
- status: 200,
197
- text: jest.fn().mockImplementationOnce(() => Promise.resolve()),
198
- json: jest.fn().mockImplementationOnce(() => Promise.resolve())
199
- })
200
- .calledWith(`/app/migration/forge/v1/feedback/${invalidTransferId}`, {
201
- method: 'POST',
202
- headers: {
203
- 'content-type': 'application/json'
204
- },
205
- body: JSON.stringify(feedbackPayload)
206
- })
207
- .mockReturnValue({
208
- status: 403,
209
- statusText: 'Forbidden'
210
- });
211
- });
212
- it('should send feedback when updateFeedback method called with valid transferId', async () => {
213
- const returnedValue = migration_1.migration.updateFeedback(transferId, feedbackPayload);
214
- await expect(returnedValue).resolves.toBeUndefined();
215
- });
216
- it('should return 403 when updateFeedback method called with invalid transferId', async () => {
217
- const returnedValue = migration_1.migration.updateFeedback(invalidTransferId, feedbackPayload);
218
- await expect(returnedValue).rejects.toThrow(errors_1.APIError.forStatus(403, 'Forbidden'));
219
- });
220
- });
221
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=query-api.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query-api.test.d.ts","sourceRoot":"","sources":["../../src/__test__/query-api.test.ts"],"names":[],"mappings":""}