@webiny/data-migration 0.0.0-unstable.e3f4727c56 → 0.0.0-unstable.eb196ccd2f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/MigrationRunner.d.ts +16 -9
  2. package/MigrationRunner.js +243 -62
  3. package/MigrationRunner.js.map +1 -1
  4. package/cli/CliMigrationRunReporter.d.ts +10 -0
  5. package/cli/CliMigrationRunReporter.js +55 -0
  6. package/cli/CliMigrationRunReporter.js.map +1 -0
  7. package/cli/InteractiveCliStatusReporter.d.ts +11 -0
  8. package/cli/InteractiveCliStatusReporter.js +74 -0
  9. package/cli/InteractiveCliStatusReporter.js.map +1 -0
  10. package/cli/LogReporter.d.ts +10 -0
  11. package/cli/LogReporter.js +43 -0
  12. package/cli/LogReporter.js.map +1 -0
  13. package/cli/LogStream.d.ts +10 -0
  14. package/cli/LogStream.js +58 -0
  15. package/cli/LogStream.js.map +1 -0
  16. package/cli/MigrationRunReporter.d.ts +4 -0
  17. package/cli/MigrationRunReporter.js +7 -0
  18. package/cli/MigrationRunReporter.js.map +1 -0
  19. package/cli/MigrationRunner.d.ts +45 -0
  20. package/cli/MigrationRunner.js +136 -0
  21. package/cli/MigrationRunner.js.map +1 -0
  22. package/cli/MigrationStatusReporter.d.ts +4 -0
  23. package/cli/MigrationStatusReporter.js +7 -0
  24. package/cli/MigrationStatusReporter.js.map +1 -0
  25. package/cli/NonInteractiveCliStatusReporter.d.ts +9 -0
  26. package/cli/NonInteractiveCliStatusReporter.js +42 -0
  27. package/cli/NonInteractiveCliStatusReporter.js.map +1 -0
  28. package/cli/VoidStatusReporter.d.ts +4 -0
  29. package/cli/VoidStatusReporter.js +14 -0
  30. package/cli/VoidStatusReporter.js.map +1 -0
  31. package/cli/getDuration.d.ts +5 -0
  32. package/cli/getDuration.js +23 -0
  33. package/cli/getDuration.js.map +1 -0
  34. package/cli/index.d.ts +10 -0
  35. package/cli/index.js +117 -0
  36. package/cli/index.js.map +1 -0
  37. package/createPinoLogger.d.ts +4 -7
  38. package/createPinoLogger.js +7 -3
  39. package/createPinoLogger.js.map +1 -1
  40. package/createTable.d.ts +4 -4
  41. package/createTable.js +8 -4
  42. package/createTable.js.map +1 -1
  43. package/handlers/createDdbEsProjectMigration.d.ts +9 -8
  44. package/handlers/createDdbEsProjectMigration.js +24 -7
  45. package/handlers/createDdbEsProjectMigration.js.map +1 -1
  46. package/handlers/createDdbProjectMigration.d.ts +7 -6
  47. package/handlers/createDdbProjectMigration.js +24 -7
  48. package/handlers/createDdbProjectMigration.js.map +1 -1
  49. package/handlers/createPatternMatcher.d.ts +1 -1
  50. package/handlers/createPatternMatcher.js +3 -1
  51. package/handlers/createPatternMatcher.js.map +1 -1
  52. package/handlers/devVersionErrorResponse.js +3 -1
  53. package/handlers/devVersionErrorResponse.js.map +1 -1
  54. package/index.d.ts +1 -1
  55. package/index.js +3 -12
  56. package/index.js.map +1 -1
  57. package/package.json +21 -30
  58. package/repository/createStandardEntity.d.ts +52 -0
  59. package/repository/{migrations.entity.js → createStandardEntity.js} +10 -7
  60. package/repository/createStandardEntity.js.map +1 -0
  61. package/repository/migrations.repository.d.ts +11 -4
  62. package/repository/migrations.repository.js +87 -15
  63. package/repository/migrations.repository.js.map +1 -1
  64. package/symbols.d.ts +1 -0
  65. package/symbols.js +10 -13
  66. package/symbols.js.map +1 -1
  67. package/types.d.ts +59 -33
  68. package/types.js +2 -7
  69. package/types.js.map +1 -1
  70. package/repository/migrations.entity.d.ts +0 -4
  71. package/repository/migrations.entity.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/data-migration",
3
- "version": "0.0.0-unstable.e3f4727c56",
3
+ "version": "0.0.0-unstable.eb196ccd2f",
4
4
  "main": "index.js",
5
5
  "types": "types.ts",
6
6
  "license": "MIT",
@@ -11,46 +11,37 @@
11
11
  "description": "Tools to author and execute data migrations.",
12
12
  "author": "Webiny Ltd.",
