@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.
- package/MigrationRunner.d.ts +3 -3
- package/MigrationRunner.js +13 -20
- package/MigrationRunner.js.map +1 -1
- package/README.md +9 -4
- package/cli/CliMigrationRunReporter.d.ts +8 -5
- package/cli/CliMigrationRunReporter.js +15 -20
- package/cli/CliMigrationRunReporter.js.map +1 -1
- package/cli/InteractiveCliStatusReporter.d.ts +3 -3
- package/cli/InteractiveCliStatusReporter.js +4 -12
- package/cli/InteractiveCliStatusReporter.js.map +1 -1
- package/cli/LogReporter.d.ts +1 -1
- package/cli/LogReporter.js +3 -10
- package/cli/LogReporter.js.map +1 -1
- package/cli/LogStream.js +3 -10
- package/cli/LogStream.js.map +1 -1
- package/cli/MigrationRunReporter.d.ts +1 -1
- package/cli/MigrationRunReporter.js +1 -5
- package/cli/MigrationRunReporter.js.map +1 -1
- package/cli/MigrationRunner.d.ts +3 -3
- package/cli/MigrationRunner.js +9 -17
- package/cli/MigrationRunner.js.map +1 -1
- package/cli/MigrationStatusReporter.d.ts +1 -1
- package/cli/MigrationStatusReporter.js +1 -5
- package/cli/MigrationStatusReporter.js.map +1 -1
- package/cli/NonInteractiveCliStatusReporter.d.ts +3 -3
- package/cli/NonInteractiveCliStatusReporter.js +1 -8
- package/cli/NonInteractiveCliStatusReporter.js.map +1 -1
- package/cli/VoidStatusReporter.d.ts +1 -1
- package/cli/VoidStatusReporter.js +1 -8
- package/cli/VoidStatusReporter.js.map +1 -1
- package/cli/getDuration.js +1 -8
- package/cli/getDuration.js.map +1 -1
- package/cli/index.d.ts +10 -10
- package/cli/index.js +10 -115
- package/cli/index.js.map +1 -1
- package/createPinoLogger.d.ts +4 -60
- package/createPinoLogger.js +9 -18
- package/createPinoLogger.js.map +1 -1
- package/createTable.d.ts +2 -2
- package/createTable.js +3 -10
- package/createTable.js.map +1 -1
- package/handlers/createDdbEsProjectMigration.d.ts +5 -5
- package/handlers/createDdbEsProjectMigration.js +22 -29
- package/handlers/createDdbEsProjectMigration.js.map +1 -1
- package/handlers/createDdbProjectMigration.d.ts +4 -4
- package/handlers/createDdbProjectMigration.js +20 -27
- package/handlers/createDdbProjectMigration.js.map +1 -1
- package/handlers/createPatternMatcher.d.ts +1 -1
- package/handlers/createPatternMatcher.js +3 -11
- package/handlers/createPatternMatcher.js.map +1 -1
- package/handlers/devVersionErrorResponse.js +1 -8
- package/handlers/devVersionErrorResponse.js.map +1 -1
- package/index.d.ts +6 -7
- package/index.js +6 -71
- package/index.js.map +1 -1
- package/package.json +20 -36
- package/repository/migrations.repository.d.ts +2 -2
- package/repository/migrations.repository.js +38 -64
- package/repository/migrations.repository.js.map +1 -1
- package/symbols.js +7 -13
- package/symbols.js.map +1 -1
- package/types.d.ts +3 -3
- package/types.js +1 -5
- package/types.js.map +1 -1
- package/repository/createStandardEntity.d.ts +0 -51
- package/repository/createStandardEntity.js +0 -39
- package/repository/createStandardEntity.js.map +0 -1
|
@@ -1,32 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 = (
|
|
6
|
+
this.run = createGlobalEntity({
|
|
15
7
|
table,
|
|
16
8
|
name: "MigrationRun"
|
|
17
9
|
});
|
|
18
|
-
this.migration = (
|
|
10
|
+
this.migration = createGlobalEntity({
|
|
19
11
|
table,
|
|
20
12
|
name: "Migration"
|
|
21
13
|
});
|
|
22
|
-
this.checkpoint = (
|
|
14
|
+
this.checkpoint = createGlobalEntity({
|
|
23
15
|
table,
|
|
24
16
|
name: "MigrationCheckpoint"
|
|
25
17
|
});
|
|
26
18
|
}
|
|
27
19
|
async getLastRun() {
|
|
28
|
-
const result = await
|
|
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
|
|
28
|
+
return result?.data || null;
|
|
38
29
|
}
|
|
39
30
|
async saveRun(run) {
|
|
40
|
-
await
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
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
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
97
|
-
|
|
98
|
-
|
|
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
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
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":["
|
|
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(PrimaryDynamo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AAI,CAACe,MAAM,EAAE;MACT,OAAO,IAAI;IACf;IACA,OAAOA,MAAM,CAACpB,IAAI;EACtB;AACJ;AAEAlB,cAAc,CAACG,uBAAuB,EAAE,CAACJ,MAAM,CAACE,wBAAwB,CAAC,CAAC,CAAC","ignoreList":[]}
|
package/symbols.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
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","
|
|
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
|
|
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
|
|
67
|
+
export type MigrationEventHandlerResponse = undefined | MigrationStatusResponse | MigrationInvocationErrorResponse;
|
|
68
68
|
export interface MigrationInvocationErrorResponse {
|
|
69
69
|
error: {
|
|
70
70
|
message: string;
|
package/types.js
CHANGED
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":[]}
|