11# Standard library imports 
22import  json 
33import  os 
4- from  typing  import  cast ,  Any 
4+ from  typing  import  Any ,  TypedDict 
55# Third party imports 
66import  flask 
77import  opengeode 
1212routes  =  flask .Blueprint ("create" , __name__ , url_prefix = "/opengeodeweb_back/create" )
1313schemas  =  os .path .join (os .path .dirname (__file__ ), "schemas" )
1414
15- # --- Type definitions for JSON and RPC --- 
16- type JsonPrimitive  =  str  |  int  |  float  |  bool 
17- type JsonValue  =  JsonPrimitive  |  dict [str , JsonValue ] |  list [JsonValue ]
18- type RpcParams  =  dict [str , JsonValue ]
19- type SchemaDict  =  dict [str , Any ]  # Changé pour éviter cast sur json.load 
15+ # --- Type definitions --- 
16+ type SchemaDict  =  dict [str , Any ]
2017
21- # --- Specialized type aliases for each RPC endpoint --- 
22- type PointDict  =  dict [str , float ]  # {"x": float, "y": float} 
23- type CreatePointParams  =  dict [str , str  |  float ]  # {"name": str, "x": float, "y": float, "z": float} 
24- type CreateAOIParams  =  dict [str , str  |  float  |  list [PointDict ]]  # {"name": str, "points": list[PointDict], "z": float} 
18+ class  PointDict (TypedDict ):
19+     x : float 
20+     y : float 
2521
26- # Load schema for point creation 
22+ class  CreatePointParams (TypedDict ):
23+     name : str 
24+     x : float 
25+     y : float 
26+     z : float 
27+ 
28+ class  CreateAOIParams (TypedDict ):
29+     name : str 
30+     points : list [PointDict ]
31+     z : float 
32+ 
33+ # Load schemas 
2734with  open (os .path .join (schemas , "create_point.json" ), "r" ) as  file :
2835    create_point_json : SchemaDict  =  json .load (file )
2936
@@ -38,10 +45,10 @@ def create_point() -> flask.Response:
3845
3946    # Extract and validate data from request 
4047    params : CreatePointParams  =  flask .request .get_json ()
41-     name :  str   =  params ["name" ]   # type: ignore 
42-     x :  float   =  params ["x" ]   # type: ignore 
43-     y :  float   =  params ["y" ]   # type: ignore 
44-     z :  float   =  params ["z" ]   # type: ignore 
48+     name   =  params ["name" ]
49+     x   =  params ["x" ]
50+     y   =  params ["y" ]
51+     z   =  params ["z" ]
4552
4653    # Create the point 
4754    class_  =  geode_functions .geode_object_class ("PointSet3D" )
@@ -75,9 +82,9 @@ def create_aoi() -> flask.Response:
7582
7683    # Extract and validate data from request 
7784    params : CreateAOIParams  =  flask .request .get_json ()
78-     name :  str   =  params ["name" ]   # type: ignore 
79-     points :  list [ PointDict ]  =  params ["points" ]   # type: ignore 
80-     z :  float   =  params ["z" ]   # type: ignore 
85+     name   =  params ["name" ]
86+     points   =  params ["points" ]
87+     z   =  params ["z" ]
8188
8289    # Create the edged curve 
8390    class_  =  geode_functions .geode_object_class ("EdgedCurve3D" )
@@ -98,7 +105,7 @@ def create_aoi() -> flask.Response:
98105        edge_id  =  builder .create_edge ()
99106        builder .set_edge_vertex (opengeode .EdgeVertex (edge_id , 0 ), vertex_indices [i ])
100107        builder .set_edge_vertex (opengeode .EdgeVertex (edge_id , 1 ), vertex_indices [next_i ])
101- 
108+          
102109    # Save and get info 
103110    result  =  save_all_viewables_and_return_info (
104111        geode_object = "EdgedCurve3D" ,
0 commit comments