@webiny/data-migration 0.0.0-unstable.e3f4727c56 → 0.0.0-unstable.eb196ccd2f
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 +16 -9
- package/MigrationRunner.js +243 -62
- package/MigrationRunner.js.map +1 -1
- package/cli/CliMigrationRunReporter.d.ts +10 -0
- package/cli/CliMigrationRunReporter.js +55 -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 +43 -0
- package/cli/LogReporter.js.map +1 -0
- package/cli/LogStream.d.ts +10 -0
- package/cli/LogStream.js +58 -0
- package/cli/LogStream.js.map +1 -0
- package/cli/MigrationRunReporter.d.ts +4 -0
- package/cli/MigrationRunReporter.js +7 -0
- package/cli/MigrationRunReporter.js.map +1 -0
- package/cli/MigrationRunner.d.ts +45 -0
- package/cli/MigrationRunner.js +136 -0
- package/cli/MigrationRunner.js.map +1 -0
- package/cli/MigrationStatusReporter.d.ts +4 -0
- package/cli/MigrationStatusReporter.js +7 -0
- package/cli/MigrationStatusReporter.js.map +1 -0
- package/cli/NonInteractiveCliStatusReporter.d.ts +9 -0
- package/cli/NonInteractiveCliStatusReporter.js +42 -0
- package/cli/NonInteractiveCliStatusReporter.js.map +1 -0
- package/cli/VoidStatusReporter.d.ts +4 -0
- package/cli/VoidStatusReporter.js +14 -0
- package/cli/VoidStatusReporter.js.map +1 -0
- package/cli/getDuration.d.ts +5 -0
- package/cli/getDuration.js +23 -0
- package/cli/getDuration.js.map +1 -0
- package/cli/index.d.ts +10 -0
- package/cli/index.js +117 -0
- package/cli/index.js.map +1 -0
- package/createPinoLogger.d.ts +4 -7
- package/createPinoLogger.js +7 -3
- package/createPinoLogger.js.map +1 -1
- package/createTable.d.ts +4 -4
- package/createTable.js +8 -4
- package/createTable.js.map +1 -1
- package/handlers/createDdbEsProjectMigration.d.ts +9 -8
- package/handlers/createDdbEsProjectMigration.js +24 -7
- package/handlers/createDdbEsProjectMigration.js.map +1 -1
- package/handlers/createDdbProjectMigration.d.ts +7 -6
- package/handlers/createDdbProjectMigration.js +24 -7
- package/handlers/createDdbProjectMigration.js.map +1 -1
- package/handlers/createPatternMatcher.d.ts +1 -1
- package/handlers/createPatternMatcher.js +3 -1
- package/handlers/createPatternMatcher.js.map +1 -1
- package/handlers/devVersionErrorResponse.js +3 -1
- package/handlers/devVersionErrorResponse.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +3 -12
- package/index.js.map +1 -1
- package/package.json +21 -30
- package/repository/createStandardEntity.d.ts +52 -0
- package/repository/{migrations.entity.js → createStandardEntity.js} +10 -7
- package/repository/createStandardEntity.js.map +1 -0
- package/repository/migrations.repository.d.ts +11 -4
- package/repository/migrations.repository.js +87 -15
- package/repository/migrations.repository.js.map +1 -1
- package/symbols.d.ts +1 -0
- package/symbols.js +10 -13
- package/symbols.js.map +1 -1
- package/types.d.ts +59 -33
- package/types.js +2 -7
- package/types.js.map +1 -1
- package/repository/migrations.entity.d.ts +0 -4
- package/repository/migrations.entity.js.map +0 -1
package/cli/index.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _getDuration = require("./getDuration");
|
|
7
|
+
Object.keys(_getDuration).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _getDuration[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
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
|
+
});
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=index.js.map
|
package/cli/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_getDuration","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_MigrationRunner","_MigrationStatusReporter","_MigrationRunReporter","_InteractiveCliStatusReporter","_NonInteractiveCliStatusReporter","_VoidStatusReporter","_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 \"./VoidStatusReporter\";\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,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,YAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GA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AA,CAAAX,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAO,wBAAA,CAAAX,GAAA;IAAA;EAAA;AAAA;AACA,IAAAY,UAAA,GAAAhB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAc,UAAA,EAAAb,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAY,UAAA,CAAAZ,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAQ,UAAA,CAAAZ,GAAA;IAAA;EAAA;AAAA;AACA,IAAAa,YAAA,GAAAjB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAe,YAAA,EAAAd,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAa,YAAA,CAAAb,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAS,YAAA,CAAAb,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/createPinoLogger.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const getChildLogger: (logger: Logger, migration: DataMigration) => pino.Logger<import("pino").LoggerOptions & {
|
|
6
|
-
msgPrefix: string;
|
|
7
|
-
}>;
|
|
1
|
+
import type { DataMigration } from "./types";
|
|
2
|
+
import type { Logger } from "@webiny/logger";
|
|
3
|
+
export declare const createPinoLogger: () => Logger;
|
|
4
|
+
export declare const getChildLogger: (logger: Logger, migration: DataMigration) => import("pino").default.Logger<never>;
|
package/createPinoLogger.js
CHANGED
|
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.getChildLogger = exports.createPinoLogger = void 0;
|
|
8
8
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
-
var _pino = require("pino");
|
|
10
9
|
var _pinoPretty = _interopRequireDefault(require("pino-pretty"));
|
|
10
|
+
var _logger = require("@webiny/logger");
|
|
11
11
|
const createPinoLogger = () => {
|
|
12
|
-
return (0,
|
|
12
|
+
return (0, _logger.createPinoLogger)({
|
|
13
|
+
level: (0, _logger.getLogLevel)(process.env.MIGRATIONS_LOG_LEVEL, "trace")
|
|
14
|
+
}, (0, _pinoPretty.default)({
|
|
13
15
|
ignore: "pid,hostname"
|
|
14
16
|
}));
|
|
15
17
|
};
|
|
@@ -19,4 +21,6 @@ const getChildLogger = (logger, migration) => {
|
|
|
19
21
|
msgPrefix: _chalk.default.blueBright(`[${migration.getId()}]`) + " "
|
|
20
22
|
});
|
|
21
23
|
};
|
|
22
|
-
exports.getChildLogger = getChildLogger;
|
|
24
|
+
exports.getChildLogger = getChildLogger;
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=createPinoLogger.js.map
|
package/createPinoLogger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createPinoLogger","
|
|
1
|
+
{"version":3,"names":["_chalk","_interopRequireDefault","require","_pinoPretty","_logger","createPinoLogger","baseCreatePinoLogger","level","getLogLevel","process","env","MIGRATIONS_LOG_LEVEL","pinoPretty","ignore","exports","getChildLogger","logger","migration","child","msgPrefix","chalk","blueBright","getId"],"sources":["createPinoLogger.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport pinoPretty from \"pino-pretty\";\nimport type { DataMigration } from \"~/types\";\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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA,IAAAE,OAAA,GAAAF,OAAA;AAEO,MAAMG,gBAAgB,GAAGA,CAAA,KAAM;EAClC,OAAO,IAAAC,wBAAoB,EACvB;IACIC,KAAK,EAAE,IAAAC,mBAAW,EAACC,OAAO,CAACC,GAAG,CAACC,oBAAoB,EAAE,OAAO;EAChE,CAAC,EACD,IAAAC,mBAAU,EAAC;IACPC,MAAM,EAAE;EACZ,CAAC,CACL,CAAC;AACL,CAAC;AAACC,OAAA,CAAAT,gBAAA,GAAAA,gBAAA;AAEK,MAAMU,cAAc,GAAGA,CAACC,MAAc,EAAEC,SAAwB,KAAK;EACxE,OAAOD,MAAM,CAACE,KAAK,CAAC,CAAC,CAAC,EAAE;IAAEC,SAAS,EAAEC,cAAK,CAACC,UAAU,CAAC,IAAIJ,SAAS,CAACK,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG;EAAI,CAAC,CAAC;AAC5F,CAAC;AAACR,OAAA,CAAAC,cAAA,GAAAA,cAAA","ignoreList":[]}
|
package/createTable.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Table } from "dynamodb
|
|
1
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
2
|
+
import { Table } from "@webiny/db-dynamodb/toolbox";
|
|
3
3
|
export interface CreateTableParams {
|
|
4
4
|
name: string;
|
|
5
|
-
documentClient:
|
|
5
|
+
documentClient: DynamoDBDocument;
|
|
6
6
|
}
|
|
7
|
-
export declare const createTable: ({ name, documentClient }: CreateTableParams) => Table
|
|
7
|
+
export declare const createTable: ({ name, documentClient }: CreateTableParams) => Table<string, "PK", "SK">;
|
package/createTable.js
CHANGED
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createTable = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
8
8
|
const createTable = ({
|
|
9
9
|
name,
|
|
10
10
|
documentClient
|
|
11
11
|
}) => {
|
|
12
|
-
return new
|
|
12
|
+
return new _toolbox.Table({
|
|
13
13
|
name,
|
|
14
14
|
partitionKey: "PK",
|
|
15
15
|
sortKey: "SK",
|
|
@@ -23,7 +23,11 @@ const createTable = ({
|
|
|
23
23
|
// partitionKey: "GSI2_PK",
|
|
24
24
|
// sortKey: "GSI2_SK"
|
|
25
25
|
// }
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
|
+
autoExecute: true,
|
|
28
|
+
autoParse: true
|
|
27
29
|
});
|
|
28
30
|
};
|
|
29
|
-
exports.createTable = createTable;
|
|
31
|
+
exports.createTable = createTable;
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=createTable.js.map
|
package/createTable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createTable","name","documentClient","Table","partitionKey","sortKey","DocumentClient","indexes","GSI1"],"sources":["createTable.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"names":["_toolbox","require","createTable","name","documentClient","Table","partitionKey","sortKey","DocumentClient","indexes","GSI1","autoExecute","autoParse","exports"],"sources":["createTable.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { Table } from \"@webiny/db-dynamodb/toolbox\";\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,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,WAAW,GAAGA,CAAC;EAAEC,IAAI;EAAEC;AAAkC,CAAC,KAAK;EACxE,OAAO,IAAIC,cAAK,CAAC;IACbF,IAAI;IACJG,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAEJ,cAAc;IAC9BK,OAAO,EAAE;MACLC,IAAI,EAAE;QACFJ,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;MACb;MACA;MACA;MACA;MACA;IACJ,CAAC;IACDI,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE;EACf,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAX,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { Client as ElasticsearchClient } from "@elastic/elasticsearch";
|
|
2
|
-
import { Table } from "dynamodb
|
|
3
|
-
import { Constructor } from "@webiny/ioc";
|
|
4
|
-
import { DataMigration, 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";
|
|
3
|
+
import type { Constructor } from "@webiny/ioc";
|
|
4
|
+
import type { DataMigration, ExecutionTimeLimiter, MigrationEventHandlerResponse, MigrationEventPayload, MigrationRepository } from "../types";
|
|
5
|
+
import type { IsMigrationApplicable } from "../MigrationRunner";
|
|
6
6
|
interface CreateDdbEsDataMigrationConfig {
|
|
7
7
|
elasticsearchClient: ElasticsearchClient;
|
|
8
|
-
primaryTable: Table
|
|
9
|
-
dynamoToEsTable: Table
|
|
8
|
+
primaryTable: Table<string, string, string>;
|
|
9
|
+
dynamoToEsTable: Table<string, string, string>;
|
|
10
10
|
migrations: Constructor<DataMigration>[];
|
|
11
11
|
isMigrationApplicable?: IsMigrationApplicable;
|
|
12
12
|
repository?: MigrationRepository;
|
|
13
|
+
timeLimiter?: ExecutionTimeLimiter;
|
|
13
14
|
}
|
|
14
|
-
export declare const createDdbEsProjectMigration: ({ migrations, elasticsearchClient, primaryTable, dynamoToEsTable, isMigrationApplicable, repository }: CreateDdbEsDataMigrationConfig) => import("@webiny/handler-aws").RawEventHandler<MigrationEventPayload, any, MigrationEventHandlerResponse>;
|
|
15
|
+
export declare const createDdbEsProjectMigration: ({ migrations, elasticsearchClient, primaryTable, dynamoToEsTable, isMigrationApplicable, repository, ...config }: CreateDdbEsDataMigrationConfig) => import("@webiny/handler-aws").RawEventHandler<MigrationEventPayload, any, MigrationEventHandlerResponse>;
|
|
15
16
|
export {};
|
|
@@ -11,19 +11,24 @@ var _MigrationRunner = require("../MigrationRunner");
|
|
|
11
11
|
var _migrations = require("../repository/migrations.repository");
|
|
12
12
|
var _devVersionErrorResponse = require("./devVersionErrorResponse");
|
|
13
13
|
var _createPatternMatcher = require("./createPatternMatcher");
|
|
14
|
+
var _semver = require("semver");
|
|
14
15
|
const createDdbEsProjectMigration = ({
|
|
15
16
|
migrations,
|
|
16
17
|
elasticsearchClient,
|
|
17
18
|
primaryTable,
|
|
18
19
|
dynamoToEsTable,
|
|
19
20
|
isMigrationApplicable = undefined,
|
|
20
|
-
repository = undefined
|
|
21
|
+
repository = undefined,
|
|
22
|
+
...config
|
|
21
23
|
}) => {
|
|
22
24
|
return (0, _handlerAws.createRawEventHandler)(async ({
|
|
23
|
-
payload
|
|
25
|
+
payload,
|
|
26
|
+
lambdaContext
|
|
24
27
|
}) => {
|
|
25
|
-
const projectVersion = String(
|
|
26
|
-
|
|
28
|
+
const projectVersion = String(payload?.version || process.env.WEBINY_VERSION);
|
|
29
|
+
const forceExecute = payload.force === true;
|
|
30
|
+
const version = (0, _semver.coerce)(projectVersion);
|
|
31
|
+
if (version?.version === "0.0.0") {
|
|
27
32
|
return (0, _devVersionErrorResponse.devVersionErrorResponse)();
|
|
28
33
|
}
|
|
29
34
|
|
|
@@ -32,6 +37,8 @@ const createDdbEsProjectMigration = ({
|
|
|
32
37
|
container.bind(_symbols.PrimaryDynamoTableSymbol).toConstantValue(primaryTable);
|
|
33
38
|
container.bind(_symbols.ElasticsearchDynamoTableSymbol).toConstantValue(dynamoToEsTable);
|
|
34
39
|
container.bind(_symbols.ElasticsearchClientSymbol).toConstantValue(elasticsearchClient);
|
|
40
|
+
const timeLimiter = config.timeLimiter || lambdaContext?.getRemainingTimeInMillis || (() => 0);
|
|
41
|
+
container.bind(_symbols.ExecutionTimeLimiterSymbol).toConstantValue(timeLimiter);
|
|
35
42
|
if (repository) {
|
|
36
43
|
// Repository implementation provided by the user.
|
|
37
44
|
container.bind(_symbols.MigrationRepositorySymbol).toConstantValue(repository);
|
|
@@ -51,9 +58,17 @@ const createDdbEsProjectMigration = ({
|
|
|
51
58
|
|
|
52
59
|
// Inject dependencies and execute.
|
|
53
60
|
try {
|
|
54
|
-
const
|
|
61
|
+
const runner = await container.resolve(_MigrationRunner.MigrationRunner);
|
|
62
|
+
runner.setContext({
|
|
63
|
+
logGroupName: process.env.AWS_LAMBDA_LOG_GROUP_NAME,
|
|
64
|
+
logStreamName: process.env.AWS_LAMBDA_LOG_STREAM_NAME
|
|
65
|
+
});
|
|
66
|
+
if (payload.command === "execute") {
|
|
67
|
+
await runner.execute(projectVersion, patternMatcher || isMigrationApplicable, forceExecute);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
55
70
|
return {
|
|
56
|
-
data
|
|
71
|
+
data: await runner.getStatus()
|
|
57
72
|
};
|
|
58
73
|
} catch (err) {
|
|
59
74
|
return {
|
|
@@ -64,4 +79,6 @@ const createDdbEsProjectMigration = ({
|
|
|
64
79
|
}
|
|
65
80
|
});
|
|
66
81
|
};
|
|
67
|
-
exports.createDdbEsProjectMigration = createDdbEsProjectMigration;
|
|
82
|
+
exports.createDdbEsProjectMigration = createDdbEsProjectMigration;
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=createDdbEsProjectMigration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createDdbEsProjectMigration","migrations","elasticsearchClient","primaryTable","dynamoToEsTable","isMigrationApplicable","undefined","repository","createRawEventHandler","payload","projectVersion","String","version","process","env","WEBINY_VERSION","devVersionErrorResponse","container","createContainer","bind","PrimaryDynamoTableSymbol","toConstantValue","ElasticsearchDynamoTableSymbol","ElasticsearchClientSymbol","MigrationRepositorySymbol","to","MigrationRepositoryImpl","forEach","migration","MigrationSymbol","patternMatcher","pattern","createPatternMatcher","
|
|
1
|
+
{"version":3,"names":["_handlerAws","require","_ioc","_symbols","_MigrationRunner","_migrations","_devVersionErrorResponse","_createPatternMatcher","_semver","createDdbEsProjectMigration","migrations","elasticsearchClient","primaryTable","dynamoToEsTable","isMigrationApplicable","undefined","repository","config","createRawEventHandler","payload","lambdaContext","projectVersion","String","version","process","env","WEBINY_VERSION","forceExecute","force","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 type { Client as ElasticsearchClient } from \"@elastic/elasticsearch\";\nimport type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport type { Constructor } from \"@webiny/ioc\";\nimport { createContainer } from \"@webiny/ioc\";\nimport type {\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 type { IsMigrationApplicable } from \"~/MigrationRunner\";\nimport { 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<string, string, string>;\n dynamoToEsTable: Table<string, string, string>;\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 const forceExecute = payload.force === true;\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(\n projectVersion,\n patternMatcher || isMigrationApplicable,\n forceExecute\n );\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;AAEA,IAAAC,IAAA,GAAAD,OAAA;AAQA,IAAAE,QAAA,GAAAF,OAAA;AASA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,wBAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAYO,MAAMQ,2BAA2B,GAAGA,CAAC;EACxCC,UAAU;EACVC,mBAAmB;EACnBC,YAAY;EACZC,eAAe;EACfC,qBAAqB,GAAGC,SAAS;EACjCC,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,EAAE,CAACG,SAAS,CAAC,CAAC;;IAE9E;IACA,IAAIE,cAAc;IAClB,IAAI5B,OAAO,CAAC6B,OAAO,EAAE;MACjBD,cAAc,GAAG,IAAAE,0CAAoB,EAAC9B,OAAO,CAAC6B,OAAO,CAAC;IAC1D;;IAEA;IACA,IAAI;MACA,MAAME,MAAM,GAAG,MAAMnB,SAAS,CAACoB,OAAO,CAACC,gCAAe,CAAC;MACvDF,MAAM,CAACG,UAAU,CAAC;QACdC,YAAY,EAAE9B,OAAO,CAACC,GAAG,CAAC8B,yBAAyB;QACnDC,aAAa,EAAEhC,OAAO,CAACC,GAAG,CAACgC;MAC/B,CAAC,CAAC;MAEF,IAAItC,OAAO,CAACuC,OAAO,KAAK,SAAS,EAAE;QAC/B,MAAMR,MAAM,CAACS,OAAO,CAChBtC,cAAc,EACd0B,cAAc,IAAIjC,qBAAqB,EACvCa,YACJ,CAAC;QACD;MACJ;MAEA,OAAO;QAAEiC,IAAI,EAAE,MAAMV,MAAM,CAACW,SAAS,CAAC;MAAE,CAAC;IAC7C,CAAC,CAAC,OAAOC,GAAG,EAAE;MACV,OAAO;QAAEC,KAAK,EAAE;UAAEC,OAAO,EAAEF,GAAG,CAACE;QAAQ;MAAE,CAAC;IAC9C;EACJ,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAxD,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Table } from "dynamodb
|
|
2
|
-
import { Constructor } from "@webiny/ioc";
|
|
3
|
-
import { IsMigrationApplicable } from "../MigrationRunner";
|
|
4
|
-
import { DataMigration, MigrationEventHandlerResponse, MigrationEventPayload, MigrationRepository } from "../types";
|
|
1
|
+
import type { Table } from "@webiny/db-dynamodb/toolbox";
|
|
2
|
+
import type { Constructor } from "@webiny/ioc";
|
|
3
|
+
import type { IsMigrationApplicable } from "../MigrationRunner";
|
|
4
|
+
import type { DataMigration, ExecutionTimeLimiter, MigrationEventHandlerResponse, MigrationEventPayload, MigrationRepository } from "../types";
|
|
5
5
|
interface CreateDdbDataMigrationConfig {
|
|
6
6
|
migrations: Constructor<DataMigration>[];
|
|
7
|
-
primaryTable: Table
|
|
7
|
+
primaryTable: Table<string, string, string>;
|
|
8
8
|
repository?: MigrationRepository;
|
|
9
9
|
isMigrationApplicable?: IsMigrationApplicable;
|
|
10
|
+
timeLimiter?: ExecutionTimeLimiter;
|
|
10
11
|
}
|
|
11
|
-
export declare const createDdbProjectMigration: ({ migrations, primaryTable, isMigrationApplicable, repository }: CreateDdbDataMigrationConfig) => import("@webiny/handler-aws").RawEventHandler<MigrationEventPayload, any, MigrationEventHandlerResponse>;
|
|
12
|
+
export declare const createDdbProjectMigration: ({ migrations, primaryTable, isMigrationApplicable, repository, ...config }: CreateDdbDataMigrationConfig) => import("@webiny/handler-aws").RawEventHandler<MigrationEventPayload, any, MigrationEventHandlerResponse>;
|
|
12
13
|
export {};
|
|
@@ -11,23 +11,30 @@ var _symbols = require("../symbols");
|
|
|
11
11
|
var _migrations = require("../repository/migrations.repository");
|
|
12
12
|
var _devVersionErrorResponse = require("./devVersionErrorResponse");
|
|
13
13
|
var _createPatternMatcher = require("./createPatternMatcher");
|
|
14
|
+
var _semver = require("semver");
|
|
14
15
|
const createDdbProjectMigration = ({
|
|
15
16
|
migrations,
|
|
16
17
|
primaryTable,
|
|
17
18
|
isMigrationApplicable = undefined,
|
|
18
|
-
repository = undefined
|
|
19
|
+
repository = undefined,
|
|
20
|
+
...config
|
|
19
21
|
}) => {
|
|
20
22
|
return (0, _handlerAws.createRawEventHandler)(async ({
|
|
21
|
-
payload
|
|
23
|
+
payload,
|
|
24
|
+
lambdaContext
|
|
22
25
|
}) => {
|
|
23
|
-
const projectVersion = String(
|
|
24
|
-
|
|
26
|
+
const projectVersion = String(payload?.version || process.env.WEBINY_VERSION);
|
|
27
|
+
const forceExecute = payload.force === true;
|
|
28
|
+
const version = (0, _semver.coerce)(projectVersion);
|
|
29
|
+
if (version?.version === "0.0.0") {
|
|
25
30
|
return (0, _devVersionErrorResponse.devVersionErrorResponse)();
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
// COMPOSITION ROOT
|
|
29
34
|
const container = (0, _ioc.createContainer)();
|
|
30
35
|
container.bind(_symbols.PrimaryDynamoTableSymbol).toConstantValue(primaryTable);
|
|
36
|
+
const timeLimiter = config.timeLimiter || lambdaContext?.getRemainingTimeInMillis || (() => 0);
|
|
37
|
+
container.bind(_symbols.ExecutionTimeLimiterSymbol).toConstantValue(timeLimiter);
|
|
31
38
|
if (repository) {
|
|
32
39
|
// Repository implementation provided by the user.
|
|
33
40
|
container.bind(_symbols.MigrationRepositorySymbol).toConstantValue(repository);
|
|
@@ -47,9 +54,17 @@ const createDdbProjectMigration = ({
|
|
|
47
54
|
|
|
48
55
|
// Inject dependencies and execute.
|
|
49
56
|
try {
|
|
50
|
-
const
|
|
57
|
+
const runner = await container.resolve(_MigrationRunner.MigrationRunner);
|
|
58
|
+
runner.setContext({
|
|
59
|
+
logGroupName: process.env.AWS_LAMBDA_LOG_GROUP_NAME,
|
|
60
|
+
logStreamName: process.env.AWS_LAMBDA_LOG_STREAM_NAME
|
|
61
|
+
});
|
|
62
|
+
if (payload.command === "execute") {
|
|
63
|
+
await runner.execute(projectVersion, patternMatcher || isMigrationApplicable, forceExecute);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
51
66
|
return {
|
|
52
|
-
data
|
|
67
|
+
data: await runner.getStatus()
|
|
53
68
|
};
|
|
54
69
|
} catch (err) {
|
|
55
70
|
return {
|
|
@@ -60,4 +75,6 @@ const createDdbProjectMigration = ({
|
|
|
60
75
|
}
|
|
61
76
|
});
|
|
62
77
|
};
|
|
63
|
-
exports.createDdbProjectMigration = createDdbProjectMigration;
|
|
78
|
+
exports.createDdbProjectMigration = createDdbProjectMigration;
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=createDdbProjectMigration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createDdbProjectMigration","migrations","primaryTable","isMigrationApplicable","undefined","repository","createRawEventHandler","payload","projectVersion","String","version","process","env","WEBINY_VERSION","devVersionErrorResponse","container","createContainer","bind","PrimaryDynamoTableSymbol","toConstantValue","MigrationRepositorySymbol","to","MigrationRepositoryImpl","forEach","migration","MigrationSymbol","patternMatcher","pattern","createPatternMatcher","
|
|
1
|
+
{"version":3,"names":["_handlerAws","require","_ioc","_MigrationRunner","_symbols","_migrations","_devVersionErrorResponse","_createPatternMatcher","_semver","createDdbProjectMigration","migrations","primaryTable","isMigrationApplicable","undefined","repository","config","createRawEventHandler","payload","lambdaContext","projectVersion","String","version","process","env","WEBINY_VERSION","forceExecute","force","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 type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport type { Constructor } from \"@webiny/ioc\";\nimport { createContainer } from \"@webiny/ioc\";\nimport type { IsMigrationApplicable } from \"~/MigrationRunner\";\nimport { 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 type {\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<string, string, string>;\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 const forceExecute = payload.force === true;\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(\n projectVersion,\n patternMatcher || isMigrationApplicable,\n forceExecute\n );\n return;\n }\n\n return {\n data: await runner.getStatus()\n };\n } catch (err) {\n return { error: { message: err.message } };\n }\n }\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAMA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,wBAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AAQA,IAAAO,OAAA,GAAAP,OAAA;AAUO,MAAMQ,yBAAyB,GAAGA,CAAC;EACtCC,UAAU;EACVC,YAAY;EACZC,qBAAqB,GAAGC,SAAS;EACjCC,UAAU,GAAGD,SAAS;EACtB,GAAGE;AACuB,CAAC,KAAK;EAChC,OAAO,IAAAC,iCAAqB,EACxB,OAAO;IAAEC,OAAO;IAAEC;EAAc,CAAC,KAAK;IAClC,MAAMC,cAAc,GAAGC,MAAM,CAACH,OAAO,EAAEI,OAAO,IAAIC,OAAO,CAACC,GAAG,CAACC,cAAc,CAAC;IAC7E,MAAMC,YAAY,GAAGR,OAAO,CAACS,KAAK,KAAK,IAAI;IAE3C,MAAML,OAAO,GAAG,IAAAM,cAAY,EAACR,cAAc,CAAC;IAC5C,IAAIE,OAAO,EAAEA,OAAO,KAAK,OAAO,EAAE;MAC9B,OAAO,IAAAO,gDAAuB,EAAC,CAAC;IACpC;;IAEA;IACA,MAAMC,SAAS,GAAG,IAAAC,oBAAe,EAAC,CAAC;IACnCD,SAAS,CAACE,IAAI,CAACC,iCAAwB,CAAC,CAACC,eAAe,CAACtB,YAAY,CAAC;IAEtE,MAAMuB,WAAiC,GACnCnB,MAAM,CAACmB,WAAW,IAAIhB,aAAa,EAAEiB,wBAAwB,KAAK,MAAM,CAAC,CAAC;IAC9EN,SAAS,CAACE,IAAI,CAACK,mCAA0B,CAAC,CAACH,eAAe,CAACC,WAAW,CAAC;IAEvE,IAAIpB,UAAU,E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type { IsMigrationApplicable } from "../MigrationRunner";
|
|
2
2
|
export declare const createPatternMatcher: (pattern: string) => IsMigrationApplicable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createPatternMatcher","pattern","migration","includes","minimatch","getId"],"sources":["createPatternMatcher.ts"],"sourcesContent":["import minimatch from \"minimatch\";\nimport { IsMigrationApplicable } from \"~/MigrationRunner\";\n\nexport const createPatternMatcher = (pattern: string): IsMigrationApplicable => {\n return migration => {\n if (pattern.includes(\"*\")) {\n return minimatch(migration.getId(), pattern);\n }\n return migration.getId() === pattern;\n };\n};\n"],"mappings":";;;;;;;AAAA;AAGO,
|
|
1
|
+
{"version":3,"names":["_minimatch","_interopRequireDefault","require","createPatternMatcher","pattern","migration","includes","minimatch","getId","exports"],"sources":["createPatternMatcher.ts"],"sourcesContent":["import minimatch from \"minimatch\";\nimport type { IsMigrationApplicable } from \"~/MigrationRunner\";\n\nexport const createPatternMatcher = (pattern: string): IsMigrationApplicable => {\n return migration => {\n if (pattern.includes(\"*\")) {\n return minimatch(migration.getId(), pattern);\n }\n return migration.getId() === pattern;\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGO,MAAMC,oBAAoB,GAAIC,OAAe,IAA4B;EAC5E,OAAOC,SAAS,IAAI;IAChB,IAAID,OAAO,CAACE,QAAQ,CAAC,GAAG,CAAC,EAAE;MACvB,OAAO,IAAAC,kBAAS,EAACF,SAAS,CAACG,KAAK,CAAC,CAAC,EAAEJ,OAAO,CAAC;IAChD;IACA,OAAOC,SAAS,CAACG,KAAK,CAAC,CAAC,KAAKJ,OAAO;EACxC,CAAC;AACL,CAAC;AAACK,OAAA,CAAAN,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["devVersionErrorResponse","error","message","join"],"sources":["devVersionErrorResponse.ts"],"sourcesContent":["export const devVersionErrorResponse = () => {\n return {\n error: {\n message: [\n `This project is using a development version 0.0.0!`,\n `Migrations cannot be executed using version 0.0.0, as that makes them all eligible for execution.`,\n `To trigger a particular set of migrations, set a WEBINY_VERSION variable in the .env file.`\n ].join(\" \")\n }\n };\n};\n"],"mappings":";;;;;;AAAO,MAAMA,uBAAuB,
|
|
1
|
+
{"version":3,"names":["devVersionErrorResponse","error","message","join","exports"],"sources":["devVersionErrorResponse.ts"],"sourcesContent":["export const devVersionErrorResponse = () => {\n return {\n error: {\n message: [\n `This project is using a development version 0.0.0!`,\n `Migrations cannot be executed using version 0.0.0, as that makes them all eligible for execution.`,\n `To trigger a particular set of migrations, set a WEBINY_VERSION variable in the .env file.`\n ].join(\" \")\n }\n };\n};\n"],"mappings":";;;;;;AAAO,MAAMA,uBAAuB,GAAGA,CAAA,KAAM;EACzC,OAAO;IACHC,KAAK,EAAE;MACHC,OAAO,EAAE,CACL,oDAAoD,EACpD,mGAAmG,EACnG,4FAA4F,CAC/F,CAACC,IAAI,CAAC,GAAG;IACd;EACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAJ,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./handlers/createDdbProjectMigration";
|
|
2
2
|
export * from "./handlers/createDdbEsProjectMigration";
|
|
3
|
-
export * from "./symbols";
|
|
4
3
|
export * from "./types";
|
|
5
4
|
export * from "./createTable";
|
|
6
5
|
export * from "./createPinoLogger";
|
|
6
|
+
export * from "./createPinoLogger";
|
package/index.js
CHANGED
|
@@ -25,17 +25,6 @@ Object.keys(_createDdbEsProjectMigration).forEach(function (key) {
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
-
var _symbols = require("./symbols");
|
|
29
|
-
Object.keys(_symbols).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _symbols[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _symbols[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
28
|
var _types = require("./types");
|
|
40
29
|
Object.keys(_types).forEach(function (key) {
|
|
41
30
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -68,4 +57,6 @@ Object.keys(_createPinoLogger).forEach(function (key) {
|
|
|
68
57
|
return _createPinoLogger[key];
|
|
69
58
|
}
|
|
70
59
|
});
|
|
71
|
-
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./handlers/createDdbProjectMigration\";\nexport * from \"./handlers/createDdbEsProjectMigration\";\nexport * from \"./
|
|
1
|
+
{"version":3,"names":["_createDdbProjectMigration","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_createDdbEsProjectMigration","_types","_createTable","_createPinoLogger"],"sources":["index.ts"],"sourcesContent":["export * from \"./handlers/createDdbProjectMigration\";\nexport * from \"./handlers/createDdbEsProjectMigration\";\nexport * from \"./types\";\nexport * from \"./createTable\";\nexport * from \"./createPinoLogger\";\nexport * from \"./createPinoLogger\";\n"],"mappings":";;;;;AAAA,IAAAA,0BAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,0BAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,0BAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,0BAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,4BAA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