@ragestudio/scylla-odm 0.19.0 → 0.19.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 (131) hide show
  1. package/client.d.ts +1 -1
  2. package/document/index.d.ts +1 -1
  3. package/driver/{lib/auth → auth}/index.d.ts +1 -1
  4. package/driver/client.js +1 -0
  5. package/driver/{lib/concurrent → concurrent}/index.d.ts +2 -2
  6. package/driver/{lib/datastax → datastax}/graph/index.d.ts +1 -1
  7. package/driver/{lib/datastax → datastax}/index.d.ts +1 -1
  8. package/driver/{lib/datastax → datastax}/search/index.d.ts +1 -1
  9. package/driver/{lib/geometry → geometry}/index.d.ts +1 -1
  10. package/driver/index.d.ts +9 -9
  11. package/driver/index.js +1 -1
  12. package/driver/insights-client.js +1 -0
  13. package/driver/{lib/mapping → mapping}/index.d.ts +2 -2
  14. package/driver/{lib/metadata → metadata}/index.d.ts +2 -2
  15. package/driver/{lib/metrics → metrics}/index.d.ts +2 -2
  16. package/driver/{lib/policies → policies}/index.d.ts +2 -2
  17. package/driver/requests.js +1 -0
  18. package/driver/{lib/tracker → tracker}/index.d.ts +2 -2
  19. package/driver/{lib/types → types}/index.d.ts +2 -2
  20. package/driver/types/index.js +1 -0
  21. package/model/index.d.ts +1 -1
  22. package/operations/delete.d.ts +1 -1
  23. package/package.js +1 -1
  24. package/package.json +1 -1
  25. package/types.d.ts +1 -1
  26. package/driver/lib/client.js +0 -1
  27. package/driver/lib/insights-client.js +0 -1
  28. package/driver/lib/requests.js +0 -1
  29. package/driver/lib/types/index.js +0 -1
  30. /package/driver/{lib/auth → auth}/base-dse-authenticator.js +0 -0
  31. /package/driver/{lib/auth → auth}/dse-gssapi-auth-provider.js +0 -0
  32. /package/driver/{lib/auth → auth}/dse-plain-text-auth-provider.js +0 -0
  33. /package/driver/{lib/auth → auth}/gssapi-client.js +0 -0
  34. /package/driver/{lib/auth → auth}/index.js +0 -0
  35. /package/driver/{lib/auth → auth}/no-auth-provider.js +0 -0
  36. /package/driver/{lib/auth → auth}/plain-text-auth-provider.js +0 -0
  37. /package/driver/{lib/auth → auth}/provider.js +0 -0
  38. /package/driver/{lib/client-options.js → client-options.js} +0 -0
  39. /package/driver/{lib/concurrent → concurrent}/index.js +0 -0
  40. /package/driver/{lib/connection.js → connection.js} +0 -0
  41. /package/driver/{lib/control-connection.js → control-connection.js} +0 -0
  42. /package/driver/{lib/datastax → datastax}/graph/complex-type-helper.js +0 -0
  43. /package/driver/{lib/datastax → datastax}/graph/custom-type-serializers.js +0 -0
  44. /package/driver/{lib/datastax → datastax}/graph/graph-executor.js +0 -0
  45. /package/driver/{lib/datastax → datastax}/graph/graph-serializer.js +0 -0
  46. /package/driver/{lib/datastax → datastax}/graph/index.js +0 -0
  47. /package/driver/{lib/datastax → datastax}/graph/options.js +0 -0
  48. /package/driver/{lib/datastax → datastax}/graph/result-set.js +0 -0
  49. /package/driver/{lib/datastax → datastax}/graph/structure.js +0 -0
  50. /package/driver/{lib/datastax → datastax}/graph/type-serializers.js +0 -0
  51. /package/driver/{lib/datastax → datastax}/graph/wrappers.js +0 -0
  52. /package/driver/{lib/datastax → datastax}/search/date-range.js +0 -0
  53. /package/driver/{lib/datastax → datastax}/search/index.js +0 -0
  54. /package/driver/{lib/encoder.js → encoder.js} +0 -0
  55. /package/driver/{lib/errors.js → errors.js} +0 -0
  56. /package/driver/{lib/execution-options.js → execution-options.js} +0 -0
  57. /package/driver/{lib/execution-profile.js → execution-profile.js} +0 -0
  58. /package/driver/{lib/geometry → geometry}/geometry.js +0 -0
  59. /package/driver/{lib/geometry → geometry}/index.js +0 -0
  60. /package/driver/{lib/geometry → geometry}/line-string.js +0 -0
  61. /package/driver/{lib/geometry → geometry}/point.js +0 -0
  62. /package/driver/{lib/geometry → geometry}/polygon.js +0 -0
  63. /package/driver/{lib/host-connection-pool.js → host-connection-pool.js} +0 -0
  64. /package/driver/{lib/host.js → host.js} +0 -0
  65. /package/driver/{lib/mapping → mapping}/cache.js +0 -0
  66. /package/driver/{lib/mapping → mapping}/doc-info-adapter.js +0 -0
  67. /package/driver/{lib/mapping → mapping}/index.js +0 -0
  68. /package/driver/{lib/mapping → mapping}/mapper.js +0 -0
  69. /package/driver/{lib/mapping → mapping}/mapping-handler.js +0 -0
  70. /package/driver/{lib/mapping → mapping}/model-batch-item.js +0 -0
  71. /package/driver/{lib/mapping → mapping}/model-batch-mapper.js +0 -0
  72. /package/driver/{lib/mapping → mapping}/model-mapper.js +0 -0
  73. /package/driver/{lib/mapping → mapping}/model-mapping-info.js +0 -0
  74. /package/driver/{lib/mapping → mapping}/object-selector.js +0 -0
  75. /package/driver/{lib/mapping → mapping}/q.js +0 -0
  76. /package/driver/{lib/mapping → mapping}/query-generator.js +0 -0
  77. /package/driver/{lib/mapping → mapping}/result-mapper.js +0 -0
  78. /package/driver/{lib/mapping → mapping}/result.js +0 -0
  79. /package/driver/{lib/mapping → mapping}/table-mappings.js +0 -0
  80. /package/driver/{lib/mapping → mapping}/tree.js +0 -0
  81. /package/driver/{lib/metadata → metadata}/aggregate.js +0 -0
  82. /package/driver/{lib/metadata → metadata}/client-state.js +0 -0
  83. /package/driver/{lib/metadata → metadata}/data-collection.js +0 -0
  84. /package/driver/{lib/metadata → metadata}/event-debouncer.js +0 -0
  85. /package/driver/{lib/metadata → metadata}/index.js +0 -0
  86. /package/driver/{lib/metadata → metadata}/materialized-view.js +0 -0
  87. /package/driver/{lib/metadata → metadata}/schema-function.js +0 -0
  88. /package/driver/{lib/metadata → metadata}/schema-index.js +0 -0
  89. /package/driver/{lib/metadata → metadata}/schema-parser.js +0 -0
  90. /package/driver/{lib/metadata → metadata}/table-metadata.js +0 -0
  91. /package/driver/{lib/metrics → metrics}/client-metrics.js +0 -0
  92. /package/driver/{lib/metrics → metrics}/default-metrics.js +0 -0
  93. /package/driver/{lib/metrics → metrics}/index.js +0 -0
  94. /package/driver/{lib/operation-state.js → operation-state.js} +0 -0
  95. /package/driver/{lib/policies → policies}/address-resolution.js +0 -0
  96. /package/driver/{lib/policies → policies}/index.js +0 -0
  97. /package/driver/{lib/policies → policies}/load-balancing.js +0 -0
  98. /package/driver/{lib/policies → policies}/reconnection.js +0 -0
  99. /package/driver/{lib/policies → policies}/retry.js +0 -0
  100. /package/driver/{lib/policies → policies}/speculative-execution.js +0 -0
  101. /package/driver/{lib/policies → policies}/timestamp-generation.js +0 -0
  102. /package/driver/{lib/prepare-handler.js → prepare-handler.js} +0 -0
  103. /package/driver/{lib/promise-utils.js → promise-utils.js} +0 -0
  104. /package/driver/{lib/readers.js → readers.js} +0 -0
  105. /package/driver/{lib/request-execution.js → request-execution.js} +0 -0
  106. /package/driver/{lib/request-handler.js → request-handler.js} +0 -0
  107. /package/driver/{lib/stream-id-stack.js → stream-id-stack.js} +0 -0
  108. /package/driver/{lib/streams.js → streams.js} +0 -0
  109. /package/driver/{lib/token.js → token.js} +0 -0
  110. /package/driver/{lib/tokenizer.js → tokenizer.js} +0 -0
  111. /package/driver/{lib/tracker → tracker}/index.js +0 -0
  112. /package/driver/{lib/tracker → tracker}/request-logger.js +0 -0
  113. /package/driver/{lib/tracker → tracker}/request-tracker.js +0 -0
  114. /package/driver/{lib/types → types}/big-decimal.js +0 -0
  115. /package/driver/{lib/types → types}/duration.js +0 -0
  116. /package/driver/{lib/types → types}/inet-address.js +0 -0
  117. /package/driver/{lib/types → types}/integer.js +0 -0
  118. /package/driver/{lib/types → types}/local-date.js +0 -0
  119. /package/driver/{lib/types → types}/local-time.js +0 -0
  120. /package/driver/{lib/types → types}/mutable-long.js +0 -0
  121. /package/driver/{lib/types → types}/protocol-version.js +0 -0
  122. /package/driver/{lib/types → types}/result-set.js +0 -0
  123. /package/driver/{lib/types → types}/result-stream.js +0 -0
  124. /package/driver/{lib/types → types}/row.js +0 -0
  125. /package/driver/{lib/types → types}/time-uuid.js +0 -0
  126. /package/driver/{lib/types → types}/tuple.js +0 -0
  127. /package/driver/{lib/types → types}/uuid.js +0 -0
  128. /package/driver/{lib/types → types}/vector.js +0 -0
  129. /package/driver/{lib/types → types}/version-number.js +0 -0
  130. /package/driver/{lib/utils.js → utils.js} +0 -0
  131. /package/driver/{lib/writers.js → writers.js} +0 -0
package/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { mapping } from "./driver/lib/mapping/index.js";
1
+ import { mapping } from "./driver/mapping/index.js";
2
2
  import { Client as Client$1 } from "./driver/index.js";
3
3
  import { Model } from "./model/index.js";
4
4
  import { ClientConfig } from "./types.js";
@@ -1,4 +1,4 @@
1
- import { mapping } from "../driver/lib/mapping/index.js";
1
+ import { mapping } from "../driver/mapping/index.js";
2
2
  import { Model } from "../model/index.js";
3
3
  import { Doc } from "../types.js";
4
4
 
