oracledb 5.5.0 → 6.0.0

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.0-darwin-x64.node +0 -0
  7. package/build/Release/oracledb-6.0.0-darwin-x64.node-buildinfo.txt +1 -0
  8. package/build/Release/oracledb-6.0.0-js-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-6.0.0-linux-arm64.node +0 -0
  10. package/build/Release/oracledb-6.0.0-linux-arm64.node-buildinfo.txt +1 -0
  11. package/build/Release/oracledb-6.0.0-linux-x64.node +0 -0
  12. package/build/Release/oracledb-6.0.0-linux-x64.node-buildinfo.txt +1 -0
  13. package/build/Release/oracledb-6.0.0-win32-x64.node +0 -0
  14. package/build/Release/oracledb-6.0.0-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 +146 -7
  20. package/lib/aqEnqOptions.js +59 -7
  21. package/lib/aqMessage.js +118 -7
  22. package/lib/aqQueue.js +242 -53
  23. package/lib/connection.js +1324 -465
  24. package/lib/constants.js +203 -0
  25. package/lib/dbObject.js +346 -32
  26. package/lib/errors.js +781 -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 +156 -68
  43. package/lib/oracledb.js +1047 -345
  44. package/lib/pool.js +654 -465
  45. package/lib/poolStatistics.js +23 -9
  46. package/lib/queryStream.js +14 -7
  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 +107 -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 +1038 -0
  55. package/lib/thin/dbObject.js +629 -0
  56. package/lib/thin/index.js +40 -0
  57. package/lib/thin/lob.js +188 -0
  58. package/lib/thin/pool.js +481 -0
  59. package/lib/thin/protocol/buffer.js +1040 -0
  60. package/lib/thin/protocol/capabilities.js +116 -0
  61. package/lib/thin/protocol/constants.js +764 -0
  62. package/lib/thin/protocol/encryptDecrypt.js +185 -0
  63. package/lib/thin/protocol/messages/auth.js +348 -0
  64. package/lib/thin/protocol/messages/base.js +475 -0
  65. package/lib/thin/protocol/messages/commit.js +56 -0
  66. package/lib/thin/protocol/messages/dataType.js +382 -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 +200 -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 +811 -0
  77. package/lib/thin/protocol/oson.js +660 -0
  78. package/lib/thin/protocol/packet.js +520 -0
  79. package/lib/thin/protocol/protocol.js +202 -0
  80. package/lib/thin/protocol/utils.js +88 -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 +620 -0
  87. package/lib/thin/sqlnet/ntTcp.js +525 -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 +205 -0
  91. package/lib/thin/sqlnet/sessionAtts.js +160 -0
  92. package/lib/thin/statement.js +301 -0
  93. package/lib/thin/util.js +289 -0
  94. package/lib/transformer.js +250 -0
  95. package/lib/types.js +357 -0
  96. package/lib/util.js +194 -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,249 @@
19
26
 
20
27
  'use strict';
21
28
 
29
+ const constants = require('./constants.js');
30
+ const errors = require('./errors.js');
22
31
  const nodbUtil = require('./util.js');
32
+ const AqDeqOptions = require('./aqDeqOptions.js');
33
+ const AqEnqOptions = require('./aqEnqOptions.js');
34
+ const AqMessage = require('./aqMessage.js');
35
+ const BaseDbObject = require('./dbObject.js');
23
36
 
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
- }
37
+ class AqQueue {
32
38
 
39
+ //---------------------------------------------------------------------------
40
+ // _isPayload()
41
+ //
42
+ // Returns a boolean indicating if the value is a valid payload.
43
+ //---------------------------------------------------------------------------
44
+ _isPayload(value) {
45
+ return (typeof value === 'string' || Buffer.isBuffer(value) ||
46
+ value instanceof BaseDbObject);
47
+ }
33
48
 
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
- }
49
+ //---------------------------------------------------------------------------
50
+ // _verifyMessage()
51
+ //
52
+ // Messages that can be enqueued must be a string, Buffer or database object
53
+ // (in which case all message properties are defaulted) or an object
54
+ // containing a "payload" property along with the other properties to use
55
+ // during the enqueue. A normalized object is returned.
56
+ //---------------------------------------------------------------------------
57
+ _verifyMessage(message) {
44
58
 
59
+ // validate we have a payload of the correct type
60
+ let payload;
61
+ if (this._isPayload(message)) {
62
+ payload = message;
63
+ message = {};
64
+ } else {
65
+ message = {...message};
66
+ if (this._isPayload(message.payload)) {
67
+ payload = message.payload;
68
+ } else if (this._payloadTypeClass) {
69
+ payload = new this._payloadTypeClass(message.payload);
70
+ } else {
71
+ errors.throwErr(errors.ERR_INVALID_AQ_MESSAGE);
72
+ }
73
+ }
45
74
 
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
- }
75
+ // validate payload
76
+ if (typeof payload === 'string') {
77
+ message.payload = Buffer.from(payload);
78
+ } else if (Buffer.isBuffer(payload)) {
79
+ message.payload = payload;
80
+ } else {
81
+ message.payload = payload._impl;
82
+ }
56
83
 