13
13
  "dependencies": {
14
- "@babel/runtime": "7.20.13",
15
14
  "@elastic/elasticsearch": "7.12.0",
16
- "@types/pino": "7.0.5",
17
- "@webiny/db-dynamodb": "0.0.0-unstable.e3f4727c56",
18
- "@webiny/handler-aws": "0.0.0-unstable.e3f4727c56",
19
- "@webiny/ioc": "0.0.0-unstable.e3f4727c56",
15
+ "@webiny/aws-sdk": "0.0.0-unstable.eb196ccd2f",
16
+ "@webiny/cli": "0.0.0-unstable.eb196ccd2f",
17
+ "@webiny/db-dynamodb": "0.0.0-unstable.eb196ccd2f",
18
+ "@webiny/handler-aws": "0.0.0-unstable.eb196ccd2f",
19
+ "@webiny/ioc": "0.0.0-unstable.eb196ccd2f",
20
+ "@webiny/logger": "0.0.0-unstable.eb196ccd2f",
21
+ "@webiny/utils": "0.0.0-unstable.eb196ccd2f",
22
+ "center-align": "1.0.1",
20
23
  "chalk": "4.1.2",
21
- "dynamodb-toolbox": "0.3.5",
22
24
  "minimatch": "5.1.6",
23
- "pino": "8.11.0",
24
25
  "pino-pretty": "9.4.0",
25
- "semver": "6.3.0"
26
+ "semver": "7.6.3"
26
27
  },
27
28
  "devDependencies": {
28
- "@babel/cli": "^7.19.3",
29
- "@babel/core": "^7.19.3",
30
- "@babel/preset-env": "^7.19.4",
31
- "@types/semver": "^7.3.4",
32
- "@webiny/cli": "^0.0.0-unstable.e3f4727c56",
33
- "@webiny/project-utils": "^0.0.0-unstable.e3f4727c56",
34
- "jest": "^28.1.0",
35
- "jest-dynalite": "^3.2.0",
36
- "jest-mock-console": "^1.0.0",
37
- "rimraf": "^3.0.2",
38
- "typescript": "4.7.4"
29
+ "@types/center-align": "1.0.0",
30
+ "@types/semver": "7.3.13",
31
+ "@webiny/project-utils": "0.0.0-unstable.eb196ccd2f",
32
+ "jest": "29.7.0",
33
+ "jest-dynalite": "3.6.1",
34
+ "jest-mock-console": "2.0.0",
35
+ "rimraf": "6.0.1",
36
+ "typescript": "5.3.3"
39
37
  },
40
38
  "publishConfig": {
41
39
  "access": "public",
42
40
  "directory": "dist"
43
41
  },
44
42
  "scripts": {
45
- "build": "yarn webiny run build",
46
- "watch": "yarn webiny run watch"
43
+ "build": "node ../cli/bin.js run build",
44
+ "watch": "node ../cli/bin.js run watch"
47
45
  },
48
- "adio": {
49
- "ignore": {
50
- "dependencies": [
51
- "@types/pino"
52
- ]
53
- }
54
- },
55
- "gitHead": "e3f4727c567484dc53e1efceacfb37dbacd7f4de"
46
+ "gitHead": "eb196ccd2f32296e10f7add6dd7220d4e3abece4"
56
47
  }
