[jsforce] add streaming extensions (#38936)

* add jsforce streaming extensions

* fix typo

* fix formatting
This commit is contained in:
Gideon Goldberg
2019-10-22 23:15:11 +01:00
committed by Wesley Wigham
parent 4f90c72cf3
commit d30819ea25
2 changed files with 21 additions and 2 deletions

View File

@@ -689,6 +689,16 @@ salesforceConnection.streaming.topic("InvoiceStatementUpdates").subscribe((messa
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();
@@ -700,7 +710,6 @@ async function testDescribe() {
const object: sf.DescribeSObjectResult = await salesforceConnection.describe(sobject.name);
const cachedObject: sf.DescribeSObjectResult = salesforceConnection.describe$(sobject.name);
salesforceConnection.describe$.clear();
object.fields.forEach(field => {
const type: sf.FieldType = field.type;
// following should never compile

View File

@@ -18,6 +18,16 @@ export class Streaming extends EventEmitter {
channel(channelId: string): Channel;
subscribe(name: string, listener: StreamingMessage): any; // Faye Subscription
topic(namne: string): Topic;
topic(name: string): Topic;
unsubscribe(name: string, listener: StreamingMessage): Streaming;
createClient(extensions?: Array<any>): any // Faye Client
}
export namespace StreamingExtension {
export class Replay {
constructor(channel: string, replayId: number)
}
export class AuthFailure {
constructor(failureCallback: () => any);
}
}