jsforce2 1.11.1 → 5.2.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.

Potentially problematic release.


This version of jsforce2 might be problematic. Click here for more details.

Files changed (80) hide show
  1. package/index.js +46 -1
  2. package/package.json +7 -105
  3. package/LICENSE +0 -22
  4. package/README.md +0 -74
  5. package/bin/jsforce +0 -3
  6. package/bower.json +0 -30
  7. package/build/jsforce-api-analytics.js +0 -393
  8. package/build/jsforce-api-analytics.min.js +0 -2
  9. package/build/jsforce-api-analytics.min.js.map +0 -1
  10. package/build/jsforce-api-apex.js +0 -183
  11. package/build/jsforce-api-apex.min.js +0 -2
  12. package/build/jsforce-api-apex.min.js.map +0 -1
  13. package/build/jsforce-api-bulk.js +0 -1054
  14. package/build/jsforce-api-bulk.min.js +0 -2
  15. package/build/jsforce-api-bulk.min.js.map +0 -1
  16. package/build/jsforce-api-chatter.js +0 -320
  17. package/build/jsforce-api-chatter.min.js +0 -2
  18. package/build/jsforce-api-chatter.min.js.map +0 -1
  19. package/build/jsforce-api-metadata.js +0 -3020
  20. package/build/jsforce-api-metadata.min.js +0 -2
  21. package/build/jsforce-api-metadata.min.js.map +0 -1
  22. package/build/jsforce-api-soap.js +0 -403
  23. package/build/jsforce-api-soap.min.js +0 -2
  24. package/build/jsforce-api-soap.min.js.map +0 -1
  25. package/build/jsforce-api-streaming.js +0 -3479
  26. package/build/jsforce-api-streaming.min.js +0 -2
  27. package/build/jsforce-api-streaming.min.js.map +0 -1
  28. package/build/jsforce-api-tooling.js +0 -319
  29. package/build/jsforce-api-tooling.min.js +0 -2
  30. package/build/jsforce-api-tooling.min.js.map +0 -1
  31. package/build/jsforce-core.js +0 -25250
  32. package/build/jsforce-core.min.js +0 -2
  33. package/build/jsforce-core.min.js.map +0 -1
  34. package/build/jsforce.js +0 -31637
  35. package/build/jsforce.min.js +0 -2
  36. package/build/jsforce.min.js.map +0 -1
  37. package/core.js +0 -1
  38. package/lib/VERSION.js +0 -2
  39. package/lib/_required.js +0 -29
  40. package/lib/api/analytics.js +0 -387
  41. package/lib/api/apex.js +0 -177
  42. package/lib/api/bulk.js +0 -862
  43. package/lib/api/chatter.js +0 -314
  44. package/lib/api/index.js +0 -8
  45. package/lib/api/metadata.js +0 -848
  46. package/lib/api/soap.js +0 -397
  47. package/lib/api/streaming-extension.js +0 -136
  48. package/lib/api/streaming.js +0 -270
  49. package/lib/api/tooling.js +0 -313
  50. package/lib/browser/canvas.js +0 -90
  51. package/lib/browser/client.js +0 -241
  52. package/lib/browser/core.js +0 -5
  53. package/lib/browser/jsforce.js +0 -6
  54. package/lib/browser/jsonp.js +0 -52
  55. package/lib/browser/request.js +0 -70
  56. package/lib/cache.js +0 -252
  57. package/lib/cli/cli.js +0 -431
  58. package/lib/cli/repl.js +0 -337
  59. package/lib/connection.js +0 -1881
  60. package/lib/core.js +0 -16
  61. package/lib/csv.js +0 -50
  62. package/lib/date.js +0 -163
  63. package/lib/http-api.js +0 -300
  64. package/lib/jsforce.js +0 -10
  65. package/lib/logger.js +0 -52
  66. package/lib/oauth2.js +0 -206
  67. package/lib/process.js +0 -275
  68. package/lib/promise.js +0 -164
  69. package/lib/query.js +0 -881
  70. package/lib/quick-action.js +0 -90
  71. package/lib/record-stream.js +0 -305
  72. package/lib/record.js +0 -107
  73. package/lib/registry/file-registry.js +0 -48
  74. package/lib/registry/index.js +0 -3
  75. package/lib/registry/registry.js +0 -111
  76. package/lib/require.js +0 -14
  77. package/lib/soap.js +0 -207
  78. package/lib/sobject.js +0 -558
  79. package/lib/soql-builder.js +0 -236
  80. package/lib/transport.js +0 -233
