mongodb-livedata-server 0.0.4 → 0.0.5

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.
Files changed (93) hide show
  1. package/dist/livedata_server.js +3 -1
  2. package/package.json +2 -2
  3. package/types/livedata_server.d.ts +4 -0
  4. package/types/meteor/binary-heap/max_heap.d.ts +31 -0
  5. package/types/meteor/binary-heap/min_heap.d.ts +6 -0
  6. package/types/meteor/binary-heap/min_max_heap.d.ts +11 -0
  7. package/types/meteor/callback-hook/hook.d.ts +11 -0
  8. package/types/meteor/ddp/crossbar.d.ts +15 -0
  9. package/types/meteor/ddp/heartbeat.d.ts +19 -0
  10. package/types/meteor/ddp/livedata_server.d.ts +141 -0
  11. package/types/meteor/ddp/method-invocation.d.ts +25 -0
  12. package/types/meteor/ddp/random-stream.d.ts +8 -0
  13. package/types/meteor/ddp/session-collection-view.d.ts +27 -0
  14. package/types/meteor/ddp/session-document-view.d.ts +8 -0
  15. package/types/meteor/ddp/session.d.ts +69 -0
  16. package/types/meteor/ddp/stream_server.d.ts +21 -0
  17. package/types/meteor/ddp/subscription.d.ts +89 -0
  18. package/types/meteor/ddp/utils.d.ts +8 -0
  19. package/types/meteor/ddp/writefence.d.ts +20 -0
  20. package/types/meteor/diff-sequence/diff.d.ts +13 -0
  21. package/types/meteor/ejson/ejson.d.ts +82 -0
  22. package/types/meteor/ejson/stringify.d.ts +2 -0
  23. package/types/meteor/ejson/utils.d.ts +12 -0
  24. package/types/meteor/id-map/id_map.d.ts +16 -0
  25. package/types/meteor/mongo/caching_change_observer.d.ts +16 -0
  26. package/types/meteor/mongo/doc_fetcher.d.ts +7 -0
  27. package/types/meteor/mongo/geojson_utils.d.ts +3 -0
  28. package/types/meteor/mongo/live_connection.d.ts +27 -0
  29. package/types/meteor/mongo/live_cursor.d.ts +25 -0
  30. package/types/meteor/mongo/minimongo_common.d.ts +84 -0
  31. package/types/meteor/mongo/minimongo_matcher.d.ts +22 -0
  32. package/types/meteor/mongo/minimongo_sorter.d.ts +16 -0
  33. package/types/meteor/mongo/observe_driver_utils.d.ts +9 -0
  34. package/types/meteor/mongo/observe_multiplexer.d.ts +36 -0
  35. package/types/meteor/mongo/oplog-observe-driver.d.ts +67 -0
  36. package/types/meteor/mongo/oplog_tailing.d.ts +35 -0
  37. package/types/meteor/mongo/oplog_v2_converter.d.ts +1 -0
  38. package/types/meteor/mongo/polling_observe_driver.d.ts +30 -0
  39. package/types/meteor/mongo/synchronous-cursor.d.ts +17 -0
  40. package/types/meteor/mongo/synchronous-queue.d.ts +14 -0
  41. package/types/meteor/ordered-dict/ordered_dict.d.ts +31 -0
  42. package/types/meteor/random/AbstractRandomGenerator.d.ts +42 -0
  43. package/types/meteor/random/AleaRandomGenerator.d.ts +13 -0
  44. package/types/meteor/random/NodeRandomGenerator.d.ts +16 -0
  45. package/types/meteor/random/createAleaGenerator.d.ts +2 -0
  46. package/types/meteor/random/createRandom.d.ts +1 -0
  47. package/types/meteor/random/main.d.ts +1 -0
  48. package/meteor/LICENSE +0 -28
  49. package/meteor/binary-heap/max_heap.ts +0 -225
  50. package/meteor/binary-heap/min_heap.ts +0 -15
  51. package/meteor/binary-heap/min_max_heap.ts +0 -53
  52. package/meteor/callback-hook/hook.ts +0 -85
  53. package/meteor/ddp/crossbar.ts +0 -148
  54. package/meteor/ddp/heartbeat.ts +0 -97
  55. package/meteor/ddp/livedata_server.ts +0 -474
  56. package/meteor/ddp/method-invocation.ts +0 -86
  57. package/meteor/ddp/random-stream.ts +0 -102
  58. package/meteor/ddp/session-collection-view.ts +0 -119
  59. package/meteor/ddp/session-document-view.ts +0 -92
  60. package/meteor/ddp/session.ts +0 -708
  61. package/meteor/ddp/stream_server.ts +0 -204
  62. package/meteor/ddp/subscription.ts +0 -392
  63. package/meteor/ddp/utils.ts +0 -119
  64. package/meteor/ddp/writefence.ts +0 -130
  65. package/meteor/diff-sequence/diff.ts +0 -295
  66. package/meteor/ejson/ejson.ts +0 -601
  67. package/meteor/ejson/stringify.ts +0 -122
  68. package/meteor/ejson/utils.ts +0 -38
  69. package/meteor/id-map/id_map.ts +0 -84
  70. package/meteor/mongo/caching_change_observer.ts +0 -120
  71. package/meteor/mongo/doc_fetcher.ts +0 -52
  72. package/meteor/mongo/geojson_utils.ts +0 -42
  73. package/meteor/mongo/live_connection.ts +0 -302
  74. package/meteor/mongo/live_cursor.ts +0 -79
  75. package/meteor/mongo/minimongo_common.ts +0 -2440
  76. package/meteor/mongo/minimongo_matcher.ts +0 -275
  77. package/meteor/mongo/minimongo_sorter.ts +0 -331
  78. package/meteor/mongo/observe_driver_utils.ts +0 -79
  79. package/meteor/mongo/observe_multiplexer.ts +0 -256
  80. package/meteor/mongo/oplog-observe-driver.ts +0 -1049
  81. package/meteor/mongo/oplog_tailing.ts +0 -414
  82. package/meteor/mongo/oplog_v2_converter.ts +0 -124
  83. package/meteor/mongo/polling_observe_driver.ts +0 -247
  84. package/meteor/mongo/synchronous-cursor.ts +0 -293
  85. package/meteor/mongo/synchronous-queue.ts +0 -119
  86. package/meteor/ordered-dict/ordered_dict.ts +0 -229
  87. package/meteor/random/AbstractRandomGenerator.ts +0 -99
  88. package/meteor/random/AleaRandomGenerator.ts +0 -96
  89. package/meteor/random/NodeRandomGenerator.ts +0 -37
  90. package/meteor/random/createAleaGenerator.ts +0 -31
  91. package/meteor/random/createRandom.ts +0 -19
  92. package/meteor/random/main.ts +0 -8
  93. package/tsconfig.json +0 -10
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LiveCursor = exports.LiveMongoConnection = exports.DDPServer = void 0;
3
+ exports.LiveCursor = exports.LiveMongoConnection = exports.ddpError = exports.DDPServer = void 0;
4
4
  var livedata_server_1 = require("./meteor/ddp/livedata_server");
