tortoise-orm-studio 1.0.0__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.
Files changed (68) hide show
  1. tortoise_orm_studio/__init__.py +11 -0
  2. tortoise_orm_studio/adapters/__init__.py +1 -0
  3. tortoise_orm_studio/adapters/aiohttp_adapter.py +31 -0
  4. tortoise_orm_studio/adapters/asgi.py +89 -0
  5. tortoise_orm_studio/adapters/base.py +25 -0
  6. tortoise_orm_studio/adapters/django_adapter.py +84 -0
  7. tortoise_orm_studio/adapters/quart_adapter.py +32 -0
  8. tortoise_orm_studio/adapters/registry.py +39 -0
  9. tortoise_orm_studio/adapters/sanic_adapter.py +39 -0
  10. tortoise_orm_studio/auth.py +34 -0
  11. tortoise_orm_studio/cli.py +41 -0
  12. tortoise_orm_studio/core/__init__.py +1 -0
  13. tortoise_orm_studio/core/aerich.py +86 -0
  14. tortoise_orm_studio/core/ai.py +87 -0
  15. tortoise_orm_studio/core/audit.py +69 -0
  16. tortoise_orm_studio/core/config.py +58 -0
  17. tortoise_orm_studio/core/filters.py +94 -0
  18. tortoise_orm_studio/core/handler.py +249 -0
  19. tortoise_orm_studio/core/http.py +55 -0
  20. tortoise_orm_studio/core/i18n.py +18 -0
  21. tortoise_orm_studio/core/introspect.py +197 -0
  22. tortoise_orm_studio/core/manifest.py +128 -0
  23. tortoise_orm_studio/core/pagination.py +59 -0
  24. tortoise_orm_studio/core/permissions.py +46 -0
  25. tortoise_orm_studio/core/plugins.py +214 -0
  26. tortoise_orm_studio/core/ratelimit.py +32 -0
  27. tortoise_orm_studio/core/scoping.py +23 -0
  28. tortoise_orm_studio/core/serializers.py +61 -0
  29. tortoise_orm_studio/core/service.py +594 -0
  30. tortoise_orm_studio/plugins.py +8 -0
  31. tortoise_orm_studio/static/ALPINE_LICENSE.txt +11 -0
  32. tortoise_orm_studio/static/_types.d.ts +706 -0
  33. tortoise_orm_studio/static/a11y.js +115 -0
  34. tortoise_orm_studio/static/ai.js +66 -0
  35. tortoise_orm_studio/static/alpine.min.js +23 -0
  36. tortoise_orm_studio/static/app.css +514 -0
  37. tortoise_orm_studio/static/app.js +1443 -0
  38. tortoise_orm_studio/static/audit.js +171 -0
  39. tortoise_orm_studio/static/copy-as.js +118 -0
  40. tortoise_orm_studio/static/er-layout.js +227 -0
  41. tortoise_orm_studio/static/er.js +296 -0
  42. tortoise_orm_studio/static/filters.js +114 -0
  43. tortoise_orm_studio/static/i18n.en.js +190 -0
  44. tortoise_orm_studio/static/i18n.js +140 -0
  45. tortoise_orm_studio/static/i18n.zh-CN.js +189 -0
  46. tortoise_orm_studio/static/index.html +515 -0
  47. tortoise_orm_studio/static/inline-edit.js +107 -0
  48. tortoise_orm_studio/static/json-view.js +161 -0
  49. tortoise_orm_studio/static/migrations.js +139 -0
  50. tortoise_orm_studio/static/palette.js +141 -0
  51. tortoise_orm_studio/static/pending.js +240 -0
  52. tortoise_orm_studio/static/pickers.js +230 -0
  53. tortoise_orm_studio/static/playground.js +105 -0
  54. tortoise_orm_studio/static/query-history.js +84 -0
  55. tortoise_orm_studio/static/shortcuts.js +145 -0
  56. tortoise_orm_studio/static/state-hash.js +112 -0
  57. tortoise_orm_studio/static/tabs.js +368 -0
  58. tortoise_orm_studio/static/theme-init.js +33 -0
  59. tortoise_orm_studio/static/theme.js +106 -0
  60. tortoise_orm_studio/static/toasts.js +76 -0
  61. tortoise_orm_studio/static/views.js +70 -0
  62. tortoise_orm_studio/static/widgets.js +345 -0
  63. tortoise_orm_studio/studio.py +51 -0
  64. tortoise_orm_studio-1.0.0.dist-info/METADATA +177 -0
  65. tortoise_orm_studio-1.0.0.dist-info/RECORD +68 -0
  66. tortoise_orm_studio-1.0.0.dist-info/WHEEL +4 -0
  67. tortoise_orm_studio-1.0.0.dist-info/entry_points.txt +2 -0
  68. tortoise_orm_studio-1.0.0.dist-info/licenses/LICENSE +13 -0
