diff --git a/types/jsforce/index.d.ts b/types/jsforce/index.d.ts new file mode 100644 index 0000000000..4b7dedc2e4 --- /dev/null +++ b/types/jsforce/index.d.ts @@ -0,0 +1,198 @@ +// Type definitions for archiver 1.8 +// Project: https://github.com/jsforce/jsforce +// Definitions by: Dolan Miu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as fs from 'fs'; +import * as stream from 'stream'; +import * as express from 'express'; +import * as glob from 'glob'; + +declare namespace jsforce { + type ConnectionEvent = "refresh"; + class Connection { + constructor(params: ConnectionOptions) + + sobject(resource: string): SObject; + on(eventName: ConnectionEvent, callback: Function): void; + } + + 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; + describeGlobal$(callback: (err: Error, res: any) => void): void; + + find(query?: any, callback?: (err: Error, ret: T[]) => void): Query; + find(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T[]) => void): Query; + find(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T[]) => void): Query; + + 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; + } + + interface ConnectionOptions { + instanceUrl?: string; + accessToken?: string; + refreshToken?: string; + oauth2?: { + clientId: string, + clientSecret: string, + redirectUri?: string, + }; + sessionId?: string; + serverUrl?: string; + redirectUri?: string; + } + + interface SObjectOptions { + Id?: SalesforceId; + Name?: string; + ExtId__c?: string; + } + + class SalesforceId extends String { + } + + interface SObjectCreateOptions extends SObjectOptions { + IsDeleted?: boolean, + MasterRecordId?: SalesforceId, + Name?: string, + Type?: string, + ParentId?: SalesforceId, + BillingStreet?: string, + BillingCity?: string, + BillingState?: string, + BillingPostalCode?: string, + BillingCountry?: string, + BillingLatitude?: number, + BillingLongitude?: number, + ShippingStreet?: string, + ShippingCity?: string, + ShippingState?: string, + ShippingPostalCode?: string, + ShippingCountry?: string, + ShippingLatitude?: number, + ShippingLongitude?: number, + Phone?: string, + Website?: string, + Industry?: string, + NumberOfEmployees?: number, + Description?: string, + OwnerId?: SalesforceId, + CreatedDate?: Date, + CreatedById?: SalesforceId, + LastModifiedDate?: Date, + LastModifiedById?: SalesforceId, + SystemModstamp?: Date, + LastActivityDate?: Date, + LastViewedDate?: Date, + LastReferencedDate?: Date, + Jigsaw?: string; + JigsawCompanyId?: string; + AccountSource?: string; + SicDesc?: string; + } + + interface Meta { + label: string; + fields: string[]; + } + + enum Date { + YESTERDAY + } + + class Query { + filter(filter: Object): Query; + hint(hint: Object): Query; + limit(value: number): Query; + maxFetch(value: number): Query; + offset(value: number): Query; + skip(value: number): Query; + sort(keyOrList: string | Object[] | Object, direction?: "ASC" | "DESC" | number): Query; + run(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query; + execute(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query; + exec(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query; + del(callback?: (err: Error, ret: RecordResult) => void): any; + delete(callback?: (err: Error, ret: RecordResult) => void): any; + destroy(callback?: (err: Error, ret: RecordResult) => void): Promise; + explain(callback?: (err: Error, info: ExplainInfo) => void): Promise; + scanAll(value: boolean): Query; + select(fields: Object | string[] | string): Query; + then(onSuccess?: Function, onRejected?: Function): Promise; + thenCall(callback?: (err: Error, records: T) => void): Query; + toSOQL(callback: (err: Error, soql: string) => void): Promise; + update(mapping: any, type: string, callback: (err: Error, records: RecordResult[]) => void): Promise; + where(conditions: Object | string): Query; + } + + interface ExecuteOptions { + autoFetch?: boolean; + maxFetch?: number; + scanAll?: number; + } + + 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 + } +} + +export = jsforce; diff --git a/types/jsforce/jsforce-tests.ts b/types/jsforce/jsforce-tests.ts new file mode 100644 index 0000000000..334116ee23 --- /dev/null +++ b/types/jsforce/jsforce-tests.ts @@ -0,0 +1 @@ +import * as jsforce from 'jsforce'; diff --git a/types/jsforce/tsconfig.json b/types/jsforce/tsconfig.json new file mode 100644 index 0000000000..a7acac4d84 --- /dev/null +++ b/types/jsforce/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jsforce-tests.ts" + ] +} \ No newline at end of file diff --git a/types/jsforce/tslint.json b/types/jsforce/tslint.json new file mode 100644 index 0000000000..a62d0d4e68 --- /dev/null +++ b/types/jsforce/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "ban-types": false + } +}