@webiny/data-migration 6.0.0-alpha.5 → 6.0.0-rc.0

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.
Files changed (65) hide show
  1. package/MigrationRunner.d.ts +1 -1
  2. package/MigrationRunner.js +13 -20
  3. package/MigrationRunner.js.map +1 -1
  4. package/README.md +9 -4
  5. package/cli/CliMigrationRunReporter.d.ts +8 -5
  6. package/cli/CliMigrationRunReporter.js +15 -20
  7. package/cli/CliMigrationRunReporter.js.map +1 -1
  8. package/cli/InteractiveCliStatusReporter.d.ts +3 -3
  9. package/cli/InteractiveCliStatusReporter.js +4 -12
  10. package/cli/InteractiveCliStatusReporter.js.map +1 -1
  11. package/cli/LogReporter.d.ts +1 -1
  12. package/cli/LogReporter.js +3 -10
  13. package/cli/LogReporter.js.map +1 -1
  14. package/cli/LogStream.js +3 -10
  15. package/cli/LogStream.js.map +1 -1
  16. package/cli/MigrationRunReporter.d.ts +1 -1
  17. package/cli/MigrationRunReporter.js +1 -5
  18. package/cli/MigrationRunReporter.js.map +1 -1
  19. package/cli/MigrationRunner.d.ts +3 -3
  20. package/cli/MigrationRunner.js +9 -17
  21. package/cli/MigrationRunner.js.map +1 -1
  22. package/cli/MigrationStatusReporter.d.ts +1 -1
  23. package/cli/MigrationStatusReporter.js +1 -5
  24. package/cli/MigrationStatusReporter.js.map +1 -1
  25. package/cli/NonInteractiveCliStatusReporter.d.ts +3 -3
  26. package/cli/NonInteractiveCliStatusReporter.js +1 -8
  27. package/cli/NonInteractiveCliStatusReporter.js.map +1 -1
  28. package/cli/VoidStatusReporter.d.ts +1 -1
  29. package/cli/VoidStatusReporter.js +1 -8
  30. package/cli/VoidStatusReporter.js.map +1 -1
  31. package/cli/getDuration.js +1 -8
  32. package/cli/getDuration.js.map +1 -1
  33. package/cli/index.d.ts +10 -10
  34. package/cli/index.js +10 -115
  35. package/cli/index.js.map +1 -1
  36. package/createPinoLogger.d.ts +2 -2
  37. package/createPinoLogger.js +9 -18
  38. package/createPinoLogger.js.map +1 -1
  39. package/createTable.d.ts +2 -2
  40. package/createTable.js +3 -10
  41. package/createTable.js.map +1 -1
  42. package/handlers/createDdbEsProjectMigration.d.ts +3 -3
  43. package/handlers/createDdbEsProjectMigration.js +22 -29
  44. package/handlers/createDdbEsProjectMigration.js.map +1 -1
  45. package/handlers/createDdbProjectMigration.d.ts +3 -3
  46. package/handlers/createDdbProjectMigration.js +20 -27
  47. package/handlers/createDdbProjectMigration.js.map +1 -1
  48. package/handlers/createPatternMatcher.d.ts +1 -1
  49. package/handlers/createPatternMatcher.js +3 -11
  50. package/handlers/createPatternMatcher.js.map +1 -1
  51. package/handlers/devVersionErrorResponse.js +1 -8
  52. package/handlers/devVersionErrorResponse.js.map +1 -1
  53. package/index.d.ts +6 -6
  54. package/index.js +6 -60
  55. package/index.js.map +1 -1
  56. package/package.json +20 -24
  57. package/repository/migrations.repository.d.ts +2 -2
  58. package/repository/migrations.repository.js +38 -64
  59. package/repository/migrations.repository.js.map +1 -1
  60. package/symbols.js +7 -13
  61. package/symbols.js.map +1 -1
  62. package/types.js +1 -5
  63. package/repository/createStandardEntity.d.ts +0 -52
  64. package/repository/createStandardEntity.js +0 -39
  65. package/repository/createStandardEntity.js.map +0 -1