84
+ // validate options, if applicable
85
+ if (message.correlation !== undefined) {
86
+ errors.assertParamPropValue(typeof message.correlation === 'string', 1,
87
+ "correlation");
88
+ }
89
+ if (message.delay !== undefined) {
90
+ errors.assertParamPropValue(Number.isInteger(message.delay), 1, "delay");
91
+ }
92
+ if (message.exceptionQueue !== undefined) {
93
+ errors.assertParamPropValue(typeof message.exceptionQueue === 'string',
94
+ 1, "exceptionQueue");
95
+ }
96
+ if (message.expiration !== undefined) {
97
+ errors.assertParamPropValue(Number.isInteger(message.expiration), 1,
98
+ "expiration");
99
+ }
100
+ if (message.priority !== undefined) {
101
+ errors.assertParamPropValue(Number.isInteger(message.priority), 1,
102
+ "priority");
103
+ }
104
+ if (message.recipients !== undefined) {
105
+ errors.assertParamPropValue(nodbUtil.isArrayOfStrings(message.recipients),
106
+ 1, "recipients");
107
+ }
57
108
 
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
- }
109
+ return message;
110
+ }
111
+
112
+ //---------------------------------------------------------------------------
113
+ // create()
114
+ //
115
+ // Creates the queue and populates some internal attributes.
116
+ //---------------------------------------------------------------------------
117
+ async create(conn, name, options) {
118
+ if (options.payloadType) {
119
+ if (typeof options.payloadType == 'string') {
120
+ const cls = await conn._getDbObjectClassForName(options.payloadType);
121
+ this._payloadTypeClass = cls;
122
+ options.payloadType = cls;
123
+ } else {
124
+ errors.assertParamPropValue(nodbUtil.isObject(options.payloadType) &&
125
+ options.payloadType.prototype instanceof BaseDbObject, 2, "payloadType");
126
+ this._payloadTypeClass = options.payloadType;
127
+ }
128
+ this._payloadType = constants.DB_TYPE_OBJECT;
129
+ this._payloadTypeName = this._payloadTypeClass.prototype.name;
130
+ } else {
131
+ this._payloadType = constants.DB_TYPE_RAW;
132
+ this._payloadTypeName = "RAW";
133
+ }
134
+ this._name = name;
135
+ this._impl = await conn._impl.getQueue(name, options);
136
+ }
68
137
 
138
+ //---------------------------------------------------------------------------
139
+ // deqMany()
140
+ //
141
+ // Returns an array of messages from the queue, up to the maximum specified,
142
+ // if any are available.
143
+ //---------------------------------------------------------------------------
144
+ async deqMany(maxMessages) {
145
+ errors.assertArgCount(arguments, 1, 1);
146
+ errors.assertParamValue(Number.isInteger(maxMessages) && maxMessages > 0,
147
+ 1);
148
+ const msgImpls = await this._impl.deqMany(maxMessages);
149
+ const messages = new Array(msgImpls.length);
150
+ for (let i = 0; i < msgImpls.length; i++) {
151
+ const msg = new AqMessage();
152
+ msg._impl = msgImpls[i];
153
+ msg._payloadTypeClass = this._payloadTypeClass;
154
+ messages[i] = msg;
155
+ }
156
+ return messages;
157
+ }
69
158
 
