mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-31 11:07:32 +08:00
Merge pull request #25778 from shetzel/jsforce/fixes_and_additions
Adds 'success' and 'errors' properties to BatchResultInfo.
This commit is contained in:
6
types/jsforce/batch.d.ts
vendored
6
types/jsforce/batch.d.ts
vendored
@@ -12,8 +12,10 @@ export interface BatchInfo {
|
||||
|
||||
export interface BatchResultInfo {
|
||||
id: string;
|
||||
batchId: string;
|
||||
jobId: string;
|
||||
batchId?: string;
|
||||
jobId?: string;
|
||||
success?: boolean;
|
||||
errors?: string[];
|
||||
}
|
||||
|
||||
export class Batch extends Writable {
|
||||
|
||||
2
types/jsforce/bulk.d.ts
vendored
2
types/jsforce/bulk.d.ts
vendored
@@ -8,7 +8,7 @@ import { Batch, BatchResultInfo } from './batch';
|
||||
|
||||
export interface BulkOptions {
|
||||
extIdField: string;
|
||||
concurrencyMode: 'Serial' | 'Parallel';
|
||||
concurrencyMode?: 'Serial' | 'Parallel';
|
||||
}
|
||||
|
||||
type BulkLoadOperation =
|
||||
|
||||
15
types/jsforce/connection.d.ts
vendored
15
types/jsforce/connection.d.ts
vendored
@@ -22,9 +22,10 @@ export interface PartialOAuth2Options {
|
||||
}
|
||||
|
||||
export interface RequestInfo {
|
||||
body?: string;
|
||||
headers?: object;
|
||||
method?: string;
|
||||
url?: string;
|
||||
headers?: object;
|
||||
}
|
||||
|
||||
export interface ConnectionOptions extends PartialOAuth2Options {
|
||||
@@ -58,6 +59,16 @@ export abstract class RestApi {
|
||||
del(path: string, options: object, callback: () => object): Promise<object>;
|
||||
}
|
||||
|
||||
export interface ExecuteAnonymousResult {
|
||||
compiled: boolean;
|
||||
compileProblem: string;
|
||||
success: boolean;
|
||||
line: number;
|
||||
column: number;
|
||||
exceptionMessage: string;
|
||||
exceptionStackTrace: string;
|
||||
}
|
||||
|
||||
export type ConnectionEvent = "refresh";
|
||||
|
||||
/**
|
||||
@@ -135,5 +146,5 @@ export class Tooling extends BaseConnection {
|
||||
_logger: any;
|
||||
|
||||
// Specific to tooling
|
||||
executeAnonymous(body: string, callback?: (err: Error, res: any) => void): Promise<any>;
|
||||
executeAnonymous(body: string, callback?: (err: Error, res: any) => void): Promise<ExecuteAnonymousResult>;
|
||||
}
|
||||
|
||||
2
types/jsforce/job.d.ts
vendored
2
types/jsforce/job.d.ts
vendored
@@ -19,6 +19,6 @@ export class Job extends EventEmitter {
|
||||
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>;
|
||||
list(callback?: (err: Error, jobInfo: BatchInfo) => void): Promise<BatchInfo[]>;
|
||||
open(callback?: (err: Error, jobInfo: JobInfo) => void): Promise<JobInfo>;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,14 @@ const salesforceConnection: sf.Connection = new sf.Connection({
|
||||
|
||||
salesforceConnection.sobject<DummyRecord>("Dummy").select(["thing", "other"]);
|
||||
|
||||
const requestInfo: sf.RequestInfo = {
|
||||
body: '',
|
||||
headers: {},
|
||||
method: '',
|
||||
url: ''
|
||||
};
|
||||
salesforceConnection.request(requestInfo);
|
||||
|
||||
// note the following should never compile:
|
||||
// salesforceConnection.sobject<DummyRecord>("Dummy").select(["lol"]);
|
||||
|
||||
@@ -123,6 +131,17 @@ async function testAnalytics(conn: sf.Connection): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
async function testExecuteAnonymous(conn: sf.Connection): Promise<void> {
|
||||
const res: sf.ExecuteAnonymousResult = await salesforceConnection.tooling.executeAnonymous('');
|
||||
console.log('ExecuteAnonymousResult column: ' + res.column);
|
||||
console.log('ExecuteAnonymousResult compiled: ' + res.compiled);
|
||||
console.log('ExecuteAnonymousResult compileProblem: ' + res.compileProblem);
|
||||
console.log('ExecuteAnonymousResult exceptionMessage: ' + res.exceptionMessage);
|
||||
console.log('ExecuteAnonymousResult exceptionStackTrace: ' + res.exceptionStackTrace);
|
||||
console.log('ExecuteAnonymousResult line: ' + res.line);
|
||||
console.log('ExecuteAnonymousResult success: ' + res.success);
|
||||
}
|
||||
|
||||
async function testMetadata(conn: sf.Connection): Promise<void> {
|
||||
const md: sf.Metadata = conn.metadata;
|
||||
const m: sf.DescribeMetadataResult = await md.describe('34.0');
|
||||
@@ -281,6 +300,7 @@ async function testChatter(conn: sf.Connection): Promise<void> {
|
||||
await testAnalytics(salesforceConnection);
|
||||
await testChatter(salesforceConnection);
|
||||
await testMetadata(salesforceConnection);
|
||||
await testExecuteAnonymous(salesforceConnection);
|
||||
})();
|
||||
|
||||
const oauth2 = new sf.OAuth2({
|
||||
@@ -302,7 +322,7 @@ batch.on("queue", (batchInfo) => { // fired when batch request is queued in serv
|
||||
});
|
||||
job.batch("batchId");
|
||||
batch.poll(1000, 20000);
|
||||
batch.on("response", (rets) => {
|
||||
batch.on("response", (rets: sf.BatchResultInfo[]) => {
|
||||
for (let i = 0; i < rets.length; i++) {
|
||||
if (rets[i].success) {
|
||||
console.log(`# ${(i + 1)} loaded successfully, id = ${rets[i].id}`);
|
||||
@@ -312,6 +332,11 @@ batch.on("response", (rets) => {
|
||||
}
|
||||
});
|
||||
|
||||
(async () => {
|
||||
const batchInfos: sf.BatchInfo[] = await job.list();
|
||||
console.log('batchInfos:', batchInfos);
|
||||
});
|
||||
|
||||
salesforceConnection.streaming.topic("InvoiceStatementUpdates").subscribe((message) => {
|
||||
console.log('Event Type : ' + message.event.type);
|
||||
console.log('Event Created : ' + message.event.createdDate);
|
||||
|
||||
Reference in New Issue
Block a user