@webiny/data-migration 0.0.0-unstable.496cf268ac → 0.0.0-unstable.8acc9e8892
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.
|
@@ -13,6 +13,7 @@ var _MigrationRunner = require("../MigrationRunner");
|
|
|
13
13
|
var _migrations = require("../repository/migrations.repository");
|
|
14
14
|
var _devVersionErrorResponse = require("./devVersionErrorResponse");
|
|
15
15
|
var _createPatternMatcher = require("./createPatternMatcher");
|
|
16
|
+
var _semver = require("semver");
|
|
16
17
|
const _excluded = ["migrations", "elasticsearchClient", "primaryTable", "dynamoToEsTable", "isMigrationApplicable", "repository"];
|
|
17
18
|
const createDdbEsProjectMigration = _ref => {
|
|
18
19
|
let {
|
|
@@ -29,7 +30,8 @@ const createDdbEsProjectMigration = _ref => {
|
|
|
29
30
|
lambdaContext
|
|
30
31
|
}) => {
|
|
31
32
|
const projectVersion = String((payload === null || payload === void 0 ? void 0 : payload.version) || process.env.WEBINY_VERSION);
|
|
32
|
-
|
|
33
|
+
const version = (0, _semver.coerce)(projectVersion);
|
|
34
|
+
if ((version === null || version === void 0 ? void 0 : version.version) === "0.0.0") {
|
|
33
35
|
return (0, _devVersionErrorResponse.devVersionErrorResponse)();
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createDdbEsProjectMigration","migrations","elasticsearchClient","primaryTable","dynamoToEsTable","isMigrationApplicable","undefined","repository","config","createRawEventHandler","payload","lambdaContext","projectVersion","String","version","process","env","WEBINY_VERSION","devVersionErrorResponse","container","createContainer","bind","PrimaryDynamoTableSymbol","toConstantValue","ElasticsearchDynamoTableSymbol","ElasticsearchClientSymbol","timeLimiter","getRemainingTimeInMillis","ExecutionTimeLimiterSymbol","MigrationRepositorySymbol","to","MigrationRepositoryImpl","forEach","migration","MigrationSymbol","patternMatcher","pattern","createPatternMatcher","runner","resolve","MigrationRunner","command","execute","data","getStatus","err","error","message"],"sources":["createDdbEsProjectMigration.ts"],"sourcesContent":["import { Client as ElasticsearchClient } from \"@elastic/elasticsearch\";\nimport { Table } from \"dynamodb-toolbox\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport {
|
|
1
|
+
{"version":3,"names":["createDdbEsProjectMigration","migrations","elasticsearchClient","primaryTable","dynamoToEsTable","isMigrationApplicable","undefined","repository","config","createRawEventHandler","payload","lambdaContext","projectVersion","String","version","process","env","WEBINY_VERSION","semverCoerce","devVersionErrorResponse","container","createContainer","bind","PrimaryDynamoTableSymbol","toConstantValue","ElasticsearchDynamoTableSymbol","ElasticsearchClientSymbol","timeLimiter","getRemainingTimeInMillis","ExecutionTimeLimiterSymbol","MigrationRepositorySymbol","to","MigrationRepositoryImpl","forEach","migration","MigrationSymbol","patternMatcher","pattern","createPatternMatcher","runner","resolve","MigrationRunner","command","execute","data","getStatus","err","error","message"],"sources":["createDdbEsProjectMigration.ts"],"sourcesContent":["import { Client as ElasticsearchClient } from \"@elastic/elasticsearch\";\nimport { Table } from \"dynamodb-toolbox\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport { Constructor, createContainer } from \"@webiny/ioc\";\nimport {\n DataMigration,\n ExecutionTimeLimiter,\n MigrationEventHandlerResponse,\n MigrationEventPayload,\n MigrationRepository\n} from \"~/types\";\nimport {\n ElasticsearchClientSymbol,\n ElasticsearchDynamoTableSymbol,\n ExecutionTimeLimiterSymbol,\n MigrationRepositorySymbol,\n MigrationSymbol,\n PrimaryDynamoTableSymbol\n} from \"~/symbols\";\nimport { IsMigrationApplicable, MigrationRunner } from \"~/MigrationRunner\";\nimport { MigrationRepositoryImpl } from \"~/repository/migrations.repository\";\nimport { devVersionErrorResponse } from \"~/handlers/devVersionErrorResponse\";\nimport { createPatternMatcher } from \"~/handlers/createPatternMatcher\";\nimport { coerce as semverCoerce } from \"semver\";\n\ninterface CreateDdbEsDataMigrationConfig {\n elasticsearchClient: ElasticsearchClient;\n primaryTable: Table;\n dynamoToEsTable: Table;\n migrations: Constructor<DataMigration>[];\n isMigrationApplicable?: IsMigrationApplicable;\n repository?: MigrationRepository;\n timeLimiter?: ExecutionTimeLimiter;\n}\n\nexport const createDdbEsProjectMigration = ({\n migrations,\n elasticsearchClient,\n primaryTable,\n dynamoToEsTable,\n isMigrationApplicable = undefined,\n repository = undefined,\n ...config\n}: CreateDdbEsDataMigrationConfig) => {\n return createRawEventHandler<MigrationEventPayload, any, MigrationEventHandlerResponse>(\n async ({ payload, lambdaContext }) => {\n const projectVersion = String(payload?.version || process.env.WEBINY_VERSION);\n\n const version = semverCoerce(projectVersion);\n if (version?.version === \"0.0.0\") {\n return devVersionErrorResponse();\n }\n\n // COMPOSITION ROOT\n const container = createContainer();\n container.bind(PrimaryDynamoTableSymbol).toConstantValue(primaryTable);\n container.bind(ElasticsearchDynamoTableSymbol).toConstantValue(dynamoToEsTable);\n container.bind(ElasticsearchClientSymbol).toConstantValue(elasticsearchClient);\n\n const timeLimiter: ExecutionTimeLimiter =\n config.timeLimiter || lambdaContext?.getRemainingTimeInMillis || (() => 0);\n container.bind(ExecutionTimeLimiterSymbol).toConstantValue(timeLimiter);\n\n if (repository) {\n // Repository implementation provided by the user.\n container.bind(MigrationRepositorySymbol).toConstantValue(repository);\n } else {\n // Default repository implementation.\n container.bind(MigrationRepositorySymbol).to(MigrationRepositoryImpl);\n }\n\n // Bind the provided migrations.\n migrations.forEach(migration => container.bind(MigrationSymbol).to(migration));\n\n // If handler was invoked with a `pattern`, filter migrations that match the pattern only.\n let patternMatcher;\n if (payload.pattern) {\n patternMatcher = createPatternMatcher(payload.pattern);\n }\n\n // Inject dependencies and execute.\n try {\n const runner = await container.resolve(MigrationRunner);\n\n if (payload.command === \"execute\") {\n await runner.execute(projectVersion, patternMatcher || isMigrationApplicable);\n return;\n }\n\n return { data: await runner.getStatus() };\n } catch (err) {\n return { error: { message: err.message } };\n }\n }\n );\n};\n"],"mappings":";;;;;;;;AAEA;AACA;AAQA;AAQA;AACA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SAAS,CAACE,IAAI,CAACQ,kCAAyB,CAAC,CAACC,EAAE,CAACC,mCAAuB,CAAC;IACzE;;IAEA;IACA/B,UAAU,CAACgC,OAAO,CAACC,SAAS,IAAId,SAAS,CAACE,IAAI,CAACa,wBAAe,CAAC,CAACJ,EAAE,CAACG,SAAS,CAAC,CAAC;;IAE9E;IACA,IAAIE,cAAc;IAClB,IAAI1B,OAAO,CAAC2B,OAAO,EAAE;MACjBD,cAAc,GAAG,IAAAE,0CAAoB,EAAC5B,OAAO,CAAC2B,OAAO,CAAC;IAC1D;;IAEA;IACA,IAAI;MACA,MAAME,MAAM,GAAG,MAAMnB,SAAS,CAACoB,OAAO,CAACC,gCAAe,CAAC;MAEvD,IAAI/B,OAAO,CAACgC,OAAO,KAAK,SAAS,EAAE;QAC/B,MAAMH,MAAM,CAACI,OAAO,CAAC/B,cAAc,EAAEwB,cAAc,IAAI/B,qBAAqB,CAAC;QAC7E;MACJ;MAEA,OAAO;QAAEuC,IAAI,EAAE,MAAML,MAAM,CAACM,SAAS;MAAG,CAAC;IAC7C,CAAC,CAAC,OAAOC,GAAG,EAAE;MACV,OAAO;QAAEC,KAAK,EAAE;UAAEC,OAAO,EAAEF,GAAG,CAACE;QAAQ;MAAE,CAAC;IAC9C;EACJ,CAAC,CACJ;AACL,CAAC;AAAC"}
|
|
@@ -13,6 +13,7 @@ var _symbols = require("../symbols");
|
|
|
13
13
|
var _migrations = require("../repository/migrations.repository");
|
|
14
14
|
var _devVersionErrorResponse = require("./devVersionErrorResponse");
|
|
15
15
|
var _createPatternMatcher = require("./createPatternMatcher");
|
|
16
|
+
var _semver = require("semver");
|
|
16
17
|
const _excluded = ["migrations", "primaryTable", "isMigrationApplicable", "repository"];
|
|
17
18
|
const createDdbProjectMigration = _ref => {
|
|
18
19
|
let {
|
|
@@ -27,7 +28,8 @@ const createDdbProjectMigration = _ref => {
|
|
|
27
28
|
lambdaContext
|
|
28
29
|
}) => {
|
|
29
30
|
const projectVersion = String((payload === null || payload === void 0 ? void 0 : payload.version) || process.env.WEBINY_VERSION);
|
|
30
|
-
|
|
31
|
+
const version = (0, _semver.coerce)(projectVersion);
|
|
32
|
+
if ((version === null || version === void 0 ? void 0 : version.version) === "0.0.0") {
|
|
31
33
|
return (0, _devVersionErrorResponse.devVersionErrorResponse)();
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createDdbProjectMigration","migrations","primaryTable","isMigrationApplicable","undefined","repository","config","createRawEventHandler","payload","lambdaContext","projectVersion","String","version","process","env","WEBINY_VERSION","devVersionErrorResponse","container","createContainer","bind","PrimaryDynamoTableSymbol","toConstantValue","timeLimiter","getRemainingTimeInMillis","ExecutionTimeLimiterSymbol","MigrationRepositorySymbol","to","MigrationRepositoryImpl","forEach","migration","MigrationSymbol","patternMatcher","pattern","createPatternMatcher","runner","resolve","MigrationRunner","command","execute","data","getStatus","err","error","message"],"sources":["createDdbProjectMigration.ts"],"sourcesContent":["import { Table } from \"dynamodb-toolbox\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport { Constructor, createContainer } from \"@webiny/ioc\";\nimport { IsMigrationApplicable, MigrationRunner } from \"~/MigrationRunner\";\nimport {\n MigrationRepositorySymbol,\n MigrationSymbol,\n PrimaryDynamoTableSymbol
|
|
1
|
+
{"version":3,"names":["createDdbProjectMigration","migrations","primaryTable","isMigrationApplicable","undefined","repository","config","createRawEventHandler","payload","lambdaContext","projectVersion","String","version","process","env","WEBINY_VERSION","semverCoerce","devVersionErrorResponse","container","createContainer","bind","PrimaryDynamoTableSymbol","toConstantValue","timeLimiter","getRemainingTimeInMillis","ExecutionTimeLimiterSymbol","MigrationRepositorySymbol","to","MigrationRepositoryImpl","forEach","migration","MigrationSymbol","patternMatcher","pattern","createPatternMatcher","runner","resolve","MigrationRunner","command","execute","data","getStatus","err","error","message"],"sources":["createDdbProjectMigration.ts"],"sourcesContent":["import { Table } from \"dynamodb-toolbox\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport { Constructor, createContainer } from \"@webiny/ioc\";\nimport { IsMigrationApplicable, MigrationRunner } from \"~/MigrationRunner\";\nimport {\n ExecutionTimeLimiterSymbol,\n MigrationRepositorySymbol,\n MigrationSymbol,\n PrimaryDynamoTableSymbol\n} from \"~/symbols\";\nimport { MigrationRepositoryImpl } from \"~/repository/migrations.repository\";\nimport { devVersionErrorResponse } from \"./devVersionErrorResponse\";\nimport { createPatternMatcher } from \"./createPatternMatcher\";\nimport {\n DataMigration,\n ExecutionTimeLimiter,\n MigrationEventHandlerResponse,\n MigrationEventPayload,\n MigrationRepository\n} from \"~/types\";\nimport { coerce as semverCoerce } from \"semver\";\n\ninterface CreateDdbDataMigrationConfig {\n migrations: Constructor<DataMigration>[];\n primaryTable: Table;\n repository?: MigrationRepository;\n isMigrationApplicable?: IsMigrationApplicable;\n timeLimiter?: ExecutionTimeLimiter;\n}\n\nexport const createDdbProjectMigration = ({\n migrations,\n primaryTable,\n isMigrationApplicable = undefined,\n repository = undefined,\n ...config\n}: CreateDdbDataMigrationConfig) => {\n return createRawEventHandler<MigrationEventPayload, any, MigrationEventHandlerResponse>(\n async ({ payload, lambdaContext }) => {\n const projectVersion = String(payload?.version || process.env.WEBINY_VERSION);\n\n const version = semverCoerce(projectVersion);\n if (version?.version === \"0.0.0\") {\n return devVersionErrorResponse();\n }\n\n // COMPOSITION ROOT\n const container = createContainer();\n container.bind(PrimaryDynamoTableSymbol).toConstantValue(primaryTable);\n\n const timeLimiter: ExecutionTimeLimiter =\n config.timeLimiter || lambdaContext?.getRemainingTimeInMillis || (() => 0);\n container.bind(ExecutionTimeLimiterSymbol).toConstantValue(timeLimiter);\n\n if (repository) {\n // Repository implementation provided by the user.\n container.bind(MigrationRepositorySymbol).toConstantValue(repository);\n } else {\n // Default repository implementation.\n container.bind(MigrationRepositorySymbol).to(MigrationRepositoryImpl);\n }\n\n // Bind the provided migrations.\n migrations.forEach(migration => container.bind(MigrationSymbol).to(migration));\n\n // If handler was invoked with a `pattern`, filter migrations that match the pattern only.\n let patternMatcher;\n if (payload.pattern) {\n patternMatcher = createPatternMatcher(payload.pattern);\n }\n\n // Inject dependencies and execute.\n try {\n const runner = await container.resolve(MigrationRunner);\n\n if (payload.command === \"execute\") {\n await runner.execute(projectVersion, patternMatcher || isMigrationApplicable);\n return;\n }\n\n return { data: await runner.getStatus() };\n } catch (err) {\n return { error: { message: err.message } };\n }\n }\n );\n};\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAQA;AAAgD;AAUzC,MAAMA,yBAAyB,GAAG,QAML;EAAA,IANM;MACtCC,UAAU;MACVC,YAAY;MACZC,qBAAqB,GAAGC,SAAS;MACjCC,UAAU,GAAGD;IAEa,CAAC;IADxBE,MAAM;EAET,OAAO,IAAAC,iCAAqB,EACxB,OAAO;IAAEC,OAAO;IAAEC;EAAc,CAAC,KAAK;IAClC,MAAMC,cAAc,GAAGC,MAAM,CAAC,CAAAH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,OAAO,KAAIC,OAAO,CAACC,GAAG,CAACC,cAAc,CAAC;IAE7E,MAAMH,OAAO,GAAG,IAAAI,cAAY,EAACN,cAAc,CAAC;IAC5C,IAAI,CAAAE,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEA,OAAO,MAAK,OAAO,EAAE;MAC9B,OAAO,IAAAK,gDAAuB,GAAE;IACpC;;IAEA;IACA,MAAMC,SAAS,GAAG,IAAAC,oBAAe,GAAE;IACnCD,SAAS,CAACE,IAAI,CAACC,iCAAwB,CAAC,CAACC,eAAe,CAACpB,YAAY,CAAC;IAEtE,MAAMqB,WAAiC,GACnCjB,MAAM,CAACiB,WAAW,KAAId,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAEe,wBAAwB,MAAK,MAAM,CAAC,CAAC;IAC9EN,SAAS,CAACE,IAAI,CAACK,mCAA0B,CAAC,CAACH,eAAe,CAACC,WAAW,CAAC;IAEvE,IAAIlB,UAAU,EAAE;MACZ;MACAa,SAAS,CAACE,IAAI,CAACM,kCAAyB,CAAC,CAACJ,eAAe,CAACjB,UAAU,CAAC;IACzE,CAAC,MAAM;MACH;MACAa,SAAS,CAACE,IAAI,CAACM,kCAAyB,CAAC,CAACC,EAAE,CAACC,mCAAuB,CAAC;IACzE;;IAEA;IACA3B,UAAU,CAAC4B,OAAO,CAACC,SAAS,IAAIZ,SAAS,CAACE,IAAI,CAACW,wBAAe,CAAC,CAACJ,EAAE,CAACG,SAAS,CAAC,CAAC;;IAE9E;IACA,IAAIE,cAAc;IAClB,IAAIxB,OAAO,CAACyB,OAAO,EAAE;MACjBD,cAAc,GAAG,IAAAE,0CAAoB,EAAC1B,OAAO,CAACyB,OAAO,CAAC;IAC1D;;IAEA;IACA,IAAI;MACA,MAAME,MAAM,GAAG,MAAMjB,SAAS,CAACkB,OAAO,CAACC,gCAAe,CAAC;MAEvD,IAAI7B,OAAO,CAAC8B,OAAO,KAAK,SAAS,EAAE;QAC/B,MAAMH,MAAM,CAACI,OAAO,CAAC7B,cAAc,EAAEsB,cAAc,IAAI7B,qBAAqB,CAAC;QAC7E;MACJ;MAEA,OAAO;QAAEqC,IAAI,EAAE,MAAML,MAAM,CAACM,SAAS;MAAG,CAAC;IAC7C,CAAC,CAAC,OAAOC,GAAG,EAAE;MACV,OAAO;QAAEC,KAAK,EAAE;UAAEC,OAAO,EAAEF,GAAG,CAACE;QAAQ;MAAE,CAAC;IAC9C;EACJ,CAAC,CACJ;AACL,CAAC;AAAC"}
|
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.8acc9e8892",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "types.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"@babel/runtime": "7.20.13",
|
|
15
15
|
"@elastic/elasticsearch": "7.12.0",
|
|
16
16
|
"@types/pino": "7.0.5",
|
|
17
|
-
"@webiny/db-dynamodb": "0.0.0-unstable.
|
|
18
|
-
"@webiny/handler-aws": "0.0.0-unstable.
|
|
19
|
-
"@webiny/ioc": "0.0.0-unstable.
|
|
20
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
17
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.8acc9e8892",
|
|
18
|
+
"@webiny/handler-aws": "0.0.0-unstable.8acc9e8892",
|
|
19
|
+
"@webiny/ioc": "0.0.0-unstable.8acc9e8892",
|
|
20
|
+
"@webiny/utils": "0.0.0-unstable.8acc9e8892",
|
|
21
21
|
"center-align": "1.0.1",
|
|
22
22
|
"chalk": "4.1.2",
|
|
23
23
|
"dynamodb-toolbox": "0.3.5",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@babel/preset-env": "^7.19.4",
|
|
34
34
|
"@types/center-align": "^1.0.0",
|
|
35
35
|
"@types/semver": "^7.3.4",
|
|
36
|
-
"@webiny/cli": "^0.0.0-unstable.
|
|
37
|
-
"@webiny/project-utils": "^0.0.0-unstable.
|
|
36
|
+
"@webiny/cli": "^0.0.0-unstable.8acc9e8892",
|
|
37
|
+
"@webiny/project-utils": "^0.0.0-unstable.8acc9e8892",
|
|
38
38
|
"jest": "^28.1.0",
|
|
39
39
|
"jest-dynalite": "^3.2.0",
|
|
40
40
|
"jest-mock-console": "^1.0.0",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
]
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "8acc9e8892842cabb3980ce0b6432fde55968d5b"
|
|
60
60
|
}
|