mongodb-livedata-server 0.1.2 → 0.1.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.
Files changed (91) hide show
  1. package/dist/livedata_server.d.ts +4 -4
  2. package/dist/livedata_server.js +11 -11
  3. package/dist/meteor/binary-heap/max_heap.d.ts +31 -31
  4. package/dist/meteor/binary-heap/max_heap.js +186 -186
  5. package/dist/meteor/binary-heap/min_heap.d.ts +6 -6
  6. package/dist/meteor/binary-heap/min_heap.js +17 -17
  7. package/dist/meteor/binary-heap/min_max_heap.d.ts +11 -11
  8. package/dist/meteor/binary-heap/min_max_heap.js +48 -48
  9. package/dist/meteor/callback-hook/hook.d.ts +11 -11
  10. package/dist/meteor/callback-hook/hook.js +78 -78
  11. package/dist/meteor/ddp/crossbar.d.ts +15 -15
  12. package/dist/meteor/ddp/crossbar.js +136 -136
  13. package/dist/meteor/ddp/heartbeat.d.ts +19 -19
  14. package/dist/meteor/ddp/heartbeat.js +77 -77
  15. package/dist/meteor/ddp/livedata_server.d.ts +141 -142
  16. package/dist/meteor/ddp/livedata_server.js +403 -403
  17. package/dist/meteor/ddp/method-invocation.d.ts +35 -35
  18. package/dist/meteor/ddp/method-invocation.js +72 -72
  19. package/dist/meteor/ddp/random-stream.d.ts +8 -8
  20. package/dist/meteor/ddp/random-stream.js +100 -100
  21. package/dist/meteor/ddp/session-collection-view.d.ts +20 -20
  22. package/dist/meteor/ddp/session-collection-view.js +106 -106
  23. package/dist/meteor/ddp/session-document-view.d.ts +8 -8
  24. package/dist/meteor/ddp/session-document-view.js +82 -82
  25. package/dist/meteor/ddp/session.d.ts +75 -74
  26. package/dist/meteor/ddp/session.js +590 -589
  27. package/dist/meteor/ddp/stream_server.d.ts +20 -21
  28. package/dist/meteor/ddp/stream_server.js +181 -181
  29. package/dist/meteor/ddp/subscription.d.ts +94 -94
  30. package/dist/meteor/ddp/subscription.js +370 -370
  31. package/dist/meteor/ddp/utils.d.ts +8 -8
  32. package/dist/meteor/ddp/utils.js +104 -104
  33. package/dist/meteor/ddp/writefence.d.ts +20 -20
  34. package/dist/meteor/ddp/writefence.js +111 -111
  35. package/dist/meteor/diff-sequence/diff.d.ts +17 -17
  36. package/dist/meteor/diff-sequence/diff.js +257 -257
  37. package/dist/meteor/ejson/ejson.d.ts +82 -82
  38. package/dist/meteor/ejson/ejson.js +568 -569
  39. package/dist/meteor/ejson/stringify.d.ts +2 -2
  40. package/dist/meteor/ejson/stringify.js +119 -119
  41. package/dist/meteor/ejson/utils.d.ts +12 -12
  42. package/dist/meteor/ejson/utils.js +42 -42
  43. package/dist/meteor/mongo/caching_change_observer.d.ts +16 -16
  44. package/dist/meteor/mongo/caching_change_observer.js +63 -63
  45. package/dist/meteor/mongo/doc_fetcher.d.ts +7 -7
  46. package/dist/meteor/mongo/doc_fetcher.js +53 -53
  47. package/dist/meteor/mongo/geojson_utils.d.ts +3 -3
  48. package/dist/meteor/mongo/geojson_utils.js +40 -41
  49. package/dist/meteor/mongo/live_connection.d.ts +28 -28
  50. package/dist/meteor/mongo/live_connection.js +264 -264
  51. package/dist/meteor/mongo/live_cursor.d.ts +25 -25
  52. package/dist/meteor/mongo/live_cursor.js +60 -60
  53. package/dist/meteor/mongo/minimongo_common.d.ts +84 -84
  54. package/dist/meteor/mongo/minimongo_common.js +1998 -2002
  55. package/dist/meteor/mongo/minimongo_matcher.d.ts +23 -23
  56. package/dist/meteor/mongo/minimongo_matcher.js +283 -283
  57. package/dist/meteor/mongo/minimongo_sorter.d.ts +16 -16
  58. package/dist/meteor/mongo/minimongo_sorter.js +268 -268
  59. package/dist/meteor/mongo/observe_driver_utils.d.ts +9 -9
  60. package/dist/meteor/mongo/observe_driver_utils.js +72 -73
  61. package/dist/meteor/mongo/observe_multiplexer.d.ts +46 -46
  62. package/dist/meteor/mongo/observe_multiplexer.js +203 -203
  63. package/dist/meteor/mongo/oplog-observe-driver.d.ts +68 -68
  64. package/dist/meteor/mongo/oplog-observe-driver.js +918 -918
  65. package/dist/meteor/mongo/oplog_tailing.d.ts +35 -35
  66. package/dist/meteor/mongo/oplog_tailing.js +352 -352
  67. package/dist/meteor/mongo/oplog_v2_converter.d.ts +1 -1
  68. package/dist/meteor/mongo/oplog_v2_converter.js +125 -126
  69. package/dist/meteor/mongo/polling_observe_driver.d.ts +30 -30
  70. package/dist/meteor/mongo/polling_observe_driver.js +216 -221
  71. package/dist/meteor/mongo/synchronous-cursor.d.ts +17 -17
  72. package/dist/meteor/mongo/synchronous-cursor.js +261 -261
  73. package/dist/meteor/mongo/synchronous-queue.d.ts +13 -13
  74. package/dist/meteor/mongo/synchronous-queue.js +110 -110
  75. package/dist/meteor/ordered-dict/ordered_dict.d.ts +31 -31
  76. package/dist/meteor/ordered-dict/ordered_dict.js +198 -198
  77. package/dist/meteor/random/AbstractRandomGenerator.d.ts +42 -42
  78. package/dist/meteor/random/AbstractRandomGenerator.js +92 -92
  79. package/dist/meteor/random/AleaRandomGenerator.d.ts +13 -13
  80. package/dist/meteor/random/AleaRandomGenerator.js +90 -90
  81. package/dist/meteor/random/NodeRandomGenerator.d.ts +16 -16
  82. package/dist/meteor/random/NodeRandomGenerator.js +42 -42
  83. package/dist/meteor/random/createAleaGenerator.d.ts +2 -2
  84. package/dist/meteor/random/createAleaGenerator.js +32 -32
  85. package/dist/meteor/random/createRandom.d.ts +1 -1
  86. package/dist/meteor/random/createRandom.js +22 -22
  87. package/dist/meteor/random/main.d.ts +1 -1
  88. package/dist/meteor/random/main.js +12 -12
  89. package/dist/meteor/types.d.ts +1 -1
  90. package/dist/meteor/types.js +2 -2
  91. package/package.json +6 -5
