Skip to content

Commit 8b54926

Browse files
committed
sync d393d1c9c8eaaeaa1e4ad6764d5260561c876e8c .. be9b7f88aa409ee0915d80a0cf7e87f30ba4f219 - fixes
1 parent 1ea7a95 commit 8b54926

File tree

104 files changed

+915
-764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+915
-764
lines changed

package-lock.json

Lines changed: 141 additions & 141 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Documents/BulkInsertOperation.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,15 @@ export class BulkInsertOperation {
146146
return false;
147147
}
148148

149-
public on(event: "progress", handler: (value: BulkInsertOnProgressEventArgs) => void) {
149+
public on(event: "progress", handler: (value: BulkInsertOnProgressEventArgs) => void): this {
150150
this._emitter.on("progress", handler);
151+
this._onProgressInitialized = true;
152+
return this;
151153
}
152154

153-
public off(event: "progress", handler: (value: BulkInsertOnProgressEventArgs) => void) {
155+
public off(event: "progress", handler: (value: BulkInsertOnProgressEventArgs) => void): this {
154156
this._emitter.off("progress", handler);
157+
return this;
155158
}
156159

157160
get useCompression(): boolean {
@@ -191,6 +194,26 @@ export class BulkInsertOperation {
191194
await this._requestExecutor.execute(bulkInsertGetIdRequest);
192195
this._operationId = bulkInsertGetIdRequest.result;
193196
this._nodeTag = bulkInsertGetIdRequest.nodeTag;
197+
198+
if (this._onProgressInitialized && !this._unsubscribeChanges) {
199+
const observable = this._store.changes()
200+
.forOperationId(this._operationId);
201+
202+
const handler = value => {
203+
const state = value.state;
204+
if (state && state.status === "InProgress") {
205+
this._emitter.emit("progress", new BulkInsertOnProgressEventArgs(state.progress));
206+
}
207+
}
208+
209+
observable.on("data", handler);
210+
211+
this._unsubscribeChanges = {
212+
dispose(): void {
213+
observable.off("data", handler)
214+
}
215+
};
216+
}
194217
}
195218

196219
private static _typeCheckStoreArgs(

src/Documents/Changes/AggressiveCacheChange.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DatabaseChange } from "./DatabaseChange";
2-
import { DocumentChange, DocumentChangeTypes } from "./DocumentChange";
2+
import { DocumentChange } from "./DocumentChange";
33
import { IndexChange } from "./IndexChange";
44

55
export class AggressiveCacheChange implements DatabaseChange {

src/Documents/Changes/ChangesObservable.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ export class ChangesObservable<T, TConnectionState extends IChangesConnectionSta
1919
this._filter = filter;
2020
}
2121

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

52-
public removeListener(event: "data", handler: (value: T) => void);
53-
public removeListener(event: "error", handler: (error: Error) => void);
54-
public removeListener(event: "data" | "error", handler: ((value: T) => void) | ((error: Error) => void)) {
52+
public removeListener(event: "data", handler: (value: T) => void): this;
53+
public removeListener(event: "error", handler: (error: Error) => void): this;
54+
public removeListener(event: "data" | "error", handler: ((value: T) => void) | ((error: Error) => void)): this {
5555
return this.off(event as any, handler as any);
5656
}
5757

58-
public off(event: "data", handler: (value: T) => void);
59-
public off(event: "error", handler: (error: Error) => void);
60-
public off(event: "data" | "error", handler: ((value: T) => void) | ((error: Error) => void)) {
58+
public off(event: "data", handler: (value: T) => void): this;
59+
public off(event: "error", handler: (error: Error) => void): this;
60+
public off(event: "data" | "error", handler: ((value: T) => void) | ((error: Error) => void)): this {
6161

6262
switch (event) {
6363
case "data":

src/Documents/Changes/DatabaseChanges.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,18 @@ export class DatabaseChanges implements IDatabaseChanges {
100100
return this._client && this._client.readyState === WebSocket.OPEN;
101101
}
102102

103-
public on(eventName: "connectionStatus", handler: () => void);
104-
public on(eventName: "error", handler: (error: Error) => void);
105-
public on(eventName: "connectionStatus" | "error", handler) {
103+
public on(eventName: "connectionStatus", handler: () => void): this;
104+
public on(eventName: "error", handler: (error: Error) => void): this;
105+
public on(eventName: "connectionStatus" | "error", handler): this {
106106
this._emitter.addListener(eventName, handler);
107+
return this;
107108
}
108109

109-
public off(eventName: "connectionStatus", handler: () => void);
110-
public off(eventName: "error", handler: (error: Error) => void);
111-
public off(eventName: "connectionStatus" | "error", handler) {
110+
public off(eventName: "connectionStatus", handler: () => void): this;
111+
public off(eventName: "error", handler: (error: Error) => void): this;
112+
public off(eventName: "connectionStatus" | "error", handler): this {
112113
this._emitter.removeListener(eventName, handler);
114+
return this;
113115
}
114116

115117
public ensureConnectedNow(): Promise<IDatabaseChanges> {

src/Documents/Changes/IChangesObservable.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ export interface IChangesObservable<T> extends IObservable<T> {
33
}
44

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

8-
on(event: "error", handler: (error: Error) => void);
8+
on(event: "error", handler: (error: Error) => void): this;
99

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

12-
off(event: "error", handler: (error: Error) => void);
12+
off(event: "error", handler: (error: Error) => void): this;
1313

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

16-
removeListener(event: "error", handler: (error: Error) => void);
16+
removeListener(event: "error", handler: (error: Error) => void): this;
1717
}

src/Documents/Commands/Batches/ForceRevisionCommandData.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommandType, ICommandData } from "../CommandData";
2-
import { throwError } from "../../../Exceptions/index";
2+
import { throwError } from "../../../Exceptions";
33
import { DocumentConventions } from "../../Conventions/DocumentConventions";
44

55
export class ForceRevisionCommandData implements ICommandData {
@@ -22,4 +22,4 @@ export class ForceRevisionCommandData implements ICommandData {
2222
Type: this.type
2323
}
2424
}
25-
}
25+
}

src/Documents/Commands/Batches/PutAttachmentCommandData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ICommandData, CommandType } from "../CommandData";
2-
import { AttachmentData } from "./../../Attachments/index";
2+
import { AttachmentData } from "../../Attachments";
33
import { StringUtil } from "../../../Utility/StringUtil";
44
import { throwError } from "../../../Exceptions";
55
import { DocumentConventions } from "../../Conventions/DocumentConventions";

src/Documents/Commands/Batches/SingleNodeBatchCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { BatchCommandResult } from "../../Session/Operations/BatchCommandResult"
33
import { IDisposable } from "../../../Types/Contracts";
44
import { DocumentConventions } from "../../Conventions/DocumentConventions";
55
import { ICommandData } from "../CommandData";
6-
import { AttachmentData } from "../../Attachments/index";
6+
import { AttachmentData } from "../../Attachments";
77
import { BatchOptions } from "./BatchOptions";
88
import { TransactionMode } from "../../Session/TransactionMode";
9-
import { throwError } from "../../../Exceptions/index";
9+
import { throwError } from "../../../Exceptions";
1010
import { PutAttachmentCommandData } from "./PutAttachmentCommandData";
1111
import { HttpRequestParameters } from "../../../Primitives/Http";
1212
import { HeadersBuilder } from "../../../Utility/HttpUtil";

src/Documents/Commands/Batches/TimeSeriesBatchCommandData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommandType } from "../CommandData";
2-
import { AppendOperation, DeleteOperation, TimeSeriesOperation } from "../../Operations/TimeSeries/TimeSeriesOperation";
2+
import { AppendOperation, DeleteOperation } from "../../Operations/TimeSeries/TimeSeriesOperation";
33
import { TimeSeriesCommandData } from "./TimeSeriesCommandData";
44

55
export class TimeSeriesBatchCommandData extends TimeSeriesCommandData {

0 commit comments

Comments
 (0)