@heroku/applink
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-ea.2 • Public • Published

Node.js SDK for Heroku AppLink

Use the Node.js SDK for Heroku AppLink to develop Heroku AppLink managed apps that interact with Salesforce and Data Cloud orgs.

Node.js SDK for Heroku AppLink provides:

  • Utilities to parse requests from Salesforce Heroku-type External Services and Data Cloud Data Action Targets hydrating SDK objects that response the request: InvocationEvent and Context.
  • Objects that encapsulate the requesting Salesforce or Data Cloud Org and User.
  • Utility objects that wrap Salesforce and Data Cloud APIs to perform simple CRUD operations and complex record manipulations.

And much more!

Documentation

For more information, see API docs.

Example

Example use of the Node.js SDK for Heroku AppLink provided as part of the Heroku AppLink CLI Plugin's applink:project template:

fastify.get('/accounts', async function (request, reply) {
    const {event, context, logger} = request.sdk;

    logger.info(`GET /accounts: ${JSON.stringify(event.data || {})}`);

    const query = 'SELECT Id, Name FROM Account';

    if (process.env.SALESFORCE_ORG_NAME) {
        // If an org reference is set, query Accounts in that org
        const orgName = process.env.SALESFORCE_ORG_NAME;
        const applinkAddon = request.sdk.addons.applink;

        logger.info(`Getting org '${orgName}' connection from Heroku Applink add-on...`);
        const anotherOrg = await applinkAddon.getAuthorization(orgName);

        logger.info(`Querying org '${orgName}' (${anotherOrg.id}) Accounts...`);
        try {
            const result = await anotherOrg.dataApi.query(query);
            const accounts = result.records.map(rec => rec.fields);
            logger.info(`For org '${orgName}' (${anotherOrg.id}), found ${accounts.length} Accounts`);
        } catch (err) {
            logger.error(err.message);
        }
    }

    // Query invoking org's Accounts
    const org = context.org;
    logger.info(`Querying invoking org (${org.id}) Accounts...`);
    const result = await org.dataApi.query(query);
    const accounts = result.records.map(rec => rec.fields);
    logger.info(`For invoking org (${org.id}), found the following Accounts: ${JSON.stringify(accounts || {})}`);
    return accounts;
});

Configuration

  • HEROKU_APPLINK_ADDON_NAME - For development, configures the SDK to use a different addon name in place of "HEROKU_APPLINK". Used when fetching config vars.

Testing

Dependency

You will need java installed to run wiremock.

Running tests

To test with coverage run yarn test:coverage

Readme

Keywords

Package Sidebar

Install

npm i @heroku/applink

Weekly Downloads

35

Version

1.0.0-ea.2

License

BSD-3-Clause

Unpacked Size

74.9 kB

Total Files

40

Last publish

Collaborators

  • srishtigautam
  • aklimaite
  • jsullivandigs
  • julianduque-sfdc
  • cwallsf
  • jeffrey.estrada
  • dlira-sf
  • ntonollier
  • daebumlee
  • tetsuya_
  • mttr
  • eleary
  • salesforce-releases
  • revativelagada
  • dboston528
  • anujpandey001
  • sripad.kulkarni
  • rafaydin
  • kbaird-sf
  • cbaxtersf
  • ryoneyama
  • adirasanam
  • mengxiao.zhao
  • nrisaro
  • cmarcojos
  • adirksmeier
  • mgates-salesforce
  • ademusoyo
  • elzoona
  • christopher.jose
  • jondaniel-sfdc
  • dhagberg-sf
  • bencdenton
  • lsangalang2023
  • marcelsfdc
  • ccasey
  • joeybrown90sf
  • suppada
  • diana.doherty.sfdc
  • ryanbrainard
  • rsoerensen
  • jasoncummings-heroku
  • sconklin
  • brock-salesforce
  • tkoh-sfdc
  • gnetter
  • coreypurcell_salesforce
  • swapnilghose
  • stessema-sfc
  • jmonreal
  • brittany.jones
  • rstiltonsf
  • nilamuthu
  • sghaffar
  • cdwort-sfdc
  • agatpareek
  • aaronromeosfdc
  • kpremkumar
  • rchanda
  • 7ftz
  • xx-sfdc-npm
  • cv88
  • ekozilforce
  • umarsfdc
  • beanieboi
  • ndavidson-sf
  • mingzhi-liu1258
  • angelcampbell
  • mandeepsf
  • yann_ck
  • dasofiei
  • rajashri-gurusamy
  • sudarshanhiray
  • alex_heroku
  • sbosio_sf
  • sarahoh2468
  • justinwilaby-sf
  • cmcclung-npm-salesforce.com
  • tlowrimore
  • vish_heroku
  • ptemporini
  • tcareysmith-sfdc
  • robinson.m
  • grundy.g
  • dkabanov1
  • cgfuh
  • rdagg-hero
  • k80bowman
  • sheax0r
  • dpark.heroku
  • afraidknot
  • daniel.bright
  • jdowning
  • abhinavkoul
  • joshwlewis-sfdc
  • viniljain
  • eblack
  • k.plenty
  • apadala
  • jhili!16
  • lsorstokke
  • rcross
  • kdreyeroren
  • dhammer25
  • tenharmsel_sf
  • dougmcinnes-sfdc
  • hillzbot2000
  • chap-heroku
  • michellejhlim
  • mbuschheroku
  • reidmix
  • beckychen
  • smrutisamanta
  • apoorvasriv
  • sfalan
  • p.shreya
  • sai_harshitha_neela
  • nlanatta
  • dreichenberg
  • vlazuka
  • mars
  • heroku-front-end
  • richatiwari
  • wchrisjohnson
  • the7oka
  • simonebonettisfita
  • lucaszhou
  • psalim
  • taylor.jones
  • angelayoung
  • mble-sfdc-2
  • ktsforce
  • kerry-bennett
  • cory.steele
  • gkommineni
  • smuku
  • ykatz
  • dgallegossfdc
  • dzuelke-sfdc
  • rishabh.wason
  • sarassassin
  • araja
  • v.anand
  • lmckenzie
  • jordaneekey
  • daigo-heroku
  • mimen
  • jwadsworthsf
  • pfuente
  • montes_heroku
  • bleong
  • paguilar
  • joanneyeung
  • sbaner18
  • zli-sf
  • marcusblankenship
  • sruthich
  • mgomes-heroku
  • jesse.brown-sf
  • tij005
  • tholschuh-salesforce
  • tholmes-sfdc
  • annajohnson-sf
  • vjohne
  • slizco
  • anna-cross
  • cromwellryan-sf
  • hyunwooklee
  • matthew.rossi
  • tm-sf
  • dhawley
  • nkoziuk
  • herokucody
  • dodom-sfdc
  • csinghaus-sfdc
  • jw-sfdc
  • jlopezdan
  • gsinghsfdc
  • nrenke
  • salesforcegene
  • tanushree.gupta
  • dstarner-sfdc
  • bsonntag-salesforce
  • chetankd10
  • nicole.klusman
  • lcalermo