@sfxcode/nuxt-ui-mongocamp 1.3.5 → 1.5.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 (224) hide show
  1. package/README.md +1 -1
  2. package/dist/module.d.mts +8 -0
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +6 -0
  5. package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
  6. package/dist/runtime/components/MongocampAggregationBuilder.vue +331 -5
  7. package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
  8. package/dist/runtime/components/MongocampAggregationChart.d.vue.ts +6 -0
  9. package/dist/runtime/components/MongocampAggregationChart.vue +93 -0
  10. package/dist/runtime/components/MongocampAggregationChart.vue.d.ts +6 -0
  11. package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +10 -0
  12. package/dist/runtime/components/MongocampAggregationStagePreview.vue +149 -0
  13. package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +10 -0
  14. package/dist/runtime/components/MongocampBucketFiles.vue +230 -48
  15. package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +9 -0
  16. package/dist/runtime/components/MongocampBulkDelete.vue +94 -25
  17. package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +9 -0
  18. package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +5 -0
  19. package/dist/runtime/components/MongocampBulkEdit.vue +41 -3
  20. package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +5 -0
  21. package/dist/runtime/components/MongocampChart.d.vue.ts +29 -0
  22. package/dist/runtime/components/MongocampChart.vue +129 -0
  23. package/dist/runtime/components/MongocampChart.vue.d.ts +29 -0
  24. package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +17 -0
  25. package/dist/runtime/components/MongocampCollectionCharts.vue +200 -0
  26. package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +17 -0
  27. package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +23 -0
  28. package/dist/runtime/components/MongocampCollectionCopy.vue +206 -0
  29. package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +23 -0
  30. package/dist/runtime/components/MongocampCollectionData.d.vue.ts +6 -0
  31. package/dist/runtime/components/MongocampCollectionData.vue +423 -138
  32. package/dist/runtime/components/MongocampCollectionData.vue.d.ts +6 -0
  33. package/dist/runtime/components/MongocampCollectionInfos.vue +106 -238
  34. package/dist/runtime/components/MongocampCollectionRename.d.vue.ts +22 -0
  35. package/dist/runtime/components/MongocampCollectionRename.vue +116 -0
  36. package/dist/runtime/components/MongocampCollectionRename.vue.d.ts +22 -0
  37. package/dist/runtime/components/MongocampCollections.vue +93 -12
  38. package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +40 -0
  39. package/dist/runtime/components/MongocampCommandPalette.vue +135 -0
  40. package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +40 -0
  41. package/dist/runtime/components/MongocampConfirmByName.vue +2 -2
  42. package/dist/runtime/components/MongocampDashboard.d.vue.ts +3 -1
  43. package/dist/runtime/components/MongocampDashboard.vue +39 -5
  44. package/dist/runtime/components/MongocampDashboard.vue.d.ts +3 -1
  45. package/dist/runtime/components/MongocampDatabases.vue +35 -2
  46. package/dist/runtime/components/MongocampDocumentCompare.d.vue.ts +20 -0
  47. package/dist/runtime/components/MongocampDocumentCompare.vue +146 -0
  48. package/dist/runtime/components/MongocampDocumentCompare.vue.d.ts +20 -0
  49. package/dist/runtime/components/MongocampDocumentView.d.vue.ts +22 -0
  50. package/dist/runtime/components/MongocampDocumentView.vue +202 -0
  51. package/dist/runtime/components/MongocampDocumentView.vue.d.ts +22 -0
  52. package/dist/runtime/components/MongocampErrorAlert.vue +12 -4
  53. package/dist/runtime/components/MongocampExportAll.d.vue.ts +18 -0
  54. package/dist/runtime/components/MongocampExportAll.vue +191 -0
  55. package/dist/runtime/components/MongocampExportAll.vue.d.ts +18 -0
  56. package/dist/runtime/components/MongocampFilePreview.d.vue.ts +16 -0
  57. package/dist/runtime/components/MongocampFilePreview.vue +162 -0
  58. package/dist/runtime/components/MongocampFilePreview.vue.d.ts +16 -0
  59. package/dist/runtime/components/MongocampFilterBuilder.vue +11 -0
  60. package/dist/runtime/components/MongocampImport.vue +171 -13
  61. package/dist/runtime/components/MongocampIndexes.d.vue.ts +18 -0
  62. package/dist/runtime/components/MongocampIndexes.vue +496 -0
  63. package/dist/runtime/components/MongocampIndexes.vue.d.ts +18 -0
  64. package/dist/runtime/components/MongocampJobs.d.vue.ts +6 -1
  65. package/dist/runtime/components/MongocampJobs.vue +36 -5
  66. package/dist/runtime/components/MongocampJobs.vue.d.ts +6 -1
  67. package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +12 -0
  68. package/dist/runtime/components/MongocampPermissionMatrix.vue +301 -0
  69. package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +12 -0
  70. package/dist/runtime/components/MongocampQueryBar.d.vue.ts +26 -0
  71. package/dist/runtime/components/MongocampQueryBar.vue +398 -0
  72. package/dist/runtime/components/MongocampQueryBar.vue.d.ts +26 -0
  73. package/dist/runtime/components/MongocampRoleGrants.vue +18 -5
  74. package/dist/runtime/components/MongocampRoles.vue +16 -5
  75. package/dist/runtime/components/MongocampServerOverview.d.vue.ts +20 -0
  76. package/dist/runtime/components/MongocampServerOverview.vue +420 -0
  77. package/dist/runtime/components/MongocampServerOverview.vue.d.ts +20 -0
  78. package/dist/runtime/components/MongocampSettings.d.vue.ts +28 -1
  79. package/dist/runtime/components/MongocampSettings.vue +83 -10
  80. package/dist/runtime/components/MongocampSettings.vue.d.ts +28 -1
  81. package/dist/runtime/components/MongocampUsers.vue +19 -6
  82. package/dist/runtime/composables/useMongocampAdmin.d.ts +2 -1
  83. package/dist/runtime/composables/useMongocampAdmin.js +6 -1
  84. package/dist/runtime/composables/useMongocampAdminGate.d.ts +12 -0
  85. package/dist/runtime/composables/useMongocampAdminGate.js +12 -0
  86. package/dist/runtime/composables/useMongocampAggregation.d.ts +23 -1
  87. package/dist/runtime/composables/useMongocampAggregation.js +41 -26
  88. package/dist/runtime/composables/useMongocampAutoRefresh.d.ts +26 -0
  89. package/dist/runtime/composables/useMongocampAutoRefresh.js +78 -0
  90. package/dist/runtime/composables/useMongocampBucket.d.ts +13 -1
  91. package/dist/runtime/composables/useMongocampBucket.js +34 -0
  92. package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +15 -0
  93. package/dist/runtime/composables/useMongocampBulkByFilter.js +32 -0
  94. package/dist/runtime/composables/useMongocampClientApi.js +2 -1
  95. package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +45 -0
  96. package/dist/runtime/composables/useMongocampCollectionCopy.js +48 -0
  97. package/dist/runtime/composables/useMongocampCollectionStats.d.ts +10 -0
  98. package/dist/runtime/composables/useMongocampCollectionStats.js +17 -0
  99. package/dist/runtime/composables/useMongocampError.d.ts +2 -1
  100. package/dist/runtime/composables/useMongocampError.js +16 -1
  101. package/dist/runtime/composables/useMongocampExportAll.d.ts +53 -0
  102. package/dist/runtime/composables/useMongocampExportAll.js +57 -0
  103. package/dist/runtime/composables/useMongocampExtendedJson.d.ts +7 -2
  104. package/dist/runtime/composables/useMongocampExtendedJson.js +44 -11
  105. package/dist/runtime/composables/useMongocampFetchAll.d.ts +25 -0
  106. package/dist/runtime/composables/useMongocampFetchAll.js +27 -0
  107. package/dist/runtime/composables/useMongocampFieldTypes.d.ts +24 -0
  108. package/dist/runtime/composables/useMongocampFieldTypes.js +44 -0
  109. package/dist/runtime/composables/useMongocampImport.d.ts +4 -0
  110. package/dist/runtime/composables/useMongocampImport.js +5 -2
  111. package/dist/runtime/composables/useMongocampIndex.d.ts +6 -1
  112. package/dist/runtime/composables/useMongocampIndex.js +7 -1
  113. package/dist/runtime/composables/useMongocampPermissions.d.ts +17 -0
  114. package/dist/runtime/composables/useMongocampPermissions.js +43 -0
  115. package/dist/runtime/composables/useMongocampPersistedState.d.ts +15 -0
  116. package/dist/runtime/composables/useMongocampPersistedState.js +21 -0
  117. package/dist/runtime/composables/useMongocampProxyApi.js +2 -1
  118. package/dist/runtime/composables/useMongocampQuery.d.ts +50 -2
  119. package/dist/runtime/composables/useMongocampQuery.js +72 -1
  120. package/dist/runtime/composables/useMongocampSavedPipelines.d.ts +25 -0
  121. package/dist/runtime/composables/useMongocampSavedPipelines.js +23 -0
  122. package/dist/runtime/composables/useMongocampSavedQueries.d.ts +37 -0
  123. package/dist/runtime/composables/useMongocampSavedQueries.js +50 -0
  124. package/dist/runtime/composables/useMongocampServerOverview.d.ts +35 -0
  125. package/dist/runtime/composables/useMongocampServerOverview.js +51 -0
  126. package/dist/runtime/composables/useMongocampSession.d.ts +2 -0
  127. package/dist/runtime/composables/useMongocampSession.js +16 -2
  128. package/dist/runtime/composables/useMongocampSystem.d.ts +7 -2
  129. package/dist/runtime/composables/useMongocampSystem.js +6 -2
  130. package/dist/runtime/locales/de.json +509 -25
  131. package/dist/runtime/locales/en.json +509 -25
  132. package/dist/runtime/plugin.js +6 -3
  133. package/dist/runtime/utils/aggregationErrors.d.ts +4 -0
  134. package/dist/runtime/utils/aggregationErrors.js +7 -0
  135. package/dist/runtime/utils/aggregationPipeline.d.ts +5 -4
  136. package/dist/runtime/utils/aggregationPipeline.js +23 -9
  137. package/dist/runtime/utils/aggregationPreview.d.ts +13 -0
  138. package/dist/runtime/utils/aggregationPreview.js +10 -0
  139. package/dist/runtime/utils/aggregationResult.d.ts +5 -0
  140. package/dist/runtime/utils/aggregationResult.js +4 -0
  141. package/dist/runtime/utils/aggregationTemplates.d.ts +34 -0
  142. package/dist/runtime/utils/aggregationTemplates.js +47 -0
  143. package/dist/runtime/utils/analyzeSamples.d.ts +1 -0
  144. package/dist/runtime/utils/analyzeSamples.js +1 -1
  145. package/dist/runtime/utils/autoRefresh.d.ts +14 -0
  146. package/dist/runtime/utils/autoRefresh.js +15 -0
  147. package/dist/runtime/utils/batchInsert.d.ts +6 -0
  148. package/dist/runtime/utils/batchInsert.js +31 -3
  149. package/dist/runtime/utils/bigIntJson.d.ts +15 -0
  150. package/dist/runtime/utils/bigIntJson.js +55 -0
  151. package/dist/runtime/utils/bsonTypes.d.ts +10 -0
  152. package/dist/runtime/utils/bsonTypes.js +42 -0
  153. package/dist/runtime/utils/bulkDelete.d.ts +9 -1
  154. package/dist/runtime/utils/bulkDelete.js +15 -3
  155. package/dist/runtime/utils/bulkEdit.d.ts +6 -0
  156. package/dist/runtime/utils/bulkEdit.js +7 -0
  157. package/dist/runtime/utils/chartData.d.ts +11 -0
  158. package/dist/runtime/utils/chartData.js +9 -0
  159. package/dist/runtime/utils/collectionChart.d.ts +36 -0
  160. package/dist/runtime/utils/collectionChart.js +73 -0
  161. package/dist/runtime/utils/collectionCopy.d.ts +24 -0
  162. package/dist/runtime/utils/collectionCopy.js +37 -0
  163. package/dist/runtime/utils/collectionStats.d.ts +31 -0
  164. package/dist/runtime/utils/collectionStats.js +42 -0
  165. package/dist/runtime/utils/commandPalette.d.ts +48 -0
  166. package/dist/runtime/utils/commandPalette.js +39 -0
  167. package/dist/runtime/utils/configRows.d.ts +7 -0
  168. package/dist/runtime/utils/configRows.js +4 -0
  169. package/dist/runtime/utils/documentCompare.d.ts +31 -0
  170. package/dist/runtime/utils/documentCompare.js +71 -0
  171. package/dist/runtime/utils/documentDiff.d.ts +19 -0
  172. package/dist/runtime/utils/documentDiff.js +71 -0
  173. package/dist/runtime/utils/documentPaths.d.ts +41 -0
  174. package/dist/runtime/utils/documentPaths.js +139 -0
  175. package/dist/runtime/utils/documentTree.d.ts +40 -0
  176. package/dist/runtime/utils/documentTree.js +102 -0
  177. package/dist/runtime/utils/exportDocuments.d.ts +33 -0
  178. package/dist/runtime/utils/exportDocuments.js +53 -0
  179. package/dist/runtime/utils/exportRows.d.ts +2 -0
  180. package/dist/runtime/utils/exportRows.js +6 -3
  181. package/dist/runtime/utils/fieldDetails.d.ts +51 -0
  182. package/dist/runtime/utils/fieldDetails.js +113 -0
  183. package/dist/runtime/utils/filePreview.d.ts +27 -0
  184. package/dist/runtime/utils/filePreview.js +50 -0
  185. package/dist/runtime/utils/filterBuilder.d.ts +6 -1
  186. package/dist/runtime/utils/filterBuilder.js +6 -5
  187. package/dist/runtime/utils/formatBytes.d.ts +2 -0
  188. package/dist/runtime/utils/formatBytes.js +11 -0
  189. package/dist/runtime/utils/grantMatching.d.ts +8 -0
  190. package/dist/runtime/utils/grantMatching.js +15 -0
  191. package/dist/runtime/utils/importRows.js +12 -2
  192. package/dist/runtime/utils/indexForm.d.ts +83 -0
  193. package/dist/runtime/utils/indexForm.js +74 -0
  194. package/dist/runtime/utils/luceneExpression.d.ts +15 -0
  195. package/dist/runtime/utils/luceneExpression.js +74 -0
  196. package/dist/runtime/utils/pagedFetch.d.ts +46 -0
  197. package/dist/runtime/utils/pagedFetch.js +58 -0
  198. package/dist/runtime/utils/paginationHeaders.d.ts +4 -0
  199. package/dist/runtime/utils/paginationHeaders.js +4 -0
  200. package/dist/runtime/utils/permissionDenied.d.ts +10 -0
  201. package/dist/runtime/utils/permissionDenied.js +23 -0
  202. package/dist/runtime/utils/permissionMatrix.d.ts +55 -0
  203. package/dist/runtime/utils/permissionMatrix.js +85 -0
  204. package/dist/runtime/utils/persistedState.d.ts +25 -0
  205. package/dist/runtime/utils/persistedState.js +47 -0
  206. package/dist/runtime/utils/queryState.d.ts +45 -0
  207. package/dist/runtime/utils/queryState.js +75 -0
  208. package/dist/runtime/utils/requestLimits.d.ts +2 -0
  209. package/dist/runtime/utils/requestLimits.js +4 -0
  210. package/dist/runtime/utils/resultChart.d.ts +32 -0
  211. package/dist/runtime/utils/resultChart.js +59 -0
  212. package/dist/runtime/utils/savedPipelines.d.ts +22 -0
  213. package/dist/runtime/utils/savedPipelines.js +46 -0
  214. package/dist/runtime/utils/savedQueries.d.ts +60 -0
  215. package/dist/runtime/utils/savedQueries.js +143 -0
  216. package/dist/runtime/utils/schemaAnalysis.d.ts +16 -0
  217. package/dist/runtime/utils/schemaAnalysis.js +57 -0
  218. package/dist/runtime/utils/serverError.d.ts +19 -0
  219. package/dist/runtime/utils/serverError.js +19 -0
  220. package/dist/runtime/utils/serverOverview.d.ts +47 -0
  221. package/dist/runtime/utils/serverOverview.js +40 -0
  222. package/dist/runtime/utils/sessionGuard.d.ts +3 -0
  223. package/dist/runtime/utils/sessionGuard.js +18 -1
  224. package/package.json +15 -14
