@antelopejs/dms-database 0.0.13 → 0.1.0

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 (173) hide show
  1. package/README.md +30 -5
  2. package/dist/db/models/query_history.model.d.ts +1 -0
  3. package/dist/db/models/query_history.model.js +6 -0
  4. package/dist/db/models/query_history.model.js.map +1 -1
  5. package/dist/db/tables/query_history.table.d.ts +3 -0
  6. package/dist/db/tables/query_history.table.js +12 -0
  7. package/dist/db/tables/query_history.table.js.map +1 -1
  8. package/dist/db/tables/saved_queries.table.d.ts +1 -0
  9. package/dist/db/tables/saved_queries.table.js +4 -0
  10. package/dist/db/tables/saved_queries.table.js.map +1 -1
  11. package/dist/i18n/messages.d.ts +39 -0
  12. package/dist/i18n/messages.js +64 -0
  13. package/dist/i18n/messages.js.map +1 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +1 -7
  16. package/dist/index.js.map +1 -1
  17. package/dist/module.d.ts +11 -0
  18. package/dist/module.js +55 -0
  19. package/dist/module.js.map +1 -0
  20. package/dist/pages/data.d.ts +1 -1
  21. package/dist/pages/data.js +9 -6
  22. package/dist/pages/data.js.map +1 -1
  23. package/dist/pages/diagram.d.ts +9 -0
  24. package/dist/pages/diagram.js +45 -0
  25. package/dist/pages/diagram.js.map +1 -0
  26. package/dist/pages/index.d.ts +1 -0
  27. package/dist/pages/index.js +1 -0
  28. package/dist/pages/index.js.map +1 -1
  29. package/dist/pages/overview.d.ts +4 -1
  30. package/dist/pages/overview.js +113 -6
  31. package/dist/pages/overview.js.map +1 -1
  32. package/dist/pages/query.d.ts +1 -1
  33. package/dist/pages/query.js +22 -6
  34. package/dist/pages/query.js.map +1 -1
  35. package/dist/pages/schemas.d.ts +2 -1
  36. package/dist/pages/schemas.js +143 -6
  37. package/dist/pages/schemas.js.map +1 -1
  38. package/dist/routes/data.d.ts +8 -0
  39. package/dist/routes/data.js +84 -21
  40. package/dist/routes/data.js.map +1 -1
  41. package/dist/routes/index.d.ts +1 -0
  42. package/dist/routes/index.js +1 -0
  43. package/dist/routes/index.js.map +1 -1
  44. package/dist/routes/overview.d.ts +12 -0
  45. package/dist/routes/overview.js +55 -0
  46. package/dist/routes/overview.js.map +1 -0
  47. package/dist/routes/query.d.ts +5 -1
  48. package/dist/routes/query.js +162 -27
  49. package/dist/routes/query.js.map +1 -1
  50. package/dist/routes/tables.d.ts +15 -12
  51. package/dist/routes/tables.js +95 -55
  52. package/dist/routes/tables.js.map +1 -1
  53. package/dist/service/catalog.d.ts +3 -0
  54. package/dist/service/catalog.js +26 -0
  55. package/dist/service/catalog.js.map +1 -0
  56. package/dist/service/health.d.ts +3 -3
  57. package/dist/service/health.js +17 -14
  58. package/dist/service/health.js.map +1 -1
  59. package/dist/service/introspect.d.ts +3 -1
  60. package/dist/service/introspect.js +131 -43
  61. package/dist/service/introspect.js.map +1 -1
  62. package/dist/service/overview.d.ts +9 -0
  63. package/dist/service/overview.js +113 -0
  64. package/dist/service/overview.js.map +1 -0
  65. package/dist/service/queryInspection.d.ts +15 -0
  66. package/dist/service/queryInspection.js +107 -0
  67. package/dist/service/queryInspection.js.map +1 -0
  68. package/dist/service/references.d.ts +9 -0
  69. package/dist/service/references.js +52 -0
  70. package/dist/service/references.js.map +1 -0
  71. package/dist/service/schemaFilters.d.ts +26 -0
  72. package/dist/service/schemaFilters.js +42 -0
  73. package/dist/service/schemaFilters.js.map +1 -0
  74. package/dist/service/stagedSerialization.d.ts +2 -0
  75. package/dist/service/stagedSerialization.js +38 -10
  76. package/dist/service/stagedSerialization.js.map +1 -1
  77. package/dist/service/types.d.ts +11 -1
  78. package/dist/types/constants.d.ts +2 -0
  79. package/dist/types/constants.js +3 -1
  80. package/dist/types/constants.js.map +1 -1
  81. package/dist/utils/query.d.ts +0 -2
  82. package/dist/utils/query.js +0 -20
  83. package/dist/utils/query.js.map +1 -1
  84. package/frontend-vue/app/{composables → build/composables}/useDataBrowserGrid.ts +65 -50
  85. package/frontend-vue/app/build/composables/useDataBrowserTabs.ts +366 -0
  86. package/frontend-vue/app/build/composables/useDatabaseHealth.ts +50 -0
  87. package/frontend-vue/app/build/composables/useDatabaseSchemas.ts +140 -0
  88. package/frontend-vue/app/{composables → build/composables}/useDiagramPersistence.ts +47 -39
  89. package/frontend-vue/app/build/composables/useQueryRuntime.ts +217 -0
  90. package/frontend-vue/app/build/composables/useQueryStore.ts +162 -0
  91. package/frontend-vue/app/build/data/cellValues.ts +132 -0
  92. package/frontend-vue/app/build/data/instanceOptions.ts +36 -0
  93. package/frontend-vue/app/build/data/pickerMenus.ts +175 -0
  94. package/frontend-vue/app/build/data/recentTables.ts +48 -0
  95. package/frontend-vue/app/build/data/stagedEdits.ts +117 -0
  96. package/frontend-vue/app/build/data/stagedWrites.ts +64 -0
  97. package/frontend-vue/app/build/data/useStagedSave.ts +298 -0
  98. package/frontend-vue/app/build/diagram/autosave.ts +72 -0
  99. package/frontend-vue/app/build/diagram/graph.ts +585 -0
  100. package/frontend-vue/app/build/diagram/history.ts +178 -0
  101. package/frontend-vue/app/build/diagram/shortcuts.ts +62 -0
  102. package/frontend-vue/app/build/diagram/sync.ts +137 -0
  103. package/frontend-vue/app/build/query/completion.ts +100 -0
  104. package/frontend-vue/app/build/query/csv.ts +32 -0
  105. package/frontend-vue/app/build/query/examples.ts +38 -0
  106. package/frontend-vue/app/build/query/runs.ts +168 -0
  107. package/frontend-vue/app/build/query/tableColumns.ts +35 -0
  108. package/frontend-vue/app/build/query/target.ts +143 -0
  109. package/frontend-vue/app/build/schemas/filterState.ts +128 -0
  110. package/frontend-vue/app/build/schemas/useSchemasListing.ts +62 -0
  111. package/frontend-vue/app/build/utils/databaseLinks.ts +98 -0
  112. package/frontend-vue/app/build/utils/fieldTypes.ts +198 -0
  113. package/frontend-vue/app/build/utils/relativeTime.ts +19 -0
  114. package/frontend-vue/app/{utils → build/utils}/stagedSerialization.ts +7 -1
  115. package/frontend-vue/app/components/ConnectionStatus.vue +122 -0
  116. package/frontend-vue/app/components/DataBrowser.vue +126 -0
  117. package/frontend-vue/app/components/DataBrowserSidebar.vue +293 -210
  118. package/frontend-vue/app/components/DataBrowserTabBar.vue +185 -93
  119. package/frontend-vue/app/components/DataFilterBar.vue +163 -0
  120. package/frontend-vue/app/components/DataGrid.vue +737 -499
  121. package/frontend-vue/app/components/DataGridCell.vue +125 -77
  122. package/frontend-vue/app/components/DataGridHeaderCell.vue +119 -81
  123. package/frontend-vue/app/components/DiagramNoteNode.vue +81 -63
  124. package/frontend-vue/app/components/DiagramRelationEdge.vue +57 -27
  125. package/frontend-vue/app/components/DiagramStubNode.vue +16 -17
  126. package/frontend-vue/app/components/DiagramTableNode.vue +106 -68
  127. package/frontend-vue/app/components/InstancePicker.vue +195 -0
  128. package/frontend-vue/app/components/JsonCellPanel.vue +30 -29
  129. package/frontend-vue/app/components/QueryBuilderPanel.vue +290 -238
  130. package/frontend-vue/app/components/QueryConsole.vue +726 -0
  131. package/frontend-vue/app/components/QueryLibrary.vue +314 -0
  132. package/frontend-vue/app/components/QueryResultPanel.vue +556 -126
  133. package/frontend-vue/app/components/RowDrawer.vue +520 -0
  134. package/frontend-vue/app/components/SchemaDiagram.vue +1016 -1051
  135. package/frontend-vue/app/components/SchemaPicker.vue +86 -0
  136. package/frontend-vue/app/components/SchemasFilterBar.vue +201 -0
  137. package/frontend-vue/app/components/TableInspector.vue +741 -0
  138. package/frontend-vue/app/config/shortcuts-registry.ts +65 -0
  139. package/frontend-vue/dms.frontend.ts +5 -14
  140. package/frontend-vue/i18n/locales/database-en-GB.json +526 -193
  141. package/frontend-vue/i18n/locales/database-fr-FR.json +528 -195
  142. package/frontend-vue/package.json +2 -1
  143. package/frontend-vue/pnpm-lock.yaml +2601 -858
  144. package/frontend-vue/pnpm-workspace.yaml +1 -1
  145. package/frontend-vue/tests/dataBrowser.test.ts +206 -0
  146. package/frontend-vue/tests/diagram.test.ts +516 -0
  147. package/frontend-vue/tests/helpers.test.ts +205 -0
  148. package/frontend-vue/tests/instanceOptions.test.ts +53 -0
  149. package/frontend-vue/tests/locales.test.ts +56 -0
  150. package/frontend-vue/tests/persistence.test.ts +106 -5
  151. package/frontend-vue/tests/pickerMenus.test.ts +254 -0
  152. package/frontend-vue/tests/queryConsole.test.ts +282 -0
  153. package/frontend-vue/tests/queryRuntime.test.ts +2 -2
  154. package/frontend-vue/tests/registration.test.ts +36 -25
  155. package/frontend-vue/tests/schemasFilters.test.ts +115 -0
  156. package/package.json +9 -6
  157. package/frontend-vue/app/components/QueryFavoritesPanel.vue +0 -127
  158. package/frontend-vue/app/components/QueryHistoryPanel.vue +0 -134
  159. package/frontend-vue/app/components/SchemaTableInspector.vue +0 -278
  160. package/frontend-vue/app/composables/useDataBrowserTabs.ts +0 -255
  161. package/frontend-vue/app/composables/useDatabaseHealth.ts +0 -50
  162. package/frontend-vue/app/composables/useDatabaseSchemas.ts +0 -92
  163. package/frontend-vue/app/composables/useQueryRuntime.ts +0 -118
  164. package/frontend-vue/app/composables/useQueryStore.ts +0 -117
  165. package/frontend-vue/app/composables/useTableViewRowClick.ts +0 -22
  166. package/frontend-vue/app/custom-pages/database/data.vue +0 -41
  167. package/frontend-vue/app/custom-pages/database/overview.vue +0 -367
  168. package/frontend-vue/app/custom-pages/database/query.vue +0 -436
  169. package/frontend-vue/app/custom-pages/database/schemas.vue +0 -218
  170. package/frontend-vue/app/utils/databaseFieldModifiers.ts +0 -33
  171. package/frontend-vue/app/utils/databaseFieldTypeIcons.ts +0 -224
  172. package/frontend-vue/app/utils/dmsTableView.ts +0 -83
  173. package/frontend-vue/app/utils/relativeTime.ts +0 -18
