@sfxcode/nuxt-ui-mongocamp 1.3.4 → 1.4.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 (212) hide show
  1. package/README.md +4 -0
  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.vue +302 -3
  6. package/dist/runtime/components/MongocampAggregationChart.d.vue.ts +6 -0
  7. package/dist/runtime/components/MongocampAggregationChart.vue +93 -0
  8. package/dist/runtime/components/MongocampAggregationChart.vue.d.ts +6 -0
  9. package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +9 -0
  10. package/dist/runtime/components/MongocampAggregationStagePreview.vue +148 -0
  11. package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +9 -0
  12. package/dist/runtime/components/MongocampBucketFiles.vue +169 -48
  13. package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +19 -0
  14. package/dist/runtime/components/MongocampBulkDelete.vue +118 -23
  15. package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +19 -0
  16. package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +6 -0
  17. package/dist/runtime/components/MongocampBulkEdit.vue +23 -2
  18. package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +6 -0
  19. package/dist/runtime/components/MongocampChart.d.vue.ts +29 -0
  20. package/dist/runtime/components/MongocampChart.vue +129 -0
  21. package/dist/runtime/components/MongocampChart.vue.d.ts +29 -0
  22. package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +15 -0
  23. package/dist/runtime/components/MongocampCollectionCharts.vue +199 -0
  24. package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +15 -0
  25. package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +23 -0
  26. package/dist/runtime/components/MongocampCollectionCopy.vue +445 -0
  27. package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +23 -0
  28. package/dist/runtime/components/MongocampCollectionData.d.vue.ts +4 -0
  29. package/dist/runtime/components/MongocampCollectionData.vue +343 -146
  30. package/dist/runtime/components/MongocampCollectionData.vue.d.ts +4 -0
  31. package/dist/runtime/components/MongocampCollectionInfos.vue +106 -238
  32. package/dist/runtime/components/MongocampCollections.vue +62 -0
  33. package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +40 -0
  34. package/dist/runtime/components/MongocampCommandPalette.vue +135 -0
  35. package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +40 -0
  36. package/dist/runtime/components/MongocampConfirmByName.vue +2 -2
  37. package/dist/runtime/components/MongocampDashboard.d.vue.ts +3 -1
  38. package/dist/runtime/components/MongocampDashboard.vue +21 -2
  39. package/dist/runtime/components/MongocampDashboard.vue.d.ts +3 -1
  40. package/dist/runtime/components/MongocampDatabases.vue +22 -0
  41. package/dist/runtime/components/MongocampDocumentCompare.d.vue.ts +20 -0
  42. package/dist/runtime/components/MongocampDocumentCompare.vue +146 -0
  43. package/dist/runtime/components/MongocampDocumentCompare.vue.d.ts +20 -0
  44. package/dist/runtime/components/MongocampDocumentView.d.vue.ts +22 -0
  45. package/dist/runtime/components/MongocampDocumentView.vue +202 -0
  46. package/dist/runtime/components/MongocampDocumentView.vue.d.ts +22 -0
  47. package/dist/runtime/components/MongocampErrorAlert.vue +12 -16
  48. package/dist/runtime/components/MongocampExportAll.d.vue.ts +18 -0
  49. package/dist/runtime/components/MongocampExportAll.vue +204 -0
  50. package/dist/runtime/components/MongocampExportAll.vue.d.ts +18 -0
  51. package/dist/runtime/components/MongocampFilePreview.d.vue.ts +16 -0
  52. package/dist/runtime/components/MongocampFilePreview.vue +162 -0
  53. package/dist/runtime/components/MongocampFilePreview.vue.d.ts +16 -0
  54. package/dist/runtime/components/MongocampFilterBuilder.vue +11 -0
  55. package/dist/runtime/components/MongocampImport.vue +2 -10
  56. package/dist/runtime/components/MongocampIndexes.d.vue.ts +18 -0
  57. package/dist/runtime/components/MongocampIndexes.vue +455 -0
  58. package/dist/runtime/components/MongocampIndexes.vue.d.ts +18 -0
  59. package/dist/runtime/components/MongocampJobs.d.vue.ts +6 -1
  60. package/dist/runtime/components/MongocampJobs.vue +24 -4
  61. package/dist/runtime/components/MongocampJobs.vue.d.ts +6 -1
  62. package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +12 -0
  63. package/dist/runtime/components/MongocampPermissionMatrix.vue +301 -0
  64. package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +12 -0
  65. package/dist/runtime/components/MongocampQueryBar.d.vue.ts +26 -0
  66. package/dist/runtime/components/MongocampQueryBar.vue +398 -0
  67. package/dist/runtime/components/MongocampQueryBar.vue.d.ts +26 -0
  68. package/dist/runtime/components/MongocampRoleGrants.vue +2 -2
  69. package/dist/runtime/components/MongocampRoles.vue +3 -3
  70. package/dist/runtime/components/MongocampServerOverview.d.vue.ts +20 -0
  71. package/dist/runtime/components/MongocampServerOverview.vue +443 -0
  72. package/dist/runtime/components/MongocampServerOverview.vue.d.ts +20 -0
  73. package/dist/runtime/components/MongocampSettings.d.vue.ts +25 -1
  74. package/dist/runtime/components/MongocampSettings.vue +70 -9
  75. package/dist/runtime/components/MongocampSettings.vue.d.ts +25 -1
  76. package/dist/runtime/components/MongocampUsers.vue +3 -3
  77. package/dist/runtime/composables/useMongocampAdmin.d.ts +2 -1
  78. package/dist/runtime/composables/useMongocampAdmin.js +7 -15
  79. package/dist/runtime/composables/useMongocampAggregation.d.ts +12 -1
  80. package/dist/runtime/composables/useMongocampAggregation.js +33 -25
  81. package/dist/runtime/composables/useMongocampAutoRefresh.d.ts +26 -0
  82. package/dist/runtime/composables/useMongocampAutoRefresh.js +78 -0
  83. package/dist/runtime/composables/useMongocampBucket.d.ts +13 -1
  84. package/dist/runtime/composables/useMongocampBucket.js +34 -0
  85. package/dist/runtime/composables/useMongocampClientApi.d.ts +1 -1
  86. package/dist/runtime/composables/useMongocampClientApi.js +2 -1
  87. package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +85 -0
  88. package/dist/runtime/composables/useMongocampCollectionCopy.js +105 -0
  89. package/dist/runtime/composables/useMongocampCollectionStats.d.ts +10 -0
  90. package/dist/runtime/composables/useMongocampCollectionStats.js +17 -0
  91. package/dist/runtime/composables/useMongocampError.d.ts +2 -1
  92. package/dist/runtime/composables/useMongocampError.js +16 -1
  93. package/dist/runtime/composables/useMongocampExportAll.d.ts +47 -0
  94. package/dist/runtime/composables/useMongocampExportAll.js +27 -0
  95. package/dist/runtime/composables/useMongocampExtendedJson.d.ts +5 -1
  96. package/dist/runtime/composables/useMongocampExtendedJson.js +12 -6
  97. package/dist/runtime/composables/useMongocampFetchAll.d.ts +25 -0
  98. package/dist/runtime/composables/useMongocampFetchAll.js +27 -0
  99. package/dist/runtime/composables/useMongocampPermissions.d.ts +14 -0
  100. package/dist/runtime/composables/useMongocampPermissions.js +21 -0
  101. package/dist/runtime/composables/useMongocampPersistedState.d.ts +15 -0
  102. package/dist/runtime/composables/useMongocampPersistedState.js +21 -0
  103. package/dist/runtime/composables/useMongocampProxyApi.d.ts +1 -1
  104. package/dist/runtime/composables/useMongocampProxyApi.js +2 -1
  105. package/dist/runtime/composables/useMongocampQuery.d.ts +50 -2
  106. package/dist/runtime/composables/useMongocampQuery.js +72 -1
  107. package/dist/runtime/composables/useMongocampSavedPipelines.d.ts +25 -0
  108. package/dist/runtime/composables/useMongocampSavedPipelines.js +23 -0
  109. package/dist/runtime/composables/useMongocampSavedQueries.d.ts +37 -0
  110. package/dist/runtime/composables/useMongocampSavedQueries.js +50 -0
  111. package/dist/runtime/composables/useMongocampServerOverview.d.ts +42 -0
  112. package/dist/runtime/composables/useMongocampServerOverview.js +61 -0
  113. package/dist/runtime/composables/useMongocampSession.d.ts +3 -2
  114. package/dist/runtime/composables/useMongocampSession.js +14 -22
  115. package/dist/runtime/composables/useMongocampSystem.d.ts +7 -2
  116. package/dist/runtime/composables/useMongocampSystem.js +6 -2
  117. package/dist/runtime/locales/de.json +495 -10
  118. package/dist/runtime/locales/en.json +495 -10
  119. package/dist/runtime/plugin.js +8 -5
  120. package/dist/runtime/utils/aggregationPipeline.d.ts +5 -4
  121. package/dist/runtime/utils/aggregationPipeline.js +23 -9
  122. package/dist/runtime/utils/aggregationPreview.d.ts +13 -0
  123. package/dist/runtime/utils/aggregationPreview.js +10 -0
  124. package/dist/runtime/utils/aggregationResult.d.ts +5 -0
  125. package/dist/runtime/utils/aggregationResult.js +4 -0
  126. package/dist/runtime/utils/aggregationTemplates.d.ts +34 -0
  127. package/dist/runtime/utils/aggregationTemplates.js +47 -0
  128. package/dist/runtime/utils/analyzeSamples.d.ts +1 -0
  129. package/dist/runtime/utils/analyzeSamples.js +1 -1
  130. package/dist/runtime/utils/autoRefresh.d.ts +14 -0
  131. package/dist/runtime/utils/autoRefresh.js +15 -0
  132. package/dist/runtime/utils/bigIntJson.d.ts +15 -0
  133. package/dist/runtime/utils/bigIntJson.js +55 -0
  134. package/dist/runtime/utils/bulkDelete.d.ts +9 -1
  135. package/dist/runtime/utils/bulkDelete.js +15 -3
  136. package/dist/runtime/utils/bulkEdit.d.ts +6 -0
  137. package/dist/runtime/utils/bulkEdit.js +7 -0
  138. package/dist/runtime/utils/chartData.d.ts +11 -0
  139. package/dist/runtime/utils/chartData.js +9 -0
  140. package/dist/runtime/utils/collectionChart.d.ts +36 -0
  141. package/dist/runtime/utils/collectionChart.js +73 -0
  142. package/dist/runtime/utils/collectionCopy.d.ts +26 -0
  143. package/dist/runtime/utils/collectionCopy.js +38 -0
  144. package/dist/runtime/utils/collectionStats.d.ts +31 -0
  145. package/dist/runtime/utils/collectionStats.js +42 -0
  146. package/dist/runtime/utils/commandPalette.d.ts +48 -0
  147. package/dist/runtime/utils/commandPalette.js +39 -0
  148. package/dist/runtime/utils/createProxyMongocampApis.d.ts +2 -2
  149. package/dist/runtime/utils/createProxyMongocampApis.js +2 -2
  150. package/dist/runtime/utils/documentCompare.d.ts +31 -0
  151. package/dist/runtime/utils/documentCompare.js +70 -0
  152. package/dist/runtime/utils/documentDiff.d.ts +19 -0
  153. package/dist/runtime/utils/documentDiff.js +71 -0
  154. package/dist/runtime/utils/documentPaths.d.ts +44 -0
  155. package/dist/runtime/utils/documentPaths.js +144 -0
  156. package/dist/runtime/utils/documentTree.d.ts +40 -0
  157. package/dist/runtime/utils/documentTree.js +94 -0
  158. package/dist/runtime/utils/exportDocuments.d.ts +35 -0
  159. package/dist/runtime/utils/exportDocuments.js +54 -0
  160. package/dist/runtime/utils/exportRows.js +1 -1
  161. package/dist/runtime/utils/filePreview.d.ts +27 -0
  162. package/dist/runtime/utils/filePreview.js +50 -0
  163. package/dist/runtime/utils/filterBuilder.d.ts +6 -1
  164. package/dist/runtime/utils/filterBuilder.js +6 -5
  165. package/dist/runtime/utils/formatBytes.d.ts +2 -0
  166. package/dist/runtime/utils/formatBytes.js +11 -0
  167. package/dist/runtime/utils/grantMatching.d.ts +8 -0
  168. package/dist/runtime/utils/grantMatching.js +15 -0
  169. package/dist/runtime/utils/importRows.js +12 -2
  170. package/dist/runtime/utils/indexCopy.d.ts +26 -0
  171. package/dist/runtime/utils/indexCopy.js +22 -0
  172. package/dist/runtime/utils/indexForm.d.ts +69 -0
  173. package/dist/runtime/utils/indexForm.js +63 -0
  174. package/dist/runtime/utils/limitedMap.d.ts +17 -0
  175. package/dist/runtime/utils/limitedMap.js +19 -0
  176. package/dist/runtime/utils/luceneExpression.d.ts +15 -0
  177. package/dist/runtime/utils/luceneExpression.js +74 -0
  178. package/dist/runtime/utils/pagedFetch.d.ts +46 -0
  179. package/dist/runtime/utils/pagedFetch.js +58 -0
  180. package/dist/runtime/utils/paginationHeaders.d.ts +4 -0
  181. package/dist/runtime/utils/paginationHeaders.js +4 -0
  182. package/dist/runtime/utils/permissionDenied.d.ts +10 -0
  183. package/dist/runtime/utils/permissionDenied.js +23 -0
  184. package/dist/runtime/utils/permissionMatrix.d.ts +55 -0
  185. package/dist/runtime/utils/permissionMatrix.js +85 -0
  186. package/dist/runtime/utils/persistedState.d.ts +25 -0
  187. package/dist/runtime/utils/persistedState.js +47 -0
  188. package/dist/runtime/utils/queryState.d.ts +45 -0
  189. package/dist/runtime/utils/queryState.js +75 -0
  190. package/dist/runtime/utils/requestLimits.d.ts +2 -0
  191. package/dist/runtime/utils/requestLimits.js +4 -0
  192. package/dist/runtime/utils/resultChart.d.ts +32 -0
  193. package/dist/runtime/utils/resultChart.js +59 -0
  194. package/dist/runtime/utils/savedPipelines.d.ts +22 -0
  195. package/dist/runtime/utils/savedPipelines.js +46 -0
  196. package/dist/runtime/utils/savedQueries.d.ts +60 -0
  197. package/dist/runtime/utils/savedQueries.js +143 -0
  198. package/dist/runtime/utils/schemaAnalysis.d.ts +16 -0
  199. package/dist/runtime/utils/schemaAnalysis.js +57 -0
  200. package/dist/runtime/utils/serverError.d.ts +19 -0
  201. package/dist/runtime/utils/serverError.js +19 -0
  202. package/dist/runtime/utils/serverOverview.d.ts +47 -0
  203. package/dist/runtime/utils/serverOverview.js +40 -0
  204. package/dist/runtime/utils/sessionGuard.d.ts +3 -0
  205. package/dist/runtime/utils/sessionGuard.js +18 -1
  206. package/package.json +13 -12
  207. package/dist/runtime/utils/failureKind.d.ts +0 -3
  208. package/dist/runtime/utils/failureKind.js +0 -11
  209. package/dist/runtime/utils/serverProbe.d.ts +0 -10
  210. package/dist/runtime/utils/serverProbe.js +0 -25
  211. package/dist/runtime/utils/throttled.d.ts +0 -6
  212. package/dist/runtime/utils/throttled.js +0 -16
