1- import { google , Ydb } from "ydb-sdk-proto" ;
1+ import { google , Ydb } from "ydb-sdk-proto" ;
22import IQuery = Ydb . Table . IQuery ;
33import IType = Ydb . IType ;
44import DescribeTableResult = Ydb . Table . DescribeTableResult ;
@@ -19,15 +19,15 @@ import BulkUpsertResult = Ydb.Table.BulkUpsertResult;
1919import OperationMode = Ydb . Operations . OperationParams . OperationMode ;
2020import * as grpc from "@grpc/grpc-js" ;
2121import EventEmitter from "events" ;
22- import { ICreateSessionResult , SessionEvent , TableService } from "./table-session-pool" ;
23- import { Endpoint } from "../discovery" ;
24- import { retryable , RetryParameters , RetryStrategy } from "../retries_obsoleted" ;
25- import { MissingStatus , MissingValue , SchemeError , YdbError } from "../errors" ;
26- import { ResponseMetadataKeys } from "../constants" ;
27- import { pessimizable } from "../utils" ;
28- import { YdbOperationAsyncResponse , ensureOperationSucceeded , getOperationPayload } from "../utils/process-ydb-operation-result" ;
29- import { StreamEnd } from "../utils" ;
30- import { Logger } from "../logger/simple-logger" ;
22+ import { ICreateSessionResult , SessionEvent , TableService } from "./table-session-pool" ;
23+ import { Endpoint } from "../discovery" ;
24+ import { retryable , RetryParameters , RetryStrategy } from "../retries_obsoleted" ;
25+ import { MissingStatus , MissingValue , SchemeError , YdbError } from "../errors" ;
26+ import { ResponseMetadataKeys } from "../constants" ;
27+ import { pessimizable } from "../utils" ;
28+ import { YdbOperationAsyncResponse , ensureOperationSucceeded , getOperationPayload } from "../utils/process-ydb-operation-result" ;
29+ import { StreamEnd } from "../utils" ;
30+ import { Logger } from "../logger/simple-logger" ;
3131
3232interface PartialResponse < T > {
3333 status ?: ( Ydb . StatusIds . StatusCode | null ) ;
@@ -78,7 +78,7 @@ export class OperationParams implements Ydb.Operations.IOperationParams {
7878 }
7979
8080 withOperationTimeoutSeconds ( seconds : number ) {
81- this . operationTimeout = { seconds} ;
81+ this . operationTimeout = { seconds } ;
8282 return this ;
8383 }
8484
@@ -88,7 +88,7 @@ export class OperationParams implements Ydb.Operations.IOperationParams {
8888 }
8989
9090 withCancelAfterSeconds ( seconds : number ) {
91- this . cancelAfter = { seconds} ;
91+ this . cancelAfter = { seconds } ;
9292 return this ;
9393 }
9494
@@ -125,7 +125,7 @@ interface IDropTableSettings {
125125export class DropTableSettings extends OperationParamsSettings {
126126 muteNonExistingTableErrors : boolean ;
127127
128- constructor ( { muteNonExistingTableErrors = true } = { } as IDropTableSettings ) {
128+ constructor ( { muteNonExistingTableErrors = true } = { } as IDropTableSettings ) {
129129 super ( ) ;
130130 this . muteNonExistingTableErrors = muteNonExistingTableErrors ;
131131 }
@@ -312,13 +312,13 @@ export class TableSession extends EventEmitter implements ICreateSessionResult {
312312 return Promise . resolve ( ) ;
313313 }
314314 this . beingDeleted = true ;
315- ensureOperationSucceeded ( await this . api . deleteSession ( { sessionId : this . sessionId } ) ) ;
315+ ensureOperationSucceeded ( await this . api . deleteSession ( { sessionId : this . sessionId } ) ) ;
316316 }
317317
318318 @retryable ( )
319319 @pessimizable
320320 public async keepAlive ( ) : Promise < void > {
321- const request = { sessionId : this . sessionId } ;
321+ const request = { sessionId : this . sessionId } ;
322322 const response = await this . api . keepAlive ( request ) ;
323323 ensureOperationSucceeded ( this . processResponseMetadata ( request , response ) ) ;
324324 }
@@ -439,7 +439,7 @@ export class TableSession extends EventEmitter implements ICreateSessionResult {
439439 }
440440 const response = await this . api . beginTransaction ( request ) ;
441441 const payload = getOperationPayload ( this . processResponseMetadata ( request , response ) ) ;
442- const { txMeta} = BeginTransactionResult . decode ( payload ) ;
442+ const { txMeta } = BeginTransactionResult . decode ( payload ) ;
443443 if ( txMeta ) {
444444 return txMeta ;
445445 }
@@ -524,15 +524,15 @@ export class TableSession extends EventEmitter implements ICreateSessionResult {
524524 request . collectStats = settings . collectStats ;
525525 }
526526 if ( keepInCache ) {
527- request . queryCachePolicy = { keepInCache} ;
527+ request . queryCachePolicy = { keepInCache } ;
528528 }
529529
530530 if ( ! executeQueryRetryer ) executeQueryRetryer = new RetryStrategy ( 'TableSession:executeQuery' , new RetryParameters ( ) , this . logger ) ;
531531
532532 const response =
533533 settings ?. idempotent
534- ? await executeQueryRetryer . retry ( ( ) => this . api . executeDataQuery ( request ) )
535- : await this . api . executeDataQuery ( request ) ;
534+ ? await executeQueryRetryer . retry ( ( ) => this . api . executeDataQuery ( request ) )
535+ : await this . api . executeDataQuery ( request ) ;
536536 const payload = getOperationPayload ( this . processResponseMetadata ( request , response , settings ?. onResponseMetadata ) ) ;
537537 return ExecuteQueryResult . decode ( payload ) ;
538538 }
@@ -887,6 +887,7 @@ export class TableIndex implements Ydb.Table.ITableIndex {
887887 public dataColumns : string [ ] | null = null ;
888888 public globalIndex : Ydb . Table . IGlobalIndex | null = null ;
889889 public globalAsyncIndex : Ydb . Table . IGlobalAsyncIndex | null = null ;
890+ public globalUniqueIndex : Ydb . Table . IGlobalUniqueIndex | null = null ;
890891
891892 constructor ( public name : string ) {
892893 }
@@ -913,13 +914,20 @@ export class TableIndex implements Ydb.Table.ITableIndex {
913914 }
914915 return this
915916 }
917+
918+ withGlobalUnique ( ) {
919+ this . globalUniqueIndex = new Ydb . Table . GlobalUniqueIndex ( )
920+ this . globalAsyncIndex = null
921+ this . globalIndex = null
922+ return this
923+ }
916924}
917925
918926export class TtlSettings implements Ydb . Table . ITtlSettings {
919927 public dateTypeColumn ?: Ydb . Table . IDateTypeColumnModeSettings | null ;
920928
921929 constructor ( columnName : string , expireAfterSeconds : number = 0 ) {
922- this . dateTypeColumn = { columnName, expireAfterSeconds} ;
930+ this . dateTypeColumn = { columnName, expireAfterSeconds } ;
923931 }
924932}
925933
0 commit comments