Last active
April 24, 2022 19:22
-
-
Save nautilytics/b85d501d91ca563fbaa7de343f84827f to your computer and use it in GitHub Desktop.
The types related to Question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ValueNumberNodeType = { | |
value?: number, | |
}; | |
type BasePredicate = { | |
nodeType: | | |
'ALL' | 'ANY' | 'AND' | 'BOOLEAN' | 'EQUALS_NUMBER' | 'GEOPOINT' | 'GREATER_THAN' | | |
'IS_INSIDE_REGION' | 'IS_NOT_SELECTED' | 'IS_SELECTED' | 'LESS_THAN' | 'NOT' | | |
'NOT_EQUALS_NUMBER' | 'NUMBER' | 'OR' | 'TEXT', | |
ref?: { | |
groupName?: string, | |
questionName: string, | |
}, | |
} | |
type PredicateNumberNodeType = BasePredicate & { | |
left: ValueNumberNodeType, | |
right: ValueNumberNodeType, | |
} | |
export type PredicateNotNodeType = BasePredicate & { | |
predicate: Predicate, | |
}; | |
type PredicateAnyNodeType = BasePredicate & { // FE alias for 'OR' | |
children: Predicate[], | |
}; | |
type PredicateAllNodeType = BasePredicate & { // FE alias for 'AND' | |
children: Predicate[], | |
}; | |
type PredicateAndNodeType = BasePredicate & { | |
left: Predicate, | |
right: Predicate, | |
}; | |
type PredicateOrNodeType = BasePredicate & { | |
left: Predicate, | |
right: Predicate, | |
}; | |
type PredicateIsSelectedNodeType = BasePredicate & { | |
selectedValue: { | |
nodeType: string, | |
value: string, | |
} | |
} | |
type PredicateIsNotSelectedNodeType = BasePredicate & { | |
selectedValue: { | |
nodeType: string, | |
value: string, | |
} | |
} | |
type PredicateIsInsideRegionNodeType = BasePredicate & { | |
regionCenterPoint: { | |
latitude: string, | |
longitude: string, | |
}, | |
regionSizeMeters: number, | |
testPoint: { | |
nodeType: 'GEOPOINT', | |
ref?: { | |
groupName?: string, | |
questionName: string, | |
}, | |
}, | |
}; | |
type Predicate = | |
| PredicateNotNodeType | |
| PredicateIsInsideRegionNodeType | |
| PredicateAndNodeType | |
| PredicateOrNodeType | |
| PredicateIsSelectedNodeType | |
| PredicateIsNotSelectedNodeType | |
| PredicateNumberNodeType | |
| PredicateAnyNodeType | |
| PredicateAllNodeType; | |
type BaseQuestion = { | |
barcodeTypes: string[], | |
constraint?: { | |
errorMessage: string, | |
name: string, | |
predicate: Predicate, | |
}, | |
groupName?: string, | |
hint: string, | |
hintImages?: Array<{ | |
googleImageServiceURL?: string, | |
url: string, | |
}>, | |
hintImageURLs?: string[], | |
id: string, // PRIMARY_KEY | |
label: string, | |
labels?: string[], | |
maxDurationSeconds?: number, | |
maxUploads?: number, | |
minDurationSeconds?: number, | |
name: string, | |
necessity: { | |
errorMessage: string, | |
name: string, | |
predicate: { | |
nodeType: 'BOOLEAN', | |
ref?: { | |
groupName?: string, | |
questionName: string, | |
}, | |
value: boolean, | |
}, | |
}, | |
negativeChecks?: Array<{ | |
image?: { | |
googleImageServiceURL?: string, | |
url: string, | |
}, | |
label: string, | |
value: string, | |
}>, | |
relevance?: { | |
errorMessage: string, | |
name: string, | |
predicate: Predicate, | |
}, | |
repeatAtLeast?: number, | |
repeatAtMost?: number, | |
requiredFeatures?: string[], | |
requiredGPSAccuracyMeters?: number, | |
size?: number, | |
status: 'DELETED' | 'DRAFT' | 'PUBLISHED', // defaults to DRAFT | |
style?: | | |
'DECIMAL' | 'INTEGER' | 'MULTI_LINE' | 'SINGLE_LINE' | | |
'DROPDOWN' | 'CHECKBOX_GROUP' | 'MAP', | |
options?: Array<{ | |
image?: { | |
googleImageServiceURL?: string, | |
url: string, | |
}, | |
label: string, | |
value: string, | |
}>, | |
questionType: | | |
'BINARY' | 'CHECK_IN' | 'DATE' | 'GEOPOINT' | 'LIKERT' | 'NUMBER' | 'PHOTO' | | |
'SCANNER' | 'SCREENSHOT' | 'SELECT_MANY' | 'SELECT_ONE' | 'TEXT' | 'VIDEO', | |
tags?: string[], | |
version: number, // defaults to 0 | |
sector?: string, | |
organization: string, // defaults to Premise, maybe this should join with another org table | |
estimatedTimeForCompletion?: number, | |
rules?: string[], | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type BaseQuestion = { | |
id: string, // PRIMARY_KEY | |
barcodeTypes: string[], | |
groupName?: string, | |
hint: string, | |
hintImages?: Array<{ | |
googleImageServiceURL?: string, | |
url: string, | |
}>, | |
hintImageURLs?: string[], | |
label: string, | |
labels?: string[], | |
maxDurationSeconds?: number, | |
maxUploads?: number, | |
minDurationSeconds?: number, | |
name: string, | |
options?: Array<{ | |
image?: { | |
googleImageServiceURL?: string, | |
url: string, | |
}, | |
label: string, | |
value: string, | |
}>, | |
organization: string, // defaults to Premise, maybe this should join with another org table | |
questionType: | | |
'BINARY' | 'CHECK_IN' | 'DATE' | 'GEOPOINT' | 'LIKERT' | 'NUMBER' | 'PHOTO' | | |
'SCANNER' | 'SCREENSHOT' | 'SELECT_MANY' | 'SELECT_ONE' | 'TEXT' | 'VIDEO', | |
requiredFeatures?: string[], | |
requiredGPSAccuracyMeters?: number, | |
rules?: string[], | |
sector?: string, | |
size?: number, | |
status: 'DELETED' | 'DRAFT' | 'PUBLISHED', // defaults to DRAFT | |
style?: | | |
'DECIMAL' | 'INTEGER' | 'MULTI_LINE' | 'SINGLE_LINE' | | |
'DROPDOWN' | 'CHECKBOX_GROUP' | 'MAP', | |
tags?: string[], | |
version: number // defaults to 0 | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type QuestionType = 'BINARY' | | |
'CHECK_IN' | | |
'DATE' | | |
'GEOPOINT' | | |
'LIKERT' | | |
'NUMBER' | | |
'PHOTO' | | |
'SCANNER' | | |
'SCREENSHOT' | | |
'SELECT_MANY' | | |
'SELECT_ONE' | | |
'TEXT' | | |
'VIDEO'; | |
type NodeType = 'ALL' | | |
'ANY' | | |
'AND' | | |
'BOOLEAN' | | |
'EQUALS_NUMBER' | | |
'GEOPOINT' | | |
'GREATER_THAN' | | |
'IS_INSIDE_REGION' | | |
'IS_NOT_SELECTED' | | |
'IS_SELECTED' | | |
'LESS_THAN' | | |
'NOT' | | |
'NOT_EQUALS_NUMBER' | | |
'NUMBER' | | |
'OR' | | |
'TEXT'; | |
type ValueNumberNodeType = { | |
nodeType: 'NUMBER', | |
ref?: Ref, | |
value?: number, | |
}; | |
type TextQuestionStyle = 'MULTI_LINE' | |
| 'SINGLE_LINE'; | |
type NumberQuestionStyle = 'DECIMAL' | |
| 'INTEGER'; | |
type ValueGeoPointNodeType = { | |
nodeType: 'GEOPOINT', | |
ref?: Ref, | |
}; | |
type BasePredicate = { | |
nodeType: NodeType | |
} | |
type PredicateEqualsNumberNodeType = BasePredicate & { | |
left: ValueNumberNodeType, | |
right: ValueNumberNodeType, | |
}; | |
type PredicateNotEqualsNumberType = BasePredicate & { | |
left: ValueNumberNodeType, | |
right: ValueNumberNodeType, | |
}; | |
type PredicateGreaterThanNodeType = BasePredicate & { | |
left: ValueNumberNodeType, | |
right: ValueNumberNodeType, | |
}; | |
type PredicateLessThanNodeType = BasePredicate & { | |
left: ValueNumberNodeType, | |
right: ValueNumberNodeType, | |
}; | |
type PredicateNumberNodeType = | |
| PredicateEqualsNumberNodeType | |
| PredicateNotEqualsNumberType | |
| PredicateGreaterThanNodeType | |
| PredicateLessThanNodeType | |
export type PredicateNotNodeType = BasePredicate & { | |
predicate: Predicate, | |
}; | |
type PredicateAnyNodeType = BasePredicate & { // FE alias for 'OR' | |
children: Predicate[], | |
}; | |
type PredicateAllNodeType = BasePredicate & { // FE alias for 'AND' | |
children: Predicate[], | |
}; | |
type PredicateAndNodeType = BasePredicate & { | |
left: Predicate, | |
right: Predicate, | |
}; | |
type PredicateOrNodeType = BasePredicate & { | |
left: Predicate, | |
right: Predicate, | |
}; | |
type PredicateIsSelectedNodeType = BasePredicate & { | |
ref: Ref, | |
selectedValue: { | |
nodeType: string, | |
value: string, | |
} | |
} | |
type PredicateIsNotSelectedNodeType = BasePredicate & { | |
ref: Ref, | |
selectedValue: { | |
nodeType: string, | |
value: string, | |
} | |
} | |
type PredicateIsInsideRegionNodeType = BasePredicate & { | |
ref?: Ref, | |
regionCenterPoint: { | |
latitude: string, | |
longitude: string, | |
}, | |
regionSizeMeters: number, | |
testPoint: ValueGeoPointNodeType, | |
}; | |
type Predicate = | |
| PredicateNotNodeType | |
| PredicateIsInsideRegionNodeType | |
| PredicateAndNodeType | |
| PredicateOrNodeType | |
| PredicateIsSelectedNodeType | |
| PredicateIsNotSelectedNodeType | |
| PredicateNumberNodeType | |
| PredicateAnyNodeType | |
| PredicateAllNodeType; | |
type Ref = { | |
groupName?: string, | |
questionName: string, | |
}; | |
type Option<V = string> = { | |
image?: ImageRef, | |
label: string, | |
value: V, | |
}; | |
type ValueBooleanNodeType = { | |
nodeType: 'BOOLEAN', | |
ref?: Ref, | |
value: boolean, | |
}; | |
type ImageRef = { | |
googleImageServiceURL?: string, | |
url: string, | |
}; | |
type Constraint = { | |
errorMessage: string, | |
name: string, | |
predicate: Predicate, | |
}; | |
type NecessityConstraint = { | |
errorMessage: string, | |
name: string, | |
predicate: ValueBooleanNodeType, | |
}; | |
type StatusT = 'DELETED' | 'DRAFT' | 'PUBLISHED'; | |
type BaseQuestion = { | |
id: string, | |
constraint?: Constraint, | |
groupName?: string, | |
hint: string, | |
hintImages?: ImageRef[], | |
hintImageURLs?: string[], | |
label: string, | |
name: string, | |
necessity: NecessityConstraint, | |
negativeChecks?: Option[], | |
relevance?: Constraint, | |
requiredFeatures?: string[], | |
requiredGPSAccuracyMeters?: number, | |
status: StatusT, | |
options?: Option[], | |
questionType: QuestionType, | |
tags: string[], | |
version: string, | |
sector: string, | |
organization: string, | |
estimatedTimeForCompletion?: number, | |
rules?: string[], | |
}; | |
type BinaryQuestion = BaseQuestion & { | |
options: Option[], | |
}; | |
type GeoQuestion = BaseQuestion & { | |
style: 'MAP', | |
}; | |
type SelectManyQuestion = BaseQuestion & { | |
options: Option[], | |
style: 'DROPDOWN' | 'CHECKBOX_GROUP', | |
}; | |
type SelectOneQuestion = BaseQuestion & { | |
options: Option[], | |
style: 'DROPDOWN', | |
}; | |
type TextQuestion = BaseQuestion & { | |
style: TextQuestionStyle, | |
}; | |
type VideoQuestion = BaseQuestion & { | |
maxDurationSeconds: number, | |
minDurationSeconds: number, | |
}; | |
type ScreenshotQuestion = BaseQuestion & { | |
maxUploads: number, | |
}; | |
type ScannerQuestion = BaseQuestion & { | |
barcodeTypes: string[], | |
repeatAtLeast: number, | |
repeatAtMost: number, | |
}; | |
type LikertScaleQuestion = BaseQuestion & { | |
labels: string[], | |
size: number, | |
}; | |
type NumberQuestion = BaseQuestion & { | |
style: NumberQuestionStyle, | |
}; | |
type Question = | |
| BinaryQuestion | |
| GeoQuestion | |
| LikertScaleQuestion | |
| NumberQuestion | |
| ScreenshotQuestion | |
| ScannerQuestion | |
| SelectManyQuestion | |
| SelectOneQuestion | |
| TextQuestion | |
| VideoQuestion; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment