oracledb 5.5.0 → 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.
Files changed (107) hide show
  1. package/CHANGELOG.md +1 -1875
  2. package/LICENSE.txt +8 -222
  3. package/NOTICE.txt +1 -1
  4. package/README.md +38 -30
  5. package/SECURITY.md +38 -0
  6. package/build/Release/oracledb-6.0.1-darwin-x64.node +0 -0
  7. package/build/Release/oracledb-6.0.1-darwin-x64.node-buildinfo.txt +1 -0
  8. package/build/Release/oracledb-6.0.1-js-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-6.0.1-linux-arm64.node +0 -0
  10. package/build/Release/oracledb-6.0.1-linux-arm64.node-buildinfo.txt +1 -0
  11. package/build/Release/oracledb-6.0.1-linux-x64.node +0 -0
  12. package/build/Release/oracledb-6.0.1-linux-x64.node-buildinfo.txt +1 -0
  13. package/build/Release/oracledb-6.0.1-win32-x64.node +0 -0
  14. package/build/Release/oracledb-6.0.1-win32-x64.node-buildinfo.txt +1 -0
  15. package/examples/README.md +113 -0
  16. package/examples/dbconfig.js +100 -0
  17. package/examples/example.js +156 -0
  18. package/index.js +26 -0
  19. package/lib/aqDeqOptions.js +148 -8
  20. package/lib/aqEnqOptions.js +59 -7
  21. package/lib/aqMessage.js +118 -7
  22. package/lib/aqQueue.js +243 -53
  23. package/lib/connection.js +1326 -465
  24. package/lib/constants.js +203 -0
  25. package/lib/dbObject.js +346 -32
  26. package/lib/errors.js +785 -0
  27. package/lib/impl/aqDeqOptions.js +197 -0
  28. package/lib/impl/aqEnqOptions.js +89 -0
  29. package/lib/impl/aqMessage.js +134 -0
  30. package/lib/impl/aqQueue.js +81 -0
  31. package/lib/impl/connection.js +529 -0
  32. package/lib/impl/dbObject.js +159 -0
  33. package/lib/impl/index.js +59 -0
  34. package/lib/impl/lob.js +85 -0
  35. package/lib/impl/pool.js +195 -0
  36. package/lib/impl/resultset.js +223 -0
  37. package/lib/impl/sodaCollection.js +174 -0
  38. package/lib/impl/sodaDatabase.js +81 -0
  39. package/lib/impl/sodaDocCursor.js +63 -0
  40. package/lib/impl/sodaDocument.js +98 -0
  41. package/lib/impl/sodaOperation.js +109 -0
  42. package/lib/lob.js +157 -68
  43. package/lib/oracledb.js +1047 -345
  44. package/lib/pool.js +654 -465
  45. package/lib/poolStatistics.js +24 -9
  46. package/lib/queryStream.js +16 -8
  47. package/lib/resultset.js +291 -183
  48. package/lib/settings.js +191 -0
  49. package/lib/sodaCollection.js +214 -201
  50. package/lib/sodaDatabase.js +108 -71
  51. package/lib/sodaDocCursor.js +44 -32
  52. package/lib/sodaDocument.js +76 -14
  53. package/lib/sodaOperation.js +131 -118
  54. package/lib/thin/connection.js +1043 -0
  55. package/lib/thin/dbObject.js +630 -0
  56. package/lib/thin/index.js +40 -0
  57. package/lib/thin/lob.js +189 -0
  58. package/lib/thin/pool.js +481 -0
  59. package/lib/thin/protocol/buffer.js +1043 -0
  60. package/lib/thin/protocol/capabilities.js +121 -0
  61. package/lib/thin/protocol/constants.js +765 -0
  62. package/lib/thin/protocol/encryptDecrypt.js +185 -0
  63. package/lib/thin/protocol/messages/auth.js +349 -0
  64. package/lib/thin/protocol/messages/base.js +476 -0
  65. package/lib/thin/protocol/messages/commit.js +56 -0
  66. package/lib/thin/protocol/messages/dataType.js +391 -0
  67. package/lib/thin/protocol/messages/execute.js +312 -0
  68. package/lib/thin/protocol/messages/fetch.js +60 -0
  69. package/lib/thin/protocol/messages/index.js +53 -0
  70. package/lib/thin/protocol/messages/lobOp.js +201 -0
  71. package/lib/thin/protocol/messages/logOff.js +53 -0
  72. package/lib/thin/protocol/messages/ping.js +56 -0
  73. package/lib/thin/protocol/messages/protocol.js +78 -0
  74. package/lib/thin/protocol/messages/rollback.js +56 -0
  75. package/lib/thin/protocol/messages/sessionRelease.js +60 -0
  76. package/lib/thin/protocol/messages/withData.js +812 -0
  77. package/lib/thin/protocol/oson.js +661 -0
  78. package/lib/thin/protocol/packet.js +519 -0
  79. package/lib/thin/protocol/protocol.js +202 -0
  80. package/lib/thin/protocol/utils.js +89 -0
  81. package/lib/thin/resultSet.js +122 -0
  82. package/lib/thin/sqlnet/connStrategy.js +175 -0
  83. package/lib/thin/sqlnet/constants.js +199 -0
  84. package/lib/thin/sqlnet/ezConnectResolver.js +488 -0
  85. package/lib/thin/sqlnet/navNodes.js +870 -0
  86. package/lib/thin/sqlnet/networkSession.js +621 -0
  87. package/lib/thin/sqlnet/ntTcp.js +527 -0
  88. package/lib/thin/sqlnet/nvStrToNvPair.js +783 -0
  89. package/lib/thin/sqlnet/packet.js +405 -0
  90. package/lib/thin/sqlnet/paramParser.js +206 -0
  91. package/lib/thin/sqlnet/sessionAtts.js +160 -0
  92. package/lib/thin/statement.js +300 -0
  93. package/lib/thin/util.js +289 -0
  94. package/lib/transformer.js +252 -0
  95. package/lib/types.js +357 -0
  96. package/lib/util.js +196 -110
  97. package/lib/version.js +36 -0
  98. package/package/README.md +33 -30
  99. package/package/install.js +89 -64
  100. package/package/prunebinaries.js +60 -12
  101. package/package.json +3 -3
  102. package/build/Release/oracledb-5.5.0-darwin-x64.node +0 -0
  103. package/build/Release/oracledb-5.5.0-darwin-x64.node-buildinfo.txt +0 -1
  104. package/build/Release/oracledb-5.5.0-linux-x64.node +0 -0
  105. package/build/Release/oracledb-5.5.0-linux-x64.node-buildinfo.txt +0 -1
  106. package/build/Release/oracledb-5.5.0-win32-x64.node +0 -0
  107. package/build/Release/oracledb-5.5.0-win32-x64.node-buildinfo.txt +0 -1