@@ -0,0 +1,52 @@
1
+ import type { Table } from "@webiny/db-dynamodb/toolbox";
2
+ import { Entity } from "@webiny/db-dynamodb/toolbox";
3
+ export declare const createStandardEntity: ({ table, name }: {
4
+ table: Table<string, string, string>;
5
+ name: string;
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
+ }>;
@@ -3,13 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createMigrationsEntity = void 0;
7
- var _dynamodbToolbox = require("dynamodb-toolbox");
8
- const createMigrationsEntity = ({
9
- table
6
+ exports.createStandardEntity = void 0;
7
+ var _toolbox = require("@webiny/db-dynamodb/toolbox");
8
+ const createStandardEntity = ({
9
+ table,
10
+ name
10
11
  }) => {
11
- return new _dynamodbToolbox.Entity({
12
- name: "Migrations",
12
+ return new _toolbox.Entity({
13
+ name,
13
14
  table,
14
15
  attributes: {
15
16
  PK: {
@@ -33,4 +34,6 @@ const createMigrationsEntity = ({
33
34
  }
34
35
  });
35
36
  };
36
- exports.createMigrationsEntity = createMigrationsEntity;
37
+ exports.createStandardEntity = createStandardEntity;
38
+
39
+ //# sourceMappingURL=createStandardEntity.js.map
@@ -0,0 +1 @@
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,17 @@
1
- import { Table } from "dynamodb-toolbox";
2
- import { MigrationItem, MigrationRepository } 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
- private readonly entity;
5
- constructor(table: Table);
4
+ private readonly run;
5
+ private readonly migration;
6
+ private readonly checkpoint;
7
+ constructor(table: Table<string, string, string>);
8
+ getLastRun(): Promise<MigrationRun | null>;
9
+ saveRun(run: MigrationRun): Promise<void>;
6
10
  listMigrations(params?: {
7
11
  limit: number;
8
12
  }): Promise<MigrationItem[]>;
9
13
  logMigration(migration: MigrationItem): Promise<void>;
14
+ createCheckpoint(id: string, data: unknown): Promise<void>;
15
+ deleteCheckpoint(id: string): Promise<void>;
16
+ getCheckpoint(id: string): Promise<unknown | null>;
10
17
  }
@@ -1,20 +1,52 @@
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.MigrationRepositoryImpl = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _query = require("@webiny/db-dynamodb/utils/query");
10
- var _migrations = require("./migrations.entity");
11
8
  var _ioc = require("@webiny/ioc");
12
9
  var _symbols = require("../symbols");
10
+ var _createStandardEntity = require("./createStandardEntity");
11
+ var _dbDynamodb = require("@webiny/db-dynamodb");
13
12
  class MigrationRepositoryImpl {
14
13
  constructor(table) {
15
- (0, _defineProperty2.default)(this, "entity", void 0);
16
- this.entity = (0, _migrations.createMigrationsEntity)({
17
- table
14
+ this.run = (0, _createStandardEntity.createStandardEntity)({
15
+ table,
16
+ name: "MigrationRun"
17
+ });
18
+ this.migration = (0, _createStandardEntity.createStandardEntity)({
19
+ table,
20
+ name: "Migration"
21
+ });
22
+ this.checkpoint = (0, _createStandardEntity.createStandardEntity)({
23
+ table,
24
+ name: "MigrationCheckpoint"
25
+ });
26
+ }
27
+ async getLastRun() {
28
+ const result = await (0, _query.queryOne)({
29
+ entity: this.run,
30
+ partitionKey: "MIGRATION_RUNS",
31
+ options: {
32
+ index: "GSI1",
33
+ gt: " ",
34
+ reverse: true
35
+ }
36
+ });
37
+ return result ? result.data : null;
38
+ }
39
+ 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
+ }
18
50
  });
19
51
  }
20
52
  async listMigrations(params) {
@@ -22,7 +54,7 @@ class MigrationRepositoryImpl {
22
54
  limit
23
55
  } = params || {};
24
56
  const result = await (0, _query.queryAll)({
25
- entity: this.entity,
57
+ entity: this.migration,
26
58
  partitionKey: "MIGRATIONS",
27
59
  options: {
28
60
  index: "GSI1",
@@ -35,15 +67,55 @@ class MigrationRepositoryImpl {
35
67
  return result.map(item => item.data);
36
68
  }
37
69
  async logMigration(migration) {
38
- await this.entity.put({
39
- PK: `MIGRATION#${migration.id}`,
40
- SK: "A",
41
- TYPE: "migration",
42
- GSI1_PK: "MIGRATIONS",
43
- GSI1_SK: migration.id,
44
- data: 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
+ }
80
+ });
81
+ }
82
+ 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
+ }
45
93
  });
46
94
  }
95
+ async deleteCheckpoint(id) {
96
+ await (0, _dbDynamodb.deleteItem)({
97
+ entity: this.checkpoint,
98
+ keys: {
99
+ PK: `MIGRATION_CHECKPOINT#${id}`,
100
+ SK: "A"
101
+ }
102
+ });
103
+ }
104
+ 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
+ }
111
+ });
112
+ if (!record) {
113
+ return null;
114
+ }
115
+ return record.data;
116
+ }
47
117
  }
48
118
  exports.MigrationRepositoryImpl = MigrationRepositoryImpl;
