@webiny/data-migration 6.0.0-beta.0 → 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 (67) hide show
  1. package/MigrationRunner.d.ts +3 -3
  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 +4 -60
  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 +5 -5
  43. package/handlers/createDdbEsProjectMigration.js +22 -29
  44. package/handlers/createDdbEsProjectMigration.js.map +1 -1
  45. package/handlers/createDdbProjectMigration.d.ts +4 -4
  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 -7
  54. package/index.js +6 -71
  55. package/index.js.map +1 -1
  56. package/package.json +20 -36
  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.d.ts +3 -3
  63. package/types.js +1 -5
  64. package/types.js.map +1 -1
  65. package/repository/createStandardEntity.d.ts +0 -51
  66. package/repository/createStandardEntity.js +0 -39
  67. package/repository/createStandardEntity.js.map +0 -1
@@ -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
@@ -1 +1 @@
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 { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { queryAll, queryOne } from \"@webiny/db-dynamodb/utils/query\";\nimport { 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":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAH,OAAA;AACA,IAAAI,WA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,GAAG,MAAM,IAAAC,eAAG,EAAsB;MAC1C5B,MAAM,EAAE,IAAI,CAACJ,UAAU;MACvB6B,IAAI,EAAE;QACFf,EAAE,EAAG,wBAAuBC,EAAG,EAAC;QAChCC,EAAE,EAAE;MACR;IACJ,CAAC,CAAC;IAEF,IAAI,CAACe,MAAM,EAAE;MACT,OAAO,IAAI;IACf;IACA,OAAOA,MAAM,CAACrB,IAAI;EACtB;AACJ;AAACuB,OAAA,CAAAxC,uBAAA,GAAAA,uBAAA;AAED,IAAAyC,mBAAc,EAACzC,uBAAuB,EAAE,CAAC,IAAA0C,WAAM,EAACC,iCAAwB,CAAC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["inject","makeInjectable","PrimaryDynamoTableSymbol","createGlobalEntity","MigrationRepositoryImpl","constructor","table","run","name","migration","checkpoint","getLastRun","result","queryOne","partitionKey","options","index","gt","reverse","data","saveRun","put","PK","id","SK","TYPE","GSI1_PK","GSI1_SK","listMigrations","params","limit","queryAll","map","item","logMigration","createCheckpoint","deleteCheckpoint","delete","getCheckpoint","record","get"],"sources":["migrations.repository.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox.js\";\nimport type { MigrationItem, MigrationRepository, MigrationRun } from \"~/types.js\";\nimport { inject, makeInjectable } from \"@webiny/ioc\";\nimport { PrimaryDynamoTableSymbol } from \"~/symbols.js\";\nimport { createGlobalEntity } from \"@webiny/db-dynamodb\";\n\ninterface MigrationCheckpoint {\n data: unknown;\n}\n\nexport class MigrationRepositoryImpl implements MigrationRepository {\n private readonly run;\n private readonly migration;\n private readonly checkpoint;\n\n constructor(table: Table<string, string, string>) {\n this.run = createGlobalEntity<MigrationRun>({\n table,\n name: \"MigrationRun\"\n });\n this.migration = createGlobalEntity<MigrationItem>({\n table,\n name: \"Migration\"\n });\n this.checkpoint = createGlobalEntity<MigrationCheckpoint>({\n table,\n name: \"MigrationCheckpoint\"\n });\n }\n\n async getLastRun(): Promise<MigrationRun | null> {\n const result = await this.run.queryOne({\n partitionKey: \"MIGRATION_RUNS\",\n options: {\n index: \"GSI1\",\n gt: \" \",\n reverse: true\n }\n });\n\n return result?.data || null;\n }\n\n async saveRun(run: MigrationRun): Promise<void> {\n await this.run.put({\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 async listMigrations(params?: { limit: number }): Promise<MigrationItem[]> {\n const { limit } = params || {};\n const result = await this.migration.queryAll({\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.migration.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 async createCheckpoint(id: string, data: unknown): Promise<void> {\n await this.checkpoint.put({\n PK: `MIGRATION_CHECKPOINT#${id}`,\n SK: \"A\",\n TYPE: \"migration.checkpoint\",\n GSI1_PK: \"MIGRATION_CHECKPOINTS\",\n GSI1_SK: id,\n data: data as MigrationCheckpoint\n });\n }\n\n async deleteCheckpoint(id: string): Promise<void> {\n await this.checkpoint.delete({\n PK: `MIGRATION_CHECKPOINT#${id}`,\n SK: \"A\"\n });\n }\n\n async getCheckpoint(id: string): Promise<unknown | null> {\n const record = await this.checkpoint.get({\n PK: `MIGRATION_CHECKPOINT#${id}`,\n SK: \"A\"\n });\n\n if (!record) {\n return null;\n }\n return record.data;\n }\n}\n\nmakeInjectable(MigrationRepositoryImpl, [inject(PrimaryDynamoTableSymbol)]);\n"],"mappings":"AAEA,SAASA,MAAM,EAAEC,cAAc,QAAQ,aAAa;AACpD,SAASC,wBAAwB;AACjC,SAASC,kBAAkB,QAAQ,qBAAqB;AAM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,MAAM,CAACE,wBAAwB,CAAC,CAAC,CAAC","ignoreList":[]}
package/symbols.js CHANGED
@@ -1,15 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
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");
1
+ export const LoggerSymbol = Symbol.for("PinoLogger");
2
+ export const MigrationSymbol = Symbol.for("Migration");
3
+ export const MigrationRepositorySymbol = Symbol.for("MigrationRepository");
4
+ export const ElasticsearchClientSymbol = Symbol.for("ElasticsearchClient");
5
+ export const PrimaryDynamoTableSymbol = Symbol.for("PrimaryDynamoTable");
6
+ export const ElasticsearchDynamoTableSymbol = Symbol.for("ElasticsearchDynamoTable");
7
+ export const ExecutionTimeLimiterSymbol = Symbol.for("ExecutionTimeLimiter");
14
8
 
