11import { ILazyOperation } from "./ILazyOperation" ;
22import { ClusterTransactionOperationsBase } from "../../ClusterTransactionOperationsBase" ;
3- import { CompareExchangeResultClass } from "../../../../Types" ;
3+ import { CompareExchangeResultClass , ServerCasing , ServerResponse } from "../../../../Types" ;
44import { throwError } from "../../../../Exceptions" ;
55import { TypeUtil } from "../../../../Utility/TypeUtil" ;
66import { GetRequest } from "../../../Commands/MultiGet/GetRequest" ;
@@ -16,6 +16,7 @@ import { DocumentConventions } from "../../../Conventions/DocumentConventions";
1616import { QueryResult } from "../../../Queries/QueryResult" ;
1717import { CompareExchangeValue } from "../../../Operations/CompareExchange/CompareExchangeValue" ;
1818import { StringBuilder } from "../../../../Utility/StringBuilder" ;
19+ import { GetCompareExchangeValuesCommand } from "../../../Operations/CompareExchange/GetCompareExchangeValuesOperation" ;
1920
2021export class LazyGetCompareExchangeValuesOperation < T > implements ILazyOperation {
2122 private readonly _clusterSession : ClusterTransactionOperationsBase ;
@@ -131,14 +132,13 @@ export class LazyGetCompareExchangeValuesOperation<T> implements ILazyOperation
131132 }
132133
133134 if ( response . result ) {
134- const results = await RavenCommandResponsePipeline . create < GetCompareExchangeValuesResponse > ( )
135- . parseJsonAsync ( )
136- . jsonKeysTransform ( "GetCompareExchangeValue" , this . _conventions )
137- . process ( stringToReadable ( response . result ) ) ;
135+ const results = JSON . parse ( response . result ) as ServerCasing < ServerResponse < GetCompareExchangeValuesResponse > > ;
136+
137+ const localObject = GetCompareExchangeValuesCommand . mapToLocalObject ( results ) ;
138138
139139 if ( this . _clusterSession . session . noTracking ) {
140140 const result : { [ key : string ] : CompareExchangeValue < T > } = { } ;
141- for ( const kvp of Object . entries ( CompareExchangeValueResultParser . getValues ( results , false , this . _conventions ) ) ) {
141+ for ( const kvp of Object . entries ( CompareExchangeValueResultParser . getValues ( localObject , false , this . _conventions ) ) ) {
142142 if ( ! kvp [ 1 ] . value ) {
143143 result [ kvp [ 0 ] ] = this . _clusterSession . registerMissingCompareExchangeValue ( kvp [ 0 ] ) . getValue ( this . _clazz , this . _conventions ) ;
144144 continue ;
@@ -151,7 +151,7 @@ export class LazyGetCompareExchangeValuesOperation<T> implements ILazyOperation
151151 return ;
152152 }
153153
154- for ( const kvp of Object . entries ( CompareExchangeValueResultParser . getValues ( results , false , this . _conventions ) ) ) {
154+ for ( const kvp of Object . entries ( CompareExchangeValueResultParser . getValues ( localObject , false , this . _conventions ) ) ) {
155155 if ( ! kvp [ 1 ] ) {
156156 continue ;
157157 }
0 commit comments