@bdkinc/knex-ibmi 0.3.21 → 0.4.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/LICENSE +0 -0
- package/README.md +250 -127
- package/dist/cli.cjs +531 -0
- package/dist/index.d.mts +137 -0
- package/dist/index.d.ts +77 -53
- package/dist/index.js +654 -199
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +971 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +29 -20
package/dist/index.d.ts
CHANGED
|
@@ -1,76 +1,87 @@
|
|
|
1
|
-
import
|
|
1
|
+
import knex, { Knex } from 'knex';
|
|
2
2
|
import odbc, { Connection } from 'odbc';
|
|
3
|
-
import SchemaCompiler from 'knex/lib/schema/compiler';
|
|
4
|
-
import TableCompiler from 'knex/lib/schema/tablecompiler';
|
|
5
|
-
import ColumnCompiler from 'knex/lib/schema/columncompiler';
|
|
6
|
-
import QueryCompiler from 'knex/lib/query/querycompiler';
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
interface IBMiMigrationConfig {
|
|
5
|
+
directory: string;
|
|
6
|
+
tableName: string;
|
|
7
|
+
schemaName?: string;
|
|
8
|
+
extension?: string;
|
|
11
9
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
commit(connection: Connection): Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
declare class IBMiColumnCompiler extends ColumnCompiler {
|
|
28
|
-
increments(options?: {
|
|
29
|
-
primaryKey: boolean;
|
|
30
|
-
}): string;
|
|
10
|
+
declare class IBMiMigrationRunner {
|
|
11
|
+
private knex;
|
|
12
|
+
private config;
|
|
13
|
+
constructor(knex: Knex, config?: Partial<IBMiMigrationConfig>);
|
|
14
|
+
private getFullTableName;
|
|
15
|
+
latest(): Promise<void>;
|
|
16
|
+
rollback(steps?: number): Promise<void>;
|
|
17
|
+
currentVersion(): Promise<string | null>;
|
|
18
|
+
listExecuted(): Promise<string[]>;
|
|
19
|
+
listPending(): Promise<string[]>;
|
|
20
|
+
private getMigrationFiles;
|
|
21
|
+
private getMigrationPath;
|
|
31
22
|
}
|
|
23
|
+
declare function createIBMiMigrationRunner(knex: Knex, config?: Partial<IBMiMigrationConfig>): IBMiMigrationRunner;
|
|
32
24
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
_buildInsertData(insertValues: string | any[], returningSql: string): string;
|
|
39
|
-
_prepInsert(data: any): {
|
|
40
|
-
columns: any;
|
|
41
|
-
values: any;
|
|
25
|
+
interface QueryObject {
|
|
26
|
+
response?: {
|
|
27
|
+
rows: any[];
|
|
28
|
+
rowCount: number;
|
|
42
29
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
30
|
+
sqlMethod: SqlMethod;
|
|
31
|
+
output?: (runner: any, response: any) => any;
|
|
32
|
+
pluck?: (row: any) => any;
|
|
33
|
+
select?: boolean;
|
|
34
|
+
}
|
|
35
|
+
declare enum SqlMethod {
|
|
36
|
+
SELECT = "select",
|
|
37
|
+
PLUCK = "pluck",
|
|
38
|
+
FIRST = "first",
|
|
39
|
+
INSERT = "insert",
|
|
40
|
+
DELETE = "del",
|
|
41
|
+
DELETE_ALT = "delete",
|
|
42
|
+
UPDATE = "update",
|
|
43
|
+
COUNTER = "counter"
|
|
49
44
|
}
|
|
50
|
-
|
|
51
45
|
declare class DB2Client extends knex.Client {
|
|
52
46
|
constructor(config: Knex.Config<DB2Config>);
|
|
47
|
+
private safeStringify;
|
|
53
48
|
_driver(): typeof odbc;
|
|
54
|
-
wrapIdentifierImpl(value:
|
|
49
|
+
wrapIdentifierImpl(value: string): string;
|
|
55
50
|
printDebug(message: string): void;
|
|
56
51
|
printError(message: string): void;
|
|
57
52
|
printWarn(message: string): void;
|
|
58
|
-
acquireRawConnection(): Promise<
|
|
53
|
+
acquireRawConnection(): Promise<void | odbc.Connection>;
|
|
59
54
|
destroyRawConnection(connection: any): Promise<any>;
|
|
60
55
|
_getConnectionString(connectionConfig: DB2ConnectionConfig): string;
|
|
61
|
-
_query(connection:
|
|
56
|
+
_query(connection: Connection, obj: any): Promise<any>;
|
|
57
|
+
private normalizeQueryObject;
|
|
58
|
+
private determineQueryMethod;
|
|
59
|
+
private isSelectMethod;
|
|
60
|
+
private executeSelectQuery;
|
|
61
|
+
private executeStatementQuery;
|
|
62
|
+
private isNoDataError;
|
|
63
|
+
/**
|
|
64
|
+
* Format statement response from ODBC driver
|
|
65
|
+
* Handles special case for IDENTITY_VAL_LOCAL() function
|
|
66
|
+
*/
|
|
67
|
+
private formatStatementResponse;
|
|
62
68
|
_stream(connection: Connection, obj: {
|
|
63
69
|
sql: string;
|
|
64
70
|
bindings: any[];
|
|
65
71
|
}, stream: any, options: {
|
|
66
72
|
fetchSize?: number;
|
|
67
73
|
}): Promise<unknown>;
|
|
74
|
+
private _createCursorStream;
|
|
68
75
|
transaction(container: any, config: any, outerTx: any): Knex.Transaction;
|
|
69
|
-
schemaCompiler(tableBuilder: any):
|
|
70
|
-
tableCompiler(tableBuilder: any):
|
|
71
|
-
columnCompiler(tableCompiler: any, columnCompiler: any):
|
|
72
|
-
queryCompiler(builder: Knex.QueryBuilder, bindings?: any[]):
|
|
73
|
-
|
|
76
|
+
schemaCompiler(tableBuilder: any): any;
|
|
77
|
+
tableCompiler(tableBuilder: any): any;
|
|
78
|
+
columnCompiler(tableCompiler: any, columnCompiler: any): any;
|
|
79
|
+
queryCompiler(builder: Knex.QueryBuilder, bindings?: any[]): any;
|
|
80
|
+
createMigrationRunner(config?: Partial<IBMiMigrationConfig>): IBMiMigrationRunner;
|
|
81
|
+
processResponse(obj: QueryObject | null, runner: any): any;
|
|
82
|
+
private validateResponse;
|
|
83
|
+
private isConnectionError;
|
|
84
|
+
private processSqlMethod;
|
|
74
85
|
}
|
|
75
86
|
interface DB2PoolConfig {
|
|
76
87
|
min?: number;
|
|
@@ -91,13 +102,26 @@ interface DB2ConnectionParams {
|
|
|
91
102
|
DECFLOATERROROPTION?: 0 | 1;
|
|
92
103
|
DECFLOATROUNDMODE?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
93
104
|
MAPDECIMALFLOATDESCRIBE?: 1 | 3;
|
|
105
|
+
TFT?: 0 | 1 | 2 | 3 | 4;
|
|
106
|
+
TSP?: 0 | 1 | 2 | 3;
|
|
107
|
+
TSFT?: 0 | 1;
|
|
108
|
+
XMLCURIMPPARSE?: 0 | 1;
|
|
109
|
+
XMLDECLARATION?: 1 | 2 | 3 | 4;
|
|
94
110
|
ALLOWPROCCALLS?: 0 | 1;
|
|
95
111
|
XDYNAMIC?: 0 | 1;
|
|
112
|
+
DFTPKGLIB?: string;
|
|
113
|
+
PKG?: 0 | 1 | 2;
|
|
114
|
+
BLOCKFETCH?: 0 | 1;
|
|
115
|
+
COMPRESSION?: 0 | 1;
|
|
116
|
+
CONCURRENCY?: 0 | 1;
|
|
117
|
+
CURSORSENSITIVITY?: 0 | 1 | 2;
|
|
118
|
+
EXTCOLINFO?: "SQL_DESC_AUTO_UNIQUE_VALUE" | "SQL_DESC_BASE_COLUMN_NAME" | "SQL_DESC_BASE_TABLE_NAME and SQL_DESC_TABLE_NAME" | "SQL_DESC_LABEL" | "SQL_DESC_SCHEMA_NAME" | "SQL_DESC_SEARCHABLE" | "SQL_DESC_UNNAMED" | "SQL_DESC_UPDATABLE";
|
|
119
|
+
TRUEAUTOCOMMIT?: 0 | 1;
|
|
96
120
|
}
|
|
97
121
|
interface DB2ConnectionConfig {
|
|
98
122
|
database: string;
|
|
99
123
|
host: string;
|
|
100
|
-
port:
|
|
124
|
+
port: 8471 | 9471 | number;
|
|
101
125
|
user: string;
|
|
102
126
|
password: string;
|
|
103
127
|
driver: "IBM i Access ODBC Driver" | string;
|
|
@@ -110,4 +134,4 @@ interface DB2Config extends Knex.Config {
|
|
|
110
134
|
}
|
|
111
135
|
declare const DB2Dialect: typeof DB2Client;
|
|
112
136
|
|
|
113
|
-
export { type DB2Config, DB2Dialect, DB2Client as default };
|
|
137
|
+
export { type DB2Config, DB2Dialect, IBMiMigrationRunner, createIBMiMigrationRunner, DB2Client as default };
|