49
- (0, _ioc.makeInjectable)(MigrationRepositoryImpl, [(0, _ioc.inject)(_symbols.PrimaryDynamoTableSymbol)]);
119
+ (0, _ioc.makeInjectable)(MigrationRepositoryImpl, [(0, _ioc.inject)(_symbols.PrimaryDynamoTableSymbol)]);
120
+
121
+ //# sourceMappingURL=migrations.repository.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["MigrationRepositoryImpl","constructor","table","entity","createMigrationsEntity","listMigrations","params","limit","result","queryAll","partitionKey","options","index","gt","reverse","map","item","data","logMigration","migration","put","PK","id","SK","TYPE","GSI1_PK","GSI1_SK","makeInjectable","inject","PrimaryDynamoTableSymbol"],"sources":["migrations.repository.ts"],"sourcesContent":["import { Table, Entity } from \"dynamodb-toolbox\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { MigrationItem, MigrationRepository } from \"~/types\";\nimport { createMigrationsEntity } from \"~/repository/migrations.entity\";\nimport { inject, makeInjectable } from \"@webiny/ioc\";\nimport { PrimaryDynamoTableSymbol } from \"~/symbols\";\n\nexport class MigrationRepositoryImpl implements MigrationRepository {\n private readonly entity: Entity<any>;\n\n constructor(table: Table) {\n this.entity = createMigrationsEntity({ table });\n }\n\n async listMigrations(params?: { limit: number }): Promise<MigrationItem[]> {\n const { limit } = params || {};\n const result = await queryAll<{ data: MigrationItem }>({\n entity: this.entity,\n partitionKey: \"MIGRATIONS\",\n options: {\n index: \"GSI1\",\n gt: \" \",\n limit,\n // Sort by GSI1_SK in descending order.\n reverse: true\n }\n });\n\n return result.map(item => item.data);\n }\n\n async logMigration(migration: MigrationItem): Promise<void> {\n await this.entity.put({\n PK: `MIGRATION#${migration.id}`,\n SK: \"A\",\n TYPE: \"migration\",\n GSI1_PK: \"MIGRATIONS\",\n GSI1_SK: migration.id,\n data: migration\n });\n }\n}\n\nmakeInjectable(MigrationRepositoryImpl, [inject(PrimaryDynamoTableSymbol)]);\n"],"mappings":";;;;;;;;AACA;AAEA;AACA;AACA;AAEO,MAAMA,uBAAuB,CAAgC;EAGhEC,WAAW,CAACC,KAAY,EAAE;IAAA;IACtB,IAAI,CAACC,MAAM,GAAG,IAAAC,kCAAsB,EAAC;MAAEF;IAAM,CAAC,CAAC;EACnD;EAEA,MAAMG,cAAc,CAACC,MAA0B,EAA4B;IACvE,MAAM;MAAEC;IAAM,CAAC,GAAGD,MAAM,IAAI,CAAC,CAAC;IAC9B,MAAME,MAAM,GAAG,MAAM,IAAAC,eAAQ,EAA0B;MACnDN,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBO,YAAY,EAAE,YAAY;MAC1BC,OAAO,EAAE;QACLC,KAAK,EAAE,MAAM;QACbC,EAAE,EAAE,GAAG;QACPN,KAAK;QACL;QACAO,OAAO,EAAE;MACb;IACJ,CAAC,CAAC;IAEF,OAAON,MAAM,CAACO,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,IAAI,CAAC;EACxC;EAEA,MAAMC,YAAY,CAACC,SAAwB,EAAiB;IACxD,MAAM,IAAI,CAAChB,MAAM,CAACiB,GAAG,CAAC;MAClBC,EAAE,EAAG,aAAYF,SAAS,CAACG,EAAG,EAAC;MAC/BC,EAAE,EAAE,GAAG;MACPC,IAAI,EAAE,WAAW;MACjBC,OAAO,EAAE,YAAY;MACrBC,OAAO,EAAEP,SAAS,CAACG,EAAE;MACrBL,IAAI,EAAEE;IACV,CAAC,CAAC;EACN;AACJ;AAAC;AAED,IAAAQ,mBAAc,EAAC3B,uBAAuB,EAAE,CAAC,IAAA4B,WAAM,EAACC,iCAAwB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"names":["_query","require","_ioc","_symbols","_createStandardEntity","_dbDynamodb","MigrationRepositoryImpl","constructor","table","run","createStandardEntity","name","migration","checkpoint","getLastRun","result","queryOne","entity","partitionKey","options","index","gt","reverse","data","saveRun","put","item","PK","id","SK","TYPE","GSI1_PK","GSI1_SK","listMigrations","params","limit","queryAll","map","logMigration","createCheckpoint","deleteCheckpoint","deleteItem","keys","getCheckpoint","record","get","exports","makeInjectable","inject","PrimaryDynamoTableSymbol"],"sources":["migrations.repository.ts"],"sourcesContent":["import type { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { queryAll, queryOne } from \"@webiny/db-dynamodb/utils/query\";\nimport type { MigrationItem, MigrationRepository, MigrationRun } from \"~/types\";\nimport { inject, makeInjectable } from \"@webiny/ioc\";\nimport { PrimaryDynamoTableSymbol } from \"~/symbols\";\nimport { createStandardEntity } from \"./createStandardEntity\";\nimport { deleteItem, get, put } from \"@webiny/db-dynamodb\";\n\ninterface MigrationCheckpoint {\n data: unknown;\n}\n\nexport class MigrationRepositoryImpl implements MigrationRepository {\n private readonly run: Entity<any>;\n private readonly migration: Entity<any>;\n private readonly checkpoint: Entity<any>;\n\n constructor(table: Table<string, string, string>) {\n this.run = createStandardEntity({ table, name: \"MigrationRun\" });\n this.migration = createStandardEntity({ table, name: \"Migration\" });\n this.checkpoint = createStandardEntity({ table, name: \"MigrationCheckpoint\" });\n }\n\n async getLastRun(): Promise<MigrationRun | null> {\n const result = await queryOne<{ data: MigrationRun }>({\n entity: this.run,\n partitionKey: \"MIGRATION_RUNS\",\n options: {\n index: \"GSI1\",\n gt: \" \",\n reverse: true\n }\n });\n\n return result ? result.data : null;\n }\n\n async saveRun(run: MigrationRun): Promise<void> {\n await put({\n entity: this.run,\n item: {\n PK: `MIGRATION_RUN#${run.id}`,\n SK: \"A\",\n TYPE: \"migration.run\",\n GSI1_PK: \"MIGRATION_RUNS\",\n GSI1_SK: run.id,\n data: run\n }\n });\n }\n\n async listMigrations(params?: { limit: number }): Promise<MigrationItem[]> {\n const { limit } = params || {};\n const result = await queryAll<{ data: MigrationItem }>({\n entity: this.migration,\n partitionKey: \"MIGRATIONS\",\n options: {\n index: \"GSI1\",\n gt: \" \",\n limit,\n // Sort by GSI1_SK in descending order.\n reverse: true\n }\n });\n\n return result.map(item => item.data);\n }\n\n async logMigration(migration: MigrationItem): Promise<void> {\n await put({\n entity: this.migration,\n item: {\n PK: `MIGRATION#${migration.id}`,\n SK: \"A\",\n TYPE: \"migration\",\n GSI1_PK: \"MIGRATIONS\",\n GSI1_SK: migration.id,\n data: migration\n }\n });\n }\n\n async createCheckpoint(id: string, data: unknown): Promise<void> {\n await put({\n entity: this.checkpoint,\n item: {\n PK: `MIGRATION_CHECKPOINT#${id}`,\n SK: \"A\",\n TYPE: \"migration.checkpoint\",\n GSI1_PK: \"MIGRATION_CHECKPOINTS\",\n GSI1_SK: id,\n data\n }\n });\n }\n\n async deleteCheckpoint(id: string): Promise<void> {\n await deleteItem({\n entity: this.checkpoint,\n keys: {\n PK: `MIGRATION_CHECKPOINT#${id}`,\n SK: \"A\"\n }\n });\n }\n\n async getCheckpoint(id: string): Promise<unknown | null> {\n const record = await get<MigrationCheckpoint>({\n entity: this.checkpoint,\n keys: {\n PK: `MIGRATION_CHECKPOINT#${id}`,\n SK: \"A\"\n }\n });\n\n if (!record) {\n return null;\n }\n return record.data;\n }\n}\n\nmakeInjectable(MigrationRepositoryImpl, [inject(PrimaryDynamoTableSymbol)]);\n"],"mappings":"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","ignoreList":[]}
package/symbols.d.ts CHANGED
@@ -4,3 +4,4 @@ export declare const MigrationRepositorySymbol: unique symbol;
4
4
  export declare const ElasticsearchClientSymbol: unique symbol;
