mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
[jsforce] add streaming extensions (#38936)
* add jsforce streaming extensions * fix typo * fix formatting
This commit is contained in:
committed by
Wesley Wigham
parent
4f90c72cf3
commit
d30819ea25
@@ -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
|
||||
|
||||
12
types/jsforce/streaming.d.ts
vendored
12
types/jsforce/streaming.d.ts
vendored
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user