@webiny/data-migration 6.0.0-beta.0 → 6.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MigrationRunner.d.ts +3 -3
- package/MigrationRunner.js +13 -20
- package/MigrationRunner.js.map +1 -1
- package/README.md +9 -4
- package/cli/CliMigrationRunReporter.d.ts +8 -5
- package/cli/CliMigrationRunReporter.js +15 -20
- package/cli/CliMigrationRunReporter.js.map +1 -1
- package/cli/InteractiveCliStatusReporter.d.ts +3 -3
- package/cli/InteractiveCliStatusReporter.js +4 -12
- package/cli/InteractiveCliStatusReporter.js.map +1 -1
- package/cli/LogReporter.d.ts +1 -1
- package/cli/LogReporter.js +3 -10
- package/cli/LogReporter.js.map +1 -1
- package/cli/LogStream.js +3 -10
- package/cli/LogStream.js.map +1 -1
- package/cli/MigrationRunReporter.d.ts +1 -1
- package/cli/MigrationRunReporter.js +1 -5
- package/cli/MigrationRunReporter.js.map +1 -1
- package/cli/MigrationRunner.d.ts +3 -3
- package/cli/MigrationRunner.js +9 -17
- package/cli/MigrationRunner.js.map +1 -1
- package/cli/MigrationStatusReporter.d.ts +1 -1
- package/cli/MigrationStatusReporter.js +1 -5
- package/cli/MigrationStatusReporter.js.map +1 -1
- package/cli/NonInteractiveCliStatusReporter.d.ts +3 -3
- package/cli/NonInteractiveCliStatusReporter.js +1 -8
- package/cli/NonInteractiveCliStatusReporter.js.map +1 -1
- package/cli/VoidStatusReporter.d.ts +1 -1
- package/cli/VoidStatusReporter.js +1 -8
- package/cli/VoidStatusReporter.js.map +1 -1
- package/cli/getDuration.js +1 -8
- package/cli/getDuration.js.map +1 -1
- package/cli/index.d.ts +10 -10
- package/cli/index.js +10 -115
- package/cli/index.js.map +1 -1
- package/createPinoLogger.d.ts +4 -60
- package/createPinoLogger.js +9 -18
- package/createPinoLogger.js.map +1 -1
- package/createTable.d.ts +2 -2
- package/createTable.js +3 -10
- package/createTable.js.map +1 -1
- package/handlers/createDdbEsProjectMigration.d.ts +5 -5
- package/handlers/createDdbEsProjectMigration.js +22 -29
- package/handlers/createDdbEsProjectMigration.js.map +1 -1
- package/handlers/createDdbProjectMigration.d.ts +4 -4
- package/handlers/createDdbProjectMigration.js +20 -27
- package/handlers/createDdbProjectMigration.js.map +1 -1
- package/handlers/createPatternMatcher.d.ts +1 -1
- package/handlers/createPatternMatcher.js +3 -11
- package/handlers/createPatternMatcher.js.map +1 -1
- package/handlers/devVersionErrorResponse.js +1 -8
- package/handlers/devVersionErrorResponse.js.map +1 -1
- package/index.d.ts +6 -7
- package/index.js +6 -71
- package/index.js.map +1 -1
- package/package.json +20 -36
- package/repository/migrations.repository.d.ts +2 -2
- package/repository/migrations.repository.js +38 -64
- package/repository/migrations.repository.js.map +1 -1
- package/symbols.js +7 -13
- package/symbols.js.map +1 -1
- package/types.d.ts +3 -3
- package/types.js +1 -5
- package/types.js.map +1 -1
- package/repository/createStandardEntity.d.ts +0 -51
- package/repository/createStandardEntity.js +0 -39
- package/repository/createStandardEntity.js.map +0 -1
package/cli/MigrationRunner.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 {
|
|
1
|
+
import { InvokeCommand } from "@webiny/aws-sdk/client-lambda/index.js";
|
|
2
|
+
import { executeWithRetry } from "@webiny/utils";
|
|
3
|
+
import { VoidStatusReporter } from "./VoidStatusReporter.js";
|
|
4
|
+
export class MigrationRunnerResult {
|
|
11
5
|
successBranch = [];
|
|
12
6
|
errorBranch = [];
|
|
13
7
|
constructor(functionName, result) {
|
|
@@ -35,9 +29,8 @@ class MigrationRunnerResult {
|
|
|
35
29
|
}
|
|
36
30
|
}
|
|
37
31
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
statusReporter = new _VoidStatusReporter.VoidStatusReporter();
|
|
32
|
+
export class MigrationRunner {
|
|
33
|
+
statusReporter = new VoidStatusReporter();
|
|
41
34
|
static create(params) {
|
|
42
35
|
const runner = new MigrationRunner(params.lambdaClient, params.functionName);
|
|
43
36
|
if (params.statusReporter) {
|
|
@@ -95,7 +88,7 @@ class MigrationRunner {
|
|
|
95
88
|
await this.statusReporter.report(data);
|
|
96
89
|
}
|
|
97
90
|
async invokeMigration(payload) {
|
|
98
|
-
const response = await this.lambdaClient.send(new
|
|
91
|
+
const response = await this.lambdaClient.send(new InvokeCommand({
|
|
99
92
|
FunctionName: this.functionName,
|
|
100
93
|
InvocationType: "Event",
|
|
101
94
|
Payload: JSON.stringify({
|
|
@@ -110,7 +103,7 @@ class MigrationRunner {
|
|
|
110
103
|
}
|
|
111
104
|
async getStatus(payload) {
|
|
112
105
|
const getStatus = () => {
|
|
113
|
-
return this.lambdaClient.send(new
|
|
106
|
+
return this.lambdaClient.send(new InvokeCommand({
|
|
114
107
|
FunctionName: this.functionName,
|
|
115
108
|
InvocationType: "RequestResponse",
|
|
116
109
|
Payload: JSON.stringify({
|
|
@@ -119,7 +112,7 @@ class MigrationRunner {
|
|
|
119
112
|
})
|
|
120
113
|
}));
|
|
121
114
|
};
|
|
122
|
-
const response = await
|
|
115
|
+
const response = await executeWithRetry(getStatus);
|
|
123
116
|
const decoder = new TextDecoder("utf-8");
|
|
124
117
|
return JSON.parse(decoder.decode(response.Payload));
|
|
125
118
|
}
|
|
@@ -131,6 +124,5 @@ class MigrationRunner {
|
|
|
131
124
|
return 2000;
|
|
132
125
|
}
|
|
133
126
|
}
|
|
134
|
-
exports.MigrationRunner = MigrationRunner;
|
|
135
127
|
|
|
136
128
|
//# sourceMappingURL=MigrationRunner.js.map
|
|
@@ -1 +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 force?: boolean;\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;AAsBO,MAAMG,qBAAqB,CAAC;EAGdC,aAAa,GAA2B,EAAE;EAC1CC,WAAW,GAAyB,EAAE;EAEvDC,WAAWA,CACPC,YAAoB,EACpBC,MAAkE,EACpE;IACE,IAAI,CAACD,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACC,MAAM,GAAGA,MAAM;EACxB;EAEAC,eAAeA,CAAA,EAAG;IACd,OAAO,IAAI,CAACF,YAAY;EAC5B;EAEAG,SAASA,CAACC,EAAwB,EAAE;IAChC,IAAI,CAACP,aAAa,CAACQ,IAAI,CAACD,EAAE,CAAC;EAC/B;EAEAE,OAAOA,CAACF,EAAsB,EAAE;IAC5B,IAAI,CAACN,WAAW,CAACO,IAAI,CAACD,EAAE,CAAC;EAC7B;EAEA,MAAMG,OAAOA,CAAA,EAAkB;IAC3B,IAAI,IAAI,CAACN,MAAM,CAACO,KAAK,EAAE;MACnB,KAAK,MAAMC,OAAO,IAAI,IAAI,CAACX,WAAW,EAAE;QACpC,MAAMW,OAAO,CAAC,IAAI,CAACR,MAAM,CAACO,KAAK,CAAC;MACpC;MACA;IACJ;IAEA,KAAK,MAAMC,OAAO,IAAI,IAAI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AEC,IAAI,CAACC,SAAS,CAAC;UAAE,GAAGlB,OAAO;UAAEmB,OAAO,EAAE;QAAS,CAAC;MAC7D,CAAC,CACL,CAAC;IACL,CAAC;IAED,MAAMjB,QAAQ,GAAG,MAAM,IAAAmB,uBAAgB,EAACd,SAAS,CAAC;IAElD,MAAMe,OAAO,GAAG,IAAIC,WAAW,CAAC,OAAO,CAAC;IACxC,OAAON,IAAI,CAACO,KAAK,CAACF,OAAO,CAACG,MAAM,CAACvB,QAAQ,CAACc,OAAO,CAAC,CAAC;EACvD;EAEQV,gCAAgCA,CAAA,EAAG;IACvC,MAAMoB,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;AAACrC,OAAA,CAAAC,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["InvokeCommand","executeWithRetry","VoidStatusReporter","MigrationRunnerResult","successBranch","errorBranch","constructor","functionName","result","getFunctionName","onSuccess","cb","push","onError","process","error","handler","data","MigrationRunner","statusReporter","create","params","runner","lambdaClient","setStatusReporter","reporter","runMigration","payload","invokeMigration","response","Promise","resolve","setTimeout","getMigrationStatusReportInterval","getStatus","getResult","status","reportStatus","report","send","FunctionName","InvocationType","Payload","JSON","stringify","command","StatusCode","decoder","TextDecoder","parse","decode","envKey","env","parseInt","String"],"sources":["MigrationRunner.ts"],"sourcesContent":["import type { LambdaClient } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport { InvokeCommand } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport type { MigrationStatusReporter } from \"~/cli/MigrationStatusReporter.js\";\nimport type {\n MigrationEventHandlerResponse,\n MigrationInvocationErrorResponse,\n MigrationStatus,\n MigrationStatusResponse\n} from \"~/types.js\";\nimport { executeWithRetry } from \"@webiny/utils\";\nimport { VoidStatusReporter } from \"./VoidStatusReporter.js\";\n\ninterface MigrationRunnerConfig {\n lambdaClient: LambdaClient;\n functionName: string;\n statusReporter?: MigrationStatusReporter;\n}\n\ninterface MigrationPayload {\n version: string;\n pattern?: string;\n force?: boolean;\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":"AACA,SAASA,aAAa,QAAQ,wCAAwC;AAQtE,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,kBAAkB;AAsB3B,OAAO,MAAMC,qBAAqB,CAAC;EAGdC,aAAa,GAA2B,EAAE;E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@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["MigrationStatusReporter.ts"],"sourcesContent":["import { MigrationStatus } from \"~/types\";\n\nexport interface MigrationStatusReporter {\n report(status: MigrationStatus): void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["MigrationStatusReporter.ts"],"sourcesContent":["import type { MigrationStatus } from \"~/types.js\";\n\nexport interface MigrationStatusReporter {\n report(status: MigrationStatus): void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MigrationStatusReporter } from "
|
|
2
|
-
import { MigrationStatus } from "../types";
|
|
3
|
-
import { LogReporter } from "
|
|
1
|
+
import type { MigrationStatusReporter } from "../cli/MigrationStatusReporter.js";
|
|
2
|
+
import type { MigrationStatus } from "../types.js";
|
|
3
|
+
import type { LogReporter } from "../cli/LogReporter.js";
|
|
4
4
|
export declare class NonInteractiveCliStatusReporter implements MigrationStatusReporter {
|
|
5
5
|
private logReporter;
|
|
6
6
|
private firstCall;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.NonInteractiveCliStatusReporter = void 0;
|
|
7
|
-
class NonInteractiveCliStatusReporter {
|
|
1
|
+
export class NonInteractiveCliStatusReporter {
|
|
8
2
|
firstCall = true;
|
|
9
3
|
constructor(logReporter) {
|
|
10
4
|
this.logReporter = logReporter;
|
|
@@ -37,6 +31,5 @@ class NonInteractiveCliStatusReporter {
|
|
|
37
31
|
this.firstCall = false;
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
|
-
exports.NonInteractiveCliStatusReporter = NonInteractiveCliStatusReporter;
|
|
41
34
|
|
|
42
35
|
//# sourceMappingURL=NonInteractiveCliStatusReporter.js.map
|
|
@@ -1 +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"
|
|
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"],"sources":["NonInteractiveCliStatusReporter.ts"],"sourcesContent":["import type { MigrationStatusReporter } from \"~/cli/MigrationStatusReporter.js\";\nimport type { MigrationStatus } from \"~/types.js\";\nimport type { LogReporter } from \"~/cli/LogReporter.js\";\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":"AAIA,OAAO,MAAMA,+BAA+B,CAAoC;EAEpEC,SAAS,GAAG,IAAI;EAExBC,WAAWA,CAACC,WAAwB,EAAE;IAClC,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9BC,OAAO,CAACC,GAAG,CAAC,0CAA0C,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,CAAC,kDAAkD,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,CAAC,8CAA8C,CAAC;MACxE;IACJ;IAEA,IAAI,CAACf,SAAS,GAAG,KAAK;EAC1B;AACJ","ignoreList":[]}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.VoidStatusReporter = void 0;
|
|
7
|
-
class VoidStatusReporter {
|
|
1
|
+
export class VoidStatusReporter {
|
|
8
2
|
report() {
|
|
9
3
|
// This is a void reporter.
|
|
10
4
|
}
|
|
11
5
|
}
|
|
12
|
-
exports.VoidStatusReporter = VoidStatusReporter;
|
|
13
6
|
|
|
14
7
|
//# sourceMappingURL=VoidStatusReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["VoidStatusReporter","report"
|
|
1
|
+
{"version":3,"names":["VoidStatusReporter","report"],"sources":["VoidStatusReporter.ts"],"sourcesContent":["import type { MigrationStatusReporter } from \"./MigrationStatusReporter.js\";\n\nexport class VoidStatusReporter implements MigrationStatusReporter {\n report(): void {\n // This is a void reporter.\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,kBAAkB,CAAoC;EAC/DC,MAAMA,CAAA,EAAS;IACX;EAAA;AAER","ignoreList":[]}
|
package/cli/getDuration.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getDuration = void 0;
|
|
7
1
|
/**
|
|
8
2
|
* Get duration since the given ISO timestamp.
|
|
9
3
|
* @param string since
|
|
10
4
|
*/
|
|
11
|
-
const getDuration = since => {
|
|
5
|
+
export const getDuration = since => {
|
|
12
6
|
const ms = new Date().getTime() - new Date(since).getTime();
|
|
13
7
|
let seconds = Math.floor(ms / 1000);
|
|
14
8
|
let minutes = undefined;
|
|
@@ -18,6 +12,5 @@ const getDuration = since => {
|
|
|
18
12
|
}
|
|
19
13
|
return minutes ? `${minutes}m ${seconds}s` : `${seconds}s`;
|
|
20
14
|
};
|
|
21
|
-
exports.getDuration = getDuration;
|
|
22
15
|
|
|
23
16
|
//# sourceMappingURL=getDuration.js.map
|
package/cli/getDuration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getDuration","since","ms","Date","getTime","seconds","Math","floor","minutes","undefined"
|
|
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;AACA,OAAO,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,GAAG,GAAGA,OAAO,KAAKH,OAAO,GAAG,GAAG,GAAGA,OAAO,GAAG;AAC9D,CAAC","ignoreList":[]}
|
package/cli/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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 "./VoidStatusReporter";
|
|
8
|
-
export * from "./CliMigrationRunReporter";
|
|
9
|
-
export * from "./LogStream";
|
|
10
|
-
export * from "./LogReporter";
|
|
1
|
+
export * from "./getDuration.js";
|
|
2
|
+
export * from "./MigrationRunner.js";
|
|
3
|
+
export * from "./MigrationStatusReporter.js";
|
|
4
|
+
export * from "./MigrationRunReporter.js";
|
|
5
|
+
export * from "./InteractiveCliStatusReporter.js";
|
|
6
|
+
export * from "./NonInteractiveCliStatusReporter.js";
|
|
7
|
+
export * from "./VoidStatusReporter.js";
|
|
8
|
+
export * from "./CliMigrationRunReporter.js";
|
|
9
|
+
export * from "./LogStream.js";
|
|
10
|
+
export * from "./LogReporter.js";
|
package/cli/index.js
CHANGED
|
@@ -1,117 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _getDuration[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _MigrationRunner = require("./MigrationRunner");
|
|
18
|
-
Object.keys(_MigrationRunner).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _MigrationRunner[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _MigrationRunner[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _MigrationStatusReporter = require("./MigrationStatusReporter");
|
|
29
|
-
Object.keys(_MigrationStatusReporter).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _MigrationStatusReporter[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
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 _VoidStatusReporter = require("./VoidStatusReporter");
|
|
73
|
-
Object.keys(_VoidStatusReporter).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (key in exports && exports[key] === _VoidStatusReporter[key]) return;
|
|
76
|
-
Object.defineProperty(exports, key, {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () {
|
|
79
|
-
return _VoidStatusReporter[key];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
var _CliMigrationRunReporter = require("./CliMigrationRunReporter");
|
|
84
|
-
Object.keys(_CliMigrationRunReporter).forEach(function (key) {
|
|
85
|
-
if (key === "default" || key === "__esModule") return;
|
|
86
|
-
if (key in exports && exports[key] === _CliMigrationRunReporter[key]) return;
|
|
87
|
-
Object.defineProperty(exports, key, {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
get: function () {
|
|
90
|
-
return _CliMigrationRunReporter[key];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
var _LogStream = require("./LogStream");
|
|
95
|
-
Object.keys(_LogStream).forEach(function (key) {
|
|
96
|
-
if (key === "default" || key === "__esModule") return;
|
|
97
|
-
if (key in exports && exports[key] === _LogStream[key]) return;
|
|
98
|
-
Object.defineProperty(exports, key, {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function () {
|
|
101
|
-
return _LogStream[key];
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
var _LogReporter = require("./LogReporter");
|
|
106
|
-
Object.keys(_LogReporter).forEach(function (key) {
|
|
107
|
-
if (key === "default" || key === "__esModule") return;
|
|
108
|
-
if (key in exports && exports[key] === _LogReporter[key]) return;
|
|
109
|
-
Object.defineProperty(exports, key, {
|
|
110
|
-
enumerable: true,
|
|
111
|
-
get: function () {
|
|
112
|
-
return _LogReporter[key];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
1
|
+
export * from "./getDuration.js";
|
|
2
|
+
export * from "./MigrationRunner.js";
|
|
3
|
+
export * from "./MigrationStatusReporter.js";
|
|
4
|
+
export * from "./MigrationRunReporter.js";
|
|
5
|
+
export * from "./InteractiveCliStatusReporter.js";
|
|
6
|
+
export * from "./NonInteractiveCliStatusReporter.js";
|
|
7
|
+
export * from "./VoidStatusReporter.js";
|
|
8
|
+
export * from "./CliMigrationRunReporter.js";
|
|
9
|
+
export * from "./LogStream.js";
|
|
10
|
+
export * from "./LogReporter.js";
|
|
116
11
|
|
|
117
12
|
//# sourceMappingURL=index.js.map
|
package/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./getDuration.js\";\nexport * from \"./MigrationRunner.js\";\nexport * from \"./MigrationStatusReporter.js\";\nexport * from \"./MigrationRunReporter.js\";\nexport * from \"./InteractiveCliStatusReporter.js\";\nexport * from \"./NonInteractiveCliStatusReporter.js\";\nexport * from \"./VoidStatusReporter.js\";\nexport * from \"./CliMigrationRunReporter.js\";\nexport * from \"./LogStream.js\";\nexport * from \"./LogReporter.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/createPinoLogger.d.ts
CHANGED
|
@@ -1,60 +1,4 @@
|
|
|
1
|
-
import { DataMigration } from "./types";
|
|
2
|
-
import { Logger } from "@webiny/logger";
|
|
3
|
-
export declare const createPinoLogger: () => Logger
|
|
4
|
-
|
|
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
|
-
safe?: boolean | undefined;
|
|
8
|
-
name?: string | undefined;
|
|
9
|
-
serializers?: {
|
|
10
|
-
[key: string]: import("pino").default.SerializerFn;
|
|
11
|
-
} | undefined;
|
|
12
|
-
timestamp?: boolean | (() => string) | undefined;
|
|
13
|
-
customLevels?: {
|
|
14
|
-
[key: string]: number;
|
|
15
|
-
} | undefined;
|
|
16
|
-
useOnlyCustomLevels?: boolean | undefined;
|
|
17
|
-
mixin?: ((mergeObject: object, level: number) => object) | undefined;
|
|
18
|
-
mixinMergeStrategy?: ((mergeObject: object, mixinObject: object) => object) | undefined;
|
|
19
|
-
levelVal?: number | undefined;
|
|
20
|
-
messageKey?: string | undefined;
|
|
21
|
-
errorKey?: string | undefined;
|
|
22
|
-
nestedKey?: string | undefined;
|
|
23
|
-
enabled?: boolean | undefined;
|
|
24
|
-
browser?: {
|
|
25
|
-
asObject?: boolean | undefined;
|
|
26
|
-
write?: import("pino").default.WriteFn | ({
|
|
27
|
-
fatal?: import("pino").default.WriteFn | undefined;
|
|
28
|
-
error?: import("pino").default.WriteFn | undefined;
|
|
29
|
-
warn?: import("pino").default.WriteFn | undefined;
|
|
30
|
-
info?: import("pino").default.WriteFn | undefined;
|
|
31
|
-
debug?: import("pino").default.WriteFn | undefined;
|
|
32
|
-
trace?: import("pino").default.WriteFn | undefined;
|
|
33
|
-
} & {
|
|
34
|
-
[logLevel: string]: import("pino").default.WriteFn;
|
|
35
|
-
}) | undefined;
|
|
36
|
-
serialize?: boolean | string[] | undefined;
|
|
37
|
-
transmit?: {
|
|
38
|
-
level?: string | undefined;
|
|
39
|
-
send: (level: import("pino").default.Level, logEvent: import("pino").default.LogEvent) => void;
|
|
40
|
-
} | undefined;
|
|
41
|
-
} | undefined;
|
|
42
|
-
base?: {
|
|
43
|
-
[key: string]: any;
|
|
44
|
-
} | null | undefined;
|
|
45
|
-
formatters?: {
|
|
46
|
-
level?: ((label: string, number: number) => object) | undefined;
|
|
47
|
-
bindings?: ((bindings: import("pino").default.Bindings) => object) | undefined;
|
|
48
|
-
log?: ((object: Record<string, unknown>) => Record<string, unknown>) | undefined;
|
|
49
|
-
} | undefined;
|
|
50
|
-
msgPrefix?: string | undefined;
|
|
51
|
-
hooks?: {
|
|
52
|
-
logMethod?: ((this: import("pino").default.Logger<import("pino").default.LoggerOptions>, args: [msg: string, ...args: any[]], method: import("pino").default.LogFn, level: number) => void) | undefined;
|
|
53
|
-
} | undefined;
|
|
54
|
-
depthLimit?: number | undefined;
|
|
55
|
-
edgeLimit?: number | undefined;
|
|
56
|
-
onChild?: (<ChildOptions extends import("pino").default.ChildLoggerOptions>(child: import("pino").default.Logger<import("pino").LoggerOptions & ChildOptions>) => void) | undefined;
|
|
57
|
-
}>;
|
|
58
|
-
export declare const getChildLogger: (logger: Logger, migration: DataMigration) => import("pino").default.Logger<import("pino").LoggerOptions & {
|
|
59
|
-
msgPrefix: string;
|
|
60
|
-
}>;
|
|
1
|
+
import type { DataMigration } from "./types.js";
|
|
2
|
+
import type { Logger } from "@webiny/logger";
|
|
3
|
+
export declare const createPinoLogger: () => Logger;
|
|
4
|
+
export declare const getChildLogger: (logger: Logger, migration: DataMigration) => Logger<never, boolean>;
|
package/createPinoLogger.js
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
-
var _pinoPretty = _interopRequireDefault(require("pino-pretty"));
|
|
10
|
-
var _logger = require("@webiny/logger");
|
|
11
|
-
const createPinoLogger = () => {
|
|
12
|
-
return (0, _logger.createPinoLogger)({
|
|
13
|
-
level: (0, _logger.getLogLevel)(process.env.MIGRATIONS_LOG_LEVEL, "trace")
|
|
14
|
-
}, (0, _pinoPretty.default)({
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import pinoPretty from "pino-pretty";
|
|
3
|
+
import { createPinoLogger as baseCreatePinoLogger, getLogLevel } from "@webiny/logger";
|
|
4
|
+
export const createPinoLogger = () => {
|
|
5
|
+
return baseCreatePinoLogger({
|
|
6
|
+
level: getLogLevel(process.env.MIGRATIONS_LOG_LEVEL, "trace")
|
|
7
|
+
}, pinoPretty({
|
|
15
8
|
ignore: "pid,hostname"
|
|
16
9
|
}));
|
|
17
10
|
};
|
|
18
|
-
|
|
19
|
-
const getChildLogger = (logger, migration) => {
|
|
11
|
+
export const getChildLogger = (logger, migration) => {
|
|
20
12
|
return logger.child({}, {
|
|
21
|
-
msgPrefix:
|
|
13
|
+
msgPrefix: chalk.blueBright(`[${migration.getId()}]`) + " "
|
|
22
14
|
});
|
|
23
15
|
};
|
|
24
|
-
exports.getChildLogger = getChildLogger;
|
|
25
16
|
|
|
26
17
|
//# sourceMappingURL=createPinoLogger.js.map
|
package/createPinoLogger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["chalk","pinoPretty","createPinoLogger","baseCreatePinoLogger","getLogLevel","level","process","env","MIGRATIONS_LOG_LEVEL","ignore","getChildLogger","logger","migration","child","msgPrefix","blueBright","getId"],"sources":["createPinoLogger.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport pinoPretty from \"pino-pretty\";\nimport type { DataMigration } from \"~/types.js\";\nimport type { Logger } from \"@webiny/logger\";\nimport { createPinoLogger as baseCreatePinoLogger, getLogLevel } 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,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,aAAa;AAGpC,SAASC,gBAAgB,IAAIC,oBAAoB,EAAEC,WAAW,QAAQ,gBAAgB;AAEtF,OAAO,MAAMF,gBAAgB,GAAGA,CAAA,KAAM;EAClC,OAAOC,oBAAoB,CACvB;IACIE,KAAK,EAAED,WAAW,CAACE,OAAO,CAACC,GAAG,CAACC,oBAAoB,EAAE,OAAO;EAChE,CAAC,EACDP,UAAU,CAAC;IACPQ,MAAM,EAAE;EACZ,CAAC,CACL,CAAC;AACL,CAAC;AAED,OAAO,MAAMC,cAAc,GAAGA,CAACC,MAAc,EAAEC,SAAwB,KAAK;EACxE,OAAOD,MAAM,CAACE,KAAK,CAAC,CAAC,CAAC,EAAE;IAAEC,SAAS,EAAEd,KAAK,CAACe,UAAU,CAAC,IAAIH,SAAS,CAACI,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG;EAAI,CAAC,CAAC;AAC5F,CAAC","ignoreList":[]}
|
package/createTable.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
2
|
-
import { Table } from "@webiny/db-dynamodb/toolbox";
|
|
1
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
+
import { Table } from "@webiny/db-dynamodb/toolbox.js";
|
|
3
3
|
export interface CreateTableParams {
|
|
4
4
|
name: string;
|
|
5
5
|
documentClient: DynamoDBDocument;
|
package/createTable.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createTable = void 0;
|
|
7
|
-
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
8
|
-
const createTable = ({
|
|
1
|
+
import { Table } from "@webiny/db-dynamodb/toolbox.js";
|
|
2
|
+
export const createTable = ({
|
|
9
3
|
name,
|
|
10
4
|
documentClient
|
|
11
5
|
}) => {
|
|
12
|
-
return new
|
|
6
|
+
return new Table({
|
|
13
7
|
name,
|
|
14
8
|
partitionKey: "PK",
|
|
15
9
|
sortKey: "SK",
|
|
@@ -28,6 +22,5 @@ const createTable = ({
|
|
|
28
22
|
autoParse: true
|
|
29
23
|
});
|
|
30
24
|
};
|
|
31
|
-
exports.createTable = createTable;
|
|
32
25
|
|
|
33
26
|
//# sourceMappingURL=createTable.js.map
|
package/createTable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Table","createTable","name","documentClient","partitionKey","sortKey","DocumentClient","indexes","GSI1","autoExecute","autoParse"],"sources":["createTable.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { Table } from \"@webiny/db-dynamodb/toolbox.js\";\n\nexport interface CreateTableParams {\n name: string;\n documentClient: DynamoDBDocument;\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,SAASA,KAAK,QAAQ,gCAAgC;AAOtD,OAAO,MAAMC,WAAW,GAAGA,CAAC;EAAEC,IAAI;EAAEC;AAAkC,CAAC,KAAK;EACxE,OAAO,IAAIH,KAAK,CAAC;IACbE,IAAI;IACJE,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAEH,cAAc;IAC9BI,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","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Client as ElasticsearchClient } from "@elastic/elasticsearch";
|
|
2
|
-
import { Table } from "@webiny/db-dynamodb/toolbox";
|
|
3
|
-
import { Constructor } from "@webiny/ioc";
|
|
4
|
-
import { DataMigration, ExecutionTimeLimiter, MigrationEventHandlerResponse, MigrationEventPayload, MigrationRepository } from "../types";
|
|
5
|
-
import { IsMigrationApplicable } from "../MigrationRunner";
|
|
1
|
+
import type { Client as ElasticsearchClient } from "@elastic/elasticsearch";
|
|
2
|
+
import type { Table } from "@webiny/db-dynamodb/toolbox.js";
|
|
3
|
+
import type { Constructor } from "@webiny/ioc";
|
|
4
|
+
import type { DataMigration, ExecutionTimeLimiter, MigrationEventHandlerResponse, MigrationEventPayload, MigrationRepository } from "../types.js";
|
|
5
|
+
import type { IsMigrationApplicable } from "../MigrationRunner.js";
|
|
6
6
|
interface CreateDdbEsDataMigrationConfig {
|
|
7
7
|
elasticsearchClient: ElasticsearchClient;
|
|
8
8
|
primaryTable: Table<string, string, string>;
|