diff --git a/types/jsforce/api/analytics.d.ts b/types/jsforce/api/analytics.d.ts index 02f04fac41..09784acfed 100644 --- a/types/jsforce/api/analytics.d.ts +++ b/types/jsforce/api/analytics.d.ts @@ -1,64 +1,59 @@ -import { callback } from '../connection'; - -interface ReportInfo { -} +import { Callback } from '../connection'; +import { ExplainInfo } from '../query'; export class Dashboard { - describe(callback?: callback): Promise; + describe(callback?: Callback): Promise; - del(callback?: callback): Promise; + del(callback?: Callback): Promise; - destory(callback?: callback): Promise; + destory(callback?: Callback): Promise; - delete(callback?: callback): Promise; + delete(callback?: Callback): Promise; - components(componentIds: () => any | string[] | string, callback?: callback): Promise; + components(componentIds: () => any | string[] | string, callback?: Callback): Promise; - status(callback?: callback): Promise; + status(callback?: Callback): Promise; - refresh(callback?: callback): Promise; + refresh(callback?: Callback): Promise; - clone(name: string | object, folderid: string, callback?: callback): Promise; + clone(name: string | object, folderid: string, callback?: Callback): Promise; } export class ReportInstance { constructor(report: Report, id: string); - retrieve(callback: callback): Promise + retrieve(callback: Callback): Promise } export class Report { - describe(callback?: callback): Promise; + describe(callback?: Callback): Promise; - del(callback?: callback): Promise; + del(callback?: Callback): Promise; - destory(callback?: callback): Promise; + destory(callback?: Callback): Promise; - delete(callback?: callback): Promise; + delete(callback?: Callback): Promise; - clone(name: string, callback?: callback): Promise; + clone(name: string, callback?: Callback): Promise; - explain(callback?: callback): Promise; + explain(callback?: Callback): Promise; - run(options: () => any | object, callback?: callback): Promise; + run(options: () => any | object, callback?: Callback): Promise; - exec(options: () => any | object, callback?: callback): Promise; + exec(options: () => any | object, callback?: Callback): Promise; - execute(options: () => any | object, callback?: callback): Promise; + execute(options: () => any | object, callback?: Callback): Promise; - executeAsync(options: () => any | object, callback?: callback): Promise; + executeAsync(options: () => any | object, callback?: Callback): Promise; instance(id: string): ReportInstance; - instances(callback?: callback): Promise; + instances(callback?: Callback): Promise; } export interface ReportInstanceAttrs { } -export interface ExplainInfo { -} - export interface ReportMetadata { } @@ -74,9 +69,9 @@ export interface DashboardInfo { export class Analytics { report(id: string): Promise; - reports(callback?: callback): Promise; + reports(callback?: Callback): Promise; dashboard(id: string): Promise; - dashboards(callback?: callback): Promise; + dashboards(callback?: Callback): Promise; } diff --git a/types/jsforce/api/chatter.d.ts b/types/jsforce/api/chatter.d.ts index 05fc4551e0..4e0982ca24 100644 --- a/types/jsforce/api/chatter.d.ts +++ b/types/jsforce/api/chatter.d.ts @@ -1,4 +1,4 @@ -import { Connection, callback } from '../connection'; +import { Connection, Callback } from '../connection'; import { Query } from '../query'; import { Stream } from 'stream'; @@ -49,23 +49,23 @@ export class Request implements Promise { export class Resource extends Request { constructor(chatter: Chatter, url: string, queryParams?: object); - create(data: object | string, callback?: callback): Request; + create(data: object | string, callback?: Callback): Request; - del(callback?: callback): Request; + del(callback?: Callback): Request; - delete(callback?: callback): Request; + delete(callback?: Callback): Request; - retrieve(callback?: callback): Request; + retrieve(callback?: Callback): Request; - update(data: object, callback?: callback): Request; + update(data: object, callback?: Callback): Request; } export class Chatter { constructor(conn: Connection); - batch(callback?: callback): Promise; + batch(callback?: Callback): Promise; - request(params: RequestParams, callback?: callback>): Request; + request(params: RequestParams, callback?: Callback>): Request; resource(url: string, queryParams?: object): Resource } diff --git a/types/jsforce/api/metadata.d.ts b/types/jsforce/api/metadata.d.ts index c867ece15b..15f0fe249e 100644 --- a/types/jsforce/api/metadata.d.ts +++ b/types/jsforce/api/metadata.d.ts @@ -1,4 +1,4 @@ -import { callback, Connection } from '../connection'; +import { Callback, Connection } from '../connection'; import { EventEmitter } from 'events'; import { Stream } from 'stream'; @@ -113,9 +113,9 @@ interface DeployOptions { } export class AsyncResultLocator extends EventEmitter implements Promise { - check(callback?: callback): Promise + check(callback?: Callback): Promise - complete(callback?: callback): Promise + complete(callback?: Callback): Promise poll(interval: number, timeout: number): void; @@ -136,43 +136,43 @@ export class Metadata { constructor(conn: Connection); - checkDeployStatus(id: string, includeDetails?: boolean, callback?: callback): Promise + checkDeployStatus(id: string, includeDetails?: boolean, callback?: Callback): Promise - checkRetrieveStatus(id: string, callback?: callback): Promise + checkRetrieveStatus(id: string, callback?: Callback): Promise - checkStatus(ids: string | string[], callback?: callback>): AsyncResultLocator> + checkStatus(ids: string | string[], callback?: Callback>): AsyncResultLocator> - create(type: string, metadata: MetadataInfo | Array, callback?: callback>): Promise> + create(type: string, metadata: MetadataInfo | Array, callback?: Callback>): Promise> - createAsync(type: string, metadata: MetadataInfo | Array, callback?: callback>): Promise> + createAsync(type: string, metadata: MetadataInfo | Array, callback?: Callback>): Promise> - createSync(type: string, metadata: MetadataInfo | Array, callback?: callback>): Promise>; + createSync(type: string, metadata: MetadataInfo | Array, callback?: Callback>): Promise>; - delete(type: string, fullNames: string | string[], callback?: callback>): Promise>; + delete(type: string, fullNames: string | string[], callback?: Callback>): Promise>; - deleteAsync(type: string, metadata: string | string[] | MetadataInfo | Array, callback?: callback>): AsyncResultLocator> + deleteAsync(type: string, metadata: string | string[] | MetadataInfo | Array, callback?: Callback>): AsyncResultLocator> - deleteSync(type: string, fullNames: string | string[], callback?: callback>): Promise>; + deleteSync(type: string, fullNames: string | string[], callback?: Callback>): Promise>; - deploy(zipInput: Stream | Buffer | string, options: DeployOptions, callback?:callback): DeployResultLocator; + deploy(zipInput: Stream | Buffer | string, options: DeployOptions, callback?:Callback): DeployResultLocator; - describe(version?: string, callback?: callback): Promise; + describe(version?: string, callback?: Callback): Promise; - list(queries: ListMetadataQuery | Array, version?: string, callback?: callback>): Promise>; + list(queries: ListMetadataQuery | Array, version?: string, callback?: Callback>): Promise>; - read(type: string, fullNames: string | string[], callback?: callback>): Promise>; + read(type: string, fullNames: string | string[], callback?: Callback>): Promise>; - readSync(type: string, fullNames: string | string[], callback?: callback>): Promise>; + readSync(type: string, fullNames: string | string[], callback?: Callback>): Promise>; - rename(type: string, oldFullName: string, newFullName: string, callback?: callback): Promise + rename(type: string, oldFullName: string, newFullName: string, callback?: Callback): Promise - retrieve(request: RetrieveRequest, callback: callback): RetrieveResultLocator + retrieve(request: RetrieveRequest, callback: Callback): RetrieveResultLocator - update(type: string, updateMetadata: MetadataInfo | Array, callback?: callback>): Promise> + update(type: string, updateMetadata: MetadataInfo | Array, callback?: Callback>): Promise> - updateAsync(type: string, updateMetadata: MetadataInfo, callback?: callback>): AsyncResultLocator> + updateAsync(type: string, updateMetadata: MetadataInfo, callback?: Callback>): AsyncResultLocator> - updateSync(type: string, updateMetadata: MetadataInfo | Array, callback?: callback>): Promise> + updateSync(type: string, updateMetadata: MetadataInfo | Array, callback?: Callback>): Promise> - upsert(type: string, metadata: MetadataInfo | Array, callback?: callback>): Promise> + upsert(type: string, metadata: MetadataInfo | Array, callback?: Callback>): Promise> } diff --git a/types/jsforce/batch.d.ts b/types/jsforce/batch.d.ts new file mode 100644 index 0000000000..94a24fa2cd --- /dev/null +++ b/types/jsforce/batch.d.ts @@ -0,0 +1,26 @@ +import { Stream, Writable } from 'stream'; + +import { RecordResult } from './record-result'; +import { Record } from './record'; + +export interface BatchInfo { + id: string; + jobId: string; + state: string; + stateMessage: string; +} + +export interface BatchResultInfo { + id: string; + batchId: string; + jobId: string; +} + +export class Batch extends Writable { + check(callback?: (batchInfo: BatchInfo) => void): Promise; + execute(input?: Record[] | Stream | string, callback?: (err: Error, result: RecordResult[] | BatchResultInfo[]) => void): Batch; + poll(interval: number, timeout: number): void; + retrieve(callback?: (batchInfo: BatchInfo) => void): Promise; + then(): Promise; + thenAll(callback: (data: any) => void): void; +} diff --git a/types/jsforce/bulk.d.ts b/types/jsforce/bulk.d.ts new file mode 100644 index 0000000000..51708f59f1 --- /dev/null +++ b/types/jsforce/bulk.d.ts @@ -0,0 +1,31 @@ +import { Stream } from 'stream'; + +import { Connection } from './connection'; +import { RecordResult } from './record-result'; +import { Record } from './record'; +import { Job } from './job'; +import { Batch, BatchResultInfo } from './batch'; + +export interface BulkOptions { + extIdField: string; + concurrencyMode: 'Serial' | 'Parallel'; +} + +type BulkLoadOperation = + | 'insert' + | 'update' + | 'upsert' + | 'delete' + | 'hardDelete'; + +export class Bulk { + constructor(connection: Connection); + + pollInterval: number; + pollTimeout: number; + + createJob(type: string, operation: string, options?: BulkOptions): Job; + job(id: string): Job; + load(type: string, operation: BulkLoadOperation, options?: BulkOptions, input?: Record[] | Stream | string, callback?: (err: Error, result: RecordResult[] | BatchResultInfo[]) => void): Batch; + query(soql: string): any; +} diff --git a/types/jsforce/channel.d.ts b/types/jsforce/channel.d.ts new file mode 100644 index 0000000000..a290c04d88 --- /dev/null +++ b/types/jsforce/channel.d.ts @@ -0,0 +1,5 @@ +import { Streaming } from "./streaming"; + +export class Channel { + constructor(streaming: Streaming, name: string); +} diff --git a/types/jsforce/connection.d.ts b/types/jsforce/connection.d.ts index 06cda5e29f..2283320912 100644 --- a/types/jsforce/connection.d.ts +++ b/types/jsforce/connection.d.ts @@ -7,12 +7,14 @@ import { SObject } from './salesforce-object'; import { Analytics } from './api/analytics'; import { Chatter } from './api/chatter'; import { Metadata } from './api/metadata'; +import { Bulk } from './bulk'; +import { OAuth2, Streaming } from '.'; -export type callback = (err: Error, result: T) => void; +export type Callback = (err: Error, result: T) => void; // These are pulled out because according to http://jsforce.github.io/jsforce/doc/connection.js.html#line49 // the oauth options can either be in the `oauth2` proeprty OR spread across the main connection -export interface OAuth2Options { +export interface PartialOAuth2Options { clientId?: string; clientSecret?: string; loginUrl?: string; @@ -25,14 +27,14 @@ export interface RequestInfo { headers?: object; } -export interface ConnectionOptions extends OAuth2Options { +export interface ConnectionOptions extends PartialOAuth2Options { accessToken?: string; callOptions?: Object; instanceUrl?: string; loginUrl?: string; logLevel?: string; maxRequest?: number; - oauth2?: Partial; + oauth2?: Partial; proxyUrl?: string; redirectUri?: string; refreshToken?: string; @@ -82,21 +84,21 @@ export abstract class BaseConnection extends EventEmitter { request(info: RequestInfo | string, options?: Object, callback?: (err: Error, Object: object) => void): Promise; query(soql: string, callback?: (err: Error, result: QueryResult) => void): Query>; queryMore(locator: string, options?: object, callback?: (err: Error, result: QueryResult) => void): Promise>; - create(type: string, records: Record|Array>, options?: Object, + create(type: string, records: Record | Array>, options?: Object, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - insert(type: string, records: Record|Array>, options?: Object, + insert(type: string, records: Record | Array>, options?: Object, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - retrieve(type: string, ids: string|string[], options?: Object, + retrieve(type: string, ids: string | string[], options?: Object, callback?: (err: Error, result: Record | Array>) => void): Promise<(Record | Array>)>; - update(type: string, records: Record|Array>, options?: Object, + update(type: string, records: Record | Array>, options?: Object, callback?: (err: Error, result: RecordResult | Array>) => void): Promise<(RecordResult | RecordResult[])>; - upsert(type: string, records: Record|Array>, extIdField: string, options?: Object, + upsert(type: string, records: Record | Array>, extIdField: string, options?: Object, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - del(type: string, ids: string|string[], options?: Object, + del(type: string, ids: string | string[], options?: Object, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - delete(type: string, ids: string|string[], options?: Object, + delete(type: string, ids: string | string[], options?: Object, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - destroy(type: string, ids: string|string[], options?: Object, + destroy(type: string, ids: string | string[], options?: Object, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; describe(type: string, callback?: (err: Error, result: DescribeSObjectResult) => void): Promise; describeGlobal(callback?: (err: Error, result: DescribeGlobalResult) => void): Promise; @@ -110,6 +112,9 @@ export class Connection extends BaseConnection { analytics: Analytics; chatter: Chatter; metadata: Metadata; + bulk: Bulk; + oauth2: OAuth2; + streaming: Streaming; // Specific to Connection instanceUrl: string; diff --git a/types/jsforce/index.d.ts b/types/jsforce/index.d.ts index edb2830f52..704bb07655 100644 --- a/types/jsforce/index.d.ts +++ b/types/jsforce/index.d.ts @@ -7,24 +7,21 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -import * as fs from 'fs'; -import * as stream from 'stream'; -import * as express from 'express'; -import * as glob from 'glob'; - -export { Date } from './date-enum'; -export { Record } from './record'; -export { RecordResult } from './record-result'; -export { Connection, ConnectionOptions, RequestInfo, Tooling, callback } from './connection'; -export { SObject } from './salesforce-object'; -export { SalesforceId } from './salesforce-id'; -export { OAuth2, OAuth2Options } from './oauth2'; -export { Query, QueryResult } from './query'; -export { Promise } from './promise'; -export { Report, Dashboard, Analytics, ReportInstance, DashboardInfo, ReportInfo, ExplainInfo, ReportInstanceAttrs, - ReportMetadata, ReportResult } from './api/analytics'; -export { Chatter, Request, RequestResult, BatchRequestResults, BatchRequestParams, - Resource, BatchRequestResult, RequestParams } from './api/chatter'; -export { Metadata, SaveResult, MetadataInfo, AsyncResult, RetrieveResultLocator, RetrieveRequest, FileProperties, - ListMetadataQuery, DescribeMetadataResult, DeployOptions, AsyncResultLocator, RetrieveResult, MetadataObject, - DeployResult, DeployResultLocator, UpdateMetadataInfo, UpsertResult } from './api/metadata'; +export * from './api/analytics'; +export * from './api/chatter'; +export * from './api/metadata'; +export * from './batch'; +export * from './bulk'; +export * from './channel'; +export * from './connection'; +export * from './date-enum'; +export * from './job'; +export * from './oauth2'; +export * from './promise'; +export * from './query'; +export * from './record'; +export * from './record-result'; +export * from './salesforce-id'; +export * from './salesforce-object'; +export * from './streaming'; +export * from './topic'; diff --git a/types/jsforce/job.d.ts b/types/jsforce/job.d.ts new file mode 100644 index 0000000000..bdad4bf564 --- /dev/null +++ b/types/jsforce/job.d.ts @@ -0,0 +1,24 @@ +import { EventEmitter } from 'events'; + +import { Bulk, BulkOptions } from './bulk'; +import { Batch, BatchInfo } from './batch'; + +export interface JobInfo { + id: string; + object: string; + operation: string; + state: string; +} + +export class Job extends EventEmitter { + constructor(bulk: Bulk, type?: string, operation?: string, options?: BulkOptions, jobId?: string); + + abort(callback?: (err: Error, jobInfo: JobInfo) => void): Promise; + batch(batchId: string): Batch; + check(callback?: (err: Error, jobInfo: JobInfo) => void): Promise; + close(callback?: (err: Error, jobInfo: JobInfo) => void): Promise; + createBatch(): Batch; + info(callback?: (err: Error, jobInfo: JobInfo) => void): Promise; + list(callback?: (err: Error, jobInfo: BatchInfo) => void): Promise; + open(callback?: (err: Error, jobInfo: JobInfo) => void): Promise; +} diff --git a/types/jsforce/jsforce-tests.ts b/types/jsforce/jsforce-tests.ts index 9205d59096..156b0d292b 100644 --- a/types/jsforce/jsforce-tests.ts +++ b/types/jsforce/jsforce-tests.ts @@ -1,3 +1,8 @@ +import * as fs from 'fs'; +import * as stream from 'stream'; +import * as express from 'express'; +import * as glob from 'glob'; + import * as sf from 'jsforce'; export interface DummyRecord { @@ -125,7 +130,7 @@ async function testMetadata(conn: sf.Connection): Promise { m.metadataObjects.filter((value: sf.MetadataObject) => value.directoryName === 'pages'); console.log(`ApexPage?: ${pages[0].xmlName === 'ApexPage'}`); - const types: sf.ListMetadataQuery[] = [{type: 'CustomObject', folder: null}]; + const types: sf.ListMetadataQuery[] = [{ type: 'CustomObject', folder: null }]; md.list(types, '39.0', (err, properties: sf.FileProperties[]) => { if (err) { console.error('err', err); @@ -147,7 +152,7 @@ async function testMetadata(conn: sf.Connection): Promise { console.log('type: ' + meta.type); }); - const fullNames: string[] = [ 'Account', 'Contact' ]; + const fullNames: string[] = ['Account', 'Contact']; const info: sf.MetadataInfo | sf.MetadataInfo[] = await md.read('CustomObject', fullNames); console.log((info as sf.MetadataInfo[])[0].fullName); console.log((info as sf.MetadataInfo[])[1].fullName); @@ -196,7 +201,7 @@ async function testChatter(conn: sf.Connection): Promise { text: 'This is new post' }] }, - feedElementType : 'FeedItem', + feedElementType: 'FeedItem', subjectId: 'me' }, (err: Error, result: any) => { if (err) { @@ -255,7 +260,7 @@ async function testChatter(conn: sf.Connection): Promise { text: 'This is new comment on the post' }] }, - feedElementType : 'FeedItem', + feedElementType: 'FeedItem', subjectId: 'me' }) as Promise); @@ -264,7 +269,7 @@ async function testChatter(conn: sf.Connection): Promise { const itemsLikeResource: sf.Resource = chatter.resource(itemLikesUrl); const itemsLikeCreateResult: sf.RequestResult = await (itemsLikeResource.create('') as Promise); - console.log(`itemsLikeCreateResult['likedItem']: ${itemsLikeCreateResult as any ['likedItem']}`); + console.log(`itemsLikeCreateResult['likedItem']: ${itemsLikeCreateResult as any['likedItem']}`); } (async () => { @@ -277,3 +282,38 @@ async function testChatter(conn: sf.Connection): Promise { await testChatter(salesforceConnection); await testMetadata(salesforceConnection); })(); + +const oauth2 = new sf.OAuth2({ + // you can change loginUrl to connect to sandbox or prerelease env. + // loginUrl : 'https://test.salesforce.com', + clientId: '', + clientSecret: '', + redirectUri: '' +}); +oauth2.getAuthorizationUrl({ scope: 'api id web' }); + +const job = salesforceConnection.bulk.createJob("Account", "insert"); +const batch = job.createBatch(); +batch.execute(undefined); +batch.on("queue", (batchInfo) => { // fired when batch request is queued in server. + console.log('batchInfo:', batchInfo); + const batchId = batchInfo.id; + const jobId = batchInfo.jobId; +}); +job.batch("batchId"); +batch.poll(1000, 20000); +batch.on("response", (rets) => { + for (let i = 0; i < rets.length; i++) { + if (rets[i].success) { + console.log(`# ${(i + 1)} loaded successfully, id = ${rets[i].id}`); + } else { + console.log(`# ${(i + 1)} error occurred, message = ${rets[i].errors.join(', ')}`); + } + } +}); + +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); +}); diff --git a/types/jsforce/oauth2.d.ts b/types/jsforce/oauth2.d.ts index 833a9d45fd..64e26e1719 100644 --- a/types/jsforce/oauth2.d.ts +++ b/types/jsforce/oauth2.d.ts @@ -14,10 +14,13 @@ export interface OAuth2Options { privateKey?: string; // Used for sfdx auth files for legacy support reasons } -export class OAuth2 { - constructor (options? : OAuth2Options); +export interface TokenResponse { + access_token: string; + refresh_token: string; +} - protected _postParams(options: any, callback: () => any): void +export class OAuth2 { + constructor(options?: OAuth2Options); loginUrl: string; authzServiceUrl: string; @@ -27,9 +30,12 @@ export class OAuth2 { clientSecret: string; redirectUri: string; - getAuthorizationUrl(params: any): string; - refreshToken(code: string, callback?: () => any): Promise; - requestToken(code: string, callback?: () => any): Promise; - authenticate(username: string, password: string, callback?: () => any): Promise; - revokeToken(accessToken: string, callback?: () => any): Promise; + getAuthorizationUrl(params: { + scope?: string, + state?: string + }): string; + refreshToken(code: string, callback?: (err: Error, tokenResponse: TokenResponse) => void): Promise; + requestToken(code: string, callback?: (err: Error, tokenResponse: TokenResponse) => void): Promise; + authenticate(username: string, password: string, callback?: (err: Error, tokenResponse: TokenResponse) => void): Promise; + revokeToken(accessToken: string, callback?: (err: Error, ) => void): Promise; } diff --git a/types/jsforce/record.d.ts b/types/jsforce/record.d.ts index 3dd0bca1da..25ca2d62f4 100644 --- a/types/jsforce/record.d.ts +++ b/types/jsforce/record.d.ts @@ -1,10 +1,12 @@ +import { Stream } from 'stream'; + import { RecordResult } from './record-result'; import { Connection } from './connection'; import { SalesforceId } from './salesforce-id'; -import { Stream } from 'stream'; -export class RecordReference { +export class RecordReference { constructor(conn: Connection, type: string, id: SalesforceId); + blob(fieldName: string): Stream; del(options?: Object, callback?: (err: Error, result: RecordResult) => void): Promise; delete(options?: Object, callback?: (err: Error, result: RecordResult) => void): Promise; @@ -13,4 +15,4 @@ export class RecordReference { update(record: Partial, options?: Object, callback?: (err: Error, result: RecordResult) => void): Promise; } -export type Record = {Id: SalesforceId } & T; +export type Record = { Id?: SalesforceId } & T; diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index 86ec7ecaf4..2c54d598fc 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -7,6 +7,7 @@ import { Record, RecordReference } from './record'; import { RecordResult } from './record-result'; import { Connection } from './connection'; import { SalesforceId } from './salesforce-id'; +import { Batch, BatchResultInfo } from './batch'; export class SObject { record(id: SalesforceId): RecordReference; @@ -61,9 +62,6 @@ export interface ApprovalLayoutInfo { approvalLayouts: Object[]; } -export class Batch extends stream.Writable { -} - export interface CompactLayoutInfo { compactLayouts: Object[]; defaultCompactLayoutId: string; @@ -88,18 +86,5 @@ export class ListView { constructor(connection: Connection, type: string, id: SalesforceId) } -export interface BatchInfo { - id: string; - jobId: string; - state: string; - stateMessage: string; -} - -export interface BatchResultInfo { - id: string; - batchId: string; - jobId: string; -} - export class ListViewsInfo { } export class QuickAction { } diff --git a/types/jsforce/streaming.d.ts b/types/jsforce/streaming.d.ts new file mode 100644 index 0000000000..9d91de90f1 --- /dev/null +++ b/types/jsforce/streaming.d.ts @@ -0,0 +1,23 @@ +import { EventEmitter } from 'events'; + +import { Connection } from './connection'; +import { Record } from './record'; +import { Channel } from './channel'; +import { Topic } from './topic'; + +export interface StreamingMessage { + event: { + type: object + createdDate: any; + }; + sobject: Record +} + +export class Streaming extends EventEmitter { + constructor(connection: Connection); + + channel(channelId: string): Channel; + subscribe(name: string, listener: StreamingMessage): any; // Faye Subscription + topic(namne: string): Topic; + unsubscribe(name: string, listener: StreamingMessage): Streaming; +} diff --git a/types/jsforce/topic.d.ts b/types/jsforce/topic.d.ts new file mode 100644 index 0000000000..1de6f41aad --- /dev/null +++ b/types/jsforce/topic.d.ts @@ -0,0 +1,8 @@ +import { Streaming, StreamingMessage } from "./streaming"; + +export class Topic { + constructor(streaming: Streaming, name: string); + + subscribe(listener: (streamingMessage: StreamingMessage) => void): any; // Faye Subscription + unsubscribe(listener: (streamingMessage: StreamingMessage) => void): Topic; +} diff --git a/types/jsforce/tsconfig.json b/types/jsforce/tsconfig.json index 0d480d799f..bf92077cd0 100644 --- a/types/jsforce/tsconfig.json +++ b/types/jsforce/tsconfig.json @@ -18,14 +18,6 @@ }, "files": [ "index.d.ts", - "connection.d.ts", - "create-options.d.ts", - "date-enum.d.ts", - "salesforce-object-options.d.ts", - "salesforce-object.d.ts", - "salesforce-id.d.ts", - "query.d.ts", - "describe-result.d.ts", "jsforce-tests.ts" ] -} \ No newline at end of file +}