5
5
  Object.defineProperty(exports, "DDPServer", { enumerable: true, get: function () { return livedata_server_1.DDPServer; } });
6
+ var livedata_server_2 = require("./meteor/ddp/livedata_server");
7
+ Object.defineProperty(exports, "ddpError", { enumerable: true, get: function () { return livedata_server_2.ddpError; } });
6
8
  var live_connection_1 = require("./meteor/mongo/live_connection");
7
9
  Object.defineProperty(exports, "LiveMongoConnection", { enumerable: true, get: function () { return live_connection_1.LiveMongoConnection; } });
8
10
  var live_cursor_1 = require("./meteor/mongo/live_cursor");
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "mongodb-livedata-server",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "MongoDB live data server, extracted from Meteor, Fibers removed and converted to TypeScript",
5
5
  "main": "dist/livedata_server.js",
6
- "types": "livedata_server.ts",
6
+ "types": "types/livedata_server.d.ts",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1"
9
9
  },
@@ -0,0 +1,4 @@
1
+ export { DDPServer } from "./meteor/ddp/livedata_server";
2
+ export { ddpError } from "./meteor/ddp/livedata_server";
3
+ export { LiveMongoConnection } from "./meteor/mongo/live_connection";
4
+ export { LiveCursor } from "./meteor/mongo/live_cursor";
@@ -0,0 +1,31 @@
1
+ export interface MaxHeapOptions {
2
+ initData?: {
3
+ id: string;
4
+ value: any;
5
+ }[];
6
+ IdMap?: any;
7
+ }
8
+ export declare class MaxHeap {
9
+ protected _comparator: (a: any, b: any) => number;
10
+ protected _heap: any[];
11
+ private _heapIdx;
12
+ constructor(comparator: (a: any, b: any) => number, options?: MaxHeapOptions);
13
+ _initFromData(data: any): void;
14
+ _downHeap(idx: any): void;
15
+ _upHeap(idx: any): void;
16
+ _maxIndex(idxA: any, idxB: any): any;
17
+ _get(idx: any): any;
18
+ _swap(idxA: any, idxB: any): void;
19
+ get(id: any): any;
20
+ set(id: any, value: any): void;
21
+ remove(id: any): void;
22
+ has(id: any): any;
23
+ empty(): boolean;
24
+ clear(): void;
25
+ forEach(iterator: any): void;
26
+ size(): number;
27
+ setDefault(id: any, def: any): any;
28
+ clone(): MaxHeap;
29
+ maxElementId(): any;
30
+ _selfCheck(): void;
31
+ }
@@ -0,0 +1,6 @@
1
+ import { MaxHeap, MaxHeapOptions } from './max_heap';
2
+ export declare class MinHeap extends MaxHeap {
3
+ constructor(comparator: any, options?: MaxHeapOptions);
4
+ maxElementId(): void;
5
+ minElementId(): any;
6
+ }
@@ -0,0 +1,11 @@
1
+ import { MaxHeap, MaxHeapOptions } from './max_heap';
2
+ export declare class MinMaxHeap extends MaxHeap {
3
+ private _minHeap;
4
+ constructor(comparator: any, options?: MaxHeapOptions);
5
+ set(id: string, value: any): void;
6
+ remove(id: string): void;
7
+ clear(): void;
8
+ setDefault(id: string, def: any): any;
9
+ clone(): MinMaxHeap;
10
+ minElementId(): any;
11
+ }
@@ -0,0 +1,11 @@
1
+ export declare class Hook {
2
+ private nextCallbackId;
3
+ private callbacks;
4
+ private exceptionHandler;
5
+ constructor(options?: any);
6
+ register(callback: any): {
7
+ callback: any;
8
+ stop: () => void;
9
+ };
10
+ each(iterator: (callback: Function) => boolean): void;
11
+ }
@@ -0,0 +1,15 @@
1
+ export declare class _Crossbar {
2
+ private listenersByCollection;
3
+ private listenersByCollectionCount;
4
+ private nextId;
5
+ constructor(options: any);
6
+ _collectionForMessage(msg: {
7
+ collection?: any;
8
+ }): string;
9
+ listen(trigger: any, callback: any): {
10
+ stop: () => void;
11
+ };
12
+ fire(notification: Record<string, any>): void;
13
+ _matches(notification: Record<string, any>, trigger: Record<string, any>): boolean;
14
+ }
15
+ export declare const _InvalidationCrossbar: _Crossbar;
@@ -0,0 +1,19 @@
1
+ export declare class Heartbeat {
2
+ private heartbeatInterval;
3
+ private heartbeatTimeout;
4
+ private _sendPing;
5
+ private _onTimeout;
6
+ private _seenPacket;
7
+ private _heartbeatIntervalHandle;
8
+ private _heartbeatTimeoutHandle;
9
+ constructor(options: any);
10
+ stop(): void;
11
+ start(): void;
12
+ _startHeartbeatIntervalTimer(): void;
13
+ _startHeartbeatTimeoutTimer(): void;
14
+ _clearHeartbeatIntervalTimer(): void;
15
+ _clearHeartbeatTimeoutTimer(): void;
16
+ _heartbeatIntervalFired(): void;
17
+ _heartbeatTimeoutFired(): void;
18
+ messageReceived(): void;
19
+ }
@@ -0,0 +1,141 @@
1
+ /// <reference types="node" />
2
+ import { MethodInvocation } from "./method-invocation";
3
+ import { StreamServerSocket } from "./stream_server";
4
+ import { DDPSession, SessionConnectionHandle } from "./session";
5
+ import { Server } from "http";
6
+ import { Subscription } from "./subscription";
7
+ export declare const DDP: {
8
+ _CurrentPublicationInvocation: Subscription;
9
+ _CurrentMethodInvocation: MethodInvocation;
10
+ };
11
+ /******************************************************************************/
12
+ /******************************************************************************/
13
+ interface PublicationStrategy {
14
+ useCollectionView: boolean;
15
+ doAccountingForCollection: boolean;
16
+ }
17
+ export declare class DDPServer {
18
+ private options;
19
+ private onConnectionHook;
20
+ private onMessageHook;
21
+ private publish_handlers;
22
+ private universal_publish_handlers;
23
+ private method_handlers;
24
+ private _publicationStrategies;
25
+ private sessions;
26
+ private stream_server;
27
+ constructor(options: {}, httpServer: Server);
28
+ static publicationStrategies: {
29
+ SERVER_MERGE: {
30
+ useCollectionView: boolean;
31
+ doAccountingForCollection: boolean;
32
+ };
33
+ NO_MERGE_NO_HISTORY: {
34
+ useCollectionView: boolean;
35
+ doAccountingForCollection: boolean;
36
+ };
37
+ NO_MERGE: {
38
+ useCollectionView: boolean;
39
+ doAccountingForCollection: boolean;
40
+ };
41
+ };
42
+ /**
43
+ * @summary Register a callback to be called when a new DDP connection is made to the server.
44
+ * @locus Server
45
+ * @param {function} callback The function to call when a new DDP connection is established.
46
+ * @memberOf Meteor
47
+ * @importFromPackage meteor
48
+ */
49
+ onConnection(fn: (conn: SessionConnectionHandle) => void): {
50
+ callback: any;
51
+ stop: () => void;
52
+ };
53
+ /**
54
+ * @summary Set publication strategy for the given publication. Publications strategies are available from `DDPServer.publicationStrategies`. You call this method from `Meteor.server`, like `Meteor.server.setPublicationStrategy()`
55
+ * @locus Server
56
+ * @alias setPublicationStrategy
57
+ * @param publicationName {String}
58
+ * @param strategy {{useCollectionView: boolean, doAccountingForCollection: boolean}}
59
+ * @memberOf Meteor.server
60
+ * @importFromPackage meteor
61
+ */
62
+ setPublicationStrategy(publicationName: string, strategy: PublicationStrategy): void;
63
+ /**
64
+ * @summary Gets the publication strategy for the requested publication. You call this method from `Meteor.server`, like `Meteor.server.getPublicationStrategy()`
65
+ * @locus Server
66
+ * @alias getPublicationStrategy
67
+ * @param publicationName {String}
68
+ * @memberOf Meteor.server
69
+ * @importFromPackage meteor
70
+ * @return {{useCollectionView: boolean, doAccountingForCollection: boolean}}
71
+ */
72
+ getPublicationStrategy(publicationName: string): PublicationStrategy;
73
+ /**
74
+ * @summary Register a callback to be called when a new DDP message is received.
75
+ * @locus Server
76
+ * @param {function} callback The function to call when a new DDP message is received.
77
+ * @memberOf Meteor
78
+ * @importFromPackage meteor
79
+ */
80
+ onMessage(fn: any): {
81
+ callback: any;
82
+ stop: () => void;
83
+ };
84
+ _handleConnect(socket: StreamServerSocket, msg: any): void;
85
+ /**
86
+ * Register a publish handler function.
87
+ *
88
+ * @param name {String} identifier for query
89
+ * @param handler {Function} publish handler
90
+ *
91
+ * Server will call handler function on each new subscription,
92
+ * either when receiving DDP sub message for a named subscription, or on
93
+ * DDP connect for a universal subscription.
94
+ *
95
+ * If name is null, this will be a subscription that is
96
+ * automatically established and permanently on for all connected
97
+ * client, instead of a subscription that can be turned on and off
98
+ * with subscribe().
99
+ *
100
+ */
101
+ /**
102
+ * @summary Publish a record set.
103
+ * @memberOf Meteor
104
+ * @importFromPackage meteor
105
+ * @locus Server
106
+ * @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.
107
+ * @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.
108
+ */
109
+ publish(name: string | Record<string, (this: MethodInvocation, ...args: any[]) => Promise<any>> | null, handler?: (this: MethodInvocation, ...args: any[]) => Promise<any>): void;
110
+ _removeSession(session: DDPSession): void;
111
+ /**
112
+ * @summary Defines functions that can be invoked over the network by clients.
113
+ * @locus Anywhere
114
+ * @param {Object} methods Dictionary whose keys are method names and values are functions.
115
+ * @memberOf Meteor
116
+ * @importFromPackage meteor
117
+ */
118
+ methods(methods: Record<string, (this: MethodInvocation, ...args: any[]) => Promise<any>>): void;
119
+ callAsync(name: string, ...args: any[]): Promise<unknown>;
120
+ applyAsync(name: string, args: any[]): Promise<unknown>;
121
+ _urlForSession(sessionId: any): string;
122
+ }
123
+ export declare function _calculateVersion(clientSupportedVersions: any, serverSupportedVersions: any): any;
124
+ export declare function wrapInternalException(exception: any, context: any): any;
125
+ export declare function maybeAuditArgumentChecks(f: Function, context: any, args: any[] | null, description: string): any;
126
+ export declare function ddpError(error: string | number, reason?: string, details?: string): {
127
+ isClientSafe: boolean;
128
+ error: string | number;
129
+ reason: string;
130
+ message: string;
131
+ errorType: string;
132
+ };
133
+ export declare class ClientSafeError extends Error {
134
+ error: string | number;
135
+ reason?: string;
136
+ details?: string;
137
+ constructor(error: string | number, reason?: string, details?: string);
138
+ isClientSafe: boolean;
139
+ errorType: string;
140
+ }
141
+ export {};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @summary The state for a single invocation of a method, referenced by this
3
+ * inside a method definition.
4
+ * @param {Object} options
5
+ * @instanceName this
6
+ * @showInstanceName true
7
+ */
8
+ export declare class MethodInvocation {
9
+ userId: string;
10
+ connection: any;
11
+ private isSimulation;
12
+ private _isFromCallAsync;
13
+ private _setUserId;
14
+ private randomSeed;
15
+ private randomStream;
16
+ constructor(options: any);
17
+ /**
18
+ * @summary Set the logged in user.
19
+ * @locus Server
20
+ * @memberOf DDPCommon.MethodInvocation
21
+ * @instance
22
+ * @param {String | null} userId The value that should be returned by `userId` on this connection.
23
+ */
24
+ setUserId(userId: string | null): void;
25
+ }
@@ -0,0 +1,8 @@
1
+ export declare class RandomStream {
2
+ private seed;
3
+ private sequences;
4
+ constructor(options: any);
5
+ _sequence(name: any): any;
6
+ static get(scope: any, name: any): any;
7
+ }
8
+ export declare function makeRpcSeed(enclosing: any, methodName: any): any;
@@ -0,0 +1,27 @@
1
+ import { SessionDocumentView } from "./session-document-view";
2
+ interface SubscriptionCallbacks {
3
+ added: (collectionName: string, id: string, fields: Record<string, any>) => void;
4
+ changed: (collectionName: string, id: string, fields: Record<string, any>) => void;
5
+ removed: (collectionName: string, id: string) => void;
6
+ }
7
+ interface SubscriptionHandle {
8
+ }
9
+ /**
10
+ * Represents a client's view of a single collection
11
+ * @param {String} collectionName Name of the collection it represents
12
+ * @param {Object.<String, Function>} sessionCallbacks The callbacks for added, changed, removed
13
+ * @class SessionCollectionView
14
+ */
15
+ export declare class SessionCollectionView {
16
+ private collectionName;
17
+ private callbacks;
18
+ private documents;
19
+ constructor(collectionName: string, callbacks: SubscriptionCallbacks);
20
+ isEmpty(): boolean;
21
+ diff(previous: SessionCollectionView): void;
22
+ diffDocument(id: string, prevDV: SessionDocumentView, nowDV: SessionDocumentView): void;
23
+ added(subscriptionHandle: SubscriptionHandle, id: string, fields: Record<string, any>): void;
24
+ changed(subscriptionHandle: SubscriptionHandle, id: string, changed: Record<string, any>): void;
25
+ removed(subscriptionHandle: any, id: string): void;
26
+ }
27
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare class SessionDocumentView {
2
+ existsIn: Set<any>;
3
+ private dataByKey;
4
+ constructor();
5
+ getFields(): Record<string, any>;
6
+ clearField(subscriptionHandle: any, key: string, changeCollector: Object): void;
7
+ changeField(subscriptionHandle: any, key: string, value: any, changeCollector: Object, isAdd: boolean): void;
8
+ }
@@ -0,0 +1,69 @@
1
+ import DoubleEndedQueue from "double-ended-queue";
2
+ import { StreamServerSocket } from "./stream_server";
3
+ import { DDPServer } from "./livedata_server";
4
+ export interface SessionConnectionHandle {
5
+ id: string;
6
+ close: Function;
7
+ onClose: Function;
8
+ clientAddress: any;
9
+ httpHeaders: Record<string, any>;
10
+ }
11
+ interface DDPMessage {
12
+ msg: string;
13
+ id: string;
14
+ version?: string;
15
+ name?: string;
16
+ method?: string;
17
+ params?: any[];
18
+ randomSeed?: any;
19
+ }
20
+ export declare class DDPSession {
21
+ id: string;
22
+ server: any;
23
+ inQueue: DoubleEndedQueue<any>;
24
+ userId: string | null;
25
+ connectionHandle: SessionConnectionHandle;
26
+ _dontStartNewUniversalSubs: boolean;
27
+ _socketUrl: string;
28
+ private version;
29
+ private socket;
30
+ private initialized;
31
+ private workerRunning;
32
+ private _namedSubs;
33
+ private _universalSubs;
34
+ private collectionViews;
35
+ private _isSending;
36
+ private _pendingReady;
37
+ private _closeCallbacks;
38
+ private _respondToPings;
39
+ private heartbeat;
40
+ constructor(server: DDPServer, version: string, socket: StreamServerSocket, options: any);
41
+ sendReady(subscriptionIds: any): void;
42
+ _canSend(collectionName: any): boolean;
43
+ sendAdded(collectionName: string, id: string, fields: Record<string, any>): void;
44
+ sendChanged(collectionName: string, id: string, fields: Record<string, any>): void;
45
+ sendRemoved(collectionName: string, id: string): void;
46
+ getSendCallbacks(): {
47
+ added: any;
48
+ changed: any;
49
+ removed: any;
50
+ };
51
+ getCollectionView(collectionName: any): any;
52
+ added(subscriptionHandle: any, collectionName: any, id: any, fields: any): void;
53
+ removed(subscriptionHandle: any, collectionName: any, id: any): void;
54
+ changed(subscriptionHandle: any, collectionName: any, id: any, fields: any): void;
55
+ startUniversalSubs(): void;
56
+ close(): void;
57
+ send(msg: any): void;
58
+ sendError(reason: any, offendingMessage: any): void;
59
+ processMessage(msg_in: DDPMessage): Promise<void>;
60
+ private protocol_handlers;
61
+ _eachSub(f: any): void;
62
+ _diffCollectionViews(beforeCVs: any): void;
63
+ _setUserId(userId: any): void;
64
+ _startSubscription(handler: any, subId?: any, params?: any, name?: any): void;
65
+ _stopSubscription(subId: any, error?: any): void;
66
+ _deactivateAllSubscriptions(): void;
67
+ _clientAddress(): string;
68
+ }
69
+ export {};
@@ -0,0 +1,21 @@
1
+ /// <reference types="node" />
2
+ import { Server } from "http";
3
+ import sockjs from "sockjs";
4
+ import { DDPSession } from "./session";
5
+ export interface StreamServerSocket extends sockjs.Connection {
6
+ setWebsocketTimeout: Function;
7
+ _session?: any;
8
+ _meteorSession?: DDPSession;
9
+ send: Function;
10
+ }
11
+ export declare class StreamServer {
12
+ private httpServer;
13
+ private registration_callbacks;
14
+ private open_sockets;
15
+ private prefix;
16
+ private server;
17
+ constructor(httpServer: Server);
18
+ register(callback: (socket: StreamServerSocket) => void): void;
19
+ all_sockets(): StreamServerSocket[];
20
+ _redirectWebsocketEndpoint(): void;
21
+ }
@@ -0,0 +1,89 @@
1
+ import { DDPSession, SessionConnectionHandle } from "./session";
2
+ /**
3
+ * @summary The server's side of a subscription
4
+ * @class Subscription
5
+ * @instanceName this
6
+ * @showInstanceName true
7
+ */
8
+ export declare class Subscription {
9
+ _session: DDPSession;
10
+ private _handler;
11
+ private _subscriptionId;
12
+ private _params;
13
+ private _name?;
14
+ connection: SessionConnectionHandle;
15
+ private _subscriptionHandle;
16
+ private _deactivated;
17
+ private _stopCallbacks;
18
+ private _documents;
19
+ private _ready;
20
+ userId: string | null;
21
+ private _idFilter;
22
+ constructor(_session: DDPSession, _handler: any, _subscriptionId: string, _params?: any[], _name?: string);
23
+ _runHandler(): void;
24
+ _publishHandlerResult(res: any): void;
25
+ _deactivate(): void;
26
+ _callStopCallbacks(): void;
27
+ _removeAllDocuments(): void;
28
+ _recreate(): Subscription;
29
+ /**
30
+ * @summary Call inside the publish function. Stops this client's subscription, triggering a call on the client to the `onStop` callback passed to [`Meteor.subscribe`](#meteor_subscribe), if any. If `error` is not a [`Meteor.Error`](#meteor_error), it will be [sanitized](#meteor_error).
31
+ * @locus Server
32
+ * @param {Error} error The error to pass to the client.
33
+ * @instance
34
+ * @memberOf Subscription
35
+ */
36
+ error(error: Error): void;
37
+ /**
38
+ * @summary Call inside the publish function. Stops this client's subscription and invokes the client's `onStop` callback with no error.
39
+ * @locus Server
40
+ * @instance
41
+ * @memberOf Subscription
42
+ */
43
+ stop(): void;
44
+ /**
45
+ * @summary Call inside the publish function. Registers a callback function to run when the subscription is stopped.
46
+ * @locus Server
47
+ * @memberOf Subscription
48
+ * @instance
49
+ * @param {Function} func The callback function
50
+ */
51
+ onStop(func: () => void): void;
52
+ _isDeactivated(): boolean;
53
+ /**
54
+ * @summary Call inside the publish function. Informs the subscriber that a document has been added to the record set.
55
+ * @locus Server
56
+ * @memberOf Subscription
57
+ * @instance
58
+ * @param {String} collection The name of the collection that contains the new document.
59
+ * @param {String} id The new document's ID.
60
+ * @param {Object} fields The fields in the new document. If `_id` is present it is ignored.
61
+ */
62
+ added(collectionName: string, id: string, fields: Record<string, any>): void;
63
+ /**
64
+ * @summary Call inside the publish function. Informs the subscriber that a document in the record set has been modified.
65
+ * @locus Server
66
+ * @memberOf Subscription
67
+ * @instance
68
+ * @param {String} collection The name of the collection that contains the changed document.
69
+ * @param {String} id The changed document's ID.
70
+ * @param {Object} fields The fields in the document that have changed, together with their new values. If a field is not present in `fields` it was left unchanged; if it is present in `fields` and has a value of `undefined` it was removed from the document. If `_id` is present it is ignored.
71
+ */
72
+ changed(collectionName: string, id: string, fields: Record<string, any>): void;
73
+ /**
74
+ * @summary Call inside the publish function. Informs the subscriber that a document has been removed from the record set.
75
+ * @locus Server
76
+ * @memberOf Subscription
77
+ * @instance
78
+ * @param {String} collection The name of the collection that the document has been removed from.
79
+ * @param {String} id The ID of the document that has been removed.
80
+ */
81
+ removed(collectionName: string, id: string): void;
82
+ /**
83
+ * @summary Call inside the publish function. Informs the subscriber that an initial, complete snapshot of the record set has been sent. This will trigger a call on the client to the `onReady` callback passed to [`Meteor.subscribe`](#meteor_subscribe), if any.
84
+ * @locus Server
85
+ * @memberOf Subscription
86
+ * @instance
87
+ */
88
+ ready(): void;
89
+ }
@@ -0,0 +1,8 @@
1
+ export declare const hasOwn: (v: PropertyKey) => boolean;
2
+ export declare const slice: (start?: number, end?: number) => any[];
3
+ export declare function keys(obj: any): string[];
4
+ export declare function isEmpty(obj: any): boolean;
5
+ export declare function last(array: any, n: any, guard: any): any;
6
+ export declare const SUPPORTED_DDP_VERSIONS: string[];
7
+ export declare function parseDDP(stringMessage: string): any;
8
+ export declare function stringifyDDP(msg: any): string;
@@ -0,0 +1,20 @@
1
+ import { OplogObserveDriver } from "../mongo/oplog-observe-driver";
2
+ export declare class _WriteFence {
3
+ fired: boolean;
4
+ _oplogObserveDrivers: Record<string, OplogObserveDriver>;
5
+ private armed;
6
+ private retired;
7
+ private outstanding_writes;
8
+ private before_fire_callbacks;
9
+ private completion_callbacks;
10
+ constructor();
11
+ static _CurrentWriteFence: _WriteFence;
12
+ beginWrite(): {
13
+ committed: () => void;
14
+ };
15
+ arm(): void;
16
+ onBeforeFire(func: any): void;
17
+ onAllCommitted(func: any): void;
18
+ _maybeFire(): void;
19
+ retire(): void;
20
+ }
@@ -0,0 +1,13 @@
1
+ import { IdMap } from "../id-map/id_map";
2
+ interface DiffSequence {
3
+ diffQueryChanges(ordered: boolean, oldResults: any[], newResults: any[], observer: any, options?: any): any;
4
+ diffQueryChanges(ordered: boolean, oldResults: IdMap, newResults: IdMap, observer: any, options?: any): any;
5
+ diffQueryUnorderedChanges(oldResults: any, newResults: any, observer: any, options?: any): any;
6
+ diffQueryOrderedChanges(old_results: any, new_results: any, observer: any, options?: any): any;
7
+ diffObjects(left: any, right: any, callbacks: any): any;
8
+ diffMaps(left: any, right: any, callbacks: any): any;
9
+ makeChangedFields(newDoc: any, oldDoc: any): any;
10
+ applyChanges(doc: any, changeFields: any): void;
11
+ }
12
+ export declare const DiffSequence: DiffSequence;
13
+ export {};
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @summary Add a custom datatype to EJSON.
3
+ * @locus Anywhere
4
+ * @param {String} name A tag for your custom type; must be unique among
5
+ * custom data types defined in your project, and must
6
+ * match the result of your type's `typeName` method.
7
+ * @param {Function} factory A function that deserializes a JSON-compatible
8
+ * value into an instance of your type. This should
9
+ * match the serialization performed by your
10
+ * type's `toJSONValue` method.
11
+ */
12
+ export declare function addType(name: any, factory: any): void;
13
+ export declare function _isCustomType(obj: any): boolean;
14
+ export declare function _getTypes(isOriginal?: boolean): unknown;
15
+ export declare function _getConverters(): any;
16
+ export declare function _adjustTypesToJSONValue(obj: any): any;
17
+ /**
18
+ * @summary Serialize an EJSON-compatible value into its plain JSON
19
+ * representation.
20
+ * @locus Anywhere
21
+ * @param {EJSON} val A value to serialize to plain JSON.
22
+ */
23
+ export declare function toJSONValue(item: any): any;
24
+ export declare function _adjustTypesFromJSONValue(obj: any): any;
25
+ /**
26
+ * @summary Deserialize an EJSON value from its plain JSON representation.
27
+ * @locus Anywhere
28
+ * @param {JSONCompatible} val A value to deserialize into EJSON.
29
+ */
30
+ export declare function fromJSONValue(item: any): any;
31
+ /**
32
+ * @summary Serialize a value to a string. For EJSON values, the serialization
33
+ * fully represents the value. For non-EJSON values, serializes the
34
+ * same way as `JSON.stringify`.
35
+ * @locus Anywhere
36
+ * @param {EJSON} val A value to stringify.
37
+ * @param {Object} [options]
38
+ * @param {Boolean | Integer | String} options.indent Indents objects and
39
+ * arrays for easy readability. When `true`, indents by 2 spaces; when an
40
+ * integer, indents by that number of spaces; and when a string, uses the
41
+ * string as the indentation pattern.
42
+ * @param {Boolean} options.canonical When `true`, stringifies keys in an
43
+ * object in sorted order.
44
+ */
45
+ export declare function stringify(val: any, opts?: {
46
+ canonical?: boolean;
47
+ indent?: boolean | number | string;
48
+ }): string;
49
+ /**
50
+ * @summary Parse a string into an EJSON value. Throws an error if the string
51
+ * is not valid EJSON.
52
+ * @locus Anywhere
53
+ * @param {String} str A string to parse into an EJSON value.
54
+ */
55
+ export declare function parse(item: any): any;
56
+ /**
57
+ * @summary Returns true if `x` is a buffer of binary data, as returned from
58
+ * [`EJSON.newBinary`](#ejson_new_binary).
59
+ * @param {Object} x The variable to check.
60
+ * @locus Anywhere
61
+ */
62
+ export declare function isBinary(obj: any): obj is Uint8Array;
63
+ /**
64
+ * @summary Return true if `a` and `b` are equal to each other. Return false
65
+ * otherwise. Uses the `equals` method on `a` if present, otherwise
66
+ * performs a deep comparison.
67
+ * @locus Anywhere
68
+ * @param {EJSON} a
69
+ * @param {EJSON} b
70
+ * @param {Object} [options]
71
+ * @param {Boolean} options.keyOrderSensitive Compare in key sensitive order,
72
+ * if supported by the JavaScript implementation. For example, `{a: 1, b: 2}`
73
+ * is equal to `{b: 2, a: 1}` only when `keyOrderSensitive` is `false`. The
74
+ * default is `false`.
75
+ */
76
+ export declare function equals(a: any, b: any, options?: any): any;
77
+ /**
78
+ * @summary Return a deep copy of `val`.
79
+ * @locus Anywhere
80
+ * @param {EJSON} val A value to copy.
81
+ */
82
+ export declare function clone<T>(v: T): T;
@@ -0,0 +1,2 @@
1
+ declare const canonicalStringify: (value: any, options: any) => string;
2
+ export default canonicalStringify;