@webiny/data-migration 0.0.0-unstable.99666aeb00 → 0.0.0-unstable.a9593f74dd

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.
Files changed (74) hide show
  1. package/MigrationRunner.d.ts +3 -1
  2. package/MigrationRunner.js +29 -16
  3. package/MigrationRunner.js.map +1 -1
  4. package/cli/CliMigrationRunReporter.d.ts +10 -0
  5. package/cli/CliMigrationRunReporter.js +55 -0
  6. package/cli/CliMigrationRunReporter.js.map +1 -0
  7. package/cli/InteractiveCliStatusReporter.d.ts +11 -0
  8. package/cli/InteractiveCliStatusReporter.js +74 -0
  9. package/cli/InteractiveCliStatusReporter.js.map +1 -0
  10. package/cli/LogReporter.d.ts +10 -0
  11. package/cli/LogReporter.js +43 -0
  12. package/cli/LogReporter.js.map +1 -0
  13. package/cli/LogStream.d.ts +10 -0
  14. package/cli/LogStream.js +58 -0
  15. package/cli/LogStream.js.map +1 -0
  16. package/cli/MigrationRunReporter.d.ts +4 -0
  17. package/cli/MigrationRunReporter.js +7 -0
  18. package/cli/MigrationRunReporter.js.map +1 -0
  19. package/cli/MigrationRunner.d.ts +44 -0
  20. package/cli/MigrationRunner.js +136 -0
  21. package/cli/MigrationRunner.js.map +1 -0
  22. package/cli/MigrationStatusReporter.d.ts +4 -0
  23. package/cli/MigrationStatusReporter.js +7 -0
  24. package/cli/MigrationStatusReporter.js.map +1 -0
  25. package/cli/NonInteractiveCliStatusReporter.d.ts +9 -0
  26. package/cli/NonInteractiveCliStatusReporter.js +42 -0
  27. package/cli/NonInteractiveCliStatusReporter.js.map +1 -0
  28. package/cli/VoidStatusReporter.d.ts +4 -0
  29. package/cli/VoidStatusReporter.js +14 -0
  30. package/cli/VoidStatusReporter.js.map +1 -0
  31. package/cli/getDuration.js +3 -1
  32. package/cli/getDuration.js.map +1 -1
  33. package/cli/index.d.ts +8 -2
  34. package/cli/index.js +81 -13
  35. package/cli/index.js.map +1 -1
  36. package/createPinoLogger.d.ts +57 -4
  37. package/createPinoLogger.js +7 -3
  38. package/createPinoLogger.js.map +1 -1
  39. package/createTable.d.ts +4 -4
  40. package/createTable.js +9 -4
  41. package/createTable.js.map +1 -1
  42. package/handlers/createDdbEsProjectMigration.d.ts +3 -3
  43. package/handlers/createDdbEsProjectMigration.js +19 -17
  44. package/handlers/createDdbEsProjectMigration.js.map +1 -1
  45. package/handlers/createDdbProjectMigration.d.ts +2 -2
  46. package/handlers/createDdbProjectMigration.js +17 -15
  47. package/handlers/createDdbProjectMigration.js.map +1 -1
  48. package/handlers/createPatternMatcher.js +3 -1
  49. package/handlers/createPatternMatcher.js.map +1 -1
  50. package/handlers/devVersionErrorResponse.js +3 -1
  51. package/handlers/devVersionErrorResponse.js.map +1 -1
  52. package/index.js +3 -1
  53. package/index.js.map +1 -1
  54. package/package.json +15 -15
  55. package/repository/createStandardEntity.d.ts +49 -3
  56. package/repository/createStandardEntity.js +5 -3
  57. package/repository/createStandardEntity.js.map +1 -1
  58. package/repository/migrations.repository.d.ts +2 -2
  59. package/repository/migrations.repository.js +49 -36
  60. package/repository/migrations.repository.js.map +1 -1
  61. package/symbols.js +3 -1
  62. package/symbols.js.map +1 -1
  63. package/types.d.ts +6 -4
  64. package/types.js +2 -7
  65. package/types.js.map +1 -1
  66. package/cli/getMigrationStatus.d.ts +0 -9
  67. package/cli/getMigrationStatus.js +0 -27
  68. package/cli/getMigrationStatus.js.map +0 -1
  69. package/cli/printReport.d.ts +0 -9
  70. package/cli/printReport.js +0 -57
  71. package/cli/printReport.js.map +0 -1
  72. package/cli/runMigration.d.ts +0 -13
  73. package/cli/runMigration.js +0 -85
  74. package/cli/runMigration.js.map +0 -1
