@storyous/mongodb 1.0.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/README.md +89 -0
- package/__tests__/appData.test.js +36 -0
- package/__tests__/appData.test.ts +39 -0
- package/__tests__/fixtures.test.js +40 -0
- package/__tests__/fixtures.test.ts +44 -0
- package/__tests__/getMongoClient.js +19 -0
- package/__tests__/getMongoClient.ts +24 -0
- package/__tests__/migrations/1642152064249-test.js +7 -0
- package/__tests__/migrations/1642152064249-test.ts +7 -0
- package/__tests__/mongoLocker.test.js +151 -0
- package/__tests__/mongoLocker.test.ts +191 -0
- package/__tests__/runMigration.test.js +22 -0
- package/__tests__/runMigration.test.ts +23 -0
- package/__tests__/withTransaction.test.js +40 -0
- package/__tests__/withTransaction.test.ts +67 -0
- package/lib/appData/index.js +40 -0
- package/lib/appData/index.ts +48 -0
- package/lib/concurrentTask.js +20 -0
- package/lib/concurrentTask.ts +30 -0
- package/lib/fixtures.js +28 -0
- package/lib/fixtures.ts +36 -0
- package/lib/getCollection.js +8 -0
- package/lib/getCollection.ts +4 -0
- package/lib/getMongoLocker.js +53 -0
- package/lib/getMongoLocker.ts +71 -0
- package/lib/index.js +27 -0
- package/lib/index.ts +25 -0
- package/lib/migrations/Migration.js +22 -0
- package/lib/migrations/Migration.ts +29 -0
- package/lib/migrations/MigrationsStore.js +65 -0
- package/lib/migrations/MigrationsStore.ts +73 -0
- package/lib/migrations/runMigrations.js +50 -0
- package/lib/migrations/runMigrations.ts +57 -0
- package/lib/migrations/template.js +7 -0
- package/lib/migrations/template.ts +6 -0
- package/lib/mongoClient.js +18 -0
- package/lib/mongoClient.ts +25 -0
- package/lib/mongoErrorCodes.js +11 -0
- package/lib/mongoErrorCodes.ts +10 -0
- package/lib/mongoLocker.js +17 -0
- package/lib/mongoLocker.ts +15 -0
- package/lib/withTransaction.js +21 -0
- package/lib/withTransaction.ts +24 -0
- package/package.json +40 -0
- package/tsconfig.json +14 -0
- package/types/migrate/index.d.ts +101 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file, no-use-before-define, no-dupe-class-members */
|
|
2
|
+
|
|
3
|
+
// TODO: Copied from 'migrate' package from master branch.
|
|
4
|
+
// Types was not published yet. If will be released new version you can remove this file.
|
|
5
|
+
|
|
6
|
+
declare module 'migrate' {
|
|
7
|
+
|
|
8
|
+
import type { EventEmitter } from 'events';
|
|
9
|
+
|
|
10
|
+
type MigrationOptions = {
|
|
11
|
+
set?: MigrationSet;
|
|
12
|
+
stateStore?: string | FileStore;
|
|
13
|
+
migrationsDirectory?: string;
|
|
14
|
+
filterFunction?: (migration: string) => boolean;
|
|
15
|
+
sortFunction?: (migration1: Migration, migration2: Migration) => boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type NextFunction = () => void;
|
|
19
|
+
type CallbackError = (err: any) => void;
|
|
20
|
+
type DoneCallback = (
|
|
21
|
+
err: any,
|
|
22
|
+
store: {
|
|
23
|
+
lastRun?: string;
|
|
24
|
+
migrations: Pick<Migration, 'title' | 'description' | 'timestamp'>[];
|
|
25
|
+
}
|
|
26
|
+
) => void
|
|
27
|
+
|
|
28
|
+
export default function migrate(
|
|
29
|
+
title: string,
|
|
30
|
+
up: (next: NextFunction) => void,
|
|
31
|
+
down: (next: NextFunction) => void
|
|
32
|
+
): void;
|
|
33
|
+
|
|
34
|
+
export function load(
|
|
35
|
+
opts: MigrationOptions,
|
|
36
|
+
cb: (err: any, set: MigrationSet) => void
|
|
37
|
+
): void;
|
|
38
|
+
|
|
39
|
+
declare class Migration {
|
|
40
|
+
constructor(
|
|
41
|
+
title: string,
|
|
42
|
+
up: (next: NextFunction) => void,
|
|
43
|
+
down: (next: NextFunction) => void,
|
|
44
|
+
description: string
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
title: string;
|
|
48
|
+
|
|
49
|
+
up: (next: NextFunction) => void;
|
|
50
|
+
|
|
51
|
+
down: (next: NextFunction) => void;
|
|
52
|
+
|
|
53
|
+
description: string;
|
|
54
|
+
|
|
55
|
+
timestamp: number | null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export class MigrationSet extends EventEmitter {
|
|
59
|
+
constructor(store: FileStore);
|
|
60
|
+
|
|
61
|
+
addMigration(
|
|
62
|
+
title: string,
|
|
63
|
+
up: (next: NextFunction) => void,
|
|
64
|
+
down: (next: NextFunction) => void
|
|
65
|
+
): void;
|
|
66
|
+
|
|
67
|
+
addMigration(migration: Migration): void;
|
|
68
|
+
|
|
69
|
+
save(cb: CallbackError): void;
|
|
70
|
+
|
|
71
|
+
down(migrationName: string, cb: CallbackError): void;
|
|
72
|
+
|
|
73
|
+
down(cb: CallbackError): void;
|
|
74
|
+
|
|
75
|
+
up(migrationName: string, cb: CallbackError): void;
|
|
76
|
+
|
|
77
|
+
up(cb: CallbackError): void;
|
|
78
|
+
|
|
79
|
+
migrate(
|
|
80
|
+
direction: 'up' | 'down',
|
|
81
|
+
migrationName: string,
|
|
82
|
+
cb: CallbackError
|
|
83
|
+
): void;
|
|
84
|
+
|
|
85
|
+
migrate(direction: 'up' | 'down', cb: CallbackError): void;
|
|
86
|
+
|
|
87
|
+
migrations: Migration[];
|
|
88
|
+
|
|
89
|
+
map: { [title: string]: Migration };
|
|
90
|
+
|
|
91
|
+
lastRun: string | null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare class FileStore {
|
|
95
|
+
constructor(path: string);
|
|
96
|
+
|
|
97
|
+
save(set: MigrationSet, cb: CallbackError): void;
|
|
98
|
+
|
|
99
|
+
load(cb: DoneCallback): void;
|
|
100
|
+
}
|
|
101
|
+
}
|