@@ -1,224 +0,0 @@
1
- import type { FieldDescriptor } from "../composables/useDatabaseSchemas";
2
-
3
- export interface TypeIcon {
4
- icon: string;
5
- color: string;
6
- label: string;
7
- }
8
-
9
- const NAMED_TYPE_ICONS: Record<string, TypeIcon> = {
10
- email: { icon: "i-ph-at", color: "text-sky-500", label: "Email" },
11
- password: { icon: "i-ph-lock", color: "text-amber-500", label: "Password" },
12
- secret: { icon: "i-ph-lock", color: "text-amber-500", label: "Secret" },
13
- };
14
-
15
- const FALLBACK_ICON: TypeIcon = {
16
- icon: "i-ph-question",
17
- color: "text-muted",
18
- label: "Unknown",
19
- };
20
-
21
- const STRING_ICON: TypeIcon = {
22
- icon: "i-ph-text-aa",
23
- color: "text-neutral-500",
24
- label: "String",
25
- };
26
- const NUMBER_ICON: TypeIcon = {
27
- icon: "i-ph-hash",
28
- color: "text-blue-500",
29
- label: "Number",
30
- };
31
- const BOOLEAN_ICON: TypeIcon = {
32
- icon: "i-ph-toggle-right",
33
- color: "text-emerald-500",
34
- label: "Boolean",
35
- };
36
- const DATE_ICON: TypeIcon = {
37
- icon: "i-ph-calendar-blank",
38
- color: "text-violet-500",
39
- label: "Date",
40
- };
41
- const ARRAY_ICON: TypeIcon = {
42
- icon: "i-ph-brackets-square",
43
- color: "text-orange-500",
44
- label: "Array",
45
- };
46
- const OBJECT_ICON: TypeIcon = {
47
- icon: "i-ph-brackets-curly",
48
- color: "text-amber-600",
49
- label: "Object",
50
- };
51
- const RECORD_ICON: TypeIcon = {
52
- icon: "i-ph-brackets-curly",
53
- color: "text-amber-600",
54
- label: "Record",
55
- };
56
- const TUPLE_ICON: TypeIcon = {
57
- icon: "i-ph-brackets-square",
58
- color: "text-orange-500",
59
- label: "Tuple",
60
- };
61
- const ENUM_ICON: TypeIcon = {
62
- icon: "i-ph-list-checks",
63
- color: "text-cyan-500",
64
- label: "Enum",
65
- };
66
- const UNION_ICON: TypeIcon = {
67
- icon: "i-ph-split",
68
- color: "text-fuchsia-500",
69
- label: "Union",
70
- };
71
- const NULL_ICON: TypeIcon = {
72
- icon: "i-ph-circle-dashed",
73
- color: "text-muted",
74
- label: "Null",
75
- };
76
-
77
- const PRIMARY_KEY_NAMES = new Set(["id", "_id"]);
78
- const PRIMARY_KEY_INDEXES = ["pk", "primary"] as const;
79
-
80
- function literalLabel(value: string | number | boolean): string {
81
- if (typeof value === "string") return `"${value}"`;
82
- return String(value);
83
- }
84
-
85
- function describeDescriptor(d: FieldDescriptor): string {
86
- switch (d.kind) {
87
- case "string":
88
- case "number":
89
- case "boolean":
90
- case "date":
91
- case "any":
92
- case "unknown":
93
- case "null":
94
- case "undefined":
95
- return d.kind;
96
- case "literal":
97
- return literalLabel(d.value);
98
- case "array":
99
- return `${d.element ? describeDescriptor(d.element) : "any"}[]`;
100
- case "tuple":
101
- return `[${d.elements.map(describeDescriptor).join(", ")}]`;
102
- case "object":
103
- return d.partial ? "Partial object" : "Object";
104
- case "record":
105
- return `Record<${d.key ? describeDescriptor(d.key) : "string"}, ${describeDescriptor(
106
- d.value,
107
- )}>`;
108
- case "union":
109
- return d.members.map(describeDescriptor).join(" | ");
110
- case "intersection":
111
- return d.members.map(describeDescriptor).join(" & ");
112
- case "keyof":
113
- return d.keys.length > 0 ? d.keys.map((k) => `"${k}"`).join(" | ") : "keyof";
114
- case "refinement":
115
- return d.name;
116
- case "recursive":
117
- return d.name;
118
- }
119
- }
120
-
121
- function descriptorIcon(d: FieldDescriptor): TypeIcon {
122
- switch (d.kind) {
123
- case "string":
124
- return STRING_ICON;
125
- case "number":
126
- return NUMBER_ICON;
127
- case "boolean":
128
- return BOOLEAN_ICON;
129
- case "date":
130
- return DATE_ICON;
131
- case "null":
132
- case "undefined":
133
- return NULL_ICON;
134
- case "any":
135
- case "unknown":
136
- return FALLBACK_ICON;
137
- case "array":
138
- return d.element
139
- ? { ...ARRAY_ICON, label: `${describeDescriptor(d.element)}[]` }
140
- : ARRAY_ICON;
141
- case "tuple":
142
- return { ...TUPLE_ICON, label: describeDescriptor(d) };
143
- case "object":
144
- return d.partial ? { ...OBJECT_ICON, label: "Partial object" } : OBJECT_ICON;
145
- case "record":
146
- return { ...RECORD_ICON, label: describeDescriptor(d) };
147
- case "literal": {
148
- const base =
149
- typeof d.value === "string"
150
- ? STRING_ICON
151
- : typeof d.value === "number"
152
- ? NUMBER_ICON
153
- : BOOLEAN_ICON;
154
- return { ...base, label: literalLabel(d.value) };
155
- }
156
- case "union": {
157
- const allLiteral =
158
- d.members.length > 0 && d.members.every((m) => m.kind === "literal");
159
- if (allLiteral) {
160
- return { ...ENUM_ICON, label: describeDescriptor(d) };
161
- }
162
- return { ...UNION_ICON, label: describeDescriptor(d) };
163
- }
164
- case "intersection":
165
- return { ...UNION_ICON, label: describeDescriptor(d) };
166
- case "keyof":
167
- return { ...ENUM_ICON, label: describeDescriptor(d) };
168
- case "refinement": {
169
- const base = descriptorIcon(d.base);
170
- return { ...base, label: d.name };
171
- }
172
- case "recursive":
173
- return { ...FALLBACK_ICON, label: d.name };
174
- }
175
- }
176
-
177
- function isDescriptor(value: unknown): value is FieldDescriptor {
178
- return (
179
- value !== null &&
180
- typeof value === "object" &&
181
- typeof (value as { kind?: unknown }).kind === "string"
182
- );
183
- }
184
-
185
- const RUNTIME_TYPE_ICONS: Record<string, TypeIcon> = {
186
- string: STRING_ICON,
187
- number: NUMBER_ICON,
188
- boolean: BOOLEAN_ICON,
189
- array: ARRAY_ICON,
190
- object: OBJECT_ICON,
191
- null: NULL_ICON,
192
- undefined: NULL_ICON,
193
- };
194
-
195
- // Icon for a COARSE RUNTIME type as sampled by the browse `/columns` endpoint
196
- // (string | number | boolean | object | array | null | undefined) — the data
197
- // grid's headers use this so runtime-sampled and schema-declared columns share
198
- // one icon set. Named-field overrides (email, password…) still apply.
199
- export function runtimeTypeIcon(type: string, fieldName: string): TypeIcon {
200
- const named = NAMED_TYPE_ICONS[fieldName.toLowerCase()];
201
- if (named) return named;
202
- return RUNTIME_TYPE_ICONS[type] ?? FALLBACK_ICON;
203
- }
204
-
205
- export function inferFieldTypeIcon(
206
- field: unknown,
207
- fieldName: string,
208
- ): TypeIcon {
209
- const named = NAMED_TYPE_ICONS[fieldName.toLowerCase()];
210
- if (named) return named;
211
- if (isDescriptor(field)) return descriptorIcon(field);
212
- return FALLBACK_ICON;
213
- }
214
-
215
- export function isPrimaryKey(
216
- fieldName: string,
217
- indexes: Record<string, { fields?: string[] }>,
218
- ): boolean {
219
- if (PRIMARY_KEY_NAMES.has(fieldName)) return true;
220
- for (const indexName of PRIMARY_KEY_INDEXES) {
221
- if (indexes[indexName]?.fields?.includes(fieldName)) return true;
222
- }
223
- return false;
224
- }
@@ -1,83 +0,0 @@
1
- // Helpers that build, by hand, the *serialised* column config the shared
2
- // dms-ui `DmsTableView` component expects.
3
- //
4
- // The DMS normally generates these objects on the backend from a
5
- // `DataController` (one fixed table per controller). The module's navigation
6
- // lists (overview, schema inspector) render read-only tables against module
7
- // endpoints without such a controller, so we reproduce the same serialised
8
- // shapes the DMS emits for its own tables.
9
- //
10
- // Reference shapes:
11
- // DataTypeConfig — dms-core/app/types/data-type.ts
12
- // TableViewColumn — dms-ui/.../table-view/types/column.ts
13
- // ComponentInfo — { componentName, options? }
14
-
15
- // The component name a serialised `FormComponents.InputText()` resolves to.
16
- const TEXT_INPUT_COMPONENT = "dms-input-text";
17
-
18
- export interface DmsComponentInfo {
19
- componentName: string;
20
- options?: Record<string, unknown>;
21
- }
22
-
23
- export interface DmsDataTypeConfig {
24
- id: string;
25
- compareModes: string[];
26
- defaultCompareMode?: string;
27
- filterComponents: Record<string, DmsComponentInfo | "noInput">;
28
- inputComponent: DmsComponentInfo;
29
- }
30
-
31
- export interface DmsTableViewColumn {
32
- id: string;
33
- header: string;
34
- accessorKey: string;
35
- listable: boolean;
36
- type: DmsDataTypeConfig;
37
- visible?: boolean;
38
- enableSorting?: boolean;
39
- enableColumnFilter?: boolean;
40
- readonlyBehavior?: string;
41
- }
42
-
43
- // A string/text data type — the safe default for an introspected, schemaless
44
- // column. `id` is the load-bearing field: DmsTableView dereferences
45
- // `column.type.id` during setup, so every column MUST carry a valid type config
46
- // or the component throws immediately.
47
- export function stringDataType(): DmsDataTypeConfig {
48
- return {
49
- id: "string",
50
- // Filter modes offered when column filtering is enabled; the browse backend
51
- // decodes `is` (exact) and `contains` (substring).
52
- compareModes: ["is", "contains"],
53
- defaultCompareMode: "contains",
54
- filterComponents: {
55
- default: { componentName: TEXT_INPUT_COMPONENT },
56
- is: { componentName: TEXT_INPUT_COMPONENT },
57
- contains: { componentName: TEXT_INPUT_COMPONENT },
58
- },
59
- inputComponent: { componentName: TEXT_INPUT_COMPONENT },
60
- };
61
- }
62
-
63
- export interface ReadonlyColumnSpec {
64
- key: string;
65
- header: string;
66
- enableSorting?: boolean;
67
- }
68
-
69
- // Build read-only, sortable columns with explicit (i18n) headers — used by the
70
- // table-navigation lists, which are display-only (no form components).
71
- export function buildReadonlyColumns(
72
- specs: ReadonlyColumnSpec[],
73
- ): DmsTableViewColumn[] {
74
- return specs.map((spec) => ({
75
- id: spec.key,
76
- accessorKey: spec.key,
77
- header: spec.header,
78
- listable: true,
79
- type: stringDataType(),
80
- enableSorting: spec.enableSorting ?? true,
81
- enableColumnFilter: false,
82
- }));
83
- }
@@ -1,18 +0,0 @@
1
- const relativeFormatter = new Intl.RelativeTimeFormat(undefined, {
2
- numeric: "auto",
3
- });
4
-
5
- // Human "3 minutes ago" style label for an ISO timestamp, relative to now.
6
- // Shared by the query history and favorites panels.
7
- // Deliberately not named `formatRelativeTime`: the DMS core layer exports a
8
- // translation-aware helper under that name, and auto-imports across layers
9
- // would shadow one with the other.
10
- export function formatDatabaseRelativeTime(iso: string): string {
11
- const diffMs = new Date(iso).getTime() - Date.now();
12
- const minutes = Math.round(diffMs / 60_000);
13
- if (Math.abs(minutes) < 60) return relativeFormatter.format(minutes, "minute");
14
- const hours = Math.round(minutes / 60);
15
- if (Math.abs(hours) < 24) return relativeFormatter.format(hours, "hour");
16
- const days = Math.round(hours / 24);
17
- return relativeFormatter.format(days, "day");
18
- }