package/lib/aqQueue.js CHANGED
@@ -1,17 +1,24 @@
1
- // Copyright (c) 2019, 2022, Oracle and/or its affiliates.
1
+ // Copyright (c) 2019, 2023, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
5
- // You may not use the identified files except in compliance with the Apache
6
- // License, Version 2.0 (the "License.")
5
+ // This software is dual-licensed to you under the Universal Permissive License
6
+ // (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
7
+ // 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
8
+ // either license.
7
9
  //
10
+ // If you elect to accept the software under the Apache License, Version 2.0,
11
+ // the following applies:
12
+ //
13
+ // Licensed under the Apache License, Version 2.0 (the "License");
14
+ // you may not use this file except in compliance with the License.
8
15
  // You may obtain a copy of the License at
9
- // http://www.apache.org/licenses/LICENSE-2.0.
10
16
  //
11
- // Unless required by applicable law or agreed to in writing, software
12
- // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ // https://www.apache.org/licenses/LICENSE-2.0
14
18
  //
19
+ // Unless required by applicable law or agreed to in writing, software
20
+ // distributed under the License is distributed on an "AS IS" BASIS,
21
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
22
  // See the License for the specific language governing permissions and
16
23
  // limitations under the License.
17
24
  //
@@ -19,67 +26,250 @@
19
26
 
