fastapi-voyager 0.5.1__py3-none-any.whl → 0.5.2__py3-none-any.whl

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.
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "0.5.1"
2
+ __version__ = "0.5.2"
@@ -182,6 +182,8 @@ class Voyager:
182
182
  update_forward_refs(schema)
183
183
  self.add_to_node_set(schema)
184
184
 
185
+ base_fields = set()
186
+
185
187
  # handle schema inside ensure_subset(schema)
186
188
  if subset_reference := getattr(schema, const.ENSURE_SUBSET_REFERENCE, None):
187
189
  if is_inheritance_of_pydantic_base(subset_reference):
@@ -198,6 +200,12 @@ class Voyager:
198
200
  # handle bases
199
201
  for base_class in schema.__bases__:
200
202
  if is_inheritance_of_pydantic_base(base_class):
203
+ # collect base class field names to avoid duplicating inherited fields
204
+ try:
205
+ base_fields.update(getattr(base_class, 'model_fields', {}).keys())
206
+ except Exception:
207
+ # be defensive in case of unconventional BaseModel subclasses
208
+ pass
201
209
  self.add_to_node_set(base_class)
202
210
  self.add_to_link_set(
203
211
  source=self.generate_node_head(full_class_name(schema)),
@@ -209,6 +217,9 @@ class Voyager:
209
217
 
210
218
  # handle fields
211
219
  for k, v in schema.model_fields.items():
220
+ # skip fields inherited from base classes
221
+ if k in base_fields:
222
+ continue
212
223
  annos = get_core_types(v.annotation)
213
224
  for anno in annos:
214
225
  if anno and is_inheritance_of_pydantic_base(anno):
@@ -1,48 +1,69 @@
1
1
  import { GraphUI } from "../graph-ui.js";
2
- const { defineComponent, ref, onMounted, watch, nextTick } = window.Vue;
2
+ const { defineComponent, ref, onMounted, nextTick } = window.Vue;
3
3
 
4
- // Simple dialog-embeddable component that renders a DOT graph.
5
- // Props:
6
- // - dot: String (required) the DOT source to render
7
- // Emits:
8
- // - close: when the close button is clicked
9
4
  export default defineComponent({
10
5
  name: "RenderGraph",
11
6
  props: {
12
- dot: { type: String, required: true },
7
+ coreData: { type: [Object, Array], required: false, default: null },
13
8
  },
14
9
  emits: ["close"],
15
10
  setup(props, { emit }) {
16
11
  const containerId = `graph-render-${Math.random().toString(36).slice(2, 9)}`;
17
12
  const hasRendered = ref(false);
13
+ const loading = ref(false);
18
14
  let graphInstance = null;
19
15
 
20
- async function renderDot() {
21
- if (!props.dot) return;
16
+ async function ensureGraph() {
22
17
  await nextTick();
23
18
  if (!graphInstance) {
24
19
  graphInstance = new GraphUI(`#${containerId}`);
25
20
  }
26
- await graphInstance.render(props.dot);
21
+ }
22
+
23
+ async function renderFromDot(dotText) {
24
+ if (!dotText) return;
25
+ await ensureGraph();
26
+ await graphInstance.render(dotText);
27
27
  hasRendered.value = true;
28
28
  }
29
29
 
30
+ async function renderFromCoreData() {
31
+ if (!props.coreData) return;
32
+ loading.value = true;
33
+ try {
34
+ const res = await fetch("/dot-render-core-data", {
35
+ method: "POST",
36
+ headers: { "Content-Type": "application/json" },
37
+ body: JSON.stringify(props.coreData),
38
+ });
39
+ const dotText = await res.text();
40
+ await renderFromDot(dotText);
41
+ if (window.Quasar?.Notify) {
42
+ window.Quasar.Notify.create({ type: "positive", message: "Rendered" });
43
+ }
44
+ } catch (e) {
45
+ console.error("Render from core data failed", e);
46
+ if (window.Quasar?.Notify) {
47
+ window.Quasar.Notify.create({ type: "negative", message: "Render failed" });
48
+ }
49
+ } finally {
50
+ loading.value = false;
51
+ }
52
+ }
53
+
54
+ async function reload() {
55
+ await renderFromCoreData();
56
+ }
57
+
30
58
  onMounted(async () => {
31
- await renderDot();
59
+ await reload();
32
60
  });
33
61
 
34
- watch(
35
- () => props.dot,
36
- async () => {
37
- await renderDot();
38
- }
39
- );
40
-
41
62
  function close() {
42
63
  emit("close");
43
64
  }
44
65
 
45
- return { containerId, close, hasRendered };
66
+ return { containerId, close, hasRendered, reload, loading };
46
67
  },
47
68
  template: `
48
69
  <div style="height:100%; position:relative; background:#fff;">
@@ -52,6 +73,13 @@ export default defineComponent({
52
73
  @click="close"
53
74
  style="position:absolute; top:6px; right:6px; z-index:11; background:rgba(255,255,255,0.85);"
54
75
  />
76
+ <q-btn
77
+ flat dense round icon="refresh"
78
+ aria-label="Reload"
79
+ :loading="loading"
80
+ @click="reload"
81
+ style="position:absolute; top:6px; right:46px; z-index:11; background:rgba(255,255,255,0.85);"
82
+ />
55
83
  <div :id="containerId" style="width:100%; height:100%; overflow:auto; background:#fafafa"></div>
56
84
  </div>
57
85
  `,
@@ -250,7 +250,7 @@
250
250
 
251
251
  <!-- Render Graph Dialog (from imported core data) -->
252
252
  <q-dialog v-model="showRenderGraph" :maximized="true" :persistent="false">
253
- <render-graph :dot="renderDotString" @close="showRenderGraph = false" />
253
+ <render-graph :core-data="renderCoreData" @close="showRenderGraph = false" />
254
254
  </q-dialog>
255
255
 
256
256
  <div id="graph" style="width: 100%; flex: 1 1 auto; overflow: auto"></div>
@@ -37,8 +37,8 @@ const app = createApp({
37
37
  const dumpJson = ref("");
38
38
  const showImportDialog = ref(false);
39
39
  const importJsonText = ref("");
40
- const showRenderGraph = ref(false);
41
- const renderDotString = ref("");
40
+ const showRenderGraph = ref(false);
41
+ const renderCoreData = ref(null);
42
42
  const schemaName = ref(""); // used by detail dialog
43
43
  const schemaFieldFilterSchema = ref(null); // external schemaName for schema-field-filter
44
44
  const schemaCodeName = ref("");
@@ -222,19 +222,10 @@ const app = createApp({
222
222
  }
223
223
  return;
224
224
  }
225
- try {
226
- const res = await fetch("/dot-render-core-data", {
227
- method: "POST",
228
- headers: { "Content-Type": "application/json" },
229
- body: JSON.stringify(payloadObj),
230
- });
231
- const dotText = await res.text();
232
- renderDotString.value = dotText;
233
- showRenderGraph.value = true;
234
- showImportDialog.value = false;
235
- } catch (e) {
236
- console.error("Import render failed", e);
237
- }
225
+ // Move the request into RenderGraph component: pass the parsed object and let the component call /dot-render-core-data
226
+ renderCoreData.value = payloadObj;
227
+ showRenderGraph.value = true;
228
+ showImportDialog.value = false;
238
229
  }
239
230
 
240
231
  function showDialog() {
@@ -290,7 +281,7 @@ const app = createApp({
290
281
  onImportConfirm,
291
282
  // render graph dialog
292
283
  showRenderGraph,
293
- renderDotString,
284
+ renderCoreData,
294
285
  };
295
286
  },
296
287
  });
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-voyager
3
- Version: 0.5.1
3
+ Version: 0.5.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
@@ -6,16 +6,16 @@ fastapi_voyager/render.py,sha256=gK0ur8CAqI3jNt2H3mr-JSpC0sD1JxzLRlFcuykBkxQ,636
6
6
  fastapi_voyager/server.py,sha256=Eer6GdD9-EG9QGHlYmClF3MeVxw68amjK4iW_YZ5ShI,3751
7
7
  fastapi_voyager/type.py,sha256=Tef61aKaQdTinM8N_lpmrse8elXV8DAgY3ULySc8TEE,1642
8
8
  fastapi_voyager/type_helper.py,sha256=j7AiFXsfl4kaxshYtofbsqo08dIXiHvJ190soIzUdLk,8380
9
- fastapi_voyager/version.py,sha256=KuUsLbsba6ZKn4IW2EH9junXCihYukG7hMgo1ojf5as,48
10
- fastapi_voyager/voyager.py,sha256=xreK0tuwx1WBme4e9-YX7j92oRPpaAdY9Wh4MHu0Yhk,9626
9
+ fastapi_voyager/version.py,sha256=m_MOw_nkKIsJaKLUdJmlCrDGyTqN5GYwGMjdFF2hZmo,48
10
+ fastapi_voyager/voyager.py,sha256=InAAc_Sf1blM8X-KjF_x-CdS4OEpN-z0doMiBgnl0-A,10103
11
11
  fastapi_voyager/web/graph-ui.js,sha256=eEjDnJVMvk35LdRoxcqX_fZxLFS9_bUrGAZL6K2O5C0,4176
12
12
  fastapi_voyager/web/graphviz.svg.css,sha256=zDCjjpT0Idufu5YOiZI76PL70-avP3vTyzGPh9M85Do,1563
13
13
  fastapi_voyager/web/graphviz.svg.js,sha256=lvAdbjHc-lMSk4GQp-iqYA2PCFX4RKnW7dFaoe0LUHs,16005
14
- fastapi_voyager/web/index.html,sha256=zIihJ0S-adznFDbtoFa0cbXuP6viqZ0UtgsZWH8YSRY,10456
14
+ fastapi_voyager/web/index.html,sha256=vndU6K9BN5f75OMPPPzREF7xACmf31wTVyGuOYksiys,10461
15
15
  fastapi_voyager/web/quasar.min.css,sha256=F5jQe7X2XT54VlvAaa2V3GsBFdVD-vxDZeaPLf6U9CU,203145
16
16
  fastapi_voyager/web/quasar.min.js,sha256=h0ftyPMW_CRiyzeVfQqiup0vrVt4_QWojpqmpnpn07E,502974
17
- fastapi_voyager/web/vue-main.js,sha256=k_3SX5VHtJhtXzXEqFsB0maSJH0ljFSx7i-X4Vq40AY,9012
18
- fastapi_voyager/web/component/render-graph.js,sha256=5BdxBOWsSxWUR5tha5zEQh8eojBZjQ_vGawZFC9WNa8,1450
17
+ fastapi_voyager/web/vue-main.js,sha256=tW0jRSSABMmnAqLDaIXMeXQBm0WWOKycsYesgg8ArZw,8798
18
+ fastapi_voyager/web/component/render-graph.js,sha256=8jfN-ik7Ckn5Frx01umjlYqP6i0HELDCcWQMp5zbIhI,2323
19
19
  fastapi_voyager/web/component/route-code-display.js,sha256=NECC1OGcPCdDfbghtRJEnmFM6HmH5J3win2ibapWPeA,2649
20
20
  fastapi_voyager/web/component/schema-code-display.js,sha256=oOusgTvCaWGnoKb-NBwu0SXqJJf2PTUtp3lUczokTBM,5515
21
21
  fastapi_voyager/web/component/schema-field-filter.js,sha256=9WBjO6JJl2yf6OiiXoddMgvL32qTDu0PM-RxkkJ7t5M,6267
@@ -26,8 +26,8 @@ fastapi_voyager/web/icon/favicon-16x16.png,sha256=JC07jEzfIYxBIoQn_FHXvyHuxESdhW
26
26
  fastapi_voyager/web/icon/favicon-32x32.png,sha256=C7v1h58cfWOsiLp9yOIZtlx-dLasBcq3NqpHVGRmpt4,1859
27
27
  fastapi_voyager/web/icon/favicon.ico,sha256=tZolYIXkkBcFiYl1A8ksaXN2VjGamzcSdes838dLvNc,15406
28
28
  fastapi_voyager/web/icon/site.webmanifest,sha256=ep4Hzh9zhmiZF2At3Fp1dQrYQuYF_3ZPZxc1KcGBvwQ,263
29
- fastapi_voyager-0.5.1.dist-info/METADATA,sha256=KMBZwza3Z2hhpS1HK8WxoVBntmYEkmP0EAofWiYa2x0,6766
30
- fastapi_voyager-0.5.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
- fastapi_voyager-0.5.1.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
32
- fastapi_voyager-0.5.1.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
33
- fastapi_voyager-0.5.1.dist-info/RECORD,,
29
+ fastapi_voyager-0.5.2.dist-info/METADATA,sha256=emxagsUfAuI44P9Q0D3SMj3tkdZFNPD8UD_Ok3jscXA,6766
30
+ fastapi_voyager-0.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
+ fastapi_voyager-0.5.2.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
32
+ fastapi_voyager-0.5.2.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
33
+ fastapi_voyager-0.5.2.dist-info/RECORD,,