@@ -1,9 +1,15 @@
1
1
  type __VLS_Props = {
2
2
  collectionName: string;
3
3
  infoPath?: string;
4
+ aggregatePath?: string;
5
+ persistState?: boolean;
6
+ stateKey?: string;
4
7
  };
5
8
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
9
  infoPath: string;
10
+ aggregatePath: string;
11
+ persistState: boolean;
12
+ stateKey: string;
7
13
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
14
  declare const _default: typeof __VLS_export;
9
15
  export default _default;
@@ -1,10 +1,13 @@
1
1
  <script setup>
2
- import { computed, h, reactive, ref, resolveComponent, watch } from "vue";
3
- import { useI18n, useMongocampClientApi, useMongocampIndex, useMongocampSchema, useToast } from "#imports";
2
+ import { computed, h, ref, resolveComponent, watch } from "vue";
3
+ import { useI18n, useMongocampClientApi, useMongocampSchema, useToast } from "#imports";
4
+ import MongocampIndexes from "./MongocampIndexes.vue";
4
5
  import { useMongocampAggregation } from "../composables/useMongocampAggregation";
5
6
  import useMongocampAdmin from "../composables/useMongocampAdmin";
6
7
  import { analyzeSamples } from "../utils/analyzeSamples";
8
+ import { shortenLabel } from "../utils/chartData";
7
9
  import { downloadTextFile } from "../utils/exportRows";
