11import { getParent , getRoot , getSnapshot , types } from "mobx-state-tree" ;
2+ import { ff } from "@humansignal/core" ;
23import { guidGenerator } from "../core/Helpers" ;
34import Registry from "../core/Registry" ;
45import Tree from "../core/Tree" ;
56import { AnnotationMixin } from "../mixins/AnnotationMixin" ;
67import { isDefined } from "../utils/utilities" ;
78import { FF_LSDV_4583 , isFF } from "../utils/feature-flags" ;
89
10+ const resultTypes = [
11+ "labels" ,
12+ "hypertextlabels" ,
13+ "paragraphlabels" ,
14+ "rectangle" ,
15+ "keypoint" ,
16+ "polygon" ,
17+ "brush" ,
18+ "bitmask" ,
19+ "ellipse" ,
20+ "magicwand" ,
21+ "rectanglelabels" ,
22+ "keypointlabels" ,
23+ "polygonlabels" ,
24+ "brushlabels" ,
25+ "bitmasklabels" ,
26+ "ellipselabels" ,
27+ "timeserieslabels" ,
28+ "timelinelabels" ,
29+ "choices" ,
30+ "datetime" ,
31+ "number" ,
32+ "taxonomy" ,
33+ "textarea" ,
34+ "rating" ,
35+ "pairwise" ,
36+ "videorectangle" ,
37+ "ranker" ,
38+ ] ;
39+
40+ const resultValues = {
41+ ranker : types . union ( types . array ( types . string ) , types . frozen ( ) , types . null ) ,
42+ datetime : types . maybe ( types . string ) ,
43+ number : types . maybe ( types . number ) ,
44+ rating : types . maybe ( types . number ) ,
45+ item_index : types . maybeNull ( types . number ) ,
46+ text : types . maybe ( types . union ( types . string , types . array ( types . string ) ) ) ,
47+ choices : types . maybe ( types . array ( types . union ( types . string , types . array ( types . string ) ) ) ) ,
48+ // pairwise
49+ selected : types . maybe ( types . enumeration ( [ "left" , "right" ] ) ) ,
50+ // @todo all other *labels
51+ labels : types . maybe ( types . array ( types . string ) ) ,
52+ htmllabels : types . maybe ( types . array ( types . string ) ) ,
53+ hypertextlabels : types . maybe ( types . array ( types . string ) ) ,
54+ paragraphlabels : types . maybe ( types . array ( types . string ) ) ,
55+ rectanglelabels : types . maybe ( types . array ( types . string ) ) ,
56+ keypointlabels : types . maybe ( types . array ( types . string ) ) ,
57+ polygonlabels : types . maybe ( types . array ( types . string ) ) ,
58+ ellipselabels : types . maybe ( types . array ( types . string ) ) ,
59+ brushlabels : types . maybe ( types . array ( types . string ) ) ,
60+ timeserieslabels : types . maybe ( types . array ( types . string ) ) ,
61+ timelinelabels : types . maybe ( types . array ( types . string ) ) , // new one
62+ bitmasklabels : types . maybe ( types . array ( types . string ) ) ,
63+ taxonomy : types . frozen ( ) , // array of arrays of strings
64+ sequence : types . frozen ( ) ,
65+ } ;
66+
967const Result = types
1068 . model ( "Result" , {
1169 id : types . optional ( types . identifier , guidGenerator ) ,
@@ -32,62 +90,20 @@ const Result = types
3290 // object tag
3391 to_name : types . late ( ( ) => types . reference ( types . union ( ...Registry . objectTypes ( ) ) ) ) ,
3492 // @todo some general type, maybe just a `string`
35- type : types . enumeration ( [
36- "labels" ,
37- "hypertextlabels" ,
38- "paragraphlabels" ,
39- "rectangle" ,
40- "keypoint" ,
41- "polygon" ,
42- "brush" ,
43- "bitmask" ,
44- "ellipse" ,
45- "magicwand" ,
46- "rectanglelabels" ,
47- "keypointlabels" ,
48- "polygonlabels" ,
49- "brushlabels" ,
50- "bitmasklabels" ,
51- "ellipselabels" ,
52- "timeserieslabels" ,
53- "timelinelabels" ,
54- "choices" ,
55- "datetime" ,
56- "number" ,
57- "taxonomy" ,
58- "textarea" ,
59- "rating" ,
60- "pairwise" ,
61- "videorectangle" ,
62- "ranker" ,
63- ] ) ,
93+ type : ff . isActive ( ff . FF_CUSTOM_TAGS )
94+ ? types . late ( ( ) => types . enumeration ( [ ...resultTypes , ...Registry . customTags . map ( ( t ) => t . resultName ) ] ) )
95+ : types . enumeration ( [ ...resultTypes ] ) ,
6496 // @todo much better to have just a value, not a hash with empty fields
65- value : types . model ( {
66- ranker : types . union ( types . array ( types . string ) , types . frozen ( ) , types . null ) ,
67- datetime : types . maybe ( types . string ) ,
68- number : types . maybe ( types . number ) ,
69- rating : types . maybe ( types . number ) ,
70- item_index : types . maybeNull ( types . number ) ,
71- text : types . maybe ( types . union ( types . string , types . array ( types . string ) ) ) ,
72- choices : types . maybe ( types . array ( types . union ( types . string , types . array ( types . string ) ) ) ) ,
73- // pairwise
74- selected : types . maybe ( types . enumeration ( [ "left" , "right" ] ) ) ,
75- // @todo all other *labels
76- labels : types . maybe ( types . array ( types . string ) ) ,
77- htmllabels : types . maybe ( types . array ( types . string ) ) ,
78- hypertextlabels : types . maybe ( types . array ( types . string ) ) ,
79- paragraphlabels : types . maybe ( types . array ( types . string ) ) ,
80- rectanglelabels : types . maybe ( types . array ( types . string ) ) ,
81- keypointlabels : types . maybe ( types . array ( types . string ) ) ,
82- polygonlabels : types . maybe ( types . array ( types . string ) ) ,
83- ellipselabels : types . maybe ( types . array ( types . string ) ) ,
84- brushlabels : types . maybe ( types . array ( types . string ) ) ,
85- timeserieslabels : types . maybe ( types . array ( types . string ) ) ,
86- timelinelabels : types . maybe ( types . array ( types . string ) ) , // new one
87- bitmasklabels : types . maybe ( types . array ( types . string ) ) ,
88- taxonomy : types . frozen ( ) , // array of arrays of strings
89- sequence : types . frozen ( ) ,
90- } ) ,
97+ value : ff . isActive ( ff . FF_CUSTOM_TAGS )
98+ ? types . late ( ( ) =>
99+ types . model ( {
100+ ...resultValues ,
101+ ...Object . fromEntries ( Registry . customTags . map ( ( t ) => [ t . resultName , types . maybe ( t . result ) ] ) ) ,
102+ } ) ,
103+ )
104+ : types . model ( {
105+ ...resultValues ,
106+ } ) ,
91107 // info about object and region
92108 meta : types . frozen ( ) ,
93109 } )
0 commit comments