@nesgarbo/node-jt400 5.4.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/LICENSE +20 -0
- package/README.md +511 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/dist/integration-test/call-rpg-spec.d.ts +1 -0
- package/dist/integration-test/call-rpg-spec.js +88 -0
- package/dist/integration-test/call-rpg-spec.js.map +1 -0
- package/dist/integration-test/dataq-spec.d.ts +1 -0
- package/dist/integration-test/dataq-spec.js +42 -0
- package/dist/integration-test/dataq-spec.js.map +1 -0
- package/dist/integration-test/db.d.ts +2 -0
- package/dist/integration-test/db.js +8 -0
- package/dist/integration-test/db.js.map +1 -0
- package/dist/integration-test/db2-connect-spec.d.ts +1 -0
- package/dist/integration-test/db2-connect-spec.js +34 -0
- package/dist/integration-test/db2-connect-spec.js.map +1 -0
- package/dist/integration-test/db2-pool-spec.d.ts +1 -0
- package/dist/integration-test/db2-pool-spec.js +191 -0
- package/dist/integration-test/db2-pool-spec.js.map +1 -0
- package/dist/integration-test/ifs-spec.d.ts +1 -0
- package/dist/integration-test/ifs-spec.js +118 -0
- package/dist/integration-test/ifs-spec.js.map +1 -0
- package/dist/integration-test/msgf-spec.d.ts +1 -0
- package/dist/integration-test/msgf-spec.js +25 -0
- package/dist/integration-test/msgf-spec.js.map +1 -0
- package/dist/integration-test/msgq-spec.d.ts +1 -0
- package/dist/integration-test/msgq-spec.js +34 -0
- package/dist/integration-test/msgq-spec.js.map +1 -0
- package/dist/java/JT400.d.ts +77 -0
- package/dist/java/JT400.js +3 -0
- package/dist/java/JT400.js.map +1 -0
- package/dist/java/index.d.ts +11 -0
- package/dist/java/index.js +45 -0
- package/dist/java/index.js.map +1 -0
- package/dist/lib/baseConnection.d.ts +5 -0
- package/dist/lib/baseConnection.js +264 -0
- package/dist/lib/baseConnection.js.map +1 -0
- package/dist/lib/baseConnection.types.d.ts +53 -0
- package/dist/lib/baseConnection.types.js +7 -0
- package/dist/lib/baseConnection.types.js.map +1 -0
- package/dist/lib/connection.d.ts +13 -0
- package/dist/lib/connection.js +143 -0
- package/dist/lib/connection.js.map +1 -0
- package/dist/lib/connection.types.d.ts +77 -0
- package/dist/lib/connection.types.js +3 -0
- package/dist/lib/connection.types.js.map +1 -0
- package/dist/lib/handleError.d.ts +3 -0
- package/dist/lib/handleError.js +25 -0
- package/dist/lib/handleError.js.map +1 -0
- package/dist/lib/ifs/index.d.ts +4 -0
- package/dist/lib/ifs/index.js +47 -0
- package/dist/lib/ifs/index.js.map +1 -0
- package/dist/lib/ifs/read_stream.d.ts +6 -0
- package/dist/lib/ifs/read_stream.js +33 -0
- package/dist/lib/ifs/read_stream.js.map +1 -0
- package/dist/lib/ifs/types.d.ts +16 -0
- package/dist/lib/ifs/types.js +3 -0
- package/dist/lib/ifs/types.js.map +1 -0
- package/dist/lib/ifs/write_stream.d.ts +6 -0
- package/dist/lib/ifs/write_stream.js +39 -0
- package/dist/lib/ifs/write_stream.js.map +1 -0
- package/dist/lib/inMemoryConnection.d.ts +7 -0
- package/dist/lib/inMemoryConnection.js +35 -0
- package/dist/lib/inMemoryConnection.js.map +1 -0
- package/dist/lib/insertList.d.ts +4 -0
- package/dist/lib/insertList.js +44 -0
- package/dist/lib/insertList.js.map +1 -0
- package/dist/lib/jdbcstream.d.ts +1 -0
- package/dist/lib/jdbcstream.js +50 -0
- package/dist/lib/jdbcstream.js.map +1 -0
- package/dist/lib/jdbcwritestream.d.ts +1 -0
- package/dist/lib/jdbcwritestream.js +37 -0
- package/dist/lib/jdbcwritestream.js.map +1 -0
- package/dist/lib/logger.d.ts +7 -0
- package/dist/lib/logger.js +13 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/sqlutil.d.ts +1 -0
- package/dist/lib/sqlutil.js +18 -0
- package/dist/lib/sqlutil.js.map +1 -0
- package/dist/lib/streamTransformers.d.ts +2 -0
- package/dist/lib/streamTransformers.js +30 -0
- package/dist/lib/streamTransformers.js.map +1 -0
- package/dist/unit-test/hsql-spec.d.ts +1 -0
- package/dist/unit-test/hsql-spec.js +495 -0
- package/dist/unit-test/hsql-spec.js.map +1 -0
- package/dist/unit-test/sqlutil-spec.d.ts +1 -0
- package/dist/unit-test/sqlutil-spec.js +20 -0
- package/dist/unit-test/sqlutil-spec.js.map +1 -0
- package/dist/unit-test/streamTransformers-spec.d.ts +1 -0
- package/dist/unit-test/streamTransformers-spec.js +98 -0
- package/dist/unit-test/streamTransformers-spec.js.map +1 -0
- package/java/lib/hsqldb.jar +0 -0
- package/java/lib/json-simple-1.1.1.jar +0 -0
- package/java/lib/jt400.jar +0 -0
- package/java/lib/jt400wrap.jar +0 -0
- package/package.json +72 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"./ts-src/","sources":["lib/connection.ts"],"names":[],"mappings":";;;;;;;;;;;AAwBA,4CAwJC;AAhLD,+BAAgC;AAGhC,qDAAuD;AAQvD,+CAA2C;AAC3C,+BAAwC;AAExC,6CAAyC;AAEzC,yCAAyC;AAEzC,MAAM,kBAAkB,GAAG,UACzB,GAAoB;IAEpB,OAAQ,GAAwB,CAAC,IAAI,KAAK,SAAS,CAAA;AACrD,CAAC,CAAA;AAED,SAAgB,gBAAgB,CAAC,EAC/B,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,MAAM,GAQP;IACC,MAAM,cAAc,GAAG,IAAA,qCAAoB,EACzC,UAAU,EACV,aAAa,EACb,MAAM,EACN,QAAQ,CACT,CAAA;IACD,MAAM,KAAK,mCACN,cAAc,KACX,WAAW,CAAC,mBAAmB;;gBACnC,MAAM,CAAC,GAAG,UAAU,CAAC,qBAAqB,EAAE,CAAA;gBAC5C,MAAM,kBAAkB,GAAG,IAAA,qCAAoB,EAC7C,CAAC,EACD,aAAa,EACb,MAAM,EACN,QAAQ,CACT,CAAA;gBAED,IAAI,CAAC;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,CAAA;YACD,OAAO,SAAS,GAAG,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC;gBACrC,OAAO,GAAG;qBACP,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;qBACpC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;qBAChB,KAAK,CAAC,IAAA,yBAAW,EAAC,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;YAC1E,CAAC,CAAA;QACH,CAAC,EACD,GAAG,EAAE,IAAA,gBAAS,EAAC,UAAU,WAAW,EAAE,YAAY,EAAE,WAAW;YAC7D,OAAO,IAAI,CAAC,aAAa,CAAC;gBACxB,WAAW;gBACX,YAAY;gBACZ,WAAW;aACZ,CAAC,CAAA;QACJ,CAAC,EAAE,0FAA0F,CAAC,EAC9F,KAAK;YACH,OAAO,UAAU,CAAC,KAAK,EAAE,CAAA;QAC3B,CAAC,GACF,CAAA;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
import { BaseConnection, Close } from './baseConnection.types';
|
|
3
|
+
import { Ifs } from './ifs/types';
|
|
4
|
+
export interface ProgramDefinitionOptions {
|
|
5
|
+
programName: string;
|
|
6
|
+
paramsSchema: PgmParamType[];
|
|
7
|
+
libraryName?: string;
|
|
8
|
+
ccsid?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface PgmParamType1 {
|
|
11
|
+
name: string;
|
|
12
|
+
size: number;
|
|
13
|
+
type?: string;
|
|
14
|
+
decimals?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface PgmParamType2 {
|
|
17
|
+
name: string;
|
|
18
|
+
precision: number;
|
|
19
|
+
typeName?: string;
|
|
20
|
+
scale?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface PgmParamStructType {
|
|
23
|
+
[key: string]: PgmParamType[];
|
|
24
|
+
}
|
|
25
|
+
export type PgmParamType = PgmParamType1 | PgmParamType2 | PgmParamStructType;
|
|
26
|
+
export interface JustNameMessageQ {
|
|
27
|
+
name: string;
|
|
28
|
+
}
|
|
29
|
+
export interface JustPathMessageQ {
|
|
30
|
+
path: string;
|
|
31
|
+
}
|
|
32
|
+
export type MessageQOptions = JustNameMessageQ | JustPathMessageQ;
|
|
33
|
+
export interface MessageQReadOptions {
|
|
34
|
+
wait?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface DataQReadOptions {
|
|
37
|
+
key: string;
|
|
38
|
+
wait?: number;
|
|
39
|
+
writeKeyLength?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface MessageFileHandlerOptions {
|
|
42
|
+
path: string;
|
|
43
|
+
}
|
|
44
|
+
export interface MessageFileReadOptions {
|
|
45
|
+
messageId: string[7];
|
|
46
|
+
}
|
|
47
|
+
export interface MessageQ {
|
|
48
|
+
sendInformational: (messageText: string) => Promise<void>;
|
|
49
|
+
read: (params?: MessageQReadOptions) => Promise<any> | Promise<null>;
|
|
50
|
+
}
|
|
51
|
+
export interface DataQOptions {
|
|
52
|
+
name: string;
|
|
53
|
+
}
|
|
54
|
+
export interface KeyedDataQ {
|
|
55
|
+
write: (key: string, data: string) => void;
|
|
56
|
+
read: (params: DataQReadOptions | string) => Promise<any>;
|
|
57
|
+
}
|
|
58
|
+
export interface AS400Message {
|
|
59
|
+
getText: () => Promise<string>;
|
|
60
|
+
}
|
|
61
|
+
export interface MessageFileHandler {
|
|
62
|
+
read: (params: MessageFileReadOptions) => Promise<AS400Message>;
|
|
63
|
+
}
|
|
64
|
+
export type TransactionFun = (transaction: BaseConnection) => Promise<any>;
|
|
65
|
+
export interface Connection extends BaseConnection {
|
|
66
|
+
pgm: (programName: string, paramsSchema: PgmParamType[], libraryName?: string) => any;
|
|
67
|
+
defineProgram: (options: ProgramDefinitionOptions) => any;
|
|
68
|
+
getTablesAsStream: (params: any) => Readable;
|
|
69
|
+
getColumns: (params: any) => any;
|
|
70
|
+
getPrimaryKeys: (params: any) => any;
|
|
71
|
+
transaction: (fn: TransactionFun) => Promise<any>;
|
|
72
|
+
openMessageQ: (params: MessageQOptions) => Promise<MessageQ>;
|
|
73
|
+
createKeyedDataQ: (params: DataQOptions) => KeyedDataQ;
|
|
74
|
+
openMessageFile: (params: MessageFileHandlerOptions) => Promise<MessageFileHandler>;
|
|
75
|
+
ifs: () => Ifs;
|
|
76
|
+
close: Close;
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.types.js","sourceRoot":"./ts-src/","sources":["lib/connection.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleError = handleError;
|
|
4
|
+
const oops_error_1 = require("oops-error");
|
|
5
|
+
function handleError(context) {
|
|
6
|
+
return (err) => {
|
|
7
|
+
const errMsg = (err.cause && err.cause.getMessageSync && err.cause.getMessageSync()) ||
|
|
8
|
+
(err.getMessageSync && err.getMessageSync()) ||
|
|
9
|
+
err.message;
|
|
10
|
+
const start = errMsg.indexOf(': ');
|
|
11
|
+
const end = errMsg.indexOf('\n');
|
|
12
|
+
const message = start > 0 && end > 0 ? errMsg.slice(start + 2, end) : errMsg;
|
|
13
|
+
const category = message.toLowerCase().includes('connection') ||
|
|
14
|
+
errMsg.includes('java.net.UnknownHostException')
|
|
15
|
+
? 'OperationalError'
|
|
16
|
+
: 'ProgrammerError';
|
|
17
|
+
throw new oops_error_1.Oops({
|
|
18
|
+
message,
|
|
19
|
+
context,
|
|
20
|
+
category,
|
|
21
|
+
cause: err,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=handleError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleError.js","sourceRoot":"./ts-src/","sources":["lib/handleError.ts"],"names":[],"mappings":";;AAEA,kCAqBC;AAvBD,2CAAiC;AAEjC,SAAgB,WAAW,CAAC,OAA+B;IACzD,OAAO,CAAC,GAAQ,EAAE,EAAE;QAClB,MAAM,MAAM,GACV,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,cAAc,IAAI,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;YACrE,CAAC,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,cAAc,EAAE,CAAC;YAC5C,GAAG,CAAC,OAAO,CAAA;QACb,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAClC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAChC,MAAM,OAAO,GAAG,KAAK,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QAC5E,MAAM,QAAQ,GACZ,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;YAC5C,MAAM,CAAC,QAAQ,CAAC,+BAA+B,CAAC;YAC9C,CAAC,CAAC,kBAAkB;YACpB,CAAC,CAAC,iBAAiB,CAAA;QACvB,MAAM,IAAI,iBAAI,CAAC;YACb,OAAO;YACP,OAAO;YACP,QAAQ;YACR,KAAK,EAAE,GAAG;SACX,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ifs = ifs;
|
|
13
|
+
const path_1 = require("path");
|
|
14
|
+
const read_stream_1 = require("./read_stream");
|
|
15
|
+
const write_stream_1 = require("./write_stream");
|
|
16
|
+
function ifs(connection, bufferToJavaType, javaTypeToBuffer) {
|
|
17
|
+
return {
|
|
18
|
+
createReadStream: function (fileName) {
|
|
19
|
+
const javaStream = Promise.resolve(fileName).then(function (file) {
|
|
20
|
+
return connection.createIfsReadStream(file);
|
|
21
|
+
});
|
|
22
|
+
return new read_stream_1.IfsReadStream({
|
|
23
|
+
ifsReadStream: javaStream,
|
|
24
|
+
javaTypeToBuffer,
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
createWriteStream: function (fileName, options = { append: false }) {
|
|
28
|
+
const javaStream = Promise.resolve(fileName).then(function (file) {
|
|
29
|
+
const folderPath = (0, path_1.dirname)(file);
|
|
30
|
+
const fileName = (0, path_1.basename)(file);
|
|
31
|
+
return connection.createIfsWriteStream(folderPath, fileName, options.append, options.ccsid);
|
|
32
|
+
});
|
|
33
|
+
return new write_stream_1.IfsWriteStream({
|
|
34
|
+
ifsWriteStream: javaStream,
|
|
35
|
+
bufferToJavaType,
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
listFiles: (folderName) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const files = yield connection.listIfsFiles(folderName);
|
|
40
|
+
return files || [];
|
|
41
|
+
}),
|
|
42
|
+
moveFile: (fileName, newFileName) => connection.moveIfsFile(fileName, newFileName),
|
|
43
|
+
deleteFile: (fileName) => connection.deleteIfsFile(fileName),
|
|
44
|
+
fileMetadata: (fileName) => connection.getIfsFileMetadata(fileName).then(JSON.parse),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./ts-src/","sources":["lib/ifs/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAOA,kBA4CC;AAnDD,+BAAwC;AAGxC,+CAA6C;AAE7C,iDAA+C;AAE/C,SAAgB,GAAG,CACjB,UAAiB,EACjB,gBAAkC,EAClC,gBAAkC;IAElC,OAAO;QACL,gBAAgB,EAAE,UAAU,QAAkC;YAC5D,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI;gBAC9D,OAAO,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAA;YAC7C,CAAC,CAAC,CAAA;YACF,OAAO,IAAI,2BAAa,CAAC;gBACvB,aAAa,EAAE,UAAU;gBACzB,gBAAgB;aACjB,CAAC,CAAA;QACJ,CAAC;QACD,iBAAiB,EAAE,UACjB,QAAkC,EAClC,UAA+C,EAAE,MAAM,EAAE,KAAK,EAAE;YAEhE,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI;gBAC9D,MAAM,UAAU,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,CAAA;gBAChC,MAAM,QAAQ,GAAG,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAA;gBAC/B,OAAO,UAAU,CAAC,oBAAoB,CACpC,UAAU,EACV,QAAQ,EACR,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,KAAK,CACd,CAAA;YACH,CAAC,CAAC,CAAA;YACF,OAAO,IAAI,6BAAc,CAAC;gBACxB,cAAc,EAAE,UAAU;gBAC1B,gBAAgB;aACjB,CAAC,CAAA;QACJ,CAAC;QACD,SAAS,EAAE,CAAO,UAAkB,EAAE,EAAE;YACtC,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;YACvD,OAAO,KAAK,IAAI,EAAE,CAAA;QACpB,CAAC,CAAA;QACD,QAAQ,EAAE,CAAC,QAAgB,EAAE,WAAmB,EAAE,EAAE,CAClD,UAAU,CAAC,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC;QAC/C,UAAU,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC;QACpE,YAAY,EAAE,CAAC,QAAgB,EAAE,EAAE,CACjC,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KAC3D,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IfsReadStream = IfsReadStream;
|
|
4
|
+
const util = require("util");
|
|
5
|
+
const stream_1 = require("stream");
|
|
6
|
+
function IfsReadStream(opt) {
|
|
7
|
+
stream_1.Readable.call(this, {
|
|
8
|
+
objectMode: false,
|
|
9
|
+
});
|
|
10
|
+
this._ifsReadStream = opt.ifsReadStream;
|
|
11
|
+
this._javaTypeToBuffer = opt.javaTypeToBuffer;
|
|
12
|
+
this._buffer = [];
|
|
13
|
+
}
|
|
14
|
+
util.inherits(IfsReadStream, stream_1.Readable);
|
|
15
|
+
IfsReadStream.prototype._read = function () {
|
|
16
|
+
const _this = this;
|
|
17
|
+
const streamPromise = this._ifsReadStream;
|
|
18
|
+
streamPromise
|
|
19
|
+
.then((stream) => {
|
|
20
|
+
stream
|
|
21
|
+
.read()
|
|
22
|
+
.then((res) => {
|
|
23
|
+
this.push(this._javaTypeToBuffer(res));
|
|
24
|
+
})
|
|
25
|
+
.catch((err) => {
|
|
26
|
+
_this.emit('error', err);
|
|
27
|
+
});
|
|
28
|
+
})
|
|
29
|
+
.catch((err) => {
|
|
30
|
+
this.emit('error', err);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=read_stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read_stream.js","sourceRoot":"./ts-src/","sources":["lib/ifs/read_stream.ts"],"names":[],"mappings":";;AAKA,sCAUC;AAfD,6BAA6B;AAC7B,mCAAiC;AAIjC,SAAgB,aAAa,CAAC,GAG7B;IACC,iBAAQ,CAAC,IAAI,CAAC,IAAI,EAAE;QAClB,UAAU,EAAE,KAAK;KAClB,CAAC,CAAA;IACF,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC,aAAa,CAAA;IACvC,IAAI,CAAC,iBAAiB,GAAG,GAAG,CAAC,gBAAgB,CAAA;IAC7C,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;AACnB,CAAC;AAED,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,iBAAQ,CAAC,CAAA;AAEtC,aAAa,CAAC,SAAS,CAAC,KAAK,GAAG;IAC9B,MAAM,KAAK,GAAG,IAAI,CAAA;IAClB,MAAM,aAAa,GAA+B,IAAI,CAAC,cAAc,CAAA;IACrE,aAAa;SACV,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACf,MAAM;aACH,IAAI,EAAE;aACN,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA;QACxC,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;IACN,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;AACN,CAAC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Readable, Writable } from 'stream';
|
|
2
|
+
export interface IfsFileMetadata {
|
|
3
|
+
exists: boolean;
|
|
4
|
+
length: number;
|
|
5
|
+
}
|
|
6
|
+
export interface Ifs {
|
|
7
|
+
createReadStream: (fileName: string | Promise<string>) => Readable;
|
|
8
|
+
createWriteStream: (fileName: string | Promise<string>, options?: {
|
|
9
|
+
append: boolean;
|
|
10
|
+
ccsid?: number;
|
|
11
|
+
}) => Writable;
|
|
12
|
+
listFiles: (folderName: string) => Promise<string[]>;
|
|
13
|
+
moveFile: (fileName: string, newFileName: string) => Promise<boolean>;
|
|
14
|
+
deleteFile: (fileName: string) => Promise<boolean>;
|
|
15
|
+
fileMetadata: (fileName: string) => Promise<IfsFileMetadata>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"./ts-src/","sources":["lib/ifs/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IfsWriteStream = IfsWriteStream;
|
|
4
|
+
const util = require("util");
|
|
5
|
+
const FlushWritable = require("flushwritable");
|
|
6
|
+
function IfsWriteStream(opt) {
|
|
7
|
+
FlushWritable.call(this, {
|
|
8
|
+
objectMode: false,
|
|
9
|
+
});
|
|
10
|
+
this._ifsWriteStream = opt.ifsWriteStream;
|
|
11
|
+
this._bufferToJavaType = opt.bufferToJavaType;
|
|
12
|
+
this._buffer = [];
|
|
13
|
+
}
|
|
14
|
+
util.inherits(IfsWriteStream, FlushWritable);
|
|
15
|
+
IfsWriteStream.prototype._write = function (chunk, _, next) {
|
|
16
|
+
const writeStream = this._ifsWriteStream;
|
|
17
|
+
writeStream
|
|
18
|
+
.then((stream) => {
|
|
19
|
+
return stream.write(this._bufferToJavaType(chunk));
|
|
20
|
+
})
|
|
21
|
+
.then(() => {
|
|
22
|
+
next();
|
|
23
|
+
})
|
|
24
|
+
.catch((err) => {
|
|
25
|
+
this.emit('error', err);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
IfsWriteStream.prototype._flush = function (done) {
|
|
29
|
+
const writeStream = this._ifsWriteStream;
|
|
30
|
+
writeStream
|
|
31
|
+
.then((stream) => stream.flush())
|
|
32
|
+
.then(() => {
|
|
33
|
+
done();
|
|
34
|
+
})
|
|
35
|
+
.catch((err) => {
|
|
36
|
+
done(err);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=write_stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write_stream.js","sourceRoot":"./ts-src/","sources":["lib/ifs/write_stream.ts"],"names":[],"mappings":";;AAKA,wCAUC;AAbD,6BAA6B;AAC7B,+CAA+C;AAE/C,SAAgB,cAAc,CAAC,GAG9B;IACC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE;QACvB,UAAU,EAAE,KAAK;KAClB,CAAC,CAAA;IACF,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC,cAAc,CAAA;IACzC,IAAI,CAAC,iBAAiB,GAAG,GAAG,CAAC,gBAAgB,CAAA;IAC7C,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;AACnB,CAAC;AAED,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC,CAAA;AAE5C,cAAc,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,KAAK,EAAE,CAAC,EAAE,IAAI;IACxD,MAAM,WAAW,GAAgC,IAAI,CAAC,eAAe,CAAA;IACrE,WAAW;SACR,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACf,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAA;IACpD,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,EAAE;QACT,IAAI,EAAE,CAAA;IACR,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AAED,cAAc,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,IAAI;IAC9C,MAAM,WAAW,GAAgC,IAAI,CAAC,eAAe,CAAA;IACrE,WAAW;SACR,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;SAChC,IAAI,CAAC,GAAG,EAAE;QACT,IAAI,EAAE,CAAA;IACR,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,IAAI,CAAC,GAAG,CAAC,CAAA;IACX,CAAC,CAAC,CAAA;AACN,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JavaBridge } from '../java';
|
|
2
|
+
import { Connection } from './connection.types';
|
|
3
|
+
import { Logger } from './logger';
|
|
4
|
+
export interface InMemoryConnection extends Connection {
|
|
5
|
+
mockPgm: (programName: string, fn: (input: any) => any) => InMemoryConnection;
|
|
6
|
+
}
|
|
7
|
+
export declare function createInMemoryConnection(jt400Factory: JavaBridge, logger: Logger): InMemoryConnection;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInMemoryConnection = createInMemoryConnection;
|
|
4
|
+
const connection_1 = require("./connection");
|
|
5
|
+
const insertList_1 = require("./insertList");
|
|
6
|
+
function createInMemoryConnection(jt400Factory, logger) {
|
|
7
|
+
const javaCon = jt400Factory.createInMemoryConnection();
|
|
8
|
+
const instance = (0, connection_1.createConnection)({
|
|
9
|
+
connection: javaCon,
|
|
10
|
+
insertListFun: insertList_1.createStandardInsertList,
|
|
11
|
+
bufferToJavaType: jt400Factory.bufferToJavaType,
|
|
12
|
+
javaTypeToBuffer: jt400Factory.javaTypeToBuffer,
|
|
13
|
+
logger,
|
|
14
|
+
inMemory: true,
|
|
15
|
+
});
|
|
16
|
+
const pgmMockRegistry = {};
|
|
17
|
+
const defaultPgm = instance.defineProgram;
|
|
18
|
+
instance.defineProgram = function (opt) {
|
|
19
|
+
const defaultFunc = defaultPgm(opt);
|
|
20
|
+
return function (params, timeout = 3) {
|
|
21
|
+
const mockFunc = pgmMockRegistry[opt.programName];
|
|
22
|
+
if (mockFunc) {
|
|
23
|
+
const res = mockFunc(params, timeout);
|
|
24
|
+
return res.then ? res : Promise.resolve(res);
|
|
25
|
+
}
|
|
26
|
+
return defaultFunc(params, timeout);
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const inMemoryconnection = Object.assign(Object.assign({}, instance), { mockPgm(programName, func) {
|
|
30
|
+
pgmMockRegistry[programName] = func;
|
|
31
|
+
return inMemoryconnection;
|
|
32
|
+
} });
|
|
33
|
+
return inMemoryconnection;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=inMemoryConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inMemoryConnection.js","sourceRoot":"./ts-src/","sources":["lib/inMemoryConnection.ts"],"names":[],"mappings":";;AAUA,4DAqCC;AA9CD,6CAA+C;AAE/C,6CAAuD;AAOvD,SAAgB,wBAAwB,CACtC,YAAwB,EACxB,MAAc;IAEd,MAAM,OAAO,GAAG,YAAY,CAAC,wBAAwB,EAAE,CAAA;IACvD,MAAM,QAAQ,GAAG,IAAA,6BAAgB,EAAC;QAChC,UAAU,EAAE,OAAO;QACnB,aAAa,EAAE,qCAAwB;QACvC,gBAAgB,EAAE,YAAY,CAAC,gBAAgB;QAC/C,gBAAgB,EAAE,YAAY,CAAC,gBAAgB;QAC/C,MAAM;QACN,QAAQ,EAAE,IAAI;KACf,CAAC,CAAA;IACF,MAAM,eAAe,GAAG,EAAE,CAAA;IAE1B,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAA;IACzC,QAAQ,CAAC,aAAa,GAAG,UAAU,GAAG;QACpC,MAAM,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;QACnC,OAAO,UAAU,MAAM,EAAE,OAAO,GAAG,CAAC;YAClC,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;YAEjD,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;gBACrC,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YAC9C,CAAC;YAED,OAAO,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACrC,CAAC,CAAA;IACH,CAAC,CAAA;IACD,MAAM,kBAAkB,mCACnB,QAAQ,KACX,OAAO,CAAC,WAAW,EAAE,IAAI;YACvB,eAAe,CAAC,WAAW,CAAC,GAAG,IAAI,CAAA;YACnC,OAAO,kBAAkB,CAAA;QAC3B,CAAC,GACF,CAAA;IACD,OAAO,kBAAkB,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BaseConnection, InsertList } from './baseConnection.types';
|
|
2
|
+
export type CreateInsertList = (connection: BaseConnection) => InsertList;
|
|
3
|
+
export declare const createInsertListInOneStatment: CreateInsertList;
|
|
4
|
+
export declare const createStandardInsertList: CreateInsertList;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStandardInsertList = exports.createInsertListInOneStatment = void 0;
|
|
4
|
+
const sqlutil_1 = require("./sqlutil");
|
|
5
|
+
const createInsertListInOneStatment = (jt400) => (tableName, idColumn, list) => {
|
|
6
|
+
if (!list || list.length === 0) {
|
|
7
|
+
return Promise.resolve([]);
|
|
8
|
+
}
|
|
9
|
+
const sql = 'SELECT ' +
|
|
10
|
+
idColumn +
|
|
11
|
+
' FROM NEW TABLE(' +
|
|
12
|
+
(0, sqlutil_1.toInsertSql)(tableName, list) +
|
|
13
|
+
')';
|
|
14
|
+
const params = list.map(Object.values).reduce((arr, valueArr) => {
|
|
15
|
+
return arr.concat(valueArr);
|
|
16
|
+
}, []);
|
|
17
|
+
return jt400.query(sql, params).then((idList) => {
|
|
18
|
+
return idList.map((idObj) => idObj[idColumn.toUpperCase()]);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
exports.createInsertListInOneStatment = createInsertListInOneStatment;
|
|
22
|
+
const createStandardInsertList = (jt400) => (tableName, _, list) => {
|
|
23
|
+
const idList = [];
|
|
24
|
+
const pushToIdList = idList.push.bind(idList);
|
|
25
|
+
return list
|
|
26
|
+
.map((record) => {
|
|
27
|
+
return {
|
|
28
|
+
sql: (0, sqlutil_1.toInsertSql)(tableName, [record]),
|
|
29
|
+
values: Object.values(record),
|
|
30
|
+
};
|
|
31
|
+
})
|
|
32
|
+
.reduce((soFar, sqlObj) => {
|
|
33
|
+
return soFar
|
|
34
|
+
.then(() => {
|
|
35
|
+
return jt400.insertAndGetId(sqlObj.sql, sqlObj.values);
|
|
36
|
+
})
|
|
37
|
+
.then(pushToIdList);
|
|
38
|
+
}, Promise.resolve())
|
|
39
|
+
.then(() => {
|
|
40
|
+
return idList;
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
exports.createStandardInsertList = createStandardInsertList;
|
|
44
|
+
//# sourceMappingURL=insertList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insertList.js","sourceRoot":"./ts-src/","sources":["lib/insertList.ts"],"names":[],"mappings":";;;AACA,uCAAuC;AAGhC,MAAM,6BAA6B,GACxC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ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AAA;IACH,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,KAAK,EAAE,MAAW,EAAE,EAAE;QAC7B,OAAO,KAAK;aACT,IAAI,CAAC,GAAG,EAAE;YACT,OAAO,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QACxD,CAAC,CAAC;aACD,IAAI,CAAC,YAAY,CAAC,CAAA;IACvB,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;SACpB,IAAI,CAAC,GAAG,EAAE;QACT,OAAO,MAAM,CAAA;IACf,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AAtBU,QAAA,wBAAwB,4BAsBlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function JdbcStream(opt: any): void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JdbcStream = JdbcStream;
|
|
4
|
+
const util_1 = require("util");
|
|
5
|
+
const stream_1 = require("stream");
|
|
6
|
+
function JdbcStream(opt) {
|
|
7
|
+
stream_1.Readable.call(this, { objectMode: false });
|
|
8
|
+
this._jdbcStream = opt.jdbcStream;
|
|
9
|
+
this._jdbcStreamPromise = opt.jdbcStreamPromise;
|
|
10
|
+
}
|
|
11
|
+
(0, util_1.inherits)(JdbcStream, stream_1.Readable);
|
|
12
|
+
function read(context) {
|
|
13
|
+
if (context._closed) {
|
|
14
|
+
context._jdbcStream.close().catch((err) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
context.emit('error', err);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
context.push(null);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
context._jdbcStream
|
|
23
|
+
.read()
|
|
24
|
+
.then((res) => {
|
|
25
|
+
context.push(res);
|
|
26
|
+
})
|
|
27
|
+
.catch((err) => {
|
|
28
|
+
context.emit('error', err);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
JdbcStream.prototype.close = function () {
|
|
33
|
+
this._closed = true;
|
|
34
|
+
};
|
|
35
|
+
JdbcStream.prototype._read = function () {
|
|
36
|
+
if (!this._jdbcStream) {
|
|
37
|
+
this._jdbcStreamPromise
|
|
38
|
+
.then((stream) => {
|
|
39
|
+
this._jdbcStream = stream;
|
|
40
|
+
read(this);
|
|
41
|
+
})
|
|
42
|
+
.catch((err) => {
|
|
43
|
+
this.emit('error', err);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
read(this);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=jdbcstream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jdbcstream.js","sourceRoot":"./ts-src/","sources":["lib/jdbcstream.ts"],"names":[],"mappings":";;AAGA,gCAIC;AAPD,+BAA+B;AAC/B,mCAAiC;AAEjC,SAAgB,UAAU,CAAC,GAAG;IAC5B,iBAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAA;IAC1C,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,UAAU,CAAA;IACjC,IAAI,CAAC,kBAAkB,GAAG,GAAG,CAAC,iBAAiB,CAAA;AACjD,CAAC;AAED,IAAA,eAAQ,EAAC,UAAU,EAAE,iBAAQ,CAAC,CAAA;AAE9B,SAAS,IAAI,CAAC,OAAO;IACnB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACxC,IAAI,GAAG,EAAE,CAAC;gBACR,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;YAC5B,CAAC;QACH,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACpB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,WAAW;aAChB,IAAI,EAAE;aACN,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACnB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAC5B,CAAC,CAAC,CAAA;IACN,CAAC;AACH,CAAC;AAED,UAAU,CAAC,SAAS,CAAC,KAAK,GAAG;IAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;AACrB,CAAC,CAAA;AAED,UAAU,CAAC,SAAS,CAAC,KAAK,GAAG;IAC3B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACtB,IAAI,CAAC,kBAAkB;aACpB,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACf,IAAI,CAAC,WAAW,GAAG,MAAM,CAAA;YACzB,IAAI,CAAC,IAAI,CAAC,CAAA;QACZ,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;IACN,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,IAAI,CAAC,CAAA;IACZ,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createJdbcWriteStream(batchUpdate: any, statement: any, bufferSize: any): any;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createJdbcWriteStream = createJdbcWriteStream;
|
|
4
|
+
const FlushWritable = require("flushwritable");
|
|
5
|
+
function createJdbcWriteStream(batchUpdate, statement, bufferSize) {
|
|
6
|
+
bufferSize = bufferSize || 100;
|
|
7
|
+
let ws = new FlushWritable({ objectMode: true });
|
|
8
|
+
let dataBuffer = [];
|
|
9
|
+
function flush(done) {
|
|
10
|
+
const d = dataBuffer;
|
|
11
|
+
dataBuffer = [];
|
|
12
|
+
batchUpdate(statement, d)
|
|
13
|
+
.then(() => {
|
|
14
|
+
done();
|
|
15
|
+
})
|
|
16
|
+
.catch(done);
|
|
17
|
+
}
|
|
18
|
+
ws._write = function (chunck, _, next) {
|
|
19
|
+
dataBuffer.push(chunck);
|
|
20
|
+
if (dataBuffer.length >= bufferSize) {
|
|
21
|
+
flush(next);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
next();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
ws._flush = function (done) {
|
|
28
|
+
if (dataBuffer.length) {
|
|
29
|
+
flush(done);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
done();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return ws;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=jdbcwritestream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jdbcwritestream.js","sourceRoot":"./ts-src/","sources":["lib/jdbcwritestream.ts"],"names":[],"mappings":";;AAEA,sDAiCC;AAnCD,+CAA+C;AAE/C,SAAgB,qBAAqB,CAAC,WAAW,EAAE,SAAS,EAAE,UAAU;IACtE,UAAU,GAAG,UAAU,IAAI,GAAG,CAAA;IAC9B,IAAI,EAAE,GAAG,IAAI,aAAa,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;IAChD,IAAI,UAAU,GAAU,EAAE,CAAA;IAE1B,SAAS,KAAK,CAAC,IAAI;QACjB,MAAM,CAAC,GAAG,UAAU,CAAA;QACpB,UAAU,GAAG,EAAE,CAAA;QACf,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC;aACtB,IAAI,CAAC,GAAG,EAAE;YACT,IAAI,EAAE,CAAA;QACR,CAAC,CAAC;aACD,KAAK,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;IAED,EAAE,CAAC,MAAM,GAAG,UAAU,MAAM,EAAE,CAAC,EAAE,IAAI;QACnC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACvB,IAAI,UAAU,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;YACpC,KAAK,CAAC,IAAI,CAAC,CAAA;QACb,CAAC;aAAM,CAAC;YACN,IAAI,EAAE,CAAA;QACR,CAAC;IACH,CAAC,CAAA;IAED,EAAE,CAAC,MAAM,GAAG,UAAU,IAAI;QACxB,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACtB,KAAK,CAAC,IAAI,CAAC,CAAA;QACb,CAAC;aAAM,CAAC;YACN,IAAI,EAAE,CAAA;QACR,CAAC;IACH,CAAC,CAAA;IAED,OAAO,EAAE,CAAA;AACX,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface Logger {
|
|
2
|
+
debug: (message: any, ...args: any[]) => void;
|
|
3
|
+
info: (message: any, ...args: any[]) => void;
|
|
4
|
+
warn: (message: any, ...args: any[]) => void;
|
|
5
|
+
error: (message: any, ...args: any[]) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const createDefaultLogger: () => Logger;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDefaultLogger = void 0;
|
|
4
|
+
const createDefaultLogger = () => {
|
|
5
|
+
return {
|
|
6
|
+
debug: () => { },
|
|
7
|
+
info: () => { },
|
|
8
|
+
warn: () => { },
|
|
9
|
+
error: () => { },
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
exports.createDefaultLogger = createDefaultLogger;
|
|
13
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"./ts-src/","sources":["lib/logger.ts"],"names":[],"mappings":";;;AAOO,MAAM,mBAAmB,GAAG,GAAW,EAAE;IAE9C,OAAO;QACL,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;QACf,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;QACd,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;QACd,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;KAChB,CAAA;AACH,CAAC,CAAA;AARY,QAAA,mBAAmB,uBAQ/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toInsertSql(tableName: string, records: any[]): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toInsertSql = toInsertSql;
|
|
4
|
+
function recordToValues(record) {
|
|
5
|
+
const str = Object.keys(record)
|
|
6
|
+
.map(() => '?')
|
|
7
|
+
.join(', ');
|
|
8
|
+
return '(' + str + ')';
|
|
9
|
+
}
|
|
10
|
+
function toInsertSql(tableName, records) {
|
|
11
|
+
const first = records[0];
|
|
12
|
+
const keys = Object.keys(first);
|
|
13
|
+
const sql = `INSERT INTO ${tableName} (${keys.join(', ')}) VALUES${records
|
|
14
|
+
.map(recordToValues)
|
|
15
|
+
.join(', ')}`;
|
|
16
|
+
return sql;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=sqlutil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlutil.js","sourceRoot":"./ts-src/","sources":["lib/sqlutil.ts"],"names":[],"mappings":";;AAUA,kCAOC;AAjBD,SAAS,cAAc,CAAC,MAAM;IAC5B,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;SAC5B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC;SACd,IAAI,CAAC,IAAI,CAAC,CAAA;IACb,OAAO,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AACxB,CAAC;AAKD,SAAgB,WAAW,CAAC,SAAiB,EAAE,OAAc;IAC3D,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACxB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/B,MAAM,GAAG,GAAG,eAAe,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,OAAO;SACvE,GAAG,CAAC,cAAc,CAAC;SACnB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;IACf,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arrayToObject = arrayToObject;
|
|
4
|
+
const stream_1 = require("stream");
|
|
5
|
+
function arrayToObject(metadata) {
|
|
6
|
+
const columnNames = metadata.map((md) => md.name);
|
|
7
|
+
const transformer = new stream_1.Transform({
|
|
8
|
+
objectMode: true,
|
|
9
|
+
transform(chunk, _, callback) {
|
|
10
|
+
try {
|
|
11
|
+
if (!Array.isArray(chunk)) {
|
|
12
|
+
return callback(new Error('Expected an array chunk as input'));
|
|
13
|
+
}
|
|
14
|
+
if (chunk.length !== columnNames.length) {
|
|
15
|
+
return callback(new Error(`Array chunk length ${chunk.length} does not match columns length ${columnNames.length}`));
|
|
16
|
+
}
|
|
17
|
+
const obj = {};
|
|
18
|
+
for (let i = 0; i < columnNames.length; i++) {
|
|
19
|
+
obj[columnNames[i]] = chunk[i];
|
|
20
|
+
}
|
|
21
|
+
callback(null, obj);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
callback(err);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
return transformer;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=streamTransformers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamTransformers.js","sourceRo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