5
5
  export declare const PrimaryDynamoTableSymbol: unique symbol;
6
6
  export declare const ElasticsearchDynamoTableSymbol: unique symbol;
7
+ export declare const ExecutionTimeLimiterSymbol: unique symbol;
package/symbols.js CHANGED
@@ -3,16 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.PrimaryDynamoTableSymbol = exports.MigrationSymbol = exports.MigrationRepositorySymbol = exports.LoggerSymbol = exports.ElasticsearchDynamoTableSymbol = exports.ElasticsearchClientSymbol = void 0;
7
- const LoggerSymbol = Symbol.for("PinoLogger");
8
- exports.LoggerSymbol = LoggerSymbol;
9
- const MigrationSymbol = Symbol.for("Migration");
10
- exports.MigrationSymbol = MigrationSymbol;
11
- const MigrationRepositorySymbol = Symbol.for("MigrationRepository");
12
- exports.MigrationRepositorySymbol = MigrationRepositorySymbol;
13
- const ElasticsearchClientSymbol = Symbol.for("ElasticsearchClient");
14
- exports.ElasticsearchClientSymbol = ElasticsearchClientSymbol;
15
- const PrimaryDynamoTableSymbol = Symbol.for("PrimaryDynamoTable");
16
- exports.PrimaryDynamoTableSymbol = PrimaryDynamoTableSymbol;
17
- const ElasticsearchDynamoTableSymbol = Symbol.for("ElasticsearchDynamoTable");
18
- exports.ElasticsearchDynamoTableSymbol = ElasticsearchDynamoTableSymbol;
6
+ exports.PrimaryDynamoTableSymbol = exports.MigrationSymbol = exports.MigrationRepositorySymbol = exports.LoggerSymbol = exports.ExecutionTimeLimiterSymbol = exports.ElasticsearchDynamoTableSymbol = exports.ElasticsearchClientSymbol = void 0;
7
+ const LoggerSymbol = exports.LoggerSymbol = Symbol.for("PinoLogger");
8
+ const MigrationSymbol = exports.MigrationSymbol = Symbol.for("Migration");
9
+ const MigrationRepositorySymbol = exports.MigrationRepositorySymbol = Symbol.for("MigrationRepository");
10
+ const ElasticsearchClientSymbol = exports.ElasticsearchClientSymbol = Symbol.for("ElasticsearchClient");
11
+ const PrimaryDynamoTableSymbol = exports.PrimaryDynamoTableSymbol = Symbol.for("PrimaryDynamoTable");
12
+ const ElasticsearchDynamoTableSymbol = exports.ElasticsearchDynamoTableSymbol = Symbol.for("ElasticsearchDynamoTable");
13
+ const ExecutionTimeLimiterSymbol = exports.ExecutionTimeLimiterSymbol = Symbol.for("ExecutionTimeLimiter");
14
+
15
+ //# sourceMappingURL=symbols.js.map
package/symbols.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["LoggerSymbol","Symbol","for","MigrationSymbol","MigrationRepositorySymbol","ElasticsearchClientSymbol","PrimaryDynamoTableSymbol","ElasticsearchDynamoTableSymbol"],"sources":["symbols.ts"],"sourcesContent":["export const LoggerSymbol = Symbol.for(\"PinoLogger\");\nexport const MigrationSymbol = Symbol.for(\"Migration\");\nexport const MigrationRepositorySymbol = Symbol.for(\"MigrationRepository\");\nexport const ElasticsearchClientSymbol = Symbol.for(\"ElasticsearchClient\");\nexport const PrimaryDynamoTableSymbol = Symbol.for(\"PrimaryDynamoTable\");\nexport const ElasticsearchDynamoTableSymbol = Symbol.for(\"ElasticsearchDynamoTable\");\n"],"mappings":";;;;;;AAAO,MAAMA,YAAY,GAAGC,MAAM,CAACC,GAAG,CAAC,YAAY,CAAC;AAAC;AAC9C,MAAMC,eAAe,GAAGF,MAAM,CAACC,GAAG,CAAC,WAAW,CAAC;AAAC;AAChD,MAAME,yBAAyB,GAAGH,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAAC;AAAC;AACpE,MAAMG,yBAAyB,GAAGJ,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAAC;AAAC;AACpE,MAAMI,wBAAwB,GAAGL,MAAM,CAACC,GAAG,CAAC,oBAAoB,CAAC;AAAC;AAClE,MAAMK,8BAA8B,GAAGN,MAAM,CAACC,GAAG,CAAC,0BAA0B,CAAC;AAAC"}
1
+ {"version":3,"names":["LoggerSymbol","exports","Symbol","for","MigrationSymbol","MigrationRepositorySymbol","ElasticsearchClientSymbol","PrimaryDynamoTableSymbol","ElasticsearchDynamoTableSymbol","ExecutionTimeLimiterSymbol"],"sources":["symbols.ts"],"sourcesContent":["export const LoggerSymbol = Symbol.for(\"PinoLogger\");\nexport const MigrationSymbol = Symbol.for(\"Migration\");\nexport const MigrationRepositorySymbol = Symbol.for(\"MigrationRepository\");\nexport const ElasticsearchClientSymbol = Symbol.for(\"ElasticsearchClient\");\nexport const PrimaryDynamoTableSymbol = Symbol.for(\"PrimaryDynamoTable\");\nexport const ElasticsearchDynamoTableSymbol = Symbol.for(\"ElasticsearchDynamoTable\");\nexport const ExecutionTimeLimiterSymbol = Symbol.for(\"ExecutionTimeLimiter\");\n"],"mappings":";;;;;;AAAO,MAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAGE,MAAM,CAACC,GAAG,CAAC,YAAY,CAAC;AAC7C,MAAMC,eAAe,GAAAH,OAAA,CAAAG,eAAA,GAAGF,MAAM,CAACC,GAAG,CAAC,WAAW,CAAC;AAC/C,MAAME,yBAAyB,GAAAJ,OAAA,CAAAI,yBAAA,GAAGH,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAAC;AACnE,MAAMG,yBAAyB,GAAAL,OAAA,CAAAK,yBAAA,GAAGJ,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAAC;AACnE,MAAMI,wBAAwB,GAAAN,OAAA,CAAAM,wBAAA,GAAGL,MAAM,CAACC,GAAG,CAAC,oBAAoB,CAAC;AACjE,MAAMK,8BAA8B,GAAAP,OAAA,CAAAO,8BAAA,GAAGN,MAAM,CAACC,GAAG,CAAC,0BAA0B,CAAC;AAC7E,MAAMM,0BAA0B,GAAAR,OAAA,CAAAQ,0BAAA,GAAGP,MAAM,CAACC,GAAG,CAAC,sBAAsB,CAAC","ignoreList":[]}
package/types.d.ts CHANGED
@@ -1,57 +1,83 @@
1
- import { Logger, LogEvent } from "pino";
2
- export { Logger };
1
+ import type { Logger } from "@webiny/logger";
2
+ export type { Logger };
3
3
  export interface MigrationItem {
4
4
  id: string;
5
5
  description: string;
6
- createdOn: string;
7
- duration: number;
8
6
  reason: string;
7
+ startedOn?: string;
8
+ finishedOn?: string;
9
+ }
10
+ export interface MigrationRun {
11
+ id: string;
12
+ startedOn: string;
13
+ finishedOn: string;
14
+ status: "init" | "running" | "pending" | "done" | "error";
15
+ migrations: MigrationRunItem[];
16
+ context?: Record<string, any>;
17
+ error?: {
18
+ message: string;
19
+ name?: string;
20
+ code?: string;
21
+ data?: Record<string, any>;
22
+ stack?: string;
23
+ };
24
+ }
25
+ export interface MigrationRunItem {
26
+ id: string;
27
+ status: "done" | "running" | "skipped" | "pending" | "not-applicable" | "error";
28
+ startedOn?: string;
29
+ finishedOn?: string;
9
30
  }
