Split up the file into multiple, more manageable files

This commit is contained in:
Dolan
2017-05-17 00:52:31 +01:00
parent 320d860d42
commit 305b169061
12 changed files with 206 additions and 176 deletions

View File

@@ -0,0 +1,28 @@
import { SObjectCreateOptions } from './create-options';
import { DescribeSObjectResult } from './describe-result';
import { Query } from './query';
import { RecordResult } from './record-result';
import { SObject } from './salesforce-object';
export interface ConnectionOptions {
instanceUrl?: string;
accessToken?: string;
refreshToken?: string;
oauth2?: {
clientId: string,
clientSecret: string,
redirectUri?: string,
};
sessionId?: string;
serverUrl?: string;
redirectUri?: string;
}
export type ConnectionEvent = "refresh";
export declare class Connection {
constructor(params: ConnectionOptions)
sobject(resource: string): SObject;
on(eventName: ConnectionEvent, callback: Function): void;
}

View File

@@ -0,0 +1,42 @@
import { SalesforceId } from './salesforce-id';
import { SObjectOptions } from './salesforce-object-options';
export 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;
}

View File

@@ -0,0 +1,3 @@
export enum Date {
YESTERDAY
}

View File

@@ -0,0 +1,4 @@
export interface DescribeSObjectResult {
label: string;
fields: string[];
}

View File