@@ -1 +1 @@
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,IAAA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AAyB,CAAC,CAACC,EAAE,CAACC,mCAAuB,CAAC;IACzE;;IAEA;IACAjC,UAAU,CAACkC,OAAO,CAACC,SAAS,IAAId,SAAS,CAACE,IAAI,CAACa,wBAAe,CAAC,CAACJ,EAAE,CAACG,SAAS,CAAC,CAAC;;IAE9E;IACA,IAAIE,cAAc;IAClB,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
+ {"version":3,"names":["createRawEventHandler","createContainer","ElasticsearchClientSymbol","ElasticsearchDynamoTableSymbol","ExecutionTimeLimiterSymbol","MigrationRepositorySymbol","MigrationSymbol","PrimaryDynamoTableSymbol","MigrationRunner","MigrationRepositoryImpl","devVersionErrorResponse","createPatternMatcher","coerce","semverCoerce","createDdbEsProjectMigration","migrations","elasticsearchClient","primaryTable","dynamoToEsTable","isMigrationApplicable","undefined","repository","config","payload","lambdaContext","projectVersion","String","version","process","env","WEBINY_VERSION","forceExecute","force","container","bind","toConstantValue","timeLimiter","getRemainingTimeInMillis","to","forEach","migration","patternMatcher","pattern","runner","resolve","setContext","logGroupName","AWS_LAMBDA_LOG_GROUP_NAME","logStreamName","AWS_LAMBDA_LOG_STREAM_NAME","command","execute","data","getStatus","err","error","message"],"sources":["createDdbEsProjectMigration.ts"],"sourcesContent":["import type { Client as ElasticsearchClient } from \"@elastic/elasticsearch\";\nimport type { Table } from \"@webiny/db-dynamodb/toolbox.js\";\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.js\";\nimport {\n ElasticsearchClientSymbol,\n ElasticsearchDynamoTableSymbol,\n ExecutionTimeLimiterSymbol,\n MigrationRepositorySymbol,\n MigrationSymbol,\n PrimaryDynamoTableSymbol\n} from \"~/symbols.js\";\nimport type { IsMigrationApplicable } from \"~/MigrationRunner.js\";\nimport { MigrationRunner } from \"~/MigrationRunner.js\";\nimport { MigrationRepositoryImpl } from \"~/repository/migrations.repository.js\";\nimport { devVersionErrorResponse } from \"~/handlers/devVersionErrorResponse.js\";\nimport { createPatternMatcher } from \"~/handlers/createPatternMatcher.js\";\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,SAASA,qBAAqB,QAAQ,qBAAqB;AAE3D,SAASC,eAAe,QAAQ,aAAa;AAQ7C,SACIC,yBAAyB,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CAACC,WAAW,CAAC;IAEvE,IAAIf,UAAU,EAAE;MACZ;MACAY,SAAS,CAACC,IAAI,CAAC7B,yBAAyB,CAAC,CAAC8B,eAAe,CAACd,UAAU,CAAC;IACzE,CAAC,MAAM;MACH;MACAY,SAAS,CAACC,IAAI,CAAC7B,yBAAyB,CAAC,CAACiC,EAAE,CAAC7B,uBAAuB,CAAC;IACzE;;IAEA;IACAM,UAAU,CAACwB,OAAO,CAACC,SAAS,IAAIP,SAAS,CAACC,IAAI,CAAC5B,eAAe,CAAC,CAACgC,EAAE,CAACE,SAAS,CAAC,CAAC;;IAE9E;IACA,IAAIC,cAAc;IAClB,IAAIlB,OAAO,CAACmB,OAAO,EAAE;MACjBD,cAAc,GAAG9B,oBAAoB,CAACY,OAAO,CAACmB,OAAO,CAAC;IAC1D;;IAEA;IACA,IAAI;MACA,MAAMC,MAAM,GAAG,MAAMV,SAAS,CAACW,OAAO,CAACpC,eAAe,CAAC;MACvDmC,MAAM,CAACE,UAAU,CAAC;QACdC,YAAY,EAAElB,OAAO,CAACC,GAAG,CAACkB,yBAAyB;QACnDC,aAAa,EAAEpB,OAAO,CAACC,GAAG,CAACoB;MAC/B,CAAC,CAAC;MAEF,IAAI1B,OAAO,CAAC2B,OAAO,KAAK,SAAS,EAAE;QAC/B,MAAMP,MAAM,CAACQ,OAAO,CAChB1B,cAAc,EACdgB,cAAc,IAAItB,qBAAqB,EACvCY,YACJ,CAAC;QACD;MACJ;MAEA,OAAO;QAAEqB,IAAI,EAAE,MAAMT,MAAM,CAACU,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","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import type { Table } from "@webiny/db-dynamodb/toolbox";
1
+ import type { Table } from "@webiny/db-dynamodb/toolbox.js";
2
2
  import type { Constructor } from "@webiny/ioc";
3
- import type { IsMigrationApplicable } from "../MigrationRunner";
4
- import type { DataMigration, ExecutionTimeLimiter, MigrationEventHandlerResponse, MigrationEventPayload, MigrationRepository } from "../types";
3
+ import type { IsMigrationApplicable } from "../MigrationRunner.js";
4
+ import type { DataMigration, ExecutionTimeLimiter, MigrationEventHandlerResponse, MigrationEventPayload, MigrationRepository } from "../types.js";
5
5
  interface CreateDdbDataMigrationConfig {
6
6
  migrations: Constructor<DataMigration>[];
7
7
  primaryTable: Table<string, string, string>;
@@ -1,60 +1,54 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createDdbProjectMigration = void 0;
7
- var _handlerAws = require("@webiny/handler-aws");
8
- var _ioc = require("@webiny/ioc");
9
- var _MigrationRunner = require("../MigrationRunner");
10
- var _symbols = require("../symbols");
11
- var _migrations = require("../repository/migrations.repository");
12
- var _devVersionErrorResponse = require("./devVersionErrorResponse");
13
- var _createPatternMatcher = require("./createPatternMatcher");
14
- var _semver = require("semver");
15
- const createDdbProjectMigration = ({
1
+ import { createRawEventHandler } from "@webiny/handler-aws";
2
+ import { createContainer } from "@webiny/ioc";
3
+ import { MigrationRunner } from "../MigrationRunner.js";
4
+ import { ExecutionTimeLimiterSymbol, MigrationRepositorySymbol, MigrationSymbol, PrimaryDynamoTableSymbol } from "../symbols.js";
5
+ import { MigrationRepositoryImpl } from "../repository/migrations.repository.js";
6
+ import { devVersionErrorResponse } from "./devVersionErrorResponse.js";
7
+ import { createPatternMatcher } from "./createPatternMatcher.js";
8
+ import { coerce as semverCoerce } from "semver";
9
+ export const createDdbProjectMigration = ({
16
10
  migrations,
17
11
  primaryTable,
18
12
  isMigrationApplicable = undefined,
19
13
  repository = undefined,
20
14
  ...config
21
15
  }) => {
22
- return (0, _handlerAws.createRawEventHandler)(async ({
16
+ return createRawEventHandler(async ({
23
17
  payload,
24
18
  lambdaContext
25
19
  }) => {
26
20
  const projectVersion = String(payload?.version || process.env.WEBINY_VERSION);
27
21
  const forceExecute = payload.force === true;
28
- const version = (0, _semver.coerce)(projectVersion);
22
+ const version = semverCoerce(projectVersion);
29
23
  if (version?.version === "0.0.0") {
30
- return (0, _devVersionErrorResponse.devVersionErrorResponse)();
24
+ return devVersionErrorResponse();
31
25
  }
32
26
 
33
27
  // COMPOSITION ROOT
34
- const container = (0, _ioc.createContainer)();
35
- container.bind(_symbols.PrimaryDynamoTableSymbol).toConstantValue(primaryTable);
28
+ const container = createContainer();
29
+ container.bind(PrimaryDynamoTableSymbol).toConstantValue(primaryTable);
36
30
  const timeLimiter = config.timeLimiter || lambdaContext?.getRemainingTimeInMillis || (() => 0);
37
- container.bind(_symbols.ExecutionTimeLimiterSymbol).toConstantValue(timeLimiter);
31
+ container.bind(ExecutionTimeLimiterSymbol).toConstantValue(timeLimiter);
38
32
  if (repository) {
39
33
  // Repository implementation provided by the user.
40
- container.bind(_symbols.MigrationRepositorySymbol).toConstantValue(repository);
34
+ container.bind(MigrationRepositorySymbol).toConstantValue(repository);
41
35
  } else {
42
36
  // Default repository implementation.
43
- container.bind(_symbols.MigrationRepositorySymbol).to(_migrations.MigrationRepositoryImpl);
37
+ container.bind(MigrationRepositorySymbol).to(MigrationRepositoryImpl);
44
38
  }
45
39
 
46
40
  // Bind the provided migrations.
47
- migrations.forEach(migration => container.bind(_symbols.MigrationSymbol).to(migration));
41
+ migrations.forEach(migration => container.bind(MigrationSymbol).to(migration));
48
42
 
49
43
  // If handler was invoked with a `pattern`, filter migrations that match the pattern only.
50
44
  let patternMatcher;
51
45
  if (payload.pattern) {
52
- patternMatcher = (0, _createPatternMatcher.createPatternMatcher)(payload.pattern);
46
+ patternMatcher = createPatternMatcher(payload.pattern);
53
47
  }
54
48
 
55
49
  // Inject dependencies and execute.
56
50
  try {
57
- const runner = await container.resolve(_MigrationRunner.MigrationRunner);
51
+ const runner = await container.resolve(MigrationRunner);
58
52
  runner.setContext({
59
53
  logGroupName: process.env.AWS_LAMBDA_LOG_GROUP_NAME,
60
54
  logStreamName: process.env.AWS_LAMBDA_LOG_STREAM_NAME
@@ -75,6 +69,5 @@ const createDdbProjectMigration = ({
75
69
  }
76
70
  });
77
71
  };
78
- exports.createDdbProjectMigration = createDdbProjectMigration;
79
72
 
80
73
  //# sourceMappingURL=createDdbProjectMigration.js.map
@@ -1 +1 @@
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
+ {"version":3,"names":["createRawEventHandler","createContainer","MigrationRunner","ExecutionTimeLimiterSymbol","MigrationRepositorySymbol","MigrationSymbol","PrimaryDynamoTableSymbol","MigrationRepositoryImpl","devVersionErrorResponse","createPatternMatcher","coerce","semverCoerce","createDdbProjectMigration","migrations","primaryTable","isMigrationApplicable","undefined","repository","config","payload","lambdaContext","projectVersion","String","version","process","env","WEBINY_VERSION","forceExecute","force","container","bind","toConstantValue","timeLimiter","getRemainingTimeInMillis","to","forEach","migration","patternMatcher","pattern","runner","resolve","setContext","logGroupName","AWS_LAMBDA_LOG_GROUP_NAME","logStreamName","AWS_LAMBDA_LOG_STREAM_NAME","command","execute","data","getStatus","err","error","message"],"sources":["createDdbProjectMigration.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox.js\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport type { Constructor } from \"@webiny/ioc\";\nimport { createContainer } from \"@webiny/ioc\";\nimport type { IsMigrationApplicable } from \"~/MigrationRunner.js\";\nimport { MigrationRunner } from \"~/MigrationRunner.js\";\nimport {\n ExecutionTimeLimiterSymbol,\n MigrationRepositorySymbol,\n MigrationSymbol,\n PrimaryDynamoTableSymbol\n} from \"~/symbols.js\";\nimport { MigrationRepositoryImpl } from \"~/repository/migrations.repository.js\";\nimport { devVersionErrorResponse } from \"./devVersionErrorResponse.js\";\nimport { createPatternMatcher } from \"./createPatternMatcher.js\";\nimport type {\n DataMigration,\n ExecutionTimeLimiter,\n MigrationEventHandlerResponse,\n MigrationEventPayload,\n MigrationRepository\n} from \"~/types.js\";\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,SAASA,qBAAqB,QAAQ,qBAAqB;AAE3D,SAASC,eAAe,QAAQ,aAAa;AAE7C,SAASC,eAAe;AACxB,SACIC,0BAA0B,EAC1BC,yBAAyB,EACzBC,eAAe,EACfC,wBAAwB;AAE5B,SAASC,uBAAuB;AAChC,SAASC,uBAAuB;AAChC,SAASC,oBAAoB;AAQ7B,SAASC,MAAM,IAAIC,YAAY,QAAQ,QAAQ;AAU/C,OAAO,MAAMC,yBAAy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AO,EAAE;MACjBD,cAAc,GAAG5B,oBAAoB,CAACU,OAAO,CAACmB,OAAO,CAAC;IAC1D;;IAEA;IACA,IAAI;MACA,MAAMC,MAAM,GAAG,MAAMV,SAAS,CAACW,OAAO,CAACtC,eAAe,CAAC;MACvDqC,MAAM,CAACE,UAAU,CAAC;QACdC,YAAY,EAAElB,OAAO,CAACC,GAAG,CAACkB,yBAAyB;QACnDC,aAAa,EAAEpB,OAAO,CAACC,GAAG,CAACoB;MAC/B,CAAC,CAAC;MAEF,IAAI1B,OAAO,CAAC2B,OAAO,KAAK,SAAS,EAAE;QAC/B,MAAMP,MAAM,CAACQ,OAAO,CAChB1B,cAAc,EACdgB,cAAc,IAAItB,qBAAqB,EACvCY,YACJ,CAAC;QACD;MACJ;MAEA,OAAO;QACHqB,IAAI,EAAE,MAAMT,MAAM,CAACU,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","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import type { IsMigrationApplicable } from "../MigrationRunner";
1
+ import type { IsMigrationApplicable } from "../MigrationRunner.js";
2
2
  export declare const createPatternMatcher: (pattern: string) => IsMigrationApplicable;
@@ -1,19 +1,11 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createPatternMatcher = void 0;
8
- var _minimatch = _interopRequireDefault(require("minimatch"));
9
- const createPatternMatcher = pattern => {
1
+ import { minimatch } from "minimatch";
2
+ export const createPatternMatcher = pattern => {
10
3
  return migration => {
11
4
  if (pattern.includes("*")) {
12
- return (0, _minimatch.default)(migration.getId(), pattern);
5
+ return minimatch(migration.getId(), pattern);
13
6
  }
14
7
  return migration.getId() === pattern;
15
8
  };
16
9
  };
17
- exports.createPatternMatcher = createPatternMatcher;
18
10
 
19
11
  //# sourceMappingURL=createPatternMatcher.js.map
@@ -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 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
+ {"version":3,"names":["minimatch","createPatternMatcher","pattern","migration","includes","getId"],"sources":["createPatternMatcher.ts"],"sourcesContent":["import { minimatch } from \"minimatch\";\nimport type { IsMigrationApplicable } from \"~/MigrationRunner.js\";\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,SAASA,SAAS,QAAQ,WAAW;AAGrC,OAAO,MAAMC,oBAAoB,GAAIC,OAAe,IAA4B;EAC5E,OAAOC,SAAS,IAAI;IAChB,IAAID,OAAO,CAACE,QAAQ,CAAC,GAAG,CAAC,EAAE;MACvB,OAAOJ,SAAS,CAACG,SAAS,CAACE,KAAK,CAAC,CAAC,EAAEH,OAAO,CAAC;IAChD;IACA,OAAOC,SAAS,CAACE,KAAK,CAAC,CAAC,KAAKH,OAAO;EACxC,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,16 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.devVersionErrorResponse = void 0;
7
- const devVersionErrorResponse = () => {
1
+ export const devVersionErrorResponse = () => {
8
2
  return {
9
3
  error: {
10
4
  message: [`This project is using a development version 0.0.0!`, `Migrations cannot be executed using version 0.0.0, as that makes them all eligible for execution.`, `To trigger a particular set of migrations, set a WEBINY_VERSION variable in the .env file.`].join(" ")
11
5
  }
12
6
  };
13
7
  };
14
- exports.devVersionErrorResponse = devVersionErrorResponse;
15
8
 
16
9
  //# sourceMappingURL=devVersionErrorResponse.js.map
@@ -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,CACL,oDAAoD,EACpD,mGAAmG,EACnG,4FAA4F,CAC/F,CAACC,IAAI,CAAC,GAAG;IACd;EACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAJ,uBAAA,GAAAA,uBAAA","ignoreList":[]}
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":"AAAA,OAAO,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","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from "./handlers/createDdbProjectMigration";
2
- export * from "./handlers/createDdbEsProjectMigration";
3
- export * from "./types";
4
- export * from "./createTable";
5
- export * from "./createPinoLogger";
6
- export * from "./createPinoLogger";
1
+ export * from "./handlers/createDdbProjectMigration.js";
2
+ export * from "./handlers/createDdbEsProjectMigration.js";
3
+ export * from "./types.js";
4
+ export * from "./createTable.js";
5
+ export * from "./createPinoLogger.js";
6
+ export * from "./createPinoLogger.js";
package/index.js CHANGED
@@ -1,62 +1,8 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _createDdbProjectMigration = require("./handlers/createDdbProjectMigration");
7
- Object.keys(_createDdbProjectMigration).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _createDdbProjectMigration[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _createDdbProjectMigration[key];
14
- }
15
- });
16
- });
17
- var _createDdbEsProjectMigration = require("./handlers/createDdbEsProjectMigration");
18
- Object.keys(_createDdbEsProjectMigration).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _createDdbEsProjectMigration[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _createDdbEsProjectMigration[key];
25
- }
26
- });
27
- });
28
- var _types = require("./types");
29
- Object.keys(_types).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _types[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _types[key];
36
- }
37
- });
38
- });
39
- var _createTable = require("./createTable");
40
- Object.keys(_createTable).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _createTable[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _createTable[key];
47
- }
48
- });
49
- });
50
- var _createPinoLogger = require("./createPinoLogger");
51
- Object.keys(_createPinoLogger).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _createPinoLogger[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _createPinoLogger[key];
58
- }
59
- });
60
- });
1
+ export * from "./handlers/createDdbProjectMigration.js";
2
+ export * from "./handlers/createDdbEsProjectMigration.js";
3
+ export * from "./types.js";
4
+ export * from "./createTable.js";
5
+ export * from "./createPinoLogger.js";
6
+ export * from "./createPinoLogger.js";
61
7
 
