@nesgarbo/node-jt400 5.4.3 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +88 -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 +67 -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 +367 -0
- package/dist-cjs/lib/baseConnection.js.map +1 -0
- package/dist-cjs/lib/baseConnection.types.d.cts +62 -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 +25 -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 +344 -0
- package/dist-esm/lib/baseConnection.js.map +1 -0
- package/dist-esm/lib/baseConnection.types.d.ts +62 -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,59 @@
|
|
|
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 inMemoryConnection_exports = {};
|
|
19
|
+
__export(inMemoryConnection_exports, {
|
|
20
|
+
createInMemoryConnection: () => createInMemoryConnection
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(inMemoryConnection_exports);
|
|
23
|
+
var import_connection = require("./connection.js");
|
|
24
|
+
var import_insertList = require("./insertList.js");
|
|
25
|
+
function createInMemoryConnection(jt400Factory, logger) {
|
|
26
|
+
const javaCon = jt400Factory.createInMemoryConnection();
|
|
27
|
+
const instance = (0, import_connection.createConnection)({
|
|
28
|
+
connection: javaCon,
|
|
29
|
+
insertListFun: import_insertList.createStandardInsertList,
|
|
30
|
+
logger,
|
|
31
|
+
inMemory: true
|
|
32
|
+
});
|
|
33
|
+
const pgmMockRegistry = {};
|
|
34
|
+
const defaultPgm = instance.defineProgram;
|
|
35
|
+
instance.defineProgram = function(opt) {
|
|
36
|
+
const defaultFunc = defaultPgm(opt);
|
|
37
|
+
return function(params, timeout = 3) {
|
|
38
|
+
const mockFunc = pgmMockRegistry[opt.programName];
|
|
39
|
+
if (mockFunc) {
|
|
40
|
+
const res = mockFunc(params, timeout);
|
|
41
|
+
return res.then ? res : Promise.resolve(res);
|
|
42
|
+
}
|
|
43
|
+
return defaultFunc(params, timeout);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const inMemoryconnection = {
|
|
47
|
+
...instance,
|
|
48
|
+
mockPgm(programName, func) {
|
|
49
|
+
pgmMockRegistry[programName] = func;
|
|
50
|
+
return inMemoryconnection;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return inMemoryconnection;
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
createInMemoryConnection
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=inMemoryConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../ts-src/lib/inMemoryConnection.ts"],"sourcesContent":["import { JavaBridge } from '../java/index.js'\nimport { createConnection } from './connection.js'\nimport { Connection } from './connection.types.js'\nimport { createStandardInsertList } from './insertList.js'\nimport { Logger } from './logger.js'\n\nexport interface InMemoryConnection extends Connection {\n mockPgm: (programName: string, fn: (input: any) => any) => InMemoryConnection\n}\n\nexport function createInMemoryConnection(\n jt400Factory: JavaBridge,\n logger: Logger,\n): InMemoryConnection {\n const javaCon = jt400Factory.createInMemoryConnection()\n const instance = createConnection({\n connection: javaCon,\n insertListFun: createStandardInsertList,\n logger,\n inMemory: true,\n })\n const pgmMockRegistry = {}\n\n const defaultPgm = instance.defineProgram\n instance.defineProgram = function (opt) {\n const defaultFunc = defaultPgm(opt)\n return function (params, timeout = 3) {\n const mockFunc = pgmMockRegistry[opt.programName]\n\n if (mockFunc) {\n const res = mockFunc(params, timeout)\n return res.then ? res : Promise.resolve(res)\n }\n\n return defaultFunc(params, timeout)\n }\n }\n const inMemoryconnection: InMemoryConnection = {\n ...instance,\n mockPgm(programName, func) {\n pgmMockRegistry[programName] = func\n return inMemoryconnection\n },\n }\n return inMemoryconnection\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAAiC;AAEjC,wBAAyC;AAOlC,SAAS,yBACd,cACA,QACoB;AACpB,QAAM,UAAU,aAAa,yBAAyB;AACtD,QAAM,eAAW,oCAAiB;AAAA,IAChC,YAAY;AAAA,IACZ,eAAe;AAAA,IACf;AAAA,IACA,UAAU;AAAA,EACZ,CAAC;AACD,QAAM,kBAAkB,CAAC;AAEzB,QAAM,aAAa,SAAS;AAC5B,WAAS,gBAAgB,SAAU,KAAK;AACtC,UAAM,cAAc,WAAW,GAAG;AAClC,WAAO,SAAU,QAAQ,UAAU,GAAG;AACpC,YAAM,WAAW,gBAAgB,IAAI,WAAW;AAEhD,UAAI,UAAU;AACZ,cAAM,MAAM,SAAS,QAAQ,OAAO;AACpC,eAAO,IAAI,OAAO,MAAM,QAAQ,QAAQ,GAAG;AAAA,MAC7C;AAEA,aAAO,YAAY,QAAQ,OAAO;AAAA,IACpC;AAAA,EACF;AACA,QAAM,qBAAyC;AAAA,IAC7C,GAAG;AAAA,IACH,QAAQ,aAAa,MAAM;AACzB,sBAAgB,WAAW,IAAI;AAC/B,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseConnection, InsertList } from './baseConnection.types.cjs';
|
|
2
|
+
import 'stream';
|
|
3
|
+
|
|
4
|
+
type CreateInsertList = (connection: BaseConnection) => InsertList;
|
|
5
|
+
declare const createInsertListInOneStatment: CreateInsertList;
|
|
6
|
+
declare const createStandardInsertList: CreateInsertList;
|
|
7
|
+
|
|
8
|
+
export { type CreateInsertList, createInsertListInOneStatment, createStandardInsertList };
|
|
@@ -0,0 +1,58 @@
|
|
|
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 insertList_exports = {};
|
|
19
|
+
__export(insertList_exports, {
|
|
20
|
+
createInsertListInOneStatment: () => createInsertListInOneStatment,
|
|
21
|
+
createStandardInsertList: () => createStandardInsertList
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(insertList_exports);
|
|
24
|
+
var import_sqlutil = require("./sqlutil.js");
|
|
25
|
+
const createInsertListInOneStatment = (jt400) => (tableName, idColumn, list) => {
|
|
26
|
+
if (!list || list.length === 0) {
|
|
27
|
+
return Promise.resolve([]);
|
|
28
|
+
}
|
|
29
|
+
const sql = "SELECT " + idColumn + " FROM NEW TABLE(" + (0, import_sqlutil.toInsertSql)(tableName, list) + ")";
|
|
30
|
+
const params = list.map(Object.values).reduce((arr, valueArr) => {
|
|
31
|
+
return arr.concat(valueArr);
|
|
32
|
+
}, []);
|
|
33
|
+
return jt400.query(sql, params).then((idList) => {
|
|
34
|
+
return idList.map((idObj) => idObj[idColumn.toUpperCase()]);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const createStandardInsertList = (jt400) => (tableName, _, list) => {
|
|
38
|
+
const idList = [];
|
|
39
|
+
const pushToIdList = idList.push.bind(idList);
|
|
40
|
+
return list.map((record) => {
|
|
41
|
+
return {
|
|
42
|
+
sql: (0, import_sqlutil.toInsertSql)(tableName, [record]),
|
|
43
|
+
values: Object.values(record)
|
|
44
|
+
};
|
|
45
|
+
}).reduce((soFar, sqlObj) => {
|
|
46
|
+
return soFar.then(() => {
|
|
47
|
+
return jt400.insertAndGetId(sqlObj.sql, sqlObj.values);
|
|
48
|
+
}).then(pushToIdList);
|
|
49
|
+
}, Promise.resolve()).then(() => {
|
|
50
|
+
return idList;
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
createInsertListInOneStatment,
|
|
56
|
+
createStandardInsertList
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=insertList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../ts-src/lib/insertList.ts"],"sourcesContent":["import { BaseConnection, InsertList } from './baseConnection.types.js'\nimport { toInsertSql } from './sqlutil.js'\n\nexport type CreateInsertList = (connection: BaseConnection) => InsertList\nexport const createInsertListInOneStatment: CreateInsertList =\n (jt400) => (tableName, idColumn, list) => {\n if (!list || list.length === 0) {\n return Promise.resolve([])\n }\n const sql =\n 'SELECT ' +\n idColumn +\n ' FROM NEW TABLE(' +\n toInsertSql(tableName, list) +\n ')'\n const params = list.map(Object.values).reduce((arr, valueArr) => {\n return arr.concat(valueArr)\n }, [])\n\n return jt400.query<any>(sql, params).then((idList) => {\n return idList.map((idObj) => idObj[idColumn.toUpperCase()])\n })\n }\n\nexport const createStandardInsertList: CreateInsertList =\n (jt400) => (tableName, _, list) => {\n const idList = []\n const pushToIdList = idList.push.bind(idList)\n\n return list\n .map((record) => {\n return {\n sql: toInsertSql(tableName, [record]),\n values: Object.values(record),\n }\n })\n .reduce((soFar, sqlObj: any) => {\n return soFar\n .then(() => {\n return jt400.insertAndGetId(sqlObj.sql, sqlObj.values)\n })\n .then(pushToIdList)\n }, Promise.resolve())\n .then(() => {\n return idList\n })\n }\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAA4B;AAGrB,MAAM,gCACX,CAAC,UAAU,CAAC,WAAW,UAAU,SAAS;AACxC,MAAI,CAAC,QAAQ,KAAK,WAAW,GAAG;AAC9B,WAAO,QAAQ,QAAQ,CAAC,CAAC;AAAA,EAC3B;AACA,QAAM,MACJ,YACA,WACA,yBACA,4BAAY,WAAW,IAAI,IAC3B;AACF,QAAM,SAAS,KAAK,IAAI,OAAO,MAAM,EAAE,OAAO,CAAC,KAAK,aAAa;AAC/D,WAAO,IAAI,OAAO,QAAQ;AAAA,EAC5B,GAAG,CAAC,CAAC;AAEL,SAAO,MAAM,MAAW,KAAK,MAAM,EAAE,KAAK,CAAC,WAAW;AACpD,WAAO,OAAO,IAAI,CAAC,UAAU,MAAM,SAAS,YAAY,CAAC,CAAC;AAAA,EAC5D,CAAC;AACH;AAEK,MAAM,2BACX,CAAC,UAAU,CAAC,WAAW,GAAG,SAAS;AACjC,QAAM,SAAS,CAAC;AAChB,QAAM,eAAe,OAAO,KAAK,KAAK,MAAM;AAE5C,SAAO,KACJ,IAAI,CAAC,WAAW;AACf,WAAO;AAAA,MACL,SAAK,4BAAY,WAAW,CAAC,MAAM,CAAC;AAAA,MACpC,QAAQ,OAAO,OAAO,MAAM;AAAA,IAC9B;AAAA,EACF,CAAC,EACA,OAAO,CAAC,OAAO,WAAgB;AAC9B,WAAO,MACJ,KAAK,MAAM;AACV,aAAO,MAAM,eAAe,OAAO,KAAK,OAAO,MAAM;AAAA,IACvD,CAAC,EACA,KAAK,YAAY;AAAA,EACtB,GAAG,QAAQ,QAAQ,CAAC,EACnB,KAAK,MAAM;AACV,WAAO;AAAA,EACT,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 jdbcstream_exports = {};
|
|
19
|
+
__export(jdbcstream_exports, {
|
|
20
|
+
JdbcStream: () => JdbcStream
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(jdbcstream_exports);
|
|
23
|
+
var import_util = require("util");
|
|
24
|
+
var import_stream = require("stream");
|
|
25
|
+
function JdbcStream(opt) {
|
|
26
|
+
import_stream.Readable.call(this, { objectMode: false });
|
|
27
|
+
this._jdbcStream = opt.jdbcStream;
|
|
28
|
+
this._jdbcStreamPromise = opt.jdbcStreamPromise;
|
|
29
|
+
}
|
|
30
|
+
(0, import_util.inherits)(JdbcStream, import_stream.Readable);
|
|
31
|
+
function read(context) {
|
|
32
|
+
if (context._closed) {
|
|
33
|
+
context._jdbcStream.close().catch((err) => {
|
|
34
|
+
if (err) {
|
|
35
|
+
context.emit("error", err);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
context.push(null);
|
|
39
|
+
} else {
|
|
40
|
+
context._jdbcStream.read().then((res) => {
|
|
41
|
+
context.push(res);
|
|
42
|
+
}).catch((err) => {
|
|
43
|
+
context.emit("error", err);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
JdbcStream.prototype.close = function() {
|
|
48
|
+
this._closed = true;
|
|
49
|
+
};
|
|
50
|
+
JdbcStream.prototype._read = function() {
|
|
51
|
+
if (!this._jdbcStream) {
|
|
52
|
+
this._jdbcStreamPromise.then((stream) => {
|
|
53
|
+
this._jdbcStream = stream;
|
|
54
|
+
read(this);
|
|
55
|
+
}).catch((err) => {
|
|
56
|
+
this.emit("error", err);
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
read(this);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
JdbcStream
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=jdbcstream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../ts-src/lib/jdbcstream.ts"],"sourcesContent":["import { inherits } from 'util'\nimport { Readable } from 'stream'\n\nexport function JdbcStream(opt) {\n Readable.call(this, { objectMode: false })\n this._jdbcStream = opt.jdbcStream\n this._jdbcStreamPromise = opt.jdbcStreamPromise\n}\n\ninherits(JdbcStream, Readable)\n\nfunction read(context) {\n if (context._closed) {\n context._jdbcStream.close().catch((err) => {\n if (err) {\n context.emit('error', err)\n }\n })\n context.push(null)\n } else {\n context._jdbcStream\n .read()\n .then((res) => {\n context.push(res)\n })\n .catch((err) => {\n context.emit('error', err)\n })\n }\n}\n\nJdbcStream.prototype.close = function () {\n this._closed = true\n}\n\nJdbcStream.prototype._read = function () {\n if (!this._jdbcStream) {\n this._jdbcStreamPromise\n .then((stream) => {\n this._jdbcStream = stream\n read(this)\n })\n .catch((err) => {\n this.emit('error', err)\n })\n } else {\n read(this)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AACzB,oBAAyB;AAElB,SAAS,WAAW,KAAK;AAC9B,yBAAS,KAAK,MAAM,EAAE,YAAY,MAAM,CAAC;AACzC,OAAK,cAAc,IAAI;AACvB,OAAK,qBAAqB,IAAI;AAChC;AAAA,IAEA,sBAAS,YAAY,sBAAQ;AAE7B,SAAS,KAAK,SAAS;AACrB,MAAI,QAAQ,SAAS;AACnB,YAAQ,YAAY,MAAM,EAAE,MAAM,CAAC,QAAQ;AACzC,UAAI,KAAK;AACP,gBAAQ,KAAK,SAAS,GAAG;AAAA,MAC3B;AAAA,IACF,CAAC;AACD,YAAQ,KAAK,IAAI;AAAA,EACnB,OAAO;AACL,YAAQ,YACL,KAAK,EACL,KAAK,CAAC,QAAQ;AACb,cAAQ,KAAK,GAAG;AAAA,IAClB,CAAC,EACA,MAAM,CAAC,QAAQ;AACd,cAAQ,KAAK,SAAS,GAAG;AAAA,IAC3B,CAAC;AAAA,EACL;AACF;AAEA,WAAW,UAAU,QAAQ,WAAY;AACvC,OAAK,UAAU;AACjB;AAEA,WAAW,UAAU,QAAQ,WAAY;AACvC,MAAI,CAAC,KAAK,aAAa;AACrB,SAAK,mBACF,KAAK,CAAC,WAAW;AAChB,WAAK,cAAc;AACnB,WAAK,IAAI;AAAA,IACX,CAAC,EACA,MAAM,CAAC,QAAQ;AACd,WAAK,KAAK,SAAS,GAAG;AAAA,IACxB,CAAC;AAAA,EACL,OAAO;AACL,SAAK,IAAI;AAAA,EACX;AACF;","names":[]}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 jdbcwritestream_exports = {};
|
|
29
|
+
__export(jdbcwritestream_exports, {
|
|
30
|
+
createJdbcWriteStream: () => createJdbcWriteStream
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(jdbcwritestream_exports);
|
|
33
|
+
var import_flushwritable = __toESM(require("flushwritable"), 1);
|
|
34
|
+
function createJdbcWriteStream(batchUpdate, statement, bufferSize) {
|
|
35
|
+
bufferSize = bufferSize || 100;
|
|
36
|
+
const ws = new import_flushwritable.default({ objectMode: true });
|
|
37
|
+
let dataBuffer = [];
|
|
38
|
+
function flush(done) {
|
|
39
|
+
const d = dataBuffer;
|
|
40
|
+
dataBuffer = [];
|
|
41
|
+
batchUpdate(statement, d).then(() => {
|
|
42
|
+
done();
|
|
43
|
+
}).catch(done);
|
|
44
|
+
}
|
|
45
|
+
ws._write = function(chunck, _, next) {
|
|
46
|
+
dataBuffer.push(chunck);
|
|
47
|
+
if (dataBuffer.length >= bufferSize) {
|
|
48
|
+
flush(next);
|
|
49
|
+
} else {
|
|
50
|
+
next();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
ws._flush = function(done) {
|
|
54
|
+
if (dataBuffer.length) {
|
|
55
|
+
flush(done);
|
|
56
|
+
} else {
|
|
57
|
+
done();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return ws;
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
createJdbcWriteStream
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=jdbcwritestream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../ts-src/lib/jdbcwritestream.ts"],"sourcesContent":["import FlushWritable from 'flushwritable'\n\nexport function createJdbcWriteStream(batchUpdate, statement, bufferSize) {\n bufferSize = bufferSize || 100\n const ws = new FlushWritable({ objectMode: true })\n let dataBuffer: any[] = []\n\n function flush(done) {\n const d = dataBuffer\n dataBuffer = []\n batchUpdate(statement, d)\n .then(() => {\n done()\n })\n .catch(done)\n }\n\n ws._write = function (chunck, _, next) {\n dataBuffer.push(chunck)\n if (dataBuffer.length >= bufferSize) {\n flush(next)\n } else {\n next()\n }\n }\n\n ws._flush = function (done) {\n if (dataBuffer.length) {\n flush(done)\n } else {\n done()\n }\n }\n\n return ws\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAA0B;AAEnB,SAAS,sBAAsB,aAAa,WAAW,YAAY;AACxE,eAAa,cAAc;AAC3B,QAAM,KAAK,IAAI,qBAAAA,QAAc,EAAE,YAAY,KAAK,CAAC;AACjD,MAAI,aAAoB,CAAC;AAEzB,WAAS,MAAM,MAAM;AACnB,UAAM,IAAI;AACV,iBAAa,CAAC;AACd,gBAAY,WAAW,CAAC,EACrB,KAAK,MAAM;AACV,WAAK;AAAA,IACP,CAAC,EACA,MAAM,IAAI;AAAA,EACf;AAEA,KAAG,SAAS,SAAU,QAAQ,GAAG,MAAM;AACrC,eAAW,KAAK,MAAM;AACtB,QAAI,WAAW,UAAU,YAAY;AACnC,YAAM,IAAI;AAAA,IACZ,OAAO;AACL,WAAK;AAAA,IACP;AAAA,EACF;AAEA,KAAG,SAAS,SAAU,MAAM;AAC1B,QAAI,WAAW,QAAQ;AACrB,YAAM,IAAI;AAAA,IACZ,OAAO;AACL,WAAK;AAAA,IACP;AAAA,EACF;AAEA,SAAO;AACT;","names":["FlushWritable"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
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
|
+
declare const createDefaultLogger: () => Logger;
|
|
8
|
+
|
|
9
|
+
export { type Logger, createDefaultLogger };
|
|
@@ -0,0 +1,39 @@
|
|
|
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 logger_exports = {};
|
|
19
|
+
__export(logger_exports, {
|
|
20
|
+
createDefaultLogger: () => createDefaultLogger
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(logger_exports);
|
|
23
|
+
const createDefaultLogger = () => {
|
|
24
|
+
return {
|
|
25
|
+
debug: () => {
|
|
26
|
+
},
|
|
27
|
+
info: () => {
|
|
28
|
+
},
|
|
29
|
+
warn: () => {
|
|
30
|
+
},
|
|
31
|
+
error: () => {
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
createDefaultLogger
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../ts-src/lib/logger.ts"],"sourcesContent":["export interface Logger {\n debug: (message: any, ...args: any[]) => void\n info: (message: any, ...args: any[]) => void\n warn: (message: any, ...args: any[]) => void\n error: (message: any, ...args: any[]) => void\n}\n\nexport const createDefaultLogger = (): Logger => {\n // Default logger that does nothing\n return {\n debug: () => {},\n info: () => {},\n warn: () => {},\n error: () => {},\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,MAAM,sBAAsB,MAAc;AAE/C,SAAO;AAAA,IACL,OAAO,MAAM;AAAA,IAAC;AAAA,IACd,MAAM,MAAM;AAAA,IAAC;AAAA,IACb,MAAM,MAAM;AAAA,IAAC;AAAA,IACb,OAAO,MAAM;AAAA,IAAC;AAAA,EAChB;AACF;","names":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 sqlutil_exports = {};
|
|
19
|
+
__export(sqlutil_exports, {
|
|
20
|
+
toInsertSql: () => toInsertSql
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(sqlutil_exports);
|
|
23
|
+
function recordToValues(record) {
|
|
24
|
+
const str = Object.keys(record).map(() => "?").join(", ");
|
|
25
|
+
return "(" + str + ")";
|
|
26
|
+
}
|
|
27
|
+
function toInsertSql(tableName, records) {
|
|
28
|
+
const first = records[0];
|
|
29
|
+
const keys = Object.keys(first);
|
|
30
|
+
const sql = `INSERT INTO ${tableName} (${keys.join(", ")}) VALUES${records.map(recordToValues).join(", ")}`;
|
|
31
|
+
return sql;
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
toInsertSql
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=sqlutil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../ts-src/lib/sqlutil.ts"],"sourcesContent":["function recordToValues(record) {\n const str = Object.keys(record)\n .map(() => '?')\n .join(', ')\n return '(' + str + ')'\n}\n\n/**\n * Returns insert statement for records\n */\nexport function toInsertSql(tableName: string, records: any[]): string {\n const first = records[0]\n const keys = Object.keys(first)\n const sql = `INSERT INTO ${tableName} (${keys.join(', ')}) VALUES${records\n .map(recordToValues)\n .join(', ')}`\n return sql\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,eAAe,QAAQ;AAC9B,QAAM,MAAM,OAAO,KAAK,MAAM,EAC3B,IAAI,MAAM,GAAG,EACb,KAAK,IAAI;AACZ,SAAO,MAAM,MAAM;AACrB;AAKO,SAAS,YAAY,WAAmB,SAAwB;AACrE,QAAM,QAAQ,QAAQ,CAAC;AACvB,QAAM,OAAO,OAAO,KAAK,KAAK;AAC9B,QAAM,MAAM,eAAe,SAAS,KAAK,KAAK,KAAK,IAAI,CAAC,WAAW,QAChE,IAAI,cAAc,EAClB,KAAK,IAAI,CAAC;AACb,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 streamTransformers_exports = {};
|
|
19
|
+
__export(streamTransformers_exports, {
|
|
20
|
+
arrayToObject: () => arrayToObject
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(streamTransformers_exports);
|
|
23
|
+
var import_stream = require("stream");
|
|
24
|
+
function arrayToObject(metadata) {
|
|
25
|
+
const columnNames = metadata.map((md) => md.name);
|
|
26
|
+
const transformer = new import_stream.Transform({
|
|
27
|
+
objectMode: true,
|
|
28
|
+
transform(chunk, _, callback) {
|
|
29
|
+
try {
|
|
30
|
+
if (!Array.isArray(chunk)) {
|
|
31
|
+
return callback(new Error("Expected an array chunk as input"));
|
|
32
|
+
}
|
|
33
|
+
if (chunk.length !== columnNames.length) {
|
|
34
|
+
return callback(
|
|
35
|
+
new Error(
|
|
36
|
+
`Array chunk length ${chunk.length} does not match columns length ${columnNames.length}`
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
const obj = {};
|
|
41
|
+
for (let i = 0; i < columnNames.length; i++) {
|
|
42
|
+
obj[columnNames[i]] = chunk[i];
|
|
43
|
+
}
|
|
44
|
+
callback(null, obj);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
callback(err);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return transformer;
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
arrayToObject
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=streamTransformers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../ts-src/lib/streamTransformers.ts"],"sourcesContent":["import { Transform } from 'stream'\n\nexport function arrayToObject(metadata) {\n const columnNames = metadata.map((md) => md.name)\n\n const transformer = new Transform({\n objectMode: true,\n transform(chunk, _, callback) {\n try {\n if (!Array.isArray(chunk)) {\n return callback(new Error('Expected an array chunk as input'))\n }\n\n if (chunk.length !== columnNames.length) {\n return callback(\n new Error(\n `Array chunk length ${chunk.length} does not match columns length ${columnNames.length}`,\n ),\n )\n }\n\n const obj = {}\n for (let i = 0; i < columnNames.length; i++) {\n obj[columnNames[i]] = chunk[i]\n }\n\n callback(null, obj)\n } catch (err) {\n callback(err)\n }\n },\n })\n\n return transformer\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0B;AAEnB,SAAS,cAAc,UAAU;AACtC,QAAM,cAAc,SAAS,IAAI,CAAC,OAAO,GAAG,IAAI;AAEhD,QAAM,cAAc,IAAI,wBAAU;AAAA,IAChC,YAAY;AAAA,IACZ,UAAU,OAAO,GAAG,UAAU;AAC5B,UAAI;AACF,YAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,iBAAO,SAAS,IAAI,MAAM,kCAAkC,CAAC;AAAA,QAC/D;AAEA,YAAI,MAAM,WAAW,YAAY,QAAQ;AACvC,iBAAO;AAAA,YACL,IAAI;AAAA,cACF,sBAAsB,MAAM,MAAM,kCAAkC,YAAY,MAAM;AAAA,YACxF;AAAA,UACF;AAAA,QACF;AAEA,cAAM,MAAM,CAAC;AACb,iBAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;AAC3C,cAAI,YAAY,CAAC,CAAC,IAAI,MAAM,CAAC;AAAA,QAC/B;AAEA,iBAAS,MAAM,GAAG;AAAA,MACpB,SAAS,KAAK;AACZ,iBAAS,GAAG;AAAA,MACd;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
|