Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introducing JSforce 2.0

Introducing JSforce 2.0

Presented at #JapanDreamin 2020

Shinichi Tomita

January 25, 2020
Tweet

Other Decks in Programming

Transcript

  1. Shinichi Tomita • CEO at Mashmatrix, Inc. (Tokyo, Japan) •

    Author of JSforce • Ex-Salesforce (2006-2007) • Force.com MVP (2014)
  2. Last Decades: 2000-2019 • JavaScript ruled the World • 2000-2004:

    DHTML – Hacky and difficult to maintain • 2005-2009: AJAX – Powerful but requires specialty • 2010-2014: Single Page App – Accepted in mainstream • 2015-2019: ESNext / TypeScript – Sophisticated
  3. Last Decades: 2000-2019 • Salesforce democratized the World • 2000-2004:

    Custom Object / Field – Database • 2005-2009: Apex / Visualforce – Application Logics • 2010-2014: REST API / OAuth - Connectivity • 2015-2019: Lightning – User Interface
  4. Salesforce and JavaScript • Salesforce is betting on JavaScript •

    AJAX Toolkit • JavaScript Remoting • Aura / Lightning Web Components • Evergreen (NEW)
  5. Node.js const jsforce = require('jsforce'); const conn = new jsforce.Connection();

    conn.login('[email protected]', 'password', function(err, res) { if (err) { return console.error(err); } conn.query('SELECT Id, Name FROM Account', function(err, res) { if (err) { return console.error(err); } console.log(res); }); });
  6. Visualforce Page <apex:page docType="html-5.0" showHeader="false"> <apex:includeScript value="{!URLFOR($Resource.JSforce)}" /> <script> var

    conn = new jsforce.Connection({ accessToken: '{!$API.Session_Id}' }); conn.query('SELECT Id, Name FROM Account', function(err, res) { if (err) { return console.error(err); } console.log(res); }); </script> </apex:page>
  7. Command Line Interface $ jsforce > .connect [email protected] Password: *******

    Logged in as : [email protected] > query("SELECT Id, Name FROM Account LIMIT 1") { totalSize: 1, done: true, records: [ { attributes: [Object], Id: '0012v00002LsGwPAAV', Name: 'Giant Robot' } ] }
  8. 2.0 features • Pushing TypeScript App Development • Auto Completion

    in IDE / Static Type Checking • Schema Type Support • Type Inference using Salesforce SObject Schema Info • SFDX Connection Registry Support • Instant Access to Scratch Orgs
  9. Connect to Scratch Org w/o Password $ JSFORCE_CONNECTION_REGISTRY=sfdx jsforce -c

    MyScratchOrg Logged in as : [email protected] > query('SELECT Id, Name FROM Organization LIMIT 1') { totalSize: 1, done: true, records: [ { attributes: [Object], Id: '00D1m0000008bcKEAQ', Name: 'EnterpriseOrg' } ] }
  10. Release Schedule • 2.0 GA – Mid of 2020 •

    All code rewritten in TypeScript • All API modules (streaming, bulk, etc.) provided in 1.x • Tree Shaking Support using bundler (webpack, etc.) • 3.0 - • New bulk API support ?