62
8
  //# 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","_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,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;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":[]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./handlers/createDdbProjectMigration.js\";\nexport * from \"./handlers/createDdbEsProjectMigration.js\";\nexport * from \"./types.js\";\nexport * from \"./createTable.js\";\nexport * from \"./createPinoLogger.js\";\nexport * from \"./createPinoLogger.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@webiny/data-migration",
3
- "version": "6.0.0-alpha.5",
3
+ "version": "6.0.0-rc.0",
4
4
  "main": "index.js",
5
- "types": "types.ts",
5
+ "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -12,36 +12,32 @@
12
12
  "author": "Webiny Ltd.",
13
13
  "dependencies": {
14
14
  "@elastic/elasticsearch": "7.12.0",
15
- "@webiny/aws-sdk": "6.0.0-alpha.5",
16
- "@webiny/cli": "6.0.0-alpha.5",
17
- "@webiny/db-dynamodb": "6.0.0-alpha.5",
18
- "@webiny/handler-aws": "6.0.0-alpha.5",
19
- "@webiny/ioc": "6.0.0-alpha.5",
20
- "@webiny/logger": "6.0.0-alpha.5",
21
- "@webiny/utils": "6.0.0-alpha.5",
15
+ "@webiny/aws-sdk": "6.0.0-rc.0",
16
+ "@webiny/db-dynamodb": "6.0.0-rc.0",
17
+ "@webiny/handler-aws": "6.0.0-rc.0",
18
+ "@webiny/ioc": "6.0.0-rc.0",
19
+ "@webiny/logger": "6.0.0-rc.0",
20
+ "@webiny/project": "6.0.0-rc.0",
21
+ "@webiny/utils": "6.0.0-rc.0",
22
22
  "center-align": "1.0.1",
23
23
  "chalk": "4.1.2",
24
- "minimatch": "5.1.6",
25
- "pino-pretty": "9.4.0",
26
- "semver": "7.6.3"
24
+ "minimatch": "10.2.2",
25
+ "pino-pretty": "9.4.1",
26
+ "semver": "7.7.4"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/center-align": "1.0.0",
30
- "@types/semver": "7.3.13",
31
- "@webiny/project-utils": "6.0.0-alpha.5",
32
- "jest": "29.7.0",
29
+ "@types/center-align": "1.0.2",
30
+ "@types/semver": "7.7.1",
31
+ "@webiny/build-tools": "6.0.0-rc.0",
32
+ "@webiny/project-utils": "6.0.0-rc.0",
33
33
  "jest-dynalite": "3.6.1",
34
- "jest-mock-console": "2.0.0",
35
- "rimraf": "6.0.1",
36
- "typescript": "5.3.3"
34
+ "rimraf": "6.1.3",
35
+ "typescript": "5.9.3",
36
+ "vitest": "4.0.18"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public",
40
40
  "directory": "dist"
41
41
  },