15
9
  //# sourceMappingURL=symbols.js.map
package/symbols.js.map CHANGED
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"names":["LoggerSymbol","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":"AAAA,OAAO,MAAMA,YAAY,GAAGC,MAAM,CAACC,GAAG,CAAC,YAAY,CAAC;AACpD,OAAO,MAAMC,eAAe,GAAGF,MAAM,CAACC,GAAG,CAAC,WAAW,CAAC;AACtD,OAAO,MAAME,yBAAyB,GAAGH,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAAC;AAC1E,OAAO,MAAMG,yBAAyB,GAAGJ,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAAC;AAC1E,OAAO,MAAMI,wBAAwB,GAAGL,MAAM,CAACC,GAAG,CAAC,oBAAoB,CAAC;AACxE,OAAO,MAAMK,8BAA8B,GAAGN,MAAM,CAACC,GAAG,CAAC,0BAA0B,CAAC;AACpF,OAAO,MAAMM,0BAA0B,GAAGP,MAAM,CAACC,GAAG,CAAC,sBAAsB,CAAC","ignoreList":[]}
package/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Logger } from "@webiny/logger";
1
+ import type { Logger } from "@webiny/logger";
2
2
  export type { Logger };
3
3
  export interface MigrationItem {
4
4
  id: string;
@@ -57,14 +57,14 @@ export interface DataMigration<TCheckpoint = any> {
57
57
  /**
58
58
  * Migration execution time limiter (in milliseconds).
59
59
  */
60
- export declare type ExecutionTimeLimiter = () => number;
60
+ export type ExecutionTimeLimiter = () => number;
61
61
  export interface MigrationEventPayload {
62
62
  command: "status" | "execute";
63
63
  version?: string;
64
64
  pattern?: string;
65
65
  force?: boolean;
66
66
  }
67
- export declare type MigrationEventHandlerResponse = undefined | MigrationStatusResponse | MigrationInvocationErrorResponse;
67
+ export type MigrationEventHandlerResponse = undefined | MigrationStatusResponse | MigrationInvocationErrorResponse;
68
68
  export interface MigrationInvocationErrorResponse {
69
69
  error: {
70
70
  message: string;
package/types.js CHANGED
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { 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
+ {"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,51 +0,0 @@
1
- import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
2
- export declare const createStandardEntity: ({ table, name }: {
3
- table: Table<string, string, string>;
4
- name: string;
5
- }) => 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, {
6
- PK: {
7
- partitionKey: true;
8
- };
9
- SK: {
10
- sortKey: true;
11
- };
12
- GSI1_PK: {
13
- type: "string";
14
- };
15
- GSI1_SK: {
16
- type: "string";
17
- };
18
- TYPE: {
19
- type: "string";
20
- };
21
- data: {
22
- type: "map";
23
- };
24
- }, {
25
- PK: {
26
- partitionKey: true;
27
- };
28
- SK: {
29
- sortKey: true;
30
- };
31
- GSI1_PK: {
32
- type: "string";
33
- };
34
- GSI1_SK: {
35
- type: "string";
36
- };
37
- TYPE: {
38
- type: "string";
39
- };
40
- data: {
41
- type: "map";
42
- };
43
- }, import("dynamodb-toolbox/dist/cjs/classes/Entity").ParsedAttributes<import("ts-toolbelt/out/Any/Key").Key>, any, {
44
- [x: string]: any;
45
- [x: number]: any;
46
- [x: symbol]: any;
47
- }, {
48
- [x: string]: any;
49
- [x: number]: any;
50
- [x: symbol]: any;
51
- }>;
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createStandardEntity = void 0;
7
- var _toolbox = require("@webiny/db-dynamodb/toolbox");
8
- const createStandardEntity = ({
9
- table,
10
- name
11
- }) => {
12
- return new _toolbox.Entity({
13
- name,
14
- table,
15
- attributes: {
16
- PK: {
17
- partitionKey: true
18
- },
19
- SK: {
20
- sortKey: true
21
- },
22
- GSI1_PK: {
23
- type: "string"
24
- },
25
- GSI1_SK: {
26
- type: "string"
27
- },
28
- TYPE: {
29
- type: "string"
30
- },
31
- data: {
32
- type: "map"
33
- }
34
- }
35
- });
36
- };
37
- exports.createStandardEntity = createStandardEntity;
38
-
39
- //# sourceMappingURL=createStandardEntity.js.map
@@ -1 +0,0 @@
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 { Entity, Table } 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":";;;;;;AAAA,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":[]}