70
- class AqQueue {
159
+ //---------------------------------------------------------------------------
160
+ // deqOne()
161
+ //
162
+ // Returns a single message from the queue, if one is available.
163
+ //---------------------------------------------------------------------------
164
+ async deqOne() {
165
+ errors.assertArgCount(arguments, 0, 0);
166
+ const msgImpl = await this._impl.deqOne();
167
+ if (msgImpl) {
168
+ const msg = new AqMessage();
169
+ msg._impl = msgImpl;
170
+ msg._payloadTypeClass = this._payloadTypeClass;
171
+ return msg;
172
+ }
173
+ }
71
174
 
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));
175
+ //---------------------------------------------------------------------------
176
+ // deqOptions
177
+ //
178
+ // Property for the dequeue options associated with the queue.
179
+ //---------------------------------------------------------------------------
180
+ get deqOptions() {
181
+ if (!this._deqOptions) {
182
+ const deqOptions = new AqDeqOptions();
183
+ deqOptions._impl = this._impl.deqOptions;
184
+ this._deqOptions = deqOptions;
185
+ }
186
+ return this._deqOptions;
77
187
  }
78
188
 
79
- _getConnection() {
80
- return this._connection;
189
+ //---------------------------------------------------------------------------
190
+ // enqMany()
191
+ //
192
+ // Enqueues multiple messages into the queue at the same time, avoiding
193
+ // multiple round-trips.
194
+ //---------------------------------------------------------------------------
195
+ async enqMany(messages) {
196
+ errors.assertArgCount(arguments, 1, 1);
197
+ errors.assertParamValue(Array.isArray(messages) && messages.length > 0, 1);
198
+ const verifiedMessages = new Array(messages.length);
199
+ for (let i = 0; i < messages.length; i++) {
200
+ verifiedMessages[i] = this._verifyMessage(messages[i]);
201
+ }
202
+ return await this._impl.enqMany(verifiedMessages);
203
+ }
204
+
205
+ //---------------------------------------------------------------------------
206
+ // enqOne()
207
+ //
208
+ // Enqueues a single message into the queue.
209
+ //---------------------------------------------------------------------------
210
+ async enqOne(message) {
211
+ errors.assertArgCount(arguments, 1, 1);
212
+ message = this._verifyMessage(message);
213
+ return await this._impl.enqOne(message);
214
+ }
215
+
216
+ //---------------------------------------------------------------------------
217
+ // enqOptions
218
+ //
219
+ // Property for the enqueue options associated with the queue.
220
+ //---------------------------------------------------------------------------
221
+ get enqOptions() {
222
+ if (!this._enqOptions) {
223
+ const enqOptions = new AqEnqOptions();
224
+ enqOptions._impl = this._impl.enqOptions;
225
+ this._enqOptions = enqOptions;
226
+ }
227
+ return this._enqOptions;
228
+ }
229
+
230
+ //---------------------------------------------------------------------------
231
+ // name
232
+ //
233
+ // Property for the name of the queue.
234
+ //---------------------------------------------------------------------------
235
+ get name() {
236
+ return this._name;
237
+ }
238
+
239
+ //---------------------------------------------------------------------------
240
+ // payloadType
241
+ //
242
+ // Property for the payload type.
243
+ //---------------------------------------------------------------------------
244
+ get payloadType() {
245
+ return this._payloadType;
246
+ }
247
+
248
+ //---------------------------------------------------------------------------
249
+ // payloadTypeName
250
+ //
251
+ // Property for the payload type name.
252
+ //---------------------------------------------------------------------------
253
+ get payloadTypeName() {
254
+ return this._payloadTypeName;
255
+ }
256
+
257
+ //---------------------------------------------------------------------------
258
+ // payloadTypeClass
259
+ //
260
+ // Property for the payload type class.
261
+ //---------------------------------------------------------------------------
262
+ get payloadTypeClass() {
263
+ return this._payloadTypeClass;
81
264
  }
82
265
 
83
266
  }
84
267
 
268
+ nodbUtil.wrapFns(AqQueue.prototype,
269
+ "deqOne",
270
+ "deqMany",
271
+ "enqOne",
272
+ "enqMany");
273
+
85
274
  module.exports = AqQueue;