10
+ import { FULL_ANALYSIS_MAX_DOCUMENTS, statisticsFromSchemaAnalysis } from "../utils/schemaAnalysis";
8
11
  const props = defineProps({
9
12
  collectionName: { type: String, required: true },
10
13
  sampleSize: { type: Number, required: false, default: 500 }
@@ -12,24 +15,14 @@ const props = defineProps({
12
15
  const { t } = useI18n();
13
16
  const { collectionApi, documentApi } = useMongocampClientApi();
14
17
  const { schemaFromSamples, schemaToTsInterface } = useMongocampSchema();
15
- const { listIndexes, createIndex, createUniqueIndex, createTextIndex, createExpiringIndex, deleteIndex } = useMongocampIndex();
16
18
  const { sampleDocuments, describeAggregationError } = useMongocampAggregation();
17
- const { getJsonSchema } = useMongocampAdmin();
19
+ const { getJsonSchema, getSchemaAnalysis } = useMongocampAdmin();
18
20
  const UBadge = resolveComponent("UBadge");
19
21
  const UIcon = resolveComponent("UIcon");
20
- const UButton = resolveComponent("UButton");
21
- const UTooltip = resolveComponent("UTooltip");
22
- function withTooltip(text, node) {
23
- return h(UTooltip, { text }, { default: () => node });
24
- }
25
22
  const info = ref(null);
23
+ const chartField = ref("");
26
24
  const columnDefinitions = ref([]);
27
- const indexes = ref([]);
28
25
  const loading = ref(false);
29
- async function fetchIndexes() {
30
- if (!props.collectionName) return;
31
- indexes.value = await listIndexes(props.collectionName);
32
- }
33
26
  async function fetchInfo() {
34
27
  if (!props.collectionName) return;
35
28
  loading.value = true;
@@ -41,11 +34,11 @@ async function fetchInfo() {
41
34
  page: 1
42
35
  });
43
36
  columnDefinitions.value = schemaFromSamples(samples);
44
- await fetchIndexes();
45
37
  } finally {
46
38
  loading.value = false;
47
39
  }
48
40
  }
41
+ watch(() => props.collectionName, () => chartField.value = "");
49
42
  watch(() => [props.collectionName, props.sampleSize], fetchInfo, { immediate: true });
50
43
  const TYPE_COLORS = {
51
44
  "string": "neutral",
@@ -139,6 +132,7 @@ const KIND_COLORS = {
139
132
  null: "neutral"
140
133
  };
141
134
  const statsSampleSize = ref(500);
135
+ const statsMode = ref("sample");
142
136
  const statsLoading = ref(false);
143
137
  const statsError = ref(null);
144
138
  const statsAnalysis = ref(null);
@@ -147,6 +141,7 @@ async function analyzeFields() {
147
141
  const run = ++statsRun;
148
142
  statsLoading.value = true;
149
143
  statsError.value = null;
144
+ statsMode.value = "sample";
150
145
  try {
151
146
  const { rows } = await sampleDocuments(props.collectionName, statsSampleSize.value);
152
147
  if (run !== statsRun) return;
@@ -160,8 +155,32 @@ async function analyzeFields() {
160
155
  if (run === statsRun) statsLoading.value = false;
161
156
  }
162
157
  }
158
+ const canAnalyzeAll = computed(() => (info.value?.count ?? 0) > 0 && (info.value?.count ?? 0) <= FULL_ANALYSIS_MAX_DOCUMENTS);
159
+ async function analyzeAllDocuments() {
160
+ const run = ++statsRun;
161
+ statsLoading.value = true;
162
+ statsError.value = null;
163
+ statsMode.value = "server";
164
+ try {
165
+ const analysis = await getSchemaAnalysis(props.collectionName, info.value?.count ?? 0);
166
+ if (run !== statsRun) return;
167
+ statsAnalysis.value = statisticsFromSchemaAnalysis(analysis);
168
+ } catch (error) {
169
+ const timedOut = error?.name === "TimeoutError";
170
+ const described = timedOut ? { kind: "retryable", message: t("nuxtUiMongocamp.collectionInfos.statsServerTimeout") } : await describeAggregationError(error);
171
+ if (run !== statsRun) return;
172
+ statsAnalysis.value = null;
173
+ statsError.value = described;
174
+ } finally {
175
+ if (run === statsRun) statsLoading.value = false;
176
+ }
177
+ }
178
+ function retryStats() {
179
+ return statsMode.value === "server" ? analyzeAllDocuments() : analyzeFields();
180
+ }
163
181
  watch(() => props.collectionName, () => {
164
182
  statsRun++;
183
+ statsMode.value = "sample";
165
184
  statsAnalysis.value = null;
166
185
  statsError.value = null;
167
186
  statsLoading.value = false;
@@ -170,6 +189,8 @@ function percent(share) {
170
189
  if (share >= 1) return "100%";
171
190
  return share > 0 && share < 0.01 ? "<1%" : `${Math.round(share * 100)}%`;
172
191
  }
192
+ const PRESENCE_MAX_FIELDS = 20;
193
+ const presenceChart = computed(() => [...statsAnalysis.value?.fields ?? []].sort((a, b) => a.share - b.share || a.path.localeCompare(b.path)).slice(0, PRESENCE_MAX_FIELDS).map((f) => ({ path: shortenLabel(f.path, 32), share: Math.round(f.share * 100) })));
173
194
  const statsColumns = computed(() => [
174
195
  {
175
196
  accessorKey: "path",
@@ -190,7 +211,7 @@ const statsColumns = computed(() => [
190
211
  {
191
212
  id: "present",
192
213
  header: t("nuxtUiMongocamp.collectionInfos.statsColumnPresent"),
193
- cell: ({ row }) => h("span", { title: t("nuxtUiMongocamp.collectionInfos.statsPresentTitle", { present: row.original.present, sampled: statsAnalysis.value?.sampled ?? 0 }) }, percent(row.original.share))
214
+ cell: ({ row }) => h("span", { title: t(statsMode.value === "server" ? "nuxtUiMongocamp.collectionInfos.statsPresentTitleAll" : "nuxtUiMongocamp.collectionInfos.statsPresentTitle", { present: row.original.present, sampled: statsAnalysis.value?.sampled ?? 0 }) }, percent(row.original.share))
194
215
  },
195
216
  {
196
217
  id: "values",
@@ -198,143 +219,10 @@ const statsColumns = computed(() => [
198
219
  cell: ({ row }) => row.original.topValues ? h("span", { class: "text-xs" }, row.original.topValues.map((v) => `${v.value} (${v.count})`).join(", ")) : h("span", { class: "text-dimmed" }, "\u2014")
199
220
  }
200
221
  ]);
201
- const indexRows = computed(
202
- () => indexes.value.map((idx) => ({
203
- name: idx.name,
204
- keys: Object.entries(idx.keys ?? {}).map(([field, direction]) => `${field}: ${direction}`).join(", "),
205
- unique: idx.unique,
206
- text: idx.text,
207
- expire: idx.expire,
208
- sizeKb: Math.round((info.value?.indexSizes?.[idx.name] ?? 0) / 1024)
209
- }))
210
- );
211
- const isCreateIndexModalOpen = ref(false);
212
- const createIndexError = ref("");
213
- const newIndex = ref({ fieldName: "", sortAscending: true, indexType: "standard", duration: "3600s" });
214
- const createIndexSchema = reactive([
215
- {
216
- $formkit: "nuxtUIInput",
217
- name: "fieldName",
218
- label: t("nuxtUiMongocamp.collectionInfos.fieldName"),
219
- validation: "required"
220
- },
221
- {
222
- $formkit: "nuxtUISwitch",
223
- name: "sortAscending",
224
- label: t("nuxtUiMongocamp.collectionInfos.ascending")
225
- },
226
- {
227
- $formkit: "nuxtUISelectMenu",
228
- id: "indexType",
229
- name: "indexType",
230
- label: t("nuxtUiMongocamp.collectionInfos.indexType"),
231
- options: ["standard", "unique", "text", "expiring"],
232
- validation: "required"
233
- },
234
- {
235
- $formkit: "nuxtUIInput",
236
- name: "duration",
237
- label: t("nuxtUiMongocamp.collectionInfos.expireAfter"),
238
- help: t("nuxtUiMongocamp.collectionInfos.expireAfterHelp"),
239
- if: "$get(indexType).value === 'expiring'"
240
- }
241
- ]);
242
- function extractSelectValue(raw) {
243
- if (typeof raw === "object" && raw !== null) {
244
- const obj = raw;
245
- return obj.value ?? obj.label ?? "";
246
- }
247
- return String(raw ?? "");
248
- }
249
- function openCreateIndex() {
250
- createIndexError.value = "";
251
- newIndex.value = { fieldName: "", sortAscending: true, indexType: "standard", duration: "3600s" };
252
- isCreateIndexModalOpen.value = true;
253
- }
254
- async function handleCreateIndex() {
255
- createIndexError.value = "";
256
- const { fieldName, sortAscending } = newIndex.value;
257
- const indexType = extractSelectValue(newIndex.value.indexType);
258
- try {
259
- if (indexType === "unique") {
260
- await createUniqueIndex(props.collectionName, fieldName, sortAscending);
261
- } else if (indexType === "text") {
262
- await createTextIndex(props.collectionName, fieldName);
263
- } else if (indexType === "expiring") {
264
- await createExpiringIndex(props.collectionName, fieldName, newIndex.value.duration);
265
- } else {
266
- await createIndex(props.collectionName, { [fieldName]: sortAscending ? 1 : -1 });
267
- }
268
- isCreateIndexModalOpen.value = false;
269
- await fetchIndexes();
270
- } catch (e) {
271
- createIndexError.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.collectionInfos.errorCreateIndex");
272
- }
273
- }
274
- const isDeleteIndexModalOpen = ref(false);
275
- const deleteIndexError = ref("");
276
- const indexToDelete = ref(void 0);
277
- function confirmDeleteIndex(indexName) {
278
- indexToDelete.value = indexName;
279
- deleteIndexError.value = "";
280
- isDeleteIndexModalOpen.value = true;
222
+ const chartFieldItems = computed(() => columnDefinitions.value.filter((c) => c.columnType !== "object" && c.columnType !== "array").map((c) => ({ label: c.columnKey, value: c.columnKey })));
223
+ async function refreshInfo() {
224
+ info.value = await collectionApi.getCollectionInformation({ collectionName: props.collectionName });
281
225
  }
282
- async function handleDeleteIndex() {
283
- deleteIndexError.value = "";
284
- if (!indexToDelete.value) return;
285
- try {
286
- await deleteIndex(props.collectionName, indexToDelete.value);
287
- isDeleteIndexModalOpen.value = false;
288
- await fetchIndexes();
289
- } catch (e) {
290
- deleteIndexError.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.collectionInfos.errorDeleteIndex");
291
- }
292
- }
293
- const INDEX_FLAG_BADGES = [
294
- { key: "unique", label: "unique", color: "warning" },
295
- { key: "text", label: "text", color: "info" },
296
- { key: "expire", label: "expire", color: "secondary" }
297
- ];
298
- const indexTableColumns = computed(() => [
299
- {
300
- accessorKey: "name",
301
- header: t("nuxtUiMongocamp.collectionInfos.columnIndex")
302
- },
303
- {
304
- accessorKey: "keys",
305
- header: t("nuxtUiMongocamp.collectionInfos.columnKeys"),
306
- cell: ({ row }) => h("span", { class: "font-mono text-xs" }, row.original.keys)
307
- },
308
- {
309
- id: "flags",
310
- header: t("nuxtUiMongocamp.collectionInfos.columnType"),
311
- cell: ({ row }) => {
312
- const badges = INDEX_FLAG_BADGES.filter((flag) => row.original[flag.key]).map((flag) => h(UBadge, { label: flag.label, color: flag.color, variant: "subtle", size: "sm" }));
313
- if (badges.length === 0) {
314
- badges.push(h(UBadge, { label: t("nuxtUiMongocamp.collectionInfos.typeStandard"), color: "neutral", variant: "subtle", size: "sm" }));
315
- }
316
- return h("div", { class: "flex gap-1" }, badges);
317
- }
318
- },
319
- {
320
- accessorKey: "sizeKb",
321
- header: t("nuxtUiMongocamp.collectionInfos.columnSizeKb")
322
- },
323
- {
324
- id: "actions",
325
- header: "",
326
- cell: ({ row }) => row.original.name === "_id_" ? null : h("div", { class: "flex justify-end" }, [
327
- withTooltip(t("nuxtUiMongocamp.collectionInfos.deleteIndexTooltip"), h(UButton, {
328
- "icon": "i-lucide-trash-2",
329
- "color": "error",
330
- "variant": "ghost",
331
- "size": "sm",
332
- "aria-label": t("nuxtUiMongocamp.collectionInfos.deleteIndexTooltip"),
333
- "onClick": () => confirmDeleteIndex(row.original.name)
334
- }))
335
- ])
336
- }
337
- ]);
338
226
  </script>
339
227
 
340
228
  <template>
@@ -396,37 +284,12 @@ const indexTableColumns = computed(() => [
396
284
  </div>
397
285
  </UCard>
398
286
  </div>
399
- <UCard v-if="indexRows.length">
400
- <template #header>
401
- <div class="flex items-center justify-between gap-2">
402
- <div class="flex items-center gap-2">
403
- <UIcon
404
- name="i-lucide-list-tree"
405
- class="size-4 text-(--ui-primary)"
406
- />
407
- <span class="font-semibold">{{ t("nuxtUiMongocamp.collectionInfos.indexes") }}</span>
408
- <UBadge
409
- :label="t('nuxtUiMongocamp.collectionInfos.indexesCount', { count: indexRows.length })"
410
- variant="subtle"
411
- color="neutral"
412
- size="sm"
413
- />
414
- </div>
415
- <UButton
416
- icon="i-lucide-plus"
417
- :label="t('nuxtUiMongocamp.collectionInfos.createIndex')"
418
- color="neutral"
419
- variant="ghost"
420
- size="sm"
421
- @click="openCreateIndex"
422
- />
423
- </div>
424
- </template>
425
- <UTable
426
- :data="indexRows"
427
- :columns="indexTableColumns"
428
- />
429
- </UCard>
287
+ <MongocampIndexes
288
+ v-if="!loading"
289
+ :collection-name="collectionName"
290
+ :fields="columnDefinitions.map((c) => c.columnKey)"
291
+ @changed="refreshInfo"
292
+ />
430
293
 
431
294
  <UCard v-if="schemaRows.length">
432
295
  <template #header>
@@ -470,6 +333,32 @@ const indexTableColumns = computed(() => [
470
333
  />
471
334
  </UCard>
472
335
 
336
+ <UCard v-if="chartFieldItems.length > 0">
337
+ <template #header>
338
+ <div class="flex items-center gap-2">
339
+ <UIcon
340
+ name="i-lucide-chart-column"
341
+ class="size-4 text-(--ui-primary)"
342
+ />
343
+ <span class="font-semibold">{{ t("nuxtUiMongocamp.collectionInfos.chartsTitle") }}</span>
344
+ </div>
345
+ </template>
346
+ <div class="flex flex-col gap-4">
347
+ <USelect
348
+ v-model="chartField"
349
+ :items="chartFieldItems"
350
+ :placeholder="t('nuxtUiMongocamp.collectionInfos.chartsPick')"
351
+ class="w-72"
352
+ :aria-label="t('nuxtUiMongocamp.collectionInfos.chartsField')"
353
+ />
354
+ <MongocampCollectionCharts
355
+ v-if="chartField"
356
+ :collection-name="collectionName"
357
+ :field="chartField"
358
+ />
359
+ </div>
360
+ </UCard>
361
+
473
362
  <UCard v-if="info && !loading">
474
363
  <template #header>
475
364
  <div class="flex flex-wrap items-center justify-between gap-2">
@@ -481,7 +370,7 @@ const indexTableColumns = computed(() => [
481
370
  <span class="font-semibold">{{ t("nuxtUiMongocamp.collectionInfos.statsTitle") }}</span>
482
371
  <UBadge
483
372
  v-if="statsAnalysis"
484
- :label="t('nuxtUiMongocamp.collectionInfos.statsSampled', { sampled: statsAnalysis.sampled, total: info.count })"
373
+ :label="statsMode === 'server' ? t('nuxtUiMongocamp.collectionInfos.statsAnalysed', { count: statsAnalysis.sampled }) : t('nuxtUiMongocamp.collectionInfos.statsSampled', { sampled: statsAnalysis.sampled, total: info.count })"
485
374
  variant="subtle"
486
375
  color="neutral"
487
376
  size="sm"
@@ -501,9 +390,21 @@ const indexTableColumns = computed(() => [
501
390
  color="neutral"
502
391
  variant="subtle"
503
392
  size="sm"
504
- :loading="statsLoading"
393
+ :loading="statsLoading && statsMode === 'sample'"
394
+ :disabled="statsLoading"
505
395
  @click="analyzeFields"
506
396
  />
397
+ <UButton
398
+ icon="i-lucide-scan-search"
399
+ :label="t('nuxtUiMongocamp.collectionInfos.statsAnalyzeAll')"
400
+ :title="canAnalyzeAll || (info.count ?? 0) === 0 ? t('nuxtUiMongocamp.collectionInfos.statsAnalyzeAllHint') : t('nuxtUiMongocamp.collectionInfos.statsAnalyzeAllTooLarge', { max: FULL_ANALYSIS_MAX_DOCUMENTS })"
401
+ color="neutral"
402
+ variant="outline"
403
+ size="sm"
404
+ :loading="statsLoading && statsMode === 'server'"
405
+ :disabled="!canAnalyzeAll || statsLoading"
406
+ @click="analyzeAllDocuments"
407
+ />
507
408
  </div>
508
409
  </div>
509
410
  </template>
@@ -537,13 +438,13 @@ const indexTableColumns = computed(() => [
537
438
  color="error"
538
439
  variant="subtle"
539
440
  icon="i-lucide-refresh-cw"
540
- @click="analyzeFields"
441
+ @click="retryStats"
541
442
  />
542
443
  </template>
543
444
  </UAlert>
544
445
  <template v-if="statsAnalysis">
545
446
  <p class="mb-2 text-xs text-dimmed">
546
- {{ t("nuxtUiMongocamp.collectionInfos.statsNote") }}
447
+ {{ statsMode === "server" ? t("nuxtUiMongocamp.collectionInfos.statsNoteAll", { count: statsAnalysis.sampled }) : t("nuxtUiMongocamp.collectionInfos.statsNote") }}
547
448
  <template v-if="statsAnalysis.truncated">
548
449
  {{ t("nuxtUiMongocamp.collectionInfos.statsTruncated", { count: statsAnalysis.fields.length }) }}
549
450
  </template>
@@ -556,59 +457,26 @@ const indexTableColumns = computed(() => [
556
457
  <MongocampEmptyState :title="t('nuxtUiMongocamp.collectionInfos.statsEmpty')" />
557
458
  </template>
558
459
  </UTable>
559
- </template>
560
- </UCard>
561
-
562
- <UModal
563
- v-model:open="isCreateIndexModalOpen"
564
- :title="t('nuxtUiMongocamp.collectionInfos.createIndexTitle')"
565
- >
566
- <template #body>
567
- <FUDataEdit
568
- :data="newIndex"
569
- :schema="createIndexSchema"
570
- :submit-label="t('nuxtUiMongocamp.collectionInfos.createIndex')"
571
- submit-icon="i-lucide-plus"
572
- @data-saved="handleCreateIndex"
573
- />
574
- <p
575
- v-if="createIndexError"
576
- class="mt-2 text-sm text-error-500"
460
+ <details
461
+ v-if="presenceChart.length > 1"
462
+ class="mt-3 text-sm"
463
+ data-testid="presence-chart"
577
464
  >
578
- {{ createIndexError }}
579
- </p>
580
- </template>
581
- </UModal>
582
-
583
- <UModal
584
- v-model:open="isDeleteIndexModalOpen"
585
- :title="t('nuxtUiMongocamp.collectionInfos.deleteIndexTitle')"
586
- :ui="{ footer: 'justify-end' }"
587
- >
588
- <template #body>
589
- <p>{{ t("nuxtUiMongocamp.collectionInfos.confirmDeleteIndex", { indexName: indexToDelete }) }}</p>
590
- <p
591
- v-if="deleteIndexError"
592
- class="mt-2 text-sm text-error-500"
593
- >
594
- {{ deleteIndexError }}
595
- </p>
596
- </template>
597
- <template #footer>
598
- <UButton
599
- :label="t('nuxtUiMongocamp.common.cancel')"
600
- color="neutral"
601
- variant="ghost"
602
- @click="isDeleteIndexModalOpen = false"
603
- />
604
- <UButton
605
- :label="t('nuxtUiMongocamp.common.delete')"
606
- color="error"
607
- icon="i-lucide-trash-2"
608
- @click="handleDeleteIndex"
609
- />
465
+ <summary class="cursor-pointer text-dimmed">
466
+ {{ t("nuxtUiMongocamp.collectionInfos.presenceSummary") }}
467
+ </summary>
468
+ <MongocampChart
469
+ class="mt-2"
470
+ :data="presenceChart"
471
+ index="path"
472
+ :categories="[{ key: 'share', label: t('nuxtUiMongocamp.collectionInfos.presenceLabel') }]"
473
+ :format="(v) => `${v}%`"
474
+ :chart-label="t('nuxtUiMongocamp.collectionInfos.presenceLabel')"
475
+ :chart-description="t('nuxtUiMongocamp.collectionInfos.presenceDescription', { count: presenceChart.length })"
476
+ />
477
+ </details>
610
478
  </template>
611
- </UModal>
479
+ </UCard>
612
480
 
613
481
  <UModal
614
482
  v-model:open="isSchemaOpen"
@@ -0,0 +1,22 @@
1
+ type __VLS_Props = {
2
+ source: string;
3
+ };
4
+ type __VLS_ModelProps = {
5
+ 'open'?: boolean;
6
+ };
7
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ "update:open": (value: boolean) => any;
10
+ done: (payload: {
11
+ source: string;
12
+ target: string;
13
+ }) => any;
14
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
16
+ onDone?: ((payload: {
17
+ source: string;
18
+ target: string;
19
+ }) => any) | undefined;
20
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
+ declare const _default: typeof __VLS_export;
22
+ export default _default;
@@ -0,0 +1,116 @@
1
+ <script setup>
2
+ import { computed, ref, watch } from "vue";
3
+ import { useI18n, useMongocampError } from "#imports";
4
+ import { useMongocampCollectionCopy } from "../composables/useMongocampCollectionCopy";
5
+ import { MAX_COLLECTION_NAME_LENGTH, validateTargetName } from "../utils/collectionCopy";
6
+ const props = defineProps({
7
+ source: { type: String, required: true }
8
+ });
9
+ const emit = defineEmits(["done"]);
10
+ const isOpen = defineModel("open", { type: Boolean, ...{ default: false } });
11
+ const { t } = useI18n();
12
+ const { describeServerError } = useMongocampError();
13
+ const { renameCollection, listCollectionNames } = useMongocampCollectionCopy();
14
+ const target = ref("");
15
+ const existing = ref([]);
16
+ const renaming = ref(false);
17
+ const errorText = ref("");
18
+ let opened = 0;
19
+ watch(isOpen, async (open) => {
20
+ if (!open) return;
21
+ const mine = ++opened;
22
+ target.value = "";
23
+ errorText.value = "";
24
+ renaming.value = false;
25
+ try {
26
+ const names = await listCollectionNames();
27
+ if (mine === opened) existing.value = names;
28
+ } catch {
29
+ if (mine === opened) existing.value = [];
30
+ }
31
+ }, { immediate: true });
32
+ const problem = computed(() => target.value === "" ? void 0 : validateTargetName(target.value, props.source, existing.value));
33
+ const problemText = computed(() => {
34
+ const key = { "empty": "problemEmpty", "too-long": "problemTooLong", "invalid-characters": "problemInvalid", "protected": "problemProtected", "same-as-source": "problemSame", "exists": "problemExists" }[problem.value ?? "empty"];
35
+ return problem.value ? t(`nuxtUiMongocamp.collectionCopy.${key}`, { max: MAX_COLLECTION_NAME_LENGTH }) : "";
36
+ });
37
+ const targetName = computed(() => target.value.trim());
38
+ const canRename = computed(() => targetName.value !== "" && problem.value === void 0 && !renaming.value);
39
+ async function rename() {
40
+ if (!canRename.value) return;
41
+ renaming.value = true;
42
+ errorText.value = "";
43
+ try {
44
+ const result = await renameCollection(props.source, targetName.value);
45
+ if (result.refused === "target-exists") {
46
+ existing.value = [...existing.value, targetName.value];
47
+ errorText.value = t("nuxtUiMongocamp.collectionRename.refusedExists", { target: targetName.value });
48
+ return;
49
+ }
50
+ emit("done", { source: props.source, target: result.target });
51
+ isOpen.value = false;
52
+ } catch (e) {
53
+ errorText.value = (await describeServerError(e, "nuxtUiMongocamp.collectionRename.failedGeneric")).message;
54
+ } finally {
55
+ renaming.value = false;
56
+ }
57
+ }
58
+ </script>
59
+
60
+ <template>
61
+ <UModal
62
+ v-model:open="isOpen"
63
+ :title="t('nuxtUiMongocamp.collectionRename.title', { source })"
64
+ :dismissible="!renaming"
65
+ :ui="{ footer: 'justify-end' }"
66
+ >
67
+ <template #body>
68
+ <div class="flex flex-col gap-4">
69
+ <UAlert
70
+ color="warning"
71
+ variant="subtle"
72
+ icon="i-lucide-triangle-alert"
73
+ :description="t('nuxtUiMongocamp.collectionRename.grantsWarning')"
74
+ data-test="rename-grants-warning"
75
+ />
76
+ <UFormField
77
+ :label="t('nuxtUiMongocamp.collectionRename.targetLabel')"
78
+ :help="t('nuxtUiMongocamp.collectionCopy.targetHelp')"
79
+ :error="problemText || void 0"
80
+ >
81
+ <UInput
82
+ v-model="target"
83
+ class="w-full"
84
+ autocomplete="off"
85
+ :disabled="renaming"
86
+ :aria-label="t('nuxtUiMongocamp.collectionRename.targetLabel')"
87
+ @keydown.enter.prevent="rename"
88
+ />
89
+ </UFormField>
90
+ <p
91
+ v-if="errorText"
92
+ class="text-sm text-error"
93
+ role="alert"
94
+ >
95
+ {{ errorText }}
96
+ </p>
97
+ </div>
98
+ </template>
99
+ <template #footer>
100
+ <UButton
101
+ :label="t('nuxtUiMongocamp.common.cancel')"
102
+ color="neutral"
103
+ variant="ghost"
104
+ :disabled="renaming"
105
+ @click="isOpen = false"
106
+ />
107
+ <UButton
108
+ :label="t('nuxtUiMongocamp.collectionRename.confirm')"
109
+ icon="i-lucide-pencil"
110
+ :loading="renaming"
111
+ :disabled="!canRename"
112
+ @click="rename"
113
+ />
114
+ </template>
115
+ </UModal>
116
+ </template>
@@ -0,0 +1,22 @@
1
+ type __VLS_Props = {
2
+ source: string;
3
+ };
4
+ type __VLS_ModelProps = {
5
+ 'open'?: boolean;
6
+ };
7
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ "update:open": (value: boolean) => any;
10
+ done: (payload: {
11
+ source: string;
12
+ target: string;
13
+ }) => any;
14
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
16
+ onDone?: ((payload: {
17
+ source: string;
18
+ target: string;
19
+ }) => any) | undefined;
20
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
+ declare const _default: typeof __VLS_export;
22
+ export default _default;