Skip to content

Commit

Permalink
sync d393d1c9c8eaaeaa1e4ad6764d5260561c876e8c .. be9b7f88aa409ee0915d…
Browse files Browse the repository at this point in the history
…80a0cf7e87f30ba4f219 - fixes
  • Loading branch information
ml054 committed Dec 1, 2023
1 parent 1ea7a95 commit ce7b36c
Show file tree
Hide file tree
Showing 104 changed files with 915 additions and 764 deletions.
282 changes: 141 additions & 141 deletions package-lock.json

Large diffs are not rendered by default.

27 changes: 25 additions & 2 deletions src/Documents/BulkInsertOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,15 @@ export class BulkInsertOperation {
return false;
}

public on(event: "progress", handler: (value: BulkInsertOnProgressEventArgs) => void) {
public on(event: "progress", handler: (value: BulkInsertOnProgressEventArgs) => void): this {
this._emitter.on("progress", handler);
this._onProgressInitialized = true;
return this;
}

public off(event: "progress", handler: (value: BulkInsertOnProgressEventArgs) => void) {
public off(event: "progress", handler: (value: BulkInsertOnProgressEventArgs) => void): this {
this._emitter.off("progress", handler);
return this;
}

get useCompression(): boolean {
Expand Down Expand Up @@ -191,6 +194,26 @@ export class BulkInsertOperation {
await this._requestExecutor.execute(bulkInsertGetIdRequest);
this._operationId = bulkInsertGetIdRequest.result;
this._nodeTag = bulkInsertGetIdRequest.nodeTag;

if (this._onProgressInitialized && !this._unsubscribeChanges) {
const observable = this._store.changes()
.forOperationId(this._operationId);

const handler = value => {
const state = value.state;
if (state && state.status === "InProgress") {
this._emitter.emit("progress", new BulkInsertOnProgressEventArgs(state.progress));
}
}

observable.on("data", handler);

this._unsubscribeChanges = {
dispose(): void {
observable.off("data", handler)
}
};
}
}

private static _typeCheckStoreArgs(
Expand Down
2 changes: 1 addition & 1 deletion src/Documents/Changes/AggressiveCacheChange.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DatabaseChange } from "./DatabaseChange";
import { DocumentChange, DocumentChangeTypes } from "./DocumentChange";
import { DocumentChange } from "./DocumentChange";
import { IndexChange } from "./IndexChange";

export class AggressiveCacheChange implements DatabaseChange {
Expand Down
18 changes: 9 additions & 9 deletions src/Documents/Changes/ChangesObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export class ChangesObservable<T, TConnectionState extends IChangesConnectionSta
this._filter = filter;
}

public on(event: "data", handler: (value: T) => void);
public on(event: "error", handler: (error: Error) => void);
public on(event: "data" | "error", handler: ((value: T) => void) | ((error: Error) => void)) {
public on(event: "data", handler: (value: T) => void): this;
public on(event: "error", handler: (error: Error) => void): this;
public on(event: "data" | "error", handler: ((value: T) => void) | ((error: Error) => void)): this {
switch (event) {
case "data":
// since allow multiple subscriptions on single object we cant register it multiple times
Expand Down Expand Up @@ -49,15 +49,15 @@ export class ChangesObservable<T, TConnectionState extends IChangesConnectionSta
return this;
}

public removeListener(event: "data", handler: (value: T) => void);
public removeListener(event: "error", handler: (error: Error) => void);
public removeListener(event: "data" | "error", handler: ((value: T) => void) | ((error: Error) => void)) {
public removeListener(event: "data", handler: (value: T) => void): this;
public removeListener(event: "error", handler: (error: Error) => void): this;
public removeListener(event: "data" | "error", handler: ((value: T) => void) | ((error: Error) => void)): this {
return this.off(event as any, handler as any);
}

public off(event: "data", handler: (value: T) => void);
public off(event: "error", handler: (error: Error) => void);
public off(event: "data" | "error", handler: ((value: T) => void) | ((error: Error) => void)) {
public off(event: "data", handler: (value: T) => void): this;
public off(event: "error", handler: (error: Error) => void): this;
public off(event: "data" | "error", handler: ((value: T) => void) | ((error: Error) => void)): this {

switch (event) {
case "data":
Expand Down
14 changes: 8 additions & 6 deletions src/Documents/Changes/DatabaseChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,18 @@ export class DatabaseChanges implements IDatabaseChanges {
return this._client && this._client.readyState === WebSocket.OPEN;
}

public on(eventName: "connectionStatus", handler: () => void);
public on(eventName: "error", handler: (error: Error) => void);
public on(eventName: "connectionStatus" | "error", handler) {
public on(eventName: "connectionStatus", handler: () => void): this;
public on(eventName: "error", handler: (error: Error) => void): this;
public on(eventName: "connectionStatus" | "error", handler): this {
this._emitter.addListener(eventName, handler);
return this;
}

public off(eventName: "connectionStatus", handler: () => void);
public off(eventName: "error", handler: (error: Error) => void);
public off(eventName: "connectionStatus" | "error", handler) {
public off(eventName: "connectionStatus", handler: () => void): this;
public off(eventName: "error", handler: (error: Error) => void): this;
public off(eventName: "connectionStatus" | "error", handler): this {
this._emitter.removeListener(eventName, handler);
return this;
}

public ensureConnectedNow(): Promise<IDatabaseChanges> {
Expand Down
12 changes: 6 additions & 6 deletions src/Documents/Changes/IChangesObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ export interface IChangesObservable<T> extends IObservable<T> {
}

export interface IObservable<T> {
on(event: "data", handler: (value: T) => void);
on(event: "data", handler: (value: T) => void): this;

on(event: "error", handler: (error: Error) => void);
on(event: "error", handler: (error: Error) => void): this;

off(event: "data", handler: (value: T) => void);
off(event: "data", handler: (value: T) => void): this;

off(event: "error", handler: (error: Error) => void);
off(event: "error", handler: (error: Error) => void): this;

removeListener(event: "data", handler: (value: T) => void);
removeListener(event: "data", handler: (value: T) => void): this;

removeListener(event: "error", handler: (error: Error) => void);
removeListener(event: "error", handler: (error: Error) => void): this;
}
4 changes: 2 additions & 2 deletions src/Documents/Commands/Batches/ForceRevisionCommandData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommandType, ICommandData } from "../CommandData";
import { throwError } from "../../../Exceptions/index";
import { throwError } from "../../../Exceptions";
import { DocumentConventions } from "../../Conventions/DocumentConventions";

export class ForceRevisionCommandData implements ICommandData {
Expand All @@ -22,4 +22,4 @@ export class ForceRevisionCommandData implements ICommandData {
Type: this.type
}
}
}
}
2 changes: 1 addition & 1 deletion src/Documents/Commands/Batches/PutAttachmentCommandData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ICommandData, CommandType } from "../CommandData";
import { AttachmentData } from "./../../Attachments/index";
import { AttachmentData } from "../../Attachments";
import { StringUtil } from "../../../Utility/StringUtil";
import { throwError } from "../../../Exceptions";
import { DocumentConventions } from "../../Conventions/DocumentConventions";
Expand Down
4 changes: 2 additions & 2 deletions src/Documents/Commands/Batches/SingleNodeBatchCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { BatchCommandResult } from "../../Session/Operations/BatchCommandResult"
import { IDisposable } from "../../../Types/Contracts";
import { DocumentConventions } from "../../Conventions/DocumentConventions";
import { ICommandData } from "../CommandData";
import { AttachmentData } from "../../Attachments/index";
import { AttachmentData } from "../../Attachments";
import { BatchOptions } from "./BatchOptions";
import { TransactionMode } from "../../Session/TransactionMode";
import { throwError } from "../../../Exceptions/index";
import { throwError } from "../../../Exceptions";
import { PutAttachmentCommandData } from "./PutAttachmentCommandData";
import { HttpRequestParameters } from "../../../Primitives/Http";
import { HeadersBuilder } from "../../../Utility/HttpUtil";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommandType } from "../CommandData";
import { AppendOperation, DeleteOperation, TimeSeriesOperation } from "../../Operations/TimeSeries/TimeSeriesOperation";
import { AppendOperation, DeleteOperation } from "../../Operations/TimeSeries/TimeSeriesOperation";
import { TimeSeriesCommandData } from "./TimeSeriesCommandData";

export class TimeSeriesBatchCommandData extends TimeSeriesCommandData {
Expand Down
4 changes: 2 additions & 2 deletions src/Documents/Commands/ConditionalGetDocumentsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DocumentConventions } from "../Conventions/DocumentConventions";
import { readToEnd, stringToReadable } from "../../Utility/StreamUtil";
import { RavenCommandResponsePipeline } from "../../Http/RavenCommandResponsePipeline";
import { ObjectUtil } from "../../Utility/ObjectUtil";
import { CONSTANTS, HEADERS } from "../../Constants";
import { HEADERS } from "../../Constants";

export class ConditionalGetDocumentsCommand extends RavenCommand<ConditionalGetResult> {

Expand All @@ -27,7 +27,7 @@ export class ConditionalGetDocumentsCommand extends RavenCommand<ConditionalGetR

createRequest(node: ServerNode): HttpRequestParameters {
const uri = node.url + "/databases/" + node.database + "/docs?id=" + this._urlEncode(this._id);

return {
uri,
method: "GET",
Expand Down
2 changes: 1 addition & 1 deletion src/Documents/Commands/GetTcpInfoForRemoteTaskCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RavenCommand } from "../../Http/RavenCommand";
import { TcpConnectionInfo } from "../../ServerWide/Commands/GetTcpInfoCommand";
import { throwError } from "../../Exceptions/index";
import { throwError } from "../../Exceptions";
import { ServerNode } from "../../Http/ServerNode";
import { HttpRequestParameters } from "../../Primitives/Http";
import * as stream from "readable-stream";
Expand Down
8 changes: 4 additions & 4 deletions src/Documents/Commands/HeadAttachmentCommand.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { RavenCommand, ResponseDisposeHandling } from "./../../Http/RavenCommand";
import { HttpCache } from "./../../Http/HttpCache";
import { HttpRequestParameters, HttpResponse } from "./../../Primitives/Http";
import { RavenCommand, ResponseDisposeHandling } from "../../Http/RavenCommand";
import { HttpCache } from "../../Http/HttpCache";
import { HttpRequestParameters, HttpResponse } from "../../Primitives/Http";
import { StringUtil } from "../../Utility/StringUtil";
import { throwError } from "../../Exceptions";
import { ServerNode } from "../../Http/ServerNode";
import { StatusCodes } from "./../../Http/StatusCode";
import { StatusCodes } from "../../Http/StatusCode";
import * as stream from "readable-stream";
import { getRequiredEtagHeader } from "../../Utility/HttpUtil";
import { HEADERS } from "../../Constants";
Expand Down
5 changes: 1 addition & 4 deletions src/Documents/Commands/MultiGet/MultiGetCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ import { ServerNode } from "../../../Http/ServerNode";
import { StatusCodes } from "../../../Http/StatusCode";
import { getEtagHeader } from "../../../Utility/HttpUtil";
import { DocumentConventions } from "../../Conventions/DocumentConventions";
import { TypeUtil } from "../../../Utility/TypeUtil";
import { throwError } from "../../../Exceptions";
import { IDisposable } from "../../../Types/Contracts";
import { RequestExecutor } from "../../../Http/RequestExecutor";
import { AggressiveCacheOptions } from "../../../Http/AggressiveCacheOptions";
import { CONSTANTS, HEADERS } from "../../../Constants";
import { HEADERS } from "../../../Constants";
import { ServerCasing, ServerResponse } from "../../../Types";
import { ConditionalGetResult } from "../ConditionalGetDocumentsCommand";
import { ObjectUtil } from "../../../Utility/ObjectUtil";
import { camelCase } from "change-case";
import { SessionInfo } from "../../Session/IDocumentSession";

Expand Down
4 changes: 2 additions & 2 deletions src/Documents/DocumentStoreBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { IDocumentSession } from "./Session/IDocumentSession";
import { DocumentSession } from "./Session/DocumentSession";
import { DocumentConventions } from "./Conventions/DocumentConventions";
import { RequestExecutor } from "../Http/RequestExecutor";
import { IndexCreation } from "../Documents/Indexes/IndexCreation";
import { IndexCreation } from "./Indexes/IndexCreation";
import { PutIndexesOperation } from "./Operations/Indexes/PutIndexesOperation";
import { BulkInsertOperation, BulkInsertOptions } from "./BulkInsertOperation";
import { IDatabaseChanges } from "./Changes/IDatabaseChanges";
Expand Down Expand Up @@ -174,7 +174,7 @@ export abstract class DocumentStoreBase
if (!index) {
return null;
}

return index;
}

Expand Down
4 changes: 1 addition & 3 deletions src/Documents/Identity/HiloIdGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { IDocumentStore } from "../../Documents/IDocumentStore";
import { IDocumentStore } from "../IDocumentStore";
import { DateUtil } from "../../Utility/DateUtil";
import { StringUtil } from "../../Utility/StringUtil";
import { HiloReturnCommand } from "./Commands/HiloReturnCommand";
import { NextHiloCommand, HiLoResult } from "./Commands/NextHiloCommand";
import { HiloRangeValue } from "./HiloRangeValue";
import { DocumentConventions } from "../Conventions/DocumentConventions";
import { Lazy } from "../Lazy";
import { NextId } from "./NextId";

Expand Down
2 changes: 1 addition & 1 deletion src/Documents/Indexes/AutoIndexDefinition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IndexPriority, IndexState, IndexType } from "./Enums";
import { IndexType } from "./Enums";
import { AutoIndexFieldOptions } from "./AutoIndexFieldOptions";
import { IndexDefinitionBase } from "./IndexDefinitionBase";

Expand Down
4 changes: 2 additions & 2 deletions src/Documents/Indexes/IndexDefinition.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { throwError } from "../../Exceptions/index";
import { IndexPriority, IndexLockMode, IndexType, IndexState } from "./Enums";
import { throwError } from "../../Exceptions";
import { IndexLockMode, IndexType } from "./Enums";
import { IndexFieldOptions } from "./IndexFieldOptions";
import { DocumentConventions } from "../Conventions/DocumentConventions";
import { IndexDefinitionHelper } from "./IndexDefinitionHelper";
Expand Down
4 changes: 2 additions & 2 deletions src/Documents/Indexes/IndexDefinitionHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IndexType } from "./Enums";
import { throwError } from "../../Exceptions/index";
import { throwError } from "../../Exceptions";
import { StringUtil } from "../../Utility/StringUtil";
import * as XRegExp from "xregexp";
import { IndexSourceType } from "./IndexSourceType";
Expand Down Expand Up @@ -39,7 +39,7 @@ export class IndexDefinitionHelper {

/**
* Extract runtime enum notation
* @param provider
* @param functionBody
*/
public static extractEnumNotation(functionBody: string): string {
functionBody = functionBody.trim();
Expand Down
2 changes: 1 addition & 1 deletion src/Documents/Indexes/IndexTypeExtensions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IndexType } from "../Indexes/Enums";
import { IndexType } from "./Enums";

export class IndexTypeExtensions {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { AbstractGenericTimeSeriesIndexCreationTask } from "./AbstractGenericTim
import { TimeSeriesIndexDefinition } from "./TimeSeriesIndexDefinition";
import { TimeSeriesIndexDefinitionBuilder } from "./TimeSeriesIndexDefinitionBuilder";
import { DocumentConventions } from "../../Conventions/DocumentConventions";
import { AbstractTimeSeriesIndexCreationTask } from "./AbstractTimeSeriesIndexCreationTask";

export abstract class AbstractCsharpTimeSeriesIndexCreationTask extends AbstractGenericTimeSeriesIndexCreationTask {
public map: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IOperation, OperationResultType } from "../OperationAbstractions";
import { AttachmentDetails } from "./../../Attachments/index";
import { getEtagHeader } from "./../../../Utility/HttpUtil";
import { HttpRequestParameters, HttpResponse } from "./../../../Primitives/Http";
import { AttachmentDetails } from "../../Attachments";
import { getEtagHeader } from "../../../Utility/HttpUtil";
import { HttpRequestParameters, HttpResponse } from "../../../Primitives/Http";
import { AttachmentResult, AttachmentType } from "../../Attachments";
import { RavenCommand, ResponseDisposeHandling } from "../../../Http/RavenCommand";
import { HttpCache } from "../../../Http/HttpCache";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DocumentConventions } from "../../Conventions/DocumentConventions";
import { throwError } from "../../../Exceptions";
import { TypeUtil } from "../../../Utility/TypeUtil";
import { CompareExchangeResultClass, ServerCasing, ServerResponse } from "../../../Types";
import { COMPARE_EXCHANGE } from "../../../Constants";
import { DocumentType } from "../../DocumentAbstractions";
import { ObjectUtil } from "../../../Utility/ObjectUtil";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TypeUtil } from "../../../Utility/TypeUtil";
import { ObjectUtil } from "../../../Utility/ObjectUtil";
import { CONSTANTS } from "../../../Constants";
import { MetadataAsDictionary, MetadataDictionary } from "../../../Mapping/MetadataAsDictionary";
import { ClassConstructor, CompareExchangeResultClass, EntityConstructor } from "../../../Types";
import { CompareExchangeResultClass, EntityConstructor } from "../../../Types";

export interface CompareExchangeResultItem {
index: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { CompareExchangeValueResultParser, GetCompareExchangeValuesResponse } fr
import * as stream from "readable-stream";
import { StringBuilder } from "../../../Utility/StringBuilder";
import { TypeUtil } from "../../../Utility/TypeUtil";
import { QueryResult } from "../../Queries/QueryResult";

export interface GetCompareExchangeValuesParameters<T> {
keys?: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as stream from "readable-stream";
import { ServerNode } from "../../../Http/ServerNode";
import { RavenCommand } from "../../../Http/RavenCommand";
import { HttpRequestParameters } from "../../../Primitives/Http";
import { ClientConfiguration } from "../Configuration/ClientConfiguration";
import { ClientConfiguration } from "./ClientConfiguration";
import { DocumentConventions } from "../../Conventions/DocumentConventions";
import { IMaintenanceOperation, OperationResultType } from "../OperationAbstractions";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { DocumentConventions } from "../../Conventions/DocumentConventions";
import { OperationResultType, IMaintenanceOperation } from "../OperationAbstractions";
import { RavenCommand } from "../../../Http/RavenCommand";
import { ServerNode } from "../../../Http/ServerNode";
import { OlapEtlConfiguration } from "../Etl/Olap/OlapEtlConfiguration";

export interface GetConnectionStringsResult {
ravenConnectionStrings: Record<string, RavenConnectionString>;
Expand Down
4 changes: 2 additions & 2 deletions src/Documents/Operations/Counters/GetCountersOperation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IOperation, OperationResultType } from "../OperationAbstractions";
import { CountersDetail } from "../Counters/CountersDetail";
import { CountersDetail } from "./CountersDetail";
import { IDocumentStore } from "../../IDocumentStore";
import { DocumentConventions } from "../../Conventions/DocumentConventions";
import { HttpCache } from "../../../Http/HttpCache";
Expand Down Expand Up @@ -83,7 +83,7 @@ export class GetCounterValuesCommand extends RavenCommand<CountersDetail> {
.append(encodeURIComponent(this._counters[0]));
}
}

if (this._returnFullResults && req.method === "GET") {
// if we dropped to Post, _returnFullResults is part of the request content
pathBuilder.append("&full=true");
Expand Down
2 changes: 1 addition & 1 deletion src/Documents/Operations/DatabaseStatistics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IndexInformation } from "../../Documents/Operations/IndexInformation";
import { IndexInformation } from "./IndexInformation";
import { Size } from "../../Utility/SizeUtil";

export interface DatabaseStatistics {
Expand Down
Loading

0 comments on commit ce7b36c

Please sign in to comment.