20
27
  'use strict';
21
28
 
29
+ const { Buffer } = require('buffer');
30
+ const constants = require('./constants.js');
31
+ const errors = require('./errors.js');
22
32
  const nodbUtil = require('./util.js');
33
+ const AqDeqOptions = require('./aqDeqOptions.js');
34
+ const AqEnqOptions = require('./aqEnqOptions.js');
35
+ const AqMessage = require('./aqMessage.js');
36
+ const BaseDbObject = require('./dbObject.js');
23
37
 
24
- //-----------------------------------------------------------------------------
25
- // deqOne()
26
- // Returns a single message from the queue, if one is available.
27
- //-----------------------------------------------------------------------------
28
- async function deqOne() {
29
- nodbUtil.checkArgCount(arguments, 0, 0);
30
- return await this._deqOne();
31
- }
38
+ class AqQueue {
32
39
 
40
+ //---------------------------------------------------------------------------
41
+ // _isPayload()
42
+ //
43
+ // Returns a boolean indicating if the value is a valid payload.
44
+ //---------------------------------------------------------------------------
45
+ _isPayload(value) {
46
+ return (typeof value === 'string' || Buffer.isBuffer(value) ||
47
+ value instanceof BaseDbObject);
48
+ }
33
49
 
34
- //-----------------------------------------------------------------------------
35
- // deqMany()
36
- // Returns an array of messages from the queue, up to the maximum specified,
37
- // if any are available.
38
- //----------------------------------------------------------------------------
39
- async function deqMany(maxMessages) {
40
- nodbUtil.checkArgCount(arguments, 1, 1);
41
- nodbUtil.assert(typeof maxMessages === 'number', 'NJS-005', 1);
42
- return await this._deqMany(maxMessages);
43
- }
50
+ //---------------------------------------------------------------------------
51
+ // _verifyMessage()
52
+ //
53
+ // Messages that can be enqueued must be a string, Buffer or database object
54
+ // (in which case all message properties are defaulted) or an object
55
+ // containing a "payload" property along with the other properties to use
56
+ // during the enqueue. A normalized object is returned.
57
+ //---------------------------------------------------------------------------
58
+ _verifyMessage(message) {
44
59
 
60
+ // validate we have a payload of the correct type
61
+ let payload;
62
+ if (this._isPayload(message)) {
63
+ payload = message;
64
+ message = {};
65
+ } else {
66
+ message = {...message};
67
+ if (this._isPayload(message.payload)) {
68
+ payload = message.payload;
69
+ } else if (this._payloadTypeClass) {
70
+ payload = new this._payloadTypeClass(message.payload);
71
+ } else {
72
+ errors.throwErr(errors.ERR_INVALID_AQ_MESSAGE);
73
+ }
74
+ }
45
75
 
46
- //-----------------------------------------------------------------------------
47
- // enqOne()
48
- // Enqueues a single message into the queue.
49
- //-----------------------------------------------------------------------------
50
- async function enqOne(message) {
51
- nodbUtil.checkArgCount(arguments, 1, 1);
52
- nodbUtil.assert(typeof message === 'object' || typeof message === 'string',
53
- 'NJS-005', 1);
54
- return await this._enqOne(message);
55
- }
76
+ // validate payload
77
+ if (typeof payload === 'string') {
78
+ message.payload = Buffer.from(payload);
79
+ } else if (Buffer.isBuffer(payload)) {
80
+ message.payload = payload;
81
+ } else {
82
+ message.payload = payload._impl;
83
+ }
56
84
 
85
+ // validate options, if applicable
86
+ if (message.correlation !== undefined) {
87
+ errors.assertParamPropValue(typeof message.correlation === 'string', 1,
88
+ "correlation");
89
+ }
90
+ if (message.delay !== undefined) {
91
+ errors.assertParamPropValue(Number.isInteger(message.delay), 1, "delay");
92
+ }
93
+ if (message.exceptionQueue !== undefined) {
94
+ errors.assertParamPropValue(typeof message.exceptionQueue === 'string',
95
+ 1, "exceptionQueue");
96
+ }
97
+ if (message.expiration !== undefined) {
98
+ errors.assertParamPropValue(Number.isInteger(message.expiration), 1,
99
+ "expiration");
100
+ }
101
+ if (message.priority !== undefined) {
102
+ errors.assertParamPropValue(Number.isInteger(message.priority), 1,
103
+ "priority");
104
+ }
105
+ if (message.recipients !== undefined) {
106
+ errors.assertParamPropValue(nodbUtil.isArrayOfStrings(message.recipients),
107
+ 1, "recipients");
108
+ }
57
109
 
58
- //-----------------------------------------------------------------------------
59
- // enqMany()
60
- // Enqueues multiple messages into the queue at the same time, avoiding
61
- // multiple round-trips.
62
- //----------------------------------------------------------------------------
63
- async function enqMany(messages) {
64
- nodbUtil.checkArgCount(arguments, 1, 1);
65
- nodbUtil.assert(Array.isArray(messages), 'NJS-005', 1);
66
- return await this._enqMany(messages);
67
- }
110
+ return message;
111
+ }
112
+
113
+ //---------------------------------------------------------------------------
114
+ // create()
115
+ //
116
+ // Creates the queue and populates some internal attributes.
117
+ //---------------------------------------------------------------------------
118
+ async create(conn, name, options) {
119
+ if (options.payloadType) {
120
+ if (typeof options.payloadType == 'string') {
121
+ const cls = await conn._getDbObjectClassForName(options.payloadType);
122
+ this._payloadTypeClass = cls;
123
+ options.payloadType = cls;
124
+ } else {
125
+ errors.assertParamPropValue(nodbUtil.isObject(options.payloadType) &&
126
+ options.payloadType.prototype instanceof BaseDbObject, 2, "payloadType");
127
+ this._payloadTypeClass = options.payloadType;
128
+ }
129
+ this._payloadType = constants.DB_TYPE_OBJECT;
130
+ this._payloadTypeName = this._payloadTypeClass.prototype.name;
131
+ } else {
132
+ this._payloadType = constants.DB_TYPE_RAW;
133
+ this._payloadTypeName = "RAW";
134
+ }
135
+ this._name = name;
136
+ this._impl = await conn._impl.getQueue(name, options);
137
+ }
68
138
 
139
+ //---------------------------------------------------------------------------
140
+ // deqMany()
141
+ //
142
+ // Returns an array of messages from the queue, up to the maximum specified,
143
+ // if any are available.
144
+ //---------------------------------------------------------------------------
145
+ async deqMany(maxMessages) {
146
+ errors.assertArgCount(arguments, 1, 1);
147
+ errors.assertParamValue(Number.isInteger(maxMessages) && maxMessages > 0,
148
+ 1);
149
+ const msgImpls = await this._impl.deqMany(maxMessages);
150
+ const messages = new Array(msgImpls.length);
151
+ for (let i = 0; i < msgImpls.length; i++) {
152
+ const msg = new AqMessage();
153
+ msg._impl = msgImpls[i];
154
+ msg._payloadTypeClass = this._payloadTypeClass;
155
+ messages[i] = msg;
156
+ }
157
+ return messages;
158
+ }
69
159
 
70
- class AqQueue {
160
+ //---------------------------------------------------------------------------
161
+ // deqOne()
162
+ //
163
+ // Returns a single message from the queue, if one is available.
164
+ //---------------------------------------------------------------------------
165
+ async deqOne() {
166
+ errors.assertArgCount(arguments, 0, 0);
167
+ const msgImpl = await this._impl.deqOne();
168
+ if (msgImpl) {
169
+ const msg = new AqMessage();
170
+ msg._impl = msgImpl;
171
+ msg._payloadTypeClass = this._payloadTypeClass;
172
+ return msg;
173
+ }
174
+ }
71
175
 
72
- _extend() {
73
- this.deqOne = nodbUtil.callbackify(nodbUtil.serialize(deqOne));
74
- this.deqMany = nodbUtil.callbackify(nodbUtil.serialize(deqMany));
75
- this.enqOne = nodbUtil.callbackify(nodbUtil.serialize(enqOne));
76
- this.enqMany = nodbUtil.callbackify(nodbUtil.serialize(enqMany));
176
+ //---------------------------------------------------------------------------
177
+ // deqOptions
178
+ //
179
+ // Property for the dequeue options associated with the queue.
180
+ //---------------------------------------------------------------------------
181
+ get deqOptions() {
182
+ if (!this._deqOptions) {
183
+ const deqOptions = new AqDeqOptions();
184
+ deqOptions._impl = this._impl.deqOptions;
185
+ this._deqOptions = deqOptions;
186
+ }
187
+ return this._deqOptions;
77
188
  }
78
189
 
79
- _getConnection() {
80
- return this._connection;
190
+ //---------------------------------------------------------------------------
191
+ // enqMany()
192
+ //
193
+ // Enqueues multiple messages into the queue at the same time, avoiding
194
+ // multiple round-trips.
195
+ //---------------------------------------------------------------------------
196
+ async enqMany(messages) {
197
+ errors.assertArgCount(arguments, 1, 1);
198
+ errors.assertParamValue(Array.isArray(messages) && messages.length > 0, 1);
199
+ const verifiedMessages = new Array(messages.length);
200
+ for (let i = 0; i < messages.length; i++) {
201
+ verifiedMessages[i] = this._verifyMessage(messages[i]);
202
+ }
203
+ return await this._impl.enqMany(verifiedMessages);
204
+ }
205
+
206
+ //---------------------------------------------------------------------------
207
+ // enqOne()
208
+ //
209
+ // Enqueues a single message into the queue.
210
+ //---------------------------------------------------------------------------
211
+ async enqOne(message) {
212
+ errors.assertArgCount(arguments, 1, 1);
213
+ message = this._verifyMessage(message);
214
+ return await this._impl.enqOne(message);
215
+ }
216
+
217
+ //---------------------------------------------------------------------------
218
+ // enqOptions
219
+ //
220
+ // Property for the enqueue options associated with the queue.
221
+ //---------------------------------------------------------------------------
222
+ get enqOptions() {
223
+ if (!this._enqOptions) {
224
+ const enqOptions = new AqEnqOptions();
225
+ enqOptions._impl = this._impl.enqOptions;
226
+ this._enqOptions = enqOptions;
227
+ }
228
+ return this._enqOptions;
229
+ }
230
+
231
+ //---------------------------------------------------------------------------
232
+ // name
233
+ //
234
+ // Property for the name of the queue.
235
+ //---------------------------------------------------------------------------
236
+ get name() {
237
+ return this._name;
238
+ }
239
+
240
+ //---------------------------------------------------------------------------
241
+ // payloadType
242
+ //
243
+ // Property for the payload type.
244
+ //---------------------------------------------------------------------------
245
+ get payloadType() {
246
+ return this._payloadType;
247
+ }
248
+
249
+ //---------------------------------------------------------------------------
250
+ // payloadTypeName
251
+ //
252
+ // Property for the payload type name.
253
+ //---------------------------------------------------------------------------
254
+ get payloadTypeName() {
255
+ return this._payloadTypeName;
256
+ }
257
+
258
+ //---------------------------------------------------------------------------
259
+ // payloadTypeClass
260
+ //
261
+ // Property for the payload type class.
262
+ //---------------------------------------------------------------------------
263
+ get payloadTypeClass() {
264
+ return this._payloadTypeClass;
81
265
  }
82
266
 
83
267
  }
84
268
 
269
+ nodbUtil.wrapFns(AqQueue.prototype,
270
+ "deqOne",
271
+ "deqMany",
272
+ "enqOne",
273
+ "enqMany");
274
+
85
275
  module.exports = AqQueue;