{"_id":"@appbus/nforce8","_rev":"6-7b78e889b9962adcd5c7fef9fedc01cd","time":{"2.0.12":"2020-10-22T11:54:10.977Z","created":"2020-10-22T11:56:29.703Z","2.0.13":"2020-10-22T11:56:30.461Z","modified":"2022-04-04T14:44:44.956Z"},"name":"@appbus/nforce8","dist-tags":{"latest":"2.0.13"},"versions":{"2.0.13":{"name":"@appbus/nforce8","description":"Forked from nforce by Kevin O'Hara <kevnohara80@gmail.com> (http://kevinmohara.com) for use in NodeRED. Fix for mime package update","version":"2.0.13","author":{"name":"Stephan H. Wissel","email":"stephan@wissel.net","url":"https://wissel.net"},"contributors":[{"name":"Stephan H. Wissel","email":"stephan@wissel.net","url":"https://wissel.net"},{"name":"Srikanth Ramakrishnan","email":"srikanth.r@salesforce.com"}],"keywords":["salesforce","salesforce.com","force.com","database.com","sfdc","forcedotcom","rest","api"],"sfdx":{"api":"v45.0"},"repository":{"type":"git","url":"git://github.com/stwissel/nforce8.git"},"main":"index.js","dependencies":{"faye":"1.2.5","lodash":"^4.17.20","mime":"2.4.5","node-fetch":"^2.6.0"},"devDependencies":{"body-parser":"1.19.0","codacy-coverage":"^3.4.0","cookie-parser":"1.4.5","coveralls":"^3.1.0","express":"4.17.1","express-session":"1.17.1","mocha":"^7.1.2","nyc":"^15.0.1","pug":"^2.0.4","run-sequence":"^2.2.1","should":"13.2.3"},"optionalDependencies":{},"engines":{"node":">8.0"},"bugs":{"url":"http://github.com/stwissel/nforce8/issues"},"scripts":{"preversion":"npm test","test":"nyc --reporter=text --reporter=html --reporter=text-lcov --reporter=lcovonly ./node_modules/mocha/bin/mocha ./test --reporter spec","postversion":"git push && git push --tags","coveralls":"cat ./coverage/lcov.info | coveralls","codacy":"cat ./coverage/lcov.info | codacy-coverage"},"nyc":{"exclude":["examples","docs"]},"license":"MIT","homepage":"https://github.com/stwissel/nforce8#readme","directories":{"doc":"docs","example":"examples","lib":"lib","test":"test"},"_id":"@appbus/nforce8@2.0.13","_nodeVersion":"12.14.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-iD3WQ2SSXIRN/TFp02Zij1CYbxHJyniBNnxNxQSF62pv2jMm/YApf6fHv0KkmLc7lEtj+T+rmDljoqU0Kg9aVQ==","shasum":"8bcc370b93fb99f10cceeef43f5049cbe9e9f18e","tarball":"https://registry.npmjs.org/@appbus/nforce8/-/nforce8-2.0.13.tgz","fileCount":64,"unpackedSize":258779,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkXNuCRA9TVsSAnZWagAAkJsP+wZC9u5FnqRf4T7Ep3t3\n//DYduQwBOF73b+PEji9HL3+hgtHkJtU4Fl4tGCfpoxycLWrC6BrXhRGfsJX\nbqjQndP3uIpj+UcNIeblSEGsJFKSnB8i4MTlUv3XByWUuBT4QLYbdyfyR0g/\nqPatBoudURHOLN53UmTTH1O0BcRRs8Hv57Mt4kgSvP/542uTonixO7RZ/YVx\nZd9lndnkuu0ElhwovJlNDrb/wB98YWRGZ3JYgvwYZ1c/KB9ZzFtr/T5f7uYc\n0kgHMK38h+YUTrQ7idawE6/Jg5xJsvO6GekjSx8ppej16fvvBM10QXERTcV4\nY8+Kk0OJ9qfLHsS4blBYgTUg0oyW138NhyrghKrGYIxifnr7+8phFeBNa/PQ\nI8bz+zEwd+GVyRmKcX0BoWaqPGjZpbkN3vGAcqHzmnBhxDnFwsj4juYd6lcr\nVsd/kN+RNSeP2q1xD5at+ienyzrQzy+/5dLh7dF0gTRmDWp6VUzHCBrgY7pC\n8NbLHYb2o6PbiGDN7nbMAPcSbHr8q9BhFMJSNHHiXasAhLXiBusfMiW3eNDP\n9B9c/PFeRjQu/keEuklmNC31txZTt8l8LdHMHY+RB2Ny43v/+ZkEmwQ+LopU\nr3KbhgYPYcFDCy7bK4lGUd4e/oXrNfKW7tY5W45Kh3nG1HQYu1auQLqSC0Yx\nITvg\r\n=I6lT\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEqzgrbCYHO/8lqUcuVEe+agy/VBxazkUvu9peOqA7RVAiASM+P7EHQGNuY0jHVKyIEPwteBvBkZfGfVuBr8w/JK6g=="}]},"maintainers":[{"name":"ymilshtein","email":"ymilshtein@bainsight.com"}],"_npmUser":{"name":"ymilshtein","email":"ymilshtein@bainsight.com"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nforce8_2.0.13_1603367789965_0.16656409865724786"},"_hasShrinkwrap":false,"deprecated":"this package has been deprecated"}},"maintainers":[{"name":"ymilshtein","email":"ymilshtein@bainsight.com"}],"description":"Forked from nforce by Kevin O'Hara <kevnohara80@gmail.com> (http://kevinmohara.com) for use in NodeRED. Fix for mime package update","homepage":"https://github.com/stwissel/nforce8#readme","keywords":["salesforce","salesforce.com","force.com","database.com","sfdc","forcedotcom","rest","api"],"repository":{"type":"git","url":"git://github.com/stwissel/nforce8.git"},"contributors":[{"name":"Stephan H. Wissel","email":"stephan@wissel.net","url":"https://wissel.net"},{"name":"Srikanth Ramakrishnan","email":"srikanth.r@salesforce.com"}],"author":{"name":"Stephan H. Wissel","email":"stephan@wissel.net","url":"https://wissel.net"},"bugs":{"url":"http://github.com/stwissel/nforce8/issues"},"license":"MIT","readme":"# nforce8 :: node.js salesforce REST API wrapper\n\nThis libary is based on a fork of Kevin O'Hara's brilliant\n[nforce](https://github.com/kevinohara80/nforce) library. You might want to refer to the original!\n\n## Code and build\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/719bc9f8685247fc8fdac704e596ee67)](https://www.codacy.com/app/Stwissel/nforce8?utm_source=github.com&utm_medium=referral&utm_content=Stwissel/nforce8&utm_campaign=Badge_Grade)\n[![Build Status](https://secure.travis-ci.org/Stwissel/nforce8.png)](https://travis-ci.org/Stwissel/nforce8)\n[![npm version](https://badge.fury.io/js/nforce8.svg)](https://badge.fury.io/js/nforce8)\n[![Known Vulnerabilities](https://snyk.io/test/github/Stwissel/nforce8/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Stwissel/nforce8?targetFile=package.json)\n[![Greenkeeper badge](https://badges.greenkeeper.io/Stwissel/nforce8.svg)](https://greenkeeper.io/)\n[![Coverage Status](https://coveralls.io/repos/github/Stwissel/nforce8/badge.svg?branch=master)](https://coveralls.io/github/Stwissel/nforce8?branch=master)\n\n## Rationale\n\nI'm maintaining the [NodeRED](https://nodered.org/) modules for Salesforce: [node-red-contrib-salesforce](https://www.npmjs.com/package/node-red-contrib-salesforce). The nodes needed a more recent library version and a few patches to get it to work, so I was too much tempted and forked the library.\n\n## Original Documentation\n\nRead it [here](https://www.npmjs.com/package/nforce)\n\n## Updated documentation\n\nEvolving documentation on [github.io](https://stwissel.github.io/nforce8)\n\n## Important differences\n\n- Version numbers, if provided, **must** be full qualified strings like `v42.0`, short numbers or string are no longer accepted. These will fail ~42 42.0 '42'~\n- nforce8 only works with promises, no callback support\n- Subscriptions to events need the full path, option of type gets ignored\n\n## Change Log\n\nOverview documentation on [changes between versions](https://stwissel.github.io/nforce8/Changelog.html)\n\n## Features\n\n- Promised based API\n- Intelligent sObjects (inherited from [nforce](https://www.npmjs.com/package/nforce))\n- Streaming support using [Faye](https://www.npmjs.com/package/faye) for any Salesforce topic including Change Data Capture\n- Authentication helper methods (OAuth)\n- Multi-user design with single user mode (inherited from [nforce](https://www.npmjs.com/package/nforce))\n\n## Installation\n\n```bash\nnpm install nforce8\n```\n\n## Usage\n\n### Create a client connection\n\n```js\nconst nforce = require('nforce8');\n\nconst org = nforce8.createConnection({\n  clientId: 'CLIENT_ID_OAUTH',\n  clientSecret: 'CLIENT_SECRET_OAUTH',\n  redirectUri: 'https://yourapp.herokuapp.com/oauth/_callback', // could be http://localhost:3000/ instead\n  apiVersion: 'v45.0',  // optional, defaults to current salesforce API version\n  environment: 'production',  // optional, salesforce 'sandbox' or 'production', production default\n  mode: 'multi' // optional, 'single' or 'multi' user mode, multi default\n});\n```\n\n### Authenticate using OAuth\n\n```js\n// Multi-User\nlet oauth;\nconst creds = {username: 'john.doe@noreply.com', password: 'secretjohn'};\norg.authenticate(creds)\n   .then(result => oauth = result;)\n   .catch(/* handle failure here */);\n\n// Single user mode\nconst creds = {username: 'john.doe@noreply.com', password: 'secretjohn'};\norg.authenticate(creds)\n   .then(result => console.log(org.oauth.access_token);)\n   .catch(/* handle failure here */);\n\n\n### Use the object factory to create records\n\nSample based on original nforce. In single user mode the oauth argument can be omitted since it is cached in the connection object\n\n```js\n\nconst acc = nforce.createSObject('Account');\nacc.set('Name', 'ACME Corporation');\nacc.set('Phone', '800-555-2345');\nacc.set('SLA__c', 'Platinum');\n\nconst payload = { sobject: acc, oauth: oauth };\n\norg.insert(payload)\n.then(result => console.log(JSON.stringify(result)))\n.catch(err => console.log(err));\n\n```\n\n### Query and update\n\nQuerying and updating records is super easy. **nforce** wraps API-queried records in a special object. The object caches field updates that you make to the record and allows you to pass the record directly into the update method without having to scrub out the unchanged fields. In the example below, only the Name and Industry fields will be sent in the update call despite the fact that the query returned other fields such as BillingCity and CreatedDate.\n\n```js\n\nconst q = { query :'SELECT Id, Name, CreatedDate, BillingCity FROM Account WHERE Name = \"ACME Corporation\" LIMIT 1'};\n\norg.query(q)\n   .then(resp => {\n       if (resp.records) {\n           const acc = resp.records[0];\n           acc.set('Name','ACME Coyote');\n           acc.set('Industry','Explosives');\n           const payload = {sobject: acc, oauth: oauth};\n           org.update(payload)\n            .then(result => console.log('It worked'));\n       }\n   })\n   .catch(err => console.log(err));\n\n```\n\n### Streaming API Support\n\nYou need to specify the full topic starting with a slash\n\n```js\n\nconst creds = {username: 'john.doe@noreply.com', password: 'secretjohn'};\n\norg.authenticate(creds)\n    .then(oauth => {\n        const client = org.createStreamClient();\n        const topic = {topic: '/data/ChangeEvents'};\n        const cdc = client.subscribe(topic);\n        cdc.on('error' err => {\n            console.log('subscription error');\n            console.log(err);\n            client.disconnect();\n        });\n        cdc.on('data', data => console.log(data));\n    })\n    .catch(err => console.log(err));\n\n```\n\nRead the [nforce documentation](https://www.npmjs.com/package/nforce) for more details","readmeFilename":"README.md"}