@@ -0,0 +1,44 @@
1
+ import { LambdaClient } from "@webiny/aws-sdk/client-lambda";
2
+ import { MigrationStatusReporter } from "./MigrationStatusReporter";
3
+ import { MigrationInvocationErrorResponse, MigrationStatusResponse } from "../types";
4
+ interface MigrationRunnerConfig {
5
+ lambdaClient: LambdaClient;
6
+ functionName: string;
7
+ statusReporter?: MigrationStatusReporter;
8
+ }
9
+ interface MigrationPayload {
10
+ version: string;
11
+ pattern?: string;
12
+ }
13
+ interface SuccessResultHandler {
14
+ (result: MigrationStatusResponse["data"]): void | Promise<void>;
15
+ }
16
+ interface ErrorResultHandler {
17
+ (error: MigrationInvocationErrorResponse["error"]): void | Promise<void>;
18
+ }
19
+ export declare class MigrationRunnerResult {
20
+ private readonly functionName;
21
+ private readonly result;
22
+ private readonly successBranch;
23
+ private readonly errorBranch;
24
+ constructor(functionName: string, result: MigrationStatusResponse | MigrationInvocationErrorResponse);
25
+ getFunctionName(): string;
26
+ onSuccess(cb: SuccessResultHandler): void;
27
+ onError(cb: ErrorResultHandler): void;
28
+ process(): Promise<void>;
29
+ }
30
+ export declare class MigrationRunner {
31
+ private readonly lambdaClient;
32
+ private readonly functionName;
33
+ private statusReporter;
34
+ static create(params: MigrationRunnerConfig): MigrationRunner;
35
+ private constructor();
36
+ setStatusReporter(reporter: MigrationStatusReporter): void;
37
+ runMigration(payload: MigrationPayload): Promise<MigrationRunnerResult>;
38
+ private reportStatus;
39
+ private invokeMigration;
40
+ private getResult;
41
+ private getStatus;
42
+ private getMigrationStatusReportInterval;
43
+ }
44
+ export {};
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MigrationRunnerResult = exports.MigrationRunner = void 0;
7
+ var _clientLambda = require("@webiny/aws-sdk/client-lambda");
8
+ var _utils = require("@webiny/utils");
9
+ var _VoidStatusReporter = require("./VoidStatusReporter");
10
+ class MigrationRunnerResult {
11
+ successBranch = [];
12
+ errorBranch = [];
13
+ constructor(functionName, result) {
14
+ this.functionName = functionName;
15
+ this.result = result;
16
+ }
17
+ getFunctionName() {
18
+ return this.functionName;
19
+ }
20
+ onSuccess(cb) {
21
+ this.successBranch.push(cb);
22
+ }
23
+ onError(cb) {
24
+ this.errorBranch.push(cb);
25
+ }
26
+ async process() {
27
+ if (this.result.error) {
28
+ for (const handler of this.errorBranch) {
29
+ await handler(this.result.error);
30
+ }
31
+ return;
32
+ }
33
+ for (const handler of this.successBranch) {
34
+ await handler(this.result.data);
35
+ }
36
+ }
37
+ }
38
+ exports.MigrationRunnerResult = MigrationRunnerResult;
39
+ class MigrationRunner {
40
+ statusReporter = new _VoidStatusReporter.VoidStatusReporter();
41
+ static create(params) {
42
+ const runner = new MigrationRunner(params.lambdaClient, params.functionName);
43
+ if (params.statusReporter) {
44
+ runner.setStatusReporter(params.statusReporter);
45
+ }
46
+ return runner;
47
+ }
48
+ constructor(lambdaClient, functionName) {
49
+ this.lambdaClient = lambdaClient;
50
+ this.functionName = functionName;
51
+ }
52
+ setStatusReporter(reporter) {
53
+ this.statusReporter = reporter;
54
+ }
55
+ async runMigration(payload) {
56
+ // Execute migration function.
57
+ await this.invokeMigration(payload);
58
+
59
+ // Poll for status and re-execute when migration is in "pending" state.
60
+ let response;
61
+ while (true) {
62
+ await new Promise(resolve => setTimeout(resolve, this.getMigrationStatusReportInterval()));
63
+ response = await this.getStatus(payload);
64
+ if (!response) {
65
+ continue;
66
+ }
67
+ const {
68
+ data,
69
+ error
70
+ } = response;
71
+
72
+ // If we received an error, it must be an unrecoverable error, and we don't retry.
73
+ if (error) {
74
+ return this.getResult(response);
75
+ }
76
+ switch (data.status) {
77
+ case "init":
78
+ await this.reportStatus(data);
79
+ continue;
80
+ case "pending":
81
+ await this.invokeMigration(payload);
82
+ break;
83
+ case "running":
84
+ await this.reportStatus(data);
85
+ break;
86
+ case "done":
87
+ await this.reportStatus(data);
88
+ return this.getResult(response);
89
+ default:
90
+ return this.getResult(response);
91
+ }
92
+ }
93
+ }
94
+ async reportStatus(data) {
95
+ await this.statusReporter.report(data);
96
+ }
97
+ async invokeMigration(payload) {
98
+ const response = await this.lambdaClient.send(new _clientLambda.InvokeCommand({
99
+ FunctionName: this.functionName,
100
+ InvocationType: "Event",
101
+ Payload: JSON.stringify({
102
+ ...payload,
103
+ command: "execute"
104
+ })
105
+ }));
106
+ return response.StatusCode;
107
+ }
108
+ getResult(response) {
109
+ return new MigrationRunnerResult(this.functionName, response);
110
+ }
111
+ async getStatus(payload) {
112
+ const getStatus = () => {
113
+ return this.lambdaClient.send(new _clientLambda.InvokeCommand({
114
+ FunctionName: this.functionName,
115
+ InvocationType: "RequestResponse",
116
+ Payload: JSON.stringify({
117
+ ...payload,
118
+ command: "status"
119
+ })
120
+ }));
121
+ };
122
+ const response = await (0, _utils.executeWithRetry)(getStatus);
123
+ const decoder = new TextDecoder("utf-8");
124
+ return JSON.parse(decoder.decode(response.Payload));
125
+ }
126
+ getMigrationStatusReportInterval() {
127
+ const envKey = "MIGRATION_STATUS_REPORT_INTERVAL";
128
+ if (envKey in process.env) {
129
+ return parseInt(String(process.env[envKey]));
130
+ }
131
+ return 2000;
132
+ }
133
+ }
134
+ exports.MigrationRunner = MigrationRunner;
135
+
136
+ //# sourceMappingURL=MigrationRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_clientLambda","require","_utils","_VoidStatusReporter","MigrationRunnerResult","successBranch","errorBranch","constructor","functionName","result","getFunctionName","onSuccess","cb","push","onError","process","error","handler","data","exports","MigrationRunner","statusReporter","VoidStatusReporter","create","params","runner","lambdaClient","setStatusReporter","reporter","runMigration","payload","invokeMigration","response","Promise","resolve","setTimeout","getMigrationStatusReportInterval","getStatus","getResult","status","reportStatus","report","send","InvokeCommand","FunctionName","InvocationType","Payload","JSON","stringify","command","StatusCode","executeWithRetry","decoder","TextDecoder","parse","decode","envKey","env","parseInt","String"],"sources":["MigrationRunner.ts"],"sourcesContent":["import { InvokeCommand, LambdaClient } from \"@webiny/aws-sdk/client-lambda\";\nimport { MigrationStatusReporter } from \"~/cli/MigrationStatusReporter\";\nimport {\n MigrationEventHandlerResponse,\n MigrationInvocationErrorResponse,\n MigrationStatus,\n MigrationStatusResponse\n} from \"~/types\";\nimport { executeWithRetry } from \"@webiny/utils\";\nimport { VoidStatusReporter } from \"./VoidStatusReporter\";\n\ninterface MigrationRunnerConfig {\n lambdaClient: LambdaClient;\n functionName: string;\n statusReporter?: MigrationStatusReporter;\n}\n\ninterface MigrationPayload {\n version: string;\n pattern?: string;\n}\n\ninterface SuccessResultHandler {\n (result: MigrationStatusResponse[\"data\"]): void | Promise<void>;\n}\n\ninterface ErrorResultHandler {\n (error: MigrationInvocationErrorResponse[\"error\"]): void | Promise<void>;\n}\n\nexport class MigrationRunnerResult {\n private readonly functionName: string;\n private readonly result: MigrationStatusResponse | MigrationInvocationErrorResponse;\n private readonly successBranch: SuccessResultHandler[] = [];\n private readonly errorBranch: ErrorResultHandler[] = [];\n\n constructor(\n functionName: string,\n result: MigrationStatusResponse | MigrationInvocationErrorResponse\n ) {\n this.functionName = functionName;\n this.result = result;\n }\n\n getFunctionName() {\n return this.functionName;\n }\n\n onSuccess(cb: SuccessResultHandler) {\n this.successBranch.push(cb);\n }\n\n onError(cb: ErrorResultHandler) {\n this.errorBranch.push(cb);\n }\n\n async process(): Promise<void> {\n if (this.result.error) {\n for (const handler of this.errorBranch) {\n await handler(this.result.error);\n }\n return;\n }\n\n for (const handler of this.successBranch) {\n await handler(this.result.data);\n }\n }\n}\n\nexport class MigrationRunner {\n private readonly lambdaClient: LambdaClient;\n private readonly functionName: string;\n private statusReporter: MigrationStatusReporter = new VoidStatusReporter();\n\n public static create(params: MigrationRunnerConfig) {\n const runner = new MigrationRunner(params.lambdaClient, params.functionName);\n if (params.statusReporter) {\n runner.setStatusReporter(params.statusReporter);\n }\n return runner;\n }\n\n private constructor(lambdaClient: LambdaClient, functionName: string) {\n this.lambdaClient = lambdaClient;\n this.functionName = functionName;\n }\n\n public setStatusReporter(reporter: MigrationStatusReporter) {\n this.statusReporter = reporter;\n }\n\n async runMigration(payload: MigrationPayload): Promise<MigrationRunnerResult> {\n // Execute migration function.\n await this.invokeMigration(payload);\n\n // Poll for status and re-execute when migration is in \"pending\" state.\n let response: MigrationEventHandlerResponse;\n\n while (true) {\n await new Promise(resolve =>\n setTimeout(resolve, this.getMigrationStatusReportInterval())\n );\n\n response = await this.getStatus(payload);\n\n if (!response) {\n continue;\n }\n\n const { data, error } = response;\n\n // If we received an error, it must be an unrecoverable error, and we don't retry.\n if (error) {\n return this.getResult(response);\n }\n\n switch (data.status) {\n case \"init\":\n await this.reportStatus(data);\n continue;\n case \"pending\":\n await this.invokeMigration(payload);\n break;\n case \"running\":\n await this.reportStatus(data);\n break;\n case \"done\":\n await this.reportStatus(data);\n return this.getResult(response);\n default:\n return this.getResult(response);\n }\n }\n }\n\n private async reportStatus(data: MigrationStatus) {\n await this.statusReporter.report(data);\n }\n\n private async invokeMigration(payload: MigrationPayload) {\n const response = await this.lambdaClient.send(\n new InvokeCommand({\n FunctionName: this.functionName,\n InvocationType: \"Event\",\n Payload: JSON.stringify({ ...payload, command: \"execute\" })\n })\n );\n\n return response.StatusCode;\n }\n\n private getResult(response: MigrationStatusResponse | MigrationInvocationErrorResponse) {\n return new MigrationRunnerResult(this.functionName, response);\n }\n\n private async getStatus(payload: Record<string, any>) {\n const getStatus = () => {\n return this.lambdaClient.send(\n new InvokeCommand({\n FunctionName: this.functionName,\n InvocationType: \"RequestResponse\",\n Payload: JSON.stringify({ ...payload, command: \"status\" })\n })\n );\n };\n\n const response = await executeWithRetry(getStatus);\n\n const decoder = new TextDecoder(\"utf-8\");\n return JSON.parse(decoder.decode(response.Payload)) as MigrationEventHandlerResponse;\n }\n\n private getMigrationStatusReportInterval() {\n const envKey = \"MIGRATION_STATUS_REPORT_INTERVAL\";\n if (envKey in process.env) {\n return parseInt(String(process.env[envKey]));\n }\n return 2000;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAqBO,MAAMG,qBAAqB,CAAC;EAGdC,aAAa,GAA2B,EAAE;EAC1CC,WAAW,GAAyB,EAAE;EAEv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,eAAA,GAAAA,eAAA"}
@@ -0,0 +1,4 @@
1
+ import { MigrationStatus } from "../types";
2
+ export interface MigrationStatusReporter {
3
+ report(status: MigrationStatus): void;
4
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ //# sourceMappingURL=MigrationStatusReporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["MigrationStatusReporter.ts"],"sourcesContent":["import { MigrationStatus } from \"~/types\";\n\nexport interface MigrationStatusReporter {\n report(status: MigrationStatus): void;\n}\n"],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { MigrationStatusReporter } from "./MigrationStatusReporter";
2
+ import { MigrationStatus } from "../types";
3
+ import { LogReporter } from "./LogReporter";
4
+ export declare class NonInteractiveCliStatusReporter implements MigrationStatusReporter {
5
+ private logReporter;
6
+ private firstCall;
7
+ constructor(logReporter: LogReporter);
8
+ report(migrationStatus: MigrationStatus): Promise<void>;
9
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NonInteractiveCliStatusReporter = void 0;
7
+ class NonInteractiveCliStatusReporter {
8
+ firstCall = true;
9
+ constructor(logReporter) {
10
+ this.logReporter = logReporter;
11
+ console.log(`Using "NonInteractiveCliStatusReporter".`);
12
+ }
13
+ async report(migrationStatus) {
14
+ const {
15
+ status,
16
+ context
17
+ } = migrationStatus;
18
+ const currentLogStreamName = context?.logStreamName;
19
+ if (currentLogStreamName) {
20
+ this.logReporter.initializeStream(currentLogStreamName);
21
+ if (this.firstCall) {
22
+ this.logReporter.printLogStreamLinks();
23
+ process.stdout.write(`\n---------- MIGRATION LOGS START ----------\n\n`);
24
+ }
25
+ await this.logReporter.printLogs(currentLogStreamName);
26
+ }
27
+ if (["done", "error"].includes(status)) {
28
+ // We want to give AWS some time for the latest log events to become available.
29
+ await new Promise(resolve => {
30
+ setTimeout(resolve, 10000);
31
+ });
32
+ if (currentLogStreamName) {
33
+ await this.logReporter.printLogs(currentLogStreamName);
34
+ process.stdout.write(`\n---------- MIGRATION LOGS END ----------\n`);
35
+ }
36
+ }
37
+ this.firstCall = false;
38
+ }
39
+ }
40
+ exports.NonInteractiveCliStatusReporter = NonInteractiveCliStatusReporter;
41
+
42
+ //# sourceMappingURL=NonInteractiveCliStatusReporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NonInteractiveCliStatusReporter","firstCall","constructor","logReporter","console","log","report","migrationStatus","status","context","currentLogStreamName","logStreamName","initializeStream","printLogStreamLinks","process","stdout","write","printLogs","includes","Promise","resolve","setTimeout","exports"],"sources":["NonInteractiveCliStatusReporter.ts"],"sourcesContent":["import { MigrationStatusReporter } from \"~/cli/MigrationStatusReporter\";\nimport { MigrationStatus } from \"~/types\";\nimport { LogReporter } from \"~/cli/LogReporter\";\n\nexport class NonInteractiveCliStatusReporter implements MigrationStatusReporter {\n private logReporter: LogReporter;\n private firstCall = true;\n\n constructor(logReporter: LogReporter) {\n this.logReporter = logReporter;\n console.log(`Using \"NonInteractiveCliStatusReporter\".`);\n }\n\n async report(migrationStatus: MigrationStatus) {\n const { status, context } = migrationStatus;\n\n const currentLogStreamName = context?.logStreamName;\n\n if (currentLogStreamName) {\n this.logReporter.initializeStream(currentLogStreamName);\n if (this.firstCall) {\n this.logReporter.printLogStreamLinks();\n process.stdout.write(`\\n---------- MIGRATION LOGS START ----------\\n\\n`);\n }\n await this.logReporter.printLogs(currentLogStreamName);\n }\n\n if ([\"done\", \"error\"].includes(status)) {\n // We want to give AWS some time for the latest log events to become available.\n await new Promise(resolve => {\n setTimeout(resolve, 10000);\n });\n\n if (currentLogStreamName) {\n await this.logReporter.printLogs(currentLogStreamName);\n process.stdout.write(`\\n---------- MIGRATION LOGS END ----------\\n`);\n }\n }\n\n this.firstCall = false;\n }\n}\n"],"mappings":";;;;;;AAIO,MAAMA,+BAA+B,CAAoC;EAEpEC,SAAS,GAAG,IAAI;EAExBC,WAAWA,CAACC,WAAwB,EAAE;IAClC,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9BC,OAAO,CAACC,GAAG,CAAE,0CAAyC,CAAC;EAC3D;EAEA,MAAMC,MAAMA,CAACC,eAAgC,EAAE;IAC3C,MAAM;MAAEC,MAAM;MAAEC;IAAQ,CAAC,GAAGF,eAAe;IAE3C,MAAMG,oBAAoB,GAAGD,OAAO,EAAEE,aAAa;IAEnD,IAAID,oBAAoB,EAAE;MACtB,IAAI,CAACP,WAAW,CAACS,gBAAgB,CAACF,oBAAoB,CAAC;MACvD,IAAI,IAAI,CAACT,SAAS,EAAE;QAChB,IAAI,CAACE,WAAW,CAACU,mBAAmB,CAAC,CAAC;QACtCC,OAAO,CAACC,MAAM,CAACC,KAAK,CAAE,kDAAiD,CAAC;MAC5E;MACA,MAAM,IAAI,CAACb,WAAW,CAACc,SAAS,CAACP,oBAAoB,CAAC;IAC1D;IAEA,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAACQ,QAAQ,CAACV,MAAM,CAAC,EAAE;MACpC;MACA,MAAM,IAAIW,OAAO,CAACC,OAAO,IAAI;QACzBC,UAAU,CAACD,OAAO,EAAE,KAAK,CAAC;MAC9B,CAAC,CAAC;MAEF,IAAIV,oBAAoB,EAAE;QACtB,MAAM,IAAI,CAACP,WAAW,CAACc,SAAS,CAACP,oBAAoB,CAAC;QACtDI,OAAO,CAACC,MAAM,CAACC,KAAK,CAAE,8CAA6C,CAAC;MACxE;IACJ;IAEA,IAAI,CAACf,SAAS,GAAG,KAAK;EAC1B;AACJ;AAACqB,OAAA,CAAAtB,+BAAA,GAAAA,+BAAA"}
@@ -0,0 +1,4 @@
1
+ import { MigrationStatusReporter } from "./MigrationStatusReporter";
2
+ export declare class VoidStatusReporter implements MigrationStatusReporter {
3
+ report(): void;
4
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VoidStatusReporter = void 0;
7
+ class VoidStatusReporter {
8
+ report() {
9
+ // This is a void reporter.
10
+ }
11
+ }
12
+ exports.VoidStatusReporter = VoidStatusReporter;
13
+
14
+ //# sourceMappingURL=VoidStatusReporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["VoidStatusReporter","report","exports"],"sources":["VoidStatusReporter.ts"],"sourcesContent":["import { MigrationStatusReporter } from \"./MigrationStatusReporter\";\n\nexport class VoidStatusReporter implements MigrationStatusReporter {\n report(): void {\n // This is a void reporter.\n }\n}\n"],"mappings":";;;;;;AAEO,MAAMA,kBAAkB,CAAoC;EAC/DC,MAAMA,CAAA,EAAS;IACX;EAAA;AAER;AAACC,OAAA,CAAAF,kBAAA,GAAAA,kBAAA"}
@@ -18,4 +18,6 @@ const getDuration = since => {
18
18
  }
19
19
  return minutes ? `${minutes}m ${seconds}s` : `${seconds}s`;
20
20
  };
21
- exports.getDuration = getDuration;
21
+ exports.getDuration = getDuration;
22
+
23
+ //# sourceMappingURL=getDuration.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getDuration","since","ms","Date","getTime","seconds","Math","floor","minutes","undefined"],"sources":["getDuration.ts"],"sourcesContent":["/**\n * Get duration since the given ISO timestamp.\n * @param string since\n */\nexport const getDuration = (since: string) => {\n const ms = new Date().getTime() - new Date(since).getTime();\n let seconds = Math.floor(ms / 1000);\n let minutes = undefined;\n if (seconds > 60) {\n minutes = Math.floor(seconds / 60);\n seconds = Math.floor(seconds % 60);\n }\n\n return minutes ? `${minutes}m ${seconds}s` : `${seconds}s`;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAIC,KAAa,IAAK;EAC1C,MAAMC,EAAE,GAAG,IAAIC,IAAI,EAAE,CAACC,OAAO,EAAE,GAAG,IAAID,IAAI,CAACF,KAAK,CAAC,CAACG,OAAO,EAAE;EAC3D,IAAIC,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACL,EAAE,GAAG,IAAI,CAAC;EACnC,IAAIM,OAAO,GAAGC,SAAS;EACvB,IAAIJ,OAAO,GAAG,EAAE,EAAE;IACdG,OAAO,GAAGF,IAAI,CAACC,KAAK,CAACF,OAAO,GAAG,EAAE,CAAC;IAClCA,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACF,OAAO,GAAG,EAAE,CAAC;EACtC;EAEA,OAAOG,OAAO,GAAI,GAAEA,OAAQ,KAAIH,OAAQ,GAAE,GAAI,GAAEA,OAAQ,GAAE;AAC9D,CAAC;AAAC"}
1
+ {"version":3,"names":["getDuration","since","ms","Date","getTime","seconds","Math","floor","minutes","undefined","exports"],"sources":["getDuration.ts"],"sourcesContent":["/**\n * Get duration since the given ISO timestamp.\n * @param string since\n */\nexport const getDuration = (since: string) => {\n const ms = new Date().getTime() - new Date(since).getTime();\n let seconds = Math.floor(ms / 1000);\n let minutes = undefined;\n if (seconds > 60) {\n minutes = Math.floor(seconds / 60);\n seconds = Math.floor(seconds % 60);\n }\n\n return minutes ? `${minutes}m ${seconds}s` : `${seconds}s`;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAIC,KAAa,IAAK;EAC1C,MAAMC,EAAE,GAAG,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,GAAG,IAAID,IAAI,CAACF,KAAK,CAAC,CAACG,OAAO,CAAC,CAAC;EAC3D,IAAIC,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACL,EAAE,GAAG,IAAI,CAAC;EACnC,IAAIM,OAAO,GAAGC,SAAS;EACvB,IAAIJ,OAAO,GAAG,EAAE,EAAE;IACdG,OAAO,GAAGF,IAAI,CAACC,KAAK,CAACF,OAAO,GAAG,EAAE,CAAC;IAClCA,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACF,OAAO,GAAG,EAAE,CAAC;EACtC;EAEA,OAAOG,OAAO,GAAI,GAAEA,OAAQ,KAAIH,OAAQ,GAAE,GAAI,GAAEA,OAAQ,GAAE;AAC9D,CAAC;AAACK,OAAA,CAAAV,WAAA,GAAAA,WAAA"}
package/cli/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
- export * from "./printReport";
2
- export * from "./runMigration";
3
1
  export * from "./getDuration";
2
+ export * from "./MigrationRunner";
3
+ export * from "./MigrationStatusReporter";
4
+ export * from "./MigrationRunReporter";
5
+ export * from "./InteractiveCliStatusReporter";
6
+ export * from "./NonInteractiveCliStatusReporter";
7
+ export * from "./CliMigrationRunReporter";
8
+ export * from "./LogStream";
9
+ export * from "./LogReporter";
package/cli/index.js CHANGED
@@ -3,36 +3,104 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _printReport = require("./printReport");
7
- Object.keys(_printReport).forEach(function (key) {
6
+ var _getDuration = require("./getDuration");
7
+ Object.keys(_getDuration).forEach(function (key) {
8
8
  if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _printReport[key]) return;
9
+ if (key in exports && exports[key] === _getDuration[key]) return;
10
10
  Object.defineProperty(exports, key, {
11
11
  enumerable: true,
12
12
  get: function () {
13
- return _printReport[key];
13
+ return _getDuration[key];
14
14
  }
15
15
  });
16
16
  });
17
- var _runMigration = require("./runMigration");
18
- Object.keys(_runMigration).forEach(function (key) {
17
+ var _MigrationRunner = require("./MigrationRunner");
18
+ Object.keys(_MigrationRunner).forEach(function (key) {
19
19
  if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _runMigration[key]) return;
20
+ if (key in exports && exports[key] === _MigrationRunner[key]) return;
21
21
  Object.defineProperty(exports, key, {
22
22
  enumerable: true,
23
23
  get: function () {
24
- return _runMigration[key];
24
+ return _MigrationRunner[key];
25
25
  }
26
26
  });
27
27
  });
28
- var _getDuration = require("./getDuration");
29
- Object.keys(_getDuration).forEach(function (key) {
28
+ var _MigrationStatusReporter = require("./MigrationStatusReporter");
29
+ Object.keys(_MigrationStatusReporter).forEach(function (key) {
30
30
  if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _getDuration[key]) return;
31
+ if (key in exports && exports[key] === _MigrationStatusReporter[key]) return;
32
32
  Object.defineProperty(exports, key, {
33
33
  enumerable: true,
34
34
  get: function () {
35
- return _getDuration[key];
35
+ return _MigrationStatusReporter[key];
36
+ }
37
+ });
38
+ });
39
+ var _MigrationRunReporter = require("./MigrationRunReporter");
40
+ Object.keys(_MigrationRunReporter).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _MigrationRunReporter[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _MigrationRunReporter[key];
47
+ }
48
+ });
49
+ });
50
+ var _InteractiveCliStatusReporter = require("./InteractiveCliStatusReporter");
51
+ Object.keys(_InteractiveCliStatusReporter).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _InteractiveCliStatusReporter[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _InteractiveCliStatusReporter[key];
58
+ }
59
+ });
60
+ });
61
+ var _NonInteractiveCliStatusReporter = require("./NonInteractiveCliStatusReporter");
62
+ Object.keys(_NonInteractiveCliStatusReporter).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _NonInteractiveCliStatusReporter[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _NonInteractiveCliStatusReporter[key];
69
+ }
70
+ });
71
+ });
72
+ var _CliMigrationRunReporter = require("./CliMigrationRunReporter");
73
+ Object.keys(_CliMigrationRunReporter).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _CliMigrationRunReporter[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _CliMigrationRunReporter[key];
80
+ }
81
+ });
82
+ });
83
+ var _LogStream = require("./LogStream");
84
+ Object.keys(_LogStream).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (key in exports && exports[key] === _LogStream[key]) return;
87
+ Object.defineProperty(exports, key, {
88
+ enumerable: true,
89
+ get: function () {
90
+ return _LogStream[key];
36
91
  }
37
92
  });