@@ -1,106 +1,106 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SessionCollectionView = void 0;
4
- const diff_1 = require("../diff-sequence/diff");
5
- const ejson_1 = require("../ejson/ejson");
6
- const session_document_view_1 = require("./session-document-view");
7
- /**
8
- * Represents a client's view of a single collection
9
- * @param {String} collectionName Name of the collection it represents
10
- * @param {Object.<String, Function>} sessionCallbacks The callbacks for added, changed, removed
11
- * @class SessionCollectionView
12
- */
13
- class SessionCollectionView {
14
- constructor(collectionName, callbacks) {
15
- this.collectionName = collectionName;
16
- this.callbacks = callbacks;
17
- this.documents = new Map();
18
- }
19
- isEmpty() {
20
- return this.documents.size === 0;
21
- }
22
- diff(previous) {
23
- diff_1.DiffSequence.diffMaps(previous.documents, this.documents, {
24
- both: this.diffDocument.bind(this),
25
- rightOnly: (id, nowDV) => {
26
- this.callbacks.added(this.collectionName, id, nowDV.getFields());
27
- },
28
- leftOnly: (id, prevDV) => {
29
- this.callbacks.removed(this.collectionName, id);
30
- }
31
- });
32
- }
33
- diffDocument(id, prevDV, nowDV) {
34
- const fields = {};
35
- diff_1.DiffSequence.diffObjects(prevDV.getFields(), nowDV.getFields(), {
36
- both: (key, prev, now) => {
37
- if (!(0, ejson_1.equals)(prev, now))
38
- fields[key] = now;
39
- },
40
- rightOnly: (key, now) => {
41
- fields[key] = now;
42
- },
43
- leftOnly: (key, prev) => {
44
- fields[key] = undefined;
45
- }
46
- });
47
- this.callbacks.changed(this.collectionName, id, fields);
48
- }
49
- added(subscriptionHandle, id, fields) {
50
- var self = this;
51
- var docView = self.documents.get(id);
52
- var added = false;
53
- if (!docView) {
54
- added = true;
55
- docView = new session_document_view_1.SessionDocumentView();
56
- self.documents.set(id, docView);
57
- }
58
- docView.existsIn.add(subscriptionHandle);
59
- var changeCollector = {};
60
- for (const [key, value] of Object.entries(fields)) {
61
- docView.changeField(subscriptionHandle, key, value, changeCollector, true);
62
- }
63
- if (added)
64
- self.callbacks.added(self.collectionName, id, changeCollector);
65
- else
66
- self.callbacks.changed(self.collectionName, id, changeCollector);
67
- }
68
- changed(subscriptionHandle, id, changed) {
69
- var self = this;
70
- var changedResult = {};
71
- var docView = self.documents.get(id);
72
- if (!docView)
73
- throw new Error("Could not find element with id " + id + " to change");
74
- for (const [key, value] of Object.entries(changed)) {
75
- if (value === undefined)
76
- docView.clearField(subscriptionHandle, key, changedResult);
77
- else
78
- docView.changeField(subscriptionHandle, key, value, changedResult);
79
- }
80
- self.callbacks.changed(self.collectionName, id, changedResult);
81
- }
82
- removed(subscriptionHandle, id) {
83
- var self = this;
84
- var docView = self.documents.get(id);
85
- if (!docView) {
86
- var err = new Error("Removed nonexistent document " + id);
87
- throw err;
88
- }
89
- docView.existsIn.delete(subscriptionHandle);
90
- if (docView.existsIn.size === 0) {
91
- // it is gone from everyone
92
- self.callbacks.removed(self.collectionName, id);
93
- self.documents.delete(id);
94
- }
95
- else {
96
- var changed = {};
97
- // remove this subscription from every precedence list
98
- // and record the changes
99
- docView.dataByKey.forEach((precedenceList, key) => {
100
- docView.clearField(subscriptionHandle, key, changed);
101
- });
102
- self.callbacks.changed(self.collectionName, id, changed);
103
- }
104
- }
105
- }
106
- exports.SessionCollectionView = SessionCollectionView;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SessionCollectionView = void 0;
4
+ const diff_1 = require("../diff-sequence/diff");
5
+ const ejson_1 = require("../ejson/ejson");
6
+ const session_document_view_1 = require("./session-document-view");
7
+ /**
8
+ * Represents a client's view of a single collection
9
+ * @param {String} collectionName Name of the collection it represents
10
+ * @param {Object.<String, Function>} sessionCallbacks The callbacks for added, changed, removed
11
+ * @class SessionCollectionView
12
+ */
13
+ class SessionCollectionView {
14
+ constructor(collectionName, callbacks) {
15
+ this.collectionName = collectionName;
16
+ this.callbacks = callbacks;
17
+ this.documents = new Map();
18
+ }
19
+ isEmpty() {
20
+ return this.documents.size === 0;
21
+ }
22
+ diff(previous) {
23
+ diff_1.DiffSequence.diffMaps(previous.documents, this.documents, {
24
+ both: this.diffDocument.bind(this),
25
+ rightOnly: (id, nowDV) => {
26
+ this.callbacks.added(this.collectionName, id, nowDV.getFields());
27
+ },
28
+ leftOnly: (id, prevDV) => {
29
+ this.callbacks.removed(this.collectionName, id);
30
+ }
31
+ });
32
+ }
33
+ diffDocument(id, prevDV, nowDV) {
34
+ const fields = {};
35
+ diff_1.DiffSequence.diffObjects(prevDV.getFields(), nowDV.getFields(), {
36
+ both: (key, prev, now) => {
37
+ if (!(0, ejson_1.equals)(prev, now))
38
+ fields[key] = now;
39
+ },
40
+ rightOnly: (key, now) => {
41
+ fields[key] = now;
42
+ },
43
+ leftOnly: (key, prev) => {
44
+ fields[key] = undefined;
45
+ }
46
+ });
47
+ this.callbacks.changed(this.collectionName, id, fields);
48
+ }
49
+ added(subscriptionHandle, id, fields) {
50
+ var self = this;
51
+ var docView = self.documents.get(id);
52
+ var added = false;
53
+ if (!docView) {
54
+ added = true;
55
+ docView = new session_document_view_1.SessionDocumentView();
56
+ self.documents.set(id, docView);
57
+ }
58
+ docView.existsIn.add(subscriptionHandle);
59
+ var changeCollector = {};
60
+ for (const [key, value] of Object.entries(fields)) {
61
+ docView.changeField(subscriptionHandle, key, value, changeCollector, true);
62
+ }
63
+ if (added)
64
+ self.callbacks.added(self.collectionName, id, changeCollector);
65
+ else
66
+ self.callbacks.changed(self.collectionName, id, changeCollector);
67
+ }
68
+ changed(subscriptionHandle, id, changed) {
69
+ var self = this;
70
+ var changedResult = {};
71
+ var docView = self.documents.get(id);
72
+ if (!docView)
73
+ throw new Error("Could not find element with id " + id + " to change");
74
+ for (const [key, value] of Object.entries(changed)) {
75
+ if (value === undefined)
76
+ docView.clearField(subscriptionHandle, key, changedResult);
77
+ else
78
+ docView.changeField(subscriptionHandle, key, value, changedResult);
79
+ }
80
+ self.callbacks.changed(self.collectionName, id, changedResult);
81
+ }
82
+ removed(subscriptionHandle, id) {
83
+ var self = this;
84
+ var docView = self.documents.get(id);
85
+ if (!docView) {
86
+ var err = new Error("Removed nonexistent document " + id);
87
+ throw err;
88
+ }
89
+ docView.existsIn.delete(subscriptionHandle);
90
+ if (docView.existsIn.size === 0) {
91
+ // it is gone from everyone
92
+ self.callbacks.removed(self.collectionName, id);
93
+ self.documents.delete(id);
94
+ }
95
+ else {
96
+ var changed = {};
97
+ // remove this subscription from every precedence list
98
+ // and record the changes
99
+ docView.dataByKey.forEach((precedenceList, key) => {
100
+ docView.clearField(subscriptionHandle, key, changed);
101
+ });
102
+ self.callbacks.changed(self.collectionName, id, changed);
103
+ }
104
+ }
105
+ }
106
+ exports.SessionCollectionView = SessionCollectionView;
@@ -1,8 +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
- }
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
+ }
@@ -1,82 +1,82 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SessionDocumentView = void 0;
4
- const ejson_1 = require("../ejson/ejson");
5
- // Represents a single document in a SessionCollectionView
6
- class SessionDocumentView {
7
- constructor() {
8
- this.existsIn = new Set();
9
- this.dataByKey = new Map();
10
- }
11
- ;
12
- getFields() {
13
- var ret = {};
14
- this.dataByKey.forEach((precedenceList, key) => {
15
- ret[key] = precedenceList[0].value;
16
- });
17
- return ret;
18
- }
19
- clearField(subscriptionHandle, key, changeCollector) {
20
- // Publish API ignores _id if present in fields
21
- if (key === "_id")
22
- return;
23
- const precedenceList = this.dataByKey.get(key);
24
- // It's okay to clear fields that didn't exist. No need to throw
25
- // an error.
26
- if (!precedenceList)
27
- return;
28
- let removedValue = undefined;
29
- for (var i = 0; i < precedenceList.length; i++) {
30
- var precedence = precedenceList[i];
31
- if (precedence.subscriptionHandle === subscriptionHandle) {
32
- // The view's value can only change if this subscription is the one that
33
- // used to have precedence.
34
- if (i === 0)
35
- removedValue = precedence.value;
36
- precedenceList.splice(i, 1);
37
- break;
38
- }
39
- }
40
- if (precedenceList.length === 0) {
41
- this.dataByKey.delete(key);
42
- changeCollector[key] = undefined;
43
- }
44
- else if (removedValue !== undefined && !(0, ejson_1.equals)(removedValue, precedenceList[0].value)) {
45
- changeCollector[key] = precedenceList[0].value;
46
- }
47
- }
48
- changeField(subscriptionHandle, key, value, changeCollector, isAdd) {
49
- // Publish API ignores _id if present in fields
50
- if (key === "_id")
51
- return;
52
- // Don't share state with the data passed in by the user.
53
- value = (0, ejson_1.clone)(value);
54
- if (!this.dataByKey.has(key)) {
55
- this.dataByKey.set(key, [{
56
- subscriptionHandle: subscriptionHandle,
57
- value: value
58
- }]);
59
- changeCollector[key] = value;
60
- return;
61
- }
62
- const precedenceList = this.dataByKey.get(key);
63
- let elt;
64
- if (!isAdd) {
65
- elt = precedenceList.find(precedence => {
66
- return precedence.subscriptionHandle === subscriptionHandle;
67
- });
68
- }
69
- if (elt) {
70
- if (elt === precedenceList[0] && !(0, ejson_1.equals)(value, elt.value)) {
71
- // this subscription is changing the value of this field.
72
- changeCollector[key] = value;
73
- }
74
- elt.value = value;
75
- }
76
- else {
77
- // this subscription is newly caring about this field
78
- precedenceList.push({ subscriptionHandle: subscriptionHandle, value: value });
79
- }
80
- }
81
- }
82
- exports.SessionDocumentView = SessionDocumentView;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SessionDocumentView = void 0;
4
+ const ejson_1 = require("../ejson/ejson");
5
+ // Represents a single document in a SessionCollectionView
6
+ class SessionDocumentView {
7
+ constructor() {
8
+ this.existsIn = new Set();
9
+ this.dataByKey = new Map();
10
+ }
11
+ ;
12
+ getFields() {
13
+ var ret = {};
14
+ this.dataByKey.forEach((precedenceList, key) => {
15
+ ret[key] = precedenceList[0].value;
16
+ });
17
+ return ret;
18
+ }
19
+ clearField(subscriptionHandle, key, changeCollector) {
20
+ // Publish API ignores _id if present in fields
21
+ if (key === "_id")
22
+ return;
23
+ const precedenceList = this.dataByKey.get(key);
24
+ // It's okay to clear fields that didn't exist. No need to throw
25
+ // an error.
26
+ if (!precedenceList)
27
+ return;
28
+ let removedValue = undefined;
29
+ for (var i = 0; i < precedenceList.length; i++) {
30
+ var precedence = precedenceList[i];
31
+ if (precedence.subscriptionHandle === subscriptionHandle) {
32
+ // The view's value can only change if this subscription is the one that
33
+ // used to have precedence.
34
+ if (i === 0)
35
+ removedValue = precedence.value;
36
+ precedenceList.splice(i, 1);
37
+ break;
38
+ }
39
+ }
40
+ if (precedenceList.length === 0) {
41
+ this.dataByKey.delete(key);
42
+ changeCollector[key] = undefined;
43
+ }
44
+ else if (removedValue !== undefined && !(0, ejson_1.equals)(removedValue, precedenceList[0].value)) {
45
+ changeCollector[key] = precedenceList[0].value;
46
+ }
47
+ }
48
+ changeField(subscriptionHandle, key, value, changeCollector, isAdd) {
49
+ // Publish API ignores _id if present in fields
50
+ if (key === "_id")
51
+ return;
52
+ // Don't share state with the data passed in by the user.
53
+ value = (0, ejson_1.clone)(value);
54
+ if (!this.dataByKey.has(key)) {
55
+ this.dataByKey.set(key, [{
56
+ subscriptionHandle: subscriptionHandle,
57
+ value: value
58
+ }]);
59
+ changeCollector[key] = value;
60
+ return;
61
+ }
62
+ const precedenceList = this.dataByKey.get(key);
63
+ let elt;
64
+ if (!isAdd) {
65
+ elt = precedenceList.find(precedence => {
66
+ return precedence.subscriptionHandle === subscriptionHandle;
67
+ });
68
+ }
69
+ if (elt) {
70
+ if (elt === precedenceList[0] && !(0, ejson_1.equals)(value, elt.value)) {
71
+ // this subscription is changing the value of this field.
72
+ changeCollector[key] = value;
73
+ }
74
+ elt.value = value;
75
+ }
76
+ else {
77
+ // this subscription is newly caring about this field
78
+ precedenceList.push({ subscriptionHandle: subscriptionHandle, value: value });
79
+ }
80
+ }
81
+ }
82
+ exports.SessionDocumentView = SessionDocumentView;
@@ -1,74 +1,75 @@
1
- import DoubleEndedQueue from "double-ended-queue";
2
- import { StreamServerSocket } from "./stream_server";
3
- import { DDPServer } from "./livedata_server";
4
- import { SessionCollectionView } from "./session-collection-view";
5
- import { SubscriptionHandle } from "./subscription";
6
- import { OrderedDict } from "../ordered-dict/ordered_dict";
7
- export interface SessionConnectionHandle {
8
- id: string;
9
- close: Function;
10
- onClose: Function;
11
- clientAddress: any;
12
- httpHeaders: Record<string, any>;
13
- }
14
- interface DDPMessage {
15
- msg: string;
16
- id: string;
17
- version?: string;
18
- name?: string;
19
- method?: string;
20
- params?: any[];
21
- randomSeed?: any;
22
- }
23
- export declare class DDPSession {
24
- id: string;
25
- server: DDPServer;
26
- inQueue: DoubleEndedQueue<any>;
27
- userId: string | null;
28
- connectionHandle: SessionConnectionHandle;
29
- _dontStartNewUniversalSubs: boolean;
30
- _socketUrl: string;
31
- version: string;
32
- private socket;
33
- private initialized;
34
- private workerRunning;
35
- private _namedSubs;
36
- private _universalSubs;
37
- private collectionViews;
38
- private _isSending;
39
- private _pendingReady;
40
- private _closeCallbacks;
41
- private _respondToPings;
42
- private heartbeat;
43
- constructor(server: DDPServer, version: string, socket: StreamServerSocket, options: any);
44
- sendReady(subscriptionIds: string[]): void;
45
- _canSend(collectionName: any): boolean;
46
- sendInitialAdds(collectionName: string, docs: Map<string, any> | OrderedDict): void;
47
- sendAdded(collectionName: string, id: string, fields: Record<string, any>): void;
48
- sendChanged(collectionName: string, id: string, fields: Record<string, any>): void;
49
- sendRemoved(collectionName: string, id: string): void;
50
- getSendCallbacks(): {
51
- added: any;
52
- changed: any;
53
- removed: any;
54
- };
55
- getCollectionView(collectionName: string): SessionCollectionView;
56
- initialAdds(subscriptionHandle: SubscriptionHandle, collectionName: string, docs: Map<string, any> | OrderedDict): void;
57
- added(subscriptionHandle: SubscriptionHandle, collectionName: string, id: string, fields: Record<string, any>): void;
58
- removed(subscriptionHandle: SubscriptionHandle, collectionName: string, id: string): void;
59
- changed(subscriptionHandle: SubscriptionHandle, collectionName: string, id: string, fields: Record<string, any>): void;
60
- startUniversalSubs(): void;
61
- close(): void;
62
- send(msg: any): void;
63
- sendError(reason: any, offendingMessage: any): void;
64
- processMessage(msg_in: DDPMessage): Promise<void>;
65
- private protocol_handlers;
66
- _eachSub(f: any): void;
67
- _diffCollectionViews(beforeCVs: any): void;
68
- _setUserId(userId: any): void;
69
- _startSubscription(handler: any, subId?: any, params?: any, name?: any): Promise<void>;
70
- _stopSubscription(subId: any, error?: any): void;
71
- _deactivateAllSubscriptions(): void;
72
- _clientAddress(): string;
73
- }
74
- export {};
1
+ import DoubleEndedQueue from "double-ended-queue";
2
+ import { StreamServerSocket } from "./stream_server";
3
+ import { DDPServer } from "./livedata_server";
4
+ import { SessionCollectionView } from "./session-collection-view";
5
+ import { SubscriptionHandle } from "./subscription";
6
+ import { OrderedDict } from "../ordered-dict/ordered_dict";
7
+ export interface SessionConnectionHandle {
8
+ id: string;
9
+ close: Function;
10
+ onClose: Function;
11
+ clientAddress: string | null;
12
+ httpHeaders: Record<string, any>;
13
+ sockjsSessionId?: string;
14
+ }
15
+ interface DDPMessage {
16
+ msg: string;
17
+ id: string;
18
+ version?: string;
19
+ name?: string;
20
+ method?: string;
21
+ params?: any[];
22
+ randomSeed?: any;
23
+ }
24
+ export declare class DDPSession {
25
+ id: string;
26
+ server: DDPServer;
27
+ inQueue: DoubleEndedQueue<any>;
28
+ userId: string | null;
29
+ connectionHandle: SessionConnectionHandle;
30
+ _dontStartNewUniversalSubs: boolean;
31
+ _socketUrl: string;
32
+ version: string;
33
+ private socket;
34
+ private initialized;
35
+ private workerRunning;
36
+ private _namedSubs;
37
+ private _universalSubs;
38
+ private collectionViews;
39
+ private _isSending;
40
+ private _pendingReady;
41
+ private _closeCallbacks;
42
+ private _respondToPings;
43
+ private heartbeat;
44
+ constructor(server: DDPServer, version: string, socket: StreamServerSocket, options: any);
45
+ sendReady(subscriptionIds: string[]): void;
46
+ _canSend(collectionName: any): boolean;
47
+ sendInitialAdds(collectionName: string, docs: Map<string, any> | OrderedDict): void;
48
+ sendAdded(collectionName: string, id: string, fields: Record<string, any>): void;
49
+ sendChanged(collectionName: string, id: string, fields: Record<string, any>): void;
50
+ sendRemoved(collectionName: string, id: string): void;
51
+ getSendCallbacks(): {
52
+ added: any;
53
+ changed: any;
54
+ removed: any;
55
+ };
56
+ getCollectionView(collectionName: string): SessionCollectionView;
57
+ initialAdds(subscriptionHandle: SubscriptionHandle, collectionName: string, docs: Map<string, any> | OrderedDict): void;
58
+ added(subscriptionHandle: SubscriptionHandle, collectionName: string, id: string, fields: Record<string, any>): void;
59
+ removed(subscriptionHandle: SubscriptionHandle, collectionName: string, id: string): void;
60
+ changed(subscriptionHandle: SubscriptionHandle, collectionName: string, id: string, fields: Record<string, any>): void;
61
+ startUniversalSubs(): void;
62
+ close(): void;
63
+ send(msg: any): void;
64
+ sendError(reason: any, offendingMessage: any): void;
65
+ processMessage(msg_in: DDPMessage): Promise<void>;
66
+ private protocol_handlers;
67
+ _eachSub(f: any): void;
68
+ _diffCollectionViews(beforeCVs: any): void;
69
+ _setUserId(userId: any): void;
70
+ _startSubscription(handler: any, subId?: any, params?: any, name?: any): Promise<void>;
71
+ _stopSubscription(subId: any, error?: any): void;
72
+ _deactivateAllSubscriptions(): void;
73
+ _clientAddress(): string;
74
+ }
75
+ export {};