@oliasoft-open-source/node-json-migrator 4.6.0-beta-2 → 5.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/dist/index.d.mts +113 -107
- package/dist/index.mjs +4537 -4400
- package/package.json +15 -21
- package/dist/index.cjs +0 -4824
- package/dist/index.d.cts +0 -165
package/dist/index.d.cts
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { ITask, IDatabase, IHelpers } from 'pg-promise';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Generate a new entity migration
|
|
5
|
-
*/
|
|
6
|
-
declare const createMigration: (directory: string, description: string, entity: string, enableMetaData?: boolean) => Promise<void>;
|
|
7
|
-
|
|
8
|
-
type TPlanEntry = {
|
|
9
|
-
fileName: string;
|
|
10
|
-
fileHash: string;
|
|
11
|
-
sequence: string;
|
|
12
|
-
};
|
|
13
|
-
type TPlan = TPlanEntry[];
|
|
14
|
-
type TPayload = Record<string, unknown>;
|
|
15
|
-
type TMetaData = Record<string, unknown>;
|
|
16
|
-
type TMigration = {
|
|
17
|
-
fileName?: string;
|
|
18
|
-
fileHash?: string;
|
|
19
|
-
sequence?: string;
|
|
20
|
-
isValidFileName?: boolean;
|
|
21
|
-
fileHashFromPlan?: string;
|
|
22
|
-
fileHashFromHistory?: string;
|
|
23
|
-
skippedFileHashes?: string[];
|
|
24
|
-
sequenceFromHistory?: string;
|
|
25
|
-
script?: string;
|
|
26
|
-
filePath?: string;
|
|
27
|
-
migrator?: (payload: TPayload, metaData?: TMetaData) => TPayload;
|
|
28
|
-
};
|
|
29
|
-
type TRecordDetails = {
|
|
30
|
-
id: number | string;
|
|
31
|
-
name: string;
|
|
32
|
-
created: string | Date;
|
|
33
|
-
version: string;
|
|
34
|
-
currentPlan?: TPlan;
|
|
35
|
-
};
|
|
36
|
-
type TRecordDetailsList = TRecordDetails[];
|
|
37
|
-
type TEntityColumnNames = {
|
|
38
|
-
id: string;
|
|
39
|
-
name: string;
|
|
40
|
-
payload: string;
|
|
41
|
-
etag?: string;
|
|
42
|
-
version: string;
|
|
43
|
-
created: string;
|
|
44
|
-
};
|
|
45
|
-
type TRecord<T extends TEntityColumnNames = TEntityColumnNames, TData = TPayload> = {
|
|
46
|
-
[K in T['id']]: number | string;
|
|
47
|
-
} & {
|
|
48
|
-
[K in T['name']]: string;
|
|
49
|
-
} & {
|
|
50
|
-
[K in T['payload']]: TData;
|
|
51
|
-
} & (T['etag'] extends string ? {
|
|
52
|
-
[K in T['etag']]?: string;
|
|
53
|
-
} : Record<never, never>) & {
|
|
54
|
-
[K in T['version']]: string;
|
|
55
|
-
} & {
|
|
56
|
-
[K in T['created']]: string | Date;
|
|
57
|
-
};
|
|
58
|
-
type TConfig = {
|
|
59
|
-
directory: string;
|
|
60
|
-
database?: IDatabase<unknown>;
|
|
61
|
-
pgpHelpers?: IHelpers;
|
|
62
|
-
entity?: string;
|
|
63
|
-
entityTableName?: string;
|
|
64
|
-
entityColumnNames?: TEntityColumnNames;
|
|
65
|
-
version?: string;
|
|
66
|
-
printPendingFileNames?: boolean;
|
|
67
|
-
force?: boolean;
|
|
68
|
-
dry?: boolean;
|
|
69
|
-
importModule?: boolean;
|
|
70
|
-
autoInitializeTable?: boolean;
|
|
71
|
-
};
|
|
72
|
-
type TBeforeMigrateRecordPayload = {
|
|
73
|
-
currentRecord: TRecord;
|
|
74
|
-
transaction?: ITask<unknown>;
|
|
75
|
-
dry: boolean;
|
|
76
|
-
};
|
|
77
|
-
type TBeforeMigrateRecord = (params: TBeforeMigrateRecordPayload) => Promise<void>;
|
|
78
|
-
type TAfterMigrateRecordPayload = {
|
|
79
|
-
currentRecord: TRecord;
|
|
80
|
-
nextRecord: TRecord;
|
|
81
|
-
transaction?: ITask<unknown>;
|
|
82
|
-
dry: boolean;
|
|
83
|
-
};
|
|
84
|
-
type TAfterMigrateRecord = (params: TAfterMigrateRecordPayload) => Promise<void>;
|
|
85
|
-
type TMigrationErrorPayload = {
|
|
86
|
-
id: string;
|
|
87
|
-
name: string;
|
|
88
|
-
created: string | Date;
|
|
89
|
-
error: unknown;
|
|
90
|
-
stackTrace?: string;
|
|
91
|
-
};
|
|
92
|
-
type TOnMigrationErrorsPayload = {
|
|
93
|
-
migrationErrors: TMigrationErrorPayload[];
|
|
94
|
-
dry: boolean;
|
|
95
|
-
};
|
|
96
|
-
type TOnMigrationErrors = (params: TOnMigrationErrorsPayload) => Promise<void>;
|
|
97
|
-
|
|
98
|
-
declare const getPlannedMigrations: ({ config }: {
|
|
99
|
-
config: TConfig;
|
|
100
|
-
}) => Promise<{
|
|
101
|
-
validatedPlan: {
|
|
102
|
-
fileHash: string;
|
|
103
|
-
fileName: string;
|
|
104
|
-
sequence: string;
|
|
105
|
-
}[];
|
|
106
|
-
plannedMigrations: TMigration[] & {
|
|
107
|
-
fileHash: string;
|
|
108
|
-
migrator: (...args: unknown[]) => unknown;
|
|
109
|
-
}[];
|
|
110
|
-
nextVersion: string;
|
|
111
|
-
}>;
|
|
112
|
-
|
|
113
|
-
declare const getPlannedVersion: ({ config }: {
|
|
114
|
-
config: any;
|
|
115
|
-
}) => Promise<string>;
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Migrates a payload
|
|
119
|
-
*
|
|
120
|
-
* There are two ways to use this function:
|
|
121
|
-
* i) function looks up the pending migrations for you (default)
|
|
122
|
-
* ii) pass in pre-fetched pending migrators via config.pending
|
|
123
|
-
*/
|
|
124
|
-
declare const migrate: ({ payload, config, metaData, }: {
|
|
125
|
-
payload: TPayload;
|
|
126
|
-
config: TConfig;
|
|
127
|
-
metaData?: TMetaData;
|
|
128
|
-
}) => Promise<{
|
|
129
|
-
nextPayload: TPayload;
|
|
130
|
-
nextVersion: string;
|
|
131
|
-
}>;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Migrate all records (only use via command line interface)
|
|
135
|
-
*/
|
|
136
|
-
declare const migrateAll: ({ config, beforeMigrateRecord, afterMigrateRecord, onMigrationErrors, }: {
|
|
137
|
-
config: TConfig;
|
|
138
|
-
beforeMigrateRecord: TBeforeMigrateRecord;
|
|
139
|
-
afterMigrateRecord: TAfterMigrateRecord;
|
|
140
|
-
onMigrationErrors: TOnMigrationErrors;
|
|
141
|
-
}) => Promise<void>;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Executes the pending migrators on a payload, returns modified payload
|
|
145
|
-
*
|
|
146
|
-
* Loosely based on:
|
|
147
|
-
* - Eric Elliott's pipe implementation https://medium.com/javascript-scene/reduce-composing-software-fe22f0c39a1d
|
|
148
|
-
* - lodash flow https://lodash.com/docs/4.17.15#flow
|
|
149
|
-
*
|
|
150
|
-
* Implementation includes exception handling to extend errors with the filename
|
|
151
|
-
* until native dynamic imports fix their stack trace handling (see OW-8879)
|
|
152
|
-
*/
|
|
153
|
-
declare const pipe: (migrations: TMigration[], payload: TPayload, metaData?: TMetaData) => TPayload;
|
|
154
|
-
|
|
155
|
-
declare const getVersions: (db: IDatabase<unknown>, entity: string) => Promise<any[]>;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Prints the version history of plan.json (for debugging)
|
|
159
|
-
*/
|
|
160
|
-
declare const printVersionHistory: ({ config }: {
|
|
161
|
-
config: TConfig;
|
|
162
|
-
}) => Promise<void>;
|
|
163
|
-
|
|
164
|
-
export { createMigration, getPlannedMigrations, getPlannedVersion, getVersions, migrate, migrateAll, pipe, printVersionHistory };
|
|
165
|
-
export type { TAfterMigrateRecord, TAfterMigrateRecordPayload, TBeforeMigrateRecord, TBeforeMigrateRecordPayload, TConfig, TEntityColumnNames, TMetaData, TMigration, TMigrationErrorPayload, TOnMigrationErrors, TOnMigrationErrorsPayload, TPayload, TPlan, TPlanEntry, TRecord, TRecordDetails, TRecordDetailsList };
|