diff --git a/types/jsforce/jsforce-tests.ts b/types/jsforce/jsforce-tests.ts index 296b4c9518..af404285f1 100644 --- a/types/jsforce/jsforce-tests.ts +++ b/types/jsforce/jsforce-tests.ts @@ -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 diff --git a/types/jsforce/streaming.d.ts b/types/jsforce/streaming.d.ts index 9d91de90f1..ea1ce24dcc 100644 --- a/types/jsforce/streaming.d.ts +++ b/types/jsforce/streaming.d.ts @@ -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 // Faye Client +} + +export namespace StreamingExtension { + export class Replay { + constructor(channel: string, replayId: number) + } + export class AuthFailure { + constructor(failureCallback: () => any); + } }