10
31
  export interface MigrationRepository {
32
+ getLastRun(): Promise<MigrationRun | null>;
33
+ saveRun(run: MigrationRun): Promise<void>;
11
34
  listMigrations(params?: {
12
35
  limit: number;
13
36
  }): Promise<MigrationItem[]>;
14
37
  logMigration(migration: MigrationItem): Promise<void>;
38
+ createCheckpoint(id: string, data: unknown): Promise<void>;
39
+ getCheckpoint(id: string): Promise<unknown>;
40
+ deleteCheckpoint(id: string): Promise<void>;
15
41
  }
16
- export interface DataMigrationContext {
42
+ export interface DataMigrationContext<TCheckpoint = any> {
17
43
  projectVersion: string;
18
44
  logger: Logger;
45
+ checkpoint?: TCheckpoint;
46
+ forceExecute: boolean;
47
+ runningOutOfTime: () => boolean;
48
+ createCheckpoint: (data: TCheckpoint) => Promise<void>;
49
+ createCheckpointAndExit: (data: TCheckpoint) => Promise<void>;
19
50
  }
20
- export interface DataMigration {
51
+ export interface DataMigration<TCheckpoint = any> {
21
52
  getId(): string;
22
53
  getDescription(): string;
23
- shouldExecute(context: DataMigrationContext): Promise<boolean>;
24
- execute(context: DataMigrationContext): Promise<void>;
25
- }
26
- export interface MigrationResult {
27
- success: boolean;
28
- logs: LogEvent[];
29
- duration: number;
30
- }
31
- export interface ExecutedMigrationResponse {
32
- id: string;
33
- description: string;
34
- result: MigrationResult;
35
- }
36
- export interface SkippedMigrationResponse {
37
- id: string;
38
- description: string;
39
- reason: string;
54
+ shouldExecute(context: DataMigrationContext<TCheckpoint>): Promise<boolean>;
55
+ execute(context: DataMigrationContext<TCheckpoint>): Promise<void>;
40
56
  }
57
+ /**
58
+ * Migration execution time limiter (in milliseconds).
59
+ */
60
+ export type ExecutionTimeLimiter = () => number;
41
61
  export interface MigrationEventPayload {
62
+ command: "status" | "execute";
42
63
  version?: string;
43
64
  pattern?: string;
65
+ force?: boolean;
44
66
  }
45
- export declare type MigrationEventHandlerResponse = {
67
+ export type MigrationEventHandlerResponse = undefined | MigrationStatusResponse | MigrationInvocationErrorResponse;
68
+ export interface MigrationInvocationErrorResponse {
46
69
  error: {
47
70
  message: string;
48
71
  };
49
- data?: never;
50
- } | {
51
- data: {
52
- executed: ExecutedMigrationResponse[];
53
- skipped: SkippedMigrationResponse[];
54
- notApplicable: SkippedMigrationResponse[];
55
- };
56
- error?: never;
57
- };
72
+ data?: undefined;
73
+ }
74
+ export interface MigrationStatusRunItem extends MigrationRunItem {
75
+ description: string;
76
+ }
77
+ export interface MigrationStatus extends MigrationRun {
78
+ migrations: MigrationStatusRunItem[];
79
+ }
80
+ export interface MigrationStatusResponse {
81
+ data: MigrationStatus;
82
+ error?: undefined;
83
+ }
package/types.js CHANGED
@@ -3,10 +3,5 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Logger", {
7
- enumerable: true,
8
- get: function () {
9
- return _pino.Logger;
10
- }
11
- });
12
- var _pino = require("pino");
6
+
7
+ //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { Logger, LogEvent } from \"pino\";\n\nexport { Logger };\n\nexport interface MigrationItem {\n id: string;\n description: string;\n createdOn: string;\n duration: number;\n reason: string;\n}\n\nexport interface MigrationRepository {\n listMigrations(params?: { limit: number }): Promise<MigrationItem[]>;\n logMigration(migration: MigrationItem): Promise<void>;\n}\n\nexport interface DataMigrationContext {\n projectVersion: string;\n logger: Logger;\n}\n\nexport interface DataMigration {\n getId(): string;\n getDescription(): string;\n // This function should check of the migration needs to apply some changes to the system.\n // Returning `false` means \"everything is ok, mark this migration as executed\".\n shouldExecute(context: DataMigrationContext): Promise<boolean>;\n execute(context: DataMigrationContext): Promise<void>;\n}\n\nexport interface MigrationResult {\n success: boolean;\n logs: LogEvent[];\n duration: number;\n}\n\nexport interface ExecutedMigrationResponse {\n id: string;\n description: string;\n result: MigrationResult;\n}\n\nexport interface SkippedMigrationResponse {\n id: string;\n description: string;\n reason: string;\n}\n\nexport interface MigrationEventPayload {\n version?: string;\n pattern?: string;\n}\n\nexport type MigrationEventHandlerResponse =\n // We can either have a `data`, or `error`, but never both.\n | {\n error: {\n message: string;\n };\n data?: never;\n }\n | {\n data: {\n // Executed migrations\n executed: ExecutedMigrationResponse[];\n // Applicable, but the migration itself decided it should not be executed.\n skipped: SkippedMigrationResponse[];\n // Not applicable; either out of version range, or already applied.\n notApplicable: SkippedMigrationResponse[];\n };\n error?: never;\n };\n"],"mappings":";;;;;;;;;;;AAAA"}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { Logger } from \"@webiny/logger\";\n\nexport type { Logger };\n\nexport interface MigrationItem {\n id: string;\n description: string;\n reason: string;\n startedOn?: string;\n finishedOn?: string;\n}\n\nexport interface MigrationRun {\n id: string;\n startedOn: string;\n finishedOn: string;\n status: \"init\" | \"running\" | \"pending\" | \"done\" | \"error\";\n migrations: MigrationRunItem[];\n context?: Record<string, any>;\n error?: {\n message: string;\n name?: string;\n code?: string;\n data?: Record<string, any>;\n stack?: string;\n };\n}\n\nexport interface MigrationRunItem {\n id: string;\n status: \"done\" | \"running\" | \"skipped\" | \"pending\" | \"not-applicable\" | \"error\";\n startedOn?: string;\n finishedOn?: string;\n}\n\nexport interface MigrationRepository {\n getLastRun(): Promise<MigrationRun | null>;\n saveRun(run: MigrationRun): Promise<void>;\n listMigrations(params?: { limit: number }): Promise<MigrationItem[]>;\n logMigration(migration: MigrationItem): Promise<void>;\n createCheckpoint(id: string, data: unknown): Promise<void>;\n getCheckpoint(id: string): Promise<unknown>;\n deleteCheckpoint(id: string): Promise<void>;\n}\n\nexport interface DataMigrationContext<TCheckpoint = any> {\n projectVersion: string;\n logger: Logger;\n checkpoint?: TCheckpoint;\n forceExecute: boolean;\n runningOutOfTime: () => boolean;\n createCheckpoint: (data: TCheckpoint) => Promise<void>;\n createCheckpointAndExit: (data: TCheckpoint) => Promise<void>;\n}\n\nexport interface DataMigration<TCheckpoint = any> {\n getId(): string;\n getDescription(): string;\n // This function should check of the migration needs to apply some changes to the system.\n // Returning `false` means \"everything is ok, mark this migration as executed\".\n shouldExecute(context: DataMigrationContext<TCheckpoint>): Promise<boolean>;\n execute(context: DataMigrationContext<TCheckpoint>): Promise<void>;\n}\n\n/**\n * Migration execution time limiter (in milliseconds).\n */\nexport type ExecutionTimeLimiter = () => number;\n\nexport interface MigrationEventPayload {\n command: \"status\" | \"execute\";\n version?: string;\n pattern?: string;\n force?: boolean;\n}\n\nexport type MigrationEventHandlerResponse =\n // When migration is triggered (via `Event` invocation type), it simply gets invoked, and returns nothing.\n | undefined\n // Last migration run state.\n | MigrationStatusResponse\n // If an unhandled error is thrown, return the error object.\n | MigrationInvocationErrorResponse;\n\nexport interface MigrationInvocationErrorResponse {\n error: { message: string };\n data?: undefined;\n}\n\nexport interface MigrationStatusRunItem extends MigrationRunItem {\n description: string;\n}\n\nexport interface MigrationStatus extends MigrationRun {\n migrations: MigrationStatusRunItem[];\n}\n\nexport interface MigrationStatusResponse {\n data: MigrationStatus;\n error?: undefined;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- import { Table, Entity } from "dynamodb-toolbox";
2
- export declare const createMigrationsEntity: ({ table }: {
3
- table: Table;
4
- }) => Entity<{}>;
@@ -1 +0,0 @@
1
- {"version":3,"names":["createMigrationsEntity","table","Entity","name","attributes","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","TYPE","data"],"sources":["migrations.entity.ts"],"sourcesContent":["import { Table, Entity } from \"dynamodb-toolbox\";\n\nexport const createMigrationsEntity = ({ table }: { table: Table }) => {\n return new Entity({\n name: \"Migrations\",\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":";;;;;;AAAA;AAEO,MAAMA,sBAAsB,GAAG,CAAC;EAAEC;AAAwB,CAAC,KAAK;EACnE,OAAO,IAAIC,uBAAM,CAAC;IACdC,IAAI,EAAE,YAAY;IAClBF,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;AAAC"}