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.
- package/index.js +46 -1
- package/package.json +7 -105
- package/LICENSE +0 -22
- package/README.md +0 -74
- package/bin/jsforce +0 -3
- package/bower.json +0 -30
- package/build/jsforce-api-analytics.js +0 -393
- package/build/jsforce-api-analytics.min.js +0 -2
- package/build/jsforce-api-analytics.min.js.map +0 -1
- package/build/jsforce-api-apex.js +0 -183
- package/build/jsforce-api-apex.min.js +0 -2
- package/build/jsforce-api-apex.min.js.map +0 -1
- package/build/jsforce-api-bulk.js +0 -1054
- package/build/jsforce-api-bulk.min.js +0 -2
- package/build/jsforce-api-bulk.min.js.map +0 -1
- package/build/jsforce-api-chatter.js +0 -320
- package/build/jsforce-api-chatter.min.js +0 -2
- package/build/jsforce-api-chatter.min.js.map +0 -1
- package/build/jsforce-api-metadata.js +0 -3020
- package/build/jsforce-api-metadata.min.js +0 -2
- package/build/jsforce-api-metadata.min.js.map +0 -1
- package/build/jsforce-api-soap.js +0 -403
- package/build/jsforce-api-soap.min.js +0 -2
- package/build/jsforce-api-soap.min.js.map +0 -1
- package/build/jsforce-api-streaming.js +0 -3479
- package/build/jsforce-api-streaming.min.js +0 -2
- package/build/jsforce-api-streaming.min.js.map +0 -1
- package/build/jsforce-api-tooling.js +0 -319
- package/build/jsforce-api-tooling.min.js +0 -2
- package/build/jsforce-api-tooling.min.js.map +0 -1
- package/build/jsforce-core.js +0 -25250
- package/build/jsforce-core.min.js +0 -2
- package/build/jsforce-core.min.js.map +0 -1
- package/build/jsforce.js +0 -31637
- package/build/jsforce.min.js +0 -2
- package/build/jsforce.min.js.map +0 -1
- package/core.js +0 -1
- package/lib/VERSION.js +0 -2
- package/lib/_required.js +0 -29
- package/lib/api/analytics.js +0 -387
- package/lib/api/apex.js +0 -177
- package/lib/api/bulk.js +0 -862
- package/lib/api/chatter.js +0 -314
- package/lib/api/index.js +0 -8
- package/lib/api/metadata.js +0 -848
- package/lib/api/soap.js +0 -397
- package/lib/api/streaming-extension.js +0 -136
- package/lib/api/streaming.js +0 -270
- package/lib/api/tooling.js +0 -313
- package/lib/browser/canvas.js +0 -90
- package/lib/browser/client.js +0 -241
- package/lib/browser/core.js +0 -5
- package/lib/browser/jsforce.js +0 -6
- package/lib/browser/jsonp.js +0 -52
- package/lib/browser/request.js +0 -70
- package/lib/cache.js +0 -252
- package/lib/cli/cli.js +0 -431
- package/lib/cli/repl.js +0 -337
- package/lib/connection.js +0 -1881
- package/lib/core.js +0 -16
- package/lib/csv.js +0 -50
- package/lib/date.js +0 -163
- package/lib/http-api.js +0 -300
- package/lib/jsforce.js +0 -10
- package/lib/logger.js +0 -52
- package/lib/oauth2.js +0 -206
- package/lib/process.js +0 -275
- package/lib/promise.js +0 -164
- package/lib/query.js +0 -881
- package/lib/quick-action.js +0 -90
- package/lib/record-stream.js +0 -305
- package/lib/record.js +0 -107
- package/lib/registry/file-registry.js +0 -48
- package/lib/registry/index.js +0 -3
- package/lib/registry/registry.js +0 -111
- package/lib/require.js +0 -14
- package/lib/soap.js +0 -207
- package/lib/sobject.js +0 -558
- package/lib/soql-builder.js +0 -236
- package/lib/transport.js +0 -233
package/lib/soap.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Manages method call to SOAP endpoint
|
|
3
|
-
* @author Shinichi Tomita <shinichi.tomita@gmail.com>
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
var inherits = require('inherits'),
|
|
9
|
-
_ = require('lodash/core'),
|
|
10
|
-
xml2js = require('xml2js'),
|
|
11
|
-
HttpApi = require('./http-api');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Class for SOAP endpoint of Salesforce
|
|
16
|
-
*
|
|
17
|
-
* @protected
|
|
18
|
-
* @class
|
|
19
|
-
* @constructor
|
|
20
|
-
* @param {Connection} conn - Connection instance
|
|
21
|
-
* @param {Object} options - SOAP endpoint setting options
|
|
22
|
-
* @param {String} options.endpointUrl - SOAP endpoint URL
|
|
23
|
-
* @param {String} [options.xmlns] - XML namespace for method call (default is "urn:partner.soap.sforce.com")
|
|
24
|
-
*/
|
|
25
|
-
var SOAP = module.exports = function(conn, options) {
|
|
26
|
-
SOAP.super_.apply(this, arguments);
|
|
27
|
-
this._endpointUrl = options.endpointUrl;
|
|
28
|
-
this._xmlns = options.xmlns || 'urn:partner.soap.sforce.com';
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
inherits(SOAP, HttpApi);
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Invoke SOAP call using method and arguments
|
|
35
|
-
*
|
|
36
|
-
* @param {String} method - Method name
|
|
37
|
-
* @param {Object} args - Arguments for the method call
|
|
38
|
-
* @param {Object} [schema] - Schema definition of response message
|
|
39
|
-
* @param {Callback.<Object>} [callback] - Callback function
|
|
40
|
-
* @returns {Promise.<Object>}
|
|
41
|
-
*/
|
|
42
|
-
SOAP.prototype.invoke = function(method, args, schema, callback) {
|
|
43
|
-
if (typeof schema === 'function') {
|
|
44
|
-
callback = schema;
|
|
45
|
-
schema = null;
|
|
46
|
-
}
|
|
47
|
-
var message = {};
|
|
48
|
-
message[method] = args;
|
|
49
|
-
return this.request({
|
|
50
|
-
method: 'POST',
|
|
51
|
-
url: this._endpointUrl,
|
|
52
|
-
headers: {
|
|
53
|
-
'Content-Type': 'text/xml',
|
|
54
|
-
'SOAPAction': '""'
|
|
55
|
-
},
|
|
56
|
-
message: message
|
|
57
|
-
}).then(function(res) {
|
|
58
|
-
return schema ? convertType(res, schema) : res;
|
|
59
|
-
}).thenCall(callback);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/* @private */
|
|
63
|
-
function convertType(value, schema) {
|
|
64
|
-
if (_.isArray(value)) {
|
|
65
|
-
return value.map(function(v) {
|
|
66
|
-
return convertType(v, schema && schema[0])
|
|
67
|
-
});
|
|
68
|
-
} else if (_.isObject(value)) {
|
|
69
|
-
if (value.$ && value.$['xsi:nil'] === 'true') {
|
|
70
|
-
return null;
|
|
71
|
-
} else if (_.isArray(schema)) {
|
|
72
|
-
return [ convertType(value, schema[0]) ];
|
|
73
|
-
} else {
|
|
74
|
-
var o = {};
|
|
75
|
-
for (var key in value) {
|
|
76
|
-
o[key] = convertType(value[key], schema && schema[key]);
|
|
77
|
-
}
|
|
78
|
-
return o;
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
81
|
-
if (_.isArray(schema)) {
|
|
82
|
-
return [ convertType(value, schema[0]) ];
|
|
83
|
-
} else if (_.isObject(schema)) {
|
|
84
|
-
return {};
|
|
85
|
-
} else {
|
|
86
|
-
switch(schema) {
|
|
87
|
-
case 'string':
|
|
88
|
-
return String(value);
|
|
89
|
-
case 'number':
|
|
90
|
-
return Number(value);
|
|
91
|
-
case 'boolean':
|
|
92
|
-
return value === 'true';
|
|
93
|
-
default:
|
|
94
|
-
return value;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** @override **/
|
|
101
|
-
SOAP.prototype.beforeSend = function(request) {
|
|
102
|
-
request.body = this._createEnvelope(request.message);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
/** @override **/
|
|
106
|
-
SOAP.prototype.isSessionExpired = function(response) {
|
|
107
|
-
return response.statusCode === 500 &&
|
|
108
|
-
/<faultcode>[a-zA-Z]+:INVALID_SESSION_ID<\/faultcode>/.test(response.body);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
/** @override **/
|
|
112
|
-
SOAP.prototype.parseError = function(body) {
|
|
113
|
-
var error = lookupValue(body, [ /:Envelope$/, /:Body$/, /:Fault$/ ]);
|
|
114
|
-
return {
|
|
115
|
-
errorCode: error.faultcode,
|
|
116
|
-
message: error.faultstring
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/** @override **/
|
|
121
|
-
SOAP.prototype.getResponseBody = function(response) {
|
|
122
|
-
var body = SOAP.super_.prototype.getResponseBody.call(this, response);
|
|
123
|
-
return lookupValue(body, [ /:Envelope$/, /:Body$/, /.+/ ]);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @private
|
|
128
|
-
*/
|
|
129
|
-
function lookupValue(obj, propRegExps) {
|
|
130
|
-
var regexp = propRegExps.shift();
|
|
131
|
-
if (!regexp) {
|
|
132
|
-
return obj;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
for (var prop in obj) {
|
|
136
|
-
if (regexp.test(prop)) {
|
|
137
|
-
return lookupValue(obj[prop], propRegExps);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* @private
|
|
146
|
-
*/
|
|
147
|
-
function toXML(name, value) {
|
|
148
|
-
if (_.isObject(name)) {
|
|
149
|
-
value = name;
|
|
150
|
-
name = null;
|
|
151
|
-
}
|
|
152
|
-
if (_.isArray(value)) {
|
|
153
|
-
return _.map(value, function(v) { return toXML(name, v); }).join('');
|
|
154
|
-
} else {
|
|
155
|
-
var attrs = [];
|
|
156
|
-
var elems = [];
|
|
157
|
-
if (_.isObject(value)) {
|
|
158
|
-
for (var k in value) {
|
|
159
|
-
var v = value[k];
|
|
160
|
-
if (k[0] === '@') {
|
|
161
|
-
k = k.substring(1);
|
|
162
|
-
attrs.push(k + '="' + v + '"');
|
|
163
|
-
} else {
|
|
164
|
-
elems.push(toXML(k, v));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
value = elems.join('');
|
|
168
|
-
} else {
|
|
169
|
-
value = String(value)
|
|
170
|
-
.replace(/&/g, '&')
|
|
171
|
-
.replace(/</g, '<')
|
|
172
|
-
.replace(/>/g, '>')
|
|
173
|
-
.replace(/"/g, '"')
|
|
174
|
-
.replace(/'/g, ''');
|
|
175
|
-
}
|
|
176
|
-
var startTag = name ? '<' + name + (attrs.length > 0 ? ' ' + attrs.join(' ') : '') + '>' : '';
|
|
177
|
-
var endTag = name ? '</' + name + '>' : '';
|
|
178
|
-
return startTag + value + endTag;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* @private
|
|
184
|
-
*/
|
|
185
|
-
SOAP.prototype._createEnvelope = function(message) {
|
|
186
|
-
var header = {};
|
|
187
|
-
var conn = this._conn;
|
|
188
|
-
if (conn.accessToken) {
|
|
189
|
-
header.SessionHeader = { sessionId: this._conn.accessToken };
|
|
190
|
-
}
|
|
191
|
-
if (conn.callOptions) {
|
|
192
|
-
header.CallOptions = conn.callOptions;
|
|
193
|
-
}
|
|
194
|
-
return [
|
|
195
|
-
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
196
|
-
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"',
|
|
197
|
-
' xmlns:xsd="http://www.w3.org/2001/XMLSchema"',
|
|
198
|
-
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">',
|
|
199
|
-
'<soapenv:Header xmlns="' + this._xmlns + '">',
|
|
200
|
-
toXML(header),
|
|
201
|
-
'</soapenv:Header>',
|
|
202
|
-
'<soapenv:Body xmlns="' + this._xmlns + '">',
|
|
203
|
-
toXML(message),
|
|
204
|
-
'</soapenv:Body>',
|
|
205
|
-
'</soapenv:Envelope>'
|
|
206
|
-
].join('');
|
|
207
|
-
};
|