jsforce2 1.11.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/LICENSE +22 -0
- package/README.md +74 -0
- package/bin/jsforce +3 -0
- package/bower.json +30 -0
- package/build/jsforce-api-analytics.js +393 -0
- package/build/jsforce-api-analytics.min.js +2 -0
- package/build/jsforce-api-analytics.min.js.map +1 -0
- package/build/jsforce-api-apex.js +183 -0
- package/build/jsforce-api-apex.min.js +2 -0
- package/build/jsforce-api-apex.min.js.map +1 -0
- package/build/jsforce-api-bulk.js +1054 -0
- package/build/jsforce-api-bulk.min.js +2 -0
- package/build/jsforce-api-bulk.min.js.map +1 -0
- package/build/jsforce-api-chatter.js +320 -0
- package/build/jsforce-api-chatter.min.js +2 -0
- package/build/jsforce-api-chatter.min.js.map +1 -0
- package/build/jsforce-api-metadata.js +3020 -0
- package/build/jsforce-api-metadata.min.js +2 -0
- package/build/jsforce-api-metadata.min.js.map +1 -0
- package/build/jsforce-api-soap.js +403 -0
- package/build/jsforce-api-soap.min.js +2 -0
- package/build/jsforce-api-soap.min.js.map +1 -0
- package/build/jsforce-api-streaming.js +3479 -0
- package/build/jsforce-api-streaming.min.js +2 -0
- package/build/jsforce-api-streaming.min.js.map +1 -0
- package/build/jsforce-api-tooling.js +319 -0
- package/build/jsforce-api-tooling.min.js +2 -0
- package/build/jsforce-api-tooling.min.js.map +1 -0
- package/build/jsforce-core.js +25250 -0
- package/build/jsforce-core.min.js +2 -0
- package/build/jsforce-core.min.js.map +1 -0
- package/build/jsforce.js +31637 -0
- package/build/jsforce.min.js +2 -0
- package/build/jsforce.min.js.map +1 -0
- package/core.js +1 -0
- package/index.js +1 -0
- package/lib/VERSION.js +2 -0
- package/lib/_required.js +29 -0
- package/lib/api/analytics.js +387 -0
- package/lib/api/apex.js +177 -0
- package/lib/api/bulk.js +862 -0
- package/lib/api/chatter.js +314 -0
- package/lib/api/index.js +8 -0
- package/lib/api/metadata.js +848 -0
- package/lib/api/soap.js +397 -0
- package/lib/api/streaming-extension.js +136 -0
- package/lib/api/streaming.js +270 -0
- package/lib/api/tooling.js +313 -0
- package/lib/browser/canvas.js +90 -0
- package/lib/browser/client.js +241 -0
- package/lib/browser/core.js +5 -0
- package/lib/browser/jsforce.js +6 -0
- package/lib/browser/jsonp.js +52 -0
- package/lib/browser/request.js +70 -0
- package/lib/cache.js +252 -0
- package/lib/cli/cli.js +431 -0
- package/lib/cli/repl.js +337 -0
- package/lib/connection.js +1881 -0
- package/lib/core.js +16 -0
- package/lib/csv.js +50 -0
- package/lib/date.js +163 -0
- package/lib/http-api.js +300 -0
- package/lib/jsforce.js +10 -0
- package/lib/logger.js +52 -0
- package/lib/oauth2.js +206 -0
- package/lib/process.js +275 -0
- package/lib/promise.js +164 -0
- package/lib/query.js +881 -0
- package/lib/quick-action.js +90 -0
- package/lib/record-stream.js +305 -0
- package/lib/record.js +107 -0
- package/lib/registry/file-registry.js +48 -0
- package/lib/registry/index.js +3 -0
- package/lib/registry/registry.js +111 -0
- package/lib/require.js +14 -0
- package/lib/soap.js +207 -0
- package/lib/sobject.js +558 -0
- package/lib/soql-builder.js +236 -0
- package/lib/transport.js +233 -0
- package/package.json +110 -0
package/core.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./lib/core');
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./lib/jsforce');
|
package/lib/VERSION.js
ADDED
package/lib/_required.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// This file content is dynamically created in build script
|
|
2
|
+
"use strict";
|
|
3
|
+
module.exports = {
|
|
4
|
+
'inherits': require('inherits'),
|
|
5
|
+
'util': require('util'),
|
|
6
|
+
'events': require('events'),
|
|
7
|
+
'lodash/core': require('lodash/core'),
|
|
8
|
+
'readable-stream': require('readable-stream'),
|
|
9
|
+
'multistream': require('multistream'),
|
|
10
|
+
'./VERSION': require('./VERSION'),
|
|
11
|
+
'./cache': require('./cache'),
|
|
12
|
+
'./connection': require('./connection'),
|
|
13
|
+
'./core': require('./core'),
|
|
14
|
+
'./csv': require('./csv'),
|
|
15
|
+
'./date': require('./date'),
|
|
16
|
+
'./http-api': require('./http-api'),
|
|
17
|
+
'./logger': require('./logger'),
|
|
18
|
+
'./oauth2': require('./oauth2'),
|
|
19
|
+
'./process': require('./process'),
|
|
20
|
+
'./promise': require('./promise'),
|
|
21
|
+
'./query': require('./query'),
|
|
22
|
+
'./quick-action': require('./quick-action'),
|
|
23
|
+
'./record-stream': require('./record-stream'),
|
|
24
|
+
'./record': require('./record'),
|
|
25
|
+
'./soap': require('./soap'),
|
|
26
|
+
'./sobject': require('./sobject'),
|
|
27
|
+
'./soql-builder': require('./soql-builder'),
|
|
28
|
+
'./transport': require('./transport')
|
|
29
|
+
};
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Manages Salesforce Analytics API
|
|
3
|
+
* @author Shinichi Tomita <shinichi.tomita@gmail.com>
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
var _ = require('lodash/core'),
|
|
9
|
+
jsforce = require('../core'),
|
|
10
|
+
Promise = require('../promise');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Report instance to retrieving asynchronously executed result
|
|
14
|
+
*
|
|
15
|
+
* @protected
|
|
16
|
+
* @class Analytics~ReportInstance
|
|
17
|
+
* @param {Analytics~Report} report - Report
|
|
18
|
+
* @param {String} id - Report instance id
|
|
19
|
+
*/
|
|
20
|
+
var ReportInstance = function(report, id) {
|
|
21
|
+
this._report = report;
|
|
22
|
+
this._conn = report._conn;
|
|
23
|
+
this.id = id;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Retrieve report result asynchronously executed
|
|
28
|
+
*
|
|
29
|
+
* @method Analytics~ReportInstance#retrieve
|
|
30
|
+
* @param {Callback.<Analytics~ReportResult>} [callback] - Callback function
|
|
31
|
+
* @returns {Promise.<Analytics~ReportResult>}
|
|
32
|
+
*/
|
|
33
|
+
ReportInstance.prototype.retrieve = function(callback) {
|
|
34
|
+
var conn = this._conn,
|
|
35
|
+
report = this._report;
|
|
36
|
+
var url = [ conn._baseUrl(), "analytics", "reports", report.id, "instances", this.id ].join('/');
|
|
37
|
+
return conn.request(url).thenCall(callback);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Report object in Analytics API
|
|
42
|
+
*
|
|
43
|
+
* @protected
|
|
44
|
+
* @class Analytics~Report
|
|
45
|
+
* @param {Connection} conn Connection
|
|
46
|
+
*/
|
|
47
|
+
var Report = function(conn, id) {
|
|
48
|
+
this._conn = conn;
|
|
49
|
+
this.id = id;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Describe report metadata
|
|
54
|
+
*
|
|
55
|
+
* @method Analytics~Report#describe
|
|
56
|
+
* @param {Callback.<Analytics~ReportMetadata>} [callback] - Callback function
|
|
57
|
+
* @returns {Promise.<Analytics~ReportMetadata>}
|
|
58
|
+
*/
|
|
59
|
+
Report.prototype.describe = function(callback) {
|
|
60
|
+
var url = [ this._conn._baseUrl(), "analytics", "reports", this.id, "describe" ].join('/');
|
|
61
|
+
return this._conn.request(url).thenCall(callback);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Synonym of Analytics~Report#destroy()
|
|
66
|
+
*
|
|
67
|
+
* @method Analytics~Report#delete
|
|
68
|
+
* @param {Callback.<Analytics~ReportResult>} [callback] - Callback function
|
|
69
|
+
* @returns {Promise.<Analytics~ReportResult>}
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* Synonym of Analytics~Report#destroy()
|
|
73
|
+
*
|
|
74
|
+
* @method Analytics~Report#del
|
|
75
|
+
* @param {Callback.<Analytics~ReportResult>} [callback] - Callback function
|
|
76
|
+
* @returns {Promise.<Analytics~ReportResult>}
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* Destroy a report
|
|
80
|
+
*
|
|
81
|
+
* @method Analytics~Report#destroy
|
|
82
|
+
* @param {Callback.<Analytics~ReportResult>} [callback] - Callback function
|
|
83
|
+
* @returns {Promise.<Analytics~ReportResult>}
|
|
84
|
+
*/
|
|
85
|
+
Report.prototype["delete"] =
|
|
86
|
+
Report.prototype.del =
|
|
87
|
+
Report.prototype.destroy = function(callback) {
|
|
88
|
+
var url = [ this._conn._baseUrl(), "analytics", "reports", this.id ].join('/');
|
|
89
|
+
return this._conn.request({method: 'DELETE', url: url}).thenCall(callback);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Clones a given report
|
|
94
|
+
*
|
|
95
|
+
* @method Analytics~Report#clone
|
|
96
|
+
* @param {String} name - The name of the new report
|
|
97
|
+
* @param {Callback.<Analytics~ReportResult>} [callback] - Callback function
|
|
98
|
+
* @returns {Promise.<Analytics~ReportResult>}
|
|
99
|
+
*/
|
|
100
|
+
Report.prototype.clone = function(name, callback) {
|
|
101
|
+
var url = [ this._conn._baseUrl(), "analytics", "reports" ].join('/');
|
|
102
|
+
url += "?cloneId=" + this.id;
|
|
103
|
+
var data = { reportMetadata: { name: name } };
|
|
104
|
+
var params = { method : 'POST', url: url, headers: { "Content-Type" : "application/json" }, body: JSON.stringify(data)};
|
|
105
|
+
|
|
106
|
+
return this._conn.request(params).thenCall(callback);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Explain plan for executing report
|
|
111
|
+
*
|
|
112
|
+
* @method Analytics~Report#explain
|
|
113
|
+
* @param {Callback.<ExplainInfo>} [callback] - Callback function
|
|
114
|
+
* @returns {Promise.<ExplainInfo>}
|
|
115
|
+
*/
|
|
116
|
+
Report.prototype.explain = function(callback) {
|
|
117
|
+
var url = "/query/?explain=" + this.id;
|
|
118
|
+
return this._conn.request(url).thenCall(callback);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Run report synchronously
|
|
124
|
+
*
|
|
125
|
+
* @method Analytics~Report#execute
|
|
126
|
+
* @param {Object} [options] - Options
|
|
127
|
+
* @param {Boolean} options.details - Flag if include detail in result
|
|
128
|
+
* @param {Analytics~ReportMetadata} options.metadata - Overriding report metadata
|
|
129
|
+
* @param {Callback.<Analytics~ReportResult>} [callback] - Callback function
|
|
130
|
+
* @returns {Promise.<Analytics~ReportResult>}
|
|
131
|
+
*/
|
|
132
|
+
Report.prototype.run =
|
|
133
|
+
Report.prototype.exec =
|
|
134
|
+
Report.prototype.execute = function(options, callback) {
|
|
135
|
+
options = options || {};
|
|
136
|
+
if (_.isFunction(options)) {
|
|
137
|
+
callback = options;
|
|
138
|
+
options = {};
|
|
139
|
+
}
|
|
140
|
+
var url = [ this._conn._baseUrl(), "analytics", "reports", this.id ].join('/');
|
|
141
|
+
url += "?includeDetails=" + (options.details ? "true" : "false");
|
|
142
|
+
var params = { method : options.metadata ? 'POST' : 'GET', url : url };
|
|
143
|
+
if (options.metadata) {
|
|
144
|
+
params.headers = { "Content-Type" : "application/json" };
|
|
145
|
+
params.body = JSON.stringify(options.metadata);
|
|
146
|
+
}
|
|
147
|
+
return this._conn.request(params).thenCall(callback);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Run report asynchronously
|
|
153
|
+
*
|
|
154
|
+
* @method Analytics~Report#executeAsync
|
|
155
|
+
* @param {Object} [options] - Options
|
|
156
|
+
* @param {Boolean} options.details - Flag if include detail in result
|
|
157
|
+
* @param {Analytics~ReportMetadata} options.metadata - Overriding report metadata
|
|
158
|
+
* @param {Callback.<Analytics~ReportInstanceAttrs>} [callback] - Callback function
|
|
159
|
+
* @returns {Promise.<Analytics~ReportInstanceAttrs>}
|
|
160
|
+
*/
|
|
161
|
+
Report.prototype.executeAsync = function(options, callback) {
|
|
162
|
+
options = options || {};
|
|
163
|
+
if (_.isFunction(options)) {
|
|
164
|
+
callback = options;
|
|
165
|
+
options = {};
|
|
166
|
+
}
|
|
167
|
+
var url = [ this._conn._baseUrl(), "analytics", "reports", this.id, "instances" ].join('/');
|
|
168
|
+
if (options.details) {
|
|
169
|
+
url += "?includeDetails=true";
|
|
170
|
+
}
|
|
171
|
+
var params = { method : 'POST', url : url, body: "" };
|
|
172
|
+
if (options.metadata) {
|
|
173
|
+
params.headers = { "Content-Type" : "application/json" };
|
|
174
|
+
params.body = JSON.stringify(options.metadata);
|
|
175
|
+
}
|
|
176
|
+
return this._conn.request(params).thenCall(callback);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Get report instance for specified instance ID
|
|
181
|
+
*
|
|
182
|
+
* @method Analytics~Report#instance
|
|
183
|
+
* @param {String} id - Report instance ID
|
|
184
|
+
* @returns {Analytics~ReportInstance}
|
|
185
|
+
*/
|
|
186
|
+
Report.prototype.instance = function(id) {
|
|
187
|
+
return new ReportInstance(this, id);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* List report instances which had been executed asynchronously
|
|
192
|
+
*
|
|
193
|
+
* @method Analytics~Report#instances
|
|
194
|
+
* @param {Callback.<Array.<Analytics~ReportInstanceAttrs>>} [callback] - Callback function
|
|
195
|
+
* @returns {Promise.<Array.<Analytics~ReportInstanceAttrs>>}
|
|
196
|
+
*/
|
|
197
|
+
Report.prototype.instances = function(callback) {
|
|
198
|
+
var url = [ this._conn._baseUrl(), "analytics", "reports", this.id, "instances" ].join('/');
|
|
199
|
+
return this._conn.request(url).thenCall(callback);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Dashboard object in the Analytics API
|
|
204
|
+
*
|
|
205
|
+
* @protected
|
|
206
|
+
* @class Analytics-Dashboard
|
|
207
|
+
* @param {Connection} conn Connection
|
|
208
|
+
* @param {String} id - The Id
|
|
209
|
+
*/
|
|
210
|
+
|
|
211
|
+
var Dashboard = function(conn, id) {
|
|
212
|
+
this._conn = conn;
|
|
213
|
+
this.id = id;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Describe dashboard metadata
|
|
218
|
+
*
|
|
219
|
+
* @method Analytics~Dashboard#describe
|
|
220
|
+
* @param {Callback.<Analytics-DashboardMetadata>} [callback] - Callback function
|
|
221
|
+
* @returns {Promise.<Analytics-DashboardMetadata>}
|
|
222
|
+
*/
|
|
223
|
+
Dashboard.prototype.describe = function(callback) {
|
|
224
|
+
var url = [ this._conn._baseUrl(), "analytics", "dashboards", this.id, "describe" ].join('/');
|
|
225
|
+
return this._conn.request(url).thenCall(callback);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Get details about dashboard components
|
|
230
|
+
*
|
|
231
|
+
* @method Analytics~Dashboard#components
|
|
232
|
+
* @param {Callback.<Analytics-DashboardComponentMetadata>} [callback] - Callback function
|
|
233
|
+
* @returns {Promise.<Analytics-DashboardComponentMetadata>}
|
|
234
|
+
*/
|
|
235
|
+
Dashboard.prototype.components = function(componentIds, callback) {
|
|
236
|
+
var url = [ this._conn._baseUrl(), "analytics", "dashboards", this.id].join('/');
|
|
237
|
+
var data = {};
|
|
238
|
+
if (_.isFunction(componentIds)) {
|
|
239
|
+
callback = componentIds;
|
|
240
|
+
} else if (_.isArray(componentIds)) {
|
|
241
|
+
data.componentIds = componentIds;
|
|
242
|
+
} else if (_.isString(componentIds)) {
|
|
243
|
+
data.componentIds = [ componentIds ];
|
|
244
|
+
}
|
|
245
|
+
var params = { method : 'POST', url : url, headers : { "Content-Type" : "application/json" }, body : JSON.stringify(data)};
|
|
246
|
+
return this._conn.request(params).thenCall(callback);
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Get dashboard status
|
|
251
|
+
*
|
|
252
|
+
* @method Analytics~Dashboard#status
|
|
253
|
+
* @param {Callback.<Analytics-DashboardStatusMetadata>} [callback] - Callback function
|
|
254
|
+
* @returns {Promise.<Analytics-DashboardStatusMetadata>}
|
|
255
|
+
*/
|
|
256
|
+
Dashboard.prototype.status = function(callback) {
|
|
257
|
+
var url = [ this._conn._baseUrl(), "analytics", "dashboards", this.id, "status" ].join('/');
|
|
258
|
+
return this._conn.request(url).thenCall(callback);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Refresh a dashboard
|
|
263
|
+
*
|
|
264
|
+
* @method Analytics~Dashboard#refresh
|
|
265
|
+
* @param {Callback.<Analytics-DashboardStatusUrl>} [callback] - Callback function
|
|
266
|
+
* @returns {Promise.<Analytics-DashboardStatusUrl>}
|
|
267
|
+
*/
|
|
268
|
+
Dashboard.prototype.refresh = function(callback) {
|
|
269
|
+
var url = [ this._conn._baseUrl(), "analytics", "dashboards", this.id ].join('/');
|
|
270
|
+
var params = { method : 'PUT', url : url, body: '' };
|
|
271
|
+
return this._conn.request(params).thenCall(callback);
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Clone a dashboard
|
|
276
|
+
*
|
|
277
|
+
* @method Analytics~Dashboard#clone
|
|
278
|
+
* @param {Callback.<Analytics-DashboardMetadata>} [callback] - Callback function
|
|
279
|
+
* @returns {Promise.<Analytics-DashboardMetadata>}
|
|
280
|
+
*/
|
|
281
|
+
Dashboard.prototype.clone = function(name, folderid, callback) {
|
|
282
|
+
var url = [ this._conn._baseUrl(), "analytics", "dashboards" ].join('/');
|
|
283
|
+
url += "?cloneId=" + this.id;
|
|
284
|
+
var data = {};
|
|
285
|
+
|
|
286
|
+
if (_.isObject(name)) {
|
|
287
|
+
data = name;
|
|
288
|
+
callback = folderid;
|
|
289
|
+
} else {
|
|
290
|
+
data.name = name;
|
|
291
|
+
data.folderId = folderid;
|
|
292
|
+
}
|
|
293
|
+
var params = { method : 'POST', url : url, headers : { "Content-Type" : "application/json" }, body : JSON.stringify(data)};
|
|
294
|
+
|
|
295
|
+
return this._conn.request(params).thenCall(callback);
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Synonym of Analytics~Dashboard#destroy()
|
|
300
|
+
*
|
|
301
|
+
* @method Analytics~Dashboard#delete
|
|
302
|
+
* @param {Callback.<Analytics~DashboardResult>} [callback] - Callback function
|
|
303
|
+
* @returns {Promise.<Analytics~DashboardResult>}
|
|
304
|
+
*/
|
|
305
|
+
/**
|
|
306
|
+
* Synonym of Analytics~Dashboard#destroy()
|
|
307
|
+
*
|
|
308
|
+
* @method Analytics~Dashboard#del
|
|
309
|
+
* @param {Callback.<Analytics~DashboardResult>} [callback] - Callback function
|
|
310
|
+
* @returns {Promise.<Analytics~DashboardResult>}
|
|
311
|
+
*/
|
|
312
|
+
/**
|
|
313
|
+
* Destroy a dashboard
|
|
314
|
+
*
|
|
315
|
+
* @method Analytics~Dashboard#destroy
|
|
316
|
+
* @param {Callback.<Analytics~DashboardResult>} [callback] - Callback function
|
|
317
|
+
* @returns {Promise.<Analytics~DashboardResult>}
|
|
318
|
+
*/
|
|
319
|
+
Dashboard.prototype["delete"] =
|
|
320
|
+
Dashboard.prototype.del =
|
|
321
|
+
Dashboard.prototype.destroy = function(callback) {
|
|
322
|
+
var url = [ this._conn._baseUrl(), "analytics", "dashboards", this.id ].join('/');
|
|
323
|
+
return this._conn.request({method: 'DELETE', url: url}).thenCall(callback);
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* API class for Analytics API
|
|
328
|
+
*
|
|
329
|
+
* @class
|
|
330
|
+
* @param {Connection} conn Connection
|
|
331
|
+
*/
|
|
332
|
+
var Analytics = function(conn) {
|
|
333
|
+
this._conn = conn;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Get report object of Analytics API
|
|
338
|
+
*
|
|
339
|
+
* @param {String} id - Report Id
|
|
340
|
+
* @returns {Analytics~Report}
|
|
341
|
+
*/
|
|
342
|
+
Analytics.prototype.report = function(id) {
|
|
343
|
+
return new Report(this._conn, id);
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Get recent report list
|
|
348
|
+
*
|
|
349
|
+
* @param {Callback.<Array.<Analytics~ReportInfo>>} [callback] - Callback function
|
|
350
|
+
* @returns {Promise.<Array.<Analytics~ReportInfo>>}
|
|
351
|
+
*/
|
|
352
|
+
Analytics.prototype.reports = function(callback) {
|
|
353
|
+
var url = [ this._conn._baseUrl(), "analytics", "reports" ].join('/');
|
|
354
|
+
return this._conn.request(url).thenCall(callback);
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Get dashboard object of Analytics API
|
|
359
|
+
*
|
|
360
|
+
* @param {String} id - Dashboard Id
|
|
361
|
+
* @returns {Analytics~Dashboard}
|
|
362
|
+
*/
|
|
363
|
+
Analytics.prototype.dashboard = function(id) {
|
|
364
|
+
return new Dashboard(this._conn, id);
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Get recent dashboard list
|
|
369
|
+
*
|
|
370
|
+
* @param {Callback.<Array.<Analytics~DashboardInfo>>} [callback] - Callback function
|
|
371
|
+
* @returns {Promise.<Array.<Analytics~DashboardInfo>>}
|
|
372
|
+
*/
|
|
373
|
+
Analytics.prototype.dashboards = function(callback) {
|
|
374
|
+
var url = [ this._conn._baseUrl(), "analytics", "dashboards" ].join('/');
|
|
375
|
+
return this._conn.request(url).thenCall(callback);
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
/*--------------------------------------------*/
|
|
379
|
+
/*
|
|
380
|
+
* Register hook in connection instantiation for dynamically adding this API module features
|
|
381
|
+
*/
|
|
382
|
+
jsforce.on('connection:new', function(conn) {
|
|
383
|
+
conn.analytics = new Analytics(conn);
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
module.exports = Analytics;
|
package/lib/api/apex.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Manages Salesforce Apex REST endpoint calls
|
|
3
|
+
* @author Shinichi Tomita <shinichi.tomita@gmail.com>
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
var jsforce = require('../core');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* API class for Apex REST endpoint call
|
|
12
|
+
*
|
|
13
|
+
* @class
|
|
14
|
+
* @param {Connection} conn Connection
|
|
15
|
+
*/
|
|
16
|
+
var Apex = function(conn) {
|
|
17
|
+
this._conn = conn;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
Apex.prototype._baseUrl = function() {
|
|
24
|
+
return this._conn.instanceUrl + "/services/apexrest";
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
Apex.prototype._createRequestParams = function(method, path, body, options) {
|
|
31
|
+
var params = {
|
|
32
|
+
method: method,
|
|
33
|
+
url: this._baseUrl() + path
|
|
34
|
+
},
|
|
35
|
+
_headers = {};
|
|
36
|
+
if(options && 'object' === typeof options['headers']){
|
|
37
|
+
_headers = options['headers'];
|
|
38
|
+
}
|
|
39
|
+
if (!/^(GET|DELETE)$/i.test(method)) {
|
|
40
|
+
_headers["Content-Type"] = "application/json";
|
|
41
|
+
}
|
|
42
|
+
params.headers = _headers;
|
|
43
|
+
if (body) {
|
|
44
|
+
var contentType = params.headers["Content-Type"];
|
|
45
|
+
if (!contentType || contentType === "application/json") {
|
|
46
|
+
params.body = JSON.stringify(body);
|
|
47
|
+
} else {
|
|
48
|
+
params.body = body;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return params;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Call Apex REST service in GET request
|
|
56
|
+
*
|
|
57
|
+
* @param {String} path - URL path to Apex REST service
|
|
58
|
+
* @param {Object} options - Holds headers and other meta data for the request.
|
|
59
|
+
* @param {Callback.<Object>} [callback] - Callback function
|
|
60
|
+
* @returns {Promise.<Object>}
|
|
61
|
+
*/
|
|
62
|
+
Apex.prototype.get = function(path, options, callback) {
|
|
63
|
+
if (typeof options === 'function') {
|
|
64
|
+
callback = options;
|
|
65
|
+
options = undefined;
|
|
66
|
+
}
|
|
67
|
+
return this._conn.request(this._createRequestParams('GET', path, undefined, options)).thenCall(callback);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Call Apex REST service in POST request
|
|
72
|
+
*
|
|
73
|
+
* @param {String} path - URL path to Apex REST service
|
|
74
|
+
* @param {Object} [body] - Request body
|
|
75
|
+
* @param {Object} options - Holds headers and other meta data for the request.
|
|
76
|
+
* @param {Callback.<Object>} [callback] - Callback function
|
|
77
|
+
* @returns {Promise.<Object>}
|
|
78
|
+
*/
|
|
79
|
+
Apex.prototype.post = function(path, body, options, callback) {
|
|
80
|
+
if (typeof body === 'function') {
|
|
81
|
+
callback = body;
|
|
82
|
+
body = undefined;
|
|
83
|
+
options = undefined;
|
|
84
|
+
}
|
|
85
|
+
if (typeof options === 'function') {
|
|
86
|
+
callback = options;
|
|
87
|
+
options = undefined;
|
|
88
|
+
}
|
|
89
|
+
var params = this._createRequestParams('POST', path, body, options);
|
|
90
|
+
return this._conn.request(params).thenCall(callback);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Call Apex REST service in PUT request
|
|
95
|
+
*
|
|
96
|
+
* @param {String} path - URL path to Apex REST service
|
|
97
|
+
* @param {Object} [body] - Request body
|
|
98
|
+
* @param {Object} [options] - Holds headers and other meta data for the request.
|
|
99
|
+
* @param {Callback.<Object>} [callback] - Callback function
|
|
100
|
+
* @returns {Promise.<Object>}
|
|
101
|
+
*/
|
|
102
|
+
Apex.prototype.put = function(path, body, options, callback) {
|
|
103
|
+
if (typeof body === 'function') {
|
|
104
|
+
callback = body;
|
|
105
|
+
body = undefined;
|
|
106
|
+
options = undefined;
|
|
107
|
+
}
|
|
108
|
+
if (typeof options === 'function') {
|
|
109
|
+
callback = options;
|
|
110
|
+
options = undefined;
|
|
111
|
+
}
|
|
112
|
+
var params = this._createRequestParams('PUT', path, body, options);
|
|
113
|
+
return this._conn.request(params).thenCall(callback);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Call Apex REST service in PATCH request
|
|
118
|
+
*
|
|
119
|
+
* @param {String} path - URL path to Apex REST service
|
|
120
|
+
* @param {Object} [body] - Request body
|
|
121
|
+
* @param {Object} [options] - Holds headers and other meta data for the request.
|
|
122
|
+
* @param {Callback.<Object>} [callback] - Callback function
|
|
123
|
+
* @returns {Promise.<Object>}
|
|
124
|
+
*/
|
|
125
|
+
Apex.prototype.patch = function(path, body, options, callback) {
|
|
126
|
+
if (typeof body === 'function') {
|
|
127
|
+
callback = body;
|
|
128
|
+
body = undefined;
|
|
129
|
+
options = undefined;
|
|
130
|
+
}
|
|
131
|
+
if (typeof options === 'function') {
|
|
132
|
+
callback = options;
|
|
133
|
+
options = undefined;
|
|
134
|
+
}
|
|
135
|
+
var params = this._createRequestParams('PATCH', path, body, options);
|
|
136
|
+
return this._conn.request(params).thenCall(callback);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Synonym of Apex#delete()
|
|
141
|
+
*
|
|
142
|
+
* @method Apex#del
|
|
143
|
+
*
|
|
144
|
+
* @param {String} path - URL path to Apex REST service
|
|
145
|
+
* @param {Callback.<Object>} [callback] - Callback function
|
|
146
|
+
* @returns {Promise.<Object>}
|
|
147
|
+
*/
|
|
148
|
+
/**
|
|
149
|
+
* Call Apex REST service in DELETE request
|
|
150
|
+
*
|
|
151
|
+
* @method Apex#delete
|
|
152
|
+
*
|
|
153
|
+
* @param {String} path - URL path to Apex REST service
|
|
154
|
+
* @param {Object} [options] - Holds headers and other meta data for the request.
|
|
155
|
+
* @param {Callback.<Object>} [callback] - Callback function
|
|
156
|
+
* @returns {Promise.<Object>}
|
|
157
|
+
*/
|
|
158
|
+
Apex.prototype.del =
|
|
159
|
+
Apex.prototype["delete"] = function(path, options, callback) {
|
|
160
|
+
if (typeof options === 'function') {
|
|
161
|
+
callback = options;
|
|
162
|
+
options = undefined;
|
|
163
|
+
}
|
|
164
|
+
return this._conn.request(this._createRequestParams('DELETE', path, undefined, options)).thenCall(callback);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
/*--------------------------------------------*/
|
|
169
|
+
/*
|
|
170
|
+
* Register hook in connection instantiation for dynamically adding this API module features
|
|
171
|
+
*/
|
|
172
|
+
jsforce.on('connection:new', function(conn) {
|
|
173
|
+
conn.apex = new Apex(conn);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
module.exports = Apex;
|