From e821bc121bef99ed3d7bd2ac80f4314d96bb2735 Mon Sep 17 00:00:00 2001 From: Dolan Date: Tue, 9 May 2017 18:35:42 +0100 Subject: [PATCH] added more typings --- types/jsforce/index.d.ts | 78 ++++++++++------------------------ types/jsforce/jsforce-tests.ts | 46 +++++++++++++++++++- 2 files changed, 67 insertions(+), 57 deletions(-) diff --git a/types/jsforce/index.d.ts b/types/jsforce/index.d.ts index 4b7dedc2e4..67d0fcdda2 100644 --- a/types/jsforce/index.d.ts +++ b/types/jsforce/index.d.ts @@ -18,17 +18,12 @@ declare namespace jsforce { } class SObject { - create(options: any, callback?: (err: Error, ret: RecordResult) => void): void; record(options: any, callback?: (err: Error, ret: any) => void): void; update(options: SObjectCreateOptions, callback?: (err: Error, ret: any) => void): void; retrieve(objectId: string | string[], callback?: (err: Error, ret: any) => void): void; - del(objectId: string | string[], callback?: (err: Error, ret: any) => void): void; - destroy(objectId: string | string[], callback?: (err: Error, ret: any) => void): void; - delete(objectId: string | string[], callback?: (err: Error, ret: any) => void): void; // upsert(options: SObjectOptions): void; - describe(callback: (err: Error, ret: Meta) => void): void; describeGlobal(callback: (err: Error, res: any) => void): void; - describe$(callback: (err: Error, ret: Meta) => void): void; + describe$(callback: (err: Error, ret: DescribeSObjectResult) => void): void; describeGlobal$(callback: (err: Error, res: any) => void): void; find(query?: any, callback?: (err: Error, ret: T[]) => void): Query; @@ -38,6 +33,20 @@ declare namespace jsforce { findOne(query?: any, callback?: (err: Error, ret: T) => void): void; findOne(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T) => void): void; findOne(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T) => void): void; + + approvalLayouts(callback?: (layoutInfo: ApprovalLayoutInfo) => void): Promise; + bulkload(operation: string, options?: { extIdField?: string }, input?: Record[] | stream.Stream[] | string[], callback?: (err: Error, ret: RecordResult) => void): Batch; + 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; + createBulk(input?: Record[] | stream.Stream | String, callback?: (err: Error, ret: RecordResult) => void): Batch; + del(ids: string | string[], callback?: (err: Error, ret: any) => void): void; + destroy(ids: string | string[], callback?: (err: Error, ret: any) => void): void; + delete(ids: string | string[], callback?: (err: Error, ret: any) => void): void; + deleteBulk(input?: Record[] | stream.Stream | String, callback?: (err: Error, ret: RecordResult) => void): Batch; + deleted(start: Date | string, end: Date | string, callback?: (info: DeletedRecordsInfo) => void): Promise; + deleteHardBulk(input?: Record[] | stream.Stream | String, callback?: (err: Error, ret: RecordResult) => void): Batch; + describe(callback?: (err: Error, ret: DescribeSObjectResult) => void): Promise; } interface ConnectionOptions { @@ -103,7 +112,7 @@ declare namespace jsforce { SicDesc?: string; } - interface Meta { + interface DescribeSObjectResult { label: string; fields: string[]; } @@ -143,56 +152,13 @@ declare namespace jsforce { } interface RecordResult { id: SalesforceId, success: boolean, anys: Object[] } - interface ExplainInfo { } - interface SalesforceContentVersionDocument { - attributes: - { - type: string, - url: string, - }; - Id: SalesforceId, - ContentDocumentId: SalesforceId, - IsLatest: boolean, - ContentUrl: string, - VersionNumber: string, - Title: string, - Description: string, - ReasonForChange: string, - SharingOption: string, - PathOnClient: string, - RatingCount: number, - IsDeleted: boolean, - ContentModifiedDate: Date, - ContentModifiedById: SalesforceId, - PositiveRatingCount: number, - NegativeRatingCount: number, - FeaturedContentBoost: Date, - FeaturedContentDate: Date, - OwnerId: SalesforceId, - CreatedById: SalesforceId, - CreatedDate: Date, - LastModifiedById: SalesforceId, - LastModifiedDate: Date, - SystemModstamp: Date, - TagCsv: string, - FileType: string, - PublishStatus: string, - VersionData: string, - ContentSize: number, - FileExtension: string, - FirstPublishLocationId: SalesforceId, - Origin: string, - ContentLocation: string, - TextPreview: string, - ExternalDocumentInfo1: string, - ExternalDocumentInfo2: string, - ExternalDataSourceId: string, - Checksum: string, - IsMajorVersion: boolean, - IsAssetEnabled: boolean, - User__c: string - } + interface ExplainInfo { } + interface ApprovalLayoutInfo { } + interface Record { } + interface Batch { } + interface CompactLayoutInfo { } + interface DeletedRecordsInfo { } } export = jsforce; diff --git a/types/jsforce/jsforce-tests.ts b/types/jsforce/jsforce-tests.ts index 334116ee23..cf25cd4a6b 100644 --- a/types/jsforce/jsforce-tests.ts +++ b/types/jsforce/jsforce-tests.ts @@ -1 +1,45 @@ -import * as jsforce from 'jsforce'; +import * as sf from 'jsforce'; + +const salesforceConnection: sf.Connection = new sf.Connection({ + instanceUrl: '', + refreshToken: '', + oauth2: { + clientId: '', + clientSecret: '', + }, +}); + +salesforceConnection.sobject("Account").create({ + Name: "Test Acc 2", + BillingStreet: "Maplestory street", + BillingPostalCode: "ME4 666" +}, (err, ret: sf.RecordResult) => { + if (err || !ret.success) { + return; + } +}); + +salesforceConnection.sobject("ContentVersion").create({ + OwnerId: '', + Title: 'hello', + PathOnClient: './hello-world.jpg', + VersionData: '{ Test: Data }' +}, (err, ret: sf.RecordResult) => { + if (err || !ret.success) { + return; + } +}); + +salesforceConnection.sobject("ContentVersion").findOne({ Id: '' }, (err, contentVersion) => { + +}); + +salesforceConnection.sobject("ContentDocumentLink").create({ + ContentDocumentId: '', + LinkedEntityId: '', + ShareType: "I" +}, (err, ret: sf.RecordResult) => { + if (err || !ret.success) { + return; + } +}); \ No newline at end of file