@forge/migrations 0.3.3 → 0.4.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 +13 -0
- package/out/migration/index.d.ts +2 -2
- package/out/migration/migration-adaptor.d.ts +2 -1
- package/out/migration/migration-adaptor.d.ts.map +1 -1
- package/out/migration/migration.d.ts +3 -2
- package/out/migration/migration.d.ts.map +1 -1
- package/out/migration/migration.js +71 -66
- package/out/migration/query-api.js +1 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @forge/migrations
|
|
2
2
|
|
|
3
|
+
## 0.4.0-next.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4238b5a: Abstracting app data retrieval for Forge migrations
|
|
8
|
+
|
|
9
|
+
## 0.3.4-next.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [1588c76]
|
|
14
|
+
- @forge/api@3.6.0-next.0
|
|
15
|
+
|
|
3
16
|
## 0.3.3
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/out/migration/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const getMigrationInstance: (adapter: Migration) => {
|
|
|
4
4
|
getMappingById: (transferId: string, namespace: string, keys: Array<string>) => Promise<import("./migration-adaptor").MappingResponse>;
|
|
5
5
|
messageProcessed: (transferId: string, messageId: string) => Promise<void>;
|
|
6
6
|
getAppDataList: (transferId: string) => Promise<import("./migration-adaptor").AppDataListResponse>;
|
|
7
|
-
getAppDataPayload: (s3Key: string) => Promise<import("
|
|
7
|
+
getAppDataPayload: (s3Key: string) => Promise<import("@forge/api").APIResponse>;
|
|
8
8
|
getMappings: (transferId: string, namespace: string) => DefaultQueryBuilder;
|
|
9
9
|
getContainers: (transferId: string, containerType: string) => DefaultQueryBuilder;
|
|
10
10
|
};
|
|
@@ -12,7 +12,7 @@ export declare const migration: {
|
|
|
12
12
|
getMappingById: (transferId: string, namespace: string, keys: Array<string>) => Promise<import("./migration-adaptor").MappingResponse>;
|
|
13
13
|
messageProcessed: (transferId: string, messageId: string) => Promise<void>;
|
|
14
14
|
getAppDataList: (transferId: string) => Promise<import("./migration-adaptor").AppDataListResponse>;
|
|
15
|
-
getAppDataPayload: (s3Key: string) => Promise<import("
|
|
15
|
+
getAppDataPayload: (s3Key: string) => Promise<import("@forge/api").APIResponse>;
|
|
16
16
|
getMappings: (transferId: string, namespace: string) => DefaultQueryBuilder;
|
|
17
17
|
getContainers: (transferId: string, containerType: string) => DefaultQueryBuilder;
|
|
18
18
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { APIResponse } from '@forge/api';
|
|
1
2
|
export interface MigrationAdapter {
|
|
2
3
|
getMappingById(transferId: string, namespace: string, keys: Array<string>): Promise<MappingResponse>;
|
|
3
4
|
getAppDataList(transferId: string): Promise<AppDataListResponse>;
|
|
4
|
-
getAppDataPayload(s3Key: string): Promise<
|
|
5
|
+
getAppDataPayload(s3Key: string): Promise<APIResponse>;
|
|
5
6
|
messageProcessed(transferId: string, messageId: string): Promise<void>;
|
|
6
7
|
}
|
|
7
8
|
export interface MappingResponse {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-adaptor.d.ts","sourceRoot":"","sources":["../../src/migration/migration-adaptor.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACrG,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACjE,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"migration-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,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC;IACrC,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAChC,MAAM,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACvC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AppDataListResponse,
|
|
1
|
+
import { AppDataListResponse, MappingResponse, MigrationAdapter, ListOptions, ListResults } from './migration-adaptor';
|
|
2
|
+
import { APIResponse } from '@forge/api';
|
|
2
3
|
export declare class Migration implements MigrationAdapter {
|
|
3
4
|
private readonly basePath;
|
|
4
5
|
getMappingById: (transferId: string, namespace: string, keys: Array<string>) => Promise<MappingResponse>;
|
|
5
6
|
getAppDataList: (transferId: string) => Promise<AppDataListResponse>;
|
|
6
|
-
getAppDataPayload: (
|
|
7
|
+
getAppDataPayload: (key: string) => Promise<APIResponse>;
|
|
7
8
|
messageProcessed: (transferId: string, messageId: string) => Promise<void>;
|
|
8
9
|
getMappings: (transferId: string, namespace?: string, lastEntity?: string, pageSize?: number) => Promise<ListResults>;
|
|
9
10
|
getContainers: (transferId: string, containerType?: string, lastEntity?: string, pageSize?: number) => Promise<ListResults>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../src/migration/migration.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../src/migration/migration.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAEnB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,WAAW,EAIZ,MAAM,qBAAqB,CAAC;AAE7B,OAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAI9C,qBAAa,SAAU,YAAW,gBAAgB;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IAEtD,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,QAAe,MAAM,KAAG,QAAQ,WAAW,CAAC,CAK3D;IAEF,gBAAgB,eAAsB,MAAM,aAAa,MAAM,KAAG,QAAQ,IAAI,CAAC,CAO7E;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"}
|
|
@@ -1,76 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Migration = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const api_1 = tslib_1.__importDefault(require("@forge/api"));
|
|
4
6
|
const utils_1 = require("./utils");
|
|
5
7
|
class Migration {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
getAppDataList = async (transferId) => {
|
|
12
|
-
const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/data/${transferId}/all`);
|
|
13
|
-
return (0, utils_1.getResponseBody)(result);
|
|
14
|
-
};
|
|
15
|
-
getAppDataPayload = async (s3Key) => {
|
|
16
|
-
const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/data/${s3Key}`);
|
|
17
|
-
return (0, utils_1.getResponseBody)(result);
|
|
18
|
-
};
|
|
19
|
-
messageProcessed = async (transferId, messageId) => {
|
|
20
|
-
const request = {
|
|
21
|
-
status: 'SUCCESS',
|
|
22
|
-
messageIds: [messageId]
|
|
8
|
+
constructor() {
|
|
9
|
+
this.basePath = '/app/migration/forge/v1';
|
|
10
|
+
this.getMappingById = async (transferId, namespace, keys) => {
|
|
11
|
+
const result = await (0, utils_1.invokePOSTApi)(`${this.basePath}/mapping/${transferId}/find?namespace=${namespace}`, keys);
|
|
12
|
+
return (0, utils_1.getResponseBody)(result);
|
|
23
13
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
getMappings = async (transferId, namespace, lastEntity, pageSize) => {
|
|
28
|
-
let queryParams = `namespace=${namespace}`;
|
|
29
|
-
if (pageSize != undefined) {
|
|
30
|
-
queryParams = queryParams + `&pageSize=${pageSize}`;
|
|
31
|
-
}
|
|
32
|
-
if (lastEntity != undefined) {
|
|
33
|
-
queryParams = queryParams + `&lastEntity=${lastEntity}`;
|
|
34
|
-
}
|
|
35
|
-
const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/mapping/${transferId}/page?${queryParams}`);
|
|
36
|
-
const mappingResponse = await (0, utils_1.getResponseBody)(result);
|
|
37
|
-
let results = [];
|
|
38
|
-
if (mappingResponse.items != null) {
|
|
39
|
-
results = Object.entries(mappingResponse.items).map((item) => {
|
|
40
|
-
return { key: item[0], value: item[1] };
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
results: results,
|
|
45
|
-
nextCursor: mappingResponse.meta.lastEntity != null ? mappingResponse.meta.lastEntity : undefined
|
|
14
|
+
this.getAppDataList = async (transferId) => {
|
|
15
|
+
const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/data/${transferId}/all`);
|
|
16
|
+
return (0, utils_1.getResponseBody)(result);
|
|
46
17
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
queryParams = queryParams + `&pageSize=${pageSize}`;
|
|
52
|
-
}
|
|
53
|
-
if (lastEntity != undefined) {
|
|
54
|
-
queryParams = queryParams + `&lastEntity=${lastEntity}`;
|
|
55
|
-
}
|
|
56
|
-
const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/container/${transferId}/page?${queryParams}`);
|
|
57
|
-
const containerResponse = await (0, utils_1.getResponseBody)(result);
|
|
58
|
-
let results = [];
|
|
59
|
-
if (containerResponse.containers != null) {
|
|
60
|
-
results = Object.entries(containerResponse.containers).map((item) => {
|
|
61
|
-
return { key: item[0], value: item[1] };
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
results: results,
|
|
66
|
-
nextCursor: containerResponse.meta.lastEntity != null ? containerResponse.meta.lastEntity : undefined
|
|
18
|
+
this.getAppDataPayload = async (key) => {
|
|
19
|
+
const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/data/${key}`);
|
|
20
|
+
const appDataPayload = await (0, utils_1.getResponseBody)(result);
|
|
21
|
+
return api_1.default.fetch(appDataPayload.url);
|
|
67
22
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
23
|
+
this.messageProcessed = async (transferId, messageId) => {
|
|
24
|
+
const request = {
|
|
25
|
+
status: 'SUCCESS',
|
|
26
|
+
messageIds: [messageId]
|
|
27
|
+
};
|
|
28
|
+
const result = await (0, utils_1.invokePOSTApi)(`${this.basePath}/message/${transferId}/status`, request);
|
|
29
|
+
return (0, utils_1.getResponseBody)(result);
|
|
30
|
+
};
|
|
31
|
+
this.getMappings = async (transferId, namespace, lastEntity, pageSize) => {
|
|
32
|
+
let queryParams = `namespace=${namespace}`;
|
|
33
|
+
if (pageSize != undefined) {
|
|
34
|
+
queryParams = queryParams + `&pageSize=${pageSize}`;
|
|
35
|
+
}
|
|
36
|
+
if (lastEntity != undefined) {
|
|
37
|
+
queryParams = queryParams + `&lastEntity=${lastEntity}`;
|
|
38
|
+
}
|
|
39
|
+
const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/mapping/${transferId}/page?${queryParams}`);
|
|
40
|
+
const mappingResponse = await (0, utils_1.getResponseBody)(result);
|
|
41
|
+
let results = [];
|
|
42
|
+
if (mappingResponse.items != null) {
|
|
43
|
+
results = Object.entries(mappingResponse.items).map((item) => {
|
|
44
|
+
return { key: item[0], value: item[1] };
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
results: results,
|
|
49
|
+
nextCursor: mappingResponse.meta.lastEntity != null ? mappingResponse.meta.lastEntity : undefined
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
this.getContainers = async (transferId, containerType, lastEntity, pageSize) => {
|
|
53
|
+
let queryParams = `containerType=${containerType}`;
|
|
54
|
+
if (pageSize != undefined) {
|
|
55
|
+
queryParams = queryParams + `&pageSize=${pageSize}`;
|
|
56
|
+
}
|
|
57
|
+
if (lastEntity != undefined) {
|
|
58
|
+
queryParams = queryParams + `&lastEntity=${lastEntity}`;
|
|
59
|
+
}
|
|
60
|
+
const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/container/${transferId}/page?${queryParams}`);
|
|
61
|
+
const containerResponse = await (0, utils_1.getResponseBody)(result);
|
|
62
|
+
let results = [];
|
|
63
|
+
if (containerResponse.containers != null) {
|
|
64
|
+
results = Object.entries(containerResponse.containers).map((item) => {
|
|
65
|
+
return { key: item[0], value: item[1] };
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
results: results,
|
|
70
|
+
nextCursor: containerResponse.meta.lastEntity != null ? containerResponse.meta.lastEntity : undefined
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
this.list = async (options, pageSize) => {
|
|
74
|
+
if (options.namespace != undefined)
|
|
75
|
+
return this.getMappings(options.transferId, options.namespace, options.cursor, pageSize);
|
|
76
|
+
else
|
|
77
|
+
return this.getContainers(options.transferId, options.containerType, options.cursor, pageSize);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
81
|
exports.Migration = Migration;
|
|
@@ -2,17 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultQueryBuilder = void 0;
|
|
4
4
|
class DefaultQueryBuilder {
|
|
5
|
-
migration;
|
|
6
|
-
queryOptions;
|
|
7
5
|
constructor(migration, queryOptions) {
|
|
8
6
|
this.migration = migration;
|
|
9
7
|
this.queryOptions = queryOptions;
|
|
10
8
|
}
|
|
11
9
|
cursor(cursor) {
|
|
12
|
-
return new DefaultQueryBuilder(this.migration, {
|
|
13
|
-
...this.queryOptions,
|
|
14
|
-
cursor
|
|
15
|
-
});
|
|
10
|
+
return new DefaultQueryBuilder(this.migration, Object.assign(Object.assign({}, this.queryOptions), { cursor }));
|
|
16
11
|
}
|
|
17
12
|
async getOne() {
|
|
18
13
|
const listResults = await this.migration.list(this.queryOptions, 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/migrations",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-next.1",
|
|
4
4
|
"description": "App migration methods for Forge app",
|
|
5
5
|
"main": "out/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
"node-fetch": "2.7.0"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@forge/api": "3.
|
|
21
|
+
"@forge/api": "3.6.0-next.0"
|
|
22
22
|
}
|
|
23
23
|
}
|