@@ -0,0 +1,140 @@
1
+ // @ts-check
2
+ /**
3
+ * Tiny CSP-safe i18n runtime for v0.9.0.
4
+ *
5
+ * Locale dictionaries are plain JS files that call `register()` before the
6
+ * Alpine component starts, so no network request or inline script is needed.
7
+ * `t()` falls back to English and then to the key itself, making a missing
8
+ * translation visible in tests instead of silently showing the wrong language.
9
+ *
10
+ * `apply(root)` translates static markup via `data-i18n*` attributes;
11
+ * dynamic strings call `t()` from the Alpine component. Everything is written
12
+ * with `textContent`/`setAttribute`, so no HTML from a locale file is trusted.
13
+ */
14
+ (function (/** @type {any} */ global) {
15
+ "use strict";
16
+
17
+ /** @type {Record<string, Record<string, string>>} */
18
+ var dictionaries = {};
19
+ var current = "en";
20
+ var FALLBACK = "en";
21
+ var STORAGE_KEY = "studio.locale.v1";
22
+
23
+ /** @param {string} value */
24
+ function normalize(value) {
25
+ var v = String(value || "").trim().replace(/_/g, "-");
26
+ // Accept both zh-CN and zh_CN in config/storage; keep the registered key.
27
+ var keys = Object.keys(dictionaries);
28
+ for (var i = 0; i < keys.length; i++) {
29
+ if (keys[i].toLowerCase() === v.toLowerCase()) return keys[i];
30
+ }
31
+ return v;
32
+ }
33
+
34
+ /**
35
+ * Register (or extend) a locale dictionary. Later calls win per key.
36
+ * @param {string} locale
37
+ * @param {Record<string, string>} dict
38
+ */
39
+ function register(locale, dict) {
40
+ if (!locale || !dict || typeof dict !== "object") return false;
41
+ var key = normalize(locale);
42
+ if (!dictionaries[key]) dictionaries[key] = {};
43
+ Object.keys(dict).forEach(function (k) {
44
+ dictionaries[key][k] = String(dict[k]);
45
+ });
46
+ return true;
47
+ }
48
+
49
+ /** @returns {string} */
50
+ function locale() { return current; }
51
+
52
+ /** @returns {string[]} */
53
+ function available() { return Object.keys(dictionaries).sort(); }
54
+
55
+ /**
56
+ * @param {string} value
57
+ * @returns {boolean} false when the locale is not registered
58
+ */
59
+ function setLocale(value) {
60
+ var key = normalize(value);
61
+ if (!dictionaries[key]) return false;
62
+ current = key;
63
+ var d = global.document;
64
+ if (d && d.documentElement && typeof d.documentElement.setAttribute === "function") {
65
+ d.documentElement.setAttribute("lang", key);
66
+ }
67
+ return true;
68
+ }
69
+
70
+ /**
71
+ * @param {string} key
72
+ * @param {Record<string, any>} [vars]
73
+ * @returns {string}
74
+ */
75
+ function t(key, vars) {
76
+ var text = (dictionaries[current] || {})[key];
77
+ if (text === undefined) text = (dictionaries[FALLBACK] || {})[key];
78
+ if (text === undefined) return key;
79
+ if (!vars) return text;
80
+ return text.replace(/\{(\w+)\}/g, function (whole, name) {
81
+ return Object.prototype.hasOwnProperty.call(vars, name) ? String(vars[name]) : whole;
82
+ });
83
+ }
84
+
85
+ /**
86
+ * Translate static markup. Called once at component init; reactive x-text
87
+ * expressions call `t()` themselves.
88
+ * @param {any} root
89
+ */
90
+ function apply(root) {
91
+ if (!root || typeof root.querySelectorAll !== "function") return 0;
92
+ var count = 0;
93
+ var map = [
94
+ ["data-i18n", "textContent"],
95
+ ["data-i18n-placeholder", "placeholder"],
96
+ ["data-i18n-aria-label", "aria-label"],
97
+ ["data-i18n-title", "title"],
98
+ ];
99
+ map.forEach(function (pair) {
100
+ var nodes = root.querySelectorAll("[" + pair[0] + "]");
101
+ for (var i = 0; i < nodes.length; i++) {
102
+ var el = nodes[i];
103
+ var value = el.getAttribute(pair[0]);
104
+ if (!value) continue;
105
+ var translated = t(value);
106
+ if (pair[1] === "textContent") el.textContent = translated;
107
+ else el.setAttribute(pair[1], translated);
108
+ count++;
109
+ }
110
+ });
111
+ return count;
112
+ }
113
+
114
+ /** @param {any} [storage] */
115
+ function load(storage) {
116
+ var s = storage || global.localStorage;
117
+ if (!s || typeof s.getItem !== "function") return current;
118
+ try {
119
+ var saved = s.getItem(STORAGE_KEY);
120
+ if (saved) setLocale(saved);
121
+ } catch (e) { /* private mode / disabled storage */ }
122
+ return current;
123
+ }
124
+
125
+ /** @param {string} value @param {any} [storage] */
126
+ function save(value, storage) {
127
+ var s = storage || global.localStorage;
128
+ if (!setLocale(value)) return false;
129
+ try {
130
+ if (s && typeof s.setItem === "function") s.setItem(STORAGE_KEY, current);
131
+ } catch (e) { /* storage failures must not break the UI */ }
132
+ return true;
133
+ }
134
+
135
+ global.StudioI18n = {
136
+ STORAGE_KEY: STORAGE_KEY,
137
+ available: available, register: register, locale: locale,
138
+ setLocale: setLocale, t: t, apply: apply, load: load, save: save,
139
+ };
140
+ })(typeof window !== "undefined" ? window : globalThis);
@@ -0,0 +1,189 @@
1
+ // @ts-check
2
+ "use strict";
3
+ /** Simplified Chinese strings. Same keys as i18n.en.js — a test pins parity. */
4
+ (/** @type {any} */ (window).StudioI18n).register("zh-CN", {
5
+ "nav.list": "数据列表",
6
+ "nav.playground": "查询演练",
7
+ "nav.er": "ER 图",
8
+ "nav.migrations": "数据库迁移",
9
+ "nav.audit": "审计日志",
10
+ "nav.plugins": "插件",
11
+
12
+ "theme.label": "配色主题",
13
+ "views.saved": "已保存视图",
14
+ "views.saveCurrent": "保存当前视图…",
15
+ "views.delete": "删除视图",
16
+ "connection.label": "连接",
17
+ "connection.default": "(默认)",
18
+
19
+ "model.filterPlaceholder": "筛选模型…",
20
+ "model.filter": "筛选模型",
21
+ "model.pin": "固定模型",
22
+ "model.unpin": "取消固定",
23
+ "tab.close": "关闭 {title}",
24
+ "tab.new": "新建标签",
25
+ "tab.split": "分屏",
26
+
27
+ "list.searchPlaceholder": "搜索(回车)",
28
+ "list.rows": "{count} 行",
29
+ "list.density.compact": "紧凑",
30
+ "list.density.comfortable": "宽松",
31
+ "list.new": "新建",
32
+ "list.undoInline": "撤销编辑",
33
+ "list.clear": "清除",
34
+ "list.columns": "列",
35
+ "list.emptyState": "当前视图没有匹配的行,请尝试清除筛选或搜索。",
36
+ "list.prev": "上一页",
37
+ "list.next": "下一页",
38
+ "list.selected": "已选 {count} 项",
39
+ "list.deleteSelected": "删除所选",
40
+ "list.copyOptions": "复制选项",
41
+ "list.copyAs": "复制为",
42
+ "list.copyJson": "JSON",
43
+ "list.copyCreate": "create()",
44
+ "list.copyCsv": "CSV 行",
45
+ "list.copyRowAs": "将第 {pk} 行复制为",
46
+ "list.copyOptionsFor": "第 {pk} 行的复制选项",
47
+ "list.doubleClick": "双击可编辑",
48
+ "list.filter.add": "+ 筛选",
49
+ "list.filter.cancel": "取消",
50
+ "list.filter.value": "值",
51
+ "list.sortAsc": "{col}(升序)",
52
+ "list.sortDesc": "{col}(降序)",
53
+ "list.null": "NULL",
54
+
55
+ "ai.title": "描述筛选条件",
56
+ "ai.prompt": "例如:年龄大于 18 的活跃用户",
57
+ "ai.field": "筛选条件描述",
58
+ "ai.suggest": "生成筛选建议",
59
+ "ai.apply": "应用所选筛选",
60
+ "ai.removeChip": "移除筛选标签",
61
+
62
+ "detail.label": "行详情",
63
+ "detail.close": "关闭详情抽屉",
64
+ "detail.save": "保存",
65
+ "detail.delete": "删除",
66
+ "detail.stage": "暂存更改",
67
+ "detail.stageDelete": "暂存删除",
68
+ "detail.formMode.json": "JSON 视图",
69
+ "detail.formMode.form": "表单视图",
70
+ "detail.jsonTree": "JSON 树",
71
+ "detail.applyEdits": "应用编辑",
72
+ "detail.jsonHint": "编辑上方 JSON 文本,然后点击“应用编辑”。",
73
+ "detail.dirty": "有未保存的更改",
74
+ "detail.changes": "字段变更",
75
+ "detail.rowJson": "行 JSON",
76
+ "detail.add": "+ 添加",
77
+ "detail.remove": "移除",
78
+ "detail.stageAdd": "暂存添加",
79
+ "detail.stageRemove": "暂存移除",
80
+
81
+ "playground.title": "查询演练",
82
+ "playground.hint": "预览筛选/排序组合对应的 Python 调用和生成的 SQL。",
83
+ "playground.model": "模型",
84
+ "playground.filters": "筛选(JSON)",
85
+ "playground.search": "搜索",
86
+ "playground.sort": "排序",
87
+ "playground.limit": "条数上限",
88
+ "playground.run": "运行预览",
89
+ "playground.history": "历史",
90
+ "playground.openInList": "在列表中打开",
91
+ "playground.lastQuery": "上次查询耗时",
92
+ "playground.recent": "最近的查询",
93
+ "playground.none": "暂无查询。",
94
+ "playground.clear": "清除",
95
+
96
+ "er.title": "ER 图",
97
+ "er.hint": "所有已注册模型的 Mermaid erDiagram 文本。",
98
+
99
+ "migrations.title": "数据库迁移",
100
+ "migrations.hint": "当前连接已应用和待执行的 Aerich 迁移。",
101
+
102
+ "audit.title": "审计日志",
103
+ "audit.hint": "审计钩子记录的每一次创建 / 更新 / 删除。",
104
+ "audit.action": "操作",
105
+ "audit.any": "(全部)",
106
+ "audit.model": "模型",
107
+ "audit.actor": "操作者",
108
+ "audit.apply": "应用",
109
+ "audit.clear": "清除",
110
+
111
+ "plugin.title": "插件",
112
+ "plugin.hint": "已安装插件提供的操作,输出只读。",
113
+
114
+ "pending.title": "待保存更改({count})",
115
+ "pending.show": "显示",
116
+ "pending.hide": "隐藏",
117
+ "pending.empty": "暂无暂存的更改。",
118
+ "pending.deleteRow": "删除行",
119
+ "pending.remove": "移除暂存的更改",
120
+ "pending.saveAll": "全部保存",
121
+ "pending.undo": "撤销上一步",
122
+ "pending.discard": "全部丢弃",
123
+
124
+ "status.db": "数据库:{conn}",
125
+ "status.readOnly": "只读",
126
+ "status.writeEnabled": "可写",
127
+ "status.help": "键盘快捷键",
128
+
129
+ "help.title": "键盘快捷键",
130
+ "help.palette": "命令面板",
131
+ "help.focusSearch": "聚焦搜索框",
132
+ "help.move": "向下 / 向上移动选中项",
133
+ "help.open": "打开选中的行",
134
+ "help.back": "返回 / 关闭",
135
+ "help.models": "转到模型列表",
136
+ "help.this": "本帮助",
137
+ "common.close": "关闭",
138
+
139
+ // Dynamic messages (keys are the English source strings).
140
+ "search: {q}": "搜索:{q}",
141
+ "no filters": "无筛选条件",
142
+ "This tab has unsaved changes. Close it anyway?": "此标签有未保存的更改,仍要关闭吗?",
143
+ "No rows selected": "未选择任何行",
144
+ "Cannot delete {n} rows (max {max})": "无法删除 {n} 行(上限 {max})",
145
+ "Deleted {n} row(s)": "已删除 {n} 行",
146
+ "Invalid JSON: {msg}": "无效的 JSON:{msg}",
147
+ "Invalid JSON: expected an object": "无效的 JSON:应为对象",
148
+ "Created": "已创建",
149
+ "Saved": "已保存",
150
+ "Delete this row?": "删除这一行?",
151
+ "Deleted": "已删除",
152
+ "pickers.js not loaded": "pickers.js 未加载",
153
+ "Added {n}": "已添加 {n} 项",
154
+ "Removed {n}": "已移除 {n} 项",
155
+ "This row has unsaved changes. Leave it anyway?": "此行有未保存的更改,仍要离开吗?",
156
+ "No change": "无更改",
157
+ "Cell change staged": "单元格更改已暂存",
158
+ "Undid last cell edit": "已撤销上一次单元格编辑",
159
+ "Copied {label}": "已复制 {label}",
160
+ "Copy failed": "复制失败",
161
+ "JSON applied": "JSON 已应用",
162
+ "Change staged": "更改已暂存",
163
+ "Stage deletion of this row?": "暂存删除这一行?",
164
+ "Deletion staged": "删除已暂存",
165
+ "{n} relation change(s) staged": "已暂存 {n} 项关系更改",
166
+ "Saved all staged changes": "已保存全部暂存的更改",
167
+ "Discarded all staged changes": "已丢弃全部暂存的更改",
168
+ "Query history cleared": "查询历史已清除",
169
+ "Invalid filter JSON": "筛选条件 JSON 无效",
170
+ "No model selected": "未选择模型",
171
+ "Save view as (existing names overwrite):": "视图名称(同名将覆盖):",
172
+ "views.js not loaded": "views.js 未加载",
173
+ "Saved view: {name}": "已保存视图:{name}",
174
+ "Deleted view: {name}": "已删除视图:{name}",
175
+ "list.removeFilter": "移除筛选条件",
176
+ "list.filter.addButton": "添加",
177
+ "detail.breadcrumb": "面包屑导航",
178
+ "detail.relation": "{name}({type})",
179
+ "a11y.openViews": "打开的视图",
180
+ "a11y.skip": "跳到主要内容",
181
+ "a11y.models": "模型",
182
+ "a11y.collapseSidebar": "折叠侧边栏",
183
+ "a11y.selectRow": "选择第 {pk} 行",
184
+ "a11y.selectAll": "选择所有可见行",
185
+ "a11y.row": "打开第 {pk} 行",
186
+ "a11y.search": "搜索行",
187
+ "a11y.filterValue": "筛选值",
188
+ "locale.label": "语言",
189
+ });