diff --git a/types/jsforce/connection.d.ts b/types/jsforce/connection.d.ts index 2f970cc764..9759d67a9d 100644 --- a/types/jsforce/connection.d.ts +++ b/types/jsforce/connection.d.ts @@ -112,11 +112,17 @@ export abstract class BaseConnection extends EventEmitter { callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; destroy(type: string, ids: string | string[], options?: Object, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - /** Returns a value from the cache if it exists, otherwise calls Connection.describe */ - describe$(type: string, callback?: (err: Error, result: DescribeSObjectResult) => void): DescribeSObjectResult; + describe$: { + /** Returns a value from the cache if it exists, otherwise calls Connection.describe */ + (type: string, callback?: (err: Error, result: DescribeSObjectResult) => void): DescribeSObjectResult; + clear(): void; + } describe(type: string, callback?: (err: Error, result: DescribeSObjectResult) => void): Promise; - /** Returns a value from the cache if it exists, otherwise calls Connection.describeGlobal */ - describeGlobal$(callback?: (err: Error, result: DescribeGlobalResult) => void): DescribeGlobalResult; + describeGlobal$: { + /** Returns a value from the cache if it exists, otherwise calls Connection.describeGlobal */ + (callback?: (err: Error, result: DescribeGlobalResult) => void): DescribeGlobalResult; + clear(): void; + } describeGlobal(callback?: (err: Error, result: DescribeGlobalResult) => void): Promise; sobject(resource: string): SObject; } diff --git a/types/jsforce/jsforce-tests.ts b/types/jsforce/jsforce-tests.ts index 741b1875f7..8eb97aebc7 100644 --- a/types/jsforce/jsforce-tests.ts +++ b/types/jsforce/jsforce-tests.ts @@ -356,10 +356,12 @@ 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(); object.fields.forEach(field => { const type: sf.FieldType = field.type; diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index 0d8bf52e41..ab3e398891 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -27,12 +27,18 @@ export class SObject { findOne(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T) => void): Query; findOne(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T) => void): Query; - /** Returns a value from the cache if it exists, otherwise calls SObject.approvalLayouts */ - approvalLayouts$(callback?: (layoutInfo: ApprovalLayoutInfo) => void): ApprovalLayoutInfo; + approvalLayouts$: { + /** Returns a value from the cache if it exists, otherwise calls SObject.approvalLayouts */ + (callback?: (layoutInfo: ApprovalLayoutInfo) => void): ApprovalLayoutInfo; + clear(): void; + } approvalLayouts(callback?: (layoutInfo: ApprovalLayoutInfo) => void): Promise; bulkload(operation: string, options?: { extIdField?: string }, input?: Array> | stream.Stream[] | string[], callback?: (err: Error, ret: RecordResult) => void): Batch; - /** Returns a value from the cache if it exists, otherwise calls SObject.compactLayouts */ - compactLayouts$(callback?: CompactLayoutInfo): CompactLayoutInfo; + compactLayouts$: { + /** Returns a value from the cache if it exists, otherwise calls SObject.compactLayouts */ + (callback?: CompactLayoutInfo): CompactLayoutInfo; + clear(): void; + } compactLayouts(callback?: CompactLayoutInfo): Promise; count(conditions?: Object | string, callback?: (err: Error, num: number) => void): Promise; create(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise; @@ -46,12 +52,18 @@ export class SObject { deleted(start: Date | string, end: Date | string, callback?: (info: DeletedRecordsInfo) => void): Promise; deleteHardBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; describe(callback?: (err: Error, ret: DescribeSObjectResult) => void): Promise; - /** Returns a value from the cache if it exists, otherwise calls SObject.describe */ - describe$(callback?: (err: Error, ret: DescribeSObjectResult) => void): DescribeSObjectResult; + describe$: { + /** Returns a value from the cache if it exists, otherwise calls SObject.describe */ + (callback?: (err: Error, ret: DescribeSObjectResult) => void): DescribeSObjectResult; + clear(): void; + } insert(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise; insertBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; /** Returns a value from the cache if it exists, otherwise calls SObject.layouts */ - layouts$(layoutName?: string, callback?: (err: Error, info: LayoutInfo) => void): LayoutInfo; + layouts$: { + (layoutName?: string, callback?: (err: Error, info: LayoutInfo) => void): LayoutInfo; + clear(): void; + } layouts(layoutName?: string, callback?: (err: Error, info: LayoutInfo) => void): Promise; listview(id: string): ListView; listviews(callback?: (err: Error, info: ListViewsInfo) => void): Promise;