mongodb-livedata-server 0.0.6 → 0.0.8

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.
@@ -121,7 +121,7 @@ export declare class DDPServer {
121
121
  _urlForSession(sessionId: any): string;
122
122
  }
123
123
  export declare function _calculateVersion(clientSupportedVersions: any, serverSupportedVersions: any): any;
124
- export declare function wrapInternalException(exception: any, context: any): any;
124
+ export declare function wrapInternalException(exception: any, context: string): any;
125
125
  export declare function maybeAuditArgumentChecks(f: Function, context: any, args: any[] | null, description: string): any;
126
126
  export declare function ddpError(error: string | number, reason?: string, details?: string): {
127
127
  isClientSafe: boolean;
@@ -1,3 +1,12 @@
1
+ import { SessionConnectionHandle } from "./session";
2
+ interface MethodInvocationOptions {
3
+ isSimulation: boolean;
4
+ isFromCallAsync?: boolean;
5
+ userId: string;
6
+ setUserId: (userId: string) => void;
7
+ connection: SessionConnectionHandle;
8
+ randomSeed: number;
9
+ }
1
10
  /**
2
11
  * @summary The state for a single invocation of a method, referenced by this
3
12
  * inside a method definition.
@@ -7,13 +16,13 @@
7
16
  */
8
17
  export declare class MethodInvocation {
9
18
  userId: string;
10
- connection: any;
19
+ connection: SessionConnectionHandle;
11
20
  private isSimulation;
12
21
  private _isFromCallAsync;
13
22
  private _setUserId;
14
23
  private randomSeed;
15
24
  private randomStream;
16
- constructor(options: any);
25
+ constructor(options: MethodInvocationOptions);
17
26
  /**
18
27
  * @summary Set the logged in user.
19
28
  * @locus Server
@@ -23,3 +32,4 @@ export declare class MethodInvocation {
23
32
  */
24
33
  setUserId(userId: string | null): void;
25
34
  }
35
+ export {};
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MethodInvocation = void 0;
4
2
  // Instance name is this because it is usually referred to as this inside a
5
3
  // method definition
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.MethodInvocation = void 0;
6
6
  /**
7
7
  * @summary The state for a single invocation of a method, referenced by this
8
8
  * inside a method definition.
@@ -6,7 +6,7 @@ export interface SessionConnectionHandle {
6
6
  close: Function;
7
7
  onClose: Function;
8
8
  clientAddress: any;
9
- httpHeaders: Record<string, any>;
9
+ httpHeaders: Record<string, string>;
10
10
  }
11
11
  interface DDPMessage {
12
12
  msg: string;
@@ -139,6 +139,7 @@ class DDPSession {
139
139
  self.send(payload);
140
140
  }, (exception) => {
141
141
  finish();
142
+ console.error(`Exception while invoking method '${msg.method}'`, exception);
142
143
  payload.error = (0, livedata_server_1.wrapInternalException)(exception, `while invoking method '${msg.method}'`);
143
144
  self.send(payload);
144
145
  });
@@ -1,4 +1,4 @@
1
- import MongoDB from "mongodb";
1
+ import * as MongoDB from "mongodb";
2
2
  export declare class DocFetcher {
3
3
  private db;
4
4
  private _callbacksForOp;
@@ -1,7 +1,7 @@
1
1
  import { Subscription } from "../ddp/subscription";
2
- import MongoDB, { WithId } from "mongodb";
2
+ import * as MongoDB from "mongodb";
3
3
  import { LiveMongoConnection } from "./live_connection";
4
- interface CustomFindOptions<T> extends MongoDB.FindOptions<WithId<T>> {
4
+ interface CustomFindOptions<T> extends MongoDB.FindOptions<MongoDB.WithId<T>> {
5
5
  pollingThrottleMs?: number;
6
6
  pollingIntervalMs?: number;
7
7
  transform?: (doc: T) => T;
@@ -10,14 +10,14 @@ interface CustomFindOptions<T> extends MongoDB.FindOptions<WithId<T>> {
10
10
  }
11
11
  export declare class CursorDescription<T> {
12
12
  collectionName: string;
13
- selector: MongoDB.Filter<WithId<T>>;
14
- options: CustomFindOptions<WithId<T>>;
15
- constructor(collectionName: string, selector: MongoDB.Filter<WithId<T>>, options?: CustomFindOptions<WithId<T>>);
13
+ selector: MongoDB.Filter<MongoDB.WithId<T>>;
14
+ options: CustomFindOptions<MongoDB.WithId<T>>;
15
+ constructor(collectionName: string, selector: MongoDB.Filter<MongoDB.WithId<T>>, options?: CustomFindOptions<MongoDB.WithId<T>>);
16
16
  }
17
17
  export declare class LiveCursor<T> {
18
18
  mongo: LiveMongoConnection;
19
19
  cursorDescription: CursorDescription<T>;
20
- constructor(mongo: LiveMongoConnection, collectionName: string, selector: MongoDB.Filter<WithId<T>>, options: CustomFindOptions<WithId<T>>);
20
+ constructor(mongo: LiveMongoConnection, collectionName: string, selector: MongoDB.Filter<MongoDB.WithId<T>>, options: CustomFindOptions<MongoDB.WithId<T>>);
21
21
  _publishCursor(sub: Subscription): {
22
22
  stop: () => void;
23
23
  };
@@ -1,4 +1,4 @@
1
- import MongoDB from "mongodb";
1
+ import * as MongoDB from "mongodb";
2
2
  import { CursorDescription } from "./live_cursor";
3
3
  export declare function listenAll(cursorDescription: CursorDescription<any>, listenCallback: Function): {
4
4
  stop: () => void;
@@ -107,8 +107,8 @@ class OplogObserveDriver {
107
107
  self._stopHandles.push(self._mongoHandle._oplogHandle.onSkippedEntries(finishIfNeedToPollQuery(function () {
108
108
  self._needToPollQuery();
109
109
  })));
110
- (0, observe_driver_utils_1.forEachTrigger)(self._cursorDescription, function (trigger) {
111
- self._stopHandles.push(/*async*/ self._mongoHandle._oplogHandle.onOplogEntry(trigger, function (notification) {
110
+ (0, observe_driver_utils_1.forEachTrigger)(self._cursorDescription, async (trigger) => {
111
+ self._stopHandles.push(await self._mongoHandle._oplogHandle.onOplogEntry(trigger, function (notification) {
112
112
  //Meteor._noYieldsAllowed(finishIfNeedToPollQuery(function () {
113
113
  var op = notification.op;
114
114
  if (notification.dropCollection || notification.dropDatabase) {
@@ -330,7 +330,7 @@ class OplogHandle {
330
330
  self._lastProcessedTS = ts;
331
331
  while (self._catchingUpFutures.length > 0 && self._catchingUpFutures[0].ts.lessThanOrEqual(self._lastProcessedTS)) {
332
332
  var sequencer = self._catchingUpFutures.shift();
333
- sequencer.future.return();
333
+ sequencer.future.resolve();
334
334
  }
335
335
  }
336
336
  //Methods used on tests to dinamically change TOO_FAR_BEHIND
@@ -1,4 +1,4 @@
1
- import MongoDB from "mongodb";
1
+ import * as MongoDB from "mongodb";
2
2
  import { CursorDescription } from "./live_cursor";
3
3
  export declare function _createSynchronousCursor(db: MongoDB.Db, cursorDescription: CursorDescription<any>, options?: any): SynchronousCursor;
4
4
  export declare class SynchronousCursor {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb-livedata-server",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "MongoDB live data server, extracted from Meteor, Fibers removed and converted to TypeScript",
5
5
  "main": "dist/livedata_server.js",
6
6
  "types": "dist/livedata_server.d.ts",