42
- "scripts": {
43
- "build": "node ../cli/bin.js run build",
44
- "watch": "node ../cli/bin.js run watch"
45
- },
46
- "gitHead": "b7e120541b093e91f214904a9f13e4c2c4640978"
42
+ "gitHead": "0f2aa699f4642e550ab62c96fcd050e8d02345c9"
47
43
  }
@@ -1,5 +1,5 @@
1
- import type { Table } from "@webiny/db-dynamodb/toolbox";
2
- import type { MigrationItem, MigrationRepository, MigrationRun } from "../types";
1
+ import type { Table } from "@webiny/db-dynamodb/toolbox.js";
2
+ import type { MigrationItem, MigrationRepository, MigrationRun } from "../types.js";
3
3
  export declare class MigrationRepositoryImpl implements MigrationRepository {
4
4
  private readonly run;
5
5
  private readonly migration;
@@ -1,32 +1,23 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.MigrationRepositoryImpl = void 0;
7
- var _query = require("@webiny/db-dynamodb/utils/query");
8
- var _ioc = require("@webiny/ioc");
9
- var _symbols = require("../symbols");
10
- var _createStandardEntity = require("./createStandardEntity");
11
- var _dbDynamodb = require("@webiny/db-dynamodb");
12
- class MigrationRepositoryImpl {
1
+ import { inject, makeInjectable } from "@webiny/ioc";
2
+ import { PrimaryDynamoTableSymbol } from "../symbols.js";
3
+ import { createGlobalEntity } from "@webiny/db-dynamodb";
4
+ export class MigrationRepositoryImpl {
13
5
  constructor(table) {
14
- this.run = (0, _createStandardEntity.createStandardEntity)({
6
+ this.run = createGlobalEntity({
15
7
  table,
16
8
  name: "MigrationRun"
17
9
  });
18
- this.migration = (0, _createStandardEntity.createStandardEntity)({
10
+ this.migration = createGlobalEntity({
19
11
  table,
20
12
  name: "Migration"
21
13
  });
22
- this.checkpoint = (0, _createStandardEntity.createStandardEntity)({
14
+ this.checkpoint = createGlobalEntity({
23
15
  table,
24
16
  name: "MigrationCheckpoint"
25
17
  });
26
18
  }
27
19
  async getLastRun() {
28
- const result = await (0, _query.queryOne)({
29
- entity: this.run,
20
+ const result = await this.run.queryOne({
30
21
  partitionKey: "MIGRATION_RUNS",
31
22
  options: {
32
23
  index: "GSI1",
@@ -34,27 +25,23 @@ class MigrationRepositoryImpl {
34
25
  reverse: true
35
26
  }
36
27
  });
37
- return result ? result.data : null;
28
+ return result?.data || null;
38
29
  }
39
30
  async saveRun(run) {
40
- await (0, _dbDynamodb.put)({
41
- entity: this.run,
42
- item: {
43
- PK: `MIGRATION_RUN#${run.id}`,
44
- SK: "A",
45
- TYPE: "migration.run",
46
- GSI1_PK: "MIGRATION_RUNS",
47
- GSI1_SK: run.id,
48
- data: run
49
- }
31
+ await this.run.put({
32
+ PK: `MIGRATION_RUN#${run.id}`,
33
+ SK: "A",
34
+ TYPE: "migration.run",
35
+ GSI1_PK: "MIGRATION_RUNS",
36
+ GSI1_SK: run.id,
37
+ data: run
50
38
  });
51
39
  }
52
40
  async listMigrations(params) {
53
41
  const {
54
42
  limit
55
43
  } = params || {};
56
- const result = await (0, _query.queryAll)({
57
- entity: this.migration,
44
+ const result = await this.migration.queryAll({
58
45
  partitionKey: "MIGRATIONS",
59
46
  options: {
60
47
  index: "GSI1",
@@ -67,47 +54,35 @@ class MigrationRepositoryImpl {
67
54
  return result.map(item => item.data);
68
55
  }
69
56
  async logMigration(migration) {
70
- await (0, _dbDynamodb.put)({
71
- entity: this.migration,
72
- item: {
73
- PK: `MIGRATION#${migration.id}`,
74
- SK: "A",
75
- TYPE: "migration",
76
- GSI1_PK: "MIGRATIONS",
77
- GSI1_SK: migration.id,
78
- data: migration
79
- }
57
+ await this.migration.put({
58
+ PK: `MIGRATION#${migration.id}`,
59
+ SK: "A",
60
+ TYPE: "migration",
61
+ GSI1_PK: "MIGRATIONS",
62
+ GSI1_SK: migration.id,
63
+ data: migration
80
64
  });
81
65
  }
82
66
  async createCheckpoint(id, data) {
83
- await (0, _dbDynamodb.put)({
84
- entity: this.checkpoint,
85
- item: {
86
- PK: `MIGRATION_CHECKPOINT#${id}`,
87
- SK: "A",
88
- TYPE: "migration.checkpoint",
89
- GSI1_PK: "MIGRATION_CHECKPOINTS",
90
- GSI1_SK: id,
91
- data
92
- }
67
+ await this.checkpoint.put({
68
+ PK: `MIGRATION_CHECKPOINT#${id}`,
69
+ SK: "A",
70
+ TYPE: "migration.checkpoint",
71
+ GSI1_PK: "MIGRATION_CHECKPOINTS",
72
+ GSI1_SK: id,
73
+ data: data
93
74
  });
94
75
  }
95
76
  async deleteCheckpoint(id) {
96
- await (0, _dbDynamodb.deleteItem)({
97
- entity: this.checkpoint,
98
- keys: {
99
- PK: `MIGRATION_CHECKPOINT#${id}`,
100
- SK: "A"
101
- }
77
+ await this.checkpoint.delete({
78
+ PK: `MIGRATION_CHECKPOINT#${id}`,
79
+ SK: "A"
102
80
  });
103
81
  }
104
82
  async getCheckpoint(id) {
105
- const record = await (0, _dbDynamodb.get)({
106
- entity: this.checkpoint,
107
- keys: {
108
- PK: `MIGRATION_CHECKPOINT#${id}`,
109
- SK: "A"
110
- }
83
+ const record = await this.checkpoint.get({
84
+ PK: `MIGRATION_CHECKPOINT#${id}`,
85
+ SK: "A"
111
86
  });
112
87
  if (!record) {
113
88
  return null;
@@ -115,7 +90,6 @@ class MigrationRepositoryImpl {
115
90
  return record.data;
116
91
  }
117
92
  }
118
- exports.MigrationRepositoryImpl = MigrationRepositoryImpl;
119
- (0, _ioc.makeInjectable)(MigrationRepositoryImpl, [(0, _ioc.inject)(_symbols.PrimaryDynamoTableSymbol)]);
93
+ makeInjectable(MigrationRepositoryImpl, [inject(PrimaryDynamoTableSymbol)]);
120
94
 
121
95
  //# sourceMappingURL=migrations.repository.js.map