@forge/migrations 0.3.3 → 0.3.4-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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @forge/migrations
2
2
 
3
+ ## 0.3.4-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [1588c76]
8
+ - @forge/api@3.6.0-next.0
9
+
3
10
  ## 0.3.3
4
11
 
5
12
  ### Patch Changes
@@ -3,74 +3,76 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Migration = void 0;
4
4
  const utils_1 = require("./utils");
5
5
  class Migration {
6
- basePath = '/app/migration/forge/v1';
7
- getMappingById = async (transferId, namespace, keys) => {
8
- const result = await (0, utils_1.invokePOSTApi)(`${this.basePath}/mapping/${transferId}/find?namespace=${namespace}`, keys);
9
- return (0, utils_1.getResponseBody)(result);
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]
6
+ constructor() {
7
+ this.basePath = '/app/migration/forge/v1';
8
+ this.getMappingById = async (transferId, namespace, keys) => {
9
+ const result = await (0, utils_1.invokePOSTApi)(`${this.basePath}/mapping/${transferId}/find?namespace=${namespace}`, keys);
10
+ return (0, utils_1.getResponseBody)(result);
23
11
  };
24
- const result = await (0, utils_1.invokePOSTApi)(`${this.basePath}/message/${transferId}/status`, request);
25
- return (0, utils_1.getResponseBody)(result);
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
12
+ this.getAppDataList = async (transferId) => {
13
+ const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/data/${transferId}/all`);
14
+ return (0, utils_1.getResponseBody)(result);
46
15
  };
47
- };
48
- getContainers = async (transferId, containerType, lastEntity, pageSize) => {
49
- let queryParams = `containerType=${containerType}`;
50
- if (pageSize != undefined) {
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
16
+ this.getAppDataPayload = async (s3Key) => {
17
+ const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/data/${s3Key}`);
18
+ return (0, utils_1.getResponseBody)(result);
67
19
  };
68
- };
69
- list = async (options, pageSize) => {
70
- if (options.namespace != undefined)
71
- return this.getMappings(options.transferId, options.namespace, options.cursor, pageSize);
72
- else
73
- return this.getContainers(options.transferId, options.containerType, options.cursor, pageSize);
74
- };
20
+ this.messageProcessed = async (transferId, messageId) => {
21
+ const request = {
22
+ status: 'SUCCESS',
23
+ messageIds: [messageId]
24
+ };
25
+ const result = await (0, utils_1.invokePOSTApi)(`${this.basePath}/message/${transferId}/status`, request);
26
+ return (0, utils_1.getResponseBody)(result);
27
+ };
28
+ this.getMappings = async (transferId, namespace, lastEntity, pageSize) => {
29
+ let queryParams = `namespace=${namespace}`;
30
+ if (pageSize != undefined) {
31
+ queryParams = queryParams + `&pageSize=${pageSize}`;
32
+ }
33
+ if (lastEntity != undefined) {
34
+ queryParams = queryParams + `&lastEntity=${lastEntity}`;
35
+ }
36
+ const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/mapping/${transferId}/page?${queryParams}`);
37
+ const mappingResponse = await (0, utils_1.getResponseBody)(result);
38
+ let results = [];
39
+ if (mappingResponse.items != null) {
40
+ results = Object.entries(mappingResponse.items).map((item) => {
41
+ return { key: item[0], value: item[1] };
42
+ });
43
+ }
44
+ return {
45
+ results: results,
46
+ nextCursor: mappingResponse.meta.lastEntity != null ? mappingResponse.meta.lastEntity : undefined
47
+ };
48
+ };
49
+ this.getContainers = async (transferId, containerType, lastEntity, pageSize) => {
50
+ let queryParams = `containerType=${containerType}`;
51
+ if (pageSize != undefined) {
52
+ queryParams = queryParams + `&pageSize=${pageSize}`;
53
+ }
54
+ if (lastEntity != undefined) {
55
+ queryParams = queryParams + `&lastEntity=${lastEntity}`;
56
+ }
57
+ const result = await (0, utils_1.invokeGETApi)(`${this.basePath}/container/${transferId}/page?${queryParams}`);
58
+ const containerResponse = await (0, utils_1.getResponseBody)(result);
59
+ let results = [];
60
+ if (containerResponse.containers != null) {
61
+ results = Object.entries(containerResponse.containers).map((item) => {
62
+ return { key: item[0], value: item[1] };
63
+ });
64
+ }
65
+ return {
66
+ results: results,
67
+ nextCursor: containerResponse.meta.lastEntity != null ? containerResponse.meta.lastEntity : undefined
68
+ };
69
+ };
70
+ this.list = async (options, pageSize) => {
71
+ if (options.namespace != undefined)
72
+ return this.getMappings(options.transferId, options.namespace, options.cursor, pageSize);
73
+ else
74
+ return this.getContainers(options.transferId, options.containerType, options.cursor, pageSize);
75
+ };
76
+ }
75
77
  }
76
78
  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.3",
3
+ "version": "0.3.4-next.0",
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.5.0"
21
+ "@forge/api": "3.6.0-next.0"
22
22
  }
23
23
  }