ChuckJonas / ts-force

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

Metadata Structure Design #83

Closed ChuckJonas closed 3 years ago

ChuckJonas commented 4 years ago

Issue to discuss and finalize Metadata structure.

Prototype

interface FieldMetadata {
  apiName: string;
  type?: unknown;
  creatable?: boolean;
  updatable?: boolean;
  childRelationship?: boolean;
  reference?: (() => Metadata<any>);
}
type Metadata<T = {}> = Record<keyof T, FieldMetadata>;

See SObjectDescribeResult for additional metadata returned from salesforce.

ChuckJonas commented 4 years ago

Here's the current field metadata for ts-force

{
    public apiName: string;
    public updateable: boolean;
    public createable: boolean;
    public reference: () => { new(): RestObject; };
    public required: boolean;
    public externalId: boolean;
    public childRelationship: boolean;
    public salesforceType: SalesforceFieldType;
    public salesforceLabel?: string;
}

Thinking we should add required, salesforceType & salesforceLabel.

I don't think I've every actually used externalId in the current version, but it might be nice to have (potentially would allow us to mock upsert)

One very minor thing that we will lose with this data structure is that I was able to generate doc comments using the help text. I don't think that will be possible with the dynamic types we will be created 🤷‍♂