fastapi-voyager 0.12.9__py3-none-any.whl → 0.12.11__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.
fastapi_voyager/render.py CHANGED
@@ -57,7 +57,7 @@ class Renderer:
57
57
  header_color = 'tomato' if node.id == self.schema else default_color
58
58
  header = f"""<tr><td cellpadding="6" bgcolor="{header_color}" align="center" colspan="1" port="{PK}"> <font color="white"> {node.name} </font></td> </tr>"""
59
59
  field_content = ''.join(fields_parts) if fields_parts else ''
60
- return f"""<<table border="1" cellborder="0" cellpadding="0" bgcolor="white"> {header} {field_content} </table>>"""
60
+ return f"""<<table border="0" cellborder="1" cellpadding="0" cellspacing="0" bgcolor="white"> {header} {field_content} </table>>"""
61
61
 
62
62
  def _handle_schema_anchor(self, source: str) -> str:
63
63
  if '::' in source:
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "0.12.9"
2
+ __version__ = "0.12.11"
@@ -91,7 +91,13 @@ export class GraphUI {
91
91
  ready: function () {
92
92
  self.gv = this;
93
93
 
94
- self.gv.nodes().dblclick(function (event) {
94
+ const nodes = self.gv.nodes();
95
+ const edges = self.gv.edges();
96
+
97
+ nodes.off(".graphui");
98
+ edges.off(".graphui");
99
+
100
+ nodes.on("dblclick.graphui", function (event) {
95
101
  event.stopPropagation();
96
102
  try {
97
103
  self.highlightSchemaBanner(this)
@@ -110,7 +116,7 @@ export class GraphUI {
110
116
  }
111
117
  });
112
118
 
113
- self.gv.edges().click(function (event) {
119
+ edges.on("click.graphui", function (event) {
114
120
  const up = $();
115
121
  const down = $();
116
122
  const edge = $();
@@ -127,13 +133,14 @@ export class GraphUI {
127
133
  self._highlightEdgeNodes();
128
134
  })
129
135
 
130
- self.gv.nodes().click(function (event) {
136
+ nodes.on("click.graphui", function (event) {
131
137
  const set = $();
132
138
  set.push(this);
133
139
  const obj = { set, direction: "bidirectional" };
134
140
 
135
141
  const schemaName = event.currentTarget.dataset.name;
136
- if (event.shiftKey && self.options.onSchemaClick) {
142
+ console.log("shift click detected");
143
+ if (event.shiftKey && self.options.onSchemaShiftClick) {
137
144
  if (schemaName) {
138
145
  try {
139
146
  self.options.onSchemaShiftClick(schemaName);
@@ -158,7 +158,16 @@
158
158
  @update:model-value="onSearchSchemaChange"
159
159
  @filter="filterSearchSchemas"
160
160
  @clear="resetSearch"
161
- ></q-select>
161
+ >
162
+ <template v-slot:option="scope">
163
+ <q-item v-bind="scope.itemProps">
164
+ <q-item-section>
165
+ <q-item-label>{{ scope.opt.label }}</q-item-label>
166
+ <q-item-label caption>{{ scope.opt.desc }}</q-item-label>
167
+ </q-item-section>
168
+ </q-item>
169
+ </template>
170
+ </q-select>
162
171
 
163
172
  <q-select
164
173
  dense
@@ -272,7 +281,6 @@
272
281
  expand-separator
273
282
  :model-value="store.state.leftPanel._tag === tag.name || store.state.search.mode"
274
283
  @update:model-value="(val) => toggleTag(tag.name, val)"
275
- @click="() => toggleTag(tag.name, true)"
276
284
  :header-class="store.state.leftPanel.tag === tag.name ? 'text-primary text-bold tag-bg' : 'tag-bg'"
277
285
  content-class="q-pa-none"
278
286
  >
@@ -9,6 +9,12 @@ const state = reactive({
9
9
  config: {
10
10
  initial_page_policy: 'first'
11
11
  },
12
+
13
+ previousTagRoute: { // for shift + click, store previous tag/route, and populate back when needed
14
+ hasValue: false,
15
+ tag: null,
16
+ routeId: null
17
+ },
12
18
 
13
19
  swagger: {
14
20
  url: ''
@@ -12,14 +12,11 @@ const app = createApp({
12
12
  let graphUI = null;
13
13
  const allSchemaOptions = ref([]);
14
14
 
15
- const NBSP = String.fromCharCode(160);
16
- const formatSchemaLabel = (name, id) =>
17
- `${name}${NBSP}${NBSP}${NBSP}-${NBSP}${NBSP}${NBSP}${id}`;
18
-
19
15
  function rebuildSchemaOptions() {
20
16
  const dict = store.state.graph.schemaMap || {};
21
17
  const opts = Object.values(dict).map((s) => ({
22
- label: formatSchemaLabel(s.name, s.id),
18
+ label: s.name,
19
+ desc: s.id,
23
20
  value: s.id,
24
21
  }));
25
22
  allSchemaOptions.value = opts;
@@ -64,7 +61,11 @@ const app = createApp({
64
61
  function onSearchSchemaChange(val) {
65
62
  store.state.search.schemaName = val;
66
63
  store.state.search.mode = false;
67
- onSearch()
64
+ if (!val) {
65
+ // Clearing the select should only run resetSearch via @clear
66
+ return;
67
+ }
68
+ onSearch();
68
69
  }
69
70
 
70
71
  function readQuerySelection() {
@@ -132,9 +133,19 @@ const app = createApp({
132
133
 
133
134
  async function resetSearch() {
134
135
  store.state.search.mode = false;
135
- store.state.leftPanel.tag = null;
136
- store.state.leftPanel._tag = null;
137
- store.state.leftPanel.routeId = null;
136
+ console.log(store.state.previousTagRoute.hasValue)
137
+ console.log(store.state.previousTagRoute)
138
+ if (store.state.previousTagRoute.hasValue) {
139
+ store.state.leftPanel.tag = store.state.previousTagRoute.tag;
140
+ store.state.leftPanel._tag = store.state.previousTagRoute.tag;
141
+ store.state.leftPanel.routeId = store.state.previousTagRoute.routeId;
142
+ store.state.previousTagRoute.hasValue = false;
143
+ } else {
144
+ store.state.leftPanel.tag = null;
145
+ store.state.leftPanel._tag = null;
146
+ store.state.leftPanel.routeId = null;
147
+ }
148
+
138
149
  syncSelectionToUrl()
139
150
  await loadSearchedTags();
140
151
  renderBasedOnInitialPolicy()
@@ -270,12 +281,19 @@ const app = createApp({
270
281
  graphUI = new GraphUI("#graph", {
271
282
  onSchemaShiftClick: (id) => {
272
283
  if (store.state.graph.schemaKeys.has(id)) {
284
+
285
+ console.log(store.state.leftPanel)
286
+ store.state.previousTagRoute.tag = store.state.leftPanel.tag;
287
+ store.state.previousTagRoute.routeId = store.state.leftPanel.routeId;
288
+ store.state.previousTagRoute.hasValue = true;
289
+
273
290
  store.state.search.mode = true;
274
291
  store.state.search.schemaName = id;
275
292
  onSearch();
276
293
  }
277
294
  },
278
295
  onSchemaClick: (id) => {
296
+ console.log("schema clicked:", id);
279
297
  resetDetailPanels();
280
298
  if (store.state.graph.schemaKeys.has(id)) {
281
299
  store.state.schemaDetail.schemaCodeName = id;
@@ -314,7 +332,7 @@ const app = createApp({
314
332
  }
315
333
 
316
334
  function toggleTag(tagName, expanded = null) {
317
- if (expanded === true) {
335
+ if (expanded === true || store.state.search.mode === true) {
318
336
  store.state.leftPanel._tag = tagName;
319
337
  store.state.leftPanel.tag = tagName;
320
338
  store.state.leftPanel.routeId = "";
@@ -331,16 +349,24 @@ const app = createApp({
331
349
  }
332
350
 
333
351
  function selectRoute(routeId) {
352
+ // find belonging tag
353
+ const belongingTag = findTagByRoute(routeId);
354
+ if (belongingTag) {
355
+ store.state.leftPanel.tag = belongingTag;
356
+ store.state.leftPanel._tag = belongingTag;
357
+ }
358
+
334
359
  if (store.state.leftPanel.routeId === routeId) {
335
360
  store.state.leftPanel.routeId = "";
336
361
  } else {
337
362
  store.state.leftPanel.routeId = routeId;
338
363
  }
364
+
339
365
  store.state.rightDrawer.drawer = false;
340
366
  store.state.routeDetail.show = false;
341
367
  store.state.schemaDetail.schemaCodeName = "";
342
- onGenerate();
343
368
  syncSelectionToUrl();
369
+ onGenerate();
344
370
  }
345
371
 
346
372
  function toggleShowModule(val) {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-voyager
3
- Version: 0.12.9
3
+ Version: 0.12.11
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
@@ -31,7 +31,6 @@ Description-Content-Type: text/markdown
31
31
  [![PyPI Downloads](https://static.pepy.tech/badge/fastapi-voyager/month)](https://pepy.tech/projects/fastapi-voyager)
32
32
 
33
33
 
34
-
35
34
  Visualize your FastAPI endpoints, and explore them interactively.
36
35
 
37
36
  > This repo is still in early stage, it supports pydantic v2 only
@@ -49,7 +48,7 @@ app.mount('/voyager',
49
48
  module_color={'src.services': 'tomato'},
50
49
  module_prefix='src.services',
51
50
  swagger_url="/docs",
52
- ga_id="G-R64S7Q49VL",
51
+ ga_id="G-XXXXXXXXVL",
53
52
  initial_page_policy='first',
54
53
  online_repo_url='https://github.com/allmonday/composition-oriented-development-pattern/blob/master'))
55
54
  ```
@@ -2,20 +2,20 @@ fastapi_voyager/__init__.py,sha256=kqwzThE1YhmQ_7jPKGlnWvqRGC-hFrRqq_lKhKaleYU,2
2
2
  fastapi_voyager/cli.py,sha256=td3yIIigEomhSdDO-Xkh-CgpEwCafwlwnpvxnT9QsBo,10488
3
3
  fastapi_voyager/filter.py,sha256=AN_HIu8-DtKisIq5mFt7CnqRHtxKewedNGyyaI82hSY,11529
4
4
  fastapi_voyager/module.py,sha256=h9YR3BpS-CAcJW9WCdVkF4opqwY32w9T67g9GfdLytk,3425
5
- fastapi_voyager/render.py,sha256=7jSChISqTV2agaO55thhwyrOhqVOMux4x7k8rSQROnU,9960
5
+ fastapi_voyager/render.py,sha256=O_HR8ypOrFhjejkBpKIH_8foB78DgzH0hvO-CWeYt0w,9976
6
6
  fastapi_voyager/server.py,sha256=wwCFl1eeq_jn8nfIwcy7s8Sh6MB55SN8u9AsJRnkFWQ,7979
7
7
  fastapi_voyager/type.py,sha256=7EL1zaIwKVRGpLig7fqaOrZGN5k0Rm31C9COfck3CSs,1750
8
8
  fastapi_voyager/type_helper.py,sha256=UTCFWluFeGdGkJX3wiE_bZ2EgZsu4JkmqHjsJVdG81Q,9953
9
- fastapi_voyager/version.py,sha256=zqg8eyYmMv7qmhNprlm0Gp1wy1_Md8MuU6RGjhIE1LQ,49
9
+ fastapi_voyager/version.py,sha256=YNroKDVY4KuIpPNPQwev35dx9wIdzbqUsl6fQBE7haU,50
10
10
  fastapi_voyager/voyager.py,sha256=qJZvkLh5W_18X5B4pJ8XYbytx2Wvcz-0OnYoHWw8XlA,14046
11
- fastapi_voyager/web/graph-ui.js,sha256=wxKjmVEpaMJZXMTW7tJ4BiaACCI1oVN6cx7hSMI0K5U,6428
11
+ fastapi_voyager/web/graph-ui.js,sha256=hTsZO1Ly1JuoRg0kZWQ62jeLiD2kbnzACfbSPd0F95U,6634
12
12
  fastapi_voyager/web/graphviz.svg.css,sha256=zDCjjpT0Idufu5YOiZI76PL70-avP3vTyzGPh9M85Do,1563
13
13
  fastapi_voyager/web/graphviz.svg.js,sha256=wZwz_lBztoXmujEN21P0w-HMpdmbqPwTQQ6Ebxd9rGo,18569
14
- fastapi_voyager/web/index.html,sha256=gF73eTnh5M2PcjWFOsDzqvCQBdl4KpaZW28hjS0iJnM,18454
14
+ fastapi_voyager/web/index.html,sha256=SNa6Vt3juCbRztA3ZH1PpJ0kW5fFSY1Mb0vVock2SOY,18774
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/store.js,sha256=ul6I00XqT9FByAD20JgO2mzdbYCZhTI-CP5t0g_k6yo,1776
18
- fastapi_voyager/web/vue-main.js,sha256=_yxkrWqxNIUMc3LMBi0TxT5SnDlV-_0n9tPaJdlwiFg,14064
17
+ fastapi_voyager/web/store.js,sha256=eYKy5kuCa5weazb_qC6PvJhSunhQwjJdPuH8W7_qq_0,1957
18
+ fastapi_voyager/web/vue-main.js,sha256=DFSje-Axno70B9NmmNAYhMsJU7YXZypz5hFdt3xcVK4,15061
19
19
  fastapi_voyager/web/component/demo.js,sha256=bQb16Un4XZ3Mf8qL6gvyrXe_mmA3V3mSIRMQAWg2MNk,352
20
20
  fastapi_voyager/web/component/render-graph.js,sha256=e8Xgh2Kl-nYU0P1gstEmAepCgFnk2J6UdxW8TlMafGs,2322
21
21
  fastapi_voyager/web/component/route-code-display.js,sha256=8NJPPjNRUC21gjpY8XYEQs4RBbhX1pCiqEhJp39ku6k,3678
@@ -27,8 +27,8 @@ fastapi_voyager/web/icon/favicon-16x16.png,sha256=JC07jEzfIYxBIoQn_FHXvyHuxESdhW
27
27
  fastapi_voyager/web/icon/favicon-32x32.png,sha256=C7v1h58cfWOsiLp9yOIZtlx-dLasBcq3NqpHVGRmpt4,1859
28
28
  fastapi_voyager/web/icon/favicon.ico,sha256=tZolYIXkkBcFiYl1A8ksaXN2VjGamzcSdes838dLvNc,15406
29
29
  fastapi_voyager/web/icon/site.webmanifest,sha256=ep4Hzh9zhmiZF2At3Fp1dQrYQuYF_3ZPZxc1KcGBvwQ,263
30
- fastapi_voyager-0.12.9.dist-info/METADATA,sha256=mwXk2O8gEasBEpci6RZagsLQ7rUGk7tRPvLfb-Q7bUg,6523
31
- fastapi_voyager-0.12.9.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
32
- fastapi_voyager-0.12.9.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
33
- fastapi_voyager-0.12.9.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
34
- fastapi_voyager-0.12.9.dist-info/RECORD,,
30
+ fastapi_voyager-0.12.11.dist-info/METADATA,sha256=QxERp2EpXzxzknG0jX8dAVH3bhiMqwIpvUyFRfOXLXo,6523
31
+ fastapi_voyager-0.12.11.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
32
+ fastapi_voyager-0.12.11.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
33
+ fastapi_voyager-0.12.11.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
34
+ fastapi_voyager-0.12.11.dist-info/RECORD,,