ChuckJonas / ts-force

A Salesforce REST Client written in Typescript for Typescript
88 stars 21 forks source link

Object "Service" API #86

Closed ChuckJonas closed 3 years ago

ChuckJonas commented 4 years ago

Prototype

declare class ObjectService<Meta extends Metadata> {
  constructor(metadata: Meta);

  create(props: Creatable<Meta>): Promise<string>;
  update(props: Updatable<Meta>): Promise<void>;
  delete(id: string): Promise<void>;
  query(): Query<Meta>;
}

Other things to consider:

ChuckJonas commented 4 years ago

It might be helpful to mock up some code for a base scenario to make sure we provide a solid developer experience:

Base Scenario:

One thing that worries me is it might be awkward it will be to work with the derived types (passing queried objects into functions, combining updated results with queried results). ReturnType<> will probably be heavily used.

Example:

function calculateAnnualRevenue(acc: ?): ?{

}

const accs = AccountService.query().select('id','name').limit(200);
for(acc of accs){
   calculateAnnualRevenue(acc);
}
//update all accounts 

//display the retrieved account info + the new fields