package/lib/api/soap.js DELETED
@@ -1,397 +0,0 @@
1
- /**
2
- * @file Salesforce SOAP API
3
- * @author Shinichi Tomita <shinichi.tomita@gmail.com>
4
- */
5
-
6
- 'use strict';
7
-
8
- var _ = require('lodash/core');
9
- var jsforce = require('../core');
10
- var SOAP = require('../soap');
11
-
12
- /**
13
- * API class for Partner SOAP call
14
- *
15
- * @class
16
- * @param {Connection} conn - Connection
17
- */
18
- var SoapApi = module.exports = function(conn) {
19
- this._conn = conn;
20
- };
21
-
22
- /**
23
- * Call SOAP Api (Partner) endpoint
24
- * @private
25
- */
26
- SoapApi.prototype._invoke = function(method, message, schema, callback) {
27
- var soapEndpoint = new SOAP(this._conn, {
28
- xmlns: "urn:partner.soap.sforce.com",
29
- endpointUrl: this._conn.instanceUrl + "/services/Soap/u/" + this._conn.version
30
- });
31
- return soapEndpoint.invoke(method, message, { result: schema }).then(function(res) {
32
- return res.result;
33
- }).thenCall(callback);
34
- };
35
-
36
-
37
- /* */
38
- var Schemas = {};
39
-
40
- /**
41
- * @typedef SoapApi~LeadConvert
42
- * @prop {String} convertedStatus - Status of converted lead
43
- * @prop {String} leadId - Lead record Id to convert
44
- * @prop {String} [accountId] - Account record Id to assign the converted record
45
- * @prop {String} [contactId] - Contact record Id to assign the converted record
46
- * @prop {Boolean} [doNotCreateOpportunity] - True if you don't want to create a new opportunity
47
- * @prop {String} [opportunityName] - Name of opportunity to create
48
- * @prop {Boolean} [overwriteLeadSource] - True if overwriting lead source
49
- * @prop {String} [ownerId] - Owner Id
50
- * @prop {Boolean} [sendNotificationEmail] - True if send notification email
51
- */
52
- /**
53
- * @typedef SoapApi~LeadConvertResult
54
- * @prop {String} leadId - Lead record Id to convert
55
- * @prop {String} [accountId] - Account record Id of converted lead
56
- * @prop {String} [contactId] - Contact record Id of converted lead
57
- * @prop {String} [opportunityId] - Opportunity record Id created in conversion
58
- * @prop {Boolean} success - True if successfully converted
59
- * @prop {Array.<Object>} errors - Error
60
- */
61
- /**
62
- * Converts a Lead into an Account, Contact, or (optionally) an Opportunity.
63
- *
64
- * @param {SoapApi~LeadConvert|Array.<SoapApi~LeadConvert>} leadConverts
65
- * @param {Callback.<SoapApi~LeadConvertResult|Array.<SoapApi~LeadConvertResult>>} [callback] - Callback function
66
- * @returns {Promise.<SoapApi~LeadConvertResult|Array.<SoapApi~LeadConvertResult>>}
67
- */
68
- SoapApi.prototype.convertLead = function(leadConverts, callback) {
69
- var schema = _.isArray(leadConverts) ? [ Schemas.LeadConvertResult ] : Schemas.LeadConvertResult;
70
- return this._invoke("convertLead", { leadConverts: leadConverts }, schema, callback);
71
- };
72
- Schemas.LeadConvertResult = {
73
- success: 'boolean',
74
- errors: [],
75
- leadId: 'string',
76
- accountId: 'string',
77
- contactId: 'string',
78
- opportunityId: 'string'
79
- };
80
-
81
- /**
82
- * @typedef SoapApi~MergeRequest
83
- * @prop {Object} masterRecord - The merge destination record
84
- * @prop {Array.<String>} recordToMergeIds - Ids of records to merge
85
- */
86
- /**
87
- * @typedef SoapApi~MergeResult
88
- * @prop {Boolean} success - True if successfully merged
89
- * @prop {Array.<Object>} errors - Error
90
- * @prop {String} id - ID of the master record
91
- * @prop {Array.<String>} mergedRecordIds - ID of the records that were merged into the master record
92
- * @prop {Array.<String>} updatedRelatedIds - ID of all related records that were moved (re-parented) as a result of the merge
93
- */
94
-
95
- /**
96
- * Merge up to three records into one
97
- *
98
- * @param {SoapApi~MergeRequest|Array.<SoapApi~MergeRequest>} mergeRequests
99
- * @param {Callback.<SoapApi~MergeResult|Array.<SoapApi~MergeResult>>} [callback] - Callback function
100
- * @returns {Promise.<SoapApi~MergeResult|Array.<SoapApi~MergeResult>>}
101
- */
102
- SoapApi.prototype.merge = function(mergeRequests, callback) {
103
- var schema = _.isArray(mergeRequests) ? [ Schemas.MergeResult ] : Schemas.MergeResult;
104
- return this._invoke("merge", { mergeRequests: mergeRequests }, schema, callback);
105
- };
106
- Schemas.MergeResult = {
107
- success: 'boolean',
108
- errors: [],
109
- id: 'string',
110
- mergedRecordIds: ['string'],
111
- updatedRelatedIds: ['string']
112
- };
113
-
114
-
115
- /**
116
- * @typedef SoapApi~EmptyRecycleBinResult
117
- * @prop {String} id - ID of an sObject that you attempted to delete from the Recycle Bin
118
- * @prop {Boolean} success - Whether the call succeeded (true) or not (false) for this record
119
- * @prop {Array.<Object>} errors - Errors
120
- */
121
- /**
122
- * Delete records from the recycle bin immediately
123
- *
124
- * @param {Array.<String>} ids - Record ids to empty from recycle bin
125
- * @param {Callback.<Array.<SoapApi~EmptyRecycleBinResult>>} [callback] - Callback function
126
- * @returns {Promise.<Array.<SoapApi~EmptyRecycleBinResult>>}
127
- */
128
- SoapApi.prototype.emptyRecycleBin = function(ids, callback) {
129
- return this._invoke("emptyRecycleBin", { ids: ids }, [ Schemas.EmptyRecycleBinResult ], callback);
130
- };
131
- Schemas.EmptyRecycleBinResult = {
132
- id: 'string',
133
- success: 'boolean',
134
- errors: []
135
- };
136
-
137
-
138
- /**
139
- * @typedef SoapApi~DescribeTabSetResult
140
- * @prop {String} label - The display label for this standard or custom app
141
- * @prop {String} logoUrl - A fully qualified URL to the logo image associated with the standard or custom app
142
- * @prop {String} namespace - Namespace of application package
143
- * @prop {Boolean} selected - If true, then this standard or custom app is the user’s currently selected app
144
- * @prop {Array.<SoapApi~DescribeTab>} tabs - An array of tabs that are displayed for the specified standard app or custom app
145
- */
146
- /**
147
- * @typedef SoapApi~DescribeTab
148
- * @prop {Array.<Object>} colors - Array of color information used for a tab
149
- * @prop {Boolean} custom - true if this is a custom tab
150
- * @prop {String} iconUrl - The URL for the main 32 x 32 pixel icon for a tab
151
- * @prop {Array.<Object>} icons - Array of icon information used for a tab
152
- * @prop {String} label - The display label for this tab
153
- * @prop {String} miniIconUrl - The URL for the 16 x 16 pixel icon that represents a tab
154
- * @prop {String} name - The API name of the tab
155
- * @prop {String} sobjectName - The name of the sObject that is primarily displayed on this tab
156
- * @prop {String} url - A fully qualified URL for viewing this tab
157
- */
158
- /**
159
- * Returns information about the standard and custom apps available to the logged-in user
160
- *
161
- * @param {Callback.<Array.<SoapApi~DescribeTabSetResult>>} [callback] - Callback function
162
- * @returns {Promise.<Array.<SoapApi~DescribeTabSetResult>>}
163
- */
164
- SoapApi.prototype.describeTabs = function(callback) {
165
- return this._invoke("describeTabs", {}, [ Schemas.DescribeTabSetResult ], callback);
166
- };
167
- Schemas.DescribeTabSetResult = {
168
- label: 'string',
169
- logoUrl: 'string',
170
- namespace: 'string',
171
- selected: 'boolean',
172
- tabs: [{
173
- colors: [{
174
- theme: 'string',
175
- color: 'string',
176
- context: 'string'
177
- }],
178
- iconUrl: 'string',
179
- icons: [{
180
- theme: 'string',
181
- height: 'number',
182
- width: 'number',
183
- url: 'string',
184
- contentType: 'string'
185
- }],
186
- label: 'string',
187
- custom: 'boolean',
188
- miniIconUrl: 'string',
189
- name: 'string',
190
- sobjectName: 'string',
191
- url: 'string'
192
- }]
193
- };
194
-
195
- /**
196
- * Retrieves the current system timestamp (Coordinated Universal Time (UTC) time zone) from the API
197
- *
198
- * @typedef SoapApi~ServerTimestampResult
199
- * @prop {String} timestamp - Timestamp
200
- */
201
- /**
202
- * @param {Callback.<SoapApi~ServerTimestampResult>} [callback] - Callback function
203
- * @returns {Promise.<SoapApi~ServerTimestampResult>}
204
- */
205
- SoapApi.prototype.getServerTimestamp = function(callback) {
206
- return this._invoke("getServerTimestamp", {}, Schemas.GetServerTimestampResult, callback);
207
- };
208
- Schemas.GetServerTimestampResult = {
209
- timestamp: 'string'
210
- };
211
-
212
- /**
213
- * @typedef SoapApi~UserInfoResult
214
- * @prop {Boolean} accessibilityMode
215
- * @prop {String} currencySymbol
216
- * @prop {Number} orgAttachmentFileSizeLimit
217
- * @prop {String} orgDefaultCurrencyIsoCode
218
- * @prop {String} orgDisallowHtmlAttachments
219
- * @prop {Boolean} orgHasPersonAccounts
220
- * @prop {String} organizationId
221
- * @prop {Boolean} organizationMultiCurrency
222
- * @prop {String} organizationName
223
- * @prop {String} profileId
224
- * @prop {String} roleId
225
- * @prop {Number} sessionSecondsValid
226
- * @prop {String} userDefaultCurrencyIsoCode
227
- * @prop {String} userEmail
228
- * @prop {String} userFullName
229
- * @prop {String} userId
230
- * @prop {String} userLanguage
231
- * @prop {String} userLocale
232
- * @prop {String} userName
233
- * @prop {String} userTimeZone
234
- * @prop {String} userType
235
- * @prop {String} userUiSkin
236
- */
237
- /**
238
- * Retrieves personal information for the user associated with the current session
239
- *
240
- * @param {Callback.<SoapApi~UserInfoResult>} [callback] - Callback function
241
- * @returns {Promise.<SoapApi~UserInfoResult>}
242
- */
243
- SoapApi.prototype.getUserInfo = function(callback) {
244
- return this._invoke("getUserInfo", {}, Schemas.GetUserInfoResult, callback);
245
- };
246
- Schemas.GetUserInfoResult = {
247
- accessibilityMode: 'boolean',
248
- currencySymbol: 'string',
249
- orgAttachmentFileSizeLimit: 'number',
250
- orgDefaultCurrencyIsoCode: 'string',
251
- orgDisallowHtmlAttachments: 'boolean',
252
- orgHasPersonAccounts: 'boolean',
253
- organizationId: 'string',
254
- organizationMultiCurrency: 'boolean',
255
- organizationName: 'string',
256
- profileId: 'string',
257
- roleId: 'string',
258
- sessionSecondsValid: 'number',
259
- userDefaultCurrencyIsoCode: 'string',
260
- userEmail: 'string',
261
- userFullName: 'string',
262
- userId: 'string',
263
- userLanguage: 'string',
264
- userLocale: 'string',
265
- userName: 'string',
266
- userTimeZone: 'string',
267
- userType: 'string',
268
- userUiSkin: 'string'
269
- };
270
-
271
- /**
272
- * Sets the specified user’s password to the specified value
273
- *
274
- * @param {String} userId - User Id to set password
275
- * @param {String} password - New password
276
- * @param {Callback.<String>} [callback] - Callback function
277
- * @returns {Promise.<String>}
278
- */
279
- SoapApi.prototype.setPassword = function(userId, password, callback) {
280
- return this._invoke("setPassword", { userId: userId, password: password }, callback);
281
- };
282
-
283
- /**
284
- * @typedef SoapApi~ResetPasswordResult
285
- * @prop {String} password
286
- */
287
- /**
288
- * Resets the specified user’s password
289
- *
290
- * @param {String} userId - User Id to set password
291
- * @param {String} password - New password
292
- * @param {Callback.<SoapApi~ResetPasswordResult>} [callback] - Callback function
293
- * @returns {Promise.<SoapApi~ResetPasswordResult>}
294
- */
295
- SoapApi.prototype.resetPassword = function(userId, callback) {
296
- return this._invoke("resetPassword", { userId: userId }, callback);
297
- };
298
-
299
- /**
300
- * Adds one or more new records to your organization’s data
301
- *
302
- * @param {Array.<Object>} sObjects - Records to insert
303
- * @param {Callback.<SoapApi~SaveResult>} [callback] - Callback function
304
- * @returns {Promise.<SoapApi~SaveResult>}
305
- */
306
- SoapApi.prototype.create = function(sObjects, callback) {
307
- var schema = _.isArray(sObjects) ? [ Schemas.SaveResult ] : Schemas.SaveResult;
308
- var args = {
309
- '@xmlns' : 'urn:partner.soap.sforce.com',
310
- '@xmlns:ns1' : 'sobject.partner.soap.sforce.com',
311
- 'ns1:sObjects' : sObjects
312
- };
313
- return this._invoke("create", args, schema, callback);
314
- };
315
-
316
- /**
317
- * Updates one or more existing records in your organization’s data.
318
- *
319
- * @param {Array.<Object>} sObjects - Records to update
320
- * @param {Callback.<SoapApi~SaveResult>} [callback] - Callback function
321
- * @returns {Promise.<SoapApi~SaveResult>}
322
- */
323
- SoapApi.prototype.update = function(sObjects, callback) {
324
- var schema = _.isArray(sObjects) ? [ Schemas.SaveResult ] : Schemas.SaveResult;
325
- var args = {
326
- '@xmlns' : 'urn:partner.soap.sforce.com',
327
- '@xmlns:ns1' : 'sobject.partner.soap.sforce.com',
328
- 'ns1:sObjects' : sObjects
329
- };
330
- return this._invoke("update", args, schema, callback);
331
- };
332
-
333
- Schemas.SaveResult = {
334
- success: 'boolean',
335
- errors: [],
336
- id: 'string'
337
- };
338
-
339
- /**
340
- * Creates new records and updates existing records in your organization’s data.
341
- *
342
- * @param {Array.<Object>} sObjects - Records to upsert
343
- * @param {Callback.<SoapApi~UpsertResult>} [callback] - Callback function
344
- * @returns {Promise.<SoapApi~UpsertResult>}
345
- */
346
- SoapApi.prototype.upsert = function(externalIdFieldName, sObjects, callback) {
347
- var schema = _.isArray(sObjects) ? [ Schemas.UpsertResult ] : Schemas.UpsertResult;
348
- var args = {
349
- '@xmlns' : 'urn:partner.soap.sforce.com',
350
- '@xmlns:ns1' : 'sobject.partner.soap.sforce.com',
351
- 'ns1:externalIDFieldName' : externalIdFieldName,
352
- 'ns1:sObjects' : sObjects
353
- };
354
- return this._invoke("upsert", args, schema, callback);
355
- };
356
-
357
- Schemas.UpsertResult = {
358
- created: 'boolean',
359
- success: 'boolean',
360
- errors: [],
361
- id: 'string'
362
- };
363
-
364
- /**
365
- * Deletes one or more records from your organization’s data
366
- *
367
- * @param {Array.<Object>} ids - Id of records to delete
368
- * @param {Callback.<SoapApi~DeleteResult>} [callback] - Callback function
369
- * @returns {Promise.<SoapApi~DeleteResult>}
370
- */
371
- SoapApi.prototype.delete = function(ids, callback) {
372
- var schema = _.isArray(ids) ? [ Schemas.DeleteResult ] : Schemas.DeleteResult;
373
- var args = {
374
- '@xmlns' : 'urn:partner.soap.sforce.com',
375
- '@xmlns:ns1' : 'sobject.partner.soap.sforce.com',
376
- 'ns1:ids' : ids
377
- };
378
- return this._invoke("delete", args, schema, callback);
379
- };
380
-
381
- Schemas.DeleteResult = {
382
- success: 'boolean',
383
- errors: [],
384
- id: 'string'
385
- };
386
-
387
-
388
- /*--------------------------------------------*/
389
- /*
390
- * Register hook in connection instantiation for dynamically adding this API module features
391
- */
392
- jsforce.on('connection:new', function(conn) {
393
- conn.soap = new SoapApi(conn);
394
- });
395
-
396
-
397
- module.exports = SoapApi;
@@ -1,136 +0,0 @@
1
- /**
2
- * Faye Client extensions: https://faye.jcoglan.com/browser/extensions.html
3
- *
4
- * For use with Streaming.prototype.createClient()
5
- **/
6
- var StreamingExtension = {};
7
-
8
- /**
9
- * Constructor for an auth failure detector extension
10
- *
11
- * Based on new feature released with Salesforce Spring '18:
12
- * https://releasenotes.docs.salesforce.com/en-us/spring18/release-notes/rn_messaging_cometd_auth_validation.htm?edition=&impact=
13
- *
14
- * Example triggering error message:
15
- *
16
- * ```
17
- * {
18
- * "ext":{
19
- * "sfdc":{"failureReason":"401::Authentication invalid"},
20
- * "replay":true},
21
- * "advice":{"reconnect":"none"},
22
- * "channel":"/meta/handshake",
23
- * "error":"403::Handshake denied",
24
- * "successful":false
25
- * }
26
- * ```
27
- *
28
- * Example usage:
29
- *
30
- * ```javascript
31
- * const conn = new jsforce.Connection({ … });
32
- *
33
- * const channel = "/event/My_Event__e";
34
- *
35
- * // Exit the Node process when auth fails
36
- * const exitCallback = () => process.exit(1);
37
- * const authFailureExt = new jsforce.StreamingExtension.AuthFailure(exitCallback);
38
- *
39
- * const fayeClient = conn.streaming.createClient([ authFailureExt ]);
40
- *
41
- * const subscription = fayeClient.subscribe(channel, data => {
42
- * console.log('topic received data', data);
43
- * });
44
- *
45
- * subscription.cancel();
46
- * ```
47
- *
48
- * @param {Function} failureCallback - Invoked when authentication becomes invalid
49
- */
50
- StreamingExtension.AuthFailure = function(failureCallback) {
51
- this.incoming = function(message, callback) {
52
- if (
53
- (message.channel === '/meta/connect' ||
54
- message.channel === '/meta/handshake')
55
- && message.advice
56
- && message.advice.reconnect == 'none'
57
- ) {
58
- failureCallback(message);
59
- } else {
60
- callback(message);
61
- }
62
- }
63
- };
64
-
65
- /**
66
- * Constructor for a durable streaming replay extension
67
- *
68
- * Modified from original Salesforce demo source code:
69
- * https://github.com/developerforce/SalesforceDurableStreamingDemo/blob/3d4a56eac956f744ad6c22e6a8141b6feb57abb9/staticresources/cometdReplayExtension.resource
70
- *
71
- * Example usage:
72
- *
73
- * ```javascript
74
- * const conn = new jsforce.Connection({ … });
75
- *
76
- * const channel = "/event/My_Event__e";
77
- * const replayId = -2; // -2 is all retained events
78
- *
79
- * const replayExt = new jsforce.StreamingExtension.Replay(channel, replayId);
80
- *
81
- * const fayeClient = conn.streaming.createClient([ replayExt ]);
82
- *
83
- * const subscription = fayeClient.subscribe(channel, data => {
84
- * console.log('topic received data', data);
85
- * });
86
- *
87
- * subscription.cancel();
88
- * ```
89
- */
90
- StreamingExtension.Replay = function(channel, replayId) {
91
- var REPLAY_FROM_KEY = "replay";
92
-
93
- var _extensionEnabled = replayId != null ? true : false;
94
- var _replay = replayId;
95
- var _channel = channel;
96
-
97
- this.setExtensionEnabled = function(extensionEnabled) {
98
- _extensionEnabled = extensionEnabled;
99
- }
100
-
101
- this.setReplay = function (replay) {
102
- _replay = parseInt(replay, 10);
103
- }
104
-
105
- this.setChannel = function(channel) {
106
- _channel = channel;
107
- }
108
-
109
- this.incoming = function(message, callback) {
110
- if (message.channel === '/meta/handshake') {
111
- if (message.ext && message.ext[REPLAY_FROM_KEY] == true) {
112
- _extensionEnabled = true;
113
- }
114
- } else if (message.channel === _channel && message.data && message.data.event && message.data.event.replayId) {
115
- _replay = message.data.event.replayId;
116
- }
117
- callback(message);
118
- }
119
-
120
- this.outgoing = function(message, callback) {
121
- if (message.channel === '/meta/subscribe' && message.subscription === _channel) {
122
- if (_extensionEnabled) {
123
- if (!message.ext) { message.ext = {}; }
124
-
125
- var replayFromMap = {};
126
- replayFromMap[_channel] = _replay;
127
-
128
- // add "ext : { "replay" : { CHANNEL : REPLAY_VALUE }}" to subscribe message
129
- message.ext[REPLAY_FROM_KEY] = replayFromMap;
130
- }
131
- }
132
- callback(message);
133
- };
134
- };
135
-
136
- module.exports = StreamingExtension;