mongodb-livedata-server 0.0.2 → 0.0.4

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.
@@ -1,3 +1,4 @@
1
1
  export { DDPServer } from "./meteor/ddp/livedata_server";
2
+ export { ddpError } from "./meteor/ddp/livedata_server";
2
3
  export { LiveMongoConnection } from "./meteor/mongo/live_connection";
3
- export { LiveCursor } from "./meteor/mongo/live_cursor";
4
+ export { LiveCursor } from "./meteor/mongo/live_cursor";
@@ -1,14 +1,15 @@
1
1
  import { MethodInvocation } from "./method-invocation";
2
2
  import { StreamServer, StreamServerSocket } from "./stream_server";
3
- import { DDPSession } from "./session";
3
+ import { DDPSession, SessionConnectionHandle } from "./session";
4
4
  import { Server } from "http";
5
5
  import { parseDDP, stringifyDDP, SUPPORTED_DDP_VERSIONS } from "./utils";
6
6
  import { makeRpcSeed } from "./random-stream";
7
7
  import { clone } from "../ejson/ejson";
8
8
  import { Hook } from "../callback-hook/hook";
9
+ import { Subscription } from "./subscription";
9
10
 
10
11
  export const DDP: {
11
- _CurrentPublicationInvocation: any,
12
+ _CurrentPublicationInvocation: Subscription,
12
13
  _CurrentMethodInvocation: MethodInvocation
13
14
  } = {} as any;
14
15
 
@@ -171,7 +172,7 @@ export class DDPServer {
171
172
  * @memberOf Meteor
172
173
  * @importFromPackage meteor
173
174
  */
174
- onConnection(fn) {
175
+ onConnection(fn: (conn: SessionConnectionHandle) => void) {
175
176
  var self = this;
176
177
  return self.onConnectionHook.register(fn);
177
178
  }
@@ -289,7 +290,7 @@ export class DDPServer {
289
290
  * @param {String|Object} name If String, name of the record set. If Object, publications Dictionary of publish functions by name. If `null`, the set has no name, and the record set is automatically sent to all connected clients.
290
291
  * @param {Function} func Function called on the server each time a client subscribes. Inside the function, `this` is the publish handler object, described below. If the client passed arguments to `subscribe`, the function is called with the same arguments.
291
292
  */
292
- publish(name: string | Record<string, Function> | null, handler: Function) {
293
+ publish(name: string | Record<string, (this: MethodInvocation, ...args: any[]) => Promise<any>> | null, handler?: (this: MethodInvocation, ...args: any[]) => Promise<any>) {
293
294
  var self = this;
294
295
 
295
296
  if (typeof name === "string") {
@@ -328,7 +329,7 @@ export class DDPServer {
328
329
  * @memberOf Meteor
329
330
  * @importFromPackage meteor
330
331
  */
331
- methods(methods: Record<string, Function>) {
332
+ methods(methods: Record<string, (this: MethodInvocation, ...args: any[]) => Promise<any>>) {
332
333
  var self = this;
333
334
  for (const [name, func] of Object.entries(methods)) {
334
335
  if (typeof func !== 'function')
@@ -49,7 +49,7 @@ export class Subscription {
49
49
  }
50
50
 
51
51
  constructor (
52
- private _session: DDPSession,
52
+ public _session: DDPSession,
53
53
  private _handler: any,
54
54
  private _subscriptionId: string,
55
55
  private _params: any[] = [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb-livedata-server",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
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": "livedata_server.ts",
@@ -11,17 +11,14 @@
11
11
  "author": "Andrei Markeev",
12
12
  "license": "MIT",
13
13
  "dependencies": {
14
+ "@types/node": "^18.11.9",
15
+ "@types/sockjs": "^0.3.33",
16
+ "@types/double-ended-queue": "^2.1.1",
14
17
  "double-ended-queue": "^2.1.0-0",
15
18
  "mongodb": "^4.11.0",
16
19
  "permessage-deflate": "^0.1.7",
17
20
  "sockjs": "^0.3.24"
18
21
  },
19
- "devDependencies": {
20
- "@types/connect": "^3.4.35",
21
- "@types/double-ended-queue": "^2.1.1",
22
- "@types/node": "^18.11.9",
23
- "@types/sockjs": "^0.3.33"
24
- },
25
22
  "repository": {
26
23
  "type": "git",
27
24
  "url": "git://github.com/andrei-markeev/mongodb-livedata-server.git"