hana-kgvector 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/dist/Stream-JW2S2DUH.js +0 -6
- package/dist/Stream-JW2S2DUH.js.map +0 -1
- package/dist/chunk-I3F3SOHM.js +0 -726
- package/dist/chunk-I3F3SOHM.js.map +0 -1
- package/dist/chunk-VUNV25KB.js +0 -16
- package/dist/chunk-VUNV25KB.js.map +0 -1
- package/dist/lib-J24D2XQX.js +0 -1256
- package/dist/lib-J24D2XQX.js.map +0 -1
package/dist/chunk-I3F3SOHM.js
DELETED
|
@@ -1,726 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__commonJS,
|
|
3
|
-
__require
|
|
4
|
-
} from "./chunk-VUNV25KB.js";
|
|
5
|
-
|
|
6
|
-
// node_modules/.pnpm/@sap+hana-client@2.27.19/node_modules/@sap/hana-client/extension/Stream.js
|
|
7
|
-
var require_Stream = __commonJS({
|
|
8
|
-
"node_modules/.pnpm/@sap+hana-client@2.27.19/node_modules/@sap/hana-client/extension/Stream.js"(exports, module) {
|
|
9
|
-
module.exports = {
|
|
10
|
-
// Create an readable stream which returns object
|
|
11
|
-
createObjectStream: function(resultset) {
|
|
12
|
-
return new HanaRSStream(resultset, false);
|
|
13
|
-
},
|
|
14
|
-
// Create an readable stream which returns array
|
|
15
|
-
createArrayStream: function(resultset) {
|
|
16
|
-
return new HanaRSStream(resultset, true);
|
|
17
|
-
},
|
|
18
|
-
// Create a LOB stream
|
|
19
|
-
createLobStream: function(resultset, columnIndex, options) {
|
|
20
|
-
return new HanaLobStream(resultset, columnIndex, options);
|
|
21
|
-
},
|
|
22
|
-
// Create a LOB stream for a LOB output parameter
|
|
23
|
-
createParameterLobStream: function(statement, paramIndex, options) {
|
|
24
|
-
return new HanaParameterLobStream(statement, paramIndex, options);
|
|
25
|
-
},
|
|
26
|
-
// Create a statement which allows user to pass readable streams for input parameters
|
|
27
|
-
createStatement: function(connection, sql, callback) {
|
|
28
|
-
return new HanaStatement(connection, sql, callback);
|
|
29
|
-
},
|
|
30
|
-
// Create a statement for procedure call. After calling exec, output parameters
|
|
31
|
-
// (err, scalarParams, table1, table2...) will be passed to the callback
|
|
32
|
-
createProcStatement: function(connection, sql, callback) {
|
|
33
|
-
return new HanaProcStatement(connection, sql, callback);
|
|
34
|
-
},
|
|
35
|
-
// Execute a statement which returns multiple resultsets. After calling this method, output parameters
|
|
36
|
-
// (err, scalarParams, table1, table2..., columnInfo1, columnInfo2...) will be passed to the callback
|
|
37
|
-
executeMultipleResultSets: function(...args2) {
|
|
38
|
-
if (args2.length != 4 && args2.length != 5) {
|
|
39
|
-
throw new Error("Invalid number of parameters - executeMultipleResultSets(connection, sql, params, [options,] callback).");
|
|
40
|
-
}
|
|
41
|
-
var connection = args2[0];
|
|
42
|
-
var sql = args2[1];
|
|
43
|
-
var params = args2[2];
|
|
44
|
-
if (args2.length == 4) {
|
|
45
|
-
var options = {};
|
|
46
|
-
var callback = args2[3];
|
|
47
|
-
} else if (args2.length == 5) {
|
|
48
|
-
var options = args2[3];
|
|
49
|
-
var callback = args2[4];
|
|
50
|
-
}
|
|
51
|
-
if (callback == void 0 || callback == null || typeof callback !== "function") {
|
|
52
|
-
throw new Error("Invalid parameter 'callback'.");
|
|
53
|
-
}
|
|
54
|
-
var statement = new HanaProcStatement(connection, sql, function(err2, stmt) {
|
|
55
|
-
if (err2) {
|
|
56
|
-
callback(err2);
|
|
57
|
-
} else {
|
|
58
|
-
let s = stmt;
|
|
59
|
-
stmt.exec(params, options, function(err3, ...args3) {
|
|
60
|
-
if (!err3) {
|
|
61
|
-
s.getColumnInfo().forEach(function(ci) {
|
|
62
|
-
args3.push(ci);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
s.drop(function(errDrop) {
|
|
66
|
-
if (err3) {
|
|
67
|
-
callback(err3);
|
|
68
|
-
} else if (errDrop) {
|
|
69
|
-
callback(errDrop);
|
|
70
|
-
} else {
|
|
71
|
-
args3.unshift(void 0);
|
|
72
|
-
callback.apply(null, args3);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var util = __require("util");
|
|
81
|
-
var streamModule = __require("stream");
|
|
82
|
-
var Stream = streamModule.Stream;
|
|
83
|
-
var Readable = streamModule.Readable;
|
|
84
|
-
function HanaRSStream(resultset, asArray) {
|
|
85
|
-
checkParameter("resultset", resultset);
|
|
86
|
-
Readable.call(this, { objectMode: true });
|
|
87
|
-
resultset.setAsArrayDefault(asArray);
|
|
88
|
-
this.resultset = resultset;
|
|
89
|
-
}
|
|
90
|
-
util.inherits(HanaRSStream, Readable);
|
|
91
|
-
HanaRSStream.prototype._read = function() {
|
|
92
|
-
var stream = this;
|
|
93
|
-
if (this.resultset.nextCanBlock()) {
|
|
94
|
-
this.resultset.next(function(err2, ret2) {
|
|
95
|
-
if (err2 === void 0) {
|
|
96
|
-
if (ret2) {
|
|
97
|
-
if (stream.resultset.getValuesCanBlock()) {
|
|
98
|
-
stream.resultset.getValues(function(err3, ret3) {
|
|
99
|
-
if (err3 === void 0) {
|
|
100
|
-
stream.push(ret3);
|
|
101
|
-
} else {
|
|
102
|
-
stream.emit("error", err3);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
} else {
|
|
106
|
-
try {
|
|
107
|
-
stream.push(stream.resultset.getValues());
|
|
108
|
-
} catch (err3) {
|
|
109
|
-
stream.emit("error", err3);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
stream.push(null);
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
stream.emit("error", err2);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
} else {
|
|
120
|
-
try {
|
|
121
|
-
var ret = this.resultset.next();
|
|
122
|
-
if (ret) {
|
|
123
|
-
stream.push(stream.resultset.getValues());
|
|
124
|
-
} else {
|
|
125
|
-
stream.push(null);
|
|
126
|
-
}
|
|
127
|
-
} catch (err2) {
|
|
128
|
-
stream.emit("error", err2);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
HanaRSStream.prototype._destroy = function(error, callback) {
|
|
133
|
-
this.push(null);
|
|
134
|
-
if (typeof callback === "function") {
|
|
135
|
-
callback(error);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
function HanaLobStream(resultset, columnIndex, options) {
|
|
139
|
-
checkParameter("resultset", resultset);
|
|
140
|
-
var opts = getLobStreamOptions(options);
|
|
141
|
-
Readable.call(this, opts);
|
|
142
|
-
this.resultset = resultset;
|
|
143
|
-
this.columnInfo = this.resultset.getColumnInfo();
|
|
144
|
-
this.columnIndex = columnIndex;
|
|
145
|
-
checkColumnIndex(this.columnInfo, columnIndex);
|
|
146
|
-
checkLobType(this.columnInfo, columnIndex);
|
|
147
|
-
this.isString = this.columnInfo[this.columnIndex].typeName === "STRING";
|
|
148
|
-
this.offset = 0;
|
|
149
|
-
this.noPause = opts.noPause;
|
|
150
|
-
this.valueAsString = false;
|
|
151
|
-
if (typeof opts.valueAsString === "boolean") {
|
|
152
|
-
this.valueAsString = opts.valueAsString;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
util.inherits(HanaLobStream, Readable);
|
|
156
|
-
HanaLobStream.prototype._read = function(bufferSize) {
|
|
157
|
-
if (this.resultset.isNull(this.columnIndex)) {
|
|
158
|
-
this.push(null);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
var stream = this;
|
|
162
|
-
stream.bufferSize = bufferSize;
|
|
163
|
-
var buffer = createBuffer(bufferSize);
|
|
164
|
-
if (!this.noPause) {
|
|
165
|
-
this.pause();
|
|
166
|
-
}
|
|
167
|
-
this.resultset.getData(this.columnIndex, this.offset, buffer, 0, bufferSize, function(err2, bytesRetrieved) {
|
|
168
|
-
if (err2 === void 0) {
|
|
169
|
-
if (stream.isString) {
|
|
170
|
-
if (bytesRetrieved > 0) {
|
|
171
|
-
let nullChar = buffer.indexOf(0);
|
|
172
|
-
if (nullChar === 0) {
|
|
173
|
-
stream.push(null);
|
|
174
|
-
} else {
|
|
175
|
-
let newBuffer = buffer;
|
|
176
|
-
if (nullChar > 0) {
|
|
177
|
-
newBuffer = buffer.slice(0, nullChar);
|
|
178
|
-
}
|
|
179
|
-
let str = newBuffer.toString("utf8");
|
|
180
|
-
stream.offset += str.length;
|
|
181
|
-
if (stream.valueAsString) {
|
|
182
|
-
stream.push(str);
|
|
183
|
-
} else {
|
|
184
|
-
stream.push(newBuffer);
|
|
185
|
-
}
|
|
186
|
-
if (bytesRetrieved + 3 < stream.bufferSize) {
|
|
187
|
-
stream.push(null);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
stream.push(null);
|
|
192
|
-
}
|
|
193
|
-
} else {
|
|
194
|
-
stream.offset += bytesRetrieved;
|
|
195
|
-
if (bytesRetrieved > 0) {
|
|
196
|
-
if (bytesRetrieved < stream.bufferSize) {
|
|
197
|
-
stream.push(buffer.slice(0, bytesRetrieved));
|
|
198
|
-
stream.push(null);
|
|
199
|
-
} else {
|
|
200
|
-
stream.push(buffer);
|
|
201
|
-
}
|
|
202
|
-
} else {
|
|
203
|
-
stream.push(null);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
207
|
-
if (err2.code === 100) {
|
|
208
|
-
stream.push(null);
|
|
209
|
-
} else {
|
|
210
|
-
stream.emit("error", err2);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
if (!stream.noPause) {
|
|
214
|
-
stream.resume();
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
};
|
|
218
|
-
HanaLobStream.prototype._destroy = function(error, callback) {
|
|
219
|
-
this.push(null);
|
|
220
|
-
if (typeof callback === "function") {
|
|
221
|
-
callback(error);
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
function HanaParameterLobStream(statement, paramIndex, options) {
|
|
225
|
-
checkParameter("statement", statement);
|
|
226
|
-
var opts = getLobStreamOptions(options);
|
|
227
|
-
Readable.call(this, opts);
|
|
228
|
-
this.statement = statement;
|
|
229
|
-
this.paramInfo = this.statement.getParameterInfo();
|
|
230
|
-
this.paramIndex = paramIndex;
|
|
231
|
-
checkParameterIndex(this.paramInfo, paramIndex);
|
|
232
|
-
checkParameterLobType(this.paramInfo, paramIndex);
|
|
233
|
-
this.isString = this.paramInfo[this.paramIndex].typeName === "STRING";
|
|
234
|
-
this.offset = 0;
|
|
235
|
-
this.noPause = opts.noPause;
|
|
236
|
-
this.valueAsString = false;
|
|
237
|
-
if (typeof opts.valueAsString === "boolean") {
|
|
238
|
-
this.valueAsString = opts.valueAsString;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
util.inherits(HanaParameterLobStream, Readable);
|
|
242
|
-
HanaParameterLobStream.prototype._read = function(bufferSize) {
|
|
243
|
-
if (this.statement.isParameterNull(this.paramIndex)) {
|
|
244
|
-
this.push(null);
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
var stream = this;
|
|
248
|
-
stream.bufferSize = bufferSize;
|
|
249
|
-
var buffer = createBuffer(bufferSize);
|
|
250
|
-
if (!this.noPause) {
|
|
251
|
-
this.pause();
|
|
252
|
-
}
|
|
253
|
-
this.statement.getData(this.paramIndex, this.offset, buffer, 0, bufferSize, function(err2, bytesRetrieved) {
|
|
254
|
-
if (err2 === void 0) {
|
|
255
|
-
if (stream.isString) {
|
|
256
|
-
if (bytesRetrieved > 0) {
|
|
257
|
-
let nullChar = buffer.indexOf(0);
|
|
258
|
-
if (nullChar === 0) {
|
|
259
|
-
stream.push(null);
|
|
260
|
-
} else {
|
|
261
|
-
let newBuffer = buffer;
|
|
262
|
-
if (nullChar > 0) {
|
|
263
|
-
newBuffer = buffer.slice(0, nullChar);
|
|
264
|
-
}
|
|
265
|
-
let str = newBuffer.toString("utf8");
|
|
266
|
-
stream.offset += str.length;
|
|
267
|
-
if (stream.valueAsString) {
|
|
268
|
-
stream.push(str);
|
|
269
|
-
} else {
|
|
270
|
-
stream.push(newBuffer);
|
|
271
|
-
}
|
|
272
|
-
if (bytesRetrieved < stream.bufferSize) {
|
|
273
|
-
stream.push(null);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
} else {
|
|
277
|
-
stream.push(null);
|
|
278
|
-
}
|
|
279
|
-
} else {
|
|
280
|
-
stream.offset += bytesRetrieved;
|
|
281
|
-
if (bytesRetrieved > 0) {
|
|
282
|
-
if (bytesRetrieved < stream.bufferSize) {
|
|
283
|
-
stream.push(buffer.slice(0, bytesRetrieved));
|
|
284
|
-
stream.push(null);
|
|
285
|
-
} else {
|
|
286
|
-
stream.push(buffer);
|
|
287
|
-
}
|
|
288
|
-
} else {
|
|
289
|
-
stream.push(null);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
} else {
|
|
293
|
-
if (err2.code === 100) {
|
|
294
|
-
stream.push(null);
|
|
295
|
-
} else {
|
|
296
|
-
stream.emit("error", err2);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
if (!stream.noPause) {
|
|
300
|
-
stream.resume();
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
HanaParameterLobStream.prototype._destroy = function(error, callback) {
|
|
305
|
-
this.push(null);
|
|
306
|
-
if (typeof callback === "function") {
|
|
307
|
-
callback(error);
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
function HanaStatement(connection, sql, callback) {
|
|
311
|
-
if (connection === void 0 || connection === null) {
|
|
312
|
-
handleError("Invalid parameter 'connection'.", callback);
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
if (sql === void 0 || sql === null) {
|
|
316
|
-
handleError("Invalid parameter 'sql'.", callback);
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
this.connection = connection;
|
|
320
|
-
this.sql = sql;
|
|
321
|
-
this.stmt = null;
|
|
322
|
-
this.result = 0;
|
|
323
|
-
if (callback) {
|
|
324
|
-
var hanaStmt2 = this;
|
|
325
|
-
this.connection.prepare(sql, function(err2, stmt) {
|
|
326
|
-
hanaStmt2.stmt = stmt;
|
|
327
|
-
callback(err2, hanaStmt2);
|
|
328
|
-
});
|
|
329
|
-
} else {
|
|
330
|
-
this.stmt = this.connection.prepare(sql);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
HanaStatement.prototype.getStatement = function() {
|
|
334
|
-
return this.stmt;
|
|
335
|
-
};
|
|
336
|
-
HanaStatement.prototype.drop = function(callback) {
|
|
337
|
-
if (this.stmt) {
|
|
338
|
-
var stmt = this.stmt;
|
|
339
|
-
this.stmt = null;
|
|
340
|
-
stmt.drop(callback);
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
HanaStatement.prototype.exec = function(params, callback) {
|
|
344
|
-
if (callback === void 0 || callback === null || typeof callback !== "function") {
|
|
345
|
-
throw new Error("Invalid parameter 'callback'.");
|
|
346
|
-
}
|
|
347
|
-
if (params === void 0 || params === null || !(params instanceof Array)) {
|
|
348
|
-
handleError("Invalid parameter 'params'.", callback);
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
if (!this.stmt) {
|
|
352
|
-
handleError("Invalid statement.", callback);
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
var hasArrayParam = false;
|
|
356
|
-
var hasNonArrayParam = false;
|
|
357
|
-
for (var i2 = 0; i2 < params.length; i2++) {
|
|
358
|
-
if (params[i2] instanceof Array) {
|
|
359
|
-
hasArrayParam = true;
|
|
360
|
-
} else {
|
|
361
|
-
hasNonArrayParam = true;
|
|
362
|
-
}
|
|
363
|
-
if (hasArrayParam && hasNonArrayParam) {
|
|
364
|
-
handleError("Invalid parameter 'params': contains both array and non-array parameters.", callback);
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
if (params.length === 0) {
|
|
369
|
-
callback(null, 0);
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
this.callback = callback;
|
|
373
|
-
this.currentRow = 0;
|
|
374
|
-
if (hasArrayParam) {
|
|
375
|
-
this.paramsArray = params;
|
|
376
|
-
} else {
|
|
377
|
-
this.paramsArray = [];
|
|
378
|
-
this.paramsArray.push(params);
|
|
379
|
-
}
|
|
380
|
-
this._exec();
|
|
381
|
-
};
|
|
382
|
-
HanaStatement.prototype._exec = function() {
|
|
383
|
-
this.params = this.paramsArray[this.currentRow];
|
|
384
|
-
var isStream = [];
|
|
385
|
-
var paramsNew = [];
|
|
386
|
-
var streamCount = 0;
|
|
387
|
-
var hanaStmt2 = this;
|
|
388
|
-
for (var i2 = 0; i2 < this.params.length; i2++) {
|
|
389
|
-
if (this.params[i2] instanceof Stream) {
|
|
390
|
-
this.params[i2].pause();
|
|
391
|
-
isStream.push(true);
|
|
392
|
-
paramsNew.push({ sendParameterData: true });
|
|
393
|
-
streamCount++;
|
|
394
|
-
} else {
|
|
395
|
-
isStream.push(false);
|
|
396
|
-
paramsNew.push(this.params[i2]);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
if (streamCount <= 0) {
|
|
400
|
-
this.stmt.exec(paramsNew, function(err2, result) {
|
|
401
|
-
if (err2) {
|
|
402
|
-
hanaStmt2.callback(err2, result);
|
|
403
|
-
} else {
|
|
404
|
-
hanaStmt2.currentRow++;
|
|
405
|
-
hanaStmt2.result += result;
|
|
406
|
-
if (hanaStmt2.currentRow === hanaStmt2.paramsArray.length) {
|
|
407
|
-
hanaStmt2.callback(null, hanaStmt2.result);
|
|
408
|
-
} else {
|
|
409
|
-
hanaStmt2._exec();
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
} else {
|
|
414
|
-
this.stmt.exec(paramsNew, function(err2, result) {
|
|
415
|
-
if (err2) {
|
|
416
|
-
hanaStmt2.callback(err2, result);
|
|
417
|
-
} else {
|
|
418
|
-
for (var paramIndex = 0; paramIndex < hanaStmt2.params.length; paramIndex++) {
|
|
419
|
-
if (hanaStmt2.params[paramIndex] instanceof Stream) {
|
|
420
|
-
break;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
hanaStmt2.sendParameterData(paramIndex);
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
HanaStatement.prototype.sendParameterData = function(paramIndex) {
|
|
429
|
-
var hanaStmt2 = this;
|
|
430
|
-
this.params[paramIndex].on("error", function(error) {
|
|
431
|
-
hanaStmt2.callback(error);
|
|
432
|
-
});
|
|
433
|
-
this.params[paramIndex].on("end", function() {
|
|
434
|
-
hanaStmt2.stmt.sendParameterData(paramIndex, null, function(err2) {
|
|
435
|
-
if (err2) {
|
|
436
|
-
hanaStmt2.callback(err2);
|
|
437
|
-
} else {
|
|
438
|
-
var nextStream = -1;
|
|
439
|
-
for (var i2 = paramIndex + 1; i2 < hanaStmt2.params.length; i2++) {
|
|
440
|
-
if (hanaStmt2.params[i2] instanceof Stream) {
|
|
441
|
-
nextStream = i2;
|
|
442
|
-
break;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
if (nextStream >= 0) {
|
|
446
|
-
hanaStmt2.sendParameterData(nextStream);
|
|
447
|
-
} else {
|
|
448
|
-
hanaStmt2.currentRow++;
|
|
449
|
-
hanaStmt2.result += 1;
|
|
450
|
-
if (hanaStmt2.currentRow === hanaStmt2.paramsArray.length) {
|
|
451
|
-
hanaStmt2.callback(null, hanaStmt2.result);
|
|
452
|
-
} else {
|
|
453
|
-
hanaStmt2._exec();
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
});
|
|
459
|
-
this.params[paramIndex].on("data", function(buffer) {
|
|
460
|
-
hanaStmt2.params[paramIndex].pause();
|
|
461
|
-
hanaStmt2.stmt.sendParameterData(paramIndex, buffer, function(err2) {
|
|
462
|
-
if (err2) {
|
|
463
|
-
hanaStmt2.callback(err2);
|
|
464
|
-
} else {
|
|
465
|
-
hanaStmt2.params[paramIndex].resume();
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
});
|
|
469
|
-
this.params[paramIndex].resume();
|
|
470
|
-
};
|
|
471
|
-
function HanaProcStatement(connection, sql, callback) {
|
|
472
|
-
if (connection === void 0 || connection === null) {
|
|
473
|
-
handleError("Invalid parameter 'connection'.", callback);
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
if (sql === void 0 || sql === null) {
|
|
477
|
-
handleError("Invalid parameter 'sql'.", callback);
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
480
|
-
if (callback !== void 0 && callback !== null && typeof callback !== "function") {
|
|
481
|
-
throw new Error("Invalid parameter 'callback'.");
|
|
482
|
-
}
|
|
483
|
-
this.connection = connection;
|
|
484
|
-
this.columnInfo = [];
|
|
485
|
-
if (callback) {
|
|
486
|
-
var hanaStmt2 = this;
|
|
487
|
-
connection.prepare(sql, function(err2, stmt) {
|
|
488
|
-
hanaStmt2.stmt = stmt;
|
|
489
|
-
callback(err2, hanaStmt2);
|
|
490
|
-
});
|
|
491
|
-
} else {
|
|
492
|
-
this.stmt = connection.prepare(sql);
|
|
493
|
-
return this;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
HanaProcStatement.prototype.drop = function(callback) {
|
|
497
|
-
if (this.stmt) {
|
|
498
|
-
var stmt = this.stmt;
|
|
499
|
-
this.stmt = null;
|
|
500
|
-
stmt.drop(callback);
|
|
501
|
-
}
|
|
502
|
-
};
|
|
503
|
-
HanaProcStatement.prototype.exec = function(...args2) {
|
|
504
|
-
if (args2.length != 2 && args2.length != 3) {
|
|
505
|
-
throw new Error("Invalid number of parameters - exec(params, [options,] callback).");
|
|
506
|
-
}
|
|
507
|
-
var params = args2[0];
|
|
508
|
-
if (args2.length == 2) {
|
|
509
|
-
var options = {};
|
|
510
|
-
var callback = args2[1];
|
|
511
|
-
} else if (args2.length == 3) {
|
|
512
|
-
var options = args2[1];
|
|
513
|
-
var callback = args2[2];
|
|
514
|
-
}
|
|
515
|
-
if (params !== void 0 && params !== null && (!(params instanceof Array) && !(params instanceof Object))) {
|
|
516
|
-
handleError("Invalid parameter 'params'.", callback);
|
|
517
|
-
return;
|
|
518
|
-
}
|
|
519
|
-
if (callback === void 0 || callback === null || typeof callback !== "function") {
|
|
520
|
-
throw new Error("Invalid parameter 'callback'.");
|
|
521
|
-
}
|
|
522
|
-
if (!this.stmt) {
|
|
523
|
-
handleError("Invalid statement.", callback);
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
this.callback = callback;
|
|
527
|
-
this.scalarParams = {};
|
|
528
|
-
this.hasScalarParams = false;
|
|
529
|
-
this.tableParams = [[]];
|
|
530
|
-
this.currentTable = 0;
|
|
531
|
-
this.columnInfo = [];
|
|
532
|
-
var hanaStmt2 = this;
|
|
533
|
-
this.stmt.execQuery(params, options, function(err2, rs) {
|
|
534
|
-
if (err2) {
|
|
535
|
-
hanaStmt2.callback(err2);
|
|
536
|
-
} else {
|
|
537
|
-
hanaStmt2.rs = rs;
|
|
538
|
-
var paramInfo = hanaStmt2.stmt.getParameterInfo();
|
|
539
|
-
var paramCount = 0;
|
|
540
|
-
for (var i2 = 0; i2 < paramInfo.length; i2++) {
|
|
541
|
-
if (paramInfo[i2].direction === 2 || paramInfo[i2].direction === 3) {
|
|
542
|
-
hanaStmt2.hasScalarParams = true;
|
|
543
|
-
hanaStmt2.stmt.getParameterValue(i2, /* @__PURE__ */ (function() {
|
|
544
|
-
var index = i2;
|
|
545
|
-
return function(err3, val) {
|
|
546
|
-
if (err3) {
|
|
547
|
-
hanaStmt2.callback(err3);
|
|
548
|
-
} else {
|
|
549
|
-
++paramCount;
|
|
550
|
-
hanaStmt2.scalarParams[paramInfo[index].name] = val;
|
|
551
|
-
if (paramCount === paramInfo.length) {
|
|
552
|
-
return hanaStmt2.fetchTableParam();
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
})());
|
|
557
|
-
} else {
|
|
558
|
-
++paramCount;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
if (paramCount === paramInfo.length) {
|
|
562
|
-
hanaStmt2.fetchTableParam();
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
});
|
|
566
|
-
};
|
|
567
|
-
HanaProcStatement.prototype.getColumnInfo = function() {
|
|
568
|
-
return this.columnInfo;
|
|
569
|
-
};
|
|
570
|
-
HanaProcStatement.prototype.execute = function(params, callback) {
|
|
571
|
-
this.exec(params, callback);
|
|
572
|
-
};
|
|
573
|
-
HanaProcStatement.prototype.fetchTableParam = function() {
|
|
574
|
-
function fetchNextResult(hanaStmt) {
|
|
575
|
-
var columns = hanaStmt.rs.getColumnInfo();
|
|
576
|
-
if (columns != null && columns != void 0 && columns.length > 0) {
|
|
577
|
-
hanaStmt.columnInfo.push(columns);
|
|
578
|
-
}
|
|
579
|
-
hanaStmt.rs.nextResult(function(err, hasResult) {
|
|
580
|
-
if (err) {
|
|
581
|
-
hanaStmt.callback(err);
|
|
582
|
-
} else if (hasResult) {
|
|
583
|
-
hanaStmt.currentTable++;
|
|
584
|
-
hanaStmt.tableParams.push([]);
|
|
585
|
-
hanaStmt.fetchTableParam();
|
|
586
|
-
} else {
|
|
587
|
-
hanaStmt.rs.close(function(err) {
|
|
588
|
-
if (err) {
|
|
589
|
-
hanaStmt.callback(err);
|
|
590
|
-
} else {
|
|
591
|
-
var args = [];
|
|
592
|
-
if (hanaStmt.hasScalarParams) {
|
|
593
|
-
args.push(hanaStmt.scalarParams);
|
|
594
|
-
} else {
|
|
595
|
-
args.push({});
|
|
596
|
-
}
|
|
597
|
-
for (var i = 0; i < hanaStmt.tableParams.length; i++) {
|
|
598
|
-
args.push(hanaStmt.tableParams[i]);
|
|
599
|
-
}
|
|
600
|
-
var evalStr = "hanaStmt.callback(null";
|
|
601
|
-
for (var j = 0; j < args.length; j++) {
|
|
602
|
-
evalStr += ", args[" + j + "]";
|
|
603
|
-
}
|
|
604
|
-
evalStr += ")";
|
|
605
|
-
eval(evalStr);
|
|
606
|
-
}
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
var hanaStmt = this;
|
|
612
|
-
if (this.rs.nextCanBlock()) {
|
|
613
|
-
this.rs.next(function(err2, hasData) {
|
|
614
|
-
if (err2) {
|
|
615
|
-
hanaStmt.callback(err2);
|
|
616
|
-
} else {
|
|
617
|
-
if (hasData) {
|
|
618
|
-
try {
|
|
619
|
-
hanaStmt.tableParams[hanaStmt.currentTable].push(hanaStmt.rs.getValues());
|
|
620
|
-
} catch (newerr) {
|
|
621
|
-
hanaStmt.callback(newerr);
|
|
622
|
-
return;
|
|
623
|
-
}
|
|
624
|
-
hanaStmt.fetchTableParam();
|
|
625
|
-
} else {
|
|
626
|
-
fetchNextResult(hanaStmt);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
} else {
|
|
631
|
-
var hasDataSync = false;
|
|
632
|
-
try {
|
|
633
|
-
hasDataSync = this.rs.next();
|
|
634
|
-
if (hasDataSync) {
|
|
635
|
-
hanaStmt.tableParams[hanaStmt.currentTable].push(hanaStmt.rs.getValues());
|
|
636
|
-
}
|
|
637
|
-
} catch (newerr) {
|
|
638
|
-
hanaStmt.callback(newerr);
|
|
639
|
-
return;
|
|
640
|
-
}
|
|
641
|
-
if (hasDataSync) {
|
|
642
|
-
hanaStmt.fetchTableParam();
|
|
643
|
-
} else {
|
|
644
|
-
fetchNextResult(hanaStmt);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
function handleError(err2, callback) {
|
|
649
|
-
if (callback) {
|
|
650
|
-
callback(err2);
|
|
651
|
-
} else {
|
|
652
|
-
throw err2;
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
function isLob(type) {
|
|
656
|
-
if (type === 25 || // CLOB
|
|
657
|
-
type === 26 || // NCLOB
|
|
658
|
-
type === 27 || // BLOB
|
|
659
|
-
type === 13) {
|
|
660
|
-
return true;
|
|
661
|
-
}
|
|
662
|
-
return false;
|
|
663
|
-
}
|
|
664
|
-
function checkParameter(name, param) {
|
|
665
|
-
if (param === void 0 || param === null) {
|
|
666
|
-
throw new Error("Invalid parameter '" + name + "'.");
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
function checkColumnIndex(columnInfo, columnIndex) {
|
|
670
|
-
if (columnIndex === void 0 || columnIndex === null || columnIndex < 0 || columnIndex >= columnInfo.length) {
|
|
671
|
-
throw new Error("Invalid parameter 'columnIndex'.");
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
function checkLobType(columnInfo, columnIndex) {
|
|
675
|
-
var type = columnInfo[columnIndex].nativeType;
|
|
676
|
-
if (!isLob(type)) {
|
|
677
|
-
throw new Error("Column is not LOB type.");
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
function checkParameterIndex(paramInfo, paramIndex) {
|
|
681
|
-
if (paramIndex === void 0 || paramIndex === null || paramIndex < 0 || paramIndex >= paramInfo.length) {
|
|
682
|
-
throw new Error("Invalid parameter 'paramIndex'.");
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
function checkParameterLobType(paramInfo, paramIndex) {
|
|
686
|
-
var type = paramInfo[paramIndex].nativeType;
|
|
687
|
-
if (!isLob(type)) {
|
|
688
|
-
throw new Error("Parameter is not LOB type.");
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
function createBuffer(size) {
|
|
692
|
-
if (typeof Buffer.alloc === "function") {
|
|
693
|
-
return Buffer.alloc(size);
|
|
694
|
-
} else {
|
|
695
|
-
return new Buffer(size);
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
function isInteger(value) {
|
|
699
|
-
if (typeof value === "number" && value % 1 === 0) {
|
|
700
|
-
return true;
|
|
701
|
-
} else {
|
|
702
|
-
return false;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
function getLobStreamOptions(options) {
|
|
706
|
-
var opts = {};
|
|
707
|
-
Object.assign(opts, options);
|
|
708
|
-
opts.objectMode = false;
|
|
709
|
-
if (isInteger(opts.readSize) && opts.readSize > 0) {
|
|
710
|
-
opts.highWaterMark = opts.readSize;
|
|
711
|
-
}
|
|
712
|
-
opts.noPause = false;
|
|
713
|
-
if (options && "noPause" in options && typeof options.noPause === "boolean") {
|
|
714
|
-
opts.noPause = options.noPause;
|
|
715
|
-
}
|
|
716
|
-
return opts;
|
|
717
|
-
}
|
|
718
|
-
var MAX_READ_SIZE = Math.pow(2, 18);
|
|
719
|
-
var DEFAULT_READ_SIZE = Math.pow(2, 11) * 100;
|
|
720
|
-
}
|
|
721
|
-
});
|
|
722
|
-
|
|
723
|
-
export {
|
|
724
|
-
require_Stream
|
|
725
|
-
};
|
|
726
|
-
//# sourceMappingURL=chunk-I3F3SOHM.js.map
|