Skip to content

Commit 23aaa04

Browse files
authored
chore: update to v3 (#18)
1 parent f54f96d commit 23aaa04

12 files changed

+58
-22801
lines changed

docpad.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
docpadConfig = {
77

88
templateData:
9-
version: '1.9.1'
9+
version: '3.2.2'
1010
apiVersion: "42.0"
1111
site:
1212
url: "http://jsforce.github.io"

src/documents/download/index.html.md.eco

+6-27
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,19 @@ To locally download these files, right-click the link and select "Save as..." fr
1717

1818

1919
### All in One Library (jsforce.js)
20-
- [Development Version (v<%= @version %>)](//cdnjs.cloudflare.com/ajax/libs/jsforce/<%= @version %>/jsforce.js) - Full source, Uncompressed
21-
- [Production Version (v<%= @version %>)](//cdnjs.cloudflare.com/ajax/libs/jsforce/<%= @version %>/jsforce.min.js) - Compressed / [SourceMap](//cdnjs.cloudflare.com/ajax/libs/jsforce/<%= @version %>/jsforce.min.js.map)
22-
- [Edge Version (master)](https://raw.github.com/jsforce/jsforce/master/build/jsforce.js) - Unreleased, use at your own risk
20+
- [Development Version (v<%= @version %>)](https://cdn.jsdelivr.net/npm/jsforce@<%= @version %>/dist/jsforce.js) - Full source, Uncompressed
21+
- [Production Version (v<%= @version %>)](https://cdn.jsdelivr.net/npm/jsforce@<%= @version %>/dist/jsforce.min.js) - Compressed / [SourceMap](https://cdn.jsdelivr.net/npm/jsforce@<%= @version %>/dist/jsforce.min.js.map)
2322

2423
### Core (jsforce-core.js)
25-
- [Development Version (v<%= @version %>)](//cdnjs.cloudflare.com/ajax/libs/jsforce/<%= @version %>/jsforce-core.js) - Full source, Uncompressed
26-
- [Production Version (v<%= @version %>)](//cdnjs.cloudflare.com/ajax/libs/jsforce/<%= @version %>/jsforce-core.min.js) - Compressed / [SourceMap](//cdnjs.cloudflare.com/ajax/libs/jsforce/<%= @version %>/jsforce-core.min.js.map)
27-
28-
<% for apiname in "analytics,apex,bulk,chatter,metadata,soap,streaming,tooling".split(',') : %>
29-
### <%= apiname[0].toUpperCase() + apiname.substring(1) %> API (jsforce-api-<%= apiname %>.js)
30-
- [Development Version (v<%= @version %>)](//cdnjs.cloudflare.com/ajax/libs/jsforce/<%= @version %>/jsforce-api-<%= apiname %>.js) - Full source, Uncompressed
31-
- [Production Version (v<%= @version %>)](//cdnjs.cloudflare.com/ajax/libs/jsforce/<%= @version %>/jsforce-api-<%= apiname %>.min.js) - Compressed / [SourceMap](//cdnjs.cloudflare.com/ajax/libs/jsforce/<%= @version %>/jsforce-api-<%= apiname %>.min.js.map)
32-
<% end %>
33-
34-
## Using Bower
35-
36-
[Bower](http://bower.io/) is a package manager for web application front-end libraries. JSforce is also available in bower. To install JSforce via bower, type following in your project root:
37-
38-
```
39-
$ bower install jsforce
40-
```
41-
42-
You'll get the JSforce script files in `bower_components` directory, so write a tag in HTML to include the file.
43-
44-
```html
45-
<script src="./bower_components/jsforce/build/jsforce.min.js"></script>
46-
```
24+
- [Development Version (v<%= @version %>)](https://cdn.jsdelivr.net/npm/jsforce@<%= @version %>/dist/jsforce-core.js) - Full source, Uncompressed
25+
- [Production Version (v<%= @version %>)](https://cdn.jsdelivr.net/npm/jsforce@<%= @version %>/dist/jsforce-core.min.js) - Compressed / [SourceMap](https://cdn.jsdelivr.net/npm/jsforce@<%= @version %>/dist/jsforce-core.min.js.map)
4726

4827
## Using CDN
4928

50-
JSforce is available from CDN. You can include source directly from [cdnjs](http://cdnjs.com/) so download is not always necessary.
29+
JSforce is available from CDNs. You can load it directly from [jsDelivr](https://www.jsdelivr.com/) so download is not always necessary.
5130

5231
To include the script, put following script tag :
5332

5433
```
55-
<script src="//cdnjs.cloudflare.com/ajax/libs/jsforce/<%= @version %>/jsforce.min.js"></script>
34+
<script src="https://cdn.jsdelivr.net/npm/jsforce@<%= @version %>/dist/jsforce.min.js"></script>
5635
```

src/documents/js/main.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ $(function() {
5151
return;
5252
}
5353
var codeEl = getCodeElement(this);
54-
var code = codeEl.text();
54+
// need to wrap in async IIFE for examples using `await` in top-level
55+
var code = `(async() => { ${codeEl.text()} })()`;
5556
var context = {
5657
jsforce: window.jsforce,
5758
require: function(name){ return window[name]; },

src/documents/start/index.html.md.eco

+24-55
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ so you can learn the usage without hassle.
2424
- [Apex REST](/document/#apex-rest)
2525
- [Analytics API](/document/#analytics-api)
2626
- [Bulk API](/document/#bulk-api)
27+
- [Bulk 2.0 API](/document/#bulk-v2-api)
2728
- [Chatter API](/document/#chatter-api)
2829
- [Metadata API](/document/#metadata-api)
2930
- [Streaming API](/document/#streaming-api)
@@ -39,14 +40,24 @@ If you want to use JSforce as an API library in your Node.js project, install it
3940
$ npm install jsforce
4041
```
4142

43+
NOTE:
44+
the `jsforce` npm package includes the browser bundles + minified builds, TS source code and other deps that will not be used in a Node.js environment.
45+
For these cases we provide a slim, node-only package that strips these artifacts and deps.
46+
47+
``` shell
48+
$ npm install @jsforce/jsforce-node
49+
```
50+
51+
Aside from being smaller, there's no API differences between `jsforce` and `jsforce-node`.
52+
4253
When you installed JSforce, you can import using `require('jsforce')` in your Node.js application code.
4354

4455
``` javascript
45-
var jsforce = require('jsforce');
46-
var conn = new jsforce.Connection();
56+
const jsforce = require('jsforce');
57+
const conn = new jsforce.Connection();
4758
```
4859

49-
Details for establishing API connection are written in the [document](/document/#connection) and options are in [API reference](/jsforce/doc/Connection.html).
60+
Details for establishing API connection are written in the [document](/document/#connection) and options are in [API reference](/jsforce/classes/connection.Connection.html).
5061

5162

5263
### Web Browser
@@ -61,7 +72,7 @@ If you want to use JSforce in web browser JavaScript,
6172
Or you can use public CDN to include script directly to your web site.
6273

6374
```html
64-
<script src="//cdnjs.cloudflare.com/ajax/libs/jsforce/<%= @version %>/jsforce.min.js"></script>
75+
<script src="https://cdn.jsdelivr.net/npm/jsforce@<%= @version %>/dist/jsforce.min.js"></script>
6576
```
6677

6778
When the script is loaded, `jsforce` object will be defined in global root.
@@ -120,10 +131,8 @@ Afterward you can get authorized API connection by listening `connect` event on
120131

121132
```javascript
122133
jsforce.browser.on('connect', function(conn) {
123-
conn.query('SELECT Id, Name FROM Account', function(err, res) {
124-
if (err) { return handleError(err); }
125-
handleResult(res);
126-
});
134+
const res = await conn.query('SELECT Id, Name FROM Account')
135+
console.log(res);
127136
});
128137
```
129138

@@ -138,12 +147,9 @@ Also you can use static resources to upload JSforce JavaScript file to include.
138147
<apex:page docType="html-5.0" showHeader="false">
139148
<apex:includeScript value="{!URLFOR($Resource.JSforce)}" />
140149
<script>
141-
var conn = new jsforce.Connection({ accessToken: '{!$API.Session_Id}' });
142-
conn.query('SELECT Id, Name FROM Account', function(err, res) {
143-
if (err) { return handleError(err); }
144-
handleResult(res);
145-
});
146-
150+
const conn = new jsforce.Connection({ accessToken: '{!$API.Session_Id}' });
151+
const res = await conn.query('SELECT Id, Name FROM Account');
152+
console.log(res);
147153
// ...
148154

149155
</script>
@@ -167,12 +173,10 @@ Also you have to load canvas JS SDK officially provided from Salesforce.
167173
<script src="https://login.salesforce.com/canvas/sdk/js/<%= @apiVersion %>/canvas-all.js"></script>
168174
<script src="/js/jsforce.js"></script>
169175
<script>
170-
var sr = document.getElementById('sf-canvas-signed-request').content;
171-
var conn = new jsforce.Connection({ signedRequest: sr });
172-
conn.query('SELECT Id, Name FROM Account', function(err, res) {
173-
if (err) { return handleError(err); }
174-
handleResult(res);
175-
});
176+
let sr = document.getElementById('sf-canvas-signed-request').content;
177+
const conn = new jsforce.Connection({ signedRequest: sr });
178+
const res = await conn.query('SELECT Id, Name FROM Account');
179+
console.log(res);
176180

177181
//...
178182

@@ -189,41 +193,6 @@ When you established the connection, you can call APIs defined in connection obj
189193

190194
By JavaScript's nature, all API calls are done asynchronously.
191195

192-
### Using Callback
193-
194-
As broadly used in other JavaScript APIs, you can pass a callback function to wait and get the async response.
195-
196-
The callback function has the same interface as normal Node.js callback, accepting two arguments - error and successful result.
197-
198-
```javascript
199-
conn.query("SELECT Id, Name FROM Account LIMIT 10", function(err, res) {
200-
if (err) { return handleError(err); }
201-
handleResult(res);
202-
});
203-
```
204-
205-
### Using Promise
206-
207-
JSforce supports [Promise/A+](http://promises-aplus.github.io/promises-spec/) spec,
208-
and almost all API calls return Promise object.
209-
So you can chain the promise result by `then()` to handle the async response.
210-
211-
```javascript
212-
conn.query("SELECT Id, Name FROM Account LIMIT 1")
213-
.then(function(res) {
214-
// receive resolved result from the promise,
215-
// then return another promise for continuing API execution.
216-
return conn.sobject('Account').create({ Name: 'Another Account' });
217-
})
218-
.then(function(ret) {
219-
// handle final result of API execution
220-
// ...
221-
}, function(err) {
222-
// catch any errors in execution
223-
// ...
224-
});
225-
```
226-
227196
## Command Line Interface
228197

229198
There is a Command Line Interface (CLI) which works on tty.

0 commit comments

Comments
 (0)