@ragestudio/scylla-odm 0.22.2 → 0.22.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/batch/index.d.ts +3 -3
- package/batch/index.d.ts.map +1 -1
- package/client.d.ts +6 -5
- package/client.d.ts.map +1 -1
- package/client.js +11 -12
- package/client.js.map +1 -1
- package/cql_gen/create_table.d.ts +1 -1
- package/cql_gen/create_table.d.ts.map +1 -1
- package/document/index.d.ts +3 -3
- package/document/index.d.ts.map +1 -1
- package/driver/LICENSE.txt +177 -0
- package/driver/NOTICE.txt +67 -0
- package/driver/auth/index.d.ts +37 -0
- package/driver/auth/index.js +37 -0
- package/driver/auth/no-auth-provider.js +73 -0
- package/driver/auth/plain-text-auth-provider.js +81 -0
- package/driver/auth/provider.js +77 -0
- package/driver/client-options.js +442 -0
- package/driver/client.js +1267 -0
- package/driver/concurrent/index.d.ts +49 -0
- package/driver/concurrent/index.js +366 -0
- package/driver/connection.js +1034 -0
- package/driver/control-connection.js +1282 -0
- package/driver/encoder.js +2316 -0
- package/driver/errors.js +223 -0
- package/driver/execution-options.js +612 -0
- package/driver/execution-profile.js +274 -0
- package/driver/host-connection-pool.js +587 -0
- package/driver/host.js +699 -0
- package/driver/index.d.ts +387 -0
- package/driver/index.js +81 -0
- package/driver/mapping/cache.js +214 -0
- package/driver/mapping/doc-info-adapter.js +171 -0
- package/driver/mapping/index.d.ts +219 -0
- package/driver/mapping/index.js +57 -0
- package/driver/mapping/mapper.js +225 -0
- package/driver/mapping/mapping-handler.js +641 -0
- package/driver/mapping/model-batch-item.js +215 -0
- package/driver/mapping/model-batch-mapper.js +141 -0
- package/driver/mapping/model-mapper.js +315 -0
- package/driver/mapping/model-mapping-info.js +225 -0
- package/driver/mapping/object-selector.js +417 -0
- package/driver/mapping/q.js +156 -0
- package/driver/mapping/query-generator.js +556 -0
- package/driver/mapping/result-mapper.js +123 -0
- package/driver/mapping/result.js +139 -0
- package/driver/mapping/table-mappings.js +133 -0
- package/driver/mapping/tree.js +160 -0
- package/driver/metadata/aggregate.js +79 -0
- package/driver/metadata/client-state.js +119 -0
- package/driver/metadata/data-collection.js +182 -0
- package/driver/metadata/event-debouncer.js +174 -0
- package/driver/metadata/index.d.ts +276 -0
- package/driver/metadata/index.js +1156 -0
- package/driver/metadata/materialized-view.js +49 -0
- package/driver/metadata/schema-function.js +98 -0
- package/driver/metadata/schema-index.js +166 -0
- package/driver/metadata/schema-parser.js +1399 -0
- package/driver/metadata/table-metadata.js +77 -0
- package/driver/operation-state.js +206 -0
- package/driver/policies/address-resolution.js +145 -0
- package/driver/policies/index.d.ts +241 -0
- package/driver/policies/index.js +110 -0
- package/driver/policies/load-balancing.js +970 -0
- package/driver/policies/reconnection.js +166 -0
- package/driver/policies/retry.js +326 -0
- package/driver/policies/speculative-execution.js +150 -0
- package/driver/policies/timestamp-generation.js +176 -0
- package/driver/prepare-handler.js +347 -0
- package/driver/promise-utils.js +191 -0
- package/driver/readers.js +624 -0
- package/driver/request-execution.js +644 -0
- package/driver/request-handler.js +332 -0
- package/driver/requests.js +618 -0
- package/driver/stream-id-stack.js +209 -0
- package/driver/streams.js +745 -0
- package/driver/token.js +325 -0
- package/driver/tokenizer.js +631 -0
- package/driver/types/big-decimal.js +282 -0
- package/driver/types/duration.js +576 -0
- package/driver/types/index.d.ts +486 -0
- package/driver/types/index.js +733 -0
- package/driver/types/inet-address.js +262 -0
- package/driver/types/integer.js +818 -0
- package/driver/types/local-date.js +280 -0
- package/driver/types/local-time.js +299 -0
- package/driver/types/mutable-long.js +385 -0
- package/driver/types/protocol-version.js +391 -0
- package/driver/types/result-set.js +287 -0
- package/driver/types/result-stream.js +164 -0
- package/driver/types/row.js +85 -0
- package/driver/types/time-uuid.js +414 -0
- package/driver/types/tuple.js +103 -0
- package/driver/types/uuid.js +160 -0
- package/driver/types/vector.js +130 -0
- package/driver/types/version-number.js +153 -0
- package/driver/utils.js +1485 -0
- package/driver/writers.js +350 -0
- package/global.d.ts +1 -1
- package/global.d.ts.map +1 -1
- package/index.d.ts +6 -6
- package/index.d.ts.map +1 -1
- package/index.js +6 -6
- package/index.js.map +1 -1
- package/migrate/index.d.ts +1 -1
- package/migrate/index.d.ts.map +1 -1
- package/migrate/index.js +1 -1
- package/migrate/index.js.map +1 -1
- package/model/index.d.ts +6 -6
- package/model/index.d.ts.map +1 -1
- package/model/index.js +10 -10
- package/model/index.js.map +1 -1
- package/operations/countAll.d.ts +1 -1
- package/operations/countAll.d.ts.map +1 -1
- package/operations/delete.d.ts +3 -4
- package/operations/delete.d.ts.map +1 -1
- package/operations/delete.js +1 -1
- package/operations/delete.js.map +1 -1
- package/operations/find.d.ts +2 -2
- package/operations/find.d.ts.map +1 -1
- package/operations/find.js +1 -1
- package/operations/find.js.map +1 -1
- package/operations/findOne.d.ts +2 -2
- package/operations/findOne.d.ts.map +1 -1
- package/operations/findOne.js +1 -1
- package/operations/findOne.js.map +1 -1
- package/operations/insert.d.ts +3 -3
- package/operations/insert.d.ts.map +1 -1
- package/operations/insert.js +2 -2
- package/operations/insert.js.map +1 -1
- package/operations/sync.d.ts +1 -1
- package/operations/sync.d.ts.map +1 -1
- package/operations/sync.js +1 -1
- package/operations/sync.js.map +1 -1
- package/operations/tableExists.d.ts +1 -1
- package/operations/tableExists.d.ts.map +1 -1
- package/operations/update.d.ts +3 -3
- package/operations/update.d.ts.map +1 -1
- package/operations/update.js +2 -2
- package/operations/update.js.map +1 -1
- package/package.json +4 -12
- package/schema/index.d.ts +1 -1
- package/schema/index.d.ts.map +1 -1
- package/types.d.ts +4 -4
- package/types.d.ts.map +1 -1
- package/utils/queryParser.d.ts +1 -1
- package/utils/queryParser.d.ts.map +1 -1
- package/utils/queryParser.js +1 -1
- package/utils/queryParser.js.map +1 -1
- package/utils/typeChecker.d.ts +1 -1
- package/utils/typeChecker.d.ts.map +1 -1
- package/utils/typeChecker.js +1 -1
- package/utils/typeChecker.js.map +1 -1
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import utils from "../utils.js"
|
|
19
|
+
|
|
20
|
+
/** @module types */
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new instance of InetAddress
|
|
23
|
+
* @class
|
|
24
|
+
* @classdesc Represents an v4 or v6 Internet Protocol (IP) address.
|
|
25
|
+
* @param {Buffer} buffer
|
|
26
|
+
* @constructor
|
|
27
|
+
*/
|
|
28
|
+
function InetAddress(buffer) {
|
|
29
|
+
if (
|
|
30
|
+
!(buffer instanceof Buffer) ||
|
|
31
|
+
(buffer.length !== 4 && buffer.length !== 16)
|
|
32
|
+
) {
|
|
33
|
+
throw new TypeError("The ip address must contain 4 or 16 bytes")
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Immutable buffer that represents the IP address
|
|
38
|
+
* @type Array
|
|
39
|
+
*/
|
|
40
|
+
this.buffer = buffer
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns the length of the underlying buffer
|
|
44
|
+
* @type Number
|
|
45
|
+
*/
|
|
46
|
+
this.length = buffer.length
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Returns the Ip version (4 or 6)
|
|
50
|
+
* @type Number
|
|
51
|
+
*/
|
|
52
|
+
this.version = buffer.length === 4 ? 4 : 6
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Parses the string representation and returns an Ip address
|
|
57
|
+
* @param {String} value
|
|
58
|
+
*/
|
|
59
|
+
InetAddress.fromString = function (value) {
|
|
60
|
+
if (!value) {
|
|
61
|
+
return new InetAddress(utils.allocBufferFromArray([0, 0, 0, 0]))
|
|
62
|
+
}
|
|
63
|
+
const ipv4Pattern = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
|
|
64
|
+
const ipv6Pattern = /^[\da-f:.]+$/i
|
|
65
|
+
let parts
|
|
66
|
+
if (ipv4Pattern.test(value)) {
|
|
67
|
+
parts = value.split(".")
|
|
68
|
+
return new InetAddress(utils.allocBufferFromArray(parts))
|
|
69
|
+
}
|
|
70
|
+
if (!ipv6Pattern.test(value)) {
|
|
71
|
+
throw new TypeError(
|
|
72
|
+
"Value could not be parsed as InetAddress: " + value,
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
parts = value.split(":")
|
|
76
|
+
if (parts.length < 3) {
|
|
77
|
+
throw new TypeError(
|
|
78
|
+
"Value could not be parsed as InetAddress: " + value,
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
const buffer = utils.allocBufferUnsafe(16)
|
|
82
|
+
let filling = 8 - parts.length + 1
|
|
83
|
+
let applied = false
|
|
84
|
+
let offset = 0
|
|
85
|
+
const embeddedIp4 = ipv4Pattern.test(parts[parts.length - 1])
|
|
86
|
+
if (embeddedIp4) {
|
|
87
|
+
// Its IPv6 address with an embedded IPv4 address:
|
|
88
|
+
// subtract 1 from the potential empty filling as ip4 contains 4 bytes instead of 2 of a ipv6 section
|
|
89
|
+
filling -= 1
|
|
90
|
+
}
|
|
91
|
+
function writeItem(uIntValue) {
|
|
92
|
+
buffer.writeUInt8(+uIntValue, offset++)
|
|
93
|
+
}
|
|
94
|
+
for (let i = 0; i < parts.length; i++) {
|
|
95
|
+
const item = parts[i]
|
|
96
|
+
if (item) {
|
|
97
|
+
if (embeddedIp4 && i === parts.length - 1) {
|
|
98
|
+
item.split(".").forEach(writeItem)
|
|
99
|
+
break
|
|
100
|
+
}
|
|
101
|
+
buffer.writeUInt16BE(parseInt(item, 16), offset)
|
|
102
|
+
offset = offset + 2
|
|
103
|
+
continue
|
|
104
|
+
}
|
|
105
|
+
//its an empty string
|
|
106
|
+
if (applied) {
|
|
107
|
+
//there could be 2 occurrences of empty string
|
|
108
|
+
filling = 1
|
|
109
|
+
}
|
|
110
|
+
applied = true
|
|
111
|
+
for (let j = 0; j < filling; j++) {
|
|
112
|
+
buffer[offset++] = 0
|
|
113
|
+
buffer[offset++] = 0
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (embeddedIp4 && !isValidIPv4Mapped(buffer)) {
|
|
117
|
+
throw new TypeError(
|
|
118
|
+
"Only IPv4-Mapped IPv6 addresses are allowed as IPv6 address with embedded IPv4 address",
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
return new InetAddress(buffer)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Compares 2 addresses and returns true if the underlying bytes are the same
|
|
126
|
+
* @param {InetAddress} other
|
|
127
|
+
* @returns {Boolean}
|
|
128
|
+
*/
|
|
129
|
+
InetAddress.prototype.equals = function (other) {
|
|
130
|
+
if (!(other instanceof InetAddress)) {
|
|
131
|
+
return false
|
|
132
|
+
}
|
|
133
|
+
return (
|
|
134
|
+
this.buffer.length === other.buffer.length &&
|
|
135
|
+
this.buffer.toString("hex") === other.buffer.toString("hex")
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Returns the underlying buffer
|
|
141
|
+
* @returns {Buffer}
|
|
142
|
+
*/
|
|
143
|
+
InetAddress.prototype.getBuffer = function () {
|
|
144
|
+
return this.buffer
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Provide the name of the constructor and the string representation
|
|
149
|
+
* @returns {string}
|
|
150
|
+
*/
|
|
151
|
+
InetAddress.prototype.inspect = function () {
|
|
152
|
+
return this.constructor.name + ": " + this.toString()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Returns the string representation of the IP address.
|
|
157
|
+
* <p>For v4 IP addresses, a string in the form of d.d.d.d is returned.</p>
|
|
158
|
+
* <p>
|
|
159
|
+
* For v6 IP addresses, a string in the form of x:x:x:x:x:x:x:x is returned, where the 'x's are the hexadecimal
|
|
160
|
+
* values of the eight 16-bit pieces of the address, according to rfc5952.
|
|
161
|
+
* In cases where there is more than one field of only zeros, it can be shortened. For example, 2001:0db8:0:0:0:1:0:1
|
|
162
|
+
* will be expressed as 2001:0db8::1:0:1.
|
|
163
|
+
* </p>
|
|
164
|
+
* @param {String} [encoding]
|
|
165
|
+
* @returns {String}
|
|
166
|
+
*/
|
|
167
|
+
InetAddress.prototype.toString = function (encoding) {
|
|
168
|
+
if (encoding === "hex") {
|
|
169
|
+
//backward compatibility: behave in the same way as the buffer
|
|
170
|
+
return this.buffer.toString("hex")
|
|
171
|
+
}
|
|
172
|
+
if (this.buffer.length === 4) {
|
|
173
|
+
return (
|
|
174
|
+
this.buffer[0] +
|
|
175
|
+
"." +
|
|
176
|
+
this.buffer[1] +
|
|
177
|
+
"." +
|
|
178
|
+
this.buffer[2] +
|
|
179
|
+
"." +
|
|
180
|
+
this.buffer[3]
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
let start = -1
|
|
184
|
+
const longest = { length: 0, start: -1 }
|
|
185
|
+
function checkLongest(i) {
|
|
186
|
+
if (start >= 0) {
|
|
187
|
+
//close the group
|
|
188
|
+
const length = i - start
|
|
189
|
+
if (length > longest.length) {
|
|
190
|
+
longest.length = length
|
|
191
|
+
longest.start = start
|
|
192
|
+
start = -1
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
//get the longest 16-bit group of zeros
|
|
197
|
+
for (let i = 0; i < this.buffer.length; i = i + 2) {
|
|
198
|
+
if (this.buffer[i] === 0 && this.buffer[i + 1] === 0) {
|
|
199
|
+
//its a group of zeros
|
|
200
|
+
if (start < 0) {
|
|
201
|
+
start = i
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// at the end of the buffer, make a final call to checkLongest.
|
|
205
|
+
if (i === this.buffer.length - 2) {
|
|
206
|
+
checkLongest(i + 2)
|
|
207
|
+
}
|
|
208
|
+
continue
|
|
209
|
+
}
|
|
210
|
+
//its a group of non-zeros
|
|
211
|
+
checkLongest(i)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
let address = ""
|
|
215
|
+
for (let h = 0; h < this.buffer.length; h = h + 2) {
|
|
216
|
+
if (h === longest.start) {
|
|
217
|
+
address += ":"
|
|
218
|
+
continue
|
|
219
|
+
}
|
|
220
|
+
if (h < longest.start + longest.length && h > longest.start) {
|
|
221
|
+
//its a group of zeros
|
|
222
|
+
continue
|
|
223
|
+
}
|
|
224
|
+
if (address.length > 0) {
|
|
225
|
+
address += ":"
|
|
226
|
+
}
|
|
227
|
+
address += ((this.buffer[h] << 8) | this.buffer[h + 1]).toString(16)
|
|
228
|
+
}
|
|
229
|
+
if (address.charAt(address.length - 1) === ":") {
|
|
230
|
+
address += ":"
|
|
231
|
+
}
|
|
232
|
+
return address
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Returns the string representation.
|
|
237
|
+
* Method used by the native JSON.stringify() to serialize this instance.
|
|
238
|
+
*/
|
|
239
|
+
InetAddress.prototype.toJSON = function () {
|
|
240
|
+
return this.toString()
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Validates for a IPv4-Mapped IPv6 according to https://tools.ietf.org/html/rfc4291#section-2.2.5.5
|
|
245
|
+
* @private
|
|
246
|
+
* @param {Buffer} buffer
|
|
247
|
+
*/
|
|
248
|
+
function isValidIPv4Mapped(buffer) {
|
|
249
|
+
// check the form
|
|
250
|
+
// | 80 bits | 16 | 32 bits
|
|
251
|
+
// +----------------+----+-------------
|
|
252
|
+
// |0000........0000|FFFF| IPv4 address
|
|
253
|
+
|
|
254
|
+
for (let i = 0; i < buffer.length - 6; i++) {
|
|
255
|
+
if (buffer[i] !== 0) {
|
|
256
|
+
return false
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return !(buffer[10] !== 255 || buffer[11] !== 255)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export default InetAddress
|