@@ -1,4 +1,4 @@
1
- //#region src/driver/lib/auth/index.d.ts
1
+ //#region src/driver/auth/index.d.ts
2
2
  /*
3
3
  * Licensed to the Apache Software Foundation (ASF) under one
4
4
  * or more contributor license agreements. See the NOTICE file
@@ -0,0 +1 @@
1
+ import e from"./errors.js";import t from"./promise-utils.js";import n from"./utils.js";import r from"./types/index.js";import i from"./client-options.js";import{ProfileManager as a}from"./execution-profile.js";import{DefaultExecutionOptions as o}from"./execution-options.js";import{description as s,version as c}from"../package.js";import l from"./requests.js";import u from"./metadata/client-state.js";import d from"./prepare-handler.js";import f from"./control-connection.js";import p from"./request-handler.js";import m from"./insights-client.js";import h from"./datastax/graph/graph-executor.js";import g from"util";import _ from"events";function v(e){_.EventEmitter.call(this),this.options=i.extend({logEmitter:this.emit.bind(this),id:r.Uuid.random()},e),Object.defineProperty(this,`profileManager`,{value:new a(this.options)}),Object.defineProperty(this,`controlConnection`,{value:new f(this.options,this.profileManager),writable:!0}),Object.defineProperty(this,`insightsClient`,{value:new m(this)}),this.setMaxListeners(0),this.connected=!1,this.isShuttingDown=!1,this.keyspace=e.keyspace,this.metadata=this.controlConnection.metadata,this.hosts=this.controlConnection.hosts,this.metrics=this.options.metrics,this._graphExecutor=new h(this,e,this._execute)}g.inherits(v,_.EventEmitter),v.prototype.connect=function(e){return this.connected&&e?e():t.optionalCallback(this._connect(),e)},v.prototype._connect=async function(){if(!this.connected){if(this.isShuttingDown)throw new e.NoHostAvailableError(null,`Connecting after shutdown is not supported`);if(this.connecting)return t.fromEvent(this,`connected`);this.connecting=!0,this.log(`info`,g.format(`Connecting to cluster using '%s' version %s`,s,c));try{await this.controlConnection.init(),this.hosts=this.controlConnection.hosts,await this.profileManager.init(this,this.hosts),this.keyspace&&await p.setKeyspace(this),i.setMetadataDependent(this),await this._warmup()}catch(e){throw await this.controlConnection.reset(),this.connected=!1,this.connecting=!1,this.emit(`connected`,e),e}this._setHostListeners(),this.profileManager.getDistance(this.controlConnection.host),this.insightsClient.init(),this.connected=!0,this.connecting=!1,this.emit(`connected`)}},v.prototype.execute=function(e,n,r,i){i||(typeof r==`function`?(i=r,r=null):typeof n==`function`&&(i=n,n=null));try{let a=o.create(r,this);return t.optionalCallback(this._execute(e,n,a),i)}catch(e){return i?i(e):Promise.reject(e)}},v.prototype.executeGraph=function(e,n,r,i){return i=i||r||n,typeof i==`function`?(n=typeof n==`function`?null:n,t.toCallback(this._graphExecutor.send(e,n,r),i)):this._graphExecutor.send(e,n,r)},v.prototype.eachRow=function(e,r,i,a,s){!s&&a&&typeof i==`function`?(s=n.validateFn(a,`rowCallback`),a=i):(s||=n.noop,a=n.validateFn(a||i||r,`rowCallback`)),r=typeof r==`function`?null:r;let c;try{c=o.create(i,this,a)}catch(e){return s(e)}let l=0,u=()=>t.toCallback(this._execute(e,r,c),d);function d(e,t){if(e)return s(e);if(l+=t.rowLength,t.rawPageState!==void 0){if(c.setPageState(t.rawPageState),c.isAutoPage())return u();t.nextPage=u}t.rowLength=l,s(null,t)}t.toCallback(this._execute(e,r,c),d)},v.prototype.stream=function(e,t,i,a){a||=n.noop;let o=new r.ResultStream({objectMode:1});function s(e,t){if(e&&o.emit(`error`,e),t&&t.nextPage){o._valve(function(){try{t.nextPage()}catch(e){o.emit(`error`,e)}});return}o._valve(null),o.add(null),a(e)}let c=!0;return this.eachRow(e,t,i,function(e,t){o.add(t)},function(e,t){if(c)return setImmediate(function(){s(e,t)});s(e,t)}),c=!1,o},v.prototype.batch=function(e,n,r){return!r&&typeof n==`function`&&(r=n,n=null),t.optionalCallback(this._batch(e,n),r)},v.prototype._batch=async function(t,n){if(!Array.isArray(t))throw new e.ArgumentError(`Queries should be an Array`);if(t.length===0)throw new e.ArgumentError(`Queries array should not be empty`);await this._connect();let i=o.create(n,this),a;if(i.isPrepared()){let e=this.controlConnection.protocolVersion,o=r.protocolVersion.supportsKeyspaceInRequest(e)&&n.keyspace||this.keyspace;a=await d.getPreparedMultiple(this,i.getLoadBalancingPolicy(),t,o)}else{a=Array(t.length);for(let n=0;n<t.length;n++){let r=t[n];if(!r)throw new e.ArgumentError(`Invalid query at index ${n}`);let i=typeof r==`string`?r:r.query;if(!i)throw new e.ArgumentError(`Invalid query at index ${n}`);a[n]={query:i,params:r.params}}}let s=await this._createBatchRequest(a,i);return await p.send(s,i,this)},v.prototype.getReplicas=function(e,t){return this.metadata.getReplicas(e,t)},v.prototype.getState=function(){return u.from(this)},v.prototype.log=n.log,v.prototype.shutdown=function(e){return t.optionalCallback(this._shutdown(),e)},v.prototype._shutdown=async function(){if(this.log(`info`,`Shutting down`),!this.hosts||!this.connected){this.connected=!1;return}this.connecting&&(this.log(`warning`,`Shutting down while connecting`),await t.fromEvent(this,`connected`)),this.connected=!1,this.isShuttingDown=!0;let e=this.hosts.values();this.insightsClient.shutdown(),this.controlConnection.shutdown(),this.options.policies.speculativeExecution.shutdown(),this.options.requestTracker&&this.options.requestTracker.shutdown(),await Promise.all(e.map(e=>e.shutdown(!1)))},v.prototype._waitForSchemaAgreement=async function(e){if(this.hosts.length===1)return!0;let n=process.hrtime(),r=this.options.protocolOptions.maxSchemaAgreementWaitSeconds;this.log(`info`,`Waiting for schema agreement`);let i;for(;!i&&process.hrtime(n)[0]<r;){if(i=await this.metadata.compareSchemaVersions(e),i){this.log(`info`,`Schema versions match`);break}await t.delay(500)}return i},v.prototype.handleSchemaAgreementAndRefresh=async function(e,t){let n=!1;try{n=await this._waitForSchemaAgreement(e)}catch(e){this.log(`warning`,`There was an error while waiting for the schema agreement between nodes`,e)}if(!this.options.isMetadataSyncEnabled)return n;try{await this.controlConnection.handleSchemaChange(t,!0)}catch(e){this.log(`warning`,`There was an error while handling schema change`,e)}return n},v.prototype._execute=async function(t,n,i){let a=this.controlConnection.protocolVersion;if(!i.isPrepared()&&n&&!Array.isArray(n)&&!r.protocolVersion.supportsNamedParameters(a))throw new e.ArgumentError(`Named parameters for simple statements are not supported, use prepare flag`);let o;if(this.connected||await this._connect(),!i.isPrepared())o=await this._createQueryRequest(t,i,n);else{let e=i.getLoadBalancingPolicy(),s=r.protocolVersion.supportsKeyspaceInRequest(a)&&i.getKeyspace()||this.keyspace,{queryId:c,meta:l}=await d.getPrepared(this,e,t,s);o=await this._createExecuteRequest(t,c,i,n,l)}return await p.send(o,i,this)},v.prototype._setHostListeners=function(){function e(e,t){return()=>e.emit(`hostUp`,t)}function t(e,t){return()=>e.emit(`hostDown`,t)}let n=this;this.hosts.on(`add`,function(r){r.on(`up`,e(n,r)),r.on(`down`,t(n,r)),n.emit(`hostAdd`,r)}),this.hosts.on(`remove`,function(e){e.removeAllListeners(),n.emit(`hostRemove`,e)}),this.hosts.forEach(function(r){r.on(`up`,e(n,r)),r.on(`down`,t(n,r))})},v.prototype._warmup=function(){let e=this.hosts.values();return t.times(e.length,32,async t=>{let n=e[t],i=this.profileManager.getDistance(n);if(i!==r.distance.ignored)if(this.options.pooling.warmup&&i===r.distance.local)try{await n.warmupPool(this.keyspace)}catch(e){this.log(`warning`,`Connection pool to host ${n.address} could not be created: ${e}`,e)}else n.initializePool()})},v.prototype._getEncoder=function(){let t=this.controlConnection.getEncoder();if(!t)throw new e.DriverInternalError(`Encoder is not defined`);return t},v.prototype._createBatchRequest=async function(e,t){let n=e[0];return n.meta&&await this._setRoutingInfo(t,n.params,n.meta),new l.BatchRequest(e,t)},v.prototype._createExecuteRequest=async function(e,t,r,i,a){return i=n.adaptNamedParamsPrepared(i,a.columns),await this._setRoutingInfo(r,i,a),new l.ExecuteRequest(e,t,i,r,a)},v.prototype._createQueryRequest=async function(e,t,r){await this.metadata.adaptUserHints(this.keyspace,t.getHints());let i=n.adaptNamedParamsWithHints(r,t);return this._getEncoder().setRoutingKeyFromUser(i.params,t,i.keyIndexes),new l.QueryRequest(e,i.params,t,i.namedParameters)},v.prototype._setRoutingInfo=async function(e,t,n){let r=this._getEncoder();if(!e.getKeyspace()&&n.keyspace&&e.setKeyspace(n.keyspace),e.getRoutingKey())return r.setRoutingKeyFromUser(t,e);if(Array.isArray(n.partitionKeys))return e.setRoutingIndexes(n.partitionKeys),r.setRoutingKeyFromMeta(n,t,e);try{let i=await this.metadata.getTable(n.keyspace,n.table);if(!i)return;e.setRoutingIndexes(i.partitionKeys.map(e=>n.columnsByName[e.name])),n.partitionKeys=e.getRoutingIndexes(),r.setRoutingKeyFromMeta(n,t,e)}catch{this.log(`warning`,g.format(`Table %s.%s metadata could not be retrieved`,n.keyspace,n.table))}};export{v as default};
@@ -1,7 +1,7 @@
1
- import { Client } from "../../index.js";
1
+ import { Client } from "../index.js";
2
2
  import { Readable } from "stream";
3
3
 
4
- //#region src/driver/lib/concurrent/index.d.ts
4
+ //#region src/driver/concurrent/index.d.ts
5
5
  declare namespace concurrent {
6
6
  interface ResultSetGroup {
7
7
  errors: Error[];
@@ -1,6 +1,6 @@
1
1
  import { types } from "../../types/index.js";
2
2
 
3
- //#region src/driver/lib/datastax/graph/index.d.ts
3
+ //#region src/driver/datastax/graph/index.d.ts
4
4
  declare namespace graph {
5
5
  interface Edge extends Element {
6
6
  outV?: Vertex;
@@ -1,4 +1,4 @@
1
- //#region src/driver/lib/datastax/index.d.ts
1
+ //#region src/driver/datastax/index.d.ts
2
2
  declare namespace datastax {
3
3
  export import graph = graphModule.graph;
4
4
  export import search = searchModule.search;
@@ -1,4 +1,4 @@
1
- //#region src/driver/lib/datastax/search/index.d.ts
1
+ //#region src/driver/datastax/search/index.d.ts
2
2
  /*
3
3
  * Licensed to the Apache Software Foundation (ASF) under one
4
4
  * or more contributor license agreements. See the NOTICE file
@@ -1,4 +1,4 @@
1
- //#region src/driver/lib/geometry/index.d.ts
1
+ //#region src/driver/geometry/index.d.ts
2
2
  /*
3
3
  * Licensed to the Apache Software Foundation (ASF) under one
4
4
  * or more contributor license agreements. See the NOTICE file
package/driver/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { auth } from "./lib/auth/index.js";
2
- import { types } from "./lib/types/index.js";
3
- import { policies } from "./lib/policies/index.js";
4
- import { metrics } from "./lib/metrics/index.js";
5
- import { tracker } from "./lib/tracker/index.js";
6
- import { metadata } from "./lib/metadata/index.js";
7
- import { concurrent } from "./lib/concurrent/index.js";
8
- import { mapping } from "./lib/mapping/index.js";
9
- import { geometry } from "./lib/geometry/index.js";
1
+ import { auth } from "./auth/index.js";
2
+ import { types } from "./types/index.js";
3
+ import { policies } from "./policies/index.js";
4
+ import { metrics } from "./metrics/index.js";
5
+ import { tracker } from "./tracker/index.js";
6
+ import { metadata } from "./metadata/index.js";
7
+ import { concurrent } from "./concurrent/index.js";
8
+ import { mapping } from "./mapping/index.js";
9
+ import { geometry } from "./geometry/index.js";
10
10
  import * as events$1 from "events";
11
11
  import * as tls$1 from "tls";
12
12
 
package/driver/index.js CHANGED
@@ -1 +1 @@
1
- import e from"./lib/errors.js";import t from"./lib/types/index.js";import n from"./lib/policies/index.js";import r from"./lib/tracker/index.js";import i from"./lib/metrics/index.js";import a from"./lib/auth/index.js";import o from"./lib/client-options.js";import{ExecutionProfile as s}from"./lib/execution-profile.js";import{ExecutionOptions as c}from"./lib/execution-options.js";import{version as l}from"../package.js";import{Token as u,TokenRange as d}from"./lib/token.js";import f from"./lib/geometry/index.js";import p from"./lib/encoder.js";import m from"./lib/metadata/index.js";import h from"./lib/client.js";import g from"./lib/mapping/index.js";import _ from"./lib/concurrent/index.js";const v={Token:u,TokenRange:d},y={Metadata:m};function b(){return o.defaultOptions()}const x={Client:h,ExecutionProfile:s,ExecutionOptions:c,types:t,errors:e,policies:n,auth:a,mapping:g,tracker:r,metrics:i,concurrent:_,token:v,metadata:y,Encoder:p,geometry:f,defaultOptions:b,version:l};export{x as default};
1
+ import e from"./errors.js";import t from"./types/index.js";import n from"./policies/index.js";import r from"./tracker/index.js";import i from"./metrics/index.js";import a from"./auth/index.js";import o from"./client-options.js";import{ExecutionProfile as s}from"./execution-profile.js";import{ExecutionOptions as c}from"./execution-options.js";import{version as l}from"../package.js";import{Token as u,TokenRange as d}from"./token.js";import f from"./geometry/index.js";import p from"./encoder.js";import m from"./metadata/index.js";import h from"./client.js";import g from"./mapping/index.js";import _ from"./concurrent/index.js";const v={Token:u,TokenRange:d},y={Metadata:m};function b(){return o.defaultOptions()}const x={Client:h,ExecutionProfile:s,ExecutionOptions:c,types:t,errors:e,policies:n,auth:a,mapping:g,tracker:r,metrics:i,concurrent:_,token:v,metadata:y,Encoder:p,geometry:f,defaultOptions:b,version:l};export{x as default};
@@ -0,0 +1 @@
1
+ import e from"./promise-utils.js";import t from"./utils.js";import n from"./types/version-number.js";import r from"./types/index.js";import i from"./auth/no-auth-provider.js";import"./auth/index.js";import{ExecutionOptions as a}from"./execution-options.js";import{description as o,version as s}from"../package.js";import c from"./requests.js";import{createRequire as l}from"module";import u from"os";import d from"path";import f from"fs";const p=l(import.meta.url);let m;try{m=p(`kerberos`)}catch{}const h=new n(6,0,5),g=new n(5,1,13),_=new n(6,0,0),v=`CALL InsightsRpc.reportInsight(?)`;var y=class{constructor(e,n){this._client=e,this._sessionId=r.Uuid.random().toString(),this._enabled=!1,this._closed=!1,this._firstTimeout=null,this._recurrentTimeout=null,this._statusErrorLogs=0,n||={},this._statusEventDelay=n.statusEventDelay||3e5,this._errorCallback=n.errorCallback||t.noop}init(){this._enabled=this._client.options.monitorReporting.enabled&&this._dseSupportsInsights(),this._enabled&&e.toBackground(this._init())}async _init(){try{if(await this._sendStartupEvent(),this._closed)return;let e=Math.floor(this._statusEventDelay-.1*this._statusEventDelay*Math.random());this._firstTimeout=setTimeout(()=>{this._sendStatusEvent(),this._recurrentTimeout=setInterval(()=>this._sendStatusEvent(),this._statusEventDelay)},e)}catch(e){if(this._closed)return;this._client.log(`verbose`,`Insights startup message could not be sent (${e})`,e),this._errorCallback(e)}}async _sendStartupEvent(){let e=await this._getStartupMessage(),t=new c.QueryRequest(v,[e],a.empty());await this._client.controlConnection.query(t,!1)}async _sendStatusEvent(){let e=new c.QueryRequest(v,[this._getStatusEvent()],a.empty());try{await this._client.controlConnection.query(e,!1)}catch(e){if(this._closed)return;this._statusErrorLogs<5&&(this._client.log(`warning`,`Insights status message could not be sent (${e})`,e),this._statusErrorLogs++),this._errorCallback(e)}}_dseSupportsInsights(){return this._client.hosts.length===0?!1:this._client.hosts.values().reduce((e,t)=>{if(!e)return e;let r=t.getDseVersion();if(r.length===0)return!1;let i=new n(...r);return i.compare(h)>=0||i.compare(_)<0&&i.compare(g)>=0},!0)}async _getStartupMessage(){let e=this._client.controlConnection,t=this._client.options,n=await this._getAppInfo(t),a={metadata:{name:`driver.startup`,insightMappingId:`v1`,insightType:`EVENT`,timestamp:Date.now(),tags:{language:`nodejs`}},data:{driverName:o,driverVersion:s,clientId:t.id,sessionId:this._sessionId,applicationName:n.applicationName,applicationVersion:n.applicationVersion,applicationNameWasGenerated:n.applicationNameWasGenerated,contactPoints:b(e.getResolvedContactPoints()),dataCenters:this._getDataCenters(),initialControlConnection:e.host?e.host.address:void 0,protocolVersion:e.protocolVersion,localAddress:e.getLocalAddress(),hostName:u.hostname(),executionProfiles:w(this._client),poolSizeByHostDistance:{local:t.pooling.coreConnectionsPerHost[r.distance.local],remote:t.pooling.coreConnectionsPerHost[r.distance.remote]},heartbeatInterval:t.pooling.heartBeatInterval,compression:`NONE`,reconnectionPolicy:x(t.policies.reconnection),ssl:{enabled:!!t.sslOptions,certValidation:t.sslOptions?!!t.sslOptions.rejectUnauthorized:void 0},authProvider:{type:t.authProvider instanceof i?void 0:C(t.authProvider)},otherOptions:{coalescingThreshold:t.socketOptions.coalescingThreshold},platformInfo:{os:{name:u.platform(),version:u.release(),arch:u.arch()},cpus:{length:u.cpus().length,model:u.cpus()[0].model},runtime:{node:process.versions.node,v8:process.versions.v8,uv:process.versions.uv,openssl:process.versions.openssl,kerberos:m?m.version:void 0}},configAntiPatterns:this._getConfigAntiPatterns(),periodicStatusInterval:Math.floor(this._statusEventDelay/1e3)}};return JSON.stringify(a)}_getConfigAntiPatterns(){let e=this._client.options,t={};return e.sslOptions&&!e.sslOptions.rejectUnauthorized&&(t.sslWithoutCertValidation=`Client-to-node encryption is enabled but server certificate validation is disabled`),t}_getDataCenters(){let e=this._client.options.pooling.coreConnectionsPerHost[r.distance.remote],t=new Set;return this._client.hosts.values().forEach(n=>{let i=this._client.profileManager.getDistance(n);(i===r.distance.local||i===r.distance.remote&&e>0)&&t.add(n.datacenter)}),Array.from(t)}async _getAppInfo(e){if(typeof e.applicationName==`string`)return Promise.resolve({applicationName:e.applicationName,applicationVersion:e.applicationVersion,applicationNameWasGenerated:!1});let t=Promise.resolve();if(process.argv[1]){let e=d.dirname(process.argv[1]);t=this._readPackageInfoFile(e)}let n=await t,r=`Default Node Application`,i;if(n)try{let e=JSON.parse(n);e.name&&(r=e.name,i=e.version)}catch{}return{applicationName:r,applicationVersion:i,applicationNameWasGenerated:!0}}_readPackageInfoFile(e){return new Promise(t=>{f.readFile(d.join(e,`package.json`),`utf8`,(e,n)=>{t(n)})})}_getStatusEvent(){let e=this._client.controlConnection,t=this._client.options,n=this._client.getState(),r={};n.getConnectedHosts().forEach(e=>{r[e.address]={connections:n.getOpenConnections(e),inFlightQueries:n.getInFlightQueries(e)}});let i={metadata:{name:`driver.status`,insightMappingId:`v1`,insightType:`EVENT`,timestamp:Date.now(),tags:{language:`nodejs`}},data:{clientId:t.id,sessionId:this._sessionId,controlConnection:e.host?e.host.address:void 0,connectedNodes:r}};return JSON.stringify(i)}shutdown(){this._enabled&&(this._closed=!0,this._firstTimeout!==null&&clearTimeout(this._firstTimeout),this._recurrentTimeout!==null&&clearInterval(this._recurrentTimeout))}};function b(e){let t={};return e.forEach((e,n)=>t[n]=e),t}function x(e){if(!e)return;let n=e.getOptions&&e.getOptions();return{type:e.constructor.name,options:n instanceof Map?b(n):t.emptyObject}}function S(e){if(typeof e==`number`)return r.consistencyToString[e]}function C(e){return e?e.constructor.name:void 0}function w(e){let t={},n=e.profileManager.getDefault();return T(e,t,n,n),e.profileManager.getAll().filter(e=>e!==n).forEach(r=>T(e,t,r,n)),t}function T(e,n,r,i){let a=n[r.name]={};if(E(a,r,i,`readTimeout`),E(a,r,i,`loadBalancing`,x),E(a,r,i,`retry`,x),E(a,r,i,`consistency`,S),E(a,r,i,`serialConsistency`,S),r===i&&(a.speculativeExecution=x(e.options.policies.speculativeExecution)),r.graphOptions){a.graphOptions={};let e=i.graphOptions||t.emptyObject;E(a.graphOptions,r.graphOptions,e,`language`),E(a.graphOptions,r.graphOptions,e,`name`),E(a.graphOptions,r.graphOptions,e,`readConsistency`,S),E(a.graphOptions,r.graphOptions,e,`source`),E(a.graphOptions,r.graphOptions,e,`writeConsistency`,S),Object.keys(a.graphOptions).length===0&&(a.graphOptions=void 0)}}function E(e,t,n,r,i){let a=t[r];i||=(e=>e),(t===n&&a!==void 0||a!==n[r])&&(e[r]=i(a))}export{y as default};
@@ -1,7 +1,7 @@
1
1
  import { types } from "../types/index.js";
2
- import { Client } from "../../index.js";
2
+ import { Client } from "../index.js";
3
3
 
4
- //#region src/driver/lib/mapping/index.d.ts
4
+ //#region src/driver/mapping/index.d.ts
5
5
  declare namespace mapping {
6
6
  interface TableMappings {
7
7
  getColumnName(propName: string): string;
@@ -1,7 +1,7 @@
1
1
  import { types } from "../types/index.js";
2
- import { EmptyCallback, Host, ValueCallback, token } from "../../index.js";
2
+ import { EmptyCallback, Host, ValueCallback, token } from "../index.js";
3
3
 
4
- //#region src/driver/lib/metadata/index.d.ts
4
+ //#region src/driver/metadata/index.d.ts
5
5
  declare namespace metadata {
6
6
  interface Aggregate {
7
7
  argumentTypes: Array<{
@@ -1,6 +1,6 @@
1
- import { errors } from "../../index.js";
1
+ import { errors } from "../index.js";
2
2
 
3
- //#region src/driver/lib/metrics/index.d.ts
3
+ //#region src/driver/metrics/index.d.ts
4
4
  declare namespace metrics {
5
5
  interface ClientMetrics {
6
6
  onAuthenticationError(e: Error | errors.AuthenticationError): void;
@@ -1,7 +1,7 @@
1
1
  import { types } from "../types/index.js";
2
- import { Client, EmptyCallback, ExecutionOptions, Host, HostMap } from "../../index.js";
2
+ import { Client, EmptyCallback, ExecutionOptions, Host, HostMap } from "../index.js";
3
3
 
4
- //#region src/driver/lib/policies/index.d.ts
4
+ //#region src/driver/policies/index.d.ts
5
5
  declare namespace policies {
6
6
  function defaultAddressTranslator(): addressResolution.AddressTranslator;
7
7
  function defaultLoadBalancingPolicy(localDc?: string): loadBalancing.LoadBalancingPolicy;
@@ -0,0 +1 @@
1
+ import e from"./utils.js";import t from"./types/index.js";import{FrameWriter as n}from"./writers.js";import{ExecutionOptions as r}from"./execution-options.js";import{description as i,version as a}from"../package.js";import o from"util";const s={values:1,skipMetadata:2,pageSize:4,withPagingState:8,withSerialConsistency:16,withDefaultTimestamp:32,withNameForValues:64,withKeyspace:128,withPageSizeBytes:1073741824,withContinuousPaging:2147483648},c={withSerialConsistency:16,withDefaultTimestamp:32,withNameForValues:64,withKeyspace:128},l={withKeyspace:1},u={logged:0,unlogged:1,counter:2};var d=class{constructor(){this.length=0}write(e,t){throw Error(`Method must be implemented`)}clone(){let e=new this.constructor,t=Object.keys(this);for(let n=0;n<t.length;n++){let r=t[n];e[r]=this[r]}return e}},f=class extends d{constructor(e,n,i,a,o){super(),this.query=e,this.queryId=n,this.params=i,this.meta=o,this.options=a||r.empty(),this.timestamp=this.options.getOrGenerateTimestamp(),this.consistency=this.options.getConsistency()||t.consistencies.one,this.namedParameters=!1}getParamType(e){let t=this.meta.columns[e];return t?t.type:null}write(e,r){let i=new n(t.opcodes.execute),a=this.options.isQueryTracing()?t.frameFlags.tracing:0;return this.options.getCustomPayload()&&(a|=t.frameFlags.customPayload,i.writeCustomPayload(this.options.getCustomPayload())),i.writeShortBytes(this.queryId),t.protocolVersion.supportsResultMetadataId(e.protocolVersion)&&i.writeShortBytes(this.meta.resultId),this.writeQueryParameters(i,e),this.length=i.bodyLength,i.write(e.protocolVersion,r,a)}writeQueryParameters(e,n,r){let i=0,a=this.timestamp;if(t.protocolVersion.supportsPaging(n.protocolVersion)){i|=this.params&&this.params.length?s.values:0,i|=this.options.getFetchSize()>0?s.pageSize:0,i|=this.options.getPageState()?s.withPagingState:0,i|=this.options.getSerialConsistency()?s.withSerialConsistency:0,i|=a==null?0:s.withDefaultTimestamp,i|=this.namedParameters?s.withNameForValues:0;let o=r&&t.protocolVersion.supportsKeyspaceInRequest(n.protocolVersion);i|=o&&this.options.getKeyspace()?s.withKeyspace:0,e.writeShort(this.consistency),t.protocolVersion.uses4BytesQueryFlags(n.protocolVersion)?e.writeInt(i):e.writeByte(i)}if(this.params&&this.params.length){e.writeShort(this.params.length);for(let t=0;t<this.params.length;t++){let r=this.params[t];i&s.withNameForValues&&(e.writeString(r.name),r=r.value),e.writeBytes(n.encode(r,this.getParamType(t)))}}if(!t.protocolVersion.supportsPaging(n.protocolVersion)){(!this.params||!this.params.length)&&e.writeShort(0),e.writeShort(this.consistency);return}i&s.pageSize&&e.writeInt(this.options.getFetchSize()),i&s.withPagingState&&e.writeBytes(this.options.getPageState()),i&s.withSerialConsistency&&e.writeShort(this.options.getSerialConsistency()),i&s.withDefaultTimestamp&&e.writeLong(a),i&s.withKeyspace&&e.writeString(this.options.getKeyspace())}},p=class extends f{constructor(t,n,r,i){super(t,null,n,r,null),this.hints=this.options.getHints()||e.emptyArray,this.namedParameters=i}getParamType(e){return this.hints[e]}write(e,r){let i=new n(t.opcodes.query),a=this.options.isQueryTracing()?t.frameFlags.tracing:0;return this.options.getCustomPayload()&&(a|=t.frameFlags.customPayload,i.writeCustomPayload(this.options.getCustomPayload())),i.writeLString(this.query),t.protocolVersion.supportsPaging(e.protocolVersion)?this.writeQueryParameters(i,e,!0):i.writeShort(this.consistency),this.length=i.bodyLength,i.write(e.protocolVersion,r,a)}},m=class extends d{constructor(e,t){super(),this.query=e,this.keyspace=t}write(e,r){let i=new n(t.opcodes.prepare);if(i.writeLString(this.query),t.protocolVersion.supportsPrepareFlags(e.protocolVersion)){let n=this.keyspace&&t.protocolVersion.supportsKeyspaceInRequest(e.protocolVersion)?l.withKeyspace:0;i.writeInt(n),n&l.withKeyspace&&i.writeString(this.keyspace)}return i.write(e.protocolVersion,r)}},h=class extends d{constructor(e){super(),this.options=e||{}}write(e,r){let o=new n(t.opcodes.startup),s={CQL_VERSION:this.options.cqlVersion||`3.0.0`,DRIVER_NAME:i,DRIVER_VERSION:a};return this.options.noCompact&&(s.NO_COMPACT=`true`),this.options.clientId&&(s.CLIENT_ID=this.options.clientId.toString()),this.options.applicationName&&(s.APPLICATION_NAME=this.options.applicationName),this.options.applicationVersion&&(s.APPLICATION_VERSION=this.options.applicationVersion),o.writeStringMap(s),o.write(e.protocolVersion,r)}},g=class extends d{constructor(e){super(),this.events=e}write(e,r){let i=new n(t.opcodes.register);return i.writeStringList(this.events),i.write(e.protocolVersion,r)}},_=class extends d{constructor(e){super(),this.token=e}write(e,r){let i=new n(t.opcodes.authResponse);return i.writeBytes(this.token),i.write(e.protocolVersion,r)}},v=class extends d{constructor(e,t){super(),this.username=e,this.password=t}write(e,r){let i=new n(t.opcodes.credentials);return i.writeStringMap({username:this.username,password:this.password}),i.write(e.protocolVersion,r)}},y=class r extends d{constructor(t,n){super(),this.queries=t,this.options=n,this.timestamp=this.options.getOrGenerateTimestamp(),this.hints=n.getHints()||e.emptyArray,this.type=u.logged,n.isBatchCounter()?this.type=u.counter:n.isBatchLogged()||(this.type=u.unlogged)}write(r,i){if(!this.queries||!(this.queries.length>0))throw TypeError(o.format(`Invalid queries provided %s`,this.queries));let a=new n(t.opcodes.batch),s=this.options.isQueryTracing()?t.frameFlags.tracing:0;this.options.getCustomPayload()&&(s|=t.frameFlags.customPayload,a.writeCustomPayload(this.options.getCustomPayload())),a.writeByte(this.type),a.writeShort(this.queries.length);let l=this;if(this.queries.forEach(function(t,n){let i=l.hints[n],o=t.params||e.emptyArray,s;t.queryId?(a.writeByte(1),a.writeShortBytes(t.queryId),s=e=>t.meta.columns[e].type):(a.writeByte(0),a.writeLString(t.query),s=i?e=>i[e]:()=>null),a.writeShort(o.length),o.forEach((e,t)=>a.writeBytes(r.encode(e,s(t))))},this),a.writeShort(this.options.getConsistency()),t.protocolVersion.supportsTimestamp(r.protocolVersion)){let e=this.options.getSerialConsistency()?c.withSerialConsistency:0,n=this.timestamp;e|=n==null?0:c.withDefaultTimestamp,e|=this.options.getKeyspace()&&t.protocolVersion.supportsKeyspaceInRequest(r.protocolVersion)?c.withKeyspace:0,t.protocolVersion.uses4BytesQueryFlags(r.protocolVersion)?a.writeInt(e):a.writeByte(e),e&c.withSerialConsistency&&a.writeShort(this.options.getSerialConsistency()),e&c.withDefaultTimestamp&&a.writeLong(n),e&c.withKeyspace&&a.writeString(this.options.getKeyspace())}return this.length=a.bodyLength,a.write(r.protocolVersion,i,s)}clone(){return new r(this.queries,this.options)}};function b(e){this.streamId=null,this.operationId=e}o.inherits(b,d),b.prototype.write=function(e,r){let i=new n(t.opcodes.cancel);return i.writeInt(1),i.writeInt(this.operationId),i.write(e.protocolVersion,r)};var x={AuthResponseRequest:_,BatchRequest:y,CancelRequest:b,CredentialsRequest:v,ExecuteRequest:f,options:new class extends d{write(e,r){return new n(t.opcodes.options).write(e.protocolVersion,r,0)}clone(){return this}},PrepareRequest:m,QueryRequest:p,RegisterRequest:g,Request:d,StartupRequest:h};export{f as ExecuteRequest,p as QueryRequest,x as default};
@@ -1,6 +1,6 @@
1
- import { ExecutionOptions, Host } from "../../index.js";
1
+ import { ExecutionOptions, Host } from "../index.js";
2
2
 
3
- //#region src/driver/lib/tracker/index.d.ts
3
+ //#region src/driver/tracker/index.d.ts
4
4
  declare namespace tracker {
5
5
  interface RequestTracker {
6
6
  onError(host: Host, query: string | Array<{
@@ -1,8 +1,8 @@
1
- import { ValueCallback } from "../../index.js";
1
+ import { ValueCallback } from "../index.js";
2
2
  import _Long from "long";
3
3
  import * as stream from "stream";
4
4
 
5
- //#region src/driver/lib/types/index.d.ts
5
+ //#region src/driver/types/index.d.ts
6
6
  declare namespace types {
7
7
  class Long extends _Long {}
8
8
  enum consistencies {
@@ -0,0 +1 @@
1
+ import{__exportAll as e}from"../../_virtual/_rolldown/runtime.js";import t from"../errors.js";import n from"../utils.js";import r from"./uuid.js";import i from"./time-uuid.js";import a from"./protocol-version.js";import o from"./integer.js";import s from"./big-decimal.js";import c from"./duration.js";import l from"./inet-address.js";import u from"./local-date.js";import d from"./local-time.js";import f from"./result-set.js";import p from"./result-stream.js";import m from"./row.js";import h from"./tuple.js";import g from"./vector.js";import _ from"util";import v from"long";var y=e({BigDecimal:()=>s,DriverError:()=>B,Duration:()=>c,FrameHeader:()=>I,InetAddress:()=>l,Integer:()=>o,LocalDate:()=>u,LocalTime:()=>d,Long:()=>v,ResultSet:()=>f,ResultStream:()=>p,Row:()=>m,TimeUuid:()=>i,TimeoutError:()=>z,Tuple:()=>h,Uuid:()=>r,Vector:()=>g,consistencies:()=>b,consistencyToString:()=>x,dataTypes:()=>S,default:()=>V,distance:()=>w,frameFlags:()=>k,generateTimestamp:()=>L,getDataTypeNameByCode:()=>F,opcodes:()=>T,protocolEvents:()=>E,protocolVersion:()=>a,responseErrorCodes:()=>D,resultKind:()=>O,timeuuid:()=>N,unset:()=>A,uuid:()=>P});const b={any:0,one:1,two:2,three:3,quorum:4,all:5,localQuorum:6,eachQuorum:7,serial:8,localSerial:9,localOne:10},x={};x[b.any]=`ANY`,x[b.one]=`ONE`,x[b.two]=`TWO`,x[b.three]=`THREE`,x[b.quorum]=`QUORUM`,x[b.all]=`ALL`,x[b.localQuorum]=`LOCAL_QUORUM`,x[b.eachQuorum]=`EACH_QUORUM`,x[b.serial]=`SERIAL`,x[b.localSerial]=`LOCAL_SERIAL`,x[b.localOne]=`LOCAL_ONE`;const S={custom:0,ascii:1,bigint:2,blob:3,boolean:4,counter:5,decimal:6,double:7,float:8,int:9,text:10,timestamp:11,uuid:12,varchar:13,varint:14,timeuuid:15,inet:16,date:17,time:18,smallint:19,tinyint:20,duration:21,list:32,map:33,set:34,udt:48,tuple:49,getByName:function(e){if(e=e.toLowerCase(),e.indexOf(`<`)>0){let t=/^(list|set)<(.+)>$/.exec(e);if(t)return{code:this[t[1]],info:this.getByName(t[2])};let n=/^(map)< *(.+) *, *(.+)>$/.exec(e);if(n)return{code:this[n[1]],info:[this.getByName(n[2]),this.getByName(n[3])]};let r=/^(udt)<(.+)>$/.exec(e);if(r)return{code:this[r[1]],info:r[2]};let i=/^(tuple)<(.+)>$/.exec(e);if(i)return{code:this[i[1]],info:i[2].split(`,`).map(function(e){return this.getByName(e.trim())},this)};let a=/^vector<\s*(.+)\s*,\s*(\d+)\s*>$/.exec(e);if(a)return{code:this.custom,customTypeName:`vector`,info:[this.getByName(a[1]),parseInt(a[2],10)]}}let t={code:this[e]};if(typeof t.code!=`number`)throw TypeError(`Data type with name `+e+` not valid`);return t}},C=(function(){let e={};for(let t in S){if(!S.hasOwnProperty(t))continue;let n=S[t];typeof n==`number`&&(e[n]=t)}return e})(),w={local:0,remote:1,ignored:2},T={error:0,startup:1,ready:2,authenticate:3,credentials:4,options:5,supported:6,query:7,result:8,prepare:9,execute:10,register:11,event:12,batch:13,authChallenge:14,authResponse:15,authSuccess:16,cancel:255,isInRange:function(e){return e>this.error&&e>this.event}},E={topologyChange:`TOPOLOGY_CHANGE`,statusChange:`STATUS_CHANGE`,schemaChange:`SCHEMA_CHANGE`},D={serverError:0,protocolError:10,badCredentials:256,unavailableException:4096,overloaded:4097,isBootstrapping:4098,truncateError:4099,writeTimeout:4352,readTimeout:4608,readFailure:4864,functionFailure:5120,writeFailure:5376,syntaxError:8192,unauthorized:8448,invalid:8704,configError:8960,alreadyExists:9216,unprepared:9472,clientWriteFailure:32768},O={voidResult:1,rows:2,setKeyspace:3,prepared:4,schemaChange:5},k={compression:1,tracing:2,customPayload:4,warning:8},A=Object.freeze({unset:!0}),j=v.fromInt(1e3);let M=0;function N(e,t,r){let a,o,s,c;e&&(typeof e.msecs==`number`&&(a=new Date(e.msecs)),e.msecs instanceof Date&&(a=e.msecs),Array.isArray(e.node)&&(s=n.allocBufferFromArray(e.node)),typeof e.clockseq==`number`&&(c=n.allocBufferUnsafe(2),c.writeUInt16BE(e.clockseq,0)),typeof e.nsecs==`number`&&(o=e.nsecs));let l=new i(a,o,s,c);return t instanceof Buffer?(l.getBuffer().copy(t,r||0),t):l.toString()}function P(e,t,i){let a;return e&&Array.isArray(e.random)&&(a=new r(n.allocBufferFromArray(e.random))),a||=r.random(),t instanceof Buffer?(a.getBuffer().copy(t,i||0),t):a.toString()}function F(e){if(!e||typeof e.code!=`number`)throw new t.ArgumentError(`Invalid signature type definition`);let n=C[e.code];if(!n)throw new t.ArgumentError(_.format(`Type with code %d not found`,e.code));return!(`info`in e)||!e.info?n:e.code===S.custom&&`customTypeName`in e&&e.customTypeName===`vector`?`vector<`+F(e.info[0])+`, `+e.info[1]+`>`:Array.isArray(e.info)?n+`<`+e.info.map(function(e){return F(e)}).join(`, `)+`>`:typeof e.info.code==`number`?n+`<`+F(e.info)+`>`:e.code===S.udt?e.info.name:n}function I(e,t,n,r,i){this.version=e,this.flags=t,this.streamId=n,this.opcode=r,this.bodyLength=i}I.size=function(e){return a.uses2BytesStreamIds(e)?9:8},I.getProtocolVersion=function(e){return e[0]&127},I.fromBuffer=function(e,t){let n=0;t||=0;let r=e[t++]&127,i=e.readUInt8(t++);return a.uses2BytesStreamIds(r)?(n=e.readInt16BE(t),t+=2):n=e.readInt8(t++),new I(r,i,n,e.readUInt8(t++),e.readUInt32BE(t))},I.prototype.toBuffer=function(){let e=n.allocBufferUnsafe(I.size(this.version));e.writeUInt8(this.version,0),e.writeUInt8(this.flags,1);let t=3;return a.uses2BytesStreamIds(this.version)?(e.writeInt16BE(this.streamId,2),t=4):e.writeInt8(this.streamId,2),e.writeUInt8(this.opcode,t++),e.writeUInt32BE(this.bodyLength,t),e},v.fromBuffer=function(e){if(!(e instanceof Buffer))throw TypeError(`Expected Buffer, obtained `+_.inspect(e));return new v(e.readInt32BE(4),e.readInt32BE(0))},v.toBuffer=function(e){if(!(e instanceof v))throw TypeError(`Expected Long, obtained `+_.inspect(e));let t=n.allocBufferUnsafe(8);return t.writeUInt32BE(e.getHighBitsUnsigned(),0),t.writeUInt32BE(e.getLowBitsUnsigned(),4),t},v.prototype.inspect=function(){return`Long: `+this.toString()},v.prototype.toJSON=function(){return this.toString()};function L(e,t){e||=new Date;let n=v.ZERO;return typeof t==`number`&&t>=0&&t<1e3?n=v.fromInt(t):(M>999&&(M=0),n=v.fromInt(M),M++),v.fromNumber(e.getTime()).multiply(j).add(n)}function R(e){R.super_.call(this,e.message,this.constructor),this.internalError=e}_.inherits(R,t.DriverError);function z(e){z.super_.call(this,e,this.constructor),this.info=`Represents an error that happens when the maximum amount of time for an operation passed.`}_.inherits(z,t.DriverError);const B=t.DriverError;var V={opcodes:T,consistencies:b,consistencyToString:x,dataTypes:S,getDataTypeNameByCode:F,distance:w,frameFlags:k,protocolEvents:E,protocolVersion:a,responseErrorCodes:D,resultKind:O,timeuuid:N,uuid:P,BigDecimal:s,Duration:c,FrameHeader:I,InetAddress:l,Integer:o,LocalDate:u,LocalTime:d,Long:v,ResultSet:f,ResultStream:p,Row:m,DriverError:B,TimeoutError:z,TimeUuid:i,Tuple:h,Vector:g,Uuid:r,unset:A,generateTimestamp:L};export{v as Long,b as consistencies,V as default,F as getDataTypeNameByCode,y as types_exports};
package/model/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { mapping } from "../driver/lib/mapping/index.js";
1
+ import { mapping } from "../driver/mapping/index.js";
2
2
  import { Schema } from "../schema/index.js";
3
3
  import export_default from "../operations/tableExists.js";
4
4
  import syncOP from "../operations/sync.js";
@@ -1,4 +1,4 @@
1
- import { mapping } from "../driver/lib/mapping/index.js";
1
+ import { mapping } from "../driver/mapping/index.js";
2
2
  import { Model } from "../model/index.js";
3
3
 
4
4
  //#region src/operations/delete.d.ts
package/package.js CHANGED
@@ -1 +1 @@
1
- var e=`0.19.0`,t=`An ODM for ScyllaDB/Cassandra`;export{t as description,e as version};
1
+ var e=`0.19.1`,t=`An ODM for ScyllaDB/Cassandra`;export{t as description,e as version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ragestudio/scylla-odm",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "description": "An ODM for ScyllaDB/Cassandra",
5
5
  "license": "MIT",
6
6
  "author": "RageStudio",
package/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { mapping } from "./driver/lib/mapping/index.js";
1
+ import { mapping } from "./driver/mapping/index.js";
2
2
  import { ClientOptions } from "./driver/index.js";
3
3
  import { Schema } from "./schema/index.js";
4
4
  import { Document } from "./document/index.js";
@@ -1 +0,0 @@
1
- import e from"./errors.js";import t from"./promise-utils.js";import n from"./utils.js";import r from"./types/index.js";import i from"./client-options.js";import{ProfileManager as a}from"./execution-profile.js";import{DefaultExecutionOptions as o}from"./execution-options.js";import{description as s,version as c}from"../../package.js";import l from"./requests.js";import u from"./metadata/client-state.js";import d from"./prepare-handler.js";import f from"./control-connection.js";import p from"./request-handler.js";import m from"./insights-client.js";import h from"./datastax/graph/graph-executor.js";import g from"util";import _ from"events";function v(e){_.EventEmitter.call(this),this.options=i.extend({logEmitter:this.emit.bind(this),id:r.Uuid.random()},e),Object.defineProperty(this,`profileManager`,{value:new a(this.options)}),Object.defineProperty(this,`controlConnection`,{value:new f(this.options,this.profileManager),writable:!0}),Object.defineProperty(this,`insightsClient`,{value:new m(this)}),this.setMaxListeners(0),this.connected=!1,this.isShuttingDown=!1,this.keyspace=e.keyspace,this.metadata=this.controlConnection.metadata,this.hosts=this.controlConnection.hosts,this.metrics=this.options.metrics,this._graphExecutor=new h(this,e,this._execute)}g.inherits(v,_.EventEmitter),v.prototype.connect=function(e){return this.connected&&e?e():t.optionalCallback(this._connect(),e)},v.prototype._connect=async function(){if(!this.connected){if(this.isShuttingDown)throw new e.NoHostAvailableError(null,`Connecting after shutdown is not supported`);if(this.connecting)return t.fromEvent(this,`connected`);this.connecting=!0,this.log(`info`,g.format(`Connecting to cluster using '%s' version %s`,s,c));try{await this.controlConnection.init(),this.hosts=this.controlConnection.hosts,await this.profileManager.init(this,this.hosts),this.keyspace&&await p.setKeyspace(this),i.setMetadataDependent(this),await this._warmup()}catch(e){throw await this.controlConnection.reset(),this.connected=!1,this.connecting=!1,this.emit(`connected`,e),e}this._setHostListeners(),this.profileManager.getDistance(this.controlConnection.host),this.insightsClient.init(),this.connected=!0,this.connecting=!1,this.emit(`connected`)}},v.prototype.execute=function(e,n,r,i){i||(typeof r==`function`?(i=r,r=null):typeof n==`function`&&(i=n,n=null));try{let a=o.create(r,this);return t.optionalCallback(this._execute(e,n,a),i)}catch(e){return i?i(e):Promise.reject(e)}},v.prototype.executeGraph=function(e,n,r,i){return i=i||r||n,typeof i==`function`?(n=typeof n==`function`?null:n,t.toCallback(this._graphExecutor.send(e,n,r),i)):this._graphExecutor.send(e,n,r)},v.prototype.eachRow=function(e,r,i,a,s){!s&&a&&typeof i==`function`?(s=n.validateFn(a,`rowCallback`),a=i):(s||=n.noop,a=n.validateFn(a||i||r,`rowCallback`)),r=typeof r==`function`?null:r;let c;try{c=o.create(i,this,a)}catch(e){return s(e)}let l=0,u=()=>t.toCallback(this._execute(e,r,c),d);function d(e,t){if(e)return s(e);if(l+=t.rowLength,t.rawPageState!==void 0){if(c.setPageState(t.rawPageState),c.isAutoPage())return u();t.nextPage=u}t.rowLength=l,s(null,t)}t.toCallback(this._execute(e,r,c),d)},v.prototype.stream=function(e,t,i,a){a||=n.noop;let o=new r.ResultStream({objectMode:1});function s(e,t){if(e&&o.emit(`error`,e),t&&t.nextPage){o._valve(function(){try{t.nextPage()}catch(e){o.emit(`error`,e)}});return}o._valve(null),o.add(null),a(e)}let c=!0;return this.eachRow(e,t,i,function(e,t){o.add(t)},function(e,t){if(c)return setImmediate(function(){s(e,t)});s(e,t)}),c=!1,o},v.prototype.batch=function(e,n,r){return!r&&typeof n==`function`&&(r=n,n=null),t.optionalCallback(this._batch(e,n),r)},v.prototype._batch=async function(t,n){if(!Array.isArray(t))throw new e.ArgumentError(`Queries should be an Array`);if(t.length===0)throw new e.ArgumentError(`Queries array should not be empty`);await this._connect();let i=o.create(n,this),a;if(i.isPrepared()){let e=this.controlConnection.protocolVersion,o=r.protocolVersion.supportsKeyspaceInRequest(e)&&n.keyspace||this.keyspace;a=await d.getPreparedMultiple(this,i.getLoadBalancingPolicy(),t,o)}else{a=Array(t.length);for(let n=0;n<t.length;n++){let r=t[n];if(!r)throw new e.ArgumentError(`Invalid query at index ${n}`);let i=typeof r==`string`?r:r.query;if(!i)throw new e.ArgumentError(`Invalid query at index ${n}`);a[n]={query:i,params:r.params}}}let s=await this._createBatchRequest(a,i);return await p.send(s,i,this)},v.prototype.getReplicas=function(e,t){return this.metadata.getReplicas(e,t)},v.prototype.getState=function(){return u.from(this)},v.prototype.log=n.log,v.prototype.shutdown=function(e){return t.optionalCallback(this._shutdown(),e)},v.prototype._shutdown=async function(){if(this.log(`info`,`Shutting down`),!this.hosts||!this.connected){this.connected=!1;return}this.connecting&&(this.log(`warning`,`Shutting down while connecting`),await t.fromEvent(this,`connected`)),this.connected=!1,this.isShuttingDown=!0;let e=this.hosts.values();this.insightsClient.shutdown(),this.controlConnection.shutdown(),this.options.policies.speculativeExecution.shutdown(),this.options.requestTracker&&this.options.requestTracker.shutdown(),await Promise.all(e.map(e=>e.shutdown(!1)))},v.prototype._waitForSchemaAgreement=async function(e){if(this.hosts.length===1)return!0;let n=process.hrtime(),r=this.options.protocolOptions.maxSchemaAgreementWaitSeconds;this.log(`info`,`Waiting for schema agreement`);let i;for(;!i&&process.hrtime(n)[0]<r;){if(i=await this.metadata.compareSchemaVersions(e),i){this.log(`info`,`Schema versions match`);break}await t.delay(500)}return i},v.prototype.handleSchemaAgreementAndRefresh=async function(e,t){let n=!1;try{n=await this._waitForSchemaAgreement(e)}catch(e){this.log(`warning`,`There was an error while waiting for the schema agreement between nodes`,e)}if(!this.options.isMetadataSyncEnabled)return n;try{await this.controlConnection.handleSchemaChange(t,!0)}catch(e){this.log(`warning`,`There was an error while handling schema change`,e)}return n},v.prototype._execute=async function(t,n,i){let a=this.controlConnection.protocolVersion;if(!i.isPrepared()&&n&&!Array.isArray(n)&&!r.protocolVersion.supportsNamedParameters(a))throw new e.ArgumentError(`Named parameters for simple statements are not supported, use prepare flag`);let o;if(this.connected||await this._connect(),!i.isPrepared())o=await this._createQueryRequest(t,i,n);else{let e=i.getLoadBalancingPolicy(),s=r.protocolVersion.supportsKeyspaceInRequest(a)&&i.getKeyspace()||this.keyspace,{queryId:c,meta:l}=await d.getPrepared(this,e,t,s);o=await this._createExecuteRequest(t,c,i,n,l)}return await p.send(o,i,this)},v.prototype._setHostListeners=function(){function e(e,t){return()=>e.emit(`hostUp`,t)}function t(e,t){return()=>e.emit(`hostDown`,t)}let n=this;this.hosts.on(`add`,function(r){r.on(`up`,e(n,r)),r.on(`down`,t(n,r)),n.emit(`hostAdd`,r)}),this.hosts.on(`remove`,function(e){e.removeAllListeners(),n.emit(`hostRemove`,e)}),this.hosts.forEach(function(r){r.on(`up`,e(n,r)),r.on(`down`,t(n,r))})},v.prototype._warmup=function(){let e=this.hosts.values();return t.times(e.length,32,async t=>{let n=e[t],i=this.profileManager.getDistance(n);if(i!==r.distance.ignored)if(this.options.pooling.warmup&&i===r.distance.local)try{await n.warmupPool(this.keyspace)}catch(e){this.log(`warning`,`Connection pool to host ${n.address} could not be created: ${e}`,e)}else n.initializePool()})},v.prototype._getEncoder=function(){let t=this.controlConnection.getEncoder();if(!t)throw new e.DriverInternalError(`Encoder is not defined`);return t},v.prototype._createBatchRequest=async function(e,t){let n=e[0];return n.meta&&await this._setRoutingInfo(t,n.params,n.meta),new l.BatchRequest(e,t)},v.prototype._createExecuteRequest=async function(e,t,r,i,a){return i=n.adaptNamedParamsPrepared(i,a.columns),await this._setRoutingInfo(r,i,a),new l.ExecuteRequest(e,t,i,r,a)},v.prototype._createQueryRequest=async function(e,t,r){await this.metadata.adaptUserHints(this.keyspace,t.getHints());let i=n.adaptNamedParamsWithHints(r,t);return this._getEncoder().setRoutingKeyFromUser(i.params,t,i.keyIndexes),new l.QueryRequest(e,i.params,t,i.namedParameters)},v.prototype._setRoutingInfo=async function(e,t,n){let r=this._getEncoder();if(!e.getKeyspace()&&n.keyspace&&e.setKeyspace(n.keyspace),e.getRoutingKey())return r.setRoutingKeyFromUser(t,e);if(Array.isArray(n.partitionKeys))return e.setRoutingIndexes(n.partitionKeys),r.setRoutingKeyFromMeta(n,t,e);try{let i=await this.metadata.getTable(n.keyspace,n.table);if(!i)return;e.setRoutingIndexes(i.partitionKeys.map(e=>n.columnsByName[e.name])),n.partitionKeys=e.getRoutingIndexes(),r.setRoutingKeyFromMeta(n,t,e)}catch{this.log(`warning`,g.format(`Table %s.%s metadata could not be retrieved`,n.keyspace,n.table))}};export{v as default};
@@ -1 +0,0 @@
1
- import e from"./promise-utils.js";import t from"./utils.js";import n from"./types/version-number.js";import r from"./types/index.js";import i from"./auth/no-auth-provider.js";import"./auth/index.js";import{ExecutionOptions as a}from"./execution-options.js";import{description as o,version as s}from"../../package.js";import c from"./requests.js";import{createRequire as l}from"module";import u from"os";import d from"path";import f from"fs";const p=l(import.meta.url);let m;try{m=p(`kerberos`)}catch{}const h=new n(6,0,5),g=new n(5,1,13),_=new n(6,0,0),v=`CALL InsightsRpc.reportInsight(?)`;var y=class{constructor(e,n){this._client=e,this._sessionId=r.Uuid.random().toString(),this._enabled=!1,this._closed=!1,this._firstTimeout=null,this._recurrentTimeout=null,this._statusErrorLogs=0,n||={},this._statusEventDelay=n.statusEventDelay||3e5,this._errorCallback=n.errorCallback||t.noop}init(){this._enabled=this._client.options.monitorReporting.enabled&&this._dseSupportsInsights(),this._enabled&&e.toBackground(this._init())}async _init(){try{if(await this._sendStartupEvent(),this._closed)return;let e=Math.floor(this._statusEventDelay-.1*this._statusEventDelay*Math.random());this._firstTimeout=setTimeout(()=>{this._sendStatusEvent(),this._recurrentTimeout=setInterval(()=>this._sendStatusEvent(),this._statusEventDelay)},e)}catch(e){if(this._closed)return;this._client.log(`verbose`,`Insights startup message could not be sent (${e})`,e),this._errorCallback(e)}}async _sendStartupEvent(){let e=await this._getStartupMessage(),t=new c.QueryRequest(v,[e],a.empty());await this._client.controlConnection.query(t,!1)}async _sendStatusEvent(){let e=new c.QueryRequest(v,[this._getStatusEvent()],a.empty());try{await this._client.controlConnection.query(e,!1)}catch(e){if(this._closed)return;this._statusErrorLogs<5&&(this._client.log(`warning`,`Insights status message could not be sent (${e})`,e),this._statusErrorLogs++),this._errorCallback(e)}}_dseSupportsInsights(){return this._client.hosts.length===0?!1:this._client.hosts.values().reduce((e,t)=>{if(!e)return e;let r=t.getDseVersion();if(r.length===0)return!1;let i=new n(...r);return i.compare(h)>=0||i.compare(_)<0&&i.compare(g)>=0},!0)}async _getStartupMessage(){let e=this._client.controlConnection,t=this._client.options,n=await this._getAppInfo(t),a={metadata:{name:`driver.startup`,insightMappingId:`v1`,insightType:`EVENT`,timestamp:Date.now(),tags:{language:`nodejs`}},data:{driverName:o,driverVersion:s,clientId:t.id,sessionId:this._sessionId,applicationName:n.applicationName,applicationVersion:n.applicationVersion,applicationNameWasGenerated:n.applicationNameWasGenerated,contactPoints:b(e.getResolvedContactPoints()),dataCenters:this._getDataCenters(),initialControlConnection:e.host?e.host.address:void 0,protocolVersion:e.protocolVersion,localAddress:e.getLocalAddress(),hostName:u.hostname(),executionProfiles:w(this._client),poolSizeByHostDistance:{local:t.pooling.coreConnectionsPerHost[r.distance.local],remote:t.pooling.coreConnectionsPerHost[r.distance.remote]},heartbeatInterval:t.pooling.heartBeatInterval,compression:`NONE`,reconnectionPolicy:x(t.policies.reconnection),ssl:{enabled:!!t.sslOptions,certValidation:t.sslOptions?!!t.sslOptions.rejectUnauthorized:void 0},authProvider:{type:t.authProvider instanceof i?void 0:C(t.authProvider)},otherOptions:{coalescingThreshold:t.socketOptions.coalescingThreshold},platformInfo:{os:{name:u.platform(),version:u.release(),arch:u.arch()},cpus:{length:u.cpus().length,model:u.cpus()[0].model},runtime:{node:process.versions.node,v8:process.versions.v8,uv:process.versions.uv,openssl:process.versions.openssl,kerberos:m?m.version:void 0}},configAntiPatterns:this._getConfigAntiPatterns(),periodicStatusInterval:Math.floor(this._statusEventDelay/1e3)}};return JSON.stringify(a)}_getConfigAntiPatterns(){let e=this._client.options,t={};return e.sslOptions&&!e.sslOptions.rejectUnauthorized&&(t.sslWithoutCertValidation=`Client-to-node encryption is enabled but server certificate validation is disabled`),t}_getDataCenters(){let e=this._client.options.pooling.coreConnectionsPerHost[r.distance.remote],t=new Set;return this._client.hosts.values().forEach(n=>{let i=this._client.profileManager.getDistance(n);(i===r.distance.local||i===r.distance.remote&&e>0)&&t.add(n.datacenter)}),Array.from(t)}async _getAppInfo(e){if(typeof e.applicationName==`string`)return Promise.resolve({applicationName:e.applicationName,applicationVersion:e.applicationVersion,applicationNameWasGenerated:!1});let t=Promise.resolve();if(process.argv[1]){let e=d.dirname(process.argv[1]);t=this._readPackageInfoFile(e)}let n=await t,r=`Default Node Application`,i;if(n)try{let e=JSON.parse(n);e.name&&(r=e.name,i=e.version)}catch{}return{applicationName:r,applicationVersion:i,applicationNameWasGenerated:!0}}_readPackageInfoFile(e){return new Promise(t=>{f.readFile(d.join(e,`package.json`),`utf8`,(e,n)=>{t(n)})})}_getStatusEvent(){let e=this._client.controlConnection,t=this._client.options,n=this._client.getState(),r={};n.getConnectedHosts().forEach(e=>{r[e.address]={connections:n.getOpenConnections(e),inFlightQueries:n.getInFlightQueries(e)}});let i={metadata:{name:`driver.status`,insightMappingId:`v1`,insightType:`EVENT`,timestamp:Date.now(),tags:{language:`nodejs`}},data:{clientId:t.id,sessionId:this._sessionId,controlConnection:e.host?e.host.address:void 0,connectedNodes:r}};return JSON.stringify(i)}shutdown(){this._enabled&&(this._closed=!0,this._firstTimeout!==null&&clearTimeout(this._firstTimeout),this._recurrentTimeout!==null&&clearInterval(this._recurrentTimeout))}};function b(e){let t={};return e.forEach((e,n)=>t[n]=e),t}function x(e){if(!e)return;let n=e.getOptions&&e.getOptions();return{type:e.constructor.name,options:n instanceof Map?b(n):t.emptyObject}}function S(e){if(typeof e==`number`)return r.consistencyToString[e]}function C(e){return e?e.constructor.name:void 0}function w(e){let t={},n=e.profileManager.getDefault();return T(e,t,n,n),e.profileManager.getAll().filter(e=>e!==n).forEach(r=>T(e,t,r,n)),t}function T(e,n,r,i){let a=n[r.name]={};if(E(a,r,i,`readTimeout`),E(a,r,i,`loadBalancing`,x),E(a,r,i,`retry`,x),E(a,r,i,`consistency`,S),E(a,r,i,`serialConsistency`,S),r===i&&(a.speculativeExecution=x(e.options.policies.speculativeExecution)),r.graphOptions){a.graphOptions={};let e=i.graphOptions||t.emptyObject;E(a.graphOptions,r.graphOptions,e,`language`),E(a.graphOptions,r.graphOptions,e,`name`),E(a.graphOptions,r.graphOptions,e,`readConsistency`,S),E(a.graphOptions,r.graphOptions,e,`source`),E(a.graphOptions,r.graphOptions,e,`writeConsistency`,S),Object.keys(a.graphOptions).length===0&&(a.graphOptions=void 0)}}function E(e,t,n,r,i){let a=t[r];i||=(e=>e),(t===n&&a!==void 0||a!==n[r])&&(e[r]=i(a))}export{y as default};
@@ -1 +0,0 @@
1
- import e from"./utils.js";import t from"./types/index.js";import{FrameWriter as n}from"./writers.js";import{ExecutionOptions as r}from"./execution-options.js";import{description as i,version as a}from"../../package.js";import o from"util";const s={values:1,skipMetadata:2,pageSize:4,withPagingState:8,withSerialConsistency:16,withDefaultTimestamp:32,withNameForValues:64,withKeyspace:128,withPageSizeBytes:1073741824,withContinuousPaging:2147483648},c={withSerialConsistency:16,withDefaultTimestamp:32,withNameForValues:64,withKeyspace:128},l={withKeyspace:1},u={logged:0,unlogged:1,counter:2};var d=class{constructor(){this.length=0}write(e,t){throw Error(`Method must be implemented`)}clone(){let e=new this.constructor,t=Object.keys(this);for(let n=0;n<t.length;n++){let r=t[n];e[r]=this[r]}return e}},f=class extends d{constructor(e,n,i,a,o){super(),this.query=e,this.queryId=n,this.params=i,this.meta=o,this.options=a||r.empty(),this.timestamp=this.options.getOrGenerateTimestamp(),this.consistency=this.options.getConsistency()||t.consistencies.one,this.namedParameters=!1}getParamType(e){let t=this.meta.columns[e];return t?t.type:null}write(e,r){let i=new n(t.opcodes.execute),a=this.options.isQueryTracing()?t.frameFlags.tracing:0;return this.options.getCustomPayload()&&(a|=t.frameFlags.customPayload,i.writeCustomPayload(this.options.getCustomPayload())),i.writeShortBytes(this.queryId),t.protocolVersion.supportsResultMetadataId(e.protocolVersion)&&i.writeShortBytes(this.meta.resultId),this.writeQueryParameters(i,e),this.length=i.bodyLength,i.write(e.protocolVersion,r,a)}writeQueryParameters(e,n,r){let i=0,a=this.timestamp;if(t.protocolVersion.supportsPaging(n.protocolVersion)){i|=this.params&&this.params.length?s.values:0,i|=this.options.getFetchSize()>0?s.pageSize:0,i|=this.options.getPageState()?s.withPagingState:0,i|=this.options.getSerialConsistency()?s.withSerialConsistency:0,i|=a==null?0:s.withDefaultTimestamp,i|=this.namedParameters?s.withNameForValues:0;let o=r&&t.protocolVersion.supportsKeyspaceInRequest(n.protocolVersion);i|=o&&this.options.getKeyspace()?s.withKeyspace:0,e.writeShort(this.consistency),t.protocolVersion.uses4BytesQueryFlags(n.protocolVersion)?e.writeInt(i):e.writeByte(i)}if(this.params&&this.params.length){e.writeShort(this.params.length);for(let t=0;t<this.params.length;t++){let r=this.params[t];i&s.withNameForValues&&(e.writeString(r.name),r=r.value),e.writeBytes(n.encode(r,this.getParamType(t)))}}if(!t.protocolVersion.supportsPaging(n.protocolVersion)){(!this.params||!this.params.length)&&e.writeShort(0),e.writeShort(this.consistency);return}i&s.pageSize&&e.writeInt(this.options.getFetchSize()),i&s.withPagingState&&e.writeBytes(this.options.getPageState()),i&s.withSerialConsistency&&e.writeShort(this.options.getSerialConsistency()),i&s.withDefaultTimestamp&&e.writeLong(a),i&s.withKeyspace&&e.writeString(this.options.getKeyspace())}},p=class extends f{constructor(t,n,r,i){super(t,null,n,r,null),this.hints=this.options.getHints()||e.emptyArray,this.namedParameters=i}getParamType(e){return this.hints[e]}write(e,r){let i=new n(t.opcodes.query),a=this.options.isQueryTracing()?t.frameFlags.tracing:0;return this.options.getCustomPayload()&&(a|=t.frameFlags.customPayload,i.writeCustomPayload(this.options.getCustomPayload())),i.writeLString(this.query),t.protocolVersion.supportsPaging(e.protocolVersion)?this.writeQueryParameters(i,e,!0):i.writeShort(this.consistency),this.length=i.bodyLength,i.write(e.protocolVersion,r,a)}},m=class extends d{constructor(e,t){super(),this.query=e,this.keyspace=t}write(e,r){let i=new n(t.opcodes.prepare);if(i.writeLString(this.query),t.protocolVersion.supportsPrepareFlags(e.protocolVersion)){let n=this.keyspace&&t.protocolVersion.supportsKeyspaceInRequest(e.protocolVersion)?l.withKeyspace:0;i.writeInt(n),n&l.withKeyspace&&i.writeString(this.keyspace)}return i.write(e.protocolVersion,r)}},h=class extends d{constructor(e){super(),this.options=e||{}}write(e,r){let o=new n(t.opcodes.startup),s={CQL_VERSION:this.options.cqlVersion||`3.0.0`,DRIVER_NAME:i,DRIVER_VERSION:a};return this.options.noCompact&&(s.NO_COMPACT=`true`),this.options.clientId&&(s.CLIENT_ID=this.options.clientId.toString()),this.options.applicationName&&(s.APPLICATION_NAME=this.options.applicationName),this.options.applicationVersion&&(s.APPLICATION_VERSION=this.options.applicationVersion),o.writeStringMap(s),o.write(e.protocolVersion,r)}},g=class extends d{constructor(e){super(),this.events=e}write(e,r){let i=new n(t.opcodes.register);return i.writeStringList(this.events),i.write(e.protocolVersion,r)}},_=class extends d{constructor(e){super(),this.token=e}write(e,r){let i=new n(t.opcodes.authResponse);return i.writeBytes(this.token),i.write(e.protocolVersion,r)}},v=class extends d{constructor(e,t){super(),this.username=e,this.password=t}write(e,r){let i=new n(t.opcodes.credentials);return i.writeStringMap({username:this.username,password:this.password}),i.write(e.protocolVersion,r)}},y=class r extends d{constructor(t,n){super(),this.queries=t,this.options=n,this.timestamp=this.options.getOrGenerateTimestamp(),this.hints=n.getHints()||e.emptyArray,this.type=u.logged,n.isBatchCounter()?this.type=u.counter:n.isBatchLogged()||(this.type=u.unlogged)}write(r,i){if(!this.queries||!(this.queries.length>0))throw TypeError(o.format(`Invalid queries provided %s`,this.queries));let a=new n(t.opcodes.batch),s=this.options.isQueryTracing()?t.frameFlags.tracing:0;this.options.getCustomPayload()&&(s|=t.frameFlags.customPayload,a.writeCustomPayload(this.options.getCustomPayload())),a.writeByte(this.type),a.writeShort(this.queries.length);let l=this;if(this.queries.forEach(function(t,n){let i=l.hints[n],o=t.params||e.emptyArray,s;t.queryId?(a.writeByte(1),a.writeShortBytes(t.queryId),s=e=>t.meta.columns[e].type):(a.writeByte(0),a.writeLString(t.query),s=i?e=>i[e]:()=>null),a.writeShort(o.length),o.forEach((e,t)=>a.writeBytes(r.encode(e,s(t))))},this),a.writeShort(this.options.getConsistency()),t.protocolVersion.supportsTimestamp(r.protocolVersion)){let e=this.options.getSerialConsistency()?c.withSerialConsistency:0,n=this.timestamp;e|=n==null?0:c.withDefaultTimestamp,e|=this.options.getKeyspace()&&t.protocolVersion.supportsKeyspaceInRequest(r.protocolVersion)?c.withKeyspace:0,t.protocolVersion.uses4BytesQueryFlags(r.protocolVersion)?a.writeInt(e):a.writeByte(e),e&c.withSerialConsistency&&a.writeShort(this.options.getSerialConsistency()),e&c.withDefaultTimestamp&&a.writeLong(n),e&c.withKeyspace&&a.writeString(this.options.getKeyspace())}return this.length=a.bodyLength,a.write(r.protocolVersion,i,s)}clone(){return new r(this.queries,this.options)}};function b(e){this.streamId=null,this.operationId=e}o.inherits(b,d),b.prototype.write=function(e,r){let i=new n(t.opcodes.cancel);return i.writeInt(1),i.writeInt(this.operationId),i.write(e.protocolVersion,r)};var x={AuthResponseRequest:_,BatchRequest:y,CancelRequest:b,CredentialsRequest:v,ExecuteRequest:f,options:new class extends d{write(e,r){return new n(t.opcodes.options).write(e.protocolVersion,r,0)}clone(){return this}},PrepareRequest:m,QueryRequest:p,RegisterRequest:g,Request:d,StartupRequest:h};export{f as ExecuteRequest,p as QueryRequest,x as default};
@@ -1 +0,0 @@
1
- import{__exportAll as e}from"../../../_virtual/_rolldown/runtime.js";import t from"../errors.js";import n from"../utils.js";import r from"./uuid.js";import i from"./time-uuid.js";import a from"./protocol-version.js";import o from"./integer.js";import s from"./big-decimal.js";import c from"./duration.js";import l from"./inet-address.js";import u from"./local-date.js";import d from"./local-time.js";import f from"./result-set.js";import p from"./result-stream.js";import m from"./row.js";import h from"./tuple.js";import g from"./vector.js";import _ from"util";import v from"long";var y=e({BigDecimal:()=>s,DriverError:()=>B,Duration:()=>c,FrameHeader:()=>I,InetAddress:()=>l,Integer:()=>o,LocalDate:()=>u,LocalTime:()=>d,Long:()=>v,ResultSet:()=>f,ResultStream:()=>p,Row:()=>m,TimeUuid:()=>i,TimeoutError:()=>z,Tuple:()=>h,Uuid:()=>r,Vector:()=>g,consistencies:()=>b,consistencyToString:()=>x,dataTypes:()=>S,default:()=>V,distance:()=>w,frameFlags:()=>k,generateTimestamp:()=>L,getDataTypeNameByCode:()=>F,opcodes:()=>T,protocolEvents:()=>E,protocolVersion:()=>a,responseErrorCodes:()=>D,resultKind:()=>O,timeuuid:()=>N,unset:()=>A,uuid:()=>P});const b={any:0,one:1,two:2,three:3,quorum:4,all:5,localQuorum:6,eachQuorum:7,serial:8,localSerial:9,localOne:10},x={};x[b.any]=`ANY`,x[b.one]=`ONE`,x[b.two]=`TWO`,x[b.three]=`THREE`,x[b.quorum]=`QUORUM`,x[b.all]=`ALL`,x[b.localQuorum]=`LOCAL_QUORUM`,x[b.eachQuorum]=`EACH_QUORUM`,x[b.serial]=`SERIAL`,x[b.localSerial]=`LOCAL_SERIAL`,x[b.localOne]=`LOCAL_ONE`;const S={custom:0,ascii:1,bigint:2,blob:3,boolean:4,counter:5,decimal:6,double:7,float:8,int:9,text:10,timestamp:11,uuid:12,varchar:13,varint:14,timeuuid:15,inet:16,date:17,time:18,smallint:19,tinyint:20,duration:21,list:32,map:33,set:34,udt:48,tuple:49,getByName:function(e){if(e=e.toLowerCase(),e.indexOf(`<`)>0){let t=/^(list|set)<(.+)>$/.exec(e);if(t)return{code:this[t[1]],info:this.getByName(t[2])};let n=/^(map)< *(.+) *, *(.+)>$/.exec(e);if(n)return{code:this[n[1]],info:[this.getByName(n[2]),this.getByName(n[3])]};let r=/^(udt)<(.+)>$/.exec(e);if(r)return{code:this[r[1]],info:r[2]};let i=/^(tuple)<(.+)>$/.exec(e);if(i)return{code:this[i[1]],info:i[2].split(`,`).map(function(e){return this.getByName(e.trim())},this)};let a=/^vector<\s*(.+)\s*,\s*(\d+)\s*>$/.exec(e);if(a)return{code:this.custom,customTypeName:`vector`,info:[this.getByName(a[1]),parseInt(a[2],10)]}}let t={code:this[e]};if(typeof t.code!=`number`)throw TypeError(`Data type with name `+e+` not valid`);return t}},C=(function(){let e={};for(let t in S){if(!S.hasOwnProperty(t))continue;let n=S[t];typeof n==`number`&&(e[n]=t)}return e})(),w={local:0,remote:1,ignored:2},T={error:0,startup:1,ready:2,authenticate:3,credentials:4,options:5,supported:6,query:7,result:8,prepare:9,execute:10,register:11,event:12,batch:13,authChallenge:14,authResponse:15,authSuccess:16,cancel:255,isInRange:function(e){return e>this.error&&e>this.event}},E={topologyChange:`TOPOLOGY_CHANGE`,statusChange:`STATUS_CHANGE`,schemaChange:`SCHEMA_CHANGE`},D={serverError:0,protocolError:10,badCredentials:256,unavailableException:4096,overloaded:4097,isBootstrapping:4098,truncateError:4099,writeTimeout:4352,readTimeout:4608,readFailure:4864,functionFailure:5120,writeFailure:5376,syntaxError:8192,unauthorized:8448,invalid:8704,configError:8960,alreadyExists:9216,unprepared:9472,clientWriteFailure:32768},O={voidResult:1,rows:2,setKeyspace:3,prepared:4,schemaChange:5},k={compression:1,tracing:2,customPayload:4,warning:8},A=Object.freeze({unset:!0}),j=v.fromInt(1e3);let M=0;function N(e,t,r){let a,o,s,c;e&&(typeof e.msecs==`number`&&(a=new Date(e.msecs)),e.msecs instanceof Date&&(a=e.msecs),Array.isArray(e.node)&&(s=n.allocBufferFromArray(e.node)),typeof e.clockseq==`number`&&(c=n.allocBufferUnsafe(2),c.writeUInt16BE(e.clockseq,0)),typeof e.nsecs==`number`&&(o=e.nsecs));let l=new i(a,o,s,c);return t instanceof Buffer?(l.getBuffer().copy(t,r||0),t):l.toString()}function P(e,t,i){let a;return e&&Array.isArray(e.random)&&(a=new r(n.allocBufferFromArray(e.random))),a||=r.random(),t instanceof Buffer?(a.getBuffer().copy(t,i||0),t):a.toString()}function F(e){if(!e||typeof e.code!=`number`)throw new t.ArgumentError(`Invalid signature type definition`);let n=C[e.code];if(!n)throw new t.ArgumentError(_.format(`Type with code %d not found`,e.code));return!(`info`in e)||!e.info?n:e.code===S.custom&&`customTypeName`in e&&e.customTypeName===`vector`?`vector<`+F(e.info[0])+`, `+e.info[1]+`>`:Array.isArray(e.info)?n+`<`+e.info.map(function(e){return F(e)}).join(`, `)+`>`:typeof e.info.code==`number`?n+`<`+F(e.info)+`>`:e.code===S.udt?e.info.name:n}function I(e,t,n,r,i){this.version=e,this.flags=t,this.streamId=n,this.opcode=r,this.bodyLength=i}I.size=function(e){return a.uses2BytesStreamIds(e)?9:8},I.getProtocolVersion=function(e){return e[0]&127},I.fromBuffer=function(e,t){let n=0;t||=0;let r=e[t++]&127,i=e.readUInt8(t++);return a.uses2BytesStreamIds(r)?(n=e.readInt16BE(t),t+=2):n=e.readInt8(t++),new I(r,i,n,e.readUInt8(t++),e.readUInt32BE(t))},I.prototype.toBuffer=function(){let e=n.allocBufferUnsafe(I.size(this.version));e.writeUInt8(this.version,0),e.writeUInt8(this.flags,1);let t=3;return a.uses2BytesStreamIds(this.version)?(e.writeInt16BE(this.streamId,2),t=4):e.writeInt8(this.streamId,2),e.writeUInt8(this.opcode,t++),e.writeUInt32BE(this.bodyLength,t),e},v.fromBuffer=function(e){if(!(e instanceof Buffer))throw TypeError(`Expected Buffer, obtained `+_.inspect(e));return new v(e.readInt32BE(4),e.readInt32BE(0))},v.toBuffer=function(e){if(!(e instanceof v))throw TypeError(`Expected Long, obtained `+_.inspect(e));let t=n.allocBufferUnsafe(8);return t.writeUInt32BE(e.getHighBitsUnsigned(),0),t.writeUInt32BE(e.getLowBitsUnsigned(),4),t},v.prototype.inspect=function(){return`Long: `+this.toString()},v.prototype.toJSON=function(){return this.toString()};function L(e,t){e||=new Date;let n=v.ZERO;return typeof t==`number`&&t>=0&&t<1e3?n=v.fromInt(t):(M>999&&(M=0),n=v.fromInt(M),M++),v.fromNumber(e.getTime()).multiply(j).add(n)}function R(e){R.super_.call(this,e.message,this.constructor),this.internalError=e}_.inherits(R,t.DriverError);function z(e){z.super_.call(this,e,this.constructor),this.info=`Represents an error that happens when the maximum amount of time for an operation passed.`}_.inherits(z,t.DriverError);const B=t.DriverError;var V={opcodes:T,consistencies:b,consistencyToString:x,dataTypes:S,getDataTypeNameByCode:F,distance:w,frameFlags:k,protocolEvents:E,protocolVersion:a,responseErrorCodes:D,resultKind:O,timeuuid:N,uuid:P,BigDecimal:s,Duration:c,FrameHeader:I,InetAddress:l,Integer:o,LocalDate:u,LocalTime:d,Long:v,ResultSet:f,ResultStream:p,Row:m,DriverError:B,TimeoutError:z,TimeUuid:i,Tuple:h,Vector:g,Uuid:r,unset:A,generateTimestamp:L};export{v as Long,b as consistencies,V as default,F as getDataTypeNameByCode,y as types_exports};
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes