@bdkinc/knex-ibmi 0.3.22 → 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/dist/index.d.ts CHANGED
@@ -1,52 +1,26 @@
1
- import { knex, Knex } from 'knex';
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
- declare class IBMiSchemaCompiler extends SchemaCompiler {
9
- hasTable(tableName: any): void;
10
- toSQL(): any[];
4
+ interface IBMiMigrationConfig {
5
+ directory: string;
6
+ tableName: string;
7
+ schemaName?: string;
8
+ extension?: string;
11
9
  }
12
-
13
- declare class IBMiTableCompiler extends TableCompiler {
14
- createQuery(columns: {
15
- sql: any[];
16
- }, ifNot: any, like: any): void;
17
- dropUnique(columns: string[], indexName: any): void;
18
- unique(columns: string[], indexName: {
19
- indexName: any;
20
- deferrable: any;
21
- predicate: any;
22
- }): void;
23
- addColumns(columns: any, prefix: any): void;
24
- commit(connection: Connection): Promise<void>;
25
- }
26
-
27
- declare class IBMiColumnCompiler extends ColumnCompiler {
28
- increments(options?: {
29
- primaryKey: boolean;
30
- }): string;
31
- }
32
-
33
- declare class IBMiQueryCompiler extends QueryCompiler {
34
- insert(): "" | {
35
- sql: string;
36
- returning: any;
37
- };
38
- _buildInsertData(insertValues: string | any[], returningSql: string): string;
39
- _prepInsert(data: any): {
40
- columns: any;
41
- values: any;
42
- };
43
- update(): {
44
- sql: string;
45
- returning: any;
46
- };
47
- _returning(method: string, value: any, withTrigger: undefined): string | undefined;
48
- columnizeWithPrefix(prefix: string, target: any): 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;
49
22
  }
23
+ declare function createIBMiMigrationRunner(knex: Knex, config?: Partial<IBMiMigrationConfig>): IBMiMigrationRunner;
50
24
 
51
25
  interface QueryObject {
52
26
  response?: {
@@ -70,12 +44,13 @@ declare enum SqlMethod {
70
44
  }
71
45
  declare class DB2Client extends knex.Client {
72
46
  constructor(config: Knex.Config<DB2Config>);
47
+ private safeStringify;
73
48
  _driver(): typeof odbc;
74
- wrapIdentifierImpl(value: any): any;
49
+ wrapIdentifierImpl(value: string): string;
75
50
  printDebug(message: string): void;
76
51
  printError(message: string): void;
77
52
  printWarn(message: string): void;
78
- acquireRawConnection(): Promise<any>;
53
+ acquireRawConnection(): Promise<void | odbc.Connection>;
79
54
  destroyRawConnection(connection: any): Promise<any>;
80
55
  _getConnectionString(connectionConfig: DB2ConnectionConfig): string;
81
56
  _query(connection: Connection, obj: any): Promise<any>;
@@ -84,6 +59,11 @@ declare class DB2Client extends knex.Client {
84
59
  private isSelectMethod;
85
60
  private executeSelectQuery;
86
61
  private executeStatementQuery;
62
+ private isNoDataError;
63
+ /**
64
+ * Format statement response from ODBC driver
65
+ * Handles special case for IDENTITY_VAL_LOCAL() function
66
+ */
87
67
  private formatStatementResponse;
88
68
  _stream(connection: Connection, obj: {
89
69
  sql: string;
@@ -93,12 +73,14 @@ declare class DB2Client extends knex.Client {
93
73
  }): Promise<unknown>;
94
74
  private _createCursorStream;
95
75
  transaction(container: any, config: any, outerTx: any): Knex.Transaction;
96
- schemaCompiler(tableBuilder: any): IBMiSchemaCompiler;
97
- tableCompiler(tableBuilder: any): IBMiTableCompiler;
98
- columnCompiler(tableCompiler: any, columnCompiler: any): IBMiColumnCompiler;
99
- queryCompiler(builder: Knex.QueryBuilder, bindings?: any[]): IBMiQueryCompiler;
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;
100
81
  processResponse(obj: QueryObject | null, runner: any): any;
101
82
  private validateResponse;
83
+ private isConnectionError;
102
84
  private processSqlMethod;
103
85
  }
104
86
  interface DB2PoolConfig {
@@ -134,11 +116,12 @@ interface DB2ConnectionParams {
134
116
  CONCURRENCY?: 0 | 1;
135
117
  CURSORSENSITIVITY?: 0 | 1 | 2;
136
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;
137
120
  }
138
121
  interface DB2ConnectionConfig {
139
122
  database: string;
140
123
  host: string;
141
- port: 50000 | number;
124
+ port: 8471 | 9471 | number;
142
125
  user: string;
143
126
  password: string;
144
127
  driver: "IBM i Access ODBC Driver" | string;
@@ -151,4 +134,4 @@ interface DB2Config extends Knex.Config {
151
134
  }
152
135
  declare const DB2Dialect: typeof DB2Client;
153
136
 
154
- export { type DB2Config, DB2Dialect, DB2Client as default };
137
+ export { type DB2Config, DB2Dialect, IBMiMigrationRunner, createIBMiMigrationRunner, DB2Client as default };