Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Could eventually be added to TSD, or to jsforce package root...
- */
- declare module "jsforce" {
- type Partial<T> = {
- [P in keyof T]?: T[P];
- };
- class Connection {
- constructor({ loginUrl: string});
- login(username: string, password: string, callback: (err: Error, userInfo: UserInfo) => void);
- query(soql: string, callback: (err: Error, ret: QueryResponse) => void);
- sobject(type: 'Account'): SObjectCollection<Account>;
- sobject(type: 'Opportunity'): SObjectCollection<Opportunity>;
- sobject(type: 'Contact'): SObjectCollection<Contact>;
- }
- interface UserInfo {
- id: string;
- organizationId: string;
- url: string;
- }
- interface SObjectCollection<T> {
- retrieve(id: string, callback: (err: Error, ret: T & RetrieveResponseExtra) => void);
- retrieve(id: string[], callback: (err: Error, ret: (T & RetrieveResponseExtra)[]) => void);
- insert(record: Partial<T>, callback: (err: Error, ret: InsertResponse) => void);
- update(record: Partial<T>, callback: (err: Error, ret: UpdateResponse) => void);
- upsert(record: Partial<T>, extIdField: string, callback: (err: Error, ret: UpsertResponse) => void);
- }
- interface QueryResponse {
- records: SObject[];
- }
- interface SObject {
- Id: string;
- }
- interface Account extends SObject {
- Name: string;
- Phone: string;
- // ...
- }
- interface Opportunity extends SObject {
- Name: string;
- StageName: string;
- CloseDate: string;
- // ...
- }
- interface Contact extends SObject {
- FirstName: string;
- MiddleName: string;
- LastName: string;
- Email: string;
- // ...
- }
- interface RetrieveResponseExtra {
- attributes: Attributes;
- }
- interface Attributes {
- type: string;
- url: string;
- }
- interface InsertResponse {
- id: string;
- }
- interface UpdateResponse {
- }
- interface UpsertResponse {
- /**
- * Id only returned if a new record is created
- */
- id?: string;
- }
- export {
- Partial,
- Connection,
- Account,
- Opportunity,
- Contact
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement