@oliasoft-open-source/node-json-migrator 4.1.0 → 4.2.0-beta-2

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.cts CHANGED
@@ -5,6 +5,8 @@ import { IDatabase, IHelpers, ITask } from 'pg-promise';
5
5
  */
6
6
  declare const createMigration: (directory: string, description: string, entity: string) => Promise<void>;
7
7
 
8
+ type TPayload = Record<string, unknown>;
9
+ type TMetaData = Record<string, unknown>;
8
10
  type TMigration = {
9
11
  fileName?: string;
10
12
  fileHash?: string;
@@ -15,7 +17,7 @@ type TMigration = {
15
17
  skippedFileHashes?: string[];
16
18
  sequenceFromHistory?: string;
17
19
  script?: string;
18
- migrator?: (payload: unknown) => unknown;
20
+ migrator?: (payload: TPayload, metaData?: TMetaData) => TPayload;
19
21
  };
20
22
  type TEntityColumnNames = {
21
23
  id: string;
@@ -25,7 +27,7 @@ type TEntityColumnNames = {
25
27
  version: string;
26
28
  created: string;
27
29
  };
28
- type TRecord<T extends TEntityColumnNames = TEntityColumnNames, TData = unknown> = {
30
+ type TRecord<T extends TEntityColumnNames = TEntityColumnNames, TData = TPayload> = {
29
31
  [K in T['id']]: number | string;
30
32
  } & {
31
33
  [K in T['name']]: string;
@@ -96,11 +98,12 @@ declare const getPlannedVersion: ({ config }: {
96
98
  * i) function looks up the pending migrations for you (default)
97
99
  * ii) pass in pre-fetched pending migrators via config.pending
98
100
  */
99
- declare const migrate: ({ payload, config, }: {
100
- payload: unknown;
101
+ declare const migrate: ({ payload, config, metaData, }: {
102
+ payload: TPayload;
101
103
  config: TConfig;
104
+ metaData?: TMetaData;
102
105
  }) => Promise<{
103
- nextPayload: unknown;
106
+ nextPayload: TPayload;
104
107
  nextVersion: string;
105
108
  }>;
106
109
 
@@ -125,7 +128,7 @@ declare const migrateAll: ({ config, beforeMigrateRecord, afterMigrateRecord, on
125
128
  * until module-with-string fixes its stack trace handling (see OW-8879 and
126
129
  * https://github.com/exuanbo/module-from-string/issues/18)
127
130
  */
128
- declare const pipe: (migrations: TMigration[], payload: unknown) => unknown;
131
+ declare const pipe: (migrations: TMigration[], payload: TPayload, metaData?: TMetaData) => TPayload;
129
132
 
130
133
  declare const getVersions: (db: IDatabase<unknown>, entity: string) => Promise<any[]>;
131
134
 
@@ -136,4 +139,4 @@ declare const printVersionHistory: ({ config }: {
136
139
  config: TConfig;
137
140
  }) => Promise<void>;
138
141
 
139
- export { type TAfterMigrateRecord, type TAfterMigrateRecordPayload, type TBeforeMigrateRecord, type TBeforeMigrateRecordPayload, type TConfig, type TEntityColumnNames, type TMigration, type TMigrationErrorPayload, type TOnMigrationErrors, type TOnMigrationErrorsPayload, type TRecord, createMigration, getPlannedMigrations, getPlannedVersion, getVersions, migrate, migrateAll, pipe, printVersionHistory };
142
+ export { type TAfterMigrateRecord, type TAfterMigrateRecordPayload, type TBeforeMigrateRecord, type TBeforeMigrateRecordPayload, type TConfig, type TEntityColumnNames, type TMetaData, type TMigration, type TMigrationErrorPayload, type TOnMigrationErrors, type TOnMigrationErrorsPayload, type TPayload, type TRecord, createMigration, getPlannedMigrations, getPlannedVersion, getVersions, migrate, migrateAll, pipe, printVersionHistory };
package/dist/index.d.mts CHANGED
@@ -5,6 +5,8 @@ import { IDatabase, IHelpers, ITask } from 'pg-promise';
5
5
  */
6
6
  declare const createMigration: (directory: string, description: string, entity: string) => Promise<void>;
7
7
 
8
+ type TPayload = Record<string, unknown>;
9
+ type TMetaData = Record<string, unknown>;
8
10
  type TMigration = {
9
11
  fileName?: string;
10
12
  fileHash?: string;
@@ -15,7 +17,7 @@ type TMigration = {
15
17
  skippedFileHashes?: string[];
16
18
  sequenceFromHistory?: string;
17
19
  script?: string;
18
- migrator?: (payload: unknown) => unknown;
20
+ migrator?: (payload: TPayload, metaData?: TMetaData) => TPayload;
19
21
  };
20
22
  type TEntityColumnNames = {
21
23
  id: string;
@@ -25,7 +27,7 @@ type TEntityColumnNames = {
25
27
  version: string;
26
28
  created: string;
27
29
  };
28
- type TRecord<T extends TEntityColumnNames = TEntityColumnNames, TData = unknown> = {
30
+ type TRecord<T extends TEntityColumnNames = TEntityColumnNames, TData = TPayload> = {
29
31
  [K in T['id']]: number | string;
30
32
  } & {
31
33
  [K in T['name']]: string;
@@ -96,11 +98,12 @@ declare const getPlannedVersion: ({ config }: {
96
98
  * i) function looks up the pending migrations for you (default)
97
99
  * ii) pass in pre-fetched pending migrators via config.pending
98
100
  */
99
- declare const migrate: ({ payload, config, }: {
100
- payload: unknown;
101
+ declare const migrate: ({ payload, config, metaData, }: {
102
+ payload: TPayload;
101
103
  config: TConfig;
104
+ metaData?: TMetaData;
102
105
  }) => Promise<{
103
- nextPayload: unknown;
106
+ nextPayload: TPayload;
104
107
  nextVersion: string;
105
108
  }>;
106
109
 
@@ -125,7 +128,7 @@ declare const migrateAll: ({ config, beforeMigrateRecord, afterMigrateRecord, on
125
128
  * until module-with-string fixes its stack trace handling (see OW-8879 and
126
129
  * https://github.com/exuanbo/module-from-string/issues/18)
127
130
  */
128
- declare const pipe: (migrations: TMigration[], payload: unknown) => unknown;
131
+ declare const pipe: (migrations: TMigration[], payload: TPayload, metaData?: TMetaData) => TPayload;
129
132
 
130
133
  declare const getVersions: (db: IDatabase<unknown>, entity: string) => Promise<any[]>;
131
134
 
@@ -136,4 +139,4 @@ declare const printVersionHistory: ({ config }: {
136
139
  config: TConfig;
137
140
  }) => Promise<void>;
138
141
 
139
- export { type TAfterMigrateRecord, type TAfterMigrateRecordPayload, type TBeforeMigrateRecord, type TBeforeMigrateRecordPayload, type TConfig, type TEntityColumnNames, type TMigration, type TMigrationErrorPayload, type TOnMigrationErrors, type TOnMigrationErrorsPayload, type TRecord, createMigration, getPlannedMigrations, getPlannedVersion, getVersions, migrate, migrateAll, pipe, printVersionHistory };
142
+ export { type TAfterMigrateRecord, type TAfterMigrateRecordPayload, type TBeforeMigrateRecord, type TBeforeMigrateRecordPayload, type TConfig, type TEntityColumnNames, type TMetaData, type TMigration, type TMigrationErrorPayload, type TOnMigrationErrors, type TOnMigrationErrorsPayload, type TPayload, type TRecord, createMigration, getPlannedMigrations, getPlannedVersion, getVersions, migrate, migrateAll, pipe, printVersionHistory };