Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend document type #461

Merged
merged 2 commits into from
Nov 10, 2021
Merged

extend document type #461

merged 2 commits into from
Nov 10, 2021

Conversation

jensdev
Copy link
Contributor

@jensdev jensdev commented Nov 10, 2021

In stead of

type MeasurementStatus =
  | 'measured'
  | 'preprocessing_selection'
  | 'analysis_selection'
  | 'pending_analysis'
  | 'under_analysis'
  | 'analysis_failed'
  | 'processing_results'
  | 'analyzed'
  | 'pending_review'
  | 'reviewed';

type Measurement = Document<MeasurementData> & {
  status: MeasurementStatus;
};

you can now do

type MeasurementStatus =
  | 'measured'
  | 'preprocessing_selection'
  | 'analysis_selection'
  | 'pending_analysis'
  | 'under_analysis'
  | 'analysis_failed'
  | 'processing_results'
  | 'analyzed'
  | 'pending_review'
  | 'reviewed';
type Measurement = Document<MeasurementData, MeasurementStatus>;

Which helps when using it like this

const measurement = await sdk.data.documents.findById<MeasurementData,MeasurementStatus>(schema.id, measurmentId);

if (measurement.status === 'measured') { <-- status will be typed
  // do something
}

ThomasReyskens
ThomasReyskens previously approved these changes Nov 10, 2021
@jensdev jensdev merged commit ea03142 into dev Nov 10, 2021
@jensdev jensdev deleted the chore/extend-document-type branch November 10, 2021 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants