fastapi-voyager 0.9.1__tar.gz → 0.9.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/PKG-INFO +53 -44
  2. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/README.md +52 -43
  3. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/version.py +1 -1
  4. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/component/route-code-display.js +0 -2
  5. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/component/schema-code-display.js +3 -1
  6. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/component/schema-field-filter.js +6 -3
  7. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/index.html +1 -2
  8. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/vue-main.js +14 -56
  9. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/.gitignore +0 -0
  10. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/.python-version +0 -0
  11. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/LICENSE +0 -0
  12. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/pyproject.toml +0 -0
  13. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/__init__.py +0 -0
  14. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/cli.py +0 -0
  15. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/filter.py +0 -0
  16. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/module.py +0 -0
  17. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/render.py +0 -0
  18. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/server.py +0 -0
  19. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/type.py +0 -0
  20. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/type_helper.py +0 -0
  21. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/voyager.py +0 -0
  22. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/component/render-graph.js +0 -0
  23. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/graph-ui.js +0 -0
  24. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/graphviz.svg.css +0 -0
  25. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/graphviz.svg.js +0 -0
  26. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/icon/android-chrome-192x192.png +0 -0
  27. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/icon/android-chrome-512x512.png +0 -0
  28. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/icon/apple-touch-icon.png +0 -0
  29. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/icon/favicon-16x16.png +0 -0
  30. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/icon/favicon-32x32.png +0 -0
  31. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/icon/favicon.ico +0 -0
  32. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/icon/site.webmanifest +0 -0
  33. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/quasar.min.css +0 -0
  34. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/src/fastapi_voyager/web/quasar.min.js +0 -0
  35. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/tests/__init__.py +0 -0
  36. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/tests/demo.py +0 -0
  37. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/tests/demo_anno.py +0 -0
  38. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/tests/programatic.py +0 -0
  39. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/tests/service/__init__.py +0 -0
  40. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/tests/service/schema.py +0 -0
  41. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/tests/test_analysis.py +0 -0
  42. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/tests/test_filter.py +0 -0
  43. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/tests/test_generic.py +0 -0
  44. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/tests/test_import.py +0 -0
  45. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/tests/test_module.py +0 -0
  46. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/tests/test_type_helper.py +0 -0
  47. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/uv.lock +0 -0
  48. {fastapi_voyager-0.9.1 → fastapi_voyager-0.9.2}/voyager.jpg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-voyager
3
- Version: 0.9.1
3
+ Version: 0.9.2
4
4
  Summary: Visualize FastAPI application's routing tree and dependencies
5
5
  Project-URL: Homepage, https://github.com/allmonday/fastapi-voyager
6
6
  Project-URL: Source, https://github.com/allmonday/fastapi-voyager