@@ -8,173 +8,7 @@ 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 {
record(options: any, callback?: (err: Error, ret: any) => void): void;
update(options: SObjectCreateOptions, callback?: (err: Error, ret: any) => void): void;
retrieve(ids: string | string[], callback?: (err: Error, ret: any) => void): void;
retrieve(ids: string | string[], options?: Object, callback?: (err: Error, ret: any) => void): void;
// upsert(options: SObjectOptions): void;
describeGlobal(callback: (err: Error, res: any) => void): void;
describe$(callback: (err: Error, ret: DescribeSObjectResult) => void): void;
describeGlobal$(callback: (err: Error, res: any) => void): void;
find<T>(query?: any, callback?: (err: Error, ret: T[]) => void): Query<T>;
find<T>(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T[]) => void): Query<T>;
find<T>(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T[]) => void): Query<T>;
findOne<T>(query?: any, callback?: (err: Error, ret: T) => void): void;
findOne<T>(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T) => void): void;
findOne<T>(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T) => void): void;
approvalLayouts(callback?: (layoutInfo: ApprovalLayoutInfo) => void): Promise<ApprovalLayoutInfo>;
bulkload(operation: string, options?: { extIdField?: string }, input?: Record[] | stream.Stream[] | string[], callback?: (err: Error, ret: RecordResult) => void): Batch;
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[]>;
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;
destroyBulk(input?: Record[] | stream.Stream | String, callback?: (err: Error, ret: RecordResult) => void): Batch;
destroyHardBulk(input?: Record[] | stream.Stream | String, callback?: (err: Error, ret: RecordResult) => void): Batch;
deleted(start: Date | string, end: Date | string, callback?: (info: DeletedRecordsInfo) => void): Promise<DeletedRecordsInfo>;
deleteHardBulk(input?: Record[] | stream.Stream | String, callback?: (err: Error, ret: RecordResult) => void): Batch;
describe(callback?: (err: Error, ret: DescribeSObjectResult) => void): Promise<DescribeSObjectResult>;
insert(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise<RecordResult | RecordResult[]>;
insertBulk(input?: Record[] | stream.Stream | String, callback?: (err: Error, ret: RecordResult) => void): Batch;
layouts(layoutName?: string, callback?: (err: Error, info: LayoutInfo) => void): Promise<LayoutInfo>;
listview(id: string): ListView;
listviews(callback?: (err: Error, info: ListViewsInfo) => void): Promise<ListViewsInfo>;
quickAction(actionName: string): QuickAction;
quickActions(callback?: (err: Error, info: any) => void): Promise<any>;
recent(callback?: (err: Error, ret: RecordResult) => void): Promise<RecordResult>;
select<T>(field?: Object | string[] | string, callback?: (err: Error, ret: T[]) => void): Query<T[]>;
}
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 DescribeSObjectResult {
label: string;
fields: string[];
}
enum Date {
YESTERDAY
}
class Query<T> {
filter(filter: Object): Query<T>;
hint(hint: Object): Query<T>;
limit(value: number): Query<T>;
maxFetch(value: number): Query<T>;
offset(value: number): Query<T>;
skip(value: number): Query<T>;
sort(keyOrList: string | Object[] | Object, direction?: "ASC" | "DESC" | number): Query<T>;
run(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query<T>;
execute(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query<T>;
exec(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query<T>;
del(callback?: (err: Error, ret: RecordResult) => void): any;
delete(callback?: (err: Error, ret: RecordResult) => void): any;
destroy(callback?: (err: Error, ret: RecordResult) => void): Promise<RecordResult[]>;
explain(callback?: (err: Error, info: ExplainInfo) => void): Promise<ExplainInfo>;
scanAll(value: boolean): Query<T>;
select(fields: Object | string[] | string): Query<T>;
then(onSuccess?: Function, onRejected?: Function): Promise<any>;
thenCall(callback?: (err: Error, records: T) => void): Query<T>;
toSOQL(callback: (err: Error, soql: string) => void): Promise<string>;
update(mapping: any, type: string, callback: (err: Error, records: RecordResult[]) => void): Promise<RecordResult[]>;
where(conditions: Object | string): Query<T>;
}
interface ExecuteOptions {
autoFetch?: boolean;
maxFetch?: number;
scanAll?: number;
}
interface RecordResult { id: SalesforceId, success: boolean, anys: Object[] }
interface ExplainInfo { }
interface ApprovalLayoutInfo { }
interface Record { }
interface Batch { }
interface CompactLayoutInfo { }
interface DeletedRecordsInfo { }
interface LayoutInfo { }
interface ListView { }
interface ListViewsInfo { }
interface QuickAction { }
}
export = jsforce;
export { Date } from './date-enum';
export { RecordResult } from './record-result';
export { Connection } from './connection';
export { SObject } from './salesforce-object';

View File

@@ -13,7 +13,7 @@ salesforceConnection.sobject("Account").create({
Name: "Test Acc 2",
BillingStreet: "Maplestory street",
BillingPostalCode: "ME4 666"
}, (err, ret: sf.RecordResult) => {
}, (err: Error, ret: sf.RecordResult) => {
if (err || !ret.success) {
return;
}
@@ -24,7 +24,7 @@ salesforceConnection.sobject("ContentVersion").create({
Title: 'hello',
PathOnClient: './hello-world.jpg',
VersionData: '{ Test: Data }'
}, (err, ret: sf.RecordResult) => {
}, (err: Error, ret: sf.RecordResult) => {
if (err || !ret.success) {
return;
}
@@ -32,22 +32,23 @@ salesforceConnection.sobject("ContentVersion").create({
salesforceConnection.sobject("ContentVersion").retrieve("world", {
test: "test"
}, (err, ret: sf.RecordResult) => {
}, (err: Error, ret: sf.RecordResult) => {
if (err || !ret.success) {
return;
}
});
salesforceConnection.sobject("ContentVersion").findOne<any>({ Id: '' }, (err, contentVersion) => {
});
salesforceConnection.sobject("ContentDocumentLink").create({
ContentDocumentId: '',
LinkedEntityId: '',
ShareType: "I"
}, (err, ret: sf.RecordResult) => {
}, (err: Error, ret: sf.RecordResult) => {
if (err || !ret.success) {
return;
}
});
});
sf.Date.YESTERDAY;

34
types/jsforce/query.ts Normal file
View File

@@ -0,0 +1,34 @@
import { SalesforceId } from './salesforce-id';
import { RecordResult } from './record-result';
export interface ExecuteOptions {
autoFetch?: boolean;
maxFetch?: number;
scanAll?: number;
}
export declare class Query<T> {
filter(filter: Object): Query<T>;
hint(hint: Object): Query<T>;
limit(value: number): Query<T>;
maxFetch(value: number): Query<T>;
offset(value: number): Query<T>;
skip(value: number): Query<T>;
sort(keyOrList: string | Object[] | Object, direction?: "ASC" | "DESC" | number): Query<T>;
run(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query<T>;
execute(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query<T>;
exec(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query<T>;
del(callback?: (err: Error, ret: RecordResult) => void): any;
delete(callback?: (err: Error, ret: RecordResult) => void): any;
destroy(callback?: (err: Error, ret: RecordResult) => void): Promise<RecordResult[]>;
explain(callback?: (err: Error, info: ExplainInfo) => void): Promise<ExplainInfo>;
scanAll(value: boolean): Query<T>;
select(fields: Object | string[] | string): Query<T>;
then(onSuccess?: Function, onRejected?: Function): Promise<any>;
thenCall(callback?: (err: Error, records: T) => void): Query<T>;
toSOQL(callback: (err: Error, soql: string) => void): Promise<string>;
update(mapping: any, type: string, callback: (err: Error, records: RecordResult[]) => void): Promise<RecordResult[]>;
where(conditions: Object | string): Query<T>;
}
export interface ExplainInfo { }

View File

@@ -0,0 +1,7 @@
import { SalesforceId } from './salesforce-id';
export interface RecordResult {
id: SalesforceId;
success: boolean;
anys: Object[];
}

View File

@@ -0,0 +1,2 @@
export class SalesforceId extends String {
}

View File

@@ -0,0 +1,7 @@
import { SalesforceId } from './salesforce-id';
export interface SObjectOptions {
Id?: SalesforceId;
Name?: string;
ExtId__c?: string;
}

View File

@@ -0,0 +1,60 @@
import * as stream from 'stream';
import { SObjectCreateOptions } from './create-options';
import { DescribeSObjectResult } from './describe-result';
import { Query } from './query';
import { RecordResult } from './record-result';
export declare class SObject {
record(options: any, callback?: (err: Error, ret: any) => void): void;
update(options: SObjectCreateOptions, callback?: (err: Error, ret: any) => void): void;
retrieve(ids: string | string[], callback?: (err: Error, ret: any) => void): void;
retrieve(ids: string | string[], options?: Object, callback?: (err: Error, ret: any) => void): void;
// upsert(options: SObjectOptions): void;
describeGlobal(callback: (err: Error, res: any) => void): void;
describe$(callback: (err: Error, ret: DescribeSObjectResult) => void): void;
describeGlobal$(callback: (err: Error, res: any) => void): void;
find<T>(query?: any, callback?: (err: Error, ret: T[]) => void): Query<T>;
find<T>(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T[]) => void): Query<T>;
find<T>(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T[]) => void): Query<T>;
findOne<T>(query?: any, callback?: (err: Error, ret: T) => void): void;
findOne<T>(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T) => void): void;
findOne<T>(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T) => void): void;
approvalLayouts(callback?: (layoutInfo: ApprovalLayoutInfo) => void): Promise<ApprovalLayoutInfo>;
bulkload(operation: string, options?: { extIdField?: string }, input?: Record[] | stream.Stream[] | string[], callback?: (err: Error, ret: RecordResult) => void): Batch;
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[]>;
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;
destroyBulk(input?: Record[] | stream.Stream | String, callback?: (err: Error, ret: RecordResult) => void): Batch;
destroyHardBulk(input?: Record[] | stream.Stream | String, callback?: (err: Error, ret: RecordResult) => void): Batch;
deleted(start: Date | string, end: Date | string, callback?: (info: DeletedRecordsInfo) => void): Promise<DeletedRecordsInfo>;
deleteHardBulk(input?: Record[] | stream.Stream | String, callback?: (err: Error, ret: RecordResult) => void): Batch;
describe(callback?: (err: Error, ret: DescribeSObjectResult) => void): Promise<DescribeSObjectResult>;
insert(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise<RecordResult | RecordResult[]>;
insertBulk(input?: Record[] | stream.Stream | String, callback?: (err: Error, ret: RecordResult) => void): Batch;
layouts(layoutName?: string, callback?: (err: Error, info: LayoutInfo) => void): Promise<LayoutInfo>;
listview(id: string): ListView;
listviews(callback?: (err: Error, info: ListViewsInfo) => void): Promise<ListViewsInfo>;
quickAction(actionName: string): QuickAction;
quickActions(callback?: (err: Error, info: any) => void): Promise<any>;
recent(callback?: (err: Error, ret: RecordResult) => void): Promise<RecordResult>;
select<T>(field?: Object | string[] | string, callback?: (err: Error, ret: T[]) => void): Query<T[]>;
}
export interface ApprovalLayoutInfo { }
export interface Record { }
export interface Batch { }
export interface CompactLayoutInfo { }
export interface DeletedRecordsInfo { }
export interface LayoutInfo { }
export interface ListView { }
export interface ListViewsInfo { }
export interface QuickAction { }

View File

@@ -17,6 +17,14 @@
},
"files": [
"index.d.ts",
"connection.ts",
"create-options.ts",
"date-enum.ts",
"salesforce-object-options.ts",
"salesforce-object.ts",
"salesforce-id.ts",
"query.ts",
"describe-result.ts",
"jsforce-tests.ts"
]
}