mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
[jsforce] Added Apex definitions for the connection
This commit is contained in:
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
import { Connection, Callback, RestApiOptions } from '../connection';
|
||||
|
||||
export class Apex {
|
||||
constructor(conn: Connection);
|
||||
|
||||
get<T>(path: string, options: RestApiOptions, callback?: Callback<T>): Promise<T>;
|
||||
get<T>(path: string, callback?: Callback<T>): Promise<T>;
|
||||
|
||||
post<T>(path: string, body: object, options: RestApiOptions, callback?: Callback<T>): Promise<T>;
|
||||
post<T>(path: string, body: object, callback?: Callback<T>): Promise<T>;
|
||||
post<T>(path: string, callback?: Callback<T>): Promise<T>;
|
||||
|
||||
put<T>(path: string, body: object, options: RestApiOptions, callback?: Callback<T>): Promise<T>;
|
||||
put<T>(path: string, body: object, callback?: Callback<T>): Promise<T>;
|
||||
put<T>(path: string, callback?: Callback<T>): Promise<T>;
|
||||
|
||||
patch<T>(path: string, body: object, options: RestApiOptions, callback?: Callback<T>): Promise<T>;
|
||||
patch<T>(path: string, body: object, callback?: Callback<T>): Promise<T>;
|
||||
patch<T>(path: string, callback?: Callback<T>): Promise<T>;
|
||||
|
||||
del<T>(path: string, options: RestApiOptions, callback?: Callback<T>): Promise<T>;
|
||||
del<T>(path: string, callback?: Callback<T>): Promise<T>;
|
||||
delete<T>(path: string, options: RestApiOptions, callback?: Callback<T>): Promise<T>;
|
||||
delete<T>(path: string, callback?: Callback<T>): Promise<T>;
|
||||
}
|
||||
Vendored
+2
@@ -7,6 +7,7 @@ import { SObject } from './salesforce-object';
|
||||
import { Analytics } from './api/analytics';
|
||||
import { Chatter } from './api/chatter';
|
||||
import { Metadata } from './api/metadata';
|
||||
import { Apex } from './api/apex';
|
||||
import { Bulk } from './bulk';
|
||||
import { Cache } from './cache'
|
||||
import { OAuth2, Streaming } from '.';
|
||||
@@ -141,6 +142,7 @@ export class Connection extends BaseConnection {
|
||||
|
||||
tooling: Tooling;
|
||||
analytics: Analytics;
|
||||
apex: Apex;
|
||||
chatter: Chatter;
|
||||
metadata: Metadata;
|
||||
bulk: Bulk;
|
||||
|
||||
Vendored
+2
@@ -5,12 +5,14 @@
|
||||
// Thomas Dvornik <https://github.com/amphro>
|
||||
// Tim Noonan <https://github.com/tnoonan-salesforce>
|
||||
// Abraham White <https://github.com/whiteabelincoln>
|
||||
// Borys Kupar <https://github.com/borys-kupar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from './api/analytics';
|
||||
export * from './api/chatter';
|
||||
export * from './api/metadata';
|
||||
export * from './api/apex';
|
||||
export * from './batch';
|
||||
export * from './bulk';
|
||||
export * from './cache';
|
||||
|
||||
@@ -716,3 +716,94 @@ async function testDescribe() {
|
||||
const correctlyCached = object === cachedObject;
|
||||
});
|
||||
}
|
||||
|
||||
async function testApex(conn: sf.Connection): Promise<void> {
|
||||
const apex: sf.Apex = conn.apex;
|
||||
|
||||
// Test GET
|
||||
{
|
||||
await apex.get('/custom-get-apex-api');
|
||||
|
||||
apex.get('/custom-get-apex-api', (err: Error | null, response: object) => {
|
||||
if (!err) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
|
||||
apex.get('/custom-get-apex-api', { headers: { 'X-Custom-Header': 'value' } });
|
||||
}
|
||||
|
||||
// Test POST
|
||||
{
|
||||
await apex.post('/custom-apex-api', { email: 'test@example.com' });
|
||||
|
||||
apex.post('/custom-apex-api', (err: Error | null, response: object) => {
|
||||
if (!err) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
|
||||
// Including custom body
|
||||
apex.post('/custom-apex-api', { email: 'test@example.com' }, (err: Error | null, response: object) => {
|
||||
if (!err) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Test PUT
|
||||
{
|
||||
await apex.put('/custom-apex-api', { email: 'test@example.com' });
|
||||
|
||||
apex.put('/custom-apex-api', (err: Error | null, response: object) => {
|
||||
if (!err) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
|
||||
// Including custom body
|
||||
apex.put('/custom-apex-api', { email: 'test@example.com' }, (err: Error | null, response: object) => {
|
||||
if (!err) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Test PATCH
|
||||
{
|
||||
await apex.patch('/custom-apex-api', { email: 'test@example.com' });
|
||||
|
||||
apex.patch('/custom-apex-api', (err: Error | null, response: object) => {
|
||||
if (!err) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
|
||||
// Including custom body
|
||||
apex.patch('/custom-apex-api', { email: 'test@example.com' }, (err: Error | null, response: object) => {
|
||||
if (!err) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Test DELETE
|
||||
{
|
||||
await apex.del('/custom-apex-api');
|
||||
|
||||
apex.del('/custom-apex-api', (err: Error | null, response: object) => {
|
||||
if (!err) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
|
||||
// alias
|
||||
await apex.delete('/custom-apex-api');
|
||||
|
||||
apex.delete('/custom-apex-api', (err: Error | null, response: object) => {
|
||||
if (!err) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user