@webiny/data-migration 0.0.0-unstable.98511f29f1 → 0.0.0-unstable.9bd236cf5e
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 +8 -4
- package/MigrationRunner.js +85 -19
- 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.js +3 -1
- package/cli/getDuration.js.map +1 -1
- package/cli/index.d.ts +9 -2
- package/cli/index.js +92 -13
- package/cli/index.js.map +1 -1
- 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 +7 -7
- package/handlers/createDdbEsProjectMigration.js +21 -18
- package/handlers/createDdbEsProjectMigration.js.map +1 -1
- package/handlers/createDdbProjectMigration.d.ts +5 -5
- package/handlers/createDdbProjectMigration.js +19 -16
- 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 +0 -1
- package/index.js +3 -12
- package/index.js.map +1 -1
- package/package.json +17 -29
- package/repository/createStandardEntity.d.ts +50 -3
- package/repository/createStandardEntity.js +5 -3
- package/repository/createStandardEntity.js.map +1 -1
- package/repository/migrations.repository.d.ts +3 -3
- package/repository/migrations.repository.js +49 -36
- package/repository/migrations.repository.js.map +1 -1
- package/symbols.js +9 -14
- package/symbols.js.map +1 -1
- package/types.d.ts +9 -6
- package/types.js +2 -7
- package/types.js.map +1 -1
- package/cli/getMigrationStatus.d.ts +0 -9
- package/cli/getMigrationStatus.js +0 -27
- package/cli/getMigrationStatus.js.map +0 -1
- package/cli/printReport.d.ts +0 -9
- package/cli/printReport.js +0 -57
- package/cli/printReport.js.map +0 -1
- package/cli/runMigration.d.ts +0 -13
- package/cli/runMigration.js +0 -85
- package/cli/runMigration.js.map +0 -1
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":["
|
|
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,12 +1,12 @@
|
|
|
1
|
-
import { Client as ElasticsearchClient } from "@elastic/elasticsearch";
|
|
2
|
-
import { Table } from "dynamodb
|
|
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";
|
|
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;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.createDdbEsProjectMigration = void 0;
|
|
8
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
7
|
var _handlerAws = require("@webiny/handler-aws");
|
|
10
8
|
var _ioc = require("@webiny/ioc");
|
|
11
9
|
var _symbols = require("../symbols");
|
|
@@ -14,24 +12,23 @@ var _migrations = require("../repository/migrations.repository");
|
|
|
14
12
|
var _devVersionErrorResponse = require("./devVersionErrorResponse");
|
|
15
13
|
var _createPatternMatcher = require("./createPatternMatcher");
|
|
16
14
|
var _semver = require("semver");
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} = _ref,
|
|
27
|
-
config = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
15
|
+
const createDdbEsProjectMigration = ({
|
|
16
|
+
migrations,
|
|
17
|
+
elasticsearchClient,
|
|
18
|
+
primaryTable,
|
|
19
|
+
dynamoToEsTable,
|
|
20
|
+
isMigrationApplicable = undefined,
|
|
21
|
+
repository = undefined,
|
|
22
|
+
...config
|
|
23
|
+
}) => {
|
|
28
24
|
return (0, _handlerAws.createRawEventHandler)(async ({
|
|
29
25
|
payload,
|
|
30
26
|
lambdaContext
|
|
31
27
|
}) => {
|
|
32
|
-
const projectVersion = String(
|
|
28
|
+
const projectVersion = String(payload?.version || process.env.WEBINY_VERSION);
|
|
29
|
+
const forceExecute = payload.force === true;
|
|
33
30
|
const version = (0, _semver.coerce)(projectVersion);
|
|
34
|
-
if (
|
|
31
|
+
if (version?.version === "0.0.0") {
|
|
35
32
|
return (0, _devVersionErrorResponse.devVersionErrorResponse)();
|
|
36
33
|
}
|
|
37
34
|
|
|
@@ -40,7 +37,7 @@ const createDdbEsProjectMigration = _ref => {
|
|
|
40
37
|
container.bind(_symbols.PrimaryDynamoTableSymbol).toConstantValue(primaryTable);
|
|
41
38
|
container.bind(_symbols.ElasticsearchDynamoTableSymbol).toConstantValue(dynamoToEsTable);
|
|
42
39
|
container.bind(_symbols.ElasticsearchClientSymbol).toConstantValue(elasticsearchClient);
|
|
43
|
-
const timeLimiter = config.timeLimiter ||
|
|
40
|
+
const timeLimiter = config.timeLimiter || lambdaContext?.getRemainingTimeInMillis || (() => 0);
|
|
44
41
|
container.bind(_symbols.ExecutionTimeLimiterSymbol).toConstantValue(timeLimiter);
|
|
45
42
|
if (repository) {
|
|
46
43
|
// Repository implementation provided by the user.
|
|
@@ -62,8 +59,12 @@ const createDdbEsProjectMigration = _ref => {
|
|
|
62
59
|
// Inject dependencies and execute.
|
|
63
60
|
try {
|
|
64
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
|
+
});
|
|
65
66
|
if (payload.command === "execute") {
|
|
66
|
-
await runner.execute(projectVersion, patternMatcher || isMigrationApplicable);
|
|
67
|
+
await runner.execute(projectVersion, patternMatcher || isMigrationApplicable, forceExecute);
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
70
|
return {
|
|
@@ -78,4 +79,6 @@ const createDdbEsProjectMigration = _ref => {
|
|
|
78
79
|
}
|
|
79
80
|
});
|
|
80
81
|
};
|
|
81
|
-
exports.createDdbEsProjectMigration = createDdbEsProjectMigration;
|
|
82
|
+
exports.createDdbEsProjectMigration = createDdbEsProjectMigration;
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=createDdbEsProjectMigration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerAws","require","_ioc","_symbols","_MigrationRunner","_migrations","_devVersionErrorResponse","_createPatternMatcher","_semver","
|
|
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":"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","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Table } from "dynamodb
|
|
2
|
-
import { Constructor } from "@webiny/ioc";
|
|
3
|
-
import { IsMigrationApplicable } from "../MigrationRunner";
|
|
4
|
-
import { DataMigration, ExecutionTimeLimiter, 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
10
|
timeLimiter?: ExecutionTimeLimiter;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.createDdbProjectMigration = void 0;
|
|
8
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
7
|
var _handlerAws = require("@webiny/handler-aws");
|
|
10
8
|
var _ioc = require("@webiny/ioc");
|
|
11
9
|
var _MigrationRunner = require("../MigrationRunner");
|
|
@@ -14,29 +12,28 @@ var _migrations = require("../repository/migrations.repository");
|
|
|
14
12
|
var _devVersionErrorResponse = require("./devVersionErrorResponse");
|
|
15
13
|
var _createPatternMatcher = require("./createPatternMatcher");
|
|
16
14
|
var _semver = require("semver");
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} = _ref,
|
|
25
|
-
config = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
15
|
+
const createDdbProjectMigration = ({
|
|
16
|
+
migrations,
|
|
17
|
+
primaryTable,
|
|
18
|
+
isMigrationApplicable = undefined,
|
|
19
|
+
repository = undefined,
|
|
20
|
+
...config
|
|
21
|
+
}) => {
|
|
26
22
|
return (0, _handlerAws.createRawEventHandler)(async ({
|
|
27
23
|
payload,
|
|
28
24
|
lambdaContext
|
|
29
25
|
}) => {
|
|
30
|
-
const projectVersion = String(
|
|
26
|
+
const projectVersion = String(payload?.version || process.env.WEBINY_VERSION);
|
|
27
|
+
const forceExecute = payload.force === true;
|
|
31
28
|
const version = (0, _semver.coerce)(projectVersion);
|
|
32
|
-
if (
|
|
29
|
+
if (version?.version === "0.0.0") {
|
|
33
30
|
return (0, _devVersionErrorResponse.devVersionErrorResponse)();
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
// COMPOSITION ROOT
|
|
37
34
|
const container = (0, _ioc.createContainer)();
|
|
38
35
|
container.bind(_symbols.PrimaryDynamoTableSymbol).toConstantValue(primaryTable);
|
|
39
|
-
const timeLimiter = config.timeLimiter ||
|
|
36
|
+
const timeLimiter = config.timeLimiter || lambdaContext?.getRemainingTimeInMillis || (() => 0);
|
|
40
37
|
container.bind(_symbols.ExecutionTimeLimiterSymbol).toConstantValue(timeLimiter);
|
|
41
38
|
if (repository) {
|
|
42
39
|
// Repository implementation provided by the user.
|
|
@@ -58,8 +55,12 @@ const createDdbProjectMigration = _ref => {
|
|
|
58
55
|
// Inject dependencies and execute.
|
|
59
56
|
try {
|
|
60
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
|
+
});
|
|
61
62
|
if (payload.command === "execute") {
|
|
62
|
-
await runner.execute(projectVersion, patternMatcher || isMigrationApplicable);
|
|
63
|
+
await runner.execute(projectVersion, patternMatcher || isMigrationApplicable, forceExecute);
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
66
|
return {
|
|
@@ -74,4 +75,6 @@ const createDdbProjectMigration = _ref => {
|
|
|
74
75
|
}
|
|
75
76
|
});
|
|
76
77
|
};
|
|
77
|
-
exports.createDdbProjectMigration = createDdbProjectMigration;
|
|
78
|
+
exports.createDdbProjectMigration = createDdbProjectMigration;
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=createDdbProjectMigration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerAws","require","_ioc","_MigrationRunner","_symbols","_migrations","_devVersionErrorResponse","_createPatternMatcher","_semver","
|
|
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,EAAE;MACZ;MACAe,SAAS,CAACE,IAAI,CAACM,kCAAyB,CAAC,CAACJ,eAAe,CAACnB,UAAU,CAAC;IACzE,CAAC,MAAM;MACH;MACAe,SAAS,CAACE,IAAI,CAACM,kCAAyB,CAAC,CAACC,EAAE,CAACC,mCAAuB,CAAC;IACzE;;IAEA;IACA7B,UAAU,CAAC8B,OAAO,CAACC,SAAS,IAAIZ,SAAS,CAACE,IAAI,CAACW,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,MAAMjB,SAAS,CAACkB,OAAO,CAACC,gCAAe,CAAC;MACvDF,MAAM,CAACG,UAAU,CAAC;QACdC,YAAY,EAAE5B,OAAO,CAACC,GAAG,CAAC4B,yBAAyB;QACnDC,aAAa,EAAE9B,OAAO,CAACC,GAAG,CAAC8B;MAC/B,CAAC,CAAC;MAEF,IAAIpC,OAAO,CAACqC,OAAO,KAAK,SAAS,EAAE;QAC/B,MAAMR,MAAM,CAACS,OAAO,CAChBpC,cAAc,EACdwB,cAAc,IAAI/B,qBAAqB,EACvCa,YACJ,CAAC;QACD;MACJ;MAEA,OAAO;QACH+B,IAAI,EAAE,MAAMV,MAAM,CAACW,SAAS,CAAC;MACjC,CAAC;IACL,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,CAAApD,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IsMigrationApplicable } from "../MigrationRunner";
|
|
1
|
+
import type { IsMigrationApplicable } from "../MigrationRunner";
|
|
2
2
|
export declare const createPatternMatcher: (pattern: string) => IsMigrationApplicable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_minimatch","_interopRequireDefault","require","createPatternMatcher","pattern","migration","includes","minimatch","getId","exports"],"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,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"}
|
|
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","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,
|
|
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
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":["_createDdbProjectMigration","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_createDdbEsProjectMigration","
|
|
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,4BAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,4BAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,4BAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,4BAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,MAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,MAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,MAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,MAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,YAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,YAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,YAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,YAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;AACA,IAAAQ,iBAAA,GAAAZ,OAAA;AACAC,MAAA,CAAAC,IAAA,CAAAU,iBAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAQ,iBAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,iBAAA,CAAAR,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/data-migration",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.9bd236cf5e",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "types.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,49 +11,37 @@
|
|
|
11
11
|
"description": "Tools to author and execute data migrations.",
|
|
12
12
|
"author": "Webiny Ltd.",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@babel/runtime": "7.22.6",
|
|
15
14
|
"@elastic/elasticsearch": "7.12.0",
|
|
16
|
-
"@
|
|
17
|
-
"@webiny/
|
|
18
|
-
"@webiny/
|
|
19
|
-
"@webiny/
|
|
20
|
-
"@webiny/
|
|
15
|
+
"@webiny/aws-sdk": "0.0.0-unstable.9bd236cf5e",
|
|
16
|
+
"@webiny/cli": "0.0.0-unstable.9bd236cf5e",
|
|
17
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.9bd236cf5e",
|
|
18
|
+
"@webiny/handler-aws": "0.0.0-unstable.9bd236cf5e",
|
|
19
|
+
"@webiny/ioc": "0.0.0-unstable.9bd236cf5e",
|
|
20
|
+
"@webiny/logger": "0.0.0-unstable.9bd236cf5e",
|
|
21
|
+
"@webiny/utils": "0.0.0-unstable.9bd236cf5e",
|
|
21
22
|
"center-align": "1.0.1",
|
|
22
23
|
"chalk": "4.1.2",
|
|
23
|
-
"dynamodb-toolbox": "0.3.5",
|
|
24
24
|
"minimatch": "5.1.6",
|
|
25
|
-
"pino": "8.11.0",
|
|
26
25
|
"pino-pretty": "9.4.0",
|
|
27
|
-
"semver": "6.3
|
|
26
|
+
"semver": "7.6.3"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
30
|
-
"@babel/cli": "7.22.6",
|
|
31
|
-
"@babel/core": "7.22.8",
|
|
32
|
-
"@babel/preset-env": "7.22.7",
|
|
33
29
|
"@types/center-align": "1.0.0",
|
|
34
30
|
"@types/semver": "7.3.13",
|
|
35
|
-
"@webiny/
|
|
36
|
-
"
|
|
37
|
-
"jest": "29.5.0",
|
|
31
|
+
"@webiny/project-utils": "0.0.0-unstable.9bd236cf5e",
|
|
32
|
+
"jest": "29.7.0",
|
|
38
33
|
"jest-dynalite": "3.6.1",
|
|
39
|
-
"jest-mock-console": "
|
|
40
|
-
"rimraf": "
|
|
41
|
-
"typescript": "
|
|
34
|
+
"jest-mock-console": "2.0.0",
|
|
35
|
+
"rimraf": "6.0.1",
|
|
36
|
+
"typescript": "5.3.3"
|
|
42
37
|
},
|
|
43
38
|
"publishConfig": {
|
|
44
39
|
"access": "public",
|
|
45
40
|
"directory": "dist"
|
|
46
41
|
},
|
|
47
42
|
"scripts": {
|
|
48
|
-
"build": "
|
|
49
|
-
"watch": "
|
|
43
|
+
"build": "node ../cli/bin.js run build",
|
|
44
|
+
"watch": "node ../cli/bin.js run watch"
|
|
50
45
|
},
|
|
51
|
-
"
|
|
52
|
-
"ignore": {
|
|
53
|
-
"dependencies": [
|
|
54
|
-
"@types/pino"
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"gitHead": "98511f29f1e1fc7d03ed0d1379d0a0aeff6dae84"
|
|
46
|
+
"gitHead": "9bd236cf5e689f209a11bec089207dcc2d41a53c"
|
|
59
47
|
}
|
|
@@ -1,5 +1,52 @@
|
|
|
1
|
-
import { Table
|
|
1
|
+
import type { Table } from "@webiny/db-dynamodb/toolbox";
|
|
2
|
+
import { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
2
3
|
export declare const createStandardEntity: ({ table, name }: {
|
|
3
|
-
table: Table
|
|
4
|
+
table: Table<string, string, string>;
|
|
4
5
|
name: string;
|
|
5
|
-
}) => Entity<{
|
|
6
|
+
}) => Entity<string, import("dynamodb-toolbox/dist/cjs/classes/Entity").Overlay, import("dynamodb-toolbox/dist/cjs/classes/Entity").Overlay, Table<string, string, string>, boolean, boolean, boolean, string, string, string, boolean, {
|
|
7
|
+
PK: {
|
|
8
|
+
partitionKey: true;
|
|
9
|
+
};
|
|
10
|
+
SK: {
|
|
11
|
+
sortKey: true;
|
|
12
|
+
};
|
|
13
|
+
GSI1_PK: {
|
|
14
|
+
type: "string";
|
|
15
|
+
};
|
|
16
|
+
GSI1_SK: {
|
|
17
|
+
type: "string";
|
|
18
|
+
};
|
|
19
|
+
TYPE: {
|
|
20
|
+
type: "string";
|
|
21
|
+
};
|
|
22
|
+
data: {
|
|
23
|
+
type: "map";
|
|
24
|
+
};
|
|
25
|
+
}, {
|
|
26
|
+
PK: {
|
|
27
|
+
partitionKey: true;
|
|
28
|
+
};
|
|
29
|
+
SK: {
|
|
30
|
+
sortKey: true;
|
|
31
|
+
};
|
|
32
|
+
GSI1_PK: {
|
|
33
|
+
type: "string";
|
|
34
|
+
};
|
|
35
|
+
GSI1_SK: {
|
|
36
|
+
type: "string";
|
|
37
|
+
};
|
|
38
|
+
TYPE: {
|
|
39
|
+
type: "string";
|
|
40
|
+
};
|
|
41
|
+
data: {
|
|
42
|
+
type: "map";
|
|
43
|
+
};
|
|
44
|
+
}, import("dynamodb-toolbox/dist/cjs/classes/Entity").ParsedAttributes<import("ts-toolbelt/out/Any/Key").Key>, any, {
|
|
45
|
+
[x: string]: any;
|
|
46
|
+
[x: number]: any;
|
|
47
|
+
[x: symbol]: any;
|
|
48
|
+
}, {
|
|
49
|
+
[x: string]: any;
|
|
50
|
+
[x: number]: any;
|
|
51
|
+
[x: symbol]: any;
|
|
52
|
+
}>;
|
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createStandardEntity = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
8
8
|
const createStandardEntity = ({
|
|
9
9
|
table,
|
|
10
10
|
name
|
|
11
11
|
}) => {
|
|
12
|
-
return new
|
|
12
|
+
return new _toolbox.Entity({
|
|
13
13
|
name,
|
|
14
14
|
table,
|
|
15
15
|
attributes: {
|
|
@@ -34,4 +34,6 @@ const createStandardEntity = ({
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
exports.createStandardEntity = createStandardEntity;
|
|
37
|
+
exports.createStandardEntity = createStandardEntity;
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=createStandardEntity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_toolbox","require","createStandardEntity","table","name","Entity","attributes","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","TYPE","data","exports"],"sources":["createStandardEntity.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\n\nexport const createStandardEntity = ({\n table,\n name\n}: {\n table: Table<string, string, string>;\n name: string;\n}) => {\n return new Entity({\n name,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n }\n }\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEO,MAAMC,oBAAoB,GAAGA,CAAC;EACjCC,KAAK;EACLC;AAIJ,CAAC,KAAK;EACF,OAAO,IAAIC,eAAM,CAAC;IACdD,IAAI;IACJD,KAAK;IACLG,UAAU,EAAE;MACRC,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,OAAO,EAAE;QACLD,IAAI,EAAE;MACV,CAAC;MACDE,IAAI,EAAE;QACFF,IAAI,EAAE;MACV,CAAC;MACDG,IAAI,EAAE;QACFH,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACI,OAAA,CAAAd,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Table } from "dynamodb
|
|
2
|
-
import { MigrationItem, MigrationRepository, MigrationRun } from "../types";
|
|
1
|
+
import type { Table } from "@webiny/db-dynamodb/toolbox";
|
|
2
|
+
import type { MigrationItem, MigrationRepository, MigrationRun } from "../types";
|
|
3
3
|
export declare class MigrationRepositoryImpl implements MigrationRepository {
|
|
4
4
|
private readonly run;
|
|
5
5
|
private readonly migration;
|
|
6
6
|
private readonly checkpoint;
|
|
7
|
-
constructor(table: Table);
|
|
7
|
+
constructor(table: Table<string, string, string>);
|
|
8
8
|
getLastRun(): Promise<MigrationRun | null>;
|
|
9
9
|
saveRun(run: MigrationRun): Promise<void>;
|
|
10
10
|
listMigrations(params?: {
|