@nesgarbo/node-jt400 5.4.3 → 6.0.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/README.md +16 -6
- package/dist-cjs/index.d.cts +18 -0
- package/dist-cjs/index.js +86 -0
- package/dist-cjs/index.js.map +1 -0
- package/dist-cjs/integration-test/call-rpg-spec.d.cts +2 -0
- package/dist-cjs/integration-test/call-rpg-spec.js +101 -0
- package/dist-cjs/integration-test/call-rpg-spec.js.map +1 -0
- package/dist-cjs/integration-test/dataq-spec.d.cts +2 -0
- package/dist-cjs/integration-test/dataq-spec.js +57 -0
- package/dist-cjs/integration-test/dataq-spec.js.map +1 -0
- package/dist-cjs/integration-test/db.d.cts +8 -0
- package/dist-cjs/integration-test/db.js +31 -0
- package/dist-cjs/integration-test/db.js.map +1 -0
- package/dist-cjs/integration-test/db2-connect-spec.d.cts +2 -0
- package/dist-cjs/integration-test/db2-connect-spec.js +42 -0
- package/dist-cjs/integration-test/db2-connect-spec.js.map +1 -0
- package/dist-cjs/integration-test/db2-pool-spec.d.cts +2 -0
- package/dist-cjs/integration-test/db2-pool-spec.js +213 -0
- package/dist-cjs/integration-test/db2-pool-spec.js.map +1 -0
- package/dist-cjs/integration-test/ifs-spec.d.cts +2 -0
- package/dist-cjs/integration-test/ifs-spec.js +140 -0
- package/dist-cjs/integration-test/ifs-spec.js.map +1 -0
- package/dist-cjs/integration-test/msgf-spec.d.cts +2 -0
- package/dist-cjs/integration-test/msgf-spec.js +34 -0
- package/dist-cjs/integration-test/msgf-spec.js.map +1 -0
- package/dist-cjs/integration-test/msgq-spec.d.cts +2 -0
- package/dist-cjs/integration-test/msgq-spec.js +45 -0
- package/dist-cjs/integration-test/msgq-spec.js.map +1 -0
- package/dist-cjs/java/JT400.d.cts +79 -0
- package/dist-cjs/java/JT400.js +16 -0
- package/dist-cjs/java/JT400.js.map +1 -0
- package/dist-cjs/java/index.d.cts +10 -0
- package/dist-cjs/java/index.js +57 -0
- package/dist-cjs/java/index.js.map +1 -0
- package/dist-cjs/lib/baseConnection.d.cts +9 -0
- package/dist-cjs/lib/baseConnection.js +301 -0
- package/dist-cjs/lib/baseConnection.js.map +1 -0
- package/dist-cjs/lib/baseConnection.types.d.cts +56 -0
- package/dist-cjs/lib/baseConnection.types.js +30 -0
- package/dist-cjs/lib/baseConnection.types.js.map +1 -0
- package/dist-cjs/lib/connection.d.cts +16 -0
- package/dist-cjs/lib/connection.js +179 -0
- package/dist-cjs/lib/connection.js.map +1 -0
- package/dist-cjs/lib/connection.types.d.cts +80 -0
- package/dist-cjs/lib/connection.types.js +16 -0
- package/dist-cjs/lib/connection.types.js.map +1 -0
- package/dist-cjs/lib/handleError.d.cts +5 -0
- package/dist-cjs/lib/handleError.js +43 -0
- package/dist-cjs/lib/handleError.js.map +1 -0
- package/dist-cjs/lib/ifs/index.d.cts +7 -0
- package/dist-cjs/lib/ifs/index.js +64 -0
- package/dist-cjs/lib/ifs/index.js.map +1 -0
- package/dist-cjs/lib/ifs/read_stream.d.cts +8 -0
- package/dist-cjs/lib/ifs/read_stream.js +61 -0
- package/dist-cjs/lib/ifs/read_stream.js.map +1 -0
- package/dist-cjs/lib/ifs/types.d.cts +19 -0
- package/dist-cjs/lib/ifs/types.js +16 -0
- package/dist-cjs/lib/ifs/types.js.map +1 -0
- package/dist-cjs/lib/ifs/write_stream.d.cts +8 -0
- package/dist-cjs/lib/ifs/write_stream.js +52 -0
- package/dist-cjs/lib/ifs/write_stream.js.map +1 -0
- package/dist-cjs/lib/inMemoryConnection.d.cts +14 -0
- package/dist-cjs/lib/inMemoryConnection.js +59 -0
- package/dist-cjs/lib/inMemoryConnection.js.map +1 -0
- package/dist-cjs/lib/insertList.d.cts +8 -0
- package/dist-cjs/lib/insertList.js +58 -0
- package/dist-cjs/lib/insertList.js.map +1 -0
- package/dist-cjs/lib/jdbcstream.d.cts +3 -0
- package/dist-cjs/lib/jdbcstream.js +66 -0
- package/dist-cjs/lib/jdbcstream.js.map +1 -0
- package/dist-cjs/lib/jdbcwritestream.d.cts +3 -0
- package/dist-cjs/lib/jdbcwritestream.js +66 -0
- package/dist-cjs/lib/jdbcwritestream.js.map +1 -0
- package/dist-cjs/lib/logger.d.cts +9 -0
- package/dist-cjs/lib/logger.js +39 -0
- package/dist-cjs/lib/logger.js.map +1 -0
- package/dist-cjs/lib/sqlutil.d.cts +3 -0
- package/dist-cjs/lib/sqlutil.js +37 -0
- package/dist-cjs/lib/sqlutil.js.map +1 -0
- package/dist-cjs/lib/streamTransformers.d.cts +5 -0
- package/dist-cjs/lib/streamTransformers.js +56 -0
- package/dist-cjs/lib/streamTransformers.js.map +1 -0
- package/dist-cjs/package.json +3 -0
- package/dist-cjs/unit-test/hsql-spec.d.cts +2 -0
- package/dist-cjs/unit-test/hsql-spec.js +488 -0
- package/dist-cjs/unit-test/hsql-spec.js.map +1 -0
- package/dist-cjs/unit-test/sqlutil-spec.d.cts +2 -0
- package/dist-cjs/unit-test/sqlutil-spec.js +43 -0
- package/dist-cjs/unit-test/sqlutil-spec.js.map +1 -0
- package/dist-cjs/unit-test/streamTransformers-spec.d.cts +2 -0
- package/dist-cjs/unit-test/streamTransformers-spec.js +121 -0
- package/dist-cjs/unit-test/streamTransformers-spec.js.map +1 -0
- package/dist-esm/index.d.ts +18 -0
- package/dist-esm/index.js +59 -0
- package/dist-esm/index.js.map +1 -0
- package/dist-esm/integration-test/call-rpg-spec.d.ts +2 -0
- package/dist-esm/integration-test/call-rpg-spec.js +79 -0
- package/dist-esm/integration-test/call-rpg-spec.js.map +1 -0
- package/dist-esm/integration-test/dataq-spec.d.ts +2 -0
- package/dist-esm/integration-test/dataq-spec.js +35 -0
- package/dist-esm/integration-test/dataq-spec.js.map +1 -0
- package/dist-esm/integration-test/db.d.ts +8 -0
- package/dist-esm/integration-test/db.js +8 -0
- package/dist-esm/integration-test/db.js.map +1 -0
- package/dist-esm/integration-test/db2-connect-spec.d.ts +2 -0
- package/dist-esm/integration-test/db2-connect-spec.js +20 -0
- package/dist-esm/integration-test/db2-connect-spec.js.map +1 -0
- package/dist-esm/integration-test/db2-pool-spec.d.ts +2 -0
- package/dist-esm/integration-test/db2-pool-spec.js +197 -0
- package/dist-esm/integration-test/db2-pool-spec.js.map +1 -0
- package/dist-esm/integration-test/ifs-spec.d.ts +2 -0
- package/dist-esm/integration-test/ifs-spec.js +118 -0
- package/dist-esm/integration-test/ifs-spec.js.map +1 -0
- package/dist-esm/integration-test/msgf-spec.d.ts +2 -0
- package/dist-esm/integration-test/msgf-spec.js +12 -0
- package/dist-esm/integration-test/msgf-spec.js.map +1 -0
- package/dist-esm/integration-test/msgq-spec.d.ts +2 -0
- package/dist-esm/integration-test/msgq-spec.js +23 -0
- package/dist-esm/integration-test/msgq-spec.js.map +1 -0
- package/{dist → dist-esm}/java/JT400.d.ts +16 -14
- package/dist-esm/java/JT400.js +1 -0
- package/dist-esm/java/JT400.js.map +1 -0
- package/dist-esm/java/index.d.ts +10 -0
- package/dist-esm/java/index.js +40 -0
- package/dist-esm/java/index.js.map +1 -0
- package/dist-esm/lib/baseConnection.d.ts +9 -0
- package/dist-esm/lib/baseConnection.js +278 -0
- package/dist-esm/lib/baseConnection.js.map +1 -0
- package/dist-esm/lib/baseConnection.types.d.ts +56 -0
- package/dist-esm/lib/baseConnection.types.js +6 -0
- package/dist-esm/lib/baseConnection.types.js.map +1 -0
- package/dist-esm/lib/connection.d.ts +16 -0
- package/dist-esm/lib/connection.js +146 -0
- package/dist-esm/lib/connection.js.map +1 -0
- package/{dist → dist-esm}/lib/connection.types.d.ts +24 -21
- package/dist-esm/lib/connection.types.js +1 -0
- package/dist-esm/lib/connection.types.js.map +1 -0
- package/dist-esm/lib/handleError.d.ts +5 -0
- package/dist-esm/lib/handleError.js +20 -0
- package/dist-esm/lib/handleError.js.map +1 -0
- package/dist-esm/lib/ifs/index.d.ts +7 -0
- package/dist-esm/lib/ifs/index.js +41 -0
- package/dist-esm/lib/ifs/index.js.map +1 -0
- package/dist-esm/lib/ifs/read_stream.d.ts +8 -0
- package/dist-esm/lib/ifs/read_stream.js +28 -0
- package/dist-esm/lib/ifs/read_stream.js.map +1 -0
- package/{dist → dist-esm}/lib/ifs/types.d.ts +5 -2
- package/dist-esm/lib/ifs/types.js +1 -0
- package/dist-esm/lib/ifs/types.js.map +1 -0
- package/dist-esm/lib/ifs/write_stream.d.ts +8 -0
- package/dist-esm/lib/ifs/write_stream.js +19 -0
- package/dist-esm/lib/ifs/write_stream.js.map +1 -0
- package/dist-esm/lib/inMemoryConnection.d.ts +14 -0
- package/dist-esm/lib/inMemoryConnection.js +36 -0
- package/dist-esm/lib/inMemoryConnection.js.map +1 -0
- package/dist-esm/lib/insertList.d.ts +8 -0
- package/dist-esm/lib/insertList.js +34 -0
- package/dist-esm/lib/insertList.js.map +1 -0
- package/dist-esm/lib/jdbcstream.d.ts +3 -0
- package/dist-esm/lib/jdbcstream.js +43 -0
- package/dist-esm/lib/jdbcstream.js.map +1 -0
- package/dist-esm/lib/jdbcwritestream.d.ts +3 -0
- package/dist-esm/lib/jdbcwritestream.js +33 -0
- package/dist-esm/lib/jdbcwritestream.js.map +1 -0
- package/{dist → dist-esm}/lib/logger.d.ts +4 -2
- package/dist-esm/lib/logger.js +16 -0
- package/dist-esm/lib/logger.js.map +1 -0
- package/dist-esm/lib/sqlutil.d.ts +3 -0
- package/dist-esm/lib/sqlutil.js +14 -0
- package/dist-esm/lib/sqlutil.js.map +1 -0
- package/dist-esm/lib/streamTransformers.d.ts +5 -0
- package/dist-esm/lib/streamTransformers.js +33 -0
- package/dist-esm/lib/streamTransformers.js.map +1 -0
- package/dist-esm/package.json +3 -0
- package/dist-esm/unit-test/hsql-spec.d.ts +2 -0
- package/dist-esm/unit-test/hsql-spec.js +466 -0
- package/dist-esm/unit-test/hsql-spec.js.map +1 -0
- package/dist-esm/unit-test/sqlutil-spec.d.ts +2 -0
- package/dist-esm/unit-test/sqlutil-spec.js +21 -0
- package/dist-esm/unit-test/sqlutil-spec.js.map +1 -0
- package/dist-esm/unit-test/streamTransformers-spec.d.ts +2 -0
- package/dist-esm/unit-test/streamTransformers-spec.js +99 -0
- package/dist-esm/unit-test/streamTransformers-spec.js.map +1 -0
- package/java/lib/jt400wrap.jar +0 -0
- package/package.json +39 -19
- package/dist/index.d.ts +0 -13
- package/dist/index.js +0 -67
- package/dist/index.js.map +0 -1
- package/dist/integration-test/call-rpg-spec.d.ts +0 -1
- package/dist/integration-test/call-rpg-spec.js +0 -88
- package/dist/integration-test/call-rpg-spec.js.map +0 -1
- package/dist/integration-test/dataq-spec.d.ts +0 -1
- package/dist/integration-test/dataq-spec.js +0 -42
- package/dist/integration-test/dataq-spec.js.map +0 -1
- package/dist/integration-test/db.d.ts +0 -2
- package/dist/integration-test/db.js +0 -8
- package/dist/integration-test/db.js.map +0 -1
- package/dist/integration-test/db2-connect-spec.d.ts +0 -1
- package/dist/integration-test/db2-connect-spec.js +0 -34
- package/dist/integration-test/db2-connect-spec.js.map +0 -1
- package/dist/integration-test/db2-pool-spec.d.ts +0 -1
- package/dist/integration-test/db2-pool-spec.js +0 -191
- package/dist/integration-test/db2-pool-spec.js.map +0 -1
- package/dist/integration-test/ifs-spec.d.ts +0 -1
- package/dist/integration-test/ifs-spec.js +0 -118
- package/dist/integration-test/ifs-spec.js.map +0 -1
- package/dist/integration-test/msgf-spec.d.ts +0 -1
- package/dist/integration-test/msgf-spec.js +0 -25
- package/dist/integration-test/msgf-spec.js.map +0 -1
- package/dist/integration-test/msgq-spec.d.ts +0 -1
- package/dist/integration-test/msgq-spec.js +0 -34
- package/dist/integration-test/msgq-spec.js.map +0 -1
- package/dist/java/JT400.js +0 -3
- package/dist/java/JT400.js.map +0 -1
- package/dist/java/index.d.ts +0 -7
- package/dist/java/index.js +0 -33
- package/dist/java/index.js.map +0 -1
- package/dist/lib/baseConnection.d.ts +0 -5
- package/dist/lib/baseConnection.js +0 -264
- package/dist/lib/baseConnection.js.map +0 -1
- package/dist/lib/baseConnection.types.d.ts +0 -53
- package/dist/lib/baseConnection.types.js +0 -7
- package/dist/lib/baseConnection.types.js.map +0 -1
- package/dist/lib/connection.d.ts +0 -10
- package/dist/lib/connection.js +0 -143
- package/dist/lib/connection.js.map +0 -1
- package/dist/lib/connection.types.js +0 -3
- package/dist/lib/connection.types.js.map +0 -1
- package/dist/lib/handleError.d.ts +0 -3
- package/dist/lib/handleError.js +0 -25
- package/dist/lib/handleError.js.map +0 -1
- package/dist/lib/ifs/index.d.ts +0 -3
- package/dist/lib/ifs/index.js +0 -45
- package/dist/lib/ifs/index.js.map +0 -1
- package/dist/lib/ifs/read_stream.d.ts +0 -6
- package/dist/lib/ifs/read_stream.js +0 -28
- package/dist/lib/ifs/read_stream.js.map +0 -1
- package/dist/lib/ifs/types.js +0 -3
- package/dist/lib/ifs/types.js.map +0 -1
- package/dist/lib/ifs/write_stream.d.ts +0 -6
- package/dist/lib/ifs/write_stream.js +0 -25
- package/dist/lib/ifs/write_stream.js.map +0 -1
- package/dist/lib/inMemoryConnection.d.ts +0 -7
- package/dist/lib/inMemoryConnection.js +0 -33
- package/dist/lib/inMemoryConnection.js.map +0 -1
- package/dist/lib/insertList.d.ts +0 -4
- package/dist/lib/insertList.js +0 -44
- package/dist/lib/insertList.js.map +0 -1
- package/dist/lib/jdbcstream.d.ts +0 -1
- package/dist/lib/jdbcstream.js +0 -50
- package/dist/lib/jdbcstream.js.map +0 -1
- package/dist/lib/jdbcwritestream.d.ts +0 -1
- package/dist/lib/jdbcwritestream.js +0 -37
- package/dist/lib/jdbcwritestream.js.map +0 -1
- package/dist/lib/logger.js +0 -13
- package/dist/lib/logger.js.map +0 -1
- package/dist/lib/sqlutil.d.ts +0 -1
- package/dist/lib/sqlutil.js +0 -18
- package/dist/lib/sqlutil.js.map +0 -1
- package/dist/lib/streamTransformers.d.ts +0 -2
- package/dist/lib/streamTransformers.js +0 -30
- package/dist/lib/streamTransformers.js.map +0 -1
- package/dist/unit-test/hsql-spec.d.ts +0 -1
- package/dist/unit-test/hsql-spec.js +0 -495
- package/dist/unit-test/hsql-spec.js.map +0 -1
- package/dist/unit-test/sqlutil-spec.d.ts +0 -1
- package/dist/unit-test/sqlutil-spec.js +0 -20
- package/dist/unit-test/sqlutil-spec.js.map +0 -1
- package/dist/unit-test/streamTransformers-spec.d.ts +0 -1
- package/dist/unit-test/streamTransformers-spec.js +0 -98
- package/dist/unit-test/streamTransformers-spec.js.map +0 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var connection_exports = {};
|
|
29
|
+
__export(connection_exports, {
|
|
30
|
+
createConnection: () => createConnection
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(connection_exports);
|
|
33
|
+
var import_util = require("util");
|
|
34
|
+
var import_baseConnection = require("./baseConnection");
|
|
35
|
+
var import_handleError = require("./handleError.js");
|
|
36
|
+
var import_ifs = require("./ifs/index.js");
|
|
37
|
+
var import_jdbcstream = require("./jdbcstream.js");
|
|
38
|
+
var import_JSONStream = __toESM(require("JSONStream"), 1);
|
|
39
|
+
const isJustNameMessageQ = function(opt) {
|
|
40
|
+
return opt.name !== void 0;
|
|
41
|
+
};
|
|
42
|
+
function createConnection({
|
|
43
|
+
connection,
|
|
44
|
+
insertListFun,
|
|
45
|
+
inMemory,
|
|
46
|
+
logger
|
|
47
|
+
}) {
|
|
48
|
+
const baseConnection = (0, import_baseConnection.createBaseConnection)(
|
|
49
|
+
connection,
|
|
50
|
+
insertListFun,
|
|
51
|
+
logger,
|
|
52
|
+
inMemory
|
|
53
|
+
);
|
|
54
|
+
const jt400 = {
|
|
55
|
+
...baseConnection,
|
|
56
|
+
async transaction(transactionFunction) {
|
|
57
|
+
const t = connection.createTransactionSync();
|
|
58
|
+
const transactionContext = (0, import_baseConnection.createBaseConnection)(
|
|
59
|
+
t,
|
|
60
|
+
insertListFun,
|
|
61
|
+
logger,
|
|
62
|
+
inMemory
|
|
63
|
+
);
|
|
64
|
+
try {
|
|
65
|
+
const res = await transactionFunction(transactionContext);
|
|
66
|
+
await t.commit();
|
|
67
|
+
return res;
|
|
68
|
+
} catch (err) {
|
|
69
|
+
await t.rollback();
|
|
70
|
+
throw err;
|
|
71
|
+
} finally {
|
|
72
|
+
await t.end();
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
getTablesAsStream(opt) {
|
|
76
|
+
return new import_jdbcstream.JdbcStream({
|
|
77
|
+
jdbcStream: connection.getTablesAsStreamSync(
|
|
78
|
+
opt.catalog,
|
|
79
|
+
opt.schema,
|
|
80
|
+
opt.table || "%"
|
|
81
|
+
)
|
|
82
|
+
}).pipe(import_JSONStream.default.parse([true]));
|
|
83
|
+
},
|
|
84
|
+
getColumns(opt) {
|
|
85
|
+
return connection.getColumns(opt.catalog, opt.schema, opt.table, opt.columns || "%").then(JSON.parse);
|
|
86
|
+
},
|
|
87
|
+
getPrimaryKeys(opt) {
|
|
88
|
+
return connection.getPrimaryKeys(opt.catalog, opt.schema, opt.table).then(JSON.parse);
|
|
89
|
+
},
|
|
90
|
+
async openMessageQ(opt) {
|
|
91
|
+
const hasPath = !isJustNameMessageQ(opt);
|
|
92
|
+
const name = isJustNameMessageQ(opt) ? opt.name : opt.path;
|
|
93
|
+
const dq = await connection.openMessageQ(name, hasPath);
|
|
94
|
+
return {
|
|
95
|
+
// write (key, data) {
|
|
96
|
+
// dq.writeSync(key, data);
|
|
97
|
+
// },
|
|
98
|
+
read() {
|
|
99
|
+
let wait = -1;
|
|
100
|
+
if (arguments[0] === Object(arguments[0])) {
|
|
101
|
+
wait = arguments[0].wait || wait;
|
|
102
|
+
}
|
|
103
|
+
return dq.read(wait);
|
|
104
|
+
},
|
|
105
|
+
sendInformational(messageText) {
|
|
106
|
+
return dq.sendInformational(messageText);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
createKeyedDataQ(opt) {
|
|
111
|
+
const dq = connection.createKeyedDataQSync(opt.name);
|
|
112
|
+
const readRes = async function(key, wait, writeKeyLength) {
|
|
113
|
+
const res = await dq.readResponse(key, wait, writeKeyLength);
|
|
114
|
+
const data = await res.getData();
|
|
115
|
+
return {
|
|
116
|
+
data,
|
|
117
|
+
write: (data2) => res.write(data2)
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
return {
|
|
121
|
+
write(key, data) {
|
|
122
|
+
return dq.write(key, data);
|
|
123
|
+
},
|
|
124
|
+
read() {
|
|
125
|
+
let wait = -1;
|
|
126
|
+
let key;
|
|
127
|
+
let writeKeyLength;
|
|
128
|
+
if (arguments[0] === Object(arguments[0])) {
|
|
129
|
+
key = arguments[0].key;
|
|
130
|
+
wait = arguments[0].wait || wait;
|
|
131
|
+
writeKeyLength = arguments[0].writeKeyLength;
|
|
132
|
+
} else {
|
|
133
|
+
key = arguments[0];
|
|
134
|
+
}
|
|
135
|
+
return writeKeyLength ? readRes(key, wait, writeKeyLength) : dq.read(key, wait);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
async openMessageFile(opt) {
|
|
140
|
+
const messageFile = await connection.openMessageFile(opt.path);
|
|
141
|
+
return {
|
|
142
|
+
read() {
|
|
143
|
+
const messageId = arguments[0].messageId;
|
|
144
|
+
return messageFile.read(messageId);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
},
|
|
148
|
+
ifs() {
|
|
149
|
+
return (0, import_ifs.ifs)(connection);
|
|
150
|
+
},
|
|
151
|
+
defineProgram(opt) {
|
|
152
|
+
const pgm = connection.pgmSync(
|
|
153
|
+
opt.programName,
|
|
154
|
+
JSON.stringify(opt.paramsSchema),
|
|
155
|
+
opt.libraryName || "*LIBL",
|
|
156
|
+
opt.ccsid
|
|
157
|
+
);
|
|
158
|
+
return function run(params, timeout = 3) {
|
|
159
|
+
return pgm.run(JSON.stringify(params), timeout).then(JSON.parse).catch((0, import_handleError.handleError)({ programName: opt.programName, params, timeout }));
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
pgm: (0, import_util.deprecate)(function(programName, paramsSchema, libraryName) {
|
|
163
|
+
return this.defineProgram({
|
|
164
|
+
programName,
|
|
165
|
+
paramsSchema,
|
|
166
|
+
libraryName
|
|
167
|
+
});
|
|
168
|
+
}, "pgm function is deprecated and will be removed in version 5.0. Please use defineProgram."),
|
|
169
|
+
close() {
|
|
170
|
+
return connection.close();
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
return jt400;
|
|
174
|
+
}
|
|
175
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
176
|
+
0 && (module.exports = {
|
|
177
|
+
createConnection
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../ts-src/lib/connection.ts"],"sourcesContent":["import { deprecate } from 'util'\nimport { JT400 } from '../java/JT400'\nimport { createBaseConnection } from './baseConnection'\nimport {\n Connection,\n JustNameMessageQ,\n MessageFileHandlerOptions,\n MessageQOptions,\n ProgramDefinitionOptions,\n} from './connection.types.js'\nimport { handleError } from './handleError.js'\nimport { ifs as createIfs } from './ifs/index.js'\nimport { CreateInsertList } from './insertList.js'\nimport { JdbcStream } from './jdbcstream.js'\nimport JSONStream from 'JSONStream'\nimport { Logger } from './logger.js'\n\nconst isJustNameMessageQ = function (\n opt: MessageQOptions,\n): opt is JustNameMessageQ {\n return (opt as JustNameMessageQ).name !== undefined\n}\n\nexport function createConnection({\n connection,\n insertListFun,\n inMemory,\n logger,\n}: {\n connection: JT400\n insertListFun: CreateInsertList\n inMemory: boolean\n logger: Logger\n}): Connection {\n const baseConnection = createBaseConnection(\n connection,\n insertListFun,\n logger,\n inMemory,\n )\n const jt400: Connection = {\n ...baseConnection,\n async transaction(transactionFunction) {\n const t = connection.createTransactionSync()\n const transactionContext = createBaseConnection(\n t,\n insertListFun,\n logger,\n inMemory,\n )\n\n try {\n const res = await transactionFunction(transactionContext)\n await t.commit()\n return res\n } catch (err) {\n await t.rollback()\n throw err\n } finally {\n await t.end()\n }\n },\n getTablesAsStream(opt) {\n return new JdbcStream({\n jdbcStream: connection.getTablesAsStreamSync(\n opt.catalog,\n opt.schema,\n opt.table || '%',\n ),\n }).pipe(JSONStream.parse([true]))\n },\n getColumns(opt) {\n return connection\n .getColumns(opt.catalog, opt.schema, opt.table, opt.columns || '%')\n .then(JSON.parse)\n },\n getPrimaryKeys(opt) {\n return connection\n .getPrimaryKeys(opt.catalog, opt.schema, opt.table)\n .then(JSON.parse)\n },\n async openMessageQ(opt) {\n const hasPath = !isJustNameMessageQ(opt)\n const name = isJustNameMessageQ(opt) ? opt.name : opt.path\n const dq = await connection.openMessageQ(name, hasPath)\n return {\n // write (key, data) {\n // \tdq.writeSync(key, data);\n // },\n read() {\n let wait = -1\n if (arguments[0] === Object(arguments[0])) {\n wait = arguments[0].wait || wait\n }\n return dq.read(wait)\n },\n sendInformational(messageText) {\n return dq.sendInformational(messageText)\n },\n }\n },\n createKeyedDataQ(opt) {\n const dq = connection.createKeyedDataQSync(opt.name)\n const readRes = async function (key, wait, writeKeyLength) {\n const res = await dq.readResponse(key, wait, writeKeyLength)\n const data = await res.getData()\n return {\n data,\n write: (data: string) => res.write(data),\n }\n }\n return {\n write(key, data) {\n return dq.write(key, data)\n },\n read() {\n let wait = -1\n let key: string\n let writeKeyLength\n if (arguments[0] === Object(arguments[0])) {\n key = arguments[0].key\n wait = arguments[0].wait || wait\n writeKeyLength = arguments[0].writeKeyLength\n } else {\n key = arguments[0]\n }\n return writeKeyLength\n ? readRes(key, wait, writeKeyLength)\n : dq.read(key, wait)\n },\n }\n },\n async openMessageFile(opt: MessageFileHandlerOptions) {\n const messageFile = await connection.openMessageFile(opt.path)\n return {\n read() {\n const messageId = arguments[0].messageId\n return messageFile.read(messageId)\n },\n }\n },\n ifs() {\n return createIfs(connection)\n },\n defineProgram(opt: ProgramDefinitionOptions) {\n const pgm = connection.pgmSync(\n opt.programName,\n JSON.stringify(opt.paramsSchema),\n opt.libraryName || '*LIBL',\n opt.ccsid,\n )\n return function run(params, timeout = 3) {\n return pgm\n .run(JSON.stringify(params), timeout)\n .then(JSON.parse)\n .catch(handleError({ programName: opt.programName, params, timeout }))\n }\n },\n pgm: deprecate(function (programName, paramsSchema, libraryName) {\n return this.defineProgram({\n programName,\n paramsSchema,\n libraryName,\n })\n }, 'pgm function is deprecated and will be removed in version 5.0. Please use defineProgram.'),\n close() {\n return connection.close()\n },\n }\n\n return jt400\n}\n"],"mappings":"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","names":["JSONStream","data","createIfs"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
import { BaseConnection, Close } from './baseConnection.types.cjs';
|
|
3
|
+
import { Ifs } from './ifs/types.cjs';
|
|
4
|
+
|
|
5
|
+
interface ProgramDefinitionOptions {
|
|
6
|
+
programName: string;
|
|
7
|
+
paramsSchema: PgmParamType[];
|
|
8
|
+
libraryName?: string;
|
|
9
|
+
ccsid?: number;
|
|
10
|
+
}
|
|
11
|
+
interface PgmParamType1 {
|
|
12
|
+
name: string;
|
|
13
|
+
size: number;
|
|
14
|
+
type?: string;
|
|
15
|
+
decimals?: number;
|
|
16
|
+
}
|
|
17
|
+
interface PgmParamType2 {
|
|
18
|
+
name: string;
|
|
19
|
+
precision: number;
|
|
20
|
+
typeName?: string;
|
|
21
|
+
scale?: number;
|
|
22
|
+
}
|
|
23
|
+
interface PgmParamStructType {
|
|
24
|
+
[key: string]: PgmParamType[];
|
|
25
|
+
}
|
|
26
|
+
type PgmParamType = PgmParamType1 | PgmParamType2 | PgmParamStructType;
|
|
27
|
+
interface JustNameMessageQ {
|
|
28
|
+
name: string;
|
|
29
|
+
}
|
|
30
|
+
interface JustPathMessageQ {
|
|
31
|
+
path: string;
|
|
32
|
+
}
|
|
33
|
+
type MessageQOptions = JustNameMessageQ | JustPathMessageQ;
|
|
34
|
+
interface MessageQReadOptions {
|
|
35
|
+
wait?: number;
|
|
36
|
+
}
|
|
37
|
+
interface DataQReadOptions {
|
|
38
|
+
key: string;
|
|
39
|
+
wait?: number;
|
|
40
|
+
writeKeyLength?: number;
|
|
41
|
+
}
|
|
42
|
+
interface MessageFileHandlerOptions {
|
|
43
|
+
path: string;
|
|
44
|
+
}
|
|
45
|
+
interface MessageFileReadOptions {
|
|
46
|
+
messageId: string[7];
|
|
47
|
+
}
|
|
48
|
+
interface MessageQ {
|
|
49
|
+
sendInformational: (messageText: string) => Promise<void>;
|
|
50
|
+
read: (params?: MessageQReadOptions) => Promise<any> | Promise<null>;
|
|
51
|
+
}
|
|
52
|
+
interface DataQOptions {
|
|
53
|
+
name: string;
|
|
54
|
+
}
|
|
55
|
+
interface KeyedDataQ {
|
|
56
|
+
write: (key: string, data: string) => void;
|
|
57
|
+
read: (params: DataQReadOptions | string) => Promise<any>;
|
|
58
|
+
}
|
|
59
|
+
interface AS400Message {
|
|
60
|
+
getText: () => Promise<string>;
|
|
61
|
+
}
|
|
62
|
+
interface MessageFileHandler {
|
|
63
|
+
read: (params: MessageFileReadOptions) => Promise<AS400Message>;
|
|
64
|
+
}
|
|
65
|
+
type TransactionFun = (transaction: BaseConnection) => Promise<any>;
|
|
66
|
+
interface Connection extends BaseConnection {
|
|
67
|
+
pgm: (programName: string, paramsSchema: PgmParamType[], libraryName?: string) => any;
|
|
68
|
+
defineProgram: (options: ProgramDefinitionOptions) => any;
|
|
69
|
+
getTablesAsStream: (params: any) => Readable;
|
|
70
|
+
getColumns: (params: any) => any;
|
|
71
|
+
getPrimaryKeys: (params: any) => any;
|
|
72
|
+
transaction: (fn: TransactionFun) => Promise<any>;
|
|
73
|
+
openMessageQ: (params: MessageQOptions) => Promise<MessageQ>;
|
|
74
|
+
createKeyedDataQ: (params: DataQOptions) => KeyedDataQ;
|
|
75
|
+
openMessageFile: (params: MessageFileHandlerOptions) => Promise<MessageFileHandler>;
|
|
76
|
+
ifs: () => Ifs;
|
|
77
|
+
close: Close;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type { AS400Message, Connection, DataQOptions, DataQReadOptions, JustNameMessageQ, JustPathMessageQ, KeyedDataQ, MessageFileHandler, MessageFileHandlerOptions, MessageFileReadOptions, MessageQ, MessageQOptions, MessageQReadOptions, PgmParamStructType, PgmParamType, PgmParamType1, PgmParamType2, ProgramDefinitionOptions, TransactionFun };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var connection_types_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(connection_types_exports);
|
|
16
|
+
//# sourceMappingURL=connection.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../ts-src/lib/connection.types.ts"],"sourcesContent":["import { Readable } from 'stream'\nimport { BaseConnection, Close } from './baseConnection.types.js'\nimport { Ifs } from './ifs/types.js'\n\nexport interface ProgramDefinitionOptions {\n programName: string\n paramsSchema: PgmParamType[]\n libraryName?: string\n ccsid?: number\n}\n\nexport interface PgmParamType1 {\n name: string\n size: number\n type?: string\n decimals?: number\n}\n\nexport interface PgmParamType2 {\n name: string\n precision: number\n typeName?: string\n scale?: number\n}\n\nexport interface PgmParamStructType {\n [key: string]: PgmParamType[]\n}\n\nexport type PgmParamType = PgmParamType1 | PgmParamType2 | PgmParamStructType\n\nexport interface JustNameMessageQ {\n name: string\n}\nexport interface JustPathMessageQ {\n path: string\n}\nexport type MessageQOptions = JustNameMessageQ | JustPathMessageQ\n\nexport interface MessageQReadOptions {\n wait?: number\n}\n\nexport interface DataQReadOptions {\n key: string\n wait?: number\n writeKeyLength?: number\n}\nexport interface MessageFileHandlerOptions {\n /** Message File Location, e.g. /QSYS.LIB/YOURLIBRARY.LIB/YOURMSGFILE.MSGF */\n path: string\n}\nexport interface MessageFileReadOptions {\n /** Message Key */\n messageId: string[7]\n}\n\nexport interface MessageQ {\n sendInformational: (messageText: string) => Promise<void>\n read: (params?: MessageQReadOptions) => Promise<any> | Promise<null>\n}\n\nexport interface DataQOptions {\n name: string\n}\nexport interface KeyedDataQ {\n write: (key: string, data: string) => void\n read: (params: DataQReadOptions | string) => Promise<any>\n}\n\nexport interface AS400Message {\n getText: () => Promise<string>\n}\n\nexport interface MessageFileHandler {\n read: (params: MessageFileReadOptions) => Promise<AS400Message>\n}\n\nexport type TransactionFun = (transaction: BaseConnection) => Promise<any>\n\nexport interface Connection extends BaseConnection {\n pgm: (\n programName: string,\n paramsSchema: PgmParamType[],\n libraryName?: string,\n ) => any\n defineProgram: (options: ProgramDefinitionOptions) => any\n getTablesAsStream: (params: any) => Readable\n getColumns: (params: any) => any\n getPrimaryKeys: (params: any) => any\n transaction: (fn: TransactionFun) => Promise<any>\n openMessageQ: (params: MessageQOptions) => Promise<MessageQ>\n createKeyedDataQ: (params: DataQOptions) => KeyedDataQ\n openMessageFile: (\n params: MessageFileHandlerOptions,\n ) => Promise<MessageFileHandler>\n ifs: () => Ifs\n close: Close\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var handleError_exports = {};
|
|
19
|
+
__export(handleError_exports, {
|
|
20
|
+
handleError: () => handleError
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(handleError_exports);
|
|
23
|
+
var import_oops_error = require("oops-error");
|
|
24
|
+
function handleError(context) {
|
|
25
|
+
return (err) => {
|
|
26
|
+
const errMsg = err.cause && err.cause.getMessageSync && err.cause.getMessageSync() || err.getMessageSync && err.getMessageSync() || err.message;
|
|
27
|
+
const start = errMsg.indexOf(": ");
|
|
28
|
+
const end = errMsg.indexOf("\n");
|
|
29
|
+
const message = start > 0 && end > 0 ? errMsg.slice(start + 2, end) : errMsg;
|
|
30
|
+
const category = message.toLowerCase().includes("connection") || errMsg.includes("java.net.UnknownHostException") ? "OperationalError" : "ProgrammerError";
|
|
31
|
+
throw new import_oops_error.Oops({
|
|
32
|
+
message,
|
|
33
|
+
context,
|
|
34
|
+
category,
|
|
35
|
+
cause: err
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
handleError
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=handleError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../ts-src/lib/handleError.ts"],"sourcesContent":["import { Oops } from 'oops-error'\n\nexport function handleError(context: { [key: string]: any }) {\n return (err: any) => {\n const errMsg =\n (err.cause && err.cause.getMessageSync && err.cause.getMessageSync()) ||\n (err.getMessageSync && err.getMessageSync()) ||\n err.message\n const start = errMsg.indexOf(': ')\n const end = errMsg.indexOf('\\n')\n const message = start > 0 && end > 0 ? errMsg.slice(start + 2, end) : errMsg\n const category =\n message.toLowerCase().includes('connection') ||\n errMsg.includes('java.net.UnknownHostException')\n ? 'OperationalError'\n : 'ProgrammerError'\n throw new Oops({\n message,\n context,\n category,\n cause: err,\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAqB;AAEd,SAAS,YAAY,SAAiC;AAC3D,SAAO,CAAC,QAAa;AACnB,UAAM,SACH,IAAI,SAAS,IAAI,MAAM,kBAAkB,IAAI,MAAM,eAAe,KAClE,IAAI,kBAAkB,IAAI,eAAe,KAC1C,IAAI;AACN,UAAM,QAAQ,OAAO,QAAQ,IAAI;AACjC,UAAM,MAAM,OAAO,QAAQ,IAAI;AAC/B,UAAM,UAAU,QAAQ,KAAK,MAAM,IAAI,OAAO,MAAM,QAAQ,GAAG,GAAG,IAAI;AACtE,UAAM,WACJ,QAAQ,YAAY,EAAE,SAAS,YAAY,KAC3C,OAAO,SAAS,+BAA+B,IAC3C,qBACA;AACN,UAAM,IAAI,uBAAK;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var ifs_exports = {};
|
|
19
|
+
__export(ifs_exports, {
|
|
20
|
+
ifs: () => ifs
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(ifs_exports);
|
|
23
|
+
var import_path = require("path");
|
|
24
|
+
var import_read_stream = require("./read_stream");
|
|
25
|
+
var import_write_stream = require("./write_stream");
|
|
26
|
+
function ifs(connection) {
|
|
27
|
+
return {
|
|
28
|
+
createReadStream: function(fileName) {
|
|
29
|
+
const javaStream = Promise.resolve(fileName).then(function(file) {
|
|
30
|
+
return connection.createIfsReadStream(file);
|
|
31
|
+
});
|
|
32
|
+
return new import_read_stream.IfsReadStream({
|
|
33
|
+
ifsReadStream: javaStream
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
createWriteStream: function(fileName, options = { append: false }) {
|
|
37
|
+
const javaStream = Promise.resolve(fileName).then(function(file) {
|
|
38
|
+
const folderPath = (0, import_path.dirname)(file);
|
|
39
|
+
const fileName2 = (0, import_path.basename)(file);
|
|
40
|
+
return connection.createIfsWriteStream(
|
|
41
|
+
folderPath,
|
|
42
|
+
fileName2,
|
|
43
|
+
options.append,
|
|
44
|
+
options.ccsid
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
return new import_write_stream.IfsWriteStream({
|
|
48
|
+
ifsWriteStream: javaStream
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
listFiles: async (folderName) => {
|
|
52
|
+
const files = await connection.listIfsFiles(folderName);
|
|
53
|
+
return files || [];
|
|
54
|
+
},
|
|
55
|
+
moveFile: (fileName, newFileName) => connection.moveIfsFile(fileName, newFileName),
|
|
56
|
+
deleteFile: (fileName) => connection.deleteIfsFile(fileName),
|
|
57
|
+
fileMetadata: (fileName) => connection.getIfsFileMetadata(fileName).then(JSON.parse)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
ifs
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../ts-src/lib/ifs/index.ts"],"sourcesContent":["import { basename, dirname } from 'path'\nimport { JT400 } from '../../java/JT400'\nimport { IfsReadStream } from './read_stream'\nimport { Ifs } from './types'\nimport { IfsWriteStream } from './write_stream'\n\nexport function ifs(\n connection: JT400,\n): Ifs {\n return {\n createReadStream: function (fileName: string | Promise<string>) {\n const javaStream = Promise.resolve(fileName).then(function (file) {\n return connection.createIfsReadStream(file)\n })\n return new IfsReadStream({\n ifsReadStream: javaStream\n })\n },\n createWriteStream: function (\n fileName: string | Promise<string>,\n options: { append: boolean; ccsid?: number } = { append: false },\n ) {\n const javaStream = Promise.resolve(fileName).then(function (file) {\n const folderPath = dirname(file)\n const fileName = basename(file)\n return connection.createIfsWriteStream(\n folderPath,\n fileName,\n options.append,\n options.ccsid,\n )\n })\n return new IfsWriteStream({\n ifsWriteStream: javaStream\n })\n },\n listFiles: async (folderName: string) => {\n const files = await connection.listIfsFiles(folderName)\n return files || []\n },\n moveFile: (fileName: string, newFileName: string) =>\n connection.moveIfsFile(fileName, newFileName),\n deleteFile: (fileName: string) => connection.deleteIfsFile(fileName),\n fileMetadata: (fileName: string) =>\n connection.getIfsFileMetadata(fileName).then(JSON.parse),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAkC;AAElC,yBAA8B;AAE9B,0BAA+B;AAExB,SAAS,IACd,YACK;AACL,SAAO;AAAA,IACL,kBAAkB,SAAU,UAAoC;AAC9D,YAAM,aAAa,QAAQ,QAAQ,QAAQ,EAAE,KAAK,SAAU,MAAM;AAChE,eAAO,WAAW,oBAAoB,IAAI;AAAA,MAC5C,CAAC;AACD,aAAO,IAAI,iCAAc;AAAA,QACvB,eAAe;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,IACA,mBAAmB,SACjB,UACA,UAA+C,EAAE,QAAQ,MAAM,GAC/D;AACA,YAAM,aAAa,QAAQ,QAAQ,QAAQ,EAAE,KAAK,SAAU,MAAM;AAChE,cAAM,iBAAa,qBAAQ,IAAI;AAC/B,cAAMA,gBAAW,sBAAS,IAAI;AAC9B,eAAO,WAAW;AAAA,UAChB;AAAA,UACAA;AAAA,UACA,QAAQ;AAAA,UACR,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AACD,aAAO,IAAI,mCAAe;AAAA,QACxB,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH;AAAA,IACA,WAAW,OAAO,eAAuB;AACvC,YAAM,QAAQ,MAAM,WAAW,aAAa,UAAU;AACtD,aAAO,SAAS,CAAC;AAAA,IACnB;AAAA,IACA,UAAU,CAAC,UAAkB,gBAC3B,WAAW,YAAY,UAAU,WAAW;AAAA,IAC9C,YAAY,CAAC,aAAqB,WAAW,cAAc,QAAQ;AAAA,IACnE,cAAc,CAAC,aACb,WAAW,mBAAmB,QAAQ,EAAE,KAAK,KAAK,KAAK;AAAA,EAC3D;AACF;","names":["fileName"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var read_stream_exports = {};
|
|
29
|
+
__export(read_stream_exports, {
|
|
30
|
+
IfsReadStream: () => IfsReadStream
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(read_stream_exports);
|
|
33
|
+
var import_util = __toESM(require("util"), 1);
|
|
34
|
+
var import_stream = require("stream");
|
|
35
|
+
function IfsReadStream(opt) {
|
|
36
|
+
import_stream.Readable.call(this, { objectMode: false });
|
|
37
|
+
this._ifsReadStream = opt.ifsReadStream;
|
|
38
|
+
}
|
|
39
|
+
import_util.default.inherits(IfsReadStream, import_stream.Readable);
|
|
40
|
+
IfsReadStream.prototype._read = function() {
|
|
41
|
+
const streamPromise = this._ifsReadStream;
|
|
42
|
+
streamPromise.then(
|
|
43
|
+
(stream) => stream.read().then((res) => {
|
|
44
|
+
if (res == null) {
|
|
45
|
+
this.push(null);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const buf = Buffer.isBuffer(res) ? res : res instanceof Uint8Array ? Buffer.from(res) : Buffer.from(res);
|
|
49
|
+
if (buf.length === 0) {
|
|
50
|
+
this.push(null);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.push(buf);
|
|
54
|
+
})
|
|
55
|
+
).catch((err) => this.emit("error", err));
|
|
56
|
+
};
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
IfsReadStream
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=read_stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../ts-src/lib/ifs/read_stream.ts"],"sourcesContent":["import util from 'util'\nimport { Readable } from 'stream'\nimport { IfsReadStream as IfsReadStreamType } from '../../java/JT400'\n\ntype Opt = {\n ifsReadStream: Promise<IfsReadStreamType>\n}\n\nexport function IfsReadStream(opt: Opt) {\n Readable.call(this, { objectMode: false })\n this._ifsReadStream = opt.ifsReadStream\n}\n\nutil.inherits(IfsReadStream, Readable)\n\nIfsReadStream.prototype._read = function () {\n const streamPromise: Promise<IfsReadStreamType> = this._ifsReadStream\n streamPromise\n .then((stream) =>\n stream.read().then((res: any) => {\n // java-bridge convierte byte[] -> Buffer automáticamente\n if (res == null) {\n this.push(null) // EOF\n return\n }\n\n const buf =\n Buffer.isBuffer(res) ? res : res instanceof Uint8Array ? Buffer.from(res) : Buffer.from(res as any)\n\n if (buf.length === 0) {\n this.push(null) // EOF defensivo si llega vacío\n return\n }\n\n this.push(buf)\n }),\n )\n .catch((err: any) => this.emit('error', err))\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,oBAAyB;AAOlB,SAAS,cAAc,KAAU;AACtC,yBAAS,KAAK,MAAM,EAAE,YAAY,MAAM,CAAC;AACzC,OAAK,iBAAiB,IAAI;AAC5B;AAEA,YAAAA,QAAK,SAAS,eAAe,sBAAQ;AAErC,cAAc,UAAU,QAAQ,WAAY;AAC1C,QAAM,gBAA4C,KAAK;AACvD,gBACG;AAAA,IAAK,CAAC,WACL,OAAO,KAAK,EAAE,KAAK,CAAC,QAAa;AAE/B,UAAI,OAAO,MAAM;AACf,aAAK,KAAK,IAAI;AACd;AAAA,MACF;AAEA,YAAM,MACJ,OAAO,SAAS,GAAG,IAAI,MAAM,eAAe,aAAa,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,GAAU;AAEpG,UAAI,IAAI,WAAW,GAAG;AACpB,aAAK,KAAK,IAAI;AACd;AAAA,MACF;AAEA,WAAK,KAAK,GAAG;AAAA,IACf,CAAC;AAAA,EACH,EACC,MAAM,CAAC,QAAa,KAAK,KAAK,SAAS,GAAG,CAAC;AAChD;","names":["util"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Readable, Writable } from 'stream';
|
|
2
|
+
|
|
3
|
+
interface IfsFileMetadata {
|
|
4
|
+
exists: boolean;
|
|
5
|
+
length: number;
|
|
6
|
+
}
|
|
7
|
+
interface Ifs {
|
|
8
|
+
createReadStream: (fileName: string | Promise<string>) => Readable;
|
|
9
|
+
createWriteStream: (fileName: string | Promise<string>, options?: {
|
|
10
|
+
append: boolean;
|
|
11
|
+
ccsid?: number;
|
|
12
|
+
}) => Writable;
|
|
13
|
+
listFiles: (folderName: string) => Promise<string[]>;
|
|
14
|
+
moveFile: (fileName: string, newFileName: string) => Promise<boolean>;
|
|
15
|
+
deleteFile: (fileName: string) => Promise<boolean>;
|
|
16
|
+
fileMetadata: (fileName: string) => Promise<IfsFileMetadata>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type { Ifs, IfsFileMetadata };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var types_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(types_exports);
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../ts-src/lib/ifs/types.ts"],"sourcesContent":["import { Readable, Writable } from 'stream'\n\nexport interface IfsFileMetadata {\n exists: boolean\n length: number\n}\n\nexport interface Ifs {\n createReadStream: (fileName: string | Promise<string>) => Readable\n createWriteStream: (\n fileName: string | Promise<string>,\n options?: { append: boolean; ccsid?: number },\n ) => Writable\n listFiles: (folderName: string) => Promise<string[]>\n moveFile: (fileName: string, newFileName: string) => Promise<boolean>\n deleteFile: (fileName: string) => Promise<boolean>\n fileMetadata: (fileName: string) => Promise<IfsFileMetadata>\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var write_stream_exports = {};
|
|
29
|
+
__export(write_stream_exports, {
|
|
30
|
+
IfsWriteStream: () => IfsWriteStream
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(write_stream_exports);
|
|
33
|
+
var import_util = __toESM(require("util"), 1);
|
|
34
|
+
var import_flushwritable = __toESM(require("flushwritable"), 1);
|
|
35
|
+
function IfsWriteStream(opt) {
|
|
36
|
+
import_flushwritable.default.call(this, { objectMode: false });
|
|
37
|
+
this._ifsWriteStream = opt.ifsWriteStream;
|
|
38
|
+
}
|
|
39
|
+
import_util.default.inherits(IfsWriteStream, import_flushwritable.default);
|
|
40
|
+
IfsWriteStream.prototype._write = function(chunk, _, next) {
|
|
41
|
+
const writeStream = this._ifsWriteStream;
|
|
42
|
+
writeStream.then((stream) => stream.write(chunk)).then(() => next()).catch((err) => this.emit("error", err));
|
|
43
|
+
};
|
|
44
|
+
IfsWriteStream.prototype._flush = function(done) {
|
|
45
|
+
const writeStream = this._ifsWriteStream;
|
|
46
|
+
writeStream.then((stream) => stream.flush()).then(() => done()).catch((err) => done(err));
|
|
47
|
+
};
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
IfsWriteStream
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=write_stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../ts-src/lib/ifs/write_stream.ts"],"sourcesContent":["import { IfsWriteStream as IfsWriteStreamType } from '../../java/JT400.js'\nimport util from 'util'\nimport FlushWritable from 'flushwritable'\n\ntype Opt = {\n ifsWriteStream: Promise<IfsWriteStreamType>\n}\n\nexport function IfsWriteStream(opt: Opt) {\n FlushWritable.call(this, { objectMode: false })\n this._ifsWriteStream = opt.ifsWriteStream\n}\n\nutil.inherits(IfsWriteStream, FlushWritable)\n\nIfsWriteStream.prototype._write = function (\n chunk: Buffer,\n _: any,\n next: (err?: any) => void,\n) {\n const writeStream: Promise<IfsWriteStreamType> = this._ifsWriteStream\n writeStream\n .then((stream) => stream.write(chunk)) // Buffer -> byte[] (auto por java-bridge)\n .then(() => next())\n .catch((err) => this.emit('error', err))\n}\n\nIfsWriteStream.prototype._flush = function (done: (err?: any) => void) {\n const writeStream: Promise<IfsWriteStreamType> = this._ifsWriteStream\n writeStream\n .then((stream) => stream.flush())\n .then(() => done())\n .catch((err) => done(err))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAiB;AACjB,2BAA0B;AAMnB,SAAS,eAAe,KAAU;AACvC,uBAAAA,QAAc,KAAK,MAAM,EAAE,YAAY,MAAM,CAAC;AAC9C,OAAK,kBAAkB,IAAI;AAC7B;AAEA,YAAAC,QAAK,SAAS,gBAAgB,qBAAAD,OAAa;AAE3C,eAAe,UAAU,SAAS,SAChC,OACA,GACA,MACA;AACA,QAAM,cAA2C,KAAK;AACtD,cACG,KAAK,CAAC,WAAW,OAAO,MAAM,KAAK,CAAC,EACpC,KAAK,MAAM,KAAK,CAAC,EACjB,MAAM,CAAC,QAAQ,KAAK,KAAK,SAAS,GAAG,CAAC;AAC3C;AAEA,eAAe,UAAU,SAAS,SAAU,MAA2B;AACrE,QAAM,cAA2C,KAAK;AACtD,cACG,KAAK,CAAC,WAAW,OAAO,MAAM,CAAC,EAC/B,KAAK,MAAM,KAAK,CAAC,EACjB,MAAM,CAAC,QAAQ,KAAK,GAAG,CAAC;AAC7B;","names":["FlushWritable","util"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JavaBridge } from '../java/index.cjs';
|
|
2
|
+
import { Connection } from './connection.types.cjs';
|
|
3
|
+
import { Logger } from './logger.cjs';
|
|
4
|
+
import '../java/JT400.cjs';
|
|
5
|
+
import 'stream';
|
|
6
|
+
import './baseConnection.types.cjs';
|
|
7
|
+
import './ifs/types.cjs';
|
|
8
|
+
|
|
9
|
+
interface InMemoryConnection extends Connection {
|
|
10
|
+
mockPgm: (programName: string, fn: (input: any) => any) => InMemoryConnection;
|
|
11
|
+
}
|
|
12
|
+
declare function createInMemoryConnection(jt400Factory: JavaBridge, logger: Logger): InMemoryConnection;
|
|
13
|
+
|
|
14
|
+
export { type InMemoryConnection, createInMemoryConnection };
|