mongodb-livedata-server 0.1.3 → 0.1.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.
- package/README.md +2 -2
- package/dist/livedata_server.d.ts +4 -4
- package/dist/livedata_server.js +11 -11
- package/dist/meteor/binary-heap/max_heap.d.ts +31 -31
- package/dist/meteor/binary-heap/max_heap.js +186 -186
- package/dist/meteor/binary-heap/min_heap.d.ts +6 -6
- package/dist/meteor/binary-heap/min_heap.js +17 -17
- package/dist/meteor/binary-heap/min_max_heap.d.ts +11 -11
- package/dist/meteor/binary-heap/min_max_heap.js +48 -48
- package/dist/meteor/callback-hook/hook.d.ts +11 -11
- package/dist/meteor/callback-hook/hook.js +78 -78
- package/dist/meteor/ddp/crossbar.d.ts +15 -15
- package/dist/meteor/ddp/crossbar.js +136 -136
- package/dist/meteor/ddp/heartbeat.d.ts +19 -19
- package/dist/meteor/ddp/heartbeat.js +77 -77
- package/dist/meteor/ddp/livedata_server.d.ts +141 -142
- package/dist/meteor/ddp/livedata_server.js +403 -403
- package/dist/meteor/ddp/method-invocation.d.ts +35 -35
- package/dist/meteor/ddp/method-invocation.js +72 -72
- package/dist/meteor/ddp/random-stream.d.ts +8 -8
- package/dist/meteor/ddp/random-stream.js +100 -100
- package/dist/meteor/ddp/session-collection-view.d.ts +20 -20
- package/dist/meteor/ddp/session-collection-view.js +106 -106
- package/dist/meteor/ddp/session-document-view.d.ts +8 -8
- package/dist/meteor/ddp/session-document-view.js +82 -82
- package/dist/meteor/ddp/session.d.ts +75 -75
- package/dist/meteor/ddp/session.js +590 -590
- package/dist/meteor/ddp/stream_server.d.ts +20 -21
- package/dist/meteor/ddp/stream_server.js +181 -181
- package/dist/meteor/ddp/subscription.d.ts +94 -94
- package/dist/meteor/ddp/subscription.js +370 -370
- package/dist/meteor/ddp/utils.d.ts +8 -8
- package/dist/meteor/ddp/utils.js +104 -104
- package/dist/meteor/ddp/writefence.d.ts +20 -20
- package/dist/meteor/ddp/writefence.js +111 -111
- package/dist/meteor/diff-sequence/diff.d.ts +17 -17
- package/dist/meteor/diff-sequence/diff.js +257 -257
- package/dist/meteor/ejson/ejson.d.ts +82 -82
- package/dist/meteor/ejson/ejson.js +568 -569
- package/dist/meteor/ejson/stringify.d.ts +2 -2
- package/dist/meteor/ejson/stringify.js +119 -119
- package/dist/meteor/ejson/utils.d.ts +12 -12
- package/dist/meteor/ejson/utils.js +42 -42
- package/dist/meteor/mongo/caching_change_observer.d.ts +16 -16
- package/dist/meteor/mongo/caching_change_observer.js +63 -63
- package/dist/meteor/mongo/doc_fetcher.d.ts +7 -7
- package/dist/meteor/mongo/doc_fetcher.js +53 -53
- package/dist/meteor/mongo/geojson_utils.d.ts +3 -3
- package/dist/meteor/mongo/geojson_utils.js +40 -41
- package/dist/meteor/mongo/live_connection.d.ts +28 -28
- package/dist/meteor/mongo/live_connection.js +264 -264
- package/dist/meteor/mongo/live_cursor.d.ts +25 -25
- package/dist/meteor/mongo/live_cursor.js +60 -60
- package/dist/meteor/mongo/minimongo_common.d.ts +84 -84
- package/dist/meteor/mongo/minimongo_common.js +1998 -1998
- package/dist/meteor/mongo/minimongo_matcher.d.ts +23 -23
- package/dist/meteor/mongo/minimongo_matcher.js +283 -283
- package/dist/meteor/mongo/minimongo_sorter.d.ts +16 -16
- package/dist/meteor/mongo/minimongo_sorter.js +268 -268
- package/dist/meteor/mongo/observe_driver_utils.d.ts +9 -9
- package/dist/meteor/mongo/observe_driver_utils.js +72 -73
- package/dist/meteor/mongo/observe_multiplexer.d.ts +46 -46
- package/dist/meteor/mongo/observe_multiplexer.js +203 -203
- package/dist/meteor/mongo/oplog-observe-driver.d.ts +68 -68
- package/dist/meteor/mongo/oplog-observe-driver.js +918 -918
- package/dist/meteor/mongo/oplog_tailing.d.ts +35 -35
- package/dist/meteor/mongo/oplog_tailing.js +352 -352
- package/dist/meteor/mongo/oplog_v2_converter.d.ts +1 -1
- package/dist/meteor/mongo/oplog_v2_converter.js +125 -126
- package/dist/meteor/mongo/polling_observe_driver.d.ts +30 -30
- package/dist/meteor/mongo/polling_observe_driver.js +216 -221
- package/dist/meteor/mongo/synchronous-cursor.d.ts +17 -17
- package/dist/meteor/mongo/synchronous-cursor.js +261 -261
- package/dist/meteor/mongo/synchronous-queue.d.ts +13 -13
- package/dist/meteor/mongo/synchronous-queue.js +110 -110
- package/dist/meteor/ordered-dict/ordered_dict.d.ts +31 -31
- package/dist/meteor/ordered-dict/ordered_dict.js +198 -198
- package/dist/meteor/random/AbstractRandomGenerator.d.ts +42 -42
- package/dist/meteor/random/AbstractRandomGenerator.js +92 -92
- package/dist/meteor/random/AleaRandomGenerator.d.ts +13 -13
- package/dist/meteor/random/AleaRandomGenerator.js +90 -90
- package/dist/meteor/random/NodeRandomGenerator.d.ts +16 -16
- package/dist/meteor/random/NodeRandomGenerator.js +42 -42
- package/dist/meteor/random/createAleaGenerator.d.ts +2 -2
- package/dist/meteor/random/createAleaGenerator.js +32 -32
- package/dist/meteor/random/createRandom.d.ts +1 -1
- package/dist/meteor/random/createRandom.js +22 -22
- package/dist/meteor/random/main.d.ts +1 -1
- package/dist/meteor/random/main.js +12 -12
- package/dist/meteor/types.d.ts +1 -1
- package/dist/meteor/types.js +2 -2
- package/package.json +5 -5
|
@@ -1,35 +1,35 @@
|
|
|
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
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* @summary The state for a single invocation of a method, referenced by this
|
|
12
|
-
* inside a method definition.
|
|
13
|
-
* @param {Object} options
|
|
14
|
-
* @instanceName this
|
|
15
|
-
* @showInstanceName true
|
|
16
|
-
*/
|
|
17
|
-
export declare class MethodInvocation {
|
|
18
|
-
userId: string;
|
|
19
|
-
connection: SessionConnectionHandle;
|
|
20
|
-
private isSimulation;
|
|
21
|
-
private _isFromCallAsync;
|
|
22
|
-
private _setUserId;
|
|
23
|
-
private randomSeed;
|
|
24
|
-
private randomStream;
|
|
25
|
-
constructor(options: MethodInvocationOptions);
|
|
26
|
-
/**
|
|
27
|
-
* @summary Set the logged in user.
|
|
28
|
-
* @locus Server
|
|
29
|
-
* @memberOf DDPCommon.MethodInvocation
|
|
30
|
-
* @instance
|
|
31
|
-
* @param {String | null} userId The value that should be returned by `userId` on this connection.
|
|
32
|
-
*/
|
|
33
|
-
setUserId(userId: string | null): void;
|
|
34
|
-
}
|
|
35
|
-
export {};
|
|
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
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @summary The state for a single invocation of a method, referenced by this
|
|
12
|
+
* inside a method definition.
|
|
13
|
+
* @param {Object} options
|
|
14
|
+
* @instanceName this
|
|
15
|
+
* @showInstanceName true
|
|
16
|
+
*/
|
|
17
|
+
export declare class MethodInvocation {
|
|
18
|
+
userId: string;
|
|
19
|
+
connection: SessionConnectionHandle;
|
|
20
|
+
private isSimulation;
|
|
21
|
+
private _isFromCallAsync;
|
|
22
|
+
private _setUserId;
|
|
23
|
+
private randomSeed;
|
|
24
|
+
private randomStream;
|
|
25
|
+
constructor(options: MethodInvocationOptions);
|
|
26
|
+
/**
|
|
27
|
+
* @summary Set the logged in user.
|
|
28
|
+
* @locus Server
|
|
29
|
+
* @memberOf DDPCommon.MethodInvocation
|
|
30
|
+
* @instance
|
|
31
|
+
* @param {String | null} userId The value that should be returned by `userId` on this connection.
|
|
32
|
+
*/
|
|
33
|
+
setUserId(userId: string | null): void;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Instance name is this because it is usually referred to as this inside a
|
|
3
|
-
// method definition
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.MethodInvocation = void 0;
|
|
6
|
-
/**
|
|
7
|
-
* @summary The state for a single invocation of a method, referenced by this
|
|
8
|
-
* inside a method definition.
|
|
9
|
-
* @param {Object} options
|
|
10
|
-
* @instanceName this
|
|
11
|
-
* @showInstanceName true
|
|
12
|
-
*/
|
|
13
|
-
class MethodInvocation {
|
|
14
|
-
constructor(options) {
|
|
15
|
-
// true if we're running not the actual method, but a stub (that is,
|
|
16
|
-
// if we're on a client (which may be a browser, or in the future a
|
|
17
|
-
// server connecting to another server) and presently running a
|
|
18
|
-
// simulation of a server-side method for latency compensation
|
|
19
|
-
// purposes). not currently true except in a client such as a browser,
|
|
20
|
-
// since there's usually no point in running stubs unless you have a
|
|
21
|
-
// zero-latency connection to the user.
|
|
22
|
-
/**
|
|
23
|
-
* @summary Access inside a method invocation. Boolean value, true if this invocation is a stub.
|
|
24
|
-
* @locus Anywhere
|
|
25
|
-
* @name isSimulation
|
|
26
|
-
* @memberOf DDPCommon.MethodInvocation
|
|
27
|
-
* @instance
|
|
28
|
-
* @type {Boolean}
|
|
29
|
-
*/
|
|
30
|
-
this.isSimulation = options.isSimulation;
|
|
31
|
-
// used to know when the function apply was called by callAsync
|
|
32
|
-
this._isFromCallAsync = options.isFromCallAsync;
|
|
33
|
-
// current user id
|
|
34
|
-
/**
|
|
35
|
-
* @summary The id of the user that made this method call, or `null` if no user was logged in.
|
|
36
|
-
* @locus Anywhere
|
|
37
|
-
* @name userId
|
|
38
|
-
* @memberOf DDPCommon.MethodInvocation
|
|
39
|
-
* @instance
|
|
40
|
-
*/
|
|
41
|
-
this.userId = options.userId;
|
|
42
|
-
// sets current user id in all appropriate server contexts and
|
|
43
|
-
// reruns subscriptions
|
|
44
|
-
this._setUserId = options.setUserId || function () { };
|
|
45
|
-
// On the server, the connection this method call came in on.
|
|
46
|
-
/**
|
|
47
|
-
* @summary Access inside a method invocation. The [connection](#meteor_onconnection) that this method was received on. `null` if the method is not associated with a connection, eg. a server initiated method call. Calls to methods made from a server method which was in turn initiated from the client share the same `connection`.
|
|
48
|
-
* @locus Server
|
|
49
|
-
* @name connection
|
|
50
|
-
* @memberOf DDPCommon.MethodInvocation
|
|
51
|
-
* @instance
|
|
52
|
-
*/
|
|
53
|
-
this.connection = options.connection;
|
|
54
|
-
// The seed for randomStream value generation
|
|
55
|
-
this.randomSeed = options.randomSeed;
|
|
56
|
-
// This is set by RandomStream.get; and holds the random stream state
|
|
57
|
-
this.randomStream = null;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* @summary Set the logged in user.
|
|
61
|
-
* @locus Server
|
|
62
|
-
* @memberOf DDPCommon.MethodInvocation
|
|
63
|
-
* @instance
|
|
64
|
-
* @param {String | null} userId The value that should be returned by `userId` on this connection.
|
|
65
|
-
*/
|
|
66
|
-
setUserId(userId) {
|
|
67
|
-
this.userId = userId;
|
|
68
|
-
this._setUserId(userId);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.MethodInvocation = MethodInvocation;
|
|
72
|
-
;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Instance name is this because it is usually referred to as this inside a
|
|
3
|
+
// method definition
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.MethodInvocation = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* @summary The state for a single invocation of a method, referenced by this
|
|
8
|
+
* inside a method definition.
|
|
9
|
+
* @param {Object} options
|
|
10
|
+
* @instanceName this
|
|
11
|
+
* @showInstanceName true
|
|
12
|
+
*/
|
|
13
|
+
class MethodInvocation {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
// true if we're running not the actual method, but a stub (that is,
|
|
16
|
+
// if we're on a client (which may be a browser, or in the future a
|
|
17
|
+
// server connecting to another server) and presently running a
|
|
18
|
+
// simulation of a server-side method for latency compensation
|
|
19
|
+
// purposes). not currently true except in a client such as a browser,
|
|
20
|
+
// since there's usually no point in running stubs unless you have a
|
|
21
|
+
// zero-latency connection to the user.
|
|
22
|
+
/**
|
|
23
|
+
* @summary Access inside a method invocation. Boolean value, true if this invocation is a stub.
|
|
24
|
+
* @locus Anywhere
|
|
25
|
+
* @name isSimulation
|
|
26
|
+
* @memberOf DDPCommon.MethodInvocation
|
|
27
|
+
* @instance
|
|
28
|
+
* @type {Boolean}
|
|
29
|
+
*/
|
|
30
|
+
this.isSimulation = options.isSimulation;
|
|
31
|
+
// used to know when the function apply was called by callAsync
|
|
32
|
+
this._isFromCallAsync = options.isFromCallAsync;
|
|
33
|
+
// current user id
|
|
34
|
+
/**
|
|
35
|
+
* @summary The id of the user that made this method call, or `null` if no user was logged in.
|
|
36
|
+
* @locus Anywhere
|
|
37
|
+
* @name userId
|
|
38
|
+
* @memberOf DDPCommon.MethodInvocation
|
|
39
|
+
* @instance
|
|
40
|
+
*/
|
|
41
|
+
this.userId = options.userId;
|
|
42
|
+
// sets current user id in all appropriate server contexts and
|
|
43
|
+
// reruns subscriptions
|
|
44
|
+
this._setUserId = options.setUserId || function () { };
|
|
45
|
+
// On the server, the connection this method call came in on.
|
|
46
|
+
/**
|
|
47
|
+
* @summary Access inside a method invocation. The [connection](#meteor_onconnection) that this method was received on. `null` if the method is not associated with a connection, eg. a server initiated method call. Calls to methods made from a server method which was in turn initiated from the client share the same `connection`.
|
|
48
|
+
* @locus Server
|
|
49
|
+
* @name connection
|
|
50
|
+
* @memberOf DDPCommon.MethodInvocation
|
|
51
|
+
* @instance
|
|
52
|
+
*/
|
|
53
|
+
this.connection = options.connection;
|
|
54
|
+
// The seed for randomStream value generation
|
|
55
|
+
this.randomSeed = options.randomSeed;
|
|
56
|
+
// This is set by RandomStream.get; and holds the random stream state
|
|
57
|
+
this.randomStream = null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @summary Set the logged in user.
|
|
61
|
+
* @locus Server
|
|
62
|
+
* @memberOf DDPCommon.MethodInvocation
|
|
63
|
+
* @instance
|
|
64
|
+
* @param {String | null} userId The value that should be returned by `userId` on this connection.
|
|
65
|
+
*/
|
|
66
|
+
setUserId(userId) {
|
|
67
|
+
this.userId = userId;
|
|
68
|
+
this._setUserId(userId);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.MethodInvocation = MethodInvocation;
|
|
72
|
+
;
|
|
@@ -1,8 +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;
|
|
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;
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// RandomStream allows for generation of pseudo-random values, from a seed.
|
|
3
|
-
//
|
|
4
|
-
// We use this for consistent 'random' numbers across the client and server.
|
|
5
|
-
// We want to generate probably-unique IDs on the client, and we ideally want
|
|
6
|
-
// the server to generate the same IDs when it executes the method.
|
|
7
|
-
//
|
|
8
|
-
// For generated values to be the same, we must seed ourselves the same way,
|
|
9
|
-
// and we must keep track of the current state of our pseudo-random generators.
|
|
10
|
-
// We call this state the scope. By default, we use the current DDP method
|
|
11
|
-
// invocation as our scope. DDP now allows the client to specify a randomSeed.
|
|
12
|
-
// If a randomSeed is provided it will be used to seed our random sequences.
|
|
13
|
-
// In this way, client and server method calls will generate the same values.
|
|
14
|
-
//
|
|
15
|
-
// We expose multiple named streams; each stream is independent
|
|
16
|
-
// and is seeded differently (but predictably from the name).
|
|
17
|
-
// By using multiple streams, we support reordering of requests,
|
|
18
|
-
// as long as they occur on different streams.
|
|
19
|
-
//
|
|
20
|
-
// @param options {Optional Object}
|
|
21
|
-
// seed: Array or value - Seed value(s) for the generator.
|
|
22
|
-
// If an array, will be used as-is
|
|
23
|
-
// If a value, will be converted to a single-value array
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
;
|
|
81
|
-
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
;
|
|
1
|
+
"use strict";
|
|
2
|
+
// RandomStream allows for generation of pseudo-random values, from a seed.
|
|
3
|
+
//
|
|
4
|
+
// We use this for consistent 'random' numbers across the client and server.
|
|
5
|
+
// We want to generate probably-unique IDs on the client, and we ideally want
|
|
6
|
+
// the server to generate the same IDs when it executes the method.
|
|
7
|
+
//
|
|
8
|
+
// For generated values to be the same, we must seed ourselves the same way,
|
|
9
|
+
// and we must keep track of the current state of our pseudo-random generators.
|
|
10
|
+
// We call this state the scope. By default, we use the current DDP method
|
|
11
|
+
// invocation as our scope. DDP now allows the client to specify a randomSeed.
|
|
12
|
+
// If a randomSeed is provided it will be used to seed our random sequences.
|
|
13
|
+
// In this way, client and server method calls will generate the same values.
|
|
14
|
+
//
|
|
15
|
+
// We expose multiple named streams; each stream is independent
|
|
16
|
+
// and is seeded differently (but predictably from the name).
|
|
17
|
+
// By using multiple streams, we support reordering of requests,
|
|
18
|
+
// as long as they occur on different streams.
|
|
19
|
+
//
|
|
20
|
+
// @param options {Optional Object}
|
|
21
|
+
// seed: Array or value - Seed value(s) for the generator.
|
|
22
|
+
// If an array, will be used as-is
|
|
23
|
+
// If a value, will be converted to a single-value array
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.RandomStream = void 0;
|
|
26
|
+
exports.makeRpcSeed = makeRpcSeed;
|
|
27
|
+
const main_1 = require("../random/main");
|
|
28
|
+
// If omitted, a random array will be used as the seed.
|
|
29
|
+
class RandomStream {
|
|
30
|
+
constructor(options) {
|
|
31
|
+
this.seed = [].concat(options.seed || randomToken());
|
|
32
|
+
this.sequences = Object.create(null);
|
|
33
|
+
}
|
|
34
|
+
// Get a random sequence with the specified name, creating it if does not exist.
|
|
35
|
+
// New sequences are seeded with the seed concatenated with the name.
|
|
36
|
+
// By passing a seed into Random.create, we use the Alea generator.
|
|
37
|
+
_sequence(name) {
|
|
38
|
+
var self = this;
|
|
39
|
+
var sequence = self.sequences[name] || null;
|
|
40
|
+
if (sequence === null) {
|
|
41
|
+
var sequenceSeed = self.seed.concat(name);
|
|
42
|
+
for (var i = 0; i < sequenceSeed.length; i++) {
|
|
43
|
+
if (typeof sequenceSeed[i] === "function") {
|
|
44
|
+
sequenceSeed[i] = sequenceSeed[i]();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
self.sequences[name] = sequence = main_1.Random.createWithSeeds.apply(null, sequenceSeed);
|
|
48
|
+
}
|
|
49
|
+
return sequence;
|
|
50
|
+
}
|
|
51
|
+
// Returns the random stream with the specified name, in the specified
|
|
52
|
+
// scope. If a scope is passed, then we use that to seed a (not
|
|
53
|
+
// cryptographically secure) PRNG using the fast Alea algorithm. If
|
|
54
|
+
// scope is null (or otherwise falsey) then we use a generated seed.
|
|
55
|
+
//
|
|
56
|
+
// However, scope will normally be the current DDP method invocation,
|
|
57
|
+
// so we'll use the stream with the specified name, and we should get
|
|
58
|
+
// consistent values on the client and server sides of a method call.
|
|
59
|
+
static get(scope, name) {
|
|
60
|
+
if (!name) {
|
|
61
|
+
name = "default";
|
|
62
|
+
}
|
|
63
|
+
if (!scope) {
|
|
64
|
+
// There was no scope passed in; the sequence won't actually be
|
|
65
|
+
// reproducible. but make it fast (and not cryptographically
|
|
66
|
+
// secure) anyways, so that the behavior is similar to what you'd
|
|
67
|
+
// get by passing in a scope.
|
|
68
|
+
return main_1.Random.insecure;
|
|
69
|
+
}
|
|
70
|
+
var randomStream = scope.randomStream;
|
|
71
|
+
if (!randomStream) {
|
|
72
|
+
scope.randomStream = randomStream = new RandomStream({
|
|
73
|
+
seed: scope.randomSeed
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return randomStream._sequence(name);
|
|
77
|
+
}
|
|
78
|
+
;
|
|
79
|
+
}
|
|
80
|
+
exports.RandomStream = RandomStream;
|
|
81
|
+
;
|
|
82
|
+
// Returns a random string of sufficient length for a random seed.
|
|
83
|
+
// This is a placeholder function; a similar function is planned
|
|
84
|
+
// for Random itself; when that is added we should remove this function,
|
|
85
|
+
// and call Random's randomToken instead.
|
|
86
|
+
function randomToken() {
|
|
87
|
+
return main_1.Random.hexString(20);
|
|
88
|
+
}
|
|
89
|
+
;
|
|
90
|
+
// Creates a randomSeed for passing to a method call.
|
|
91
|
+
// Note that we take enclosing as an argument,
|
|
92
|
+
// though we expect it to be DDP._CurrentMethodInvocation.get()
|
|
93
|
+
// However, we often evaluate makeRpcSeed lazily, and thus the relevant
|
|
94
|
+
// invocation may not be the one currently in scope.
|
|
95
|
+
// If enclosing is null, we'll use Random and values won't be repeatable.
|
|
96
|
+
function makeRpcSeed(enclosing, methodName) {
|
|
97
|
+
var stream = RandomStream.get(enclosing, '/rpc/' + methodName);
|
|
98
|
+
return stream.hexString(20);
|
|
99
|
+
}
|
|
100
|
+
;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { SessionDocumentView } from "./session-document-view";
|
|
2
|
-
import { SubscriptionCallbacks, SubscriptionHandle } from "./subscription";
|
|
3
|
-
/**
|
|
4
|
-
* Represents a client's view of a single collection
|
|
5
|
-
* @param {String} collectionName Name of the collection it represents
|
|
6
|
-
* @param {Object.<String, Function>} sessionCallbacks The callbacks for added, changed, removed
|
|
7
|
-
* @class SessionCollectionView
|
|
8
|
-
*/
|
|
9
|
-
export declare class SessionCollectionView {
|
|
10
|
-
private collectionName;
|
|
11
|
-
private callbacks;
|
|
12
|
-
private documents;
|
|
13
|
-
constructor(collectionName: string, callbacks: SubscriptionCallbacks);
|
|
14
|
-
isEmpty(): boolean;
|
|
15
|
-
diff(previous: SessionCollectionView): void;
|
|
16
|
-
diffDocument(id: string, prevDV: SessionDocumentView, nowDV: SessionDocumentView): void;
|
|
17
|
-
added(subscriptionHandle: SubscriptionHandle, id: string, fields: Record<string, any>): void;
|
|
18
|
-
changed(subscriptionHandle: SubscriptionHandle, id: string, changed: Record<string, any>): void;
|
|
19
|
-
removed(subscriptionHandle: SubscriptionHandle, id: string): void;
|
|
20
|
-
}
|
|
1
|
+
import { SessionDocumentView } from "./session-document-view";
|
|
2
|
+
import { SubscriptionCallbacks, SubscriptionHandle } from "./subscription";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a client's view of a single collection
|
|
5
|
+
* @param {String} collectionName Name of the collection it represents
|
|
6
|
+
* @param {Object.<String, Function>} sessionCallbacks The callbacks for added, changed, removed
|
|
7
|
+
* @class SessionCollectionView
|
|
8
|
+
*/
|
|
9
|
+
export declare class SessionCollectionView {
|
|
10
|
+
private collectionName;
|
|
11
|
+
private callbacks;
|
|
12
|
+
private documents;
|
|
13
|
+
constructor(collectionName: string, callbacks: SubscriptionCallbacks);
|
|
14
|
+
isEmpty(): boolean;
|
|
15
|
+
diff(previous: SessionCollectionView): void;
|
|
16
|
+
diffDocument(id: string, prevDV: SessionDocumentView, nowDV: SessionDocumentView): void;
|
|
17
|
+
added(subscriptionHandle: SubscriptionHandle, id: string, fields: Record<string, any>): void;
|
|
18
|
+
changed(subscriptionHandle: SubscriptionHandle, id: string, changed: Record<string, any>): void;
|
|
19
|
+
removed(subscriptionHandle: SubscriptionHandle, id: string): void;
|
|
20
|
+
}
|