mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 20:02:05 +08:00
Add clear() method to caching describe methods
This commit is contained in:
14
types/jsforce/connection.d.ts
vendored
14
types/jsforce/connection.d.ts
vendored
@@ -112,11 +112,17 @@ export abstract class BaseConnection extends EventEmitter {
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
destroy<T>(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$<T>(type: string, callback?: (err: Error, result: DescribeSObjectResult) => void): DescribeSObjectResult;
|
||||
describe$: {
|
||||
/** Returns a value from the cache if it exists, otherwise calls Connection.describe */
|
||||
<T>(type: string, callback?: (err: Error, result: DescribeSObjectResult) => void): DescribeSObjectResult;
|
||||
clear(): void;
|
||||
}
|
||||
describe<T>(type: string, callback?: (err: Error, result: DescribeSObjectResult) => void): Promise<DescribeSObjectResult>;
|
||||
/** Returns a value from the cache if it exists, otherwise calls Connection.describeGlobal */
|
||||
describeGlobal$<T>(callback?: (err: Error, result: DescribeGlobalResult) => void): DescribeGlobalResult;
|
||||
describeGlobal$: {
|
||||
/** Returns a value from the cache if it exists, otherwise calls Connection.describeGlobal */
|
||||
<T>(callback?: (err: Error, result: DescribeGlobalResult) => void): DescribeGlobalResult;
|
||||
clear(): void;
|
||||
}
|
||||
describeGlobal<T>(callback?: (err: Error, result: DescribeGlobalResult) => void): Promise<DescribeGlobalResult>;
|
||||
sobject<T>(resource: string): SObject<T>;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
26
types/jsforce/salesforce-object.d.ts
vendored
26
types/jsforce/salesforce-object.d.ts
vendored
@@ -27,12 +27,18 @@ export class SObject<T> {
|
||||
findOne<T>(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T) => void): Query<T>;
|
||||
findOne<T>(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T) => void): Query<T>;
|
||||
|
||||
/** 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<ApprovalLayoutInfo>;
|
||||
bulkload(operation: string, options?: { extIdField?: string }, input?: Array<Record<T>> | 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<CompactLayoutInfo>;
|
||||
count(conditions?: Object | string, callback?: (err: Error, num: number) => void): Promise<number>;
|
||||
create(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise<RecordResult | RecordResult[]>;
|
||||
@@ -46,12 +52,18 @@ export class SObject<T> {
|
||||
deleted(start: Date | string, end: Date | string, callback?: (info: DeletedRecordsInfo) => void): Promise<DeletedRecordsInfo>;
|
||||
deleteHardBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch;
|
||||
describe(callback?: (err: Error, ret: DescribeSObjectResult) => void): Promise<DescribeSObjectResult>;
|
||||
/** 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<RecordResult | RecordResult[]>;
|
||||
insertBulk(input?: Array<Record<T>> | 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<LayoutInfo>;
|
||||
listview(id: string): ListView;
|
||||
listviews(callback?: (err: Error, info: ListViewsInfo) => void): Promise<ListViewsInfo>;
|
||||
|
||||
Reference in New Issue
Block a user