@@ -28,17 +28,12 @@ Description-Content-Type: text/markdown
28
28
  [![pypi](https://img.shields.io/pypi/v/fastapi-voyager.svg)](https://pypi.python.org/pypi/fastapi-voyager)
29
29
  ![Python Versions](https://img.shields.io/pypi/pyversions/fastapi-voyager)
30
30
 
31
- <p align="center"><img src="./voyager.jpg" alt="" /></p>
32
-
33
-
34
- [![IMAGE ALT TEXT](http://img.youtube.com/vi/PGlbQq1M-n8/0.jpg)](https://www.youtube.com/watch?v=PGlbQq1M-n8 "FastAPI Voyager")
35
-
31
+ > This repo is still in early stage, it supports pydantic v2 only
36
32
 
37
- > This repo is still in early stage, currently it supports pydantic v2 only, previous name: fastapi-router-viz
33
+ Inspect your API interactively!
38
34
 
39
- Inspect your API interactively
40
-
41
- <img width="1480" height="648" alt="image" src="https://github.com/user-attachments/assets/a6ccc9f1-cf06-493a-b99b-eb07767564bd" />
35
+ <p align="center"><img src="./voyager.jpg" alt="" /></p>
36
+ <p align="center"><a target="_blank" rel="" href="https://www.youtube.com/watch?v=PGlbQq1M-n8"><img src="http://img.youtube.com/vi/PGlbQq1M-n8/0.jpg" alt="" style="max-width: 100%;"></a></p>
42
37
 
43
38
  ## Installation
44
39
 
@@ -52,11 +47,6 @@ uv add fastapi-voyager
52
47
  voyager -m path.to.your.app.module --server
53
48
  ```
54
49
 
55
- ## Dependencies
56
-
57
- - FastAPI
58
- - [pydantic-resolve](https://github.com/allmonday/pydantic-resolve)
59
-
60
50
 
61
51
  ## Feature
62
52
 
@@ -79,9 +69,9 @@ voyager -m tests.demo
79
69
  ```
80
70
 
81
71
  ### generate the graph
82
- after initialization, pick tag, rotue (optional) and click `generate`.
72
+ after initialization, pick tag, rotue to render graph
83
73
 
84
- <img width="1919" height="898" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/05e321d0-49f3-4af6-a7c7-f4c9c6b1dbfd" />
74
+ <img width="1628" height="765" alt="image" src="https://github.com/user-attachments/assets/b4712f82-e754-453b-aa69-24c932b8f48f" />
85
75
 
86
76
  ### highlight
87
77
  click a node to highlight it's upperstream and downstream nodes. figure out the related models of one page, or homw many pages are related with one model.
@@ -89,9 +79,9 @@ click a node to highlight it's upperstream and downstream nodes. figure out the
89
79
  <img width="1485" height="616" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/70c4095f-86c7-45da-a6f0-fd41ac645813" />
90
80
 
91
81
  ### filter related nodes
92
- `shift` click a node to check related node, pick a field to narrow the result.
82
+ `shift` click a node to check related node, pick a field to narrow the result, picked node is marked as red.
93
83
 
94
- <img width="1917" height="800" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/e770dc70-f293-49e1-bcd7-d8dffa15d9ea" />
84
+ <img width="1423" height="552" alt="image" src="https://github.com/user-attachments/assets/468a058d-afa1-4601-a7c5-c6aad6a8a557" />
95
85
 
96
86
  ### view source code
97
87
  `alt` click a node to show source code or open file in vscode.
@@ -168,7 +158,25 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
168
158
 
169
159
  ## Plan before v1.0
170
160
 
171
- ### features:
161
+
162
+ ### backlog
163
+ - [ ] user can generate nodes/edges manually and connect to generated ones
164
+ - [ ] add owner
165
+ - [ ] add extra info for schema
166
+ - [ ] fixed left/right bar show field information
167
+ - [ ] display standard ER diagram `hard`
168
+ - [ ] display potential invalid links
169
+ - [ ] support dataclass (pending)
170
+
171
+ ### in analysis
172
+ - [ ] click field to highlight links
173
+ - [ ] animation effect for edges
174
+ - [ ] customrized right click panel
175
+ - [ ] show own dependencies
176
+ - [ ] clean up fe code
177
+
178
+ ### plan:
179
+ #### <0.9:
172
180
  - [x] group schemas by module hierarchy
173
181
  - [x] module-based coloring via Analytics(module_color={...})
174
182
  - [x] view in web browser
@@ -196,26 +204,6 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
196
204
  - [x] fix duplicated link from class and parent class, it also break clicking highlight
197
205
  - [x] refactor: abstract render module
198
206
 
199
- ### backlog
200
- - [ ] user can generate nodes/edges manually and connect to generated ones
201
- - [ ] add owner
202
- - [ ] add extra info for schema
203
- - [ ] fixed left/right bar show field information
204
- - [ ] display standard ER diagram `hard`
205
- - [ ] display potential invalid links
206
-
207
- bugs & non feature:
208
- - [ ] add tests
209
- - [ ] support dataclass (pending)
210
-
211
- ### in analysis
212
- - [ ] click field to highlight links
213
- - [ ] animation effect for edges
214
- - [ ] customrized right click panel
215
- - [ ] show own dependencies
216
-
217
- ### plan:
218
-
219
207
  #### 0.9
220
208
  - [x] refactor: server.py
221
209
  - [x] rename create_app_with_fastapi -> create_voyager
@@ -225,13 +213,24 @@ bugs & non feature:
225
213
  - [x] adjust fe
226
214
 
227
215
  #### 0.10
228
- - [ ] logging information
229
- - [ ] open route in swagger
216
+ - [ ] support opening route in swagger
230
217
  - config docs path
231
218
  - [ ] add http method for route
232
219
  - [ ] enable/disable module cluster (may save space)
220
+ - [ ] logging information
221
+ - [ ] add tests
222
+ - [ ] hide brief mode if not configured
223
+ - [ ] optimize static resource
224
+ - [ ] show route count in tag expansion item
225
+ - [ ] route list show have a max height to trigger scrollable
226
+ - [ ] fix layout issue when rendering huge graph
233
227
 
234
228
  #### 0.11
229
+ - [ ] improve user experience
230
+ - double click to show detail
231
+ - improve search dialog
232
+
233
+ #### 0.12
235
234
  - [ ] integration with pydantic-resolve
236
235
  - [ ] show hint for resolve, post fields
237
236
  - [ ] display loader as edges
@@ -247,13 +246,23 @@ pydantic-resolve's @ensure_subset decorator is helpful to pick fields from `sour
247
246
 
248
247
  ## Credits
249
248
 
250
- - https://apis.guru/graphql-voyager/, for inspiration.
251
- - https://github.com/tintinweb/vscode-interactive-graphviz, for web visualization.
249
+ - https://apis.guru/graphql-voyager/, thanks for inspiration.
250
+ - https://github.com/tintinweb/vscode-interactive-graphviz, thanks for web visualization.
251
+
252
+
253
+ ## Dependencies
254
+
255
+ - FastAPI
256
+ - [pydantic-resolve](https://github.com/allmonday/pydantic-resolve)
257
+ - Quasar
252
258
 
253
259
 
254
260
  ## Changelog
255
261
 
256
262
  - 0.9:
263
+ - 0.9.2:
264
+ - fix: missing fields in schema detail panel
265
+ - optimization: clean up fe codes.
257
266
  - 0.9.1:
258
267
  - api change: from `create_app_with_fastapi` to `create_voyager`, and expose as `from fastapi_voyager import create_voyager`
259
268
  - optimization: lazy load vscode link and source code, speed up the initialization.
@@ -1,17 +1,12 @@
1
1
  [![pypi](https://img.shields.io/pypi/v/fastapi-voyager.svg)](https://pypi.python.org/pypi/fastapi-voyager)
2
2
  ![Python Versions](https://img.shields.io/pypi/pyversions/fastapi-voyager)
3
3
 
4
- <p align="center"><img src="./voyager.jpg" alt="" /></p>
5
-
6
-
7
- [![IMAGE ALT TEXT](http://img.youtube.com/vi/PGlbQq1M-n8/0.jpg)](https://www.youtube.com/watch?v=PGlbQq1M-n8 "FastAPI Voyager")
8
-
4
+ > This repo is still in early stage, it supports pydantic v2 only
9
5
 
10
- > This repo is still in early stage, currently it supports pydantic v2 only, previous name: fastapi-router-viz
6
+ Inspect your API interactively!
11
7
 
12
- Inspect your API interactively
13
-
14
- <img width="1480" height="648" alt="image" src="https://github.com/user-attachments/assets/a6ccc9f1-cf06-493a-b99b-eb07767564bd" />
8
+ <p align="center"><img src="./voyager.jpg" alt="" /></p>
9
+ <p align="center"><a target="_blank" rel="" href="https://www.youtube.com/watch?v=PGlbQq1M-n8"><img src="http://img.youtube.com/vi/PGlbQq1M-n8/0.jpg" alt="" style="max-width: 100%;"></a></p>
15
10
 
16
11
  ## Installation
17
12
 
@@ -25,11 +20,6 @@ uv add fastapi-voyager
25
20
  voyager -m path.to.your.app.module --server
26
21
  ```
27
22
 
28
- ## Dependencies
29
-
30
- - FastAPI
31
- - [pydantic-resolve](https://github.com/allmonday/pydantic-resolve)
32
-
33
23
 
34
24
  ## Feature
35
25
 
@@ -52,9 +42,9 @@ voyager -m tests.demo
52
42
  ```
53
43
 
54
44
  ### generate the graph
55
- after initialization, pick tag, rotue (optional) and click `generate`.
45
+ after initialization, pick tag, rotue to render graph
56
46
 
57
- <img width="1919" height="898" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/05e321d0-49f3-4af6-a7c7-f4c9c6b1dbfd" />
47
+ <img width="1628" height="765" alt="image" src="https://github.com/user-attachments/assets/b4712f82-e754-453b-aa69-24c932b8f48f" />
58
48
 
59
49
  ### highlight
60
50
  click a node to highlight it's upperstream and downstream nodes. figure out the related models of one page, or homw many pages are related with one model.
@@ -62,9 +52,9 @@ click a node to highlight it's upperstream and downstream nodes. figure out the
62
52
  <img width="1485" height="616" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/70c4095f-86c7-45da-a6f0-fd41ac645813" />
63
53
 
64
54
  ### filter related nodes
65
- `shift` click a node to check related node, pick a field to narrow the result.
55
+ `shift` click a node to check related node, pick a field to narrow the result, picked node is marked as red.
66
56
 
67
- <img width="1917" height="800" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/e770dc70-f293-49e1-bcd7-d8dffa15d9ea" />
57
+ <img width="1423" height="552" alt="image" src="https://github.com/user-attachments/assets/468a058d-afa1-4601-a7c5-c6aad6a8a557" />
68
58
 
69
59
  ### view source code
70
60
  `alt` click a node to show source code or open file in vscode.
@@ -141,7 +131,25 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
141
131
 
142
132
  ## Plan before v1.0
143
133
 
144
- ### features:
134
+
135
+ ### backlog
136
+ - [ ] user can generate nodes/edges manually and connect to generated ones
137
+ - [ ] add owner
138
+ - [ ] add extra info for schema
139
+ - [ ] fixed left/right bar show field information
140
+ - [ ] display standard ER diagram `hard`
141
+ - [ ] display potential invalid links
142
+ - [ ] support dataclass (pending)
143
+
144
+ ### in analysis
145
+ - [ ] click field to highlight links
146
+ - [ ] animation effect for edges
147
+ - [ ] customrized right click panel
148
+ - [ ] show own dependencies
149
+ - [ ] clean up fe code
150
+
151
+ ### plan:
152
+ #### <0.9:
145
153
  - [x] group schemas by module hierarchy
146
154
  - [x] module-based coloring via Analytics(module_color={...})
147
155
  - [x] view in web browser
@@ -169,26 +177,6 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
169
177
  - [x] fix duplicated link from class and parent class, it also break clicking highlight
170
178
  - [x] refactor: abstract render module
171
179
 
172
- ### backlog
173
- - [ ] user can generate nodes/edges manually and connect to generated ones
174
- - [ ] add owner
175
- - [ ] add extra info for schema
176
- - [ ] fixed left/right bar show field information
177
- - [ ] display standard ER diagram `hard`
178
- - [ ] display potential invalid links
179
-
180
- bugs & non feature:
181
- - [ ] add tests
182
- - [ ] support dataclass (pending)
183
-
184
- ### in analysis
185
- - [ ] click field to highlight links
186
- - [ ] animation effect for edges
187
- - [ ] customrized right click panel
188
- - [ ] show own dependencies
189
-
190
- ### plan:
191
-
192
180
  #### 0.9
193
181
  - [x] refactor: server.py
194
182
  - [x] rename create_app_with_fastapi -> create_voyager
@@ -198,13 +186,24 @@ bugs & non feature:
198
186
  - [x] adjust fe
199
187
 
200
188
  #### 0.10
201
- - [ ] logging information
202
- - [ ] open route in swagger
189
+ - [ ] support opening route in swagger
203
190
  - config docs path
204
191
  - [ ] add http method for route
205
192
  - [ ] enable/disable module cluster (may save space)
193
+ - [ ] logging information
194
+ - [ ] add tests
195
+ - [ ] hide brief mode if not configured
196
+ - [ ] optimize static resource
197
+ - [ ] show route count in tag expansion item
198
+ - [ ] route list show have a max height to trigger scrollable
199
+ - [ ] fix layout issue when rendering huge graph
206
200
 
207
201
  #### 0.11
202
+ - [ ] improve user experience
203
+ - double click to show detail
204
+ - improve search dialog
205
+
206
+ #### 0.12
208
207
  - [ ] integration with pydantic-resolve
209
208
  - [ ] show hint for resolve, post fields
210
209
  - [ ] display loader as edges
@@ -220,13 +219,23 @@ pydantic-resolve's @ensure_subset decorator is helpful to pick fields from `sour
220
219
 
221
220
  ## Credits
222
221
 
223
- - https://apis.guru/graphql-voyager/, for inspiration.
224
- - https://github.com/tintinweb/vscode-interactive-graphviz, for web visualization.
222
+ - https://apis.guru/graphql-voyager/, thanks for inspiration.
223
+ - https://github.com/tintinweb/vscode-interactive-graphviz, thanks for web visualization.
224
+
225
+
226
+ ## Dependencies
227
+
228
+ - FastAPI
229
+ - [pydantic-resolve](https://github.com/allmonday/pydantic-resolve)
230
+ - Quasar
225
231
 
226
232
 
227
233
  ## Changelog
228
234
 
229
235
  - 0.9:
236
+ - 0.9.2:
237
+ - fix: missing fields in schema detail panel
238
+ - optimization: clean up fe codes.
230
239
  - 0.9.1:
231
240
  - api change: from `create_app_with_fastapi` to `create_voyager`, and expose as `from fastapi_voyager import create_voyager`
232
241
  - optimization: lazy load vscode link and source code, speed up the initialization.
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "0.9.1"
2
+ __version__ = "0.9.2"
@@ -4,13 +4,11 @@ const { defineComponent, ref, watch, onMounted } = window.Vue;
4
4
  // Props:
5
5
  // routeId: route id key in routeItems
6
6
  // modelValue: dialog visibility
7
- // routes: object map { id: { id, name, source_code } }
8
7
  export default defineComponent({
9
8
  name: "RouteCodeDisplay",
10
9
  props: {
11
10
  routeId: { type: String, required: true },
12
11
  modelValue: { type: Boolean, default: false },
13
- routes: { type: Object, default: () => ({}) },
14
12
  },
15
13
  emits: ["close"],
16
14
  setup(props, { emit }) {
@@ -14,7 +14,7 @@ export default defineComponent({
14
14
  props: {
15
15
  schemaName: { type: String, required: true },
16
16
  modelValue: { type: Boolean, default: false },
17
- schemas: { type: Array, default: () => [] },
17
+ schemas: { type: Object, default: () => ({}) },
18
18
  },
19
19
  emits: ["close"],
20
20
  setup(props, { emit }) {
@@ -102,6 +102,8 @@ export default defineComponent({
102
102
  loading.value = false;
103
103
  }
104
104
 
105
+ fields.value = props.schemas[props.schemaName].fields || []
106
+
105
107
  if (!error.value && tab.value === "source") {
106
108
  highlightLater();
107
109
  }
@@ -14,7 +14,8 @@ export default defineComponent({
14
14
  name: "SchemaFieldFilter",
15
15
  props: {
16
16
  schemaName: { type: String, default: null }, // external injection triggers auto-query
17
- schemas: { type: Array, default: () => [] }, // externally provided schemas (state.rawSchemasFull or similar)
17
+ // externally provided schemas dict (state.rawSchemasFull): { [id]: schema }
18
+ schemas: { type: Object, default: () => ({}) },
18
19
  },
19
20
  emits: ["queried", "close"],
20
21
  setup(props, { emit }) {
@@ -39,9 +40,11 @@ export default defineComponent({
39
40
  let lastAppliedExternal = null;
40
41
 
41
42
  async function loadSchemas() {
42
- // Refactored: use externally provided props.schemas directly; no network call.
43
+ // Use externally provided props.schemas dict directly; no network call.
43
44
  state.error = null;
44
- state.schemas = Array.isArray(props.schemas) ? props.schemas : [];
45
+ const dict = props.schemas && typeof props.schemas === "object" ? props.schemas : {};
46
+ // Flatten to array for local operations
47
+ state.schemas = Object.values(dict);
45
48
  state.schemaOptions = state.schemas.map((s) => ({
46
49
  label: `${s.name} (${s.id})`,
47
50
  value: s.id,
@@ -197,7 +197,7 @@
197
197
  </div>
198
198
  </div>
199
199
  </div>
200
- <div style="flex: 1 1 auto; min-height: 0;">
200
+ <div style="flex: 1 1 auto; min-height: 10px;">
201
201
  <q-splitter
202
202
  v-model="state.splitter"
203
203
  unit="px"
@@ -323,7 +323,6 @@
323
323
  <route-code-display
324
324
  :route-id="routeCodeId"
325
325
  :model-value="showRouteCode"
326
- :routes="state.routeItems"
327
326
  @close="showRouteCode = false"
328
327
  />
329
328
  </q-dialog>
@@ -9,13 +9,9 @@ const app = createApp({
9
9
  setup() {
10
10
  const state = reactive({
11
11
  // options and selections
12
- tag: null,
13
- tagOptions: [], // array of strings
14
- routeId: null,
15
- routeOptions: [], // [{ label, value }]
16
- schemaId: null,
17
- schemaOptions: [], // [{ label, value }]
18
- routeItems: {}, // { id: { label, value } }
12
+ tag: null, // picked tag
13
+ routeId: null, // picked route
14
+ schemaId: null, // picked schema
19
15
  showFields: "object",
20
16
  fieldOptions: [
21
17
  { label: "No fields", value: "single" },
@@ -26,17 +22,17 @@ const app = createApp({
26
22
  hidePrimitiveRoute: false,
27
23
  generating: false,
28
24
  rawTags: [], // [{ name, routes: [{ id, name }] }]
29
- rawSchemas: [], // [{ name, id }]
30
- rawSchemasFull: [], // full objects with source_code & fields
25
+ rawSchemas: new Set(), // [{ name, id }]
26
+ rawSchemasFull: {}, // full schemas dict: { [schema.id]: schema }
31
27
  initializing: true,
32
28
  // Splitter size (left panel width in px)
33
29
  splitter: 300,
34
30
  });
31
+
35
32
  const showDetail = ref(false);
36
33
  const showSchemaFieldFilter = ref(false);
37
34
  const showSchemaCode = ref(false);
38
35
  const showRouteCode = ref(false);
39
- // Dump/Import dialogs and rendered graph dialog
40
36
  const showDumpDialog = ref(false);
41
37
  const dumpJson = ref("");
42
38
  const showImportDialog = ref(false);
@@ -55,47 +51,18 @@ const app = createApp({
55
51
  showDetail.value = false;
56
52
  }
57
53
 
58
- function onFilterTags(val, update) {
59
- const normalized = (val || "").toLowerCase();
60
- update(() => {
61
- if (!normalized) {
62
- state.tagOptions = state.rawTags.map((t) => t.name);
63
- return;
64
- }
65
- state.tagOptions = state.rawTags
66
- .map((t) => t.name)
67
- .filter((n) => n.toLowerCase().includes(normalized));
68
- });
69
- }
70
-
71
- function onFilterSchemas(val, update) {
72
- const normalized = (val || "").toLowerCase();
73
- update(() => {
74
- const makeLabel = (s) => `${s.name} (${s.id})`;
75
- let list = state.rawSchemas.map((s) => ({
76
- label: makeLabel(s),
77
- value: s.id,
78
- }));
79
- if (normalized) {
80
- list = list.filter((opt) =>
81
- opt.label.toLowerCase().includes(normalized)
82
- );
83
- }
84
- state.schemaOptions = list;
85
- });
86
- }
87
-
88
54
  async function loadInitial() {
89
55
  state.initializing = true;
90
56
  try {
91
57
  const res = await fetch("dot");
92
58
  const data = await res.json();
93
59
  state.rawTags = Array.isArray(data.tags) ? data.tags : [];
94
- state.rawSchemasFull = Array.isArray(data.schemas) ? data.schemas : [];
95
- state.rawSchemas = state.rawSchemasFull.map((s) => ({
96
- name: s.name,
97
- id: s.id,
98
- }));
60
+ const schemasArr = Array.isArray(data.schemas) ? data.schemas : [];
61
+ // Build dict keyed by id for faster lookups and simpler prop passing
62
+ state.rawSchemasFull = Object.fromEntries(
63
+ schemasArr.map((s) => [s.id, s])
64
+ );
65
+ state.rawSchemas = new Set(Object.keys(state.rawSchemasFull));
99
66
  state.routeItems = data.tags
100
67
  .map((t) => t.routes)
101
68
  .flat()
@@ -104,13 +71,7 @@ const app = createApp({
104
71
  return acc;
105
72
  }, {});
106
73
 
107
- state.tagOptions = state.rawTags.map((t) => t.name);
108
- state.schemaOptions = state.rawSchemas.map((s) => ({
109
- label: `${s.name} (${s.id})`,
110
- value: s.id,
111
- }));
112
74
  // default route options placeholder
113
- state.routeOptions = [];
114
75
  } catch (e) {
115
76
  console.error("Initial load failed", e);
116
77
  } finally {
@@ -140,14 +101,13 @@ const app = createApp({
140
101
  // create graph instance once
141
102
  const graphUI = new GraphUI("#graph", {
142
103
  onSchemaClick: (id) => {
143
- if (state.rawSchemas.find((s) => s.id === id)) {
104
+ if (state.rawSchemas.has(id)) {
144
105
  schemaFieldFilterSchema.value = id;
145
106
  showSchemaFieldFilter.value = true;
146
107
  }
147
108
  },
148
109
  onSchemaAltClick: (id) => {
149
- // priority: schema id; else route id
150
- if (state.rawSchemas.find((s) => s.id === id)) {
110
+ if (state.rawSchemas.has(id)) {
151
111
  schemaCodeName.value = id;
152
112
  showSchemaCode.value = true;
153
113
  return;
@@ -282,8 +242,6 @@ const app = createApp({
282
242
  toggleBrief,
283
243
  toggleHidePrimitiveRoute,
284
244
  selectRoute,
285
- onFilterTags,
286
- onFilterSchemas,
287
245
  onGenerate,
288
246
  onReset,
289
247
  showDetail,
File without changes
File without changes