38
- });
93
+ });
94
+ var _LogReporter = require("./LogReporter");
95
+ Object.keys(_LogReporter).forEach(function (key) {
96
+ if (key === "default" || key === "__esModule") return;
97
+ if (key in exports && exports[key] === _LogReporter[key]) return;
98
+ Object.defineProperty(exports, key, {
99
+ enumerable: true,
100
+ get: function () {
101
+ return _LogReporter[key];
102
+ }
103
+ });
104
+ });
105
+
106
+ //# sourceMappingURL=index.js.map
package/cli/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./printReport\";\nexport * from \"./runMigration\";\nexport * from \"./getDuration\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_getDuration","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_MigrationRunner","_MigrationStatusReporter","_MigrationRunReporter","_InteractiveCliStatusReporter","_NonInteractiveCliStatusReporter","_CliMigrationRunReporter","_LogStream","_LogReporter"],"sources":["index.ts"],"sourcesContent":["export * from \"./getDuration\";\nexport * from \"./MigrationRunner\";\nexport * from \"./MigrationStatusReporter\";\nexport * from \"./MigrationRunReporter\";\nexport * from \"./InteractiveCliStatusReporter\";\nexport * from \"./NonInteractiveCliStatusReporter\";\nexport * from \"./CliMigrationRunReporter\";\nexport * from \"./LogStream\";\nexport * from \"./LogReporter\";\n"],"mappings":";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A;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAM,wBAAA,CAAAV,GAAA;IAAA;EAAA;AAAA;AACA,IAAAW,UAAA,GAAAf,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAa,UAAA,EAAAZ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAW,UAAA,CAAAX,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAO,UAAA,CAAAX,GAAA;IAAA;EAAA;AAAA;AACA,IAAAY,YAAA,GAAAhB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAc,YAAA,EAAAb,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAY,YAAA,CAAAZ,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAQ,YAAA,CAAAZ,GAAA;IAAA;EAAA;AAAA"}
@@ -1,7 +1,60 @@
1
- import { pino, Logger } from "pino";
2
- import pinoPretty from "pino-pretty";
3
1
  import { DataMigration } from "./types";
