mongodb-livedata-server 0.1.0 → 0.1.1
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.
- package/README.md +5 -0
- package/dist/meteor/ddp/livedata_server.js +1 -1
- package/dist/meteor/ddp/session.d.ts +1 -1
- package/dist/meteor/ddp/session.js +6 -5
- package/dist/meteor/ddp/subscription.d.ts +1 -1
- package/dist/meteor/ddp/subscription.js +4 -1
- package/dist/meteor/ddp/utils.js +1 -1
- package/package.json +1 -1
- package/git-filter-repo.py +0 -4005
package/README.md
CHANGED
|
@@ -67,4 +67,9 @@ liveDataServer.publish({
|
|
|
67
67
|
const doc = await myCollection.findOne({ _id: id });
|
|
68
68
|
```
|
|
69
69
|
- Neither MongoDB.ObjectId nor it's Meteor.js alternative is supported at the moment. String ids only.
|
|
70
|
+
|
|
71
|
+
### DDP Extension
|
|
72
|
+
|
|
70
73
|
- Starting from 0.1.0, this library extends DDP with `init` message, which is used to avoid initial spam of `added` messages.
|
|
74
|
+
- Starting from 0.1.1, `init` message will only be sent if `version` `1a` of DDP protocol is specified. Additionally, when version `1a`
|
|
75
|
+
is specified, server will not send removes for all documents when stopping a subscription, and rely on the client for the cleanup instead.
|
|
@@ -107,7 +107,7 @@ class DDPServer {
|
|
|
107
107
|
*/
|
|
108
108
|
setPublicationStrategy(publicationName, strategy) {
|
|
109
109
|
if (!Object.values(DDPServer.publicationStrategies).includes(strategy)) {
|
|
110
|
-
throw new Error(`Invalid merge strategy: ${strategy}
|
|
110
|
+
throw new Error(`Invalid merge strategy: ${strategy}
|
|
111
111
|
for collection ${publicationName}`);
|
|
112
112
|
}
|
|
113
113
|
this._publicationStrategies[publicationName] = strategy;
|
|
@@ -522,15 +522,16 @@ class DDPSession {
|
|
|
522
522
|
}
|
|
523
523
|
// Tear down specified subscription
|
|
524
524
|
_stopSubscription(subId, error) {
|
|
525
|
-
var self = this;
|
|
526
525
|
var subName = null;
|
|
527
526
|
if (subId) {
|
|
528
|
-
var maybeSub =
|
|
527
|
+
var maybeSub = this._namedSubs.get(subId);
|
|
529
528
|
if (maybeSub) {
|
|
530
529
|
subName = maybeSub._name;
|
|
531
|
-
|
|
530
|
+
// version 1a doesn't send document deletions and relies on the clients for cleanup
|
|
531
|
+
if (this.version !== "1a")
|
|
532
|
+
maybeSub._removeAllDocuments();
|
|
532
533
|
maybeSub._deactivate();
|
|
533
|
-
|
|
534
|
+
this._namedSubs.delete(subId);
|
|
534
535
|
}
|
|
535
536
|
}
|
|
536
537
|
var response = { msg: 'nosub', id: subId, error: undefined };
|
|
@@ -538,7 +539,7 @@ class DDPSession {
|
|
|
538
539
|
response.error = (0, livedata_server_1.wrapInternalException)(error, subName ? ("from sub " + subName + " id " + subId)
|
|
539
540
|
: ("from sub id " + subId));
|
|
540
541
|
}
|
|
541
|
-
|
|
542
|
+
this.send(response);
|
|
542
543
|
}
|
|
543
544
|
// Tear down all subscriptions. Note that this does NOT send removed or nosub
|
|
544
545
|
// messages, since we assume the client is gone.
|
|
@@ -287,7 +287,10 @@ class Subscription {
|
|
|
287
287
|
}
|
|
288
288
|
documents.forEach((_doc, id) => ids.add(id));
|
|
289
289
|
}
|
|
290
|
-
this._session.
|
|
290
|
+
if (this._session.version === "1a")
|
|
291
|
+
this._session.initialAdds(this._subscriptionHandle, collectionName, documents);
|
|
292
|
+
else
|
|
293
|
+
documents.forEach((doc, id) => this._session.added(this._subscriptionHandle, collectionName, id, doc));
|
|
291
294
|
}
|
|
292
295
|
/**
|
|
293
296
|
* @summary Call inside the publish function. Informs the subscriber that a document has been added to the record set.
|
package/dist/meteor/ddp/utils.js
CHANGED
|
@@ -34,7 +34,7 @@ function last(array, n, guard) {
|
|
|
34
34
|
return exports.slice.call(array, Math.max(array.length - n, 0));
|
|
35
35
|
}
|
|
36
36
|
exports.last = last;
|
|
37
|
-
exports.SUPPORTED_DDP_VERSIONS = ['1', 'pre2', 'pre1'];
|
|
37
|
+
exports.SUPPORTED_DDP_VERSIONS = ['1a', '1', 'pre2', 'pre1'];
|
|
38
38
|
function parseDDP(stringMessage) {
|
|
39
39
|
try {
|
|
40
40
|
var msg = JSON.parse(stringMessage);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongodb-livedata-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
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",
|