@@ -0,0 +1,202 @@
1
+ <script setup>
2
+ import { computed, ref, watch } from "vue";
3
+ import { useI18n, useToast } from "#imports";
4
+ import { allContainerPaths, buildDocumentTree, defaultExpanded, nodeDisplay, visibleNodes } from "../utils/documentTree";
5
+ import { valueToJson } from "../utils/exportDocuments";
6
+ const props = defineProps({
7
+ document: { type: null, required: true }
8
+ });
9
+ const emit = defineEmits(["copy"]);
10
+ const mode = defineModel("mode", { type: String, ...{ default: "tree" } });
11
+ const { t } = useI18n();
12
+ const toast = useToast();
13
+ const tree = computed(() => buildDocumentTree(props.document ?? {}));
14
+ const expanded = ref(/* @__PURE__ */ new Set());
15
+ watch(tree, (value) => expanded.value = defaultExpanded(value), { immediate: true });
16
+ const rows = computed(() => visibleNodes(tree.value, expanded.value));
17
+ const hasContainers = computed(() => allContainerPaths(tree.value).size > 0);
18
+ const allOpen = computed(() => hasContainers.value && expanded.value.size >= allContainerPaths(tree.value).size);
19
+ const isLarge = computed(() => tree.value.total > 200);
20
+ const jsonText = computed(() => props.document ? valueToJson(props.document, true) : "");
21
+ const BADGE_COLORS = {
22
+ null: "neutral",
23
+ string: "neutral",
24
+ boolean: "success",
25
+ number: "warning",
26
+ int: "warning",
27
+ long: "warning",
28
+ double: "warning",
29
+ decimal: "warning",
30
+ objectId: "info",
31
+ date: "info",
32
+ array: "primary",
33
+ object: "secondary"
34
+ };
35
+ function toggle(node) {
36
+ const next = new Set(expanded.value);
37
+ if (!next.delete(node.path)) next.add(node.path);
38
+ expanded.value = next;
39
+ }
40
+ function toggleAll() {
41
+ expanded.value = allOpen.value ? /* @__PURE__ */ new Set() : allContainerPaths(tree.value);
42
+ }
43
+ async function copy(kind, text) {
44
+ try {
45
+ await navigator.clipboard.writeText(text);
46
+ toast.add({ title: t("nuxtUiMongocamp.documentView.copied"), color: "success" });
47
+ } catch {
48
+ toast.add({ title: t("nuxtUiMongocamp.documentView.copyFailed"), color: "error" });
49
+ }
50
+ emit("copy", { kind, text });
51
+ }
52
+ function valueText(node) {
53
+ return node.children || node.type === "array" || node.type === "object" ? valueToJson(node.value, true) : nodeDisplay(node).text;
54
+ }
55
+ const modeItems = computed(() => [
56
+ { label: t("nuxtUiMongocamp.documentView.modeTree"), value: "tree", icon: "i-lucide-list-tree" },
57
+ { label: t("nuxtUiMongocamp.documentView.modeJson"), value: "json", icon: "i-lucide-braces" }
58
+ ]);
59
+ </script>
60
+
61
+ <template>
62
+ <div class="flex flex-col gap-3">
63
+ <div class="flex flex-wrap items-center justify-between gap-2">
64
+ <div
65
+ class="inline-flex rounded-md border border-default p-0.5"
66
+ role="group"
67
+ :aria-label="t('nuxtUiMongocamp.documentView.modeLabel')"
68
+ >
69
+ <UButton
70
+ v-for="item in modeItems"
71
+ :key="item.value"
72
+ :label="item.label"
73
+ :icon="item.icon"
74
+ size="xs"
75
+ color="neutral"
76
+ :variant="mode === item.value ? 'subtle' : 'ghost'"
77
+ :aria-pressed="mode === item.value"
78
+ @click="mode = item.value"
79
+ />
80
+ </div>
81
+ <div class="flex items-center gap-1">
82
+ <UButton
83
+ v-if="mode === 'tree' && hasContainers"
84
+ :label="allOpen ? t('nuxtUiMongocamp.documentView.collapseAll') : t('nuxtUiMongocamp.documentView.expandAll')"
85
+ :icon="allOpen ? 'i-lucide-chevrons-down-up' : 'i-lucide-chevrons-up-down'"
86
+ size="xs"
87
+ color="neutral"
88
+ variant="ghost"
89
+ @click="toggleAll"
90
+ />
91
+ <UButton
92
+ :label="t('nuxtUiMongocamp.documentView.copyDocument')"
93
+ icon="i-lucide-copy"
94
+ size="xs"
95
+ color="neutral"
96
+ variant="ghost"
97
+ :disabled="!document"
98
+ @click="copy('document', jsonText)"
99
+ />
100
+ </div>
101
+ </div>
102
+
103
+ <p
104
+ v-if="!document"
105
+ class="text-sm text-dimmed"
106
+ >
107
+ {{ t("nuxtUiMongocamp.documentView.empty") }}
108
+ </p>
109
+
110
+ <pre
111
+ v-else-if="mode === 'json'"
112
+ class="max-h-[70vh] overflow-auto rounded-md bg-elevated p-3 text-xs whitespace-pre-wrap break-all"
113
+ data-test="document-json"
114
+ >{{ jsonText }}</pre>
115
+
116
+ <template v-else>
117
+ <p
118
+ v-if="isLarge"
119
+ class="text-xs text-dimmed"
120
+ >
121
+ {{ t("nuxtUiMongocamp.documentView.collapsedNote") }}
122
+ </p>
123
+ <ul
124
+ class="flex flex-col text-sm"
125
+ role="tree"
126
+ data-test="document-tree"
127
+ >
128
+ <li
129
+ v-for="node in rows"
130
+ :key="node.path"
131
+ class="group flex items-start gap-1 rounded px-1 py-0.5 hover:bg-elevated"
132
+ :style="{ paddingLeft: `${node.depth * 16 + 4}px` }"
133
+ role="treeitem"
134
+ :aria-expanded="node.children ? expanded.has(node.path) : void 0"
135
+ :data-path="node.path"
136
+ >
137
+ <button
138
+ v-if="node.children"
139
+ type="button"
140
+ class="inline-flex size-6 shrink-0 items-center justify-center rounded text-muted hover:bg-accented focus-visible:outline-2 focus-visible:outline-primary"
141
+ :aria-label="expanded.has(node.path) ? t('nuxtUiMongocamp.documentView.collapse') : t('nuxtUiMongocamp.documentView.expand')"
142
+ @click="toggle(node)"
143
+ >
144
+ <UIcon
145
+ :name="expanded.has(node.path) ? 'i-lucide-chevron-down' : 'i-lucide-chevron-right'"
146
+ class="size-4"
147
+ />
148
+ </button>
149
+ <span
150
+ v-else
151
+ class="inline-block size-6 shrink-0"
152
+ />
153
+ <span class="shrink-0 font-medium">{{ node.key }}</span>
154
+ <UBadge
155
+ :label="node.type"
156
+ :color="BADGE_COLORS[node.type]"
157
+ variant="subtle"
158
+ size="sm"
159
+ class="shrink-0"
160
+ :title="t('nuxtUiMongocamp.documentView.typeLabel', { type: node.type })"
161
+ />
162
+ <span
163
+ class="min-w-0 break-all text-dimmed"
164
+ :title="nodeDisplay(node).title"
165
+ >{{ nodeDisplay(node).text }}</span>
166
+ <span class="ml-auto flex shrink-0 gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100">
167
+ <button
168
+ type="button"
169
+ class="inline-flex size-6 items-center justify-center rounded text-muted hover:bg-accented focus-visible:outline-2 focus-visible:outline-primary"
170
+ :aria-label="t('nuxtUiMongocamp.documentView.copyPath')"
171
+ :title="t('nuxtUiMongocamp.documentView.copyPath')"
172
+ @click="copy('path', node.path)"
173
+ >
174
+ <UIcon
175
+ name="i-lucide-route"
176
+ class="size-4"
177
+ />
178
+ </button>
179
+ <button
180
+ type="button"
181
+ class="inline-flex size-6 items-center justify-center rounded text-muted hover:bg-accented focus-visible:outline-2 focus-visible:outline-primary"
182
+ :aria-label="t('nuxtUiMongocamp.documentView.copyValue')"
183
+ :title="t('nuxtUiMongocamp.documentView.copyValue')"
184
+ @click="copy('value', valueText(node))"
185
+ >
186
+ <UIcon
187
+ name="i-lucide-copy"
188
+ class="size-4"
189
+ />
190
+ </button>
191
+ </span>
192
+ </li>
193
+ </ul>
194
+ <p
195
+ v-if="tree.truncated"
196
+ class="text-xs text-warning"
197
+ >
198
+ {{ t("nuxtUiMongocamp.documentView.truncated", { count: tree.total }) }}
199
+ </p>
200
+ </template>
201
+ </div>
202
+ </template>
@@ -0,0 +1,22 @@
1
+ type __VLS_Props = {
2
+ document: Record<string, unknown> | null | undefined;
3
+ };
4
+ type __VLS_ModelProps = {
5
+ 'mode'?: 'tree' | 'json';
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
+ copy: (payload: {
10
+ kind: "path" | "value" | "document";
11
+ text: string;
12
+ }) => any;
13
+ "update:mode": (value: "json" | "tree") => any;
14
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
+ onCopy?: ((payload: {
16
+ kind: "path" | "value" | "document";
17
+ text: string;
18
+ }) => any) | undefined;
19
+ "onUpdate:mode"?: ((value: "json" | "tree") => any) | undefined;
20
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
+ declare const _default: typeof __VLS_export;
22
+ export default _default;
@@ -1,7 +1,6 @@
1
1
  <script setup>
2
2
  import { computed, ref, watch } from "vue";
3
3
  import { navigateTo, useI18n, useMongocampError, useMongocampRoles, useMongocampSession } from "#imports";
4
- import { classifyFailure } from "../utils/failureKind";
5
4
  const props = defineProps({
6
5
  error: { type: null, required: true },
7
6
  title: { type: String, required: false },
@@ -10,25 +9,22 @@ const props = defineProps({
10
9
  });
11
10
  const emit = defineEmits(["retry", "clearFilters"]);
12
11
  const { t } = useI18n();
13
- const { describeError } = useMongocampError();
14
- const { diagnoseFailure, invalidateSession } = useMongocampSession();
12
+ const { describeError, describeServerError } = useMongocampError();
13
+ const { invalidateSession } = useMongocampSession();
15
14
  const { loginPath: configuredLoginPath } = useMongocampRoles();
16
- const described = computed(() => describeError(props.error));
17
- const failure = ref(null);
18
- let diagnosisRun = 0;
19
- watch(() => [props.error, props.filterRejected], async ([error, filterRejected]) => {
20
- const run = ++diagnosisRun;
21
- failure.value = null;
22
- if (!error || filterRejected) return;
23
- const kind = await classifyFailure(describeError(error).kind, diagnoseFailure);
24
- if (run === diagnosisRun) failure.value = kind;
15
+ const described = ref(describeError(props.error));
16
+ watch(() => props.error, async (error) => {
17
+ described.value = describeError(error);
18
+ const withServerText = await describeServerError(error);
19
+ if (props.error === error) described.value = withServerText;
25
20
  }, { immediate: true });
26
- const sessionGone = computed(() => described.value.kind === "unauthorized" || failure.value === "session-ended");
27
- const requestRefused = computed(() => failure.value === "rejected-request");
21
+ const sessionGone = computed(() => described.value.kind === "unauthorized");
28
22
  const description = computed(() => {
29
- if (props.filterRejected) return t("nuxtUiMongocamp.errors.filterRejected");
23
+ if (props.filterRejected) {
24
+ const reason = described.value.kind === "invalid" ? ` ${t("nuxtUiMongocamp.errors.serverMessage", { message: described.value.message })}` : "";
25
+ return t("nuxtUiMongocamp.errors.filterRejected") + reason;
26
+ }
30
27
  if (sessionGone.value) return t("nuxtUiMongocamp.errors.unauthorized");
31
- if (requestRefused.value) return t("nuxtUiMongocamp.errors.requestRefused");
32
28
  return described.value.message;
33
29
  });
34
30
  async function loginAgain() {
@@ -0,0 +1,18 @@
1
+ type __VLS_Props = {
2
+ collection: string;
3
+ filter?: string;
4
+ sort?: string[];
5
+ projection?: string[];
6
+ total?: number;
7
+ };
8
+ type __VLS_ModelProps = {
9
+ 'open'?: boolean;
10
+ };
11
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
12
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
+ "update:open": (value: boolean) => any;
14
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
16
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: typeof __VLS_export;
18
+ export default _default;
@@ -0,0 +1,204 @@
1
+ <script setup>
2
+ import { computed, ref, watch } from "vue";
3
+ import { useI18n, useMongocampError } from "#imports";
4
+ import { useMongocampExportAll } from "../composables/useMongocampExportAll";
5
+ import { DEFAULT_EXPORT_MAX_ROWS } from "../utils/exportDocuments";
6
+ const props = defineProps({
7
+ collection: { type: String, required: true },
8
+ filter: { type: String, required: false },
9
+ sort: { type: Array, required: false },
10
+ projection: { type: Array, required: false },
11
+ total: { type: Number, required: false }
12
+ });
13
+ const isOpen = defineModel("open", { type: Boolean, ...{ default: false } });
14
+ const { t } = useI18n();
15
+ const { describeServerError } = useMongocampError();
16
+ const { exportCollection } = useMongocampExportAll();
17
+ const step = ref("form");
18
+ const format = ref("json");
19
+ const progress = ref({ loaded: 0, target: 0 });
20
+ const result = ref(null);
21
+ const cancelled = ref(false);
22
+ const errorText = ref("");
23
+ let controller;
24
+ watch(isOpen, (open) => {
25
+ if (!open) {
26
+ controller?.abort();
27
+ return;
28
+ }
29
+ step.value = "form";
30
+ result.value = null;
31
+ cancelled.value = false;
32
+ errorText.value = "";
33
+ });
34
+ const formatItems = computed(() => [
35
+ { label: t("nuxtUiMongocamp.exportAll.formatJson"), value: "json" },
36
+ { label: t("nuxtUiMongocamp.exportAll.formatNdjson"), value: "ndjson" },
37
+ { label: t("nuxtUiMongocamp.exportAll.formatCsv"), value: "csv" }
38
+ ]);
39
+ const percent = computed(() => progress.value.target === 0 ? 0 : Math.round(progress.value.loaded / progress.value.target * 100));
40
+ async function start() {
41
+ errorText.value = "";
42
+ cancelled.value = false;
43
+ result.value = null;
44
+ step.value = "running";
45
+ progress.value = { loaded: 0, target: props.total ?? 0 };
46
+ const run = new AbortController();
47
+ controller = run;
48
+ try {
49
+ result.value = await exportCollection({
50
+ collection: props.collection,
51
+ format: format.value,
52
+ filter: props.filter,
53
+ sort: props.sort?.length ? props.sort : void 0,
54
+ projection: props.projection?.length ? props.projection : void 0,
55
+ signal: run.signal,
56
+ onProgress: (p) => {
57
+ progress.value = { loaded: p.loaded, target: p.target ?? p.total ?? p.loaded };
58
+ }
59
+ });
60
+ step.value = "done";
61
+ } catch (e) {
62
+ if (!isOpen.value) return;
63
+ if (e?.name === "AbortError") cancelled.value = true;
64
+ else errorText.value = (await describeServerError(e, "nuxtUiMongocamp.exportAll.failed")).message;
65
+ step.value = "done";
66
+ } finally {
67
+ if (controller === run) controller = void 0;
68
+ }
69
+ }
70
+ function cancel() {
71
+ controller?.abort();
72
+ }
73
+ </script>
74
+
75
+ <template>
76
+ <UModal
77
+ v-model:open="isOpen"
78
+ :title="t('nuxtUiMongocamp.exportAll.title')"
79
+ :ui="{ footer: 'justify-end' }"
80
+ >
81
+ <template #body>
82
+ <div
83
+ v-if="step === 'form'"
84
+ class="flex flex-col gap-4"
85
+ >
86
+ <p class="text-sm text-dimmed">
87
+ {{ t("nuxtUiMongocamp.exportAll.intro") }}
88
+ </p>
89
+ <p
90
+ class="text-sm"
91
+ data-test="export-scope"
92
+ >
93
+ {{ filter ? t("nuxtUiMongocamp.exportAll.scopeFiltered", { collection }) : t("nuxtUiMongocamp.exportAll.scopeAll", { collection }) }}
94
+ <template v-if="total !== void 0">
95
+ ({{ t("nuxtUiMongocamp.exportAll.count", { count: total }, total) }})
96
+ </template>
97
+ </p>
98
+ <UFormField :label="t('nuxtUiMongocamp.exportAll.formatLabel')">
99
+ <USelect
100
+ v-model="format"
101
+ :items="formatItems"
102
+ class="w-full"
103
+ :aria-label="t('nuxtUiMongocamp.exportAll.formatLabel')"
104
+ />
105
+ </UFormField>
106
+ <p class="text-xs text-dimmed">
107
+ {{ t("nuxtUiMongocamp.exportAll.cap", { cap: DEFAULT_EXPORT_MAX_ROWS }) }}
108
+ </p>
109
+ </div>
110
+
111
+ <div
112
+ v-else-if="step === 'running'"
113
+ class="flex flex-col gap-2"
114
+ role="status"
115
+ data-test="export-progress"
116
+ >
117
+ <UProgress
118
+ :model-value="percent"
119
+ :max="100"
120
+ />
121
+ <span class="text-sm text-dimmed">{{ t("nuxtUiMongocamp.exportAll.reading", { done: progress.loaded, total: progress.target }) }}</span>
122
+ </div>
123
+
124
+ <div
125
+ v-else
126
+ class="flex flex-col gap-3"
127
+ data-test="export-result"
128
+ >
129
+ <p
130
+ v-if="cancelled"
131
+ class="text-sm"
132
+ >
133
+ {{ t("nuxtUiMongocamp.exportAll.cancelled") }}
134
+ </p>
135
+ <p
136
+ v-else-if="errorText"
137
+ class="text-sm text-error"
138
+ role="alert"
139
+ >
140
+ {{ errorText }}
141
+ </p>
142
+ <template v-else-if="result">
143
+ <UAlert
144
+ v-if="result.truncated"
145
+ color="warning"
146
+ variant="subtle"
147
+ icon="i-lucide-circle-alert"
148
+ :title="t('nuxtUiMongocamp.exportAll.truncated', { count: result.rowCount, total: result.total ?? result.rowCount })"
149
+ />
150
+ <UAlert
151
+ v-else
152
+ color="success"
153
+ variant="subtle"
154
+ icon="i-lucide-circle-check"
155
+ :title="t('nuxtUiMongocamp.exportAll.done', { count: result.rowCount, file: result.filename }, result.rowCount)"
156
+ />
157
+ <p
158
+ v-if="result.truncated"
159
+ class="text-sm text-dimmed"
160
+ >
161
+ {{ t("nuxtUiMongocamp.exportAll.done", { count: result.rowCount, file: result.filename }, result.rowCount) }}
162
+ </p>
163
+ <p
164
+ v-if="result.totalChanged"
165
+ class="text-sm text-warning"
166
+ >
167
+ {{ t("nuxtUiMongocamp.exportAll.changed") }}
168
+ </p>
169
+ </template>
170
+ </div>
171
+ </template>
172
+
173
+ <template #footer>
174
+ <UButton
175
+ v-if="step === 'running'"
176
+ :label="t('nuxtUiMongocamp.exportAll.stop')"
177
+ color="neutral"
178
+ variant="soft"
179
+ @click="cancel"
180
+ />
181
+ <template v-else-if="step === 'done'">
182
+ <UButton
183
+ :label="t('nuxtUiMongocamp.exportAll.close')"
184
+ color="neutral"
185
+ variant="ghost"
186
+ @click="isOpen = false"
187
+ />
188
+ </template>
189
+ <template v-else>
190
+ <UButton
191
+ :label="t('nuxtUiMongocamp.common.cancel')"
192
+ color="neutral"
193
+ variant="ghost"
194
+ @click="isOpen = false"
195
+ />
196
+ <UButton
197
+ :label="t('nuxtUiMongocamp.exportAll.start')"
198
+ icon="i-lucide-download"
199
+ @click="start"
200
+ />
201
+ </template>
202
+ </template>
203
+ </UModal>
204
+ </template>
@@ -0,0 +1,18 @@
1
+ type __VLS_Props = {
2
+ collection: string;
3
+ filter?: string;
4
+ sort?: string[];
5
+ projection?: string[];
6
+ total?: number;
7
+ };
8
+ type __VLS_ModelProps = {
9
+ 'open'?: boolean;
10
+ };
11
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
12
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
+ "update:open": (value: boolean) => any;
14
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
16
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: typeof __VLS_export;
18
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import type { FileInformation } from '@sfxcode/nuxt-mongocamp-server';
2
+ type __VLS_Props = {
3
+ bucketName: string;
4
+ file?: FileInformation;
5
+ };
6
+ type __VLS_ModelProps = {
7
+ 'open'?: boolean;
8
+ };
9
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
10
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
11
+ "update:open": (value: boolean) => any;
12
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
13
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
14
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
+ declare const _default: typeof __VLS_export;
16
+ export default _default;