4
- export declare const createPinoLogger: () => Logger<pinoPretty.PrettyStream>;
5
- export declare const getChildLogger: (logger: Logger, migration: DataMigration) => pino.Logger<import("pino").LoggerOptions & {
2
+ import { Logger } from "@webiny/logger";
3
+ export declare const createPinoLogger: () => Logger<{
4
+ level: string;
5
+ redact?: string[] | import("@webiny/logger").RedactOptions | undefined;
6
+ transport?: import("pino").default.TransportSingleOptions<Record<string, any>> | import("pino").default.TransportMultiOptions<Record<string, any>> | import("pino").default.TransportPipelineOptions<Record<string, any>> | undefined;
7
+ name?: string | undefined;
8
+ base?: {
9
+ [key: string]: any;
10
+ } | null | undefined;
11
+ browser?: {
12
+ asObject?: boolean | undefined;
13
+ write?: import("pino").default.WriteFn | ({
14
+ fatal?: import("pino").default.WriteFn | undefined;
15
+ error?: import("pino").default.WriteFn | undefined;
16
+ warn?: import("pino").default.WriteFn | undefined;
17
+ info?: import("pino").default.WriteFn | undefined;
18
+ debug?: import("pino").default.WriteFn | undefined;
19
+ trace?: import("pino").default.WriteFn | undefined;
20
+ } & {
21
+ [logLevel: string]: import("pino").default.WriteFn;
22
+ }) | undefined;
23
+ serialize?: boolean | string[] | undefined;
24
+ transmit?: {
25
+ level?: string | undefined;
26
+ send: (level: import("pino").default.Level, logEvent: import("pino").default.LogEvent) => void;
27
+ } | undefined;
28
+ } | undefined;
29
+ customLevels?: {
30
+ [key: string]: number;
31
+ } | undefined;
32
+ useOnlyCustomLevels?: boolean | undefined;
33
+ levelVal?: number | undefined;
34
+ onChild?: (<ChildOptions extends import("pino").default.ChildLoggerOptions>(child: import("pino").default.Logger<import("pino").LoggerOptions & ChildOptions>) => void) | undefined;
35
+ safe?: boolean | undefined;
36
+ serializers?: {
37
+ [key: string]: import("pino").default.SerializerFn;
38
+ } | undefined;
39
+ timestamp?: boolean | (() => string) | undefined;
40
+ mixin?: ((mergeObject: object, level: number) => object) | undefined;
41
+ mixinMergeStrategy?: ((mergeObject: object, mixinObject: object) => object) | undefined;
42
+ messageKey?: string | undefined;
43
+ errorKey?: string | undefined;
44
+ nestedKey?: string | undefined;
45
+ enabled?: boolean | undefined;
46
+ formatters?: {
47
+ level?: ((label: string, number: number) => object) | undefined;
48
+ bindings?: ((bindings: import("pino").default.Bindings) => object) | undefined;
49
+ log?: ((object: Record<string, unknown>) => Record<string, unknown>) | undefined;
50
+ } | undefined;
51
+ msgPrefix?: string | undefined;
52
+ hooks?: {
53
+ logMethod?: ((this: import("pino").default.Logger<import("pino").default.LoggerOptions>, args: [msg: string, ...args: any[]], method: import("pino").default.LogFn, level: number) => void) | undefined;
54
+ } | undefined;
55
+ depthLimit?: number | undefined;
56
+ edgeLimit?: number | undefined;
57
+ }>;
58
+ export declare const getChildLogger: (logger: Logger, migration: DataMigration) => import("pino").default.Logger<import("pino").LoggerOptions & {
6
59
  msgPrefix: string;
7
60
  }>;
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getChildLogger = exports.createPinoLogger = void 0;
8
8
  var _chalk = _interopRequireDefault(require("chalk"));
9
- var _pino = require("pino");
10
9
  var _pinoPretty = _interopRequireDefault(require("pino-pretty"));
10
+ var _logger = require("@webiny/logger");
11
11
  const createPinoLogger = () => {
12
- return (0, _pino.pino)((0, _pinoPretty.default)({
12
+ return (0, _logger.createPinoLogger)({
13
+ level: (0, _logger.getLogLevel)(process.env.MIGRATIONS_LOG_LEVEL, "trace")
14
+ }, (0, _pinoPretty.default)({
13
15
  ignore: "pid,hostname"
14
16
  }));
15
17
  };
@@ -19,4 +21,6 @@ const getChildLogger = (logger, migration) => {
19
21
  msgPrefix: _chalk.default.blueBright(`[${migration.getId()}]`) + " "
20
22
  });
21
23
  };
22
- exports.getChildLogger = getChildLogger;
24
+ exports.getChildLogger = getChildLogger;
25
+
26
+ //# sourceMappingURL=createPinoLogger.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createPinoLogger","pino","pinoPretty","ignore","getChildLogger","logger","migration","child","msgPrefix","chalk","blueBright","getId"],"sources":["createPinoLogger.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { pino, Logger } from \"pino\";\nimport pinoPretty from \"pino-pretty\";\nimport { DataMigration } from \"~/types\";\n\nexport const createPinoLogger = () => {\n return pino(\n pinoPretty({\n ignore: \"pid,hostname\"\n })\n );\n};\n\nexport const getChildLogger = (logger: Logger, migration: DataMigration) => {\n return logger.child({}, { msgPrefix: chalk.blueBright(`[${migration.getId()}]`) + \" \" });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAGO,MAAMA,gBAAgB,GAAG,MAAM;EAClC,OAAO,IAAAC,UAAI,EACP,IAAAC,mBAAU,EAAC;IACPC,MAAM,EAAE;EACZ,CAAC,CAAC,CACL;AACL,CAAC;AAAC;AAEK,MAAMC,cAAc,GAAG,CAACC,MAAc,EAAEC,SAAwB,KAAK;EACxE,OAAOD,MAAM,CAACE,KAAK,CAAC,CAAC,CAAC,EAAE;IAAEC,SAAS,EAAEC,cAAK,CAACC,UAAU,CAAE,IAAGJ,SAAS,CAACK,KAAK,EAAG,GAAE,CAAC,GAAG;EAAI,CAAC,CAAC;AAC5F,CAAC;AAAC"}
1
+ {"version":3,"names":["_chalk","_interopRequireDefault","require","_pinoPretty","_logger","createPinoLogger","baseCreatePinoLogger","level","getLogLevel","process","env","MIGRATIONS_LOG_LEVEL","pinoPretty","ignore","exports","getChildLogger","logger","migration","child","msgPrefix","chalk","blueBright","getId"],"sources":["createPinoLogger.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport pinoPretty from \"pino-pretty\";\nimport { DataMigration } from \"~/types\";\nimport { createPinoLogger as baseCreatePinoLogger, getLogLevel, Logger } from \"@webiny/logger\";\n\nexport const createPinoLogger = () => {\n return baseCreatePinoLogger(\n {\n level: getLogLevel(process.env.MIGRATIONS_LOG_LEVEL, \"trace\")\n },\n pinoPretty({\n ignore: \"pid,hostname\"\n })\n );\n};\n\nexport const getChildLogger = (logger: Logger, migration: DataMigration) => {\n return logger.child({}, { msgPrefix: chalk.blueBright(`[${migration.getId()}]`) + \" \" });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAEO,MAAMG,gBAAgB,GAAGA,CAAA,KAAM;EAClC,OAAO,IAAAC,wBAAoB,EACvB;IACIC,KAAK,EAAE,IAAAC,mBAAW,EAACC,OAAO,CAACC,GAAG,CAACC,oBAAoB,EAAE,OAAO;EAChE,CAAC,EACD,IAAAC,mBAAU,EAAC;IACPC,MAAM,EAAE;EACZ,CAAC,CACL,CAAC;AACL,CAAC;AAACC,OAAA,CAAAT,gBAAA,GAAAA,gBAAA;AAEK,MAAMU,cAAc,GAAGA,CAACC,MAAc,EAAEC,SAAwB,KAAK;EACxE,OAAOD,MAAM,CAACE,KAAK,CAAC,CAAC,CAAC,EAAE;IAAEC,SAAS,EAAEC,cAAK,CAACC,UAAU,CAAE,IAAGJ,SAAS,CAACK,KAAK,CAAC,CAAE,GAAE,CAAC,GAAG;EAAI,CAAC,CAAC;AAC5F,CAAC;AAACR,OAAA,CAAAC,cAAA,GAAAA,cAAA"}
package/createTable.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { DocumentClient } from "aws-sdk/clients/dynamodb";
2
- import { Table } from "dynamodb-toolbox";
1
+ import { DynamoDBClient } from "@webiny/aws-sdk/client-dynamodb";
2
+ import { Table } from "@webiny/db-dynamodb/toolbox";
3
3
  export interface CreateTableParams {
4
4
  name: string;
5
- documentClient: DocumentClient;
5
+ documentClient: DynamoDBClient;
6
6
  }
7
- export declare const createTable: ({ name, documentClient }: CreateTableParams) => Table;
7
+ export declare const createTable: ({ name, documentClient }: CreateTableParams) => Table<string, "PK", "SK">;
package/createTable.js CHANGED
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createTable = void 0;
7
- var _dynamodbToolbox = require("dynamodb-toolbox");
7
+ var _toolbox = require("@webiny/db-dynamodb/toolbox");
8
8
  const createTable = ({
9
9
  name,
10
10
  documentClient
11
11
  }) => {
12
- return new _dynamodbToolbox.Table({
12
+ return new _toolbox.Table({
13
13
  name,
14
14
  partitionKey: "PK",
15
15
  sortKey: "SK",
@@ -23,7 +23,12 @@ const createTable = ({
23
23
  // partitionKey: "GSI2_PK",
24
24
  // sortKey: "GSI2_SK"
25
25
  // }
26
- }
26
+ },
27
+
28
+ autoExecute: true,
29
+ autoParse: true
27
30
  });
28
31
  };
29
- exports.createTable = createTable;
32
+ exports.createTable = createTable;
33
+
34
+ //# sourceMappingURL=createTable.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createTable","name","documentClient","Table","partitionKey","sortKey","DocumentClient","indexes","GSI1"],"sources":["createTable.ts"],"sourcesContent":["import { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Table } from \"dynamodb-toolbox\";\n\nexport interface CreateTableParams {\n name: string;\n documentClient: DocumentClient;\n}\n\nexport const createTable = ({ name, documentClient }: CreateTableParams) => {\n return new Table({\n name,\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n indexes: {\n GSI1: {\n partitionKey: \"GSI1_PK\",\n sortKey: \"GSI1_SK\"\n }\n // GSI2: {\n // partitionKey: \"GSI2_PK\",\n // sortKey: \"GSI2_SK\"\n // }\n }\n });\n};\n"],"mappings":";;;;;;AACA;AAOO,MAAMA,WAAW,GAAG,CAAC;EAAEC,IAAI;EAAEC;AAAkC,CAAC,KAAK;EACxE,OAAO,IAAIC,sBAAK,CAAC;IACbF,IAAI;IACJG,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAEJ,cAAc;IAC9BK,OAAO,EAAE;MACLC,IAAI,EAAE;QACFJ,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;MACb;MACA;MACA;MACA;MACA;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["_toolbox","require","createTable","name","documentClient","Table","partitionKey","sortKey","DocumentClient","indexes","GSI1","autoExecute","autoParse","exports"],"sources":["createTable.ts"],"sourcesContent":["import { DynamoDBClient } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { Table } from \"@webiny/db-dynamodb/toolbox\";\n\nexport interface CreateTableParams {\n name: string;\n documentClient: DynamoDBClient;\n}\n\nexport const createTable = ({ name, documentClient }: CreateTableParams) => {\n return new Table({\n name,\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n indexes: {\n GSI1: {\n partitionKey: \"GSI1_PK\",\n sortKey: \"GSI1_SK\"\n }\n // GSI2: {\n // partitionKey: \"GSI2_PK\",\n // sortKey: \"GSI2_SK\"\n // }\n },\n autoExecute: true,\n autoParse: true\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,WAAW,GAAGA,CAAC;EAAEC,IAAI;EAAEC;AAAkC,CAAC,KAAK;EACxE,OAAO,IAAIC,cAAK,CAAC;IACbF,IAAI;IACJG,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAEJ,cAAc;IAC9BK,OAAO,EAAE;MACLC,IAAI,EAAE;QACFJ,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;MACb;MACA;MACA;MACA;MACA;IACJ,CAAC;;IACDI,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE;EACf,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAX,WAAA,GAAAA,WAAA"}
@@ -1,12 +1,12 @@
1
1
  import { Client as ElasticsearchClient } from "@elastic/elasticsearch";
2
- import { Table } from "dynamodb-toolbox";
2
+ import { Table } from "@webiny/db-dynamodb/toolbox";
3
3
  import { Constructor } from "@webiny/ioc";
4
4
  import { DataMigration, ExecutionTimeLimiter, MigrationEventHandlerResponse, MigrationEventPayload, MigrationRepository } from "../types";
5
5
  import { IsMigrationApplicable } from "../MigrationRunner";
6
6
  interface CreateDdbEsDataMigrationConfig {
7
7
  elasticsearchClient: ElasticsearchClient;
8
- primaryTable: Table;
9
- dynamoToEsTable: Table;
8
+ primaryTable: Table<string, string, string>;
9
+ dynamoToEsTable: Table<string, string, string>;
10
10
  migrations: Constructor<DataMigration>[];
11
11
  isMigrationApplicable?: IsMigrationApplicable;
12
12
  repository?: MigrationRepository;