How to use the jsforce.StreamingExtension function in jsforce

To help you get started, we’ve selected a few jsforce examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / jsforce / jsforce-tests.ts View on Github external
(async () => {
    const batchInfos: sf.BatchInfo[] = await job.list();
    console.log('batchInfos:', batchInfos);
});

salesforceConnection.streaming.topic("InvoiceStatementUpdates").subscribe((message) => {
    console.log('Event Type : ' + message.event.type);
    console.log('Event Created : ' + message.event.createdDate);
    console.log('Object Id : ' + message.sobject.Id);
});
const exitCallback = () => process.exit(1);
const channel = '/event/My_Event__e';
const replayId = -2;
const replayExt = new sf.StreamingExtension.Replay(channel, replayId);
const authFailureExt = new sf.StreamingExtension.AuthFailure(exitCallback);
const fayeClient = salesforceConnection.streaming.createClient([authFailureExt, replayExt]);
const subscription = fayeClient.subscribe(channel, (data: any) => {
    console.log('topic received data', data);
});
subscription.cancel();

async function testDescribe() {
    const global: sf.DescribeGlobalResult = await salesforceConnection.describeGlobal();
    const globalCached: sf.DescribeGlobalResult = salesforceConnection.describeGlobal$();
    const globalCachedCorrectly = global === globalCached;
    salesforceConnection.describeGlobal$.clear();

    globalCached.sobjects.forEach(async (sobject: sf.DescribeGlobalSObjectResult) => {
        const object: sf.DescribeSObjectResult = await salesforceConnection.describe(sobject.name);
        const cachedObject: sf.DescribeSObjectResult = salesforceConnection.describe$(sobject.name);
        salesforceConnection.describe$.clear();
github DefinitelyTyped / DefinitelyTyped / types / jsforce / jsforce-tests.ts View on Github external
});

(async () => {
    const batchInfos: sf.BatchInfo[] = await job.list();
    console.log('batchInfos:', batchInfos);
});

salesforceConnection.streaming.topic("InvoiceStatementUpdates").subscribe((message) => {
    console.log('Event Type : ' + message.event.type);
    console.log('Event Created : ' + message.event.createdDate);
    console.log('Object Id : ' + message.sobject.Id);
});
const exitCallback = () => process.exit(1);
const channel = '/event/My_Event__e';
const replayId = -2;
const replayExt = new sf.StreamingExtension.Replay(channel, replayId);
const authFailureExt = new sf.StreamingExtension.AuthFailure(exitCallback);
const fayeClient = salesforceConnection.streaming.createClient([authFailureExt, replayExt]);
const subscription = fayeClient.subscribe(channel, (data: any) => {
    console.log('topic received data', data);
});
subscription.cancel();

async function testDescribe() {
    const global: sf.DescribeGlobalResult = await salesforceConnection.describeGlobal();
    const globalCached: sf.DescribeGlobalResult = salesforceConnection.describeGlobal$();
    const globalCachedCorrectly = global === globalCached;
    salesforceConnection.describeGlobal$.clear();

    globalCached.sobjects.forEach(async (sobject: sf.DescribeGlobalSObjectResult) => {
        const object: sf.DescribeSObjectResult = await salesforceConnection.describe(sobject.name);
        const cachedObject: sf.DescribeSObjectResult = salesforceConnection.describe$(sobject.name);

jsforce

Salesforce API Library for JavaScript

MIT
Latest version published 20 hours ago

Package Health Score

86 / 100
Full package analysis