@oliasoft-open-source/node-json-migrator 2.3.10 → 3.0.0-beta-1
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/dist/index.cjs +16553 -0
- package/dist/index.d.cts +81 -0
- package/dist/index.d.mts +81 -0
- package/dist/index.mjs +16526 -0
- package/package.json +51 -57
- package/dist/create/create.js +0 -76
- package/dist/database/database.js +0 -102
- package/dist/executed/executed.js +0 -68
- package/dist/git/git.js +0 -130
- package/dist/glob/glob.js +0 -58
- package/dist/hash/hash.js +0 -16
- package/dist/history/history.js +0 -90
- package/dist/index.js +0 -54
- package/dist/migrate/migrate.js +0 -59
- package/dist/pending/pending.js +0 -73
- package/dist/pipe/pipe.js +0 -38
- package/dist/plan/cached-planned-version.js +0 -25
- package/dist/plan/plan.js +0 -274
- package/dist/plan/plan.schema.json +0 -20
- package/dist/plan/planned-version.js +0 -26
- package/dist/plan/validator.js +0 -216
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { IDatabase, IHelpers } from 'pg-promise';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generate a new dataset migration
|
|
5
|
+
*/
|
|
6
|
+
declare const createMigration: (directory: string, description: string) => Promise<void>;
|
|
7
|
+
|
|
8
|
+
type TMigration = {
|
|
9
|
+
fileName?: string;
|
|
10
|
+
fileHash?: string;
|
|
11
|
+
sequence?: string;
|
|
12
|
+
isValidFileName?: boolean;
|
|
13
|
+
fileHashFromPlan?: string;
|
|
14
|
+
fileHashFromHistory?: string;
|
|
15
|
+
skippedFileHashes?: string[];
|
|
16
|
+
sequenceFromHistory?: string;
|
|
17
|
+
script?: string;
|
|
18
|
+
migrator?: (payload: unknown) => unknown;
|
|
19
|
+
};
|
|
20
|
+
type TConfig = {
|
|
21
|
+
directory: string;
|
|
22
|
+
database?: IDatabase<unknown>;
|
|
23
|
+
pgpHelpers?: IHelpers;
|
|
24
|
+
entity?: string;
|
|
25
|
+
version?: string;
|
|
26
|
+
printPendingFileNames?: boolean;
|
|
27
|
+
force?: boolean;
|
|
28
|
+
dry?: boolean;
|
|
29
|
+
importModule?: boolean;
|
|
30
|
+
autoInitializeTable?: boolean;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
declare const getPlannedMigrations: ({ config }: {
|
|
34
|
+
config: TConfig;
|
|
35
|
+
}) => Promise<{
|
|
36
|
+
plannedMigrations: TMigration[] & any[];
|
|
37
|
+
nextVersion: string;
|
|
38
|
+
}>;
|
|
39
|
+
|
|
40
|
+
declare const getPlannedVersion: ({ config }: {
|
|
41
|
+
config: any;
|
|
42
|
+
}) => Promise<any>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Migrates a payload
|
|
46
|
+
*
|
|
47
|
+
* There are two ways to use this function:
|
|
48
|
+
* i) function looks up the pending migrations for you (default)
|
|
49
|
+
* ii) pass in pre-fetched pending migrators via config.pending
|
|
50
|
+
*/
|
|
51
|
+
declare const migrate: ({ payload, config, }: {
|
|
52
|
+
payload: unknown;
|
|
53
|
+
config: TConfig;
|
|
54
|
+
}) => Promise<{
|
|
55
|
+
nextPayload: unknown;
|
|
56
|
+
nextVersion: string;
|
|
57
|
+
}>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Executes the pending migrators on a payload, returns modified payload
|
|
61
|
+
*
|
|
62
|
+
* Loosely based on:
|
|
63
|
+
* - Eric Elliott's pipe implementation https://medium.com/javascript-scene/reduce-composing-software-fe22f0c39a1d
|
|
64
|
+
* - lodash flow https://lodash.com/docs/4.17.15#flow
|
|
65
|
+
*
|
|
66
|
+
* Implementation includes exception handling to extend errors with the filename
|
|
67
|
+
* until module-with-string fixes its stack trace handling (see OW-8879 and
|
|
68
|
+
* https://github.com/exuanbo/module-from-string/issues/18)
|
|
69
|
+
*/
|
|
70
|
+
declare const pipe: (migrations: TMigration[], payload: unknown) => unknown;
|
|
71
|
+
|
|
72
|
+
declare const getVersions: (db: IDatabase<unknown>, entity: string) => Promise<any[]>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Prints the version history of plan.json (for debugging)
|
|
76
|
+
*/
|
|
77
|
+
declare const printVersionHistory: ({ config }: {
|
|
78
|
+
config: TConfig;
|
|
79
|
+
}) => Promise<void>;
|
|
80
|
+
|
|
81
|
+
export { createMigration, getPlannedMigrations, getPlannedVersion, getVersions, migrate, pipe, printVersionHistory };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { IDatabase, IHelpers } from 'pg-promise';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generate a new dataset migration
|
|
5
|
+
*/
|
|
6
|
+
declare const createMigration: (directory: string, description: string) => Promise<void>;
|
|
7
|
+
|
|
8
|
+
type TMigration = {
|
|
9
|
+
fileName?: string;
|
|
10
|
+
fileHash?: string;
|
|
11
|
+
sequence?: string;
|
|
12
|
+
isValidFileName?: boolean;
|
|
13
|
+
fileHashFromPlan?: string;
|
|
14
|
+
fileHashFromHistory?: string;
|
|
15
|
+
skippedFileHashes?: string[];
|
|
16
|
+
sequenceFromHistory?: string;
|
|
17
|
+
script?: string;
|
|
18
|
+
migrator?: (payload: unknown) => unknown;
|
|
19
|
+
};
|
|
20
|
+
type TConfig = {
|
|
21
|
+
directory: string;
|
|
22
|
+
database?: IDatabase<unknown>;
|
|
23
|
+
pgpHelpers?: IHelpers;
|
|
24
|
+
entity?: string;
|
|
25
|
+
version?: string;
|
|
26
|
+
printPendingFileNames?: boolean;
|
|
27
|
+
force?: boolean;
|
|
28
|
+
dry?: boolean;
|
|
29
|
+
importModule?: boolean;
|
|
30
|
+
autoInitializeTable?: boolean;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
declare const getPlannedMigrations: ({ config }: {
|
|
34
|
+
config: TConfig;
|
|
35
|
+
}) => Promise<{
|
|
36
|
+
plannedMigrations: TMigration[] & any[];
|
|
37
|
+
nextVersion: string;
|
|
38
|
+
}>;
|
|
39
|
+
|
|
40
|
+
declare const getPlannedVersion: ({ config }: {
|
|
41
|
+
config: any;
|
|
42
|
+
}) => Promise<any>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Migrates a payload
|
|
46
|
+
*
|
|
47
|
+
* There are two ways to use this function:
|
|
48
|
+
* i) function looks up the pending migrations for you (default)
|
|
49
|
+
* ii) pass in pre-fetched pending migrators via config.pending
|
|
50
|
+
*/
|
|
51
|
+
declare const migrate: ({ payload, config, }: {
|
|
52
|
+
payload: unknown;
|
|
53
|
+
config: TConfig;
|
|
54
|
+
}) => Promise<{
|
|
55
|
+
nextPayload: unknown;
|
|
56
|
+
nextVersion: string;
|
|
57
|
+
}>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Executes the pending migrators on a payload, returns modified payload
|
|
61
|
+
*
|
|
62
|
+
* Loosely based on:
|
|
63
|
+
* - Eric Elliott's pipe implementation https://medium.com/javascript-scene/reduce-composing-software-fe22f0c39a1d
|
|
64
|
+
* - lodash flow https://lodash.com/docs/4.17.15#flow
|
|
65
|
+
*
|
|
66
|
+
* Implementation includes exception handling to extend errors with the filename
|
|
67
|
+
* until module-with-string fixes its stack trace handling (see OW-8879 and
|
|
68
|
+
* https://github.com/exuanbo/module-from-string/issues/18)
|
|
69
|
+
*/
|
|
70
|
+
declare const pipe: (migrations: TMigration[], payload: unknown) => unknown;
|
|
71
|
+
|
|
72
|
+
declare const getVersions: (db: IDatabase<unknown>, entity: string) => Promise<any[]>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Prints the version history of plan.json (for debugging)
|
|
76
|
+
*/
|
|
77
|
+
declare const printVersionHistory: ({ config }: {
|
|
78
|
+
config: TConfig;
|
|
79
|
+
}) => Promise<void>;
|
|
80
|
+
|
|
81
|
+
export { createMigration, getPlannedMigrations, getPlannedVersion, getVersions, migrate, pipe, printVersionHistory };
|