@webiny/data-migration 5.37.3-beta.1 → 5.37.3-beta.2
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/MigrationRunner.d.ts +2 -0
- package/MigrationRunner.js +18 -5
- package/MigrationRunner.js.map +1 -1
- package/cli/CliMigrationRunReporter.d.ts +10 -0
- package/cli/CliMigrationRunReporter.js +58 -0
- package/cli/CliMigrationRunReporter.js.map +1 -0
- package/cli/InteractiveCliStatusReporter.d.ts +11 -0
- package/cli/InteractiveCliStatusReporter.js +74 -0
- package/cli/InteractiveCliStatusReporter.js.map +1 -0
- package/cli/LogReporter.d.ts +10 -0
- package/cli/LogReporter.js +45 -0
- package/cli/LogReporter.js.map +1 -0
- package/cli/LogStream.d.ts +10 -0
- package/cli/LogStream.js +62 -0
- package/cli/LogStream.js.map +1 -0
- package/cli/MigrationRunReporter.d.ts +4 -0
- package/cli/MigrationRunReporter.js +5 -0
- package/cli/MigrationRunReporter.js.map +1 -0
- package/cli/MigrationRunner.d.ts +44 -0
- package/cli/MigrationRunner.js +133 -0
- package/cli/MigrationRunner.js.map +1 -0
- package/cli/MigrationStatusReporter.d.ts +4 -0
- package/cli/MigrationStatusReporter.js +5 -0
- package/cli/MigrationStatusReporter.js.map +1 -0
- package/cli/NonInteractiveCliStatusReporter.d.ts +9 -0
- package/cli/NonInteractiveCliStatusReporter.js +43 -0
- package/cli/NonInteractiveCliStatusReporter.js.map +1 -0
- package/cli/VoidStatusReporter.d.ts +4 -0
- package/cli/VoidStatusReporter.js +12 -0
- package/cli/VoidStatusReporter.js.map +1 -0
- package/cli/getDuration.js +1 -3
- package/cli/index.d.ts +8 -2
- package/cli/index.js +78 -14
- package/cli/index.js.map +1 -1
- package/createPinoLogger.js +1 -3
- package/createTable.js +1 -3
- package/handlers/createDdbEsProjectMigration.js +5 -3
- package/handlers/createDdbEsProjectMigration.js.map +1 -1
- package/handlers/createDdbProjectMigration.js +5 -3
- package/handlers/createDdbProjectMigration.js.map +1 -1
- package/handlers/createPatternMatcher.js +1 -3
- package/handlers/devVersionErrorResponse.js +1 -3
- package/index.js +1 -3
- package/package.json +9 -9
- package/repository/createStandardEntity.js +1 -3
- package/repository/migrations.repository.js +1 -3
- package/symbols.js +1 -3
- package/types.d.ts +2 -0
- package/types.js +1 -3
- package/types.js.map +1 -1
- package/cli/getMigrationStatus.d.ts +0 -9
- package/cli/getMigrationStatus.js +0 -29
- package/cli/getMigrationStatus.js.map +0 -1
- package/cli/printReport.d.ts +0 -9
- package/cli/printReport.js +0 -59
- package/cli/printReport.js.map +0 -1
- package/cli/runMigration.d.ts +0 -13
- package/cli/runMigration.js +0 -87
- package/cli/runMigration.js.map +0 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.MigrationRunnerResult = exports.MigrationRunner = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _utils = require("@webiny/utils");
|
|
11
|
+
var _VoidStatusReporter = require("./VoidStatusReporter");
|
|
12
|
+
class MigrationRunnerResult {
|
|
13
|
+
constructor(functionName, result) {
|
|
14
|
+
(0, _defineProperty2.default)(this, "functionName", void 0);
|
|
15
|
+
(0, _defineProperty2.default)(this, "result", void 0);
|
|
16
|
+
(0, _defineProperty2.default)(this, "successBranch", []);
|
|
17
|
+
(0, _defineProperty2.default)(this, "errorBranch", []);
|
|
18
|
+
this.functionName = functionName;
|
|
19
|
+
this.result = result;
|
|
20
|
+
}
|
|
21
|
+
getFunctionName() {
|
|
22
|
+
return this.functionName;
|
|
23
|
+
}
|
|
24
|
+
onSuccess(cb) {
|
|
25
|
+
this.successBranch.push(cb);
|
|
26
|
+
}
|
|
27
|
+
onError(cb) {
|
|
28
|
+
this.errorBranch.push(cb);
|
|
29
|
+
}
|
|
30
|
+
async process() {
|
|
31
|
+
const branch = this.result.error ? this.errorBranch : this.successBranch;
|
|
32
|
+
const input = this.result.error ? this.result.error : this.result.data;
|
|
33
|
+
for (const handler of branch) {
|
|
34
|
+
await handler(input);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.MigrationRunnerResult = MigrationRunnerResult;
|
|
39
|
+
class MigrationRunner {
|
|
40
|
+
static create(params) {
|
|
41
|
+
const runner = new MigrationRunner(params.lambdaClient, params.functionName);
|
|
42
|
+
if (params.statusReporter) {
|
|
43
|
+
runner.setStatusReporter(params.statusReporter);
|
|
44
|
+
}
|
|
45
|
+
return runner;
|
|
46
|
+
}
|
|
47
|
+
constructor(lambdaClient, functionName) {
|
|
48
|
+
(0, _defineProperty2.default)(this, "lambdaClient", void 0);
|
|
49
|
+
(0, _defineProperty2.default)(this, "functionName", void 0);
|
|
50
|
+
(0, _defineProperty2.default)(this, "statusReporter", new _VoidStatusReporter.VoidStatusReporter());
|
|
51
|
+
this.lambdaClient = lambdaClient;
|
|
52
|
+
this.functionName = functionName;
|
|
53
|
+
}
|
|
54
|
+
setStatusReporter(reporter) {
|
|
55
|
+
this.statusReporter = reporter;
|
|
56
|
+
}
|
|
57
|
+
async runMigration(payload) {
|
|
58
|
+
// Execute migration function.
|
|
59
|
+
await this.invokeMigration(payload);
|
|
60
|
+
|
|
61
|
+
// Poll for status and re-execute when migration is in "pending" state.
|
|
62
|
+
let response;
|
|
63
|
+
while (true) {
|
|
64
|
+
await new Promise(resolve => setTimeout(resolve, this.getMigrationStatusReportInterval()));
|
|
65
|
+
response = await this.getStatus(payload);
|
|
66
|
+
if (!response) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const {
|
|
70
|
+
data,
|
|
71
|
+
error
|
|
72
|
+
} = response;
|
|
73
|
+
|
|
74
|
+
// If we received an error, it must be an unrecoverable error, and we don't retry.
|
|
75
|
+
if (error) {
|
|
76
|
+
return this.getResult(response);
|
|
77
|
+
}
|
|
78
|
+
switch (data.status) {
|
|
79
|
+
case "init":
|
|
80
|
+
await this.reportStatus(data);
|
|
81
|
+
continue;
|
|
82
|
+
case "pending":
|
|
83
|
+
await this.invokeMigration(payload);
|
|
84
|
+
break;
|
|
85
|
+
case "running":
|
|
86
|
+
await this.reportStatus(data);
|
|
87
|
+
break;
|
|
88
|
+
case "done":
|
|
89
|
+
await this.reportStatus(data);
|
|
90
|
+
return this.getResult(response);
|
|
91
|
+
default:
|
|
92
|
+
return this.getResult(response);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async reportStatus(data) {
|
|
97
|
+
await this.statusReporter.report(data);
|
|
98
|
+
}
|
|
99
|
+
async invokeMigration(payload) {
|
|
100
|
+
const response = await this.lambdaClient.invoke({
|
|
101
|
+
FunctionName: this.functionName,
|
|
102
|
+
InvocationType: "Event",
|
|
103
|
+
Payload: JSON.stringify((0, _objectSpread2.default)((0, _objectSpread2.default)({}, payload), {}, {
|
|
104
|
+
command: "execute"
|
|
105
|
+
}))
|
|
106
|
+
}).promise();
|
|
107
|
+
return response.StatusCode;
|
|
108
|
+
}
|
|
109
|
+
getResult(response) {
|
|
110
|
+
return new MigrationRunnerResult(this.functionName, response);
|
|
111
|
+
}
|
|
112
|
+
async getStatus(payload) {
|
|
113
|
+
const getStatus = () => {
|
|
114
|
+
return this.lambdaClient.invoke({
|
|
115
|
+
FunctionName: this.functionName,
|
|
116
|
+
InvocationType: "RequestResponse",
|
|
117
|
+
Payload: JSON.stringify((0, _objectSpread2.default)((0, _objectSpread2.default)({}, payload), {}, {
|
|
118
|
+
command: "status"
|
|
119
|
+
}))
|
|
120
|
+
}).promise();
|
|
121
|
+
};
|
|
122
|
+
const response = await (0, _utils.executeWithRetry)(getStatus);
|
|
123
|
+
return JSON.parse(response.Payload);
|
|
124
|
+
}
|
|
125
|
+
getMigrationStatusReportInterval() {
|
|
126
|
+
const envKey = "MIGRATION_STATUS_REPORT_INTERVAL";
|
|
127
|
+
if (envKey in process.env) {
|
|
128
|
+
return parseInt(String(process.env[envKey]));
|
|
129
|
+
}
|
|
130
|
+
return 2000;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.MigrationRunner = MigrationRunner;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_utils","require","_VoidStatusReporter","MigrationRunnerResult","constructor","functionName","result","_defineProperty2","default","getFunctionName","onSuccess","cb","successBranch","push","onError","errorBranch","process","branch","error","input","data","handler","exports","MigrationRunner","create","params","runner","lambdaClient","statusReporter","setStatusReporter","VoidStatusReporter","reporter","runMigration","payload","invokeMigration","response","Promise","resolve","setTimeout","getMigrationStatusReportInterval","getStatus","getResult","status","reportStatus","report","invoke","FunctionName","InvocationType","Payload","JSON","stringify","_objectSpread2","command","promise","StatusCode","executeWithRetry","parse","envKey","env","parseInt","String"],"sources":["MigrationRunner.ts"],"sourcesContent":["import LambdaClient from \"aws-sdk/clients/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 const branch = this.result.error ? this.errorBranch : this.successBranch;\n const input = this.result.error ? this.result.error : this.result.data;\n\n for (const handler of branch) {\n await handler(input as any);\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\n .invoke({\n FunctionName: this.functionName,\n InvocationType: \"Event\",\n Payload: JSON.stringify({ ...payload, command: \"execute\" })\n })\n .promise();\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\n .invoke({\n FunctionName: this.functionName,\n InvocationType: \"RequestResponse\",\n Payload: JSON.stringify({ ...payload, command: \"status\" })\n })\n .promise();\n };\n\n const response = await executeWithRetry(getStatus);\n\n return JSON.parse(response.Payload as string) 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":";;;;;;;;;AAQA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAqBO,MAAME,qBAAqB,CAAC;EAM/BC,WAAWA,CACPC,YAAoB,EACpBC,MAAkE,EACpE;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,yBANuD,EAAE;IAAA,IAAAD,gBAAA,CAAAC,OAAA,uBACN,EAAE;IAMnD,IAAI,CAACH,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACC,MAAM,GAAGA,MAAM;EACxB;EAEAG,eAAeA,CAAA,EAAG;IACd,OAAO,IAAI,CAACJ,YAAY;EAC5B;EAEAK,SAASA,CAACC,EAAwB,EAAE;IAChC,IAAI,CAACC,aAAa,CAACC,IAAI,CAACF,EAAE,CAAC;EAC/B;EAEAG,OAAOA,CAACH,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AAA3C,OAAA,MAAMyB,OAAO;QAAEmB,OAAO,EAAE;MAAS,EAAE;IAC9D,CAAC,CAAC,CACDC,OAAO,CAAC,CAAC;IAEd,OAAOlB,QAAQ,CAACmB,UAAU;EAC9B;EAEQb,SAASA,CAACN,QAAoE,EAAE;IACpF,OAAO,IAAIhC,qBAAqB,CAAC,IAAI,CAACE,YAAY,EAAE8B,QAAQ,CAAC;EACjE;EAEA,MAAcK,SAASA,CAACP,OAA4B,EAAE;IAClD,MAAMO,SAAS,GAAGA,CAAA,KAAM;MACpB,OAAO,IAAI,CAACb,YAAY,CACnBkB,MAAM,CAAC;QACJC,YAAY,EAAE,IAAI,CAACzC,YAAY;QAC/B0C,cAAc,EAAE,iBAAiB;QACjCC,OAAO,EAAEC,IAAI,CAACC,SAAS,KAAAC,cAAA,CAAA3C,OAAA,MAAA2C,cAAA,CAAA3C,OAAA,MAAMyB,OAAO;UAAEmB,OAAO,EAAE;QAAQ,EAAE;MAC7D,CAAC,CAAC,CACDC,OAAO,CAAC,CAAC;IAClB,CAAC;IAED,MAAMlB,QAAQ,GAAG,MAAM,IAAAoB,uBAAgB,EAACf,SAAS,CAAC;IAElD,OAAOS,IAAI,CAACO,KAAK,CAACrB,QAAQ,CAACa,OAAiB,CAAC;EACjD;EAEQT,gCAAgCA,CAAA,EAAG;IACvC,MAAMkB,MAAM,GAAG,kCAAkC;IACjD,IAAIA,MAAM,IAAIzC,OAAO,CAAC0C,GAAG,EAAE;MACvB,OAAOC,QAAQ,CAACC,MAAM,CAAC5C,OAAO,CAAC0C,GAAG,CAACD,MAAM,CAAC,CAAC,CAAC;IAChD;IACA,OAAO,IAAI;EACf;AACJ;AAACnC,OAAA,CAAAC,eAAA,GAAAA,eAAA"}
|
|
@@ -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,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.NonInteractiveCliStatusReporter = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
class NonInteractiveCliStatusReporter {
|
|
10
|
+
constructor(logReporter) {
|
|
11
|
+
(0, _defineProperty2.default)(this, "logReporter", void 0);
|
|
12
|
+
(0, _defineProperty2.default)(this, "firstCall", true);
|
|
13
|
+
this.logReporter = logReporter;
|
|
14
|
+
console.log(`Using "NonInteractiveCliStatusReporter".`);
|
|
15
|
+
}
|
|
16
|
+
async report(migrationStatus) {
|
|
17
|
+
const {
|
|
18
|
+
status,
|
|
19
|
+
context
|
|
20
|
+
} = migrationStatus;
|
|
21
|
+
const currentLogStreamName = context === null || context === void 0 ? void 0 : context.logStreamName;
|
|
22
|
+
if (currentLogStreamName) {
|
|
23
|
+
this.logReporter.initializeStream(currentLogStreamName);
|
|
24
|
+
if (this.firstCall) {
|
|
25
|
+
this.logReporter.printLogStreamLinks();
|
|
26
|
+
process.stdout.write(`\n---------- MIGRATION LOGS START ----------\n\n`);
|
|
27
|
+
}
|
|
28
|
+
await this.logReporter.printLogs(currentLogStreamName);
|
|
29
|
+
}
|
|
30
|
+
if (["done", "error"].includes(status)) {
|
|
31
|
+
// We want to give AWS some time for the latest log events to become available.
|
|
32
|
+
await new Promise(resolve => {
|
|
33
|
+
setTimeout(resolve, 10000);
|
|
34
|
+
});
|
|
35
|
+
if (currentLogStreamName) {
|
|
36
|
+
await this.logReporter.printLogs(currentLogStreamName);
|
|
37
|
+
process.stdout.write(`\n---------- MIGRATION LOGS END ----------\n`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
this.firstCall = false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.NonInteractiveCliStatusReporter = NonInteractiveCliStatusReporter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NonInteractiveCliStatusReporter","constructor","logReporter","_defineProperty2","default","console","log","report","migrationStatus","status","context","currentLogStreamName","logStreamName","initializeStream","firstCall","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;EAI5EC,WAAWA,CAACC,WAAwB,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,qBAFlB,IAAI;IAGpB,IAAI,CAACF,WAAW,GAAGA,WAAW;IAC9BG,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,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,aAAa;IAEnD,IAAID,oBAAoB,EAAE;MACtB,IAAI,CAACT,WAAW,CAACW,gBAAgB,CAACF,oBAAoB,CAAC;MACvD,IAAI,IAAI,CAACG,SAAS,EAAE;QAChB,IAAI,CAACZ,WAAW,CAACa,mBAAmB,CAAC,CAAC;QACtCC,OAAO,CAACC,MAAM,CAACC,KAAK,CAAE,kDAAiD,CAAC;MAC5E;MACA,MAAM,IAAI,CAAChB,WAAW,CAACiB,SAAS,CAACR,oBAAoB,CAAC;IAC1D;IAEA,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAACS,QAAQ,CAACX,MAAM,CAAC,EAAE;MACpC;MACA,MAAM,IAAIY,OAAO,CAACC,OAAO,IAAI;QACzBC,UAAU,CAACD,OAAO,EAAE,KAAK,CAAC;MAC9B,CAAC,CAAC;MAEF,IAAIX,oBAAoB,EAAE;QACtB,MAAM,IAAI,CAACT,WAAW,CAACiB,SAAS,CAACR,oBAAoB,CAAC;QACtDK,OAAO,CAACC,MAAM,CAACC,KAAK,CAAE,8CAA6C,CAAC;MACxE;IACJ;IAEA,IAAI,CAACJ,SAAS,GAAG,KAAK;EAC1B;AACJ;AAACU,OAAA,CAAAxB,+BAAA,GAAAA,+BAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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;
|
|
@@ -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"}
|
package/cli/getDuration.js
CHANGED
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,38 +3,102 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
Object.keys(
|
|
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] ===
|
|
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
|
|
13
|
+
return _getDuration[key];
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
-
var
|
|
18
|
-
Object.keys(
|
|
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] ===
|
|
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
|
|
24
|
+
return _MigrationRunner[key];
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
-
var
|
|
29
|
-
Object.keys(
|
|
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] ===
|
|
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
|
|
35
|
+
return _MigrationStatusReporter[key];
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
|
|
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];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
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
|
+
});
|
package/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
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":";;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,YAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBA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AAAC,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"}
|
package/createPinoLogger.js
CHANGED
|
@@ -21,6 +21,4 @@ const getChildLogger = (logger, migration) => {
|
|
|
21
21
|
msgPrefix: _chalk.default.blueBright(`[${migration.getId()}]`) + " "
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
|
-
exports.getChildLogger = getChildLogger;
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=createPinoLogger.js.map
|
|
24
|
+
exports.getChildLogger = getChildLogger;
|
package/createTable.js
CHANGED
|
@@ -62,6 +62,10 @@ const createDdbEsProjectMigration = _ref => {
|
|
|
62
62
|
// Inject dependencies and execute.
|
|
63
63
|
try {
|
|
64
64
|
const runner = await container.resolve(_MigrationRunner.MigrationRunner);
|
|
65
|
+
runner.setContext({
|
|
66
|
+
logGroupName: process.env.AWS_LAMBDA_LOG_GROUP_NAME,
|
|
67
|
+
logStreamName: process.env.AWS_LAMBDA_LOG_STREAM_NAME
|
|
68
|
+
});
|
|
65
69
|
if (payload.command === "execute") {
|
|
66
70
|
await runner.execute(projectVersion, patternMatcher || isMigrationApplicable);
|
|
67
71
|
return;
|
|
@@ -78,6 +82,4 @@ const createDdbEsProjectMigration = _ref => {
|
|
|
78
82
|
}
|
|
79
83
|
});
|
|
80
84
|
};
|
|
81
|
-
exports.createDdbEsProjectMigration = createDdbEsProjectMigration;
|
|
82
|
-
|
|
83
|
-
//# sourceMappingURL=createDdbEsProjectMigration.js.map
|
|
85
|
+
exports.createDdbEsProjectMigration = createDdbEsProjectMigration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerAws","require","_ioc","_symbols","_MigrationRunner","_migrations","_devVersionErrorResponse","_createPatternMatcher","_semver","_excluded","createDdbEsProjectMigration","_ref","migrations","elasticsearchClient","primaryTable","dynamoToEsTable","isMigrationApplicable","undefined","repository","config","_objectWithoutProperties2","default","createRawEventHandler","payload","lambdaContext","projectVersion","String","version","process","env","WEBINY_VERSION","semverCoerce","devVersionErrorResponse","container","createContainer","bind","PrimaryDynamoTableSymbol","toConstantValue","ElasticsearchDynamoTableSymbol","ElasticsearchClientSymbol","timeLimiter","getRemainingTimeInMillis","ExecutionTimeLimiterSymbol","MigrationRepositorySymbol","to","MigrationRepositoryImpl","forEach","migration","MigrationSymbol","patternMatcher","pattern","createPatternMatcher","runner","resolve","MigrationRunner","command","execute","data","getStatus","err","error","message","exports"],"sources":["createDdbEsProjectMigration.ts"],"sourcesContent":["import { Client as ElasticsearchClient } from \"@elastic/elasticsearch\";\nimport { Table } from \"dynamodb-toolbox\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport { Constructor, createContainer } from \"@webiny/ioc\";\nimport {\n DataMigration,\n ExecutionTimeLimiter,\n MigrationEventHandlerResponse,\n MigrationEventPayload,\n MigrationRepository\n} from \"~/types\";\nimport {\n ElasticsearchClientSymbol,\n ElasticsearchDynamoTableSymbol,\n ExecutionTimeLimiterSymbol,\n MigrationRepositorySymbol,\n MigrationSymbol,\n PrimaryDynamoTableSymbol\n} from \"~/symbols\";\nimport { IsMigrationApplicable, MigrationRunner } from \"~/MigrationRunner\";\nimport { MigrationRepositoryImpl } from \"~/repository/migrations.repository\";\nimport { devVersionErrorResponse } from \"~/handlers/devVersionErrorResponse\";\nimport { createPatternMatcher } from \"~/handlers/createPatternMatcher\";\nimport { coerce as semverCoerce } from \"semver\";\n\ninterface CreateDdbEsDataMigrationConfig {\n elasticsearchClient: ElasticsearchClient;\n primaryTable: Table;\n dynamoToEsTable: Table;\n migrations: Constructor<DataMigration>[];\n isMigrationApplicable?: IsMigrationApplicable;\n repository?: MigrationRepository;\n timeLimiter?: ExecutionTimeLimiter;\n}\n\nexport const createDdbEsProjectMigration = ({\n migrations,\n elasticsearchClient,\n primaryTable,\n dynamoToEsTable,\n isMigrationApplicable = undefined,\n repository = undefined,\n ...config\n}: CreateDdbEsDataMigrationConfig) => {\n return createRawEventHandler<MigrationEventPayload, any, MigrationEventHandlerResponse>(\n async ({ payload, lambdaContext }) => {\n const projectVersion = String(payload?.version || process.env.WEBINY_VERSION);\n\n const version = semverCoerce(projectVersion);\n if (version?.version === \"0.0.0\") {\n return devVersionErrorResponse();\n }\n\n // COMPOSITION ROOT\n const container = createContainer();\n container.bind(PrimaryDynamoTableSymbol).toConstantValue(primaryTable);\n container.bind(ElasticsearchDynamoTableSymbol).toConstantValue(dynamoToEsTable);\n container.bind(ElasticsearchClientSymbol).toConstantValue(elasticsearchClient);\n\n const timeLimiter: ExecutionTimeLimiter =\n config.timeLimiter || lambdaContext?.getRemainingTimeInMillis || (() => 0);\n container.bind(ExecutionTimeLimiterSymbol).toConstantValue(timeLimiter);\n\n if (repository) {\n // Repository implementation provided by the user.\n container.bind(MigrationRepositorySymbol).toConstantValue(repository);\n } else {\n // Default repository implementation.\n container.bind(MigrationRepositorySymbol).to(MigrationRepositoryImpl);\n }\n\n // Bind the provided migrations.\n migrations.forEach(migration => container.bind(MigrationSymbol).to(migration));\n\n // If handler was invoked with a `pattern`, filter migrations that match the pattern only.\n let patternMatcher;\n if (payload.pattern) {\n patternMatcher = createPatternMatcher(payload.pattern);\n }\n\n // Inject dependencies and execute.\n try {\n const runner = await container.resolve(MigrationRunner);\n\n if (payload.command === \"execute\") {\n await runner.execute(projectVersion, patternMatcher || isMigrationApplicable);\n return;\n }\n\n return { data: await runner.getStatus() };\n } catch (err) {\n return { error: { message: err.message } };\n }\n }\n );\n};\n"],"mappings":";;;;;;;;AAEA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAQA,IAAAE,QAAA,GAAAF,OAAA;AAQA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,wBAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAAgD,MAAAQ,SAAA;AAYzC,MAAMC,2BAA2B,GAAGC,IAAA,IAQL;EAAA,IARM;MACxCC,UAAU;MACVC,mBAAmB;MACnBC,YAAY;MACZC,eAAe;MACfC,qBAAqB,GAAGC,SAAS;MACjCC,UAAU,GAAGD;IAEe,CAAC,GAAAN,IAAA;IAD1BQ,MAAM,OAAAC,yBAAA,CAAAC,OAAA,EAAAV,IAAA,EAAAF,SAAA;EAET,OAAO,IAAAa,iCAAqB,EACxB,OAAO;IAAEC,OAAO;IAAEC;EAAc,CAAC,KAAK;IAClC,MAAMC,cAAc,GAAGC,MAAM,CAAC,CAAAH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,OAAO,KAAIC,OAAO,CAACC,GAAG,CAACC,cAAc,CAAC;IAE7E,MAAMH,OAAO,GAAG,IAAAI,cAAY,EAACN,cAAc,CAAC;IAC5C,IAAI,CAAAE,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEA,OAAO,MAAK,OAAO,EAAE;MAC9B,OAAO,IAAAK,gDAAuB,EAAC,CAAC;IACpC;;IAEA;IACA,MAAMC,SAAS,GAAG,IAAAC,oBAAe,EAAC,CAAC;IACnCD,SAAS,CAACE,IAAI,CAACC,iCAAwB,CAAC,CAACC,eAAe,CAACvB,YAAY,CAAC;IACtEmB,SAAS,CAACE,IAAI,CAACG,uCAA8B,CAAC,CAACD,eAAe,CAACtB,eAAe,CAAC;IAC/EkB,SAAS,CAACE,IAAI,CAACI,kCAAyB,CAAC,CAACF,eAAe,CAACxB,mBAAmB,CAAC;IAE9E,MAAM2B,WAAiC,GACnCrB,MAAM,CAACqB,WAAW,KAAIhB,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAEiB,wBAAwB,MAAK,MAAM,CAAC,CAAC;IAC9ER,SAAS,CAACE,IAAI,CAACO,mCAA0B,CAAC,CAACL,eAAe,CAACG,WAAW,CAAC;IAEvE,IAAItB,UAAU,EAAE;MACZ;MACAe,SAAS,CAACE,IAAI,CAACQ,kCAAyB,CAAC,CAACN,eAAe,CAACnB,UAAU,CAAC;IACzE,CAAC,MAAM;MACH;MACAe,SAAS,CAACE,IAAI,CAACQ,kCAAyB,CAAC,CAACC,EAAE,CAACC,mCAAuB,CAAC;IACzE;;IAEA;IACAjC,UAAU,CAACkC,OAAO,CAACC,SAAS,IAAId,SAAS,CAACE,IAAI,CAACa,wBAAe,CAAC,CAACJ,EAAE,CAACG,SAAS,CAAC,CAAC;;IAE9E;IACA,IAAIE,cAAc;IAClB,IAAI1B,OAAO,CAAC2B,OAAO,EAAE;MACjBD,cAAc,GAAG,IAAAE,0CAAoB,EAAC5B,OAAO,CAAC2B,OAAO,CAAC;IAC1D;;IAEA;IACA,IAAI;MACA,MAAME,MAAM,GAAG,MAAMnB,SAAS,CAACoB,OAAO,CAACC,gCAAe,CAAC;
|
|
1
|
+
{"version":3,"names":["_handlerAws","require","_ioc","_symbols","_MigrationRunner","_migrations","_devVersionErrorResponse","_createPatternMatcher","_semver","_excluded","createDdbEsProjectMigration","_ref","migrations","elasticsearchClient","primaryTable","dynamoToEsTable","isMigrationApplicable","undefined","repository","config","_objectWithoutProperties2","default","createRawEventHandler","payload","lambdaContext","projectVersion","String","version","process","env","WEBINY_VERSION","semverCoerce","devVersionErrorResponse","container","createContainer","bind","PrimaryDynamoTableSymbol","toConstantValue","ElasticsearchDynamoTableSymbol","ElasticsearchClientSymbol","timeLimiter","getRemainingTimeInMillis","ExecutionTimeLimiterSymbol","MigrationRepositorySymbol","to","MigrationRepositoryImpl","forEach","migration","MigrationSymbol","patternMatcher","pattern","createPatternMatcher","runner","resolve","MigrationRunner","setContext","logGroupName","AWS_LAMBDA_LOG_GROUP_NAME","logStreamName","AWS_LAMBDA_LOG_STREAM_NAME","command","execute","data","getStatus","err","error","message","exports"],"sources":["createDdbEsProjectMigration.ts"],"sourcesContent":["import { Client as ElasticsearchClient } from \"@elastic/elasticsearch\";\nimport { Table } from \"dynamodb-toolbox\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport { Constructor, createContainer } from \"@webiny/ioc\";\nimport {\n DataMigration,\n ExecutionTimeLimiter,\n MigrationEventHandlerResponse,\n MigrationEventPayload,\n MigrationRepository\n} from \"~/types\";\nimport {\n ElasticsearchClientSymbol,\n ElasticsearchDynamoTableSymbol,\n ExecutionTimeLimiterSymbol,\n MigrationRepositorySymbol,\n MigrationSymbol,\n PrimaryDynamoTableSymbol\n} from \"~/symbols\";\nimport { IsMigrationApplicable, MigrationRunner } from \"~/MigrationRunner\";\nimport { MigrationRepositoryImpl } from \"~/repository/migrations.repository\";\nimport { devVersionErrorResponse } from \"~/handlers/devVersionErrorResponse\";\nimport { createPatternMatcher } from \"~/handlers/createPatternMatcher\";\nimport { coerce as semverCoerce } from \"semver\";\n\ninterface CreateDdbEsDataMigrationConfig {\n elasticsearchClient: ElasticsearchClient;\n primaryTable: Table;\n dynamoToEsTable: Table;\n migrations: Constructor<DataMigration>[];\n isMigrationApplicable?: IsMigrationApplicable;\n repository?: MigrationRepository;\n timeLimiter?: ExecutionTimeLimiter;\n}\n\nexport const createDdbEsProjectMigration = ({\n migrations,\n elasticsearchClient,\n primaryTable,\n dynamoToEsTable,\n isMigrationApplicable = undefined,\n repository = undefined,\n ...config\n}: CreateDdbEsDataMigrationConfig) => {\n return createRawEventHandler<MigrationEventPayload, any, MigrationEventHandlerResponse>(\n async ({ payload, lambdaContext }) => {\n const projectVersion = String(payload?.version || process.env.WEBINY_VERSION);\n\n const version = semverCoerce(projectVersion);\n if (version?.version === \"0.0.0\") {\n return devVersionErrorResponse();\n }\n\n // COMPOSITION ROOT\n const container = createContainer();\n container.bind(PrimaryDynamoTableSymbol).toConstantValue(primaryTable);\n container.bind(ElasticsearchDynamoTableSymbol).toConstantValue(dynamoToEsTable);\n container.bind(ElasticsearchClientSymbol).toConstantValue(elasticsearchClient);\n\n const timeLimiter: ExecutionTimeLimiter =\n config.timeLimiter || lambdaContext?.getRemainingTimeInMillis || (() => 0);\n container.bind(ExecutionTimeLimiterSymbol).toConstantValue(timeLimiter);\n\n if (repository) {\n // Repository implementation provided by the user.\n container.bind(MigrationRepositorySymbol).toConstantValue(repository);\n } else {\n // Default repository implementation.\n container.bind(MigrationRepositorySymbol).to(MigrationRepositoryImpl);\n }\n\n // Bind the provided migrations.\n migrations.forEach(migration => container.bind(MigrationSymbol).to(migration));\n\n // If handler was invoked with a `pattern`, filter migrations that match the pattern only.\n let patternMatcher;\n if (payload.pattern) {\n patternMatcher = createPatternMatcher(payload.pattern);\n }\n\n // Inject dependencies and execute.\n try {\n const runner = await container.resolve(MigrationRunner);\n runner.setContext({\n logGroupName: process.env.AWS_LAMBDA_LOG_GROUP_NAME,\n logStreamName: process.env.AWS_LAMBDA_LOG_STREAM_NAME\n });\n\n if (payload.command === \"execute\") {\n await runner.execute(projectVersion, patternMatcher || isMigrationApplicable);\n return;\n }\n\n return { data: await runner.getStatus() };\n } catch (err) {\n return { error: { message: err.message } };\n }\n }\n );\n};\n"],"mappings":";;;;;;;;AAEA,IAAAA,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F,GAAG,CAACE;QAAQ;MAAE,CAAC;IAC9C;EACJ,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAzD,2BAAA,GAAAA,2BAAA"}
|
|
@@ -58,6 +58,10 @@ const createDdbProjectMigration = _ref => {
|
|
|
58
58
|
// Inject dependencies and execute.
|
|
59
59
|
try {
|
|
60
60
|
const runner = await container.resolve(_MigrationRunner.MigrationRunner);
|
|
61
|
+
runner.setContext({
|
|
62
|
+
logGroupName: process.env.AWS_LAMBDA_LOG_GROUP_NAME,
|
|
63
|
+
logStreamName: process.env.AWS_LAMBDA_LOG_STREAM_NAME
|
|
64
|
+
});
|
|
61
65
|
if (payload.command === "execute") {
|
|
62
66
|
await runner.execute(projectVersion, patternMatcher || isMigrationApplicable);
|
|
63
67
|
return;
|
|
@@ -74,6 +78,4 @@ const createDdbProjectMigration = _ref => {
|
|
|
74
78
|
}
|
|
75
79
|
});
|
|
76
80
|
};
|
|
77
|
-
exports.createDdbProjectMigration = createDdbProjectMigration;
|
|
78
|
-
|
|
79
|
-
//# sourceMappingURL=createDdbProjectMigration.js.map
|
|
81
|
+
exports.createDdbProjectMigration = createDdbProjectMigration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerAws","require","_ioc","_MigrationRunner","_symbols","_migrations","_devVersionErrorResponse","_createPatternMatcher","_semver","_excluded","createDdbProjectMigration","_ref","migrations","primaryTable","isMigrationApplicable","undefined","repository","config","_objectWithoutProperties2","default","createRawEventHandler","payload","lambdaContext","projectVersion","String","version","process","env","WEBINY_VERSION","semverCoerce","devVersionErrorResponse","container","createContainer","bind","PrimaryDynamoTableSymbol","toConstantValue","timeLimiter","getRemainingTimeInMillis","ExecutionTimeLimiterSymbol","MigrationRepositorySymbol","to","MigrationRepositoryImpl","forEach","migration","MigrationSymbol","patternMatcher","pattern","createPatternMatcher","runner","resolve","MigrationRunner","command","execute","data","getStatus","err","error","message","exports"],"sources":["createDdbProjectMigration.ts"],"sourcesContent":["import { Table } from \"dynamodb-toolbox\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport { Constructor, createContainer } from \"@webiny/ioc\";\nimport { IsMigrationApplicable, MigrationRunner } from \"~/MigrationRunner\";\nimport {\n ExecutionTimeLimiterSymbol,\n MigrationRepositorySymbol,\n MigrationSymbol,\n PrimaryDynamoTableSymbol\n} from \"~/symbols\";\nimport { MigrationRepositoryImpl } from \"~/repository/migrations.repository\";\nimport { devVersionErrorResponse } from \"./devVersionErrorResponse\";\nimport { createPatternMatcher } from \"./createPatternMatcher\";\nimport {\n DataMigration,\n ExecutionTimeLimiter,\n MigrationEventHandlerResponse,\n MigrationEventPayload,\n MigrationRepository\n} from \"~/types\";\nimport { coerce as semverCoerce } from \"semver\";\n\ninterface CreateDdbDataMigrationConfig {\n migrations: Constructor<DataMigration>[];\n primaryTable: Table;\n repository?: MigrationRepository;\n isMigrationApplicable?: IsMigrationApplicable;\n timeLimiter?: ExecutionTimeLimiter;\n}\n\nexport const createDdbProjectMigration = ({\n migrations,\n primaryTable,\n isMigrationApplicable = undefined,\n repository = undefined,\n ...config\n}: CreateDdbDataMigrationConfig) => {\n return createRawEventHandler<MigrationEventPayload, any, MigrationEventHandlerResponse>(\n async ({ payload, lambdaContext }) => {\n const projectVersion = String(payload?.version || process.env.WEBINY_VERSION);\n\n const version = semverCoerce(projectVersion);\n if (version?.version === \"0.0.0\") {\n return devVersionErrorResponse();\n }\n\n // COMPOSITION ROOT\n const container = createContainer();\n container.bind(PrimaryDynamoTableSymbol).toConstantValue(primaryTable);\n\n const timeLimiter: ExecutionTimeLimiter =\n config.timeLimiter || lambdaContext?.getRemainingTimeInMillis || (() => 0);\n container.bind(ExecutionTimeLimiterSymbol).toConstantValue(timeLimiter);\n\n if (repository) {\n // Repository implementation provided by the user.\n container.bind(MigrationRepositorySymbol).toConstantValue(repository);\n } else {\n // Default repository implementation.\n container.bind(MigrationRepositorySymbol).to(MigrationRepositoryImpl);\n }\n\n // Bind the provided migrations.\n migrations.forEach(migration => container.bind(MigrationSymbol).to(migration));\n\n // If handler was invoked with a `pattern`, filter migrations that match the pattern only.\n let patternMatcher;\n if (payload.pattern) {\n patternMatcher = createPatternMatcher(payload.pattern);\n }\n\n // Inject dependencies and execute.\n try {\n const runner = await container.resolve(MigrationRunner);\n\n if (payload.command === \"execute\") {\n await runner.execute(projectVersion, patternMatcher || isMigrationApplicable);\n return;\n }\n\n return {
|
|
1
|
+
{"version":3,"names":["_handlerAws","require","_ioc","_MigrationRunner","_symbols","_migrations","_devVersionErrorResponse","_createPatternMatcher","_semver","_excluded","createDdbProjectMigration","_ref","migrations","primaryTable","isMigrationApplicable","undefined","repository","config","_objectWithoutProperties2","default","createRawEventHandler","payload","lambdaContext","projectVersion","String","version","process","env","WEBINY_VERSION","semverCoerce","devVersionErrorResponse","container","createContainer","bind","PrimaryDynamoTableSymbol","toConstantValue","timeLimiter","getRemainingTimeInMillis","ExecutionTimeLimiterSymbol","MigrationRepositorySymbol","to","MigrationRepositoryImpl","forEach","migration","MigrationSymbol","patternMatcher","pattern","createPatternMatcher","runner","resolve","MigrationRunner","setContext","logGroupName","AWS_LAMBDA_LOG_GROUP_NAME","logStreamName","AWS_LAMBDA_LOG_STREAM_NAME","command","execute","data","getStatus","err","error","message","exports"],"sources":["createDdbProjectMigration.ts"],"sourcesContent":["import { Table } from \"dynamodb-toolbox\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport { Constructor, createContainer } from \"@webiny/ioc\";\nimport { IsMigrationApplicable, MigrationRunner } from \"~/MigrationRunner\";\nimport {\n ExecutionTimeLimiterSymbol,\n MigrationRepositorySymbol,\n MigrationSymbol,\n PrimaryDynamoTableSymbol\n} from \"~/symbols\";\nimport { MigrationRepositoryImpl } from \"~/repository/migrations.repository\";\nimport { devVersionErrorResponse } from \"./devVersionErrorResponse\";\nimport { createPatternMatcher } from \"./createPatternMatcher\";\nimport {\n DataMigration,\n ExecutionTimeLimiter,\n MigrationEventHandlerResponse,\n MigrationEventPayload,\n MigrationRepository\n} from \"~/types\";\nimport { coerce as semverCoerce } from \"semver\";\n\ninterface CreateDdbDataMigrationConfig {\n migrations: Constructor<DataMigration>[];\n primaryTable: Table;\n repository?: MigrationRepository;\n isMigrationApplicable?: IsMigrationApplicable;\n timeLimiter?: ExecutionTimeLimiter;\n}\n\nexport const createDdbProjectMigration = ({\n migrations,\n primaryTable,\n isMigrationApplicable = undefined,\n repository = undefined,\n ...config\n}: CreateDdbDataMigrationConfig) => {\n return createRawEventHandler<MigrationEventPayload, any, MigrationEventHandlerResponse>(\n async ({ payload, lambdaContext }) => {\n const projectVersion = String(payload?.version || process.env.WEBINY_VERSION);\n\n const version = semverCoerce(projectVersion);\n if (version?.version === \"0.0.0\") {\n return devVersionErrorResponse();\n }\n\n // COMPOSITION ROOT\n const container = createContainer();\n container.bind(PrimaryDynamoTableSymbol).toConstantValue(primaryTable);\n\n const timeLimiter: ExecutionTimeLimiter =\n config.timeLimiter || lambdaContext?.getRemainingTimeInMillis || (() => 0);\n container.bind(ExecutionTimeLimiterSymbol).toConstantValue(timeLimiter);\n\n if (repository) {\n // Repository implementation provided by the user.\n container.bind(MigrationRepositorySymbol).toConstantValue(repository);\n } else {\n // Default repository implementation.\n container.bind(MigrationRepositorySymbol).to(MigrationRepositoryImpl);\n }\n\n // Bind the provided migrations.\n migrations.forEach(migration => container.bind(MigrationSymbol).to(migration));\n\n // If handler was invoked with a `pattern`, filter migrations that match the pattern only.\n let patternMatcher;\n if (payload.pattern) {\n patternMatcher = createPatternMatcher(payload.pattern);\n }\n\n // Inject dependencies and execute.\n try {\n const runner = await container.resolve(MigrationRunner);\n runner.setContext({\n logGroupName: process.env.AWS_LAMBDA_LOG_GROUP_NAME,\n logStreamName: process.env.AWS_LAMBDA_LOG_STREAM_NAME\n });\n\n if (payload.command === \"execute\") {\n await runner.execute(projectVersion, patternMatcher || isMigrationApplicable);\n return;\n }\n\n return {\n data: await runner.getStatus()\n };\n } catch (err) {\n return { error: { message: err.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
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/data-migration",
|
|
3
|
-
"version": "5.37.3-beta.
|
|
3
|
+
"version": "5.37.3-beta.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "types.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"@babel/runtime": "7.22.6",
|
|
15
15
|
"@elastic/elasticsearch": "7.12.0",
|
|
16
16
|
"@types/pino": "7.0.5",
|
|
17
|
-
"@webiny/db-dynamodb": "5.37.3-beta.
|
|
18
|
-
"@webiny/handler-aws": "5.37.3-beta.
|
|
19
|
-
"@webiny/ioc": "5.37.3-beta.
|
|
20
|
-
"@webiny/logger": "5.37.3-beta.
|
|
21
|
-
"@webiny/utils": "5.37.3-beta.
|
|
17
|
+
"@webiny/db-dynamodb": "5.37.3-beta.2",
|
|
18
|
+
"@webiny/handler-aws": "5.37.3-beta.2",
|
|
19
|
+
"@webiny/ioc": "5.37.3-beta.2",
|
|
20
|
+
"@webiny/logger": "5.37.3-beta.2",
|
|
21
|
+
"@webiny/utils": "5.37.3-beta.2",
|
|
22
22
|
"center-align": "1.0.1",
|
|
23
23
|
"chalk": "4.1.2",
|
|
24
24
|
"dynamodb-toolbox": "0.3.5",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@babel/preset-env": "7.22.7",
|
|
33
33
|
"@types/center-align": "1.0.0",
|
|
34
34
|
"@types/semver": "7.3.13",
|
|
35
|
-
"@webiny/cli": "5.37.3-beta.
|
|
36
|
-
"@webiny/project-utils": "5.37.3-beta.
|
|
35
|
+
"@webiny/cli": "5.37.3-beta.2",
|
|
36
|
+
"@webiny/project-utils": "5.37.3-beta.2",
|
|
37
37
|
"jest": "29.5.0",
|
|
38
38
|
"jest-dynalite": "3.6.1",
|
|
39
39
|
"jest-mock-console": "1.3.0",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
]
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "c454fc068c68c86bd817b21291e51c845296c15a"
|
|
59
59
|
}
|