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,706 @@
1
+ // Global type declarations. Shared by widgets.js, filters.js, pickers.js, toasts.js, app.js.
2
+ // Not a module — globally visible. Dev-only, not served at runtime.
3
+
4
+ type FieldKind =
5
+ | "bool" | "int" | "float" | "decimal" | "string" | "text" | "enum"
6
+ | "date" | "time" | "datetime" | "json" | "binary" | "uuid"
7
+ | "fk" | "o2o";
8
+
9
+ type Field = {
10
+ name: string;
11
+ kind: FieldKind;
12
+ pk: boolean;
13
+ null: boolean;
14
+ readonly: boolean;
15
+ max_length?: number | null;
16
+ choices?: string[];
17
+ related_model?: string;
18
+ related_pk?: string;
19
+ column?: string;
20
+ pk_kind?: "int" | "float" | "uuid" | "string";
21
+ display_field?: string;
22
+ display_value?: string | number | null;
23
+ generated?: boolean;
24
+ };
25
+
26
+ type FilterPath = { kind: FieldKind; traversal: boolean; via?: string };
27
+
28
+ type Relation = {
29
+ name: string;
30
+ type: "fk" | "o2o" | "backward_fk" | "backward_o2o" | "m2m";
31
+ model: string;
32
+ column?: string | null;
33
+ via?: string | null;
34
+ nullable?: boolean;
35
+ related_pk?: string;
36
+ pk_kind?: string;
37
+ };
38
+
39
+ type ModelDesc = {
40
+ key: string;
41
+ app: string;
42
+ name: string;
43
+ table: string;
44
+ pk: string;
45
+ fields: Field[];
46
+ relations: Relation[];
47
+ list_display: string[];
48
+ search_fields: string[];
49
+ filter_paths: Record<string, FilterPath>;
50
+ };
51
+
52
+ type Limits = {
53
+ default_page_size: number;
54
+ max_page_size: number;
55
+ max_bulk: number;
56
+ max_batch: number;
57
+ max_export_rows: number;
58
+ };
59
+
60
+ type ApiFeatures = { ai_filter: boolean };
61
+
62
+ /** v0.9.0 — host-supplied plugin metadata from /api/schema. */
63
+ type PluginAction = { id: string; label: string; path: string; description: string };
64
+ type PluginRouteDesc = { method: string; path: string; summary: string };
65
+ /** v0.9.0 — the window.StudioI18n runtime. */
66
+ type I18nAPI = {
67
+ STORAGE_KEY: string;
68
+ available: () => string[];
69
+ register: (locale: string, dict: Record<string, string>) => boolean;
70
+ locale: () => string;
71
+ setLocale: (value: string) => boolean;
72
+ t: (key: string, vars?: Record<string, any>) => string;
73
+ apply: (root: any) => number;
74
+ load: (storage?: any) => string;
75
+ save: (value: string, storage?: any) => boolean;
76
+ };
77
+
78
+ type PluginInfo = {
79
+ version: string;
80
+ routes: PluginRouteDesc[];
81
+ actions: PluginAction[];
82
+ metadata: Record<string, any>;
83
+ };
84
+
85
+ type Schema = {
86
+ read_only: boolean;
87
+ features: ApiFeatures;
88
+ models: ModelDesc[];
89
+ connections: string[];
90
+ limits: Limits;
91
+ plugins: Record<string, PluginInfo>;
92
+ locale: string;
93
+ locales: string[];
94
+ };
95
+
96
+ type FilterPredicate = { field: string; op: string; value: unknown };
97
+
98
+ /** GET /api/models/<key> — offset page of rows. */
99
+ type ListResponse = {
100
+ items: Row[];
101
+ total: number;
102
+ page: number;
103
+ limit: number;
104
+ model?: string; // present on /related routes only
105
+ next_cursor?: string; // v0.4.0 keyset pagination
106
+ prev_cursor?: string;
107
+ };
108
+
109
+ /** Every non-2xx response from the API has this shape. */
110
+ type ErrorResponse = {
111
+ error: {
112
+ code: string;
113
+ message: string;
114
+ detail?: unknown;
115
+ };
116
+ };
117
+
118
+ type WidgetsAPI = {
119
+ renderField: (field: Field, value: unknown, onChange: (name: string, value: unknown) => void) => HTMLElement;
120
+ validate: (field: Field, value: unknown) => string | null;
121
+ };
122
+
123
+ type FiltersAPI = {
124
+ opsForField: (field: Field) => string[];
125
+ normalizeValue: (field: Field, op: string, raw: unknown) => unknown;
126
+ label: (f: FilterPredicate) => string;
127
+ validate: (field: Field, op: string, raw: unknown) => string | null;
128
+ TEXT_KINDS: Set<string>;
129
+ UNFILTERABLE: Set<string>;
130
+ BASE_OPS: string[];
131
+ TEXT_OPS: string[];
132
+ };
133
+
134
+ type PickerConfig = {
135
+ model: string;
136
+ label?: string;
137
+ multiSelect?: boolean;
138
+ preselect?: Array<string | number>;
139
+ onSelect?: (pk: unknown) => void;
140
+ onConfirm?: (pks: Array<string>) => void;
141
+ onCancel?: () => void;
142
+ };
143
+ type PickerAPI = { request: (cfg: PickerConfig) => void };
144
+
145
+ type ToastsAPI = {
146
+ show: (message: string, kind?: "info" | "success" | "warn" | "error") => HTMLElement;
147
+ error: (message: string) => HTMLElement;
148
+ warn: (message: string) => HTMLElement;
149
+ info: (message: string) => HTMLElement;
150
+ success: (message: string) => HTMLElement;
151
+ clear: () => void;
152
+ };
153
+
154
+ // ─── v0.3.0 panels ───
155
+
156
+ type MigrationsInfo = {
157
+ available: boolean;
158
+ connection: string | null;
159
+ applied: Array<{ app: string; version: string }>;
160
+ migrations_dir: string | null;
161
+ pending: Array<{ app: string; version: string; file: string }>;
162
+ };
163
+
164
+ type PreviewResult = { code: string; sql: string | null };
165
+
166
+ type PlaygroundAPI = { render: (result: PreviewResult | null) => HTMLElement };
167
+ type ErOptions = {
168
+ mermaid?: string | null;
169
+ onOpen?: (key: string) => void;
170
+ };
171
+ type ErAPI = {
172
+ render: (schema: Schema | null, options?: ErOptions) => HTMLElement;
173
+ /** Serialise a rendered SVG for download (adds theme colours to the copy). */
174
+ serialise: (svg: SVGElement) => string;
175
+ };
176
+ type PendingMigrationsInfo = {
177
+ available: boolean;
178
+ connection: string | null;
179
+ pending: Array<{ app: string; version: string; file: string }>;
180
+ };
181
+ type MigrationsAPI = {
182
+ render: (info: MigrationsInfo | null, pendingInfo?: PendingMigrationsInfo) => HTMLElement;
183
+ };
184
+
185
+ // ─── v0.3.1 audit + saved views ───
186
+
187
+ type AuditEntry = {
188
+ id: number;
189
+ action: string;
190
+ model: string;
191
+ pk: string | null;
192
+ before: unknown | null;
193
+ after: unknown | null;
194
+ actor: string | null;
195
+ at: string;
196
+ };
197
+
198
+ type AuditInfo = {
199
+ available: boolean;
200
+ items: AuditEntry[];
201
+ total: number;
202
+ page: number;
203
+ limit: number;
204
+ };
205
+
206
+ type AuditAPI = {
207
+ render: (info: AuditInfo | null, opts?: { onPageChange?: (page: number) => void }) => HTMLElement;
208
+ };
209
+
210
+ type SavedView = {
211
+ name: string;
212
+ model: string;
213
+ filters: FilterPredicate[];
214
+ sort: string;
215
+ search: string;
216
+ cols: string[];
217
+ allCols: string[];
218
+ hiddenCols: Record<string, boolean>;
219
+ savedAt: string;
220
+ };
221
+
222
+ type SavedViews = Record<string, SavedView>;
223
+
224
+ type ViewsAPI = {
225
+ load: () => SavedViews;
226
+ save: (views: SavedViews) => void;
227
+ remove: (name: string) => void;
228
+ serialize: (state: {
229
+ name: string; current: string; filters: FilterPredicate[];
230
+ sort: string; search: string; cols: string[];
231
+ allCols: string[]; hiddenCols: Record<string, boolean>;
232
+ }) => SavedView;
233
+ };
234
+
235
+ /** What the user picked in the theme toggle. `system` follows the OS. */
236
+ type ThemeChoice = "light" | "dark" | "system";
237
+
238
+ type ThemeAPI = {
239
+ KEY: string;
240
+ CHOICES: ThemeChoice[];
241
+ normalize: (value: unknown) => ThemeChoice;
242
+ resolve: (choice: ThemeChoice, prefersDark: boolean) => "light" | "dark";
243
+ attributeFor: (choice: ThemeChoice) => "light" | "dark" | null;
244
+ next: (choice: ThemeChoice) => ThemeChoice;
245
+ load: () => ThemeChoice;
246
+ save: (choice: ThemeChoice) => void;
247
+ apply: (doc: { documentElement: Element }, choice: ThemeChoice) => void;
248
+ };
249
+
250
+ /** One row as the API returns it: field values plus `_pk`. */
251
+ type Row = Record<string, unknown> & { _pk: string | number };
252
+
253
+ type Schema_ = Schema;
254
+
255
+ /**
256
+ * The full state + methods of the `studio` Alpine component. Declared once so
257
+ * `app.js` and the templates agree on property names; the template is not
258
+ * type-checked by tsc, so this typedef is the contract.
259
+ */
260
+ type StudioComponent = {
261
+ // Alpine magics (provided at runtime, stubbed in tests)
262
+ $refs?: Record<string, any>;
263
+ $nextTick?: (fn: () => void) => void;
264
+ // state
265
+ schema: Schema | null;
266
+ models: ModelDesc[];
267
+ current: string;
268
+ view: string;
269
+ rows: Row[];
270
+ total: number;
271
+ page: number;
272
+ limit: number;
273
+ sort: string;
274
+ search: string;
275
+ cols: string[];
276
+ allCols: string[];
277
+ hiddenCols: Record<string, boolean>;
278
+ pk: string | number | null;
279
+ json: string;
280
+ relations: Relation[];
281
+ relRows: Row[];
282
+ relCols: string[];
283
+ relModel: string;
284
+ relName: string;
285
+ relType: string;
286
+ hasRel: boolean;
287
+ formMode: string;
288
+ formValues: Record<string, any>;
289
+ formFields: Field[];
290
+ filters: FilterPredicate[];
291
+ draftField: string;
292
+ draftOp: string;
293
+ draftValue: unknown;
294
+ draftError: string;
295
+ showAddFilter: boolean;
296
+ connection: string;
297
+ connections: string[];
298
+ selectedPks: Record<string, true>;
299
+ playgroundModel: string;
300
+ playgroundFilters: string;
301
+ playgroundSearch: string;
302
+ playgroundSort: string;
303
+ playgroundLimit: number;
304
+ playgroundError: string;
305
+ playgroundMs: number;
306
+ playgroundHistory: any[];
307
+ queryHistoryOpen: boolean;
308
+ paletteReturnFocus: HTMLElement | null;
309
+ auditPage: number;
310
+ auditLimit: number;
311
+ auditFilters: { action: string; model: string; actor: string };
312
+ themeChoice: ThemeChoice;
313
+ themeChoices: ThemeChoice[];
314
+ viewsOpen: boolean;
315
+ savedViews: SavedViews;
316
+
317
+ // v0.3.3 navigation
318
+ sideFilter: string;
319
+ sidebarCollapsed: boolean;
320
+ pinnedModels: string[];
321
+ tabStore: TabStore;
322
+ paletteOpen: boolean;
323
+ helpOpen: boolean;
324
+
325
+ // v0.5.0 staged saves
326
+ pendingStore: PendingStore;
327
+ pendingOpen: boolean;
328
+ aiFilters: any[];
329
+ aiText: string;
330
+ aiError: string;
331
+ aiOpen: boolean;
332
+ // v0.5.0 detail drawer + inline edit
333
+ drawerSnapshot: Record<string, any>;
334
+ drawerReturnFocus: HTMLElement | null;
335
+ inline: InlineEditState;
336
+ copyMenuPk: string | null;
337
+ jsonTreeOpen: boolean;
338
+ breadcrumbs: Array<{ label: string, key?: string }>;
339
+ lastRequestMs: number;
340
+ pendingShortcut: string | null;
341
+ dense: boolean;
342
+ // v0.9.0 — i18n + declarative plugin UI actions
343
+ locale: string;
344
+ pluginTitle: string;
345
+ pluginText: string;
346
+ pluginError: string;
347
+
348
+ // derived
349
+ readonly isList: boolean;
350
+ readonly isDetail: boolean;
351
+ readonly readOnly: boolean;
352
+ readonly canWrite: boolean;
353
+ readonly canDelete: boolean;
354
+ readonly canM2m: boolean;
355
+ readonly isPlayground: boolean;
356
+ readonly isEr: boolean;
357
+ readonly isMigrations: boolean;
358
+ readonly isAudit: boolean;
359
+ readonly isPlugin: boolean;
360
+ readonly localeChoices: string[];
361
+ readonly pluginActions: Array<{ key: string; plugin: string; id: string; label: string; path: string; description: string }>;
362
+ readonly hasSavedViews: boolean;
363
+ readonly savedViewNames: string[];
364
+ readonly atFirst: boolean;
365
+ readonly atLast: boolean;
366
+ readonly pages: number;
367
+ readonly pageLabel: string;
368
+ readonly countLabel: string;
369
+ readonly showWidgets: boolean;
370
+ readonly showJson: boolean;
371
+ readonly formModeLabel: string;
372
+ readonly hasFilters: boolean;
373
+ readonly draftNeedsValue: boolean;
374
+ readonly showConnection: boolean;
375
+ readonly selectedCount: number;
376
+ readonly hasSelection: boolean;
377
+ readonly allVisibleSelected: boolean;
378
+ readonly maxBulk: number;
379
+ readonly filterableFields: Field[];
380
+ readonly draftFieldObj: Field | null;
381
+ readonly draftOps: string[];
382
+ readonly prefersDark: boolean;
383
+ readonly tabList: Tab[];
384
+ readonly activeTabId: string | null;
385
+ readonly tabSplit: boolean;
386
+ readonly tabError: string;
387
+ readonly groupedApps: string[];
388
+ readonly filterSummary: string;
389
+ readonly lastRequestLabel: string;
390
+ readonly playgroundLabel: string;
391
+ readonly pendingDirty: boolean;
392
+ readonly pendingCount: number;
393
+ readonly aiEnabled: boolean;
394
+ readonly drawerDirty: boolean;
395
+ readonly drawerDiff: DiffEntry[];
396
+ readonly inlineEditing: boolean;
397
+
398
+ // methods
399
+ api: (path: string, method?: string, body?: unknown) => Promise<any>;
400
+ guard: (fn: () => Promise<void> | void) => Promise<void>;
401
+ toastError: (m: string) => void;
402
+ toastSuccess: (m: string) => void;
403
+ tr: (key: string, vars?: Record<string, any>) => string;
404
+ setLocale: (value: string) => void;
405
+ setTheme: (choice: string) => void;
406
+ confirm: (message: string) => boolean;
407
+ prompt: (message: string) => string | null;
408
+ sideClass: (key: string) => string;
409
+ viewClass: (name: string) => string;
410
+ ariaSort: (c: string) => string;
411
+ head: (c: string) => string;
412
+ cell: (row: Row, c: string) => string;
413
+ relLabel: (r: Relation) => string;
414
+ model: (key: string) => ModelDesc | undefined;
415
+ toggleSelect: (pk: string | number) => void;
416
+ toggleSelectAll: () => void;
417
+ clearSelection: () => void;
418
+ bulkDelete: () => Promise<void>;
419
+ connectionChanged: () => Promise<void>;
420
+ renderWidgets: () => void;
421
+ updateField: (name: string, value: unknown) => void;
422
+ setFormFields: () => void;
423
+ toggleFormMode: () => void;
424
+ applyJson: () => boolean;
425
+ isHidden: (c: string) => boolean;
426
+ toggleCol: (c: string) => void;
427
+ resetCols: () => void;
428
+ toggleAddFilter: () => void;
429
+ onDraftFieldChange: () => void;
430
+ addFilter: () => Promise<void> | void;
431
+ removeFilter: (i: number) => Promise<void>;
432
+ clearFilters: () => Promise<void>;
433
+ chipLabel: (f: FilterPredicate) => string;
434
+ init: () => Promise<void>;
435
+ pick: (key: string) => Promise<void>;
436
+ load: () => Promise<void>;
437
+ doSearch: () => Promise<void>;
438
+ sortBy: (c: string) => Promise<void>;
439
+ prev: () => Promise<void>;
440
+ next: () => Promise<void>;
441
+ back: () => Promise<void>;
442
+ newRow: () => void;
443
+ openRow: (row: Row) => Promise<void>;
444
+ resetRel: (m: ModelDesc) => void;
445
+ payload: () => Record<string, any>;
446
+ save: () => Promise<void>;
447
+ remove: () => Promise<void>;
448
+ showRel: (r: { name: string; type: string; model: string }) => Promise<void>;
449
+ openRelated: (it: Row) => Promise<void>;
450
+ openM2mPicker: (mode: "add" | "remove") => void;
451
+ m2mApply: (mode: "add" | "remove", pks: string[]) => Promise<void>;
452
+ stageSave: () => void;
453
+ stageDelete: () => void;
454
+ stageM2m: (mode: "add" | "remove", pks: string[]) => void;
455
+ saveAll: () => Promise<void>;
456
+ discardAllPending: () => void;
457
+ removePending: (id: string) => void;
458
+ undoPending: () => void;
459
+ pendingDiff: (change: PendingChange) => DiffEntry[];
460
+ togglePending: () => void;
461
+ syncPendingDirty: () => void;
462
+ ie: () => InlineEditAPI | undefined;
463
+ a11y: () => A11yAPI | undefined;
464
+ rememberDrawerFocus: () => void;
465
+ restoreDrawerFocus: () => void;
466
+ focusDrawer: () => void;
467
+ onDrawerKeydown: (ev: KeyboardEvent) => void;
468
+ onPaletteKeydown: (ev: KeyboardEvent) => void;
469
+ closeDrawer: () => void;
470
+ beginInline: (row: Row, col: string, ev: any) => void;
471
+ finishInlineDom: (td: HTMLElement) => void;
472
+ commitInline: (td: HTMLElement) => void;
473
+ cancelInline: (td: HTMLElement) => void;
474
+ undoInline: () => void;
475
+ toggleCopyMenu: (pk: string | number) => void;
476
+ closeCopyMenu: () => void;
477
+ copyAs: () => CopyAsAPI | undefined;
478
+ copyRow: (kind: "json" | "create" | "csv", row: Row) => void;
479
+ toggleJsonTree: () => void;
480
+ applyJsonTree: (text: string) => void;
481
+ renderJsonTree: () => void;
482
+ toggleAi: () => void;
483
+ aiChipLabel: (f: any) => string;
484
+ removeAiChip: (i: number) => void;
485
+ runAi: () => Promise<void>;
486
+ applyAi: () => Promise<void> | void;
487
+ viewList: () => Promise<void>;
488
+ viewPlugin: () => void;
489
+ runPluginAction: (a: { plugin: string; id: string; label: string; path: string }) => Promise<void>;
490
+ openPlayground: () => Promise<void>;
491
+ runPlayground: () => Promise<void>;
492
+ queryHistory: () => QueryHistoryFactory | undefined;
493
+ initQueryHistory: () => void;
494
+ toggleQueryHistory: () => void;
495
+ loadHistoryQuery: (i: number) => Promise<void> | void;
496
+ clearQueryHistory: () => void;
497
+ openInList: () => Promise<void>;
498
+ openEr: () => Promise<void>;
499
+ openMigrations: () => Promise<void>;
500
+ openAudit: () => Promise<void>;
501
+ loadAudit: () => Promise<void>;
502
+ applyAuditFilters: () => Promise<void>;
503
+ clearAuditFilters: () => Promise<void>;
504
+ viewsToggle: () => void;
505
+ saveCurrentView: () => void;
506
+ loadView: (name: string) => Promise<void>;
507
+ deleteView: (name: string) => void;
508
+ openModelTab: (key: string) => void;
509
+ newTabWith: (state: any) => void;
510
+ newTab: () => void;
511
+ activateTab: (id: string) => void;
512
+ closeTab: (id: string) => void;
513
+ toggleSplit: () => void;
514
+ modelsForApp: (app: string) => ModelDesc[];
515
+ toggleSidebar: () => void;
516
+ isPinned: (key: string) => boolean;
517
+ togglePinModel: (key: string) => void;
518
+ togglePalette: () => void;
519
+ renderPalette: () => void;
520
+ closePalette: () => void;
521
+ toggleHelp: () => void;
522
+ goCrumb: (i: number) => void;
523
+ onKeydown: (ev: KeyboardEvent) => void;
524
+ moveSelection: (delta: number) => void;
525
+ applyHash: () => void;
526
+ syncHash: () => void;
527
+ };
528
+
529
+ // ─── v0.3.3 navigation ───
530
+
531
+ type TabState = {
532
+ view?: string;
533
+ model?: string;
534
+ filters?: FilterPredicate[];
535
+ sort?: string;
536
+ page?: number;
537
+ limit?: number;
538
+ search?: string;
539
+ cols?: string[];
540
+ hiddenCols?: Record<string, boolean>;
541
+ selectedPk?: string | number | null;
542
+ scroll?: number;
543
+ connection?: string;
544
+ playgroundModel?: string;
545
+ playgroundFilters?: string;
546
+ playgroundSearch?: string;
547
+ playgroundSort?: string;
548
+ };
549
+
550
+ type Tab = {
551
+ id: string;
552
+ title: string;
553
+ state: TabState;
554
+ pinned: boolean;
555
+ pane: number;
556
+ dirty: boolean;
557
+ };
558
+
559
+ type TabStore = {
560
+ tabs: Tab[];
561
+ activeId: string | null;
562
+ split: boolean;
563
+ cap: number;
564
+ error: string | null;
565
+ };
566
+
567
+ type TabsAPI = {
568
+ DEFAULT_CAP: number;
569
+ STATE_KEYS: string[];
570
+ create: (cap?: number) => TabStore;
571
+ active: (store: TabStore) => Tab | undefined;
572
+ add: (store: TabStore, state: any, opts?: any) => { store: TabStore, tab: Tab | null, error: string | null };
573
+ duplicate: (store: TabStore, id: string) => { store: TabStore, tab: Tab | null, error: string | null };
574
+ close: (store: TabStore, id: string, opts?: any) => { store: TabStore, error: string | null };
575
+ move: (store: TabStore, id: string, toIndex: number) => TabStore;
576
+ togglePin: (store: TabStore, id: string) => TabStore;
577
+ activate: (store: TabStore, id: string) => TabStore;
578
+ setSplit: (store: TabStore, on: boolean) => TabStore;
579
+ setPane: (store: TabStore, id: string, pane: number) => TabStore;
580
+ updateState: (store: TabStore, id: string, patch: any) => TabStore;
581
+ setDirty: (store: TabStore, id: string, dirty: boolean) => TabStore;
582
+ serialise: (store: TabStore) => string;
583
+ restore: (json: string | null, cap?: number) => TabStore;
584
+ save: (store: TabStore, storage: any, key?: string) => boolean;
585
+ load: (storage: any, cap?: number, key?: string) => TabStore;
586
+ cleanState: (state: any) => TabState;
587
+ titleFor: (state: TabState) => string;
588
+ };
589
+
590
+ type PaletteCommand = {
591
+ id: string; title: string; group: string; action: string; arg?: string;
592
+ };
593
+
594
+ type PaletteAPI = {
595
+ commands: (schema: Schema | null, flags?: any) => PaletteCommand[];
596
+ filter: (commands: PaletteCommand[], query: string) => PaletteCommand[];
597
+ render: (commands: PaletteCommand[], handlers: {
598
+ onRun: (c: PaletteCommand) => void; onClose?: () => void;
599
+ }) => HTMLElement;
600
+ };
601
+
602
+ // ─── v0.5.0 staged saves ───
603
+
604
+ type BatchOpName = "create" | "update" | "delete" | "m2m_add" | "m2m_remove";
605
+
606
+ type PendingChange = {
607
+ id: string;
608
+ seq: number;
609
+ op: BatchOpName;
610
+ model: string;
611
+ pk?: string;
612
+ data?: Record<string, any>;
613
+ before?: Record<string, any>;
614
+ expected?: Record<string, any>;
615
+ rel?: string;
616
+ ids?: string[];
617
+ };
618
+
619
+ type PendingStore = { changes: PendingChange[]; seq: number };
620
+
621
+ type DiffEntry = { field: string; before: any; after: any };
622
+
623
+ type BatchRequest = {
624
+ operations: any[];
625
+ connection?: string;
626
+ };
627
+
628
+ type PendingAPI = {
629
+ create: () => PendingStore;
630
+ isDirty: (store: PendingStore) => boolean;
631
+ stage: (store: PendingStore, spec: any) => {
632
+ store: PendingStore; change: PendingChange | null; coalesced: boolean;
633
+ };
634
+ discard: (store: PendingStore, id: string) => PendingStore;
635
+ discardAll: (store: PendingStore) => PendingStore;
636
+ undo: (store: PendingStore) => PendingStore;
637
+ diff: (change: PendingChange) => DiffEntry[];
638
+ requestBody: (store: PendingStore, connection?: string) => BatchRequest;
639
+ };
640
+
641
+ type AIFilter = { field: string; op?: string; value?: any };
642
+
643
+ type AIAPI = {
644
+ isEnabled: (schema: Schema | null) => boolean;
645
+ label: (filter: AIFilter) => string;
646
+ chips: (filters: AIFilter[], onRemove?: (index: number) => void) => DocumentFragment;
647
+ };
648
+
649
+ // ─── v0.5.0 detail drawer, inline edit & accessibility ───
650
+
651
+ type InlineEditState = { active: any, last: any };
652
+
653
+ type InlineEditAPI = {
654
+ create: () => InlineEditState;
655
+ isEditing: (state: InlineEditState) => boolean;
656
+ begin: (state: InlineEditState, spec: {
657
+ model: string; pk: any; col: string; value: any;
658
+ }) => InlineEditState;
659
+ change: (state: InlineEditState, value: any) => InlineEditState;
660
+ cancel: (state: InlineEditState) => InlineEditState;
661
+ commit: (state: InlineEditState) => {
662
+ state: InlineEditState; spec: any; changed: boolean;
663
+ };
664
+ undo: (state: InlineEditState) => { state: InlineEditState; spec: any };
665
+ };
666
+
667
+ type A11yAPI = {
668
+ focusable: (root: any) => HTMLElement[];
669
+ saveFocus: () => HTMLElement | null;
670
+ restoreFocus: (el: HTMLElement | null) => boolean;
671
+ trapFocus: (root: any, ev: KeyboardEvent) => boolean;
672
+ reducedMotion: (doc?: Document) => boolean;
673
+ };
674
+
675
+ // ─── v0.5.0 copy-as & JSON viewer ───
676
+
677
+ type CopyAsAPI = {
678
+ json: (row: any) => string;
679
+ createSnippet: (desc: any, row: any) => string;
680
+ csvLine: (row: any, cols: string[]) => string;
681
+ csvCell: (v: any) => string;
682
+ pyLiteral: (v: any) => string;
683
+ write: (text: string) => Promise<boolean>;
684
+ };
685
+
686
+ type JsonViewAPI = {
687
+ render: (value: any, options?: { rootLabel?: string }) => HTMLElement;
688
+ validate: (text: string) => { ok: boolean; value?: any; error?: string };
689
+ kindOf: (v: any) => string;
690
+ };
691
+
692
+ // ─── v0.5.0 query history ───
693
+
694
+ type QueryHistoryFactory = {
695
+ create: (storage: any) => QueryHistoryAPI;
696
+ };
697
+
698
+ type QueryHistoryAPI = {
699
+ list: () => any[];
700
+ add: (spec: {
701
+ model: string; filters?: any; search?: string; sort?: string; limit?: any;
702
+ }) => any[];
703
+ clear: () => any[];
704
+ KEY: string;
705
+ MAX: number;
706
+ };