mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Jsforce updates (#25152)
* Add bulk, batch and job and clean up * Add streaming api * Put test dependencies into test file * Update OAuth2 typings * Fix linting * Add Bulk and Streaming tests * Fix linting * Fix lint rules for new dtslinter * Make Id optional * Make T any by default * Set callbacks to have Error as first argument * Remove blank interface * Clean up and remove unused and duplicated typings * Sort exports
This commit is contained in:
53
types/jsforce/api/analytics.d.ts
vendored
53
types/jsforce/api/analytics.d.ts
vendored
@@ -1,64 +1,59 @@
|
||||
import { callback } from '../connection';
|
||||
|
||||
interface ReportInfo {
|
||||
}
|
||||
import { Callback } from '../connection';
|
||||
import { ExplainInfo } from '../query';
|
||||
|
||||
export class Dashboard {
|
||||
describe(callback?: callback<object>): Promise<any>;
|
||||
describe(callback?: Callback<object>): Promise<any>;
|
||||
|
||||
del(callback?: callback<object>): Promise<any>;
|
||||
del(callback?: Callback<object>): Promise<any>;
|
||||
|
||||
destory(callback?: callback<object>): Promise<any>;
|
||||
destory(callback?: Callback<object>): Promise<any>;
|
||||
|
||||
delete(callback?: callback<object>): Promise<any>;
|
||||
delete(callback?: Callback<object>): Promise<any>;
|
||||
|
||||
components(componentIds: () => any | string[] | string, callback?: callback<object>): Promise<any>;
|
||||
components(componentIds: () => any | string[] | string, callback?: Callback<object>): Promise<any>;
|
||||
|
||||
status(callback?: callback<object>): Promise<any>;
|
||||
status(callback?: Callback<object>): Promise<any>;
|
||||
|
||||
refresh(callback?: callback<object>): Promise<any>;
|
||||
refresh(callback?: Callback<object>): Promise<any>;
|
||||
|
||||
clone(name: string | object, folderid: string, callback?: callback<object>): Promise<any>;
|
||||
clone(name: string | object, folderid: string, callback?: Callback<object>): Promise<any>;
|
||||
}
|
||||
|
||||
export class ReportInstance {
|
||||
constructor(report: Report, id: string);
|
||||
|
||||
retrieve(callback: callback<ReportResult>): Promise<ReportResult>
|
||||
retrieve(callback: Callback<ReportResult>): Promise<ReportResult>
|
||||
}
|
||||
|
||||
export class Report {
|
||||
describe(callback?: callback<ReportMetadata>): Promise<ReportMetadata>;
|
||||
describe(callback?: Callback<ReportMetadata>): Promise<ReportMetadata>;
|
||||
|
||||
del(callback?: callback<ReportResult>): Promise<ReportResult>;
|
||||
del(callback?: Callback<ReportResult>): Promise<ReportResult>;
|
||||
|
||||
destory(callback?: callback<ReportResult>): Promise<ReportResult>;
|
||||
destory(callback?: Callback<ReportResult>): Promise<ReportResult>;
|
||||
|
||||
delete(callback?: callback<ReportResult>): Promise<ReportResult>;
|
||||
delete(callback?: Callback<ReportResult>): Promise<ReportResult>;
|
||||
|
||||
clone(name: string, callback?: callback<ReportResult>): Promise<ReportResult>;
|
||||
clone(name: string, callback?: Callback<ReportResult>): Promise<ReportResult>;
|
||||
|
||||
explain(callback?: callback<ExplainInfo>): Promise<ExplainInfo>;
|
||||
explain(callback?: Callback<ExplainInfo>): Promise<ExplainInfo>;
|
||||
|
||||
run(options: () => any | object, callback?: callback<ReportResult>): Promise<ReportResult>;
|
||||
run(options: () => any | object, callback?: Callback<ReportResult>): Promise<ReportResult>;
|
||||
|
||||
exec(options: () => any | object, callback?: callback<ReportResult>): Promise<ReportResult>;
|
||||
exec(options: () => any | object, callback?: Callback<ReportResult>): Promise<ReportResult>;
|
||||
|
||||
execute(options: () => any | object, callback?: callback<ReportResult>): Promise<ReportResult>;
|
||||
execute(options: () => any | object, callback?: Callback<ReportResult>): Promise<ReportResult>;
|
||||
|
||||
executeAsync(options: () => any | object, callback?: callback<ReportInstanceAttrs>): Promise<ReportInstanceAttrs>;
|
||||
executeAsync(options: () => any | object, callback?: Callback<ReportInstanceAttrs>): Promise<ReportInstanceAttrs>;
|
||||
|
||||
instance(id: string): ReportInstance;
|
||||
|
||||
instances(callback?: callback<ReportInstance[]>): Promise<ReportInstance[]>;
|
||||
instances(callback?: Callback<ReportInstance[]>): Promise<ReportInstance[]>;
|
||||
}
|
||||
|
||||
export interface ReportInstanceAttrs {
|
||||
}
|
||||
|
||||
export interface ExplainInfo {
|
||||
}
|
||||
|
||||
export interface ReportMetadata {
|
||||
}
|
||||
|
||||
@@ -74,9 +69,9 @@ export interface DashboardInfo {
|
||||
export class Analytics {
|
||||
report(id: string): Promise<Report>;
|
||||
|
||||
reports(callback?: callback<ReportInfo[]>): Promise<ReportInfo[]>;
|
||||
reports(callback?: Callback<ReportInfo[]>): Promise<ReportInfo[]>;
|
||||
|
||||
dashboard(id: string): Promise<Dashboard>;
|
||||
|
||||
dashboards(callback?: callback<DashboardInfo[]>): Promise<DashboardInfo[]>;
|
||||
dashboards(callback?: Callback<DashboardInfo[]>): Promise<DashboardInfo[]>;
|
||||
}
|
||||
|
||||
16
types/jsforce/api/chatter.d.ts
vendored
16
types/jsforce/api/chatter.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { Connection, callback } from '../connection';
|
||||
import { Connection, Callback } from '../connection';
|
||||
import { Query } from '../query';
|
||||
import { Stream } from 'stream';
|
||||
|
||||
@@ -49,23 +49,23 @@ export class Request<T> implements Promise<T> {
|
||||
export class Resource<T> extends Request<T> {
|
||||
constructor(chatter: Chatter, url: string, queryParams?: object);
|
||||
|
||||
create(data: object | string, callback?: callback<T>): Request<T>;
|
||||
create(data: object | string, callback?: Callback<T>): Request<T>;
|
||||
|
||||
del(callback?: callback<T>): Request<T>;
|
||||
del(callback?: Callback<T>): Request<T>;
|
||||
|
||||
delete(callback?: callback<T>): Request<T>;
|
||||
delete(callback?: Callback<T>): Request<T>;
|
||||
|
||||
retrieve(callback?: callback<T>): Request<T>;
|
||||
retrieve(callback?: Callback<T>): Request<T>;
|
||||
|
||||
update(data: object, callback?: callback<T>): Request<T>;
|
||||
update(data: object, callback?: Callback<T>): Request<T>;
|
||||
}
|
||||
|
||||
export class Chatter {
|
||||
constructor(conn: Connection);
|
||||
|
||||
batch(callback?: callback<BatchRequestResults>): Promise<BatchRequestResults>;
|
||||
batch(callback?: Callback<BatchRequestResults>): Promise<BatchRequestResults>;
|
||||
|
||||
request(params: RequestParams, callback?: callback<Request<RequestResult>>): Request<RequestResult>;
|
||||
request(params: RequestParams, callback?: Callback<Request<RequestResult>>): Request<RequestResult>;
|
||||
|
||||
resource(url: string, queryParams?: object): Resource<RequestResult>
|
||||
}
|
||||
|
||||
46
types/jsforce/api/metadata.d.ts
vendored
46
types/jsforce/api/metadata.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { callback, Connection } from '../connection';
|
||||
import { Callback, Connection } from '../connection';
|
||||
import { EventEmitter } from 'events';
|
||||
import { Stream } from 'stream';
|
||||
|
||||
@@ -113,9 +113,9 @@ interface DeployOptions {
|
||||
}
|
||||
|
||||
export class AsyncResultLocator<T> extends EventEmitter implements Promise<T> {
|
||||
check(callback?: callback<T>): Promise<T>
|
||||
check(callback?: Callback<T>): Promise<T>
|
||||
|
||||
complete(callback?: callback<T>): Promise<T>
|
||||
complete(callback?: Callback<T>): Promise<T>
|
||||
|
||||
poll(interval: number, timeout: number): void;
|
||||
|
||||
@@ -136,43 +136,43 @@ export class Metadata {
|
||||
|
||||
constructor(conn: Connection);
|
||||
|
||||
checkDeployStatus(id: string, includeDetails?: boolean, callback?: callback<DeployResult>): Promise<DeployResult>
|
||||
checkDeployStatus(id: string, includeDetails?: boolean, callback?: Callback<DeployResult>): Promise<DeployResult>
|
||||
|
||||
checkRetrieveStatus(id: string, callback?: callback<RetrieveResult>): Promise<RetrieveResult>
|
||||
checkRetrieveStatus(id: string, callback?: Callback<RetrieveResult>): Promise<RetrieveResult>
|
||||
|
||||
checkStatus(ids: string | string[], callback?: callback<AsyncResult | Array<AsyncResult>>): AsyncResultLocator<AsyncResult | Array<AsyncResult>>
|
||||
checkStatus(ids: string | string[], callback?: Callback<AsyncResult | Array<AsyncResult>>): AsyncResultLocator<AsyncResult | Array<AsyncResult>>
|
||||
|
||||
create(type: string, metadata: MetadataInfo | Array<MetadataInfo>, callback?: callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>
|
||||
create(type: string, metadata: MetadataInfo | Array<MetadataInfo>, callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>
|
||||
|
||||
createAsync(type: string, metadata: MetadataInfo | Array<MetadataInfo>, callback?: callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>
|
||||
createAsync(type: string, metadata: MetadataInfo | Array<MetadataInfo>, callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>
|
||||
|
||||
createSync(type: string, metadata: MetadataInfo | Array<MetadataInfo>, callback?: callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>;
|
||||
createSync(type: string, metadata: MetadataInfo | Array<MetadataInfo>, callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>;
|
||||
|
||||
delete(type: string, fullNames: string | string[], callback?: callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>;
|
||||
delete(type: string, fullNames: string | string[], callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>;
|
||||
|
||||
deleteAsync(type: string, metadata: string | string[] | MetadataInfo | Array<MetadataInfo>, callback?: callback<AsyncResult | Array<AsyncResult>>): AsyncResultLocator<AsyncResult | Array<AsyncResult>>
|
||||
deleteAsync(type: string, metadata: string | string[] | MetadataInfo | Array<MetadataInfo>, callback?: Callback<AsyncResult | Array<AsyncResult>>): AsyncResultLocator<AsyncResult | Array<AsyncResult>>
|
||||
|
||||
deleteSync(type: string, fullNames: string | string[], callback?: callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>;
|
||||
deleteSync(type: string, fullNames: string | string[], callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>;
|
||||
|
||||
deploy(zipInput: Stream | Buffer | string, options: DeployOptions, callback?:callback<AsyncResult>): DeployResultLocator<AsyncResult>;
|
||||
deploy(zipInput: Stream | Buffer | string, options: DeployOptions, callback?:Callback<AsyncResult>): DeployResultLocator<AsyncResult>;
|
||||
|
||||
describe(version?: string, callback?: callback<DescribeMetadataResult>): Promise<DescribeMetadataResult>;
|
||||
describe(version?: string, callback?: Callback<DescribeMetadataResult>): Promise<DescribeMetadataResult>;
|
||||
|
||||
list(queries: ListMetadataQuery | Array<ListMetadataQuery>, version?: string, callback?: callback<Array<FileProperties>>): Promise<Array<FileProperties>>;
|
||||
list(queries: ListMetadataQuery | Array<ListMetadataQuery>, version?: string, callback?: Callback<Array<FileProperties>>): Promise<Array<FileProperties>>;
|
||||
|
||||
read(type: string, fullNames: string | string[], callback?: callback<MetadataInfo | Array<MetadataInfo>>): Promise<MetadataInfo | Array<MetadataInfo>>;
|
||||
read(type: string, fullNames: string | string[], callback?: Callback<MetadataInfo | Array<MetadataInfo>>): Promise<MetadataInfo | Array<MetadataInfo>>;
|
||||
|
||||
readSync(type: string, fullNames: string | string[], callback?: callback<MetadataInfo | Array<MetadataInfo>>): Promise<MetadataInfo | Array<MetadataInfo>>;
|
||||
readSync(type: string, fullNames: string | string[], callback?: Callback<MetadataInfo | Array<MetadataInfo>>): Promise<MetadataInfo | Array<MetadataInfo>>;
|
||||
|
||||
rename(type: string, oldFullName: string, newFullName: string, callback?: callback<SaveResult>): Promise<SaveResult>
|
||||
rename(type: string, oldFullName: string, newFullName: string, callback?: Callback<SaveResult>): Promise<SaveResult>
|
||||
|
||||
retrieve(request: RetrieveRequest, callback: callback<AsyncResult>): RetrieveResultLocator<AsyncResult>
|
||||
retrieve(request: RetrieveRequest, callback: Callback<AsyncResult>): RetrieveResultLocator<AsyncResult>
|
||||
|
||||
update(type: string, updateMetadata: MetadataInfo | Array<MetadataInfo>, callback?: callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>
|
||||
update(type: string, updateMetadata: MetadataInfo | Array<MetadataInfo>, callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>
|
||||
|
||||
updateAsync(type: string, updateMetadata: MetadataInfo, callback?: callback<AsyncResult | Array<AsyncResult>>): AsyncResultLocator<AsyncResult | Array<AsyncResult>>
|
||||
updateAsync(type: string, updateMetadata: MetadataInfo, callback?: Callback<AsyncResult | Array<AsyncResult>>): AsyncResultLocator<AsyncResult | Array<AsyncResult>>
|
||||
|
||||
updateSync(type: string, updateMetadata: MetadataInfo | Array<MetadataInfo>, callback?: callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>
|
||||
updateSync(type: string, updateMetadata: MetadataInfo | Array<MetadataInfo>, callback?: Callback<SaveResult | Array<SaveResult>>): Promise<SaveResult | Array<SaveResult>>
|
||||
|
||||
upsert(type: string, metadata: MetadataInfo | Array<MetadataInfo>, callback?: callback<UpsertResult | Array<UpsertResult>>): Promise<UpsertResult | Array<UpsertResult>>
|
||||
upsert(type: string, metadata: MetadataInfo | Array<MetadataInfo>, callback?: Callback<UpsertResult | Array<UpsertResult>>): Promise<UpsertResult | Array<UpsertResult>>
|
||||
}
|
||||
|
||||
26
types/jsforce/batch.d.ts
vendored
Normal file
26
types/jsforce/batch.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Stream, Writable } from 'stream';
|
||||
|
||||
import { RecordResult } from './record-result';
|
||||
import { Record } from './record';
|
||||
|
||||
export interface BatchInfo {
|
||||
id: string;
|
||||
jobId: string;
|
||||
state: string;
|
||||
stateMessage: string;
|
||||
}
|
||||
|
||||
export interface BatchResultInfo {
|
||||
id: string;
|
||||
batchId: string;
|
||||
jobId: string;
|
||||
}
|
||||
|
||||
export class Batch extends Writable {
|
||||
check(callback?: (batchInfo: BatchInfo) => void): Promise<BatchInfo>;
|
||||
execute(input?: Record[] | Stream | string, callback?: (err: Error, result: RecordResult[] | BatchResultInfo[]) => void): Batch;
|
||||
poll(interval: number, timeout: number): void;
|
||||
retrieve(callback?: (batchInfo: BatchInfo) => void): Promise<RecordResult[] | BatchResultInfo[]>;
|
||||
then(): Promise<any>;
|
||||
thenAll(callback: (data: any) => void): void;
|
||||
}
|
||||
31
types/jsforce/bulk.d.ts
vendored
Normal file
31
types/jsforce/bulk.d.ts
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Stream } from 'stream';
|
||||
|
||||
import { Connection } from './connection';
|
||||
import { RecordResult } from './record-result';
|
||||
import { Record } from './record';
|
||||
import { Job } from './job';
|
||||
import { Batch, BatchResultInfo } from './batch';
|
||||
|
||||
export interface BulkOptions {
|
||||
extIdField: string;
|
||||
concurrencyMode: 'Serial' | 'Parallel';
|
||||
}
|
||||
|
||||
type BulkLoadOperation =
|
||||
| 'insert'
|
||||
| 'update'
|
||||
| 'upsert'
|
||||
| 'delete'
|
||||
| 'hardDelete';
|
||||
|
||||
export class Bulk {
|
||||
constructor(connection: Connection);
|
||||
|
||||
pollInterval: number;
|
||||
pollTimeout: number;
|
||||
|
||||
createJob(type: string, operation: string, options?: BulkOptions): Job;
|
||||
job(id: string): Job;
|
||||
load(type: string, operation: BulkLoadOperation, options?: BulkOptions, input?: Record[] | Stream | string, callback?: (err: Error, result: RecordResult[] | BatchResultInfo[]) => void): Batch;
|
||||
query(soql: string): any;
|
||||
}
|
||||
5
types/jsforce/channel.d.ts
vendored
Normal file
5
types/jsforce/channel.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { Streaming } from "./streaming";
|
||||
|
||||
export class Channel {
|
||||
constructor(streaming: Streaming, name: string);
|
||||
}
|
||||
29
types/jsforce/connection.d.ts
vendored
29
types/jsforce/connection.d.ts
vendored
@@ -7,12 +7,14 @@ import { SObject } from './salesforce-object';
|
||||
import { Analytics } from './api/analytics';
|
||||
import { Chatter } from './api/chatter';
|
||||
import { Metadata } from './api/metadata';
|
||||
import { Bulk } from './bulk';
|
||||
import { OAuth2, Streaming } from '.';
|
||||
|
||||
export type callback<T> = (err: Error, result: T) => void;
|
||||
export type Callback<T> = (err: Error, result: T) => void;
|
||||
|
||||
// These are pulled out because according to http://jsforce.github.io/jsforce/doc/connection.js.html#line49
|
||||
// the oauth options can either be in the `oauth2` proeprty OR spread across the main connection
|
||||
export interface OAuth2Options {
|
||||
export interface PartialOAuth2Options {
|
||||
clientId?: string;
|
||||
clientSecret?: string;
|
||||
loginUrl?: string;
|
||||
@@ -25,14 +27,14 @@ export interface RequestInfo {
|
||||
headers?: object;
|
||||
}
|
||||
|
||||
export interface ConnectionOptions extends OAuth2Options {
|
||||
export interface ConnectionOptions extends PartialOAuth2Options {
|
||||
accessToken?: string;
|
||||
callOptions?: Object;
|
||||
instanceUrl?: string;
|
||||
loginUrl?: string;
|
||||
logLevel?: string;
|
||||
maxRequest?: number;
|
||||
oauth2?: Partial<OAuth2Options>;
|
||||
oauth2?: Partial<PartialOAuth2Options>;
|
||||
proxyUrl?: string;
|
||||
redirectUri?: string;
|
||||
refreshToken?: string;
|
||||
@@ -82,21 +84,21 @@ export abstract class BaseConnection extends EventEmitter {
|
||||
request(info: RequestInfo | string, options?: Object, callback?: (err: Error, Object: object) => void): Promise<Object>;
|
||||
query<T>(soql: string, callback?: (err: Error, result: QueryResult<T>) => void): Query<QueryResult<T>>;
|
||||
queryMore<T>(locator: string, options?: object, callback?: (err: Error, result: QueryResult<T>) => void): Promise<QueryResult<T>>;
|
||||
create<T>(type: string, records: Record<T>|Array<Record<T>>, options?: Object,
|
||||
create<T>(type: string, records: Record<T> | Array<Record<T>>, options?: Object,
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
insert<T>(type: string, records: Record<T>|Array<Record<T>>, options?: Object,
|
||||
insert<T>(type: string, records: Record<T> | Array<Record<T>>, options?: Object,
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
retrieve<T>(type: string, ids: string|string[], options?: Object,
|
||||
retrieve<T>(type: string, ids: string | string[], options?: Object,
|
||||
callback?: (err: Error, result: Record<T> | Array<Record<T>>) => void): Promise<(Record<T> | Array<Record<T>>)>;
|
||||
update<T>(type: string, records: Record<T>|Array<Record<T>>, options?: Object,
|
||||
update<T>(type: string, records: Record<T> | Array<Record<T>>, options?: Object,
|
||||
callback?: (err: Error, result: RecordResult | Array<Record<T>>) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
upsert<T>(type: string, records: Record<T>|Array<Record<T>>, extIdField: string, options?: Object,
|
||||
upsert<T>(type: string, records: Record<T> | Array<Record<T>>, extIdField: string, options?: Object,
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
del<T>(type: string, ids: string|string[], options?: Object,
|
||||
del<T>(type: string, ids: string | string[], options?: Object,
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
delete<T>(type: string, ids: string|string[], options?: Object,
|
||||
delete<T>(type: string, ids: string | string[], options?: Object,
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
destroy<T>(type: string, ids: string|string[], options?: Object,
|
||||
destroy<T>(type: string, ids: string | string[], options?: Object,
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
describe<T>(type: string, callback?: (err: Error, result: DescribeSObjectResult) => void): Promise<DescribeSObjectResult>;
|
||||
describeGlobal<T>(callback?: (err: Error, result: DescribeGlobalResult) => void): Promise<DescribeGlobalResult>;
|
||||
@@ -110,6 +112,9 @@ export class Connection extends BaseConnection {
|
||||
analytics: Analytics;
|
||||
chatter: Chatter;
|
||||
metadata: Metadata;
|
||||
bulk: Bulk;
|
||||
oauth2: OAuth2;
|
||||
streaming: Streaming;
|
||||
|
||||
// Specific to Connection
|
||||
instanceUrl: string;
|
||||
|
||||
39
types/jsforce/index.d.ts
vendored
39
types/jsforce/index.d.ts
vendored
@@ -7,24 +7,21 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as stream from 'stream';
|
||||
import * as express from 'express';
|
||||
import * as glob from 'glob';
|
||||
|
||||
export { Date } from './date-enum';
|
||||
export { Record } from './record';
|
||||
export { RecordResult } from './record-result';
|
||||
export { Connection, ConnectionOptions, RequestInfo, Tooling, callback } from './connection';
|
||||
export { SObject } from './salesforce-object';
|
||||
export { SalesforceId } from './salesforce-id';
|
||||
export { OAuth2, OAuth2Options } from './oauth2';
|
||||
export { Query, QueryResult } from './query';
|
||||
export { Promise } from './promise';
|
||||
export { Report, Dashboard, Analytics, ReportInstance, DashboardInfo, ReportInfo, ExplainInfo, ReportInstanceAttrs,
|
||||
ReportMetadata, ReportResult } from './api/analytics';
|
||||
export { Chatter, Request, RequestResult, BatchRequestResults, BatchRequestParams,
|
||||
Resource, BatchRequestResult, RequestParams } from './api/chatter';
|
||||
export { Metadata, SaveResult, MetadataInfo, AsyncResult, RetrieveResultLocator, RetrieveRequest, FileProperties,
|
||||
ListMetadataQuery, DescribeMetadataResult, DeployOptions, AsyncResultLocator, RetrieveResult, MetadataObject,
|
||||
DeployResult, DeployResultLocator, UpdateMetadataInfo, UpsertResult } from './api/metadata';
|
||||
export * from './api/analytics';
|
||||
export * from './api/chatter';
|
||||
export * from './api/metadata';
|
||||
export * from './batch';
|
||||
export * from './bulk';
|
||||
export * from './channel';
|
||||
export * from './connection';
|
||||
export * from './date-enum';
|
||||
export * from './job';
|
||||
export * from './oauth2';
|
||||
export * from './promise';
|
||||
export * from './query';
|
||||
export * from './record';
|
||||
export * from './record-result';
|
||||
export * from './salesforce-id';
|
||||
export * from './salesforce-object';
|
||||
export * from './streaming';
|
||||
export * from './topic';
|
||||
|
||||
24
types/jsforce/job.d.ts
vendored
Normal file
24
types/jsforce/job.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
import { Bulk, BulkOptions } from './bulk';
|
||||
import { Batch, BatchInfo } from './batch';
|
||||
|
||||
export interface JobInfo {
|
||||
id: string;
|
||||
object: string;
|
||||
operation: string;
|
||||
state: string;
|
||||
}
|
||||
|
||||
export class Job extends EventEmitter {
|
||||
constructor(bulk: Bulk, type?: string, operation?: string, options?: BulkOptions, jobId?: string);
|
||||
|
||||
abort(callback?: (err: Error, jobInfo: JobInfo) => void): Promise<any>;
|
||||
batch(batchId: string): Batch;
|
||||
check(callback?: (err: Error, jobInfo: JobInfo) => void): Promise<JobInfo>;
|
||||
close(callback?: (err: Error, jobInfo: JobInfo) => void): Promise<JobInfo>;
|
||||
createBatch(): Batch;
|
||||
info(callback?: (err: Error, jobInfo: JobInfo) => void): Promise<JobInfo>;
|
||||
list(callback?: (err: Error, jobInfo: BatchInfo) => void): Promise<BatchInfo>;
|
||||
open(callback?: (err: Error, jobInfo: JobInfo) => void): Promise<JobInfo>;
|
||||
}
|
||||
@@ -1,3 +1,8 @@
|
||||
import * as fs from 'fs';
|
||||
import * as stream from 'stream';
|
||||
import * as express from 'express';
|
||||
import * as glob from 'glob';
|
||||
|
||||
import * as sf from 'jsforce';
|
||||
|
||||
export interface DummyRecord {
|
||||
@@ -125,7 +130,7 @@ async function testMetadata(conn: sf.Connection): Promise<void> {
|
||||
m.metadataObjects.filter((value: sf.MetadataObject) => value.directoryName === 'pages');
|
||||
console.log(`ApexPage?: ${pages[0].xmlName === 'ApexPage'}`);
|
||||
|
||||
const types: sf.ListMetadataQuery[] = [{type: 'CustomObject', folder: null}];
|
||||
const types: sf.ListMetadataQuery[] = [{ type: 'CustomObject', folder: null }];
|
||||
md.list(types, '39.0', (err, properties: sf.FileProperties[]) => {
|
||||
if (err) {
|
||||
console.error('err', err);
|
||||
@@ -147,7 +152,7 @@ async function testMetadata(conn: sf.Connection): Promise<void> {
|
||||
console.log('type: ' + meta.type);
|
||||
});
|
||||
|
||||
const fullNames: string[] = [ 'Account', 'Contact' ];
|
||||
const fullNames: string[] = ['Account', 'Contact'];
|
||||
const info: sf.MetadataInfo | sf.MetadataInfo[] = await md.read('CustomObject', fullNames);
|
||||
console.log((info as sf.MetadataInfo[])[0].fullName);
|
||||
console.log((info as sf.MetadataInfo[])[1].fullName);
|
||||
@@ -196,7 +201,7 @@ async function testChatter(conn: sf.Connection): Promise<void> {
|
||||
text: 'This is new post'
|
||||
}]
|
||||
},
|
||||
feedElementType : 'FeedItem',
|
||||
feedElementType: 'FeedItem',
|
||||
subjectId: 'me'
|
||||
}, (err: Error, result: any) => {
|
||||
if (err) {
|
||||
@@ -255,7 +260,7 @@ async function testChatter(conn: sf.Connection): Promise<void> {
|
||||
text: 'This is new comment on the post'
|
||||
}]
|
||||
},
|
||||
feedElementType : 'FeedItem',
|
||||
feedElementType: 'FeedItem',
|
||||
subjectId: 'me'
|
||||
}) as Promise<sf.RequestResult>);
|
||||
|
||||
@@ -264,7 +269,7 @@ async function testChatter(conn: sf.Connection): Promise<void> {
|
||||
const itemsLikeResource: sf.Resource<sf.RequestResult> = chatter.resource(itemLikesUrl);
|
||||
|
||||
const itemsLikeCreateResult: sf.RequestResult = await (itemsLikeResource.create('') as Promise<sf.RequestResult>);
|
||||
console.log(`itemsLikeCreateResult['likedItem']: ${itemsLikeCreateResult as any ['likedItem']}`);
|
||||
console.log(`itemsLikeCreateResult['likedItem']: ${itemsLikeCreateResult as any['likedItem']}`);
|
||||
}
|
||||
|
||||
(async () => {
|
||||
@@ -277,3 +282,38 @@ async function testChatter(conn: sf.Connection): Promise<void> {
|
||||
await testChatter(salesforceConnection);
|
||||
await testMetadata(salesforceConnection);
|
||||
})();
|
||||
|
||||
const oauth2 = new sf.OAuth2({
|
||||
// you can change loginUrl to connect to sandbox or prerelease env.
|
||||
// loginUrl : 'https://test.salesforce.com',
|
||||
clientId: '<your Salesforce OAuth2 client ID is here>',
|
||||
clientSecret: '<your Salesforce OAuth2 client secret is here>',
|
||||
redirectUri: '<callback URI is here>'
|
||||
});
|
||||
oauth2.getAuthorizationUrl({ scope: 'api id web' });
|
||||
|
||||
const job = salesforceConnection.bulk.createJob("Account", "insert");
|
||||
const batch = job.createBatch();
|
||||
batch.execute(undefined);
|
||||
batch.on("queue", (batchInfo) => { // fired when batch request is queued in server.
|
||||
console.log('batchInfo:', batchInfo);
|
||||
const batchId = batchInfo.id;
|
||||
const jobId = batchInfo.jobId;
|
||||
});
|
||||
job.batch("batchId");
|
||||
batch.poll(1000, 20000);
|
||||
batch.on("response", (rets) => {
|
||||
for (let i = 0; i < rets.length; i++) {
|
||||
if (rets[i].success) {
|
||||
console.log(`# ${(i + 1)} loaded successfully, id = ${rets[i].id}`);
|
||||
} else {
|
||||
console.log(`# ${(i + 1)} error occurred, message = ${rets[i].errors.join(', ')}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
salesforceConnection.streaming.topic("InvoiceStatementUpdates").subscribe((message) => {
|
||||
console.log('Event Type : ' + message.event.type);
|
||||
console.log('Event Created : ' + message.event.createdDate);
|
||||
console.log('Object Id : ' + message.sobject.Id);
|
||||
});
|
||||
|
||||
22
types/jsforce/oauth2.d.ts
vendored
22
types/jsforce/oauth2.d.ts
vendored
@@ -14,10 +14,13 @@ export interface OAuth2Options {
|
||||
privateKey?: string; // Used for sfdx auth files for legacy support reasons
|
||||
}
|
||||
|
||||
export class OAuth2 {
|
||||
constructor (options? : OAuth2Options);
|
||||
export interface TokenResponse {
|
||||
access_token: string;
|
||||
refresh_token: string;
|
||||
}
|
||||
|
||||
protected _postParams(options: any, callback: () => any): void
|
||||
export class OAuth2 {
|
||||
constructor(options?: OAuth2Options);
|
||||
|
||||
loginUrl: string;
|
||||
authzServiceUrl: string;
|
||||
@@ -27,9 +30,12 @@ export class OAuth2 {
|
||||
clientSecret: string;
|
||||
redirectUri: string;
|
||||
|
||||
getAuthorizationUrl(params: any): string;
|
||||
refreshToken(code: string, callback?: () => any): Promise<any>;
|
||||
requestToken(code: string, callback?: () => any): Promise<any>;
|
||||
authenticate(username: string, password: string, callback?: () => any): Promise<any>;
|
||||
revokeToken(accessToken: string, callback?: () => any): Promise<any>;
|
||||
getAuthorizationUrl(params: {
|
||||
scope?: string,
|
||||
state?: string
|
||||
}): string;
|
||||
refreshToken(code: string, callback?: (err: Error, tokenResponse: TokenResponse) => void): Promise<TokenResponse>;
|
||||
requestToken(code: string, callback?: (err: Error, tokenResponse: TokenResponse) => void): Promise<TokenResponse>;
|
||||
authenticate(username: string, password: string, callback?: (err: Error, tokenResponse: TokenResponse) => void): Promise<TokenResponse>;
|
||||
revokeToken(accessToken: string, callback?: (err: Error, ) => void): Promise<undefined>;
|
||||
}
|
||||
|
||||
8
types/jsforce/record.d.ts
vendored
8
types/jsforce/record.d.ts
vendored
@@ -1,10 +1,12 @@
|
||||
import { Stream } from 'stream';
|
||||
|
||||
import { RecordResult } from './record-result';
|
||||
import { Connection } from './connection';
|
||||
import { SalesforceId } from './salesforce-id';
|
||||
import { Stream } from 'stream';
|
||||
|
||||
export class RecordReference<T> {
|
||||
export class RecordReference<T = any> {
|
||||
constructor(conn: Connection, type: string, id: SalesforceId);
|
||||
|
||||
blob(fieldName: string): Stream;
|
||||
del(options?: Object, callback?: (err: Error, result: RecordResult) => void): Promise<RecordResult>;
|
||||
delete(options?: Object, callback?: (err: Error, result: RecordResult) => void): Promise<RecordResult>;
|
||||
@@ -13,4 +15,4 @@ export class RecordReference<T> {
|
||||
update(record: Partial<T>, options?: Object, callback?: (err: Error, result: RecordResult) => void): Promise<RecordResult>;
|
||||
}
|
||||
|
||||
export type Record<T> = {Id: SalesforceId } & T;
|
||||
export type Record<T = any> = { Id?: SalesforceId } & T;
|
||||
|
||||
17
types/jsforce/salesforce-object.d.ts
vendored
17
types/jsforce/salesforce-object.d.ts
vendored
@@ -7,6 +7,7 @@ import { Record, RecordReference } from './record';
|
||||
import { RecordResult } from './record-result';
|
||||
import { Connection } from './connection';
|
||||
import { SalesforceId } from './salesforce-id';
|
||||
import { Batch, BatchResultInfo } from './batch';
|
||||
|
||||
export class SObject<T> {
|
||||
record(id: SalesforceId): RecordReference<T>;
|
||||
@@ -61,9 +62,6 @@ export interface ApprovalLayoutInfo {
|
||||
approvalLayouts: Object[];
|
||||
}
|
||||
|
||||
export class Batch extends stream.Writable {
|
||||
}
|
||||
|
||||
export interface CompactLayoutInfo {
|
||||
compactLayouts: Object[];
|
||||
defaultCompactLayoutId: string;
|
||||
@@ -88,18 +86,5 @@ export class ListView {
|
||||
constructor(connection: Connection, type: string, id: SalesforceId)
|
||||
}
|
||||
|
||||
export interface BatchInfo {
|
||||
id: string;
|
||||
jobId: string;
|
||||
state: string;
|
||||
stateMessage: string;
|
||||
}
|
||||
|
||||
export interface BatchResultInfo {
|
||||
id: string;
|
||||
batchId: string;
|
||||
jobId: string;
|
||||
}
|
||||
|
||||
export class ListViewsInfo { }
|
||||
export class QuickAction { }
|
||||
|
||||
23
types/jsforce/streaming.d.ts
vendored
Normal file
23
types/jsforce/streaming.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
import { Connection } from './connection';
|
||||
import { Record } from './record';
|
||||
import { Channel } from './channel';
|
||||
import { Topic } from './topic';
|
||||
|
||||
export interface StreamingMessage {
|
||||
event: {
|
||||
type: object
|
||||
createdDate: any;
|
||||
};
|
||||
sobject: Record
|
||||
}
|
||||
|
||||
export class Streaming extends EventEmitter {
|
||||
constructor(connection: Connection);
|
||||
|
||||
channel(channelId: string): Channel;
|
||||
subscribe(name: string, listener: StreamingMessage): any; // Faye Subscription
|
||||
topic(namne: string): Topic;
|
||||
unsubscribe(name: string, listener: StreamingMessage): Streaming;
|
||||
}
|
||||
8
types/jsforce/topic.d.ts
vendored
Normal file
8
types/jsforce/topic.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Streaming, StreamingMessage } from "./streaming";
|
||||
|
||||
export class Topic {
|
||||
constructor(streaming: Streaming, name: string);
|
||||
|
||||
subscribe(listener: (streamingMessage: StreamingMessage) => void): any; // Faye Subscription
|
||||
unsubscribe(listener: (streamingMessage: StreamingMessage) => void): Topic;
|
||||
}
|
||||
@@ -18,14 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"connection.d.ts",
|
||||
"create-options.d.ts",
|
||||
"date-enum.d.ts",
|
||||
"salesforce-object-options.d.ts",
|
||||
"salesforce-object.d.ts",
|
||||
"salesforce-id.d.ts",
|
||||
"query.d.ts",
|
||||
"describe-result.d.ts",
|
||||
"jsforce-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user