@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,387 @@
|
|
|
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
|
+
|
|
19
|
+
import * as events from "events"
|
|
20
|
+
import * as tls from "tls"
|
|
21
|
+
import { URL } from "url"
|
|
22
|
+
import { auth } from "./auth"
|
|
23
|
+
import { policies } from "./policies"
|
|
24
|
+
import { types } from "./types"
|
|
25
|
+
import { metadata } from "./metadata"
|
|
26
|
+
import Long = types.Long
|
|
27
|
+
import Uuid = types.Uuid
|
|
28
|
+
|
|
29
|
+
// Export imported submodules
|
|
30
|
+
export { concurrent } from "./concurrent"
|
|
31
|
+
export { mapping } from "./mapping"
|
|
32
|
+
export { auth, metadata, policies, types }
|
|
33
|
+
|
|
34
|
+
export const version: number
|
|
35
|
+
|
|
36
|
+
export function defaultOptions(): ClientOptions
|
|
37
|
+
|
|
38
|
+
export type ValueCallback<T> = (err: Error, val: T) => void
|
|
39
|
+
export type EmptyCallback = (err: Error) => void
|
|
40
|
+
export type ArrayOrObject = any[] | { [key: string]: any }
|
|
41
|
+
|
|
42
|
+
export class Client extends events.EventEmitter {
|
|
43
|
+
hosts: HostMap
|
|
44
|
+
keyspace: string
|
|
45
|
+
metadata: metadata.Metadata
|
|
46
|
+
metrics: null
|
|
47
|
+
|
|
48
|
+
constructor(options: ClientOptions)
|
|
49
|
+
|
|
50
|
+
connect(): Promise<void>
|
|
51
|
+
|
|
52
|
+
connect(callback: EmptyCallback): void
|
|
53
|
+
|
|
54
|
+
execute(
|
|
55
|
+
query: string,
|
|
56
|
+
params?: ArrayOrObject,
|
|
57
|
+
options?: QueryOptions,
|
|
58
|
+
): Promise<types.ResultSet>
|
|
59
|
+
|
|
60
|
+
execute(
|
|
61
|
+
query: string,
|
|
62
|
+
params: ArrayOrObject,
|
|
63
|
+
options: QueryOptions,
|
|
64
|
+
callback: ValueCallback<types.ResultSet>,
|
|
65
|
+
): void
|
|
66
|
+
|
|
67
|
+
execute(
|
|
68
|
+
query: string,
|
|
69
|
+
params: ArrayOrObject,
|
|
70
|
+
callback: ValueCallback<types.ResultSet>,
|
|
71
|
+
): void
|
|
72
|
+
|
|
73
|
+
execute(query: string, callback: ValueCallback<types.ResultSet>): void
|
|
74
|
+
|
|
75
|
+
eachRow(
|
|
76
|
+
query: string,
|
|
77
|
+
params: ArrayOrObject,
|
|
78
|
+
options: QueryOptions,
|
|
79
|
+
rowCallback: (n: number, row: types.Row) => void,
|
|
80
|
+
callback?: ValueCallback<types.ResultSet>,
|
|
81
|
+
): void
|
|
82
|
+
|
|
83
|
+
eachRow(
|
|
84
|
+
query: string,
|
|
85
|
+
params: ArrayOrObject,
|
|
86
|
+
rowCallback: (n: number, row: types.Row) => void,
|
|
87
|
+
callback?: ValueCallback<types.ResultSet>,
|
|
88
|
+
): void
|
|
89
|
+
|
|
90
|
+
eachRow(
|
|
91
|
+
query: string,
|
|
92
|
+
rowCallback: (n: number, row: types.Row) => void,
|
|
93
|
+
): void
|
|
94
|
+
|
|
95
|
+
stream(
|
|
96
|
+
query: string,
|
|
97
|
+
params?: ArrayOrObject,
|
|
98
|
+
options?: QueryOptions,
|
|
99
|
+
callback?: EmptyCallback,
|
|
100
|
+
): events.EventEmitter
|
|
101
|
+
|
|
102
|
+
batch(
|
|
103
|
+
queries: Array<string | { query: string; params?: ArrayOrObject }>,
|
|
104
|
+
options?: QueryOptions,
|
|
105
|
+
): Promise<types.ResultSet>
|
|
106
|
+
|
|
107
|
+
batch(
|
|
108
|
+
queries: Array<string | { query: string; params?: ArrayOrObject }>,
|
|
109
|
+
options: QueryOptions,
|
|
110
|
+
callback: ValueCallback<types.ResultSet>,
|
|
111
|
+
): void
|
|
112
|
+
|
|
113
|
+
batch(
|
|
114
|
+
queries: Array<string | { query: string; params?: ArrayOrObject }>,
|
|
115
|
+
callback: ValueCallback<types.ResultSet>,
|
|
116
|
+
): void
|
|
117
|
+
|
|
118
|
+
shutdown(): Promise<void>
|
|
119
|
+
|
|
120
|
+
shutdown(callback: EmptyCallback): void
|
|
121
|
+
|
|
122
|
+
getReplicas(keyspace: string, token: Buffer): Host[]
|
|
123
|
+
|
|
124
|
+
getState(): metadata.ClientState
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface HostMap extends events.EventEmitter {
|
|
128
|
+
length: number
|
|
129
|
+
|
|
130
|
+
forEach(callback: (value: Host, key: string) => void): void
|
|
131
|
+
|
|
132
|
+
get(key: string): Host
|
|
133
|
+
|
|
134
|
+
keys(): string[]
|
|
135
|
+
|
|
136
|
+
values(): Host[]
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface Host extends events.EventEmitter {
|
|
140
|
+
address: string
|
|
141
|
+
cassandraVersion: string
|
|
142
|
+
datacenter: string
|
|
143
|
+
rack: string
|
|
144
|
+
tokens: string[]
|
|
145
|
+
hostId: types.Uuid
|
|
146
|
+
|
|
147
|
+
canBeConsideredAsUp(): boolean
|
|
148
|
+
|
|
149
|
+
getCassandraVersion(): number[]
|
|
150
|
+
|
|
151
|
+
isUp(): boolean
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface ExecutionOptions {
|
|
155
|
+
getCaptureStackTrace(): boolean
|
|
156
|
+
|
|
157
|
+
getConsistency(): types.consistencies
|
|
158
|
+
|
|
159
|
+
getCustomPayload(): { [key: string]: any }
|
|
160
|
+
|
|
161
|
+
getFetchSize(): number
|
|
162
|
+
|
|
163
|
+
getFixedHost(): Host
|
|
164
|
+
|
|
165
|
+
getHints(): string[] | string[][]
|
|
166
|
+
|
|
167
|
+
isAutoPage(): boolean
|
|
168
|
+
|
|
169
|
+
isBatchCounter(): boolean
|
|
170
|
+
|
|
171
|
+
isBatchLogged(): boolean
|
|
172
|
+
|
|
173
|
+
isIdempotent(): boolean
|
|
174
|
+
|
|
175
|
+
isPrepared(): boolean
|
|
176
|
+
|
|
177
|
+
isQueryTracing(): boolean
|
|
178
|
+
|
|
179
|
+
getKeyspace(): string
|
|
180
|
+
|
|
181
|
+
getLoadBalancingPolicy(): policies.loadBalancing.LoadBalancingPolicy
|
|
182
|
+
|
|
183
|
+
getPageState(): Buffer
|
|
184
|
+
|
|
185
|
+
getRawQueryOptions(): QueryOptions
|
|
186
|
+
|
|
187
|
+
getReadTimeout(): number
|
|
188
|
+
|
|
189
|
+
getRetryPolicy(): policies.retry.RetryPolicy
|
|
190
|
+
|
|
191
|
+
getRoutingKey(): Buffer | Buffer[]
|
|
192
|
+
|
|
193
|
+
getSerialConsistency(): types.consistencies
|
|
194
|
+
|
|
195
|
+
getTimestamp(): number | Long | undefined | null
|
|
196
|
+
|
|
197
|
+
setHints(hints: string[]): void
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface ClientOptions {
|
|
201
|
+
contactPoints?: string[]
|
|
202
|
+
localDataCenter?: string
|
|
203
|
+
keyspace?: string
|
|
204
|
+
authProvider?: auth.AuthProvider
|
|
205
|
+
credentials?: {
|
|
206
|
+
username: string
|
|
207
|
+
password: string
|
|
208
|
+
}
|
|
209
|
+
encoding?: {
|
|
210
|
+
map?: Function
|
|
211
|
+
set?: Function
|
|
212
|
+
copyBuffer?: boolean
|
|
213
|
+
useUndefinedAsUnset?: boolean
|
|
214
|
+
useBigIntAsLong?: boolean
|
|
215
|
+
useBigIntAsVarint?: boolean
|
|
216
|
+
}
|
|
217
|
+
isMetadataSyncEnabled?: boolean
|
|
218
|
+
maxPrepared?: number
|
|
219
|
+
policies?: {
|
|
220
|
+
addressResolution?: policies.addressResolution.AddressTranslator
|
|
221
|
+
loadBalancing?: policies.loadBalancing.LoadBalancingPolicy
|
|
222
|
+
reconnection?: policies.reconnection.ReconnectionPolicy
|
|
223
|
+
retry?: policies.retry.RetryPolicy
|
|
224
|
+
speculativeExecution?: policies.speculativeExecution.SpeculativeExecutionPolicy
|
|
225
|
+
timestampGeneration?: policies.timestampGeneration.TimestampGenerator
|
|
226
|
+
}
|
|
227
|
+
pooling?: {
|
|
228
|
+
coreConnectionsPerHost?: { [key: number]: number }
|
|
229
|
+
heartBeatInterval?: number
|
|
230
|
+
maxRequestsPerConnection?: number
|
|
231
|
+
warmup?: boolean
|
|
232
|
+
}
|
|
233
|
+
prepareOnAllHosts?: boolean
|
|
234
|
+
profiles?: ExecutionProfile[]
|
|
235
|
+
protocolOptions?: {
|
|
236
|
+
maxSchemaAgreementWaitSeconds?: number
|
|
237
|
+
maxVersion?: number
|
|
238
|
+
noCompact?: boolean
|
|
239
|
+
port?: number
|
|
240
|
+
}
|
|
241
|
+
promiseFactory?: (
|
|
242
|
+
handler: (callback: (err: Error, result?: any) => void) => void,
|
|
243
|
+
) => Promise<any>
|
|
244
|
+
queryOptions?: QueryOptions
|
|
245
|
+
refreshSchemaDelay?: number
|
|
246
|
+
rePrepareOnUp?: boolean
|
|
247
|
+
socketOptions?: {
|
|
248
|
+
coalescingThreshold?: number
|
|
249
|
+
connectTimeout?: number
|
|
250
|
+
defunctReadTimeoutThreshold?: number
|
|
251
|
+
keepAlive?: boolean
|
|
252
|
+
keepAliveDelay?: number
|
|
253
|
+
readTimeout?: number
|
|
254
|
+
tcpNoDelay?: boolean
|
|
255
|
+
}
|
|
256
|
+
sslOptions?: tls.ConnectionOptions
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface QueryOptions {
|
|
260
|
+
autoPage?: boolean
|
|
261
|
+
captureStackTrace?: boolean
|
|
262
|
+
consistency?: number
|
|
263
|
+
counter?: boolean
|
|
264
|
+
customPayload?: any
|
|
265
|
+
executionProfile?: string | ExecutionProfile
|
|
266
|
+
fetchSize?: number
|
|
267
|
+
hints?: string[] | string[][]
|
|
268
|
+
host?: Host
|
|
269
|
+
isIdempotent?: boolean
|
|
270
|
+
keyspace?: string
|
|
271
|
+
logged?: boolean
|
|
272
|
+
pageState?: Buffer | string
|
|
273
|
+
prepare?: boolean
|
|
274
|
+
readTimeout?: number
|
|
275
|
+
retry?: policies.retry.RetryPolicy
|
|
276
|
+
routingIndexes?: number[]
|
|
277
|
+
routingKey?: Buffer | Buffer[]
|
|
278
|
+
routingNames?: string[]
|
|
279
|
+
serialConsistency?: number
|
|
280
|
+
timestamp?: number | Long
|
|
281
|
+
traceQuery?: boolean
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export class ExecutionProfile {
|
|
285
|
+
consistency?: types.consistencies
|
|
286
|
+
loadBalancing?: policies.loadBalancing.LoadBalancingPolicy
|
|
287
|
+
name: string
|
|
288
|
+
readTimeout?: number
|
|
289
|
+
retry?: policies.retry.RetryPolicy
|
|
290
|
+
serialConsistency?: types.consistencies
|
|
291
|
+
|
|
292
|
+
constructor(
|
|
293
|
+
name: string,
|
|
294
|
+
options: {
|
|
295
|
+
consistency?: types.consistencies
|
|
296
|
+
loadBalancing?: policies.loadBalancing.LoadBalancingPolicy
|
|
297
|
+
readTimeout?: number
|
|
298
|
+
retry?: policies.retry.RetryPolicy
|
|
299
|
+
serialConsistency?: types.consistencies
|
|
300
|
+
},
|
|
301
|
+
)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export namespace errors {
|
|
305
|
+
class ArgumentError extends DriverError {
|
|
306
|
+
constructor(message: string)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
class AuthenticationError extends DriverError {
|
|
310
|
+
constructor(message: string)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
class BusyConnectionError extends DriverError {
|
|
314
|
+
constructor(
|
|
315
|
+
address: string,
|
|
316
|
+
maxRequestsPerConnection: number,
|
|
317
|
+
connectionLength: number,
|
|
318
|
+
)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
class VIntOutOfRangeException extends DriverError {
|
|
322
|
+
constructor(long: Long)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
abstract class DriverError extends Error {
|
|
326
|
+
info: string
|
|
327
|
+
|
|
328
|
+
constructor(message: string, constructor?: any)
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
class DriverInternalError extends DriverError {
|
|
332
|
+
constructor(message: string)
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
class NoHostAvailableError extends DriverError {
|
|
336
|
+
innerErrors: any
|
|
337
|
+
|
|
338
|
+
constructor(innerErrors: any, message?: string)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
class NotSupportedError extends DriverError {
|
|
342
|
+
constructor(message: string)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
class OperationTimedOutError extends DriverError {
|
|
346
|
+
host?: string
|
|
347
|
+
|
|
348
|
+
constructor(message: string, host?: string)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
class ResponseError extends DriverError {
|
|
352
|
+
code: number
|
|
353
|
+
|
|
354
|
+
constructor(code: number, message: string)
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export namespace token {
|
|
359
|
+
interface Token {
|
|
360
|
+
compare(other: Token): number
|
|
361
|
+
|
|
362
|
+
equals(other: Token): boolean
|
|
363
|
+
|
|
364
|
+
getType(): { code: types.dataTypes; info: any }
|
|
365
|
+
|
|
366
|
+
getValue(): any
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
interface TokenRange {
|
|
370
|
+
start: Token
|
|
371
|
+
end: Token
|
|
372
|
+
|
|
373
|
+
compare(other: TokenRange): number
|
|
374
|
+
|
|
375
|
+
contains(token: Token): boolean
|
|
376
|
+
|
|
377
|
+
equals(other: TokenRange): boolean
|
|
378
|
+
|
|
379
|
+
isEmpty(): boolean
|
|
380
|
+
|
|
381
|
+
isWrappedAround(): boolean
|
|
382
|
+
|
|
383
|
+
splitEvenly(numberOfSplits: number): TokenRange[]
|
|
384
|
+
|
|
385
|
+
unwrap(): TokenRange[]
|
|
386
|
+
}
|
|
387
|
+
}
|
package/driver/index.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
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 clientOptions from "./client-options.js"
|
|
19
|
+
import Client from "./client.js"
|
|
20
|
+
import { ExecutionProfile } from "./execution-profile.js"
|
|
21
|
+
import { ExecutionOptions } from "./execution-options.js"
|
|
22
|
+
import types from "./types/index.js"
|
|
23
|
+
import errors from "./errors.js"
|
|
24
|
+
import policies from "./policies/index.js"
|
|
25
|
+
import auth from "./auth/index.js"
|
|
26
|
+
import mapping from "./mapping/index.js"
|
|
27
|
+
import concurrent from "./concurrent/index.js"
|
|
28
|
+
import { Token, TokenRange } from "./token.js"
|
|
29
|
+
import Metadata from "./metadata/index.js"
|
|
30
|
+
import Encoder from "./encoder.js"
|
|
31
|
+
import { version as pkgVersion } from "../../package.json" with { type: "json" }
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
Client,
|
|
35
|
+
ExecutionProfile,
|
|
36
|
+
ExecutionOptions,
|
|
37
|
+
types,
|
|
38
|
+
errors,
|
|
39
|
+
policies,
|
|
40
|
+
auth,
|
|
41
|
+
mapping,
|
|
42
|
+
concurrent,
|
|
43
|
+
Encoder,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const token = {
|
|
47
|
+
Token: Token,
|
|
48
|
+
TokenRange: TokenRange,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const metadata = {
|
|
52
|
+
Metadata: Metadata,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Returns a new instance of the default [options]{@link ClientOptions} used by the driver.
|
|
57
|
+
*/
|
|
58
|
+
export function defaultOptions() {
|
|
59
|
+
return clientOptions.defaultOptions()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const version = pkgVersion
|
|
63
|
+
|
|
64
|
+
const _default = {
|
|
65
|
+
Client,
|
|
66
|
+
ExecutionProfile,
|
|
67
|
+
ExecutionOptions,
|
|
68
|
+
types,
|
|
69
|
+
errors,
|
|
70
|
+
policies,
|
|
71
|
+
auth,
|
|
72
|
+
mapping,
|
|
73
|
+
concurrent,
|
|
74
|
+
token,
|
|
75
|
+
metadata,
|
|
76
|
+
Encoder,
|
|
77
|
+
defaultOptions,
|
|
78
|
+
version,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default _default
|
|
@@ -0,0 +1,214 @@
|
|
|
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
|
+
|
|
19
|
+
import { QueryOperator, QueryAssignment } from "./q.js"
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Provides utility methods for obtaining a caching keys based on the specifics of the Mapper methods.
|
|
23
|
+
* @ignore
|
|
24
|
+
*/
|
|
25
|
+
class Cache {
|
|
26
|
+
/**
|
|
27
|
+
* Gets an iterator of keys to uniquely identify a document shape for a select query.
|
|
28
|
+
* @param {Array<String>} docKeys
|
|
29
|
+
* @param {Object} doc
|
|
30
|
+
* @param {{fields, limit, orderBy}} docInfo
|
|
31
|
+
* @returns {Iterator}
|
|
32
|
+
*/
|
|
33
|
+
static *getSelectKey(docKeys, doc, docInfo) {
|
|
34
|
+
yield* Cache._yieldKeyAndOperators(docKeys, doc)
|
|
35
|
+
|
|
36
|
+
yield* Cache._getSelectDocInfo(docInfo)
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Gets an iterator of keys to uniquely identify a shape for a select all query.
|
|
40
|
+
* @param {{fields, limit, orderBy}} docInfo
|
|
41
|
+
* @returns {Iterator}
|
|
42
|
+
*/
|
|
43
|
+
static *getSelectAllKey(docInfo) {
|
|
44
|
+
yield "root"
|
|
45
|
+
|
|
46
|
+
yield* Cache._getSelectDocInfo(docInfo)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Gets the parts of the key for a select query related to the docInfo.
|
|
51
|
+
* @param {{fields, limit, orderBy}} docInfo
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
static *_getSelectDocInfo(docInfo) {
|
|
55
|
+
if (docInfo) {
|
|
56
|
+
if (docInfo.fields && docInfo.fields.length > 0) {
|
|
57
|
+
// Use a separator from properties
|
|
58
|
+
yield "|f|"
|
|
59
|
+
yield* docInfo.fields
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (typeof docInfo.limit === "number") {
|
|
63
|
+
yield "|l|"
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (docInfo.orderBy) {
|
|
67
|
+
yield "|o|"
|
|
68
|
+
|
|
69
|
+
// orderBy is uses property names as keys and 'asc'/'desc' as values
|
|
70
|
+
const keys = Object.keys(docInfo.orderBy)
|
|
71
|
+
for (let i = 0; i < keys.length; i++) {
|
|
72
|
+
const key = keys[i]
|
|
73
|
+
yield key
|
|
74
|
+
yield docInfo.orderBy[key]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Gets an iterator of keys to uniquely identify a document shape for an insert query.
|
|
82
|
+
* @param {Array<String>} docKeys
|
|
83
|
+
* @param {{ifNotExists, ttl, fields}} docInfo
|
|
84
|
+
* @returns {Iterator}
|
|
85
|
+
*/
|
|
86
|
+
static *getInsertKey(docKeys, docInfo) {
|
|
87
|
+
// No operator supported on INSERT values
|
|
88
|
+
yield* docKeys
|
|
89
|
+
|
|
90
|
+
if (docInfo) {
|
|
91
|
+
if (docInfo.fields && docInfo.fields.length > 0) {
|
|
92
|
+
// Use a separator from properties
|
|
93
|
+
yield "|f|"
|
|
94
|
+
yield* docInfo.fields
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (typeof docInfo.ttl === "number") {
|
|
98
|
+
yield "|t|"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (docInfo.ifNotExists) {
|
|
102
|
+
yield "|e|"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Gets an iterator of keys to uniquely identify a document shape for an UPDATE query.
|
|
109
|
+
* @param {Array<String>} docKeys
|
|
110
|
+
* @param {Object} doc
|
|
111
|
+
* @param {{ifExists, when, ttl, fields}} docInfo
|
|
112
|
+
*/
|
|
113
|
+
static *getUpdateKey(docKeys, doc, docInfo) {
|
|
114
|
+
yield* Cache._yieldKeyAndAllQs(docKeys, doc)
|
|
115
|
+
|
|
116
|
+
if (docInfo) {
|
|
117
|
+
if (docInfo.fields && docInfo.fields.length > 0) {
|
|
118
|
+
// Use a separator from properties
|
|
119
|
+
yield "|f|"
|
|
120
|
+
yield* docInfo.fields
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (typeof docInfo.ttl === "number") {
|
|
124
|
+
yield "|t|"
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (docInfo.ifExists) {
|
|
128
|
+
yield "|e|"
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (docInfo.when) {
|
|
132
|
+
yield* Cache._yieldKeyAndOperators(
|
|
133
|
+
Object.keys(docInfo.when),
|
|
134
|
+
docInfo.when,
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Gets an iterator of keys to uniquely identify a document shape for a DELETE query.
|
|
142
|
+
* @param {Array<String>} docKeys
|
|
143
|
+
* @param {Object} doc
|
|
144
|
+
* @param {{ifExists, when, fields, deleteOnlyColumns}} docInfo
|
|
145
|
+
* @returns {Iterator}
|
|
146
|
+
*/
|
|
147
|
+
static *getRemoveKey(docKeys, doc, docInfo) {
|
|
148
|
+
yield* Cache._yieldKeyAndOperators(docKeys, doc)
|
|
149
|
+
|
|
150
|
+
if (docInfo) {
|
|
151
|
+
if (docInfo.fields && docInfo.fields.length > 0) {
|
|
152
|
+
// Use a separator from properties
|
|
153
|
+
yield "|f|"
|
|
154
|
+
yield* docInfo.fields
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (docInfo.ifExists) {
|
|
158
|
+
yield "|e|"
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (docInfo.deleteOnlyColumns) {
|
|
162
|
+
yield "|dc|"
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (docInfo.when) {
|
|
166
|
+
yield* Cache._yieldKeyAndOperators(
|
|
167
|
+
Object.keys(docInfo.when),
|
|
168
|
+
docInfo.when,
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static *_yieldKeyAndOperators(keys, obj) {
|
|
175
|
+
for (let i = 0; i < keys.length; i++) {
|
|
176
|
+
const key = keys[i]
|
|
177
|
+
yield key
|
|
178
|
+
yield* Cache._yieldOperators(obj[key])
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
static *_yieldOperators(value) {
|
|
183
|
+
if (
|
|
184
|
+
value !== null &&
|
|
185
|
+
value !== undefined &&
|
|
186
|
+
value instanceof QueryOperator
|
|
187
|
+
) {
|
|
188
|
+
yield value.key
|
|
189
|
+
if (value.hasChildValues) {
|
|
190
|
+
yield* Cache._yieldOperators(value.value[0])
|
|
191
|
+
yield "|/|"
|
|
192
|
+
yield* Cache._yieldOperators(value.value[1])
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
static *_yieldKeyAndAllQs(keys, obj) {
|
|
198
|
+
for (let i = 0; i < keys.length; i++) {
|
|
199
|
+
const key = keys[i]
|
|
200
|
+
yield key
|
|
201
|
+
const value = obj[key]
|
|
202
|
+
if (value !== null && value !== undefined) {
|
|
203
|
+
if (value instanceof QueryOperator) {
|
|
204
|
+
yield* Cache._yieldOperators(value)
|
|
205
|
+
} else if (value instanceof QueryAssignment) {
|
|
206
|
+
yield value.sign
|
|
207
|
+
yield value.inverted
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export default Cache
|