@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
@@ -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;
@@ -0,0 +1,162 @@
1
+ <script setup>
2
+ import { computed, onBeforeUnmount, ref, watch } from "vue";
3
+ import { useI18n } from "#imports";
4
+ import { useMongocampBucket } from "../composables/useMongocampBucket";
5
+ import { useMongocampError } from "../composables/useMongocampError";
6
+ import { canPreview, clipText, PREVIEW_LIMITS, prettyJson, previewKind } from "../utils/filePreview";
7
+ import { formatBytes } from "../utils/formatBytes";
8
+ const props = defineProps({
9
+ bucketName: { type: String, required: true },
10
+ file: { type: Object, required: false }
11
+ });
12
+ const open = defineModel("open", { type: Boolean, ...{ default: false } });
13
+ const { t } = useI18n();
14
+ const { fetchFileBlob, downloadFile, downloadingFileIds } = useMongocampBucket();
15
+ const { describeError } = useMongocampError();
16
+ const loading = ref(false);
17
+ const error = ref("");
18
+ const objectUrl = ref("");
19
+ const text = ref("");
20
+ const clipped = ref(false);
21
+ let generation = 0;
22
+ const kind = computed(() => props.file ? previewKind(props.file.filename) : "other");
23
+ const tooLarge = computed(() => !!props.file && kind.value !== "other" && !canPreview(kind.value, props.file.length));
24
+ const limitLabel = computed(() => kind.value === "other" ? "" : formatBytes(PREVIEW_LIMITS[kind.value]));
25
+ function release() {
26
+ if (objectUrl.value) {
27
+ URL.revokeObjectURL(objectUrl.value);
28
+ objectUrl.value = "";
29
+ }
30
+ text.value = "";
31
+ clipped.value = false;
32
+ error.value = "";
33
+ }
34
+ async function load() {
35
+ const current = ++generation;
36
+ release();
37
+ const file = props.file;
38
+ if (!open.value || !file || kind.value === "other" || tooLarge.value) {
39
+ loading.value = false;
40
+ return;
41
+ }
42
+ loading.value = true;
43
+ try {
44
+ const blob = await fetchFileBlob(props.bucketName, file.id);
45
+ if (current !== generation) return;
46
+ if (kind.value === "image" || kind.value === "pdf") {
47
+ objectUrl.value = URL.createObjectURL(blob);
48
+ } else {
49
+ const raw = await blob.text();
50
+ if (current !== generation) return;
51
+ const result = clipText(kind.value === "json" ? prettyJson(raw) : raw);
52
+ text.value = result.text;
53
+ clipped.value = result.clipped;
54
+ }
55
+ } catch (e) {
56
+ if (current === generation) error.value = describeError(e).message;
57
+ } finally {
58
+ if (current === generation) loading.value = false;
59
+ }
60
+ }
61
+ watch([open, () => props.file?.id, () => props.bucketName], load, { immediate: true });
62
+ onBeforeUnmount(() => {
63
+ generation++;
64
+ release();
65
+ });
66
+ </script>
67
+
68
+ <template>
69
+ <USlideover
70
+ v-model:open="open"
71
+ :title="file?.filename ?? t('nuxtUiMongocamp.filePreview.title')"
72
+ :description="file ? formatBytes(file.length) : void 0"
73
+ :ui="{ content: 'max-w-3xl' }"
74
+ >
75
+ <template #body>
76
+ <div
77
+ v-if="file"
78
+ class="flex flex-col gap-4"
79
+ data-testid="file-preview"
80
+ >
81
+ <div
82
+ v-if="loading"
83
+ class="flex items-center gap-2 text-sm text-dimmed"
84
+ >
85
+ <UIcon
86
+ name="i-lucide-loader-circle"
87
+ class="animate-spin"
88
+ />
89
+ {{ t("nuxtUiMongocamp.filePreview.loading") }}
90
+ </div>
91
+
92
+ <UAlert
93
+ v-else-if="error"
94
+ color="error"
95
+ variant="subtle"
96
+ icon="i-lucide-circle-alert"
97
+ :title="t('nuxtUiMongocamp.filePreview.failed')"
98
+ :description="error"
99
+ />
100
+
101
+ <UAlert
102
+ v-else-if="kind === 'other'"
103
+ color="neutral"
104
+ variant="subtle"
105
+ icon="i-lucide-file"
106
+ :title="t('nuxtUiMongocamp.filePreview.noPreview')"
107
+ />
108
+
109
+ <UAlert
110
+ v-else-if="tooLarge"
111
+ color="neutral"
112
+ variant="subtle"
113
+ icon="i-lucide-file-warning"
114
+ :title="t('nuxtUiMongocamp.filePreview.tooLarge', { max: limitLabel })"
115
+ />
116
+
117
+ <img
118
+ v-else-if="kind === 'image' && objectUrl"
119
+ :src="objectUrl"
120
+ :alt="file.filename"
121
+ class="max-w-full max-h-[70vh] object-contain mx-auto rounded"
122
+ >
123
+
124
+ <iframe
125
+ v-else-if="kind === 'pdf' && objectUrl"
126
+ :src="objectUrl"
127
+ :title="file.filename"
128
+ sandbox=""
129
+ class="w-full h-[70vh] rounded border border-default"
130
+ />
131
+
132
+ <template v-else-if="text">
133
+ <pre class="text-xs overflow-auto max-h-[70vh] whitespace-pre-wrap break-all rounded bg-elevated p-3">{{ text }}</pre>
134
+ <p
135
+ v-if="clipped"
136
+ class="text-xs text-dimmed"
137
+ >
138
+ {{ t("nuxtUiMongocamp.filePreview.clipped") }}
139
+ </p>
140
+ </template>
141
+
142
+ <div class="flex justify-end">
143
+ <UButton
144
+ icon="i-lucide-download"
145
+ color="neutral"
146
+ variant="subtle"
147
+ :label="t('nuxtUiMongocamp.filePreview.download')"
148
+ :loading="downloadingFileIds.has(file.id)"
149
+ @click="downloadFile(bucketName, file.id)"
150
+ />
151
+ </div>
152
+
153
+ <div v-if="Object.keys(file.metadata ?? {}).length">
154
+ <h4 class="text-sm font-medium mb-1">
155
+ {{ t("nuxtUiMongocamp.bucketFiles.columnMetadata") }}
156
+ </h4>
157
+ <pre class="text-xs overflow-auto max-h-48 whitespace-pre-wrap break-all rounded bg-elevated p-3">{{ JSON.stringify(file.metadata, null, 2) }}</pre>
158
+ </div>
159
+ </div>
160
+ </template>
161
+ </USlideover>
162
+ </template>
@@ -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;
@@ -79,6 +79,9 @@ function listId(condition) {
79
79
  function setMatch(match) {
80
80
  model.value = { ...model.value, match };
81
81
  }
82
+ function setNegate(negate) {
83
+ model.value = { ...model.value, negate };
84
+ }
82
85
  function apply() {
83
86
  emit("apply", query.value);
84
87
  }
@@ -113,6 +116,14 @@ function clearAll() {
113
116
  />
114
117
  </div>
115
118
 
119
+ <UCheckbox
120
+ v-if="model.conditions.length > 0"
121
+ :model-value="model.negate ?? false"
122
+ :label="t('nuxtUiMongocamp.filterBuilder.negate')"
123
+ :description="t('nuxtUiMongocamp.filterBuilder.negateHint')"
124
+ @update:model-value="(value) => setNegate(value === true)"
125
+ />
126
+
116
127
  <p
117
128
  v-if="model.conditions.length === 0"
118
129
  class="text-sm text-dimmed"
@@ -4,6 +4,7 @@ import { useI18n, useMongocampError } from "#imports";
4
4
  import { useMongocampImport } from "../composables/useMongocampImport";
5
5
  import { DEFAULT_IMPORT_LIMITS } from "../utils/importRows";
6
6
  import { detectImportFormat, prepareImport } from "../utils/importPipeline";
7
+ import { formatBytes } from "../utils/formatBytes";
7
8
  const props = defineProps({
8
9
  collectionName: { type: String, required: true }
9
10
  });
@@ -11,8 +12,8 @@ const emit = defineEmits(["imported"]);
11
12
  const PREVIEW_ROWS = 5;
12
13
  const ERROR_LIMIT = 10;
13
14
  const { t } = useI18n();
14
- const { describeError } = useMongocampError();
15
- const { importRows } = useMongocampImport();
15
+ const { describeServerError } = useMongocampError();
16
+ const { importRows, importNdjson } = useMongocampImport();
16
17
  const isOpen = ref(false);
17
18
  const step = ref("select");
18
19
  const fileInputRef = ref(null);
@@ -24,6 +25,12 @@ const delimiter = ref(",");
24
25
  const userColumnTypes = ref(null);
25
26
  const emptyAsText = ref(false);
26
27
  const stampMetadata = ref(true);
28
+ const serverFile = ref(null);
29
+ const serverPreview = ref({ rows: [], columns: [], unreadable: 0 });
30
+ const serverResult = ref(null);
31
+ const serverError = ref("");
32
+ const NDJSON_HEAD_BYTES = 64 * 1024;
33
+ const isNdjsonName = (name) => /\.(?:ndjson|jsonl)$/i.test(name);
27
34
  const progress = ref({ done: 0, total: 0 });
28
35
  const attemptRows = ref([]);
29
36
  const attemptSources = ref([]);
@@ -91,6 +98,9 @@ function resetState() {
91
98
  userColumnTypes.value = null;
92
99
  emptyAsText.value = false;
93
100
  stampMetadata.value = true;
101
+ serverFile.value = null;
102
+ serverResult.value = null;
103
+ serverError.value = "";
94
104
  progress.value = { done: 0, total: 0 };
95
105
  attemptRows.value = [];
96
106
  attemptSources.value = [];
@@ -113,6 +123,14 @@ async function handleFileSelected(event) {
113
123
  input.value = "";
114
124
  if (!file) return;
115
125
  readError.value = "";
126
+ if (isNdjsonName(file.name)) {
127
+ try {
128
+ await prepareServerFile(file);
129
+ } catch {
130
+ readError.value = t("nuxtUiMongocamp.import.readError");
131
+ }
132
+ return;
133
+ }
116
134
  try {
117
135
  const text = await file.text();
118
136
  fileName.value = file.name;
@@ -125,7 +143,60 @@ async function handleFileSelected(event) {
125
143
  readError.value = t("nuxtUiMongocamp.import.readError");
126
144
  }
127
145
  }
146
+ async function prepareServerFile(file) {
147
+ const head = await file.slice(0, NDJSON_HEAD_BYTES).text();
148
+ const lines = head.replace(/^\uFEFF/, "").split(/\r?\n/);
149
+ if (file.size > NDJSON_HEAD_BYTES) lines.pop();
150
+ const rows = [];
151
+ const columns = /* @__PURE__ */ new Set();
152
+ let unreadable = 0;
153
+ for (const line of lines.filter((l) => l.trim() !== "").slice(0, PREVIEW_ROWS)) {
154
+ try {
155
+ const value = JSON.parse(line);
156
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("not an object");
157
+ const shown = {};
158
+ for (const [key, inner] of Object.entries(value)) {
159
+ shown[key] = typeof inner === "object" && inner !== null ? JSON.stringify(inner) : String(inner);
160
+ columns.add(key);
161
+ }
162
+ rows.push(shown);
163
+ } catch {
164
+ unreadable++;
165
+ }
166
+ }
167
+ fileName.value = file.name;
168
+ serverFile.value = file;
169
+ serverPreview.value = { rows, columns: [...columns], unreadable };
170
+ serverResult.value = null;
171
+ serverError.value = "";
172
+ step.value = "preview";
173
+ }
174
+ async function startServerImport() {
175
+ const file = serverFile.value;
176
+ if (!file) return;
177
+ serverError.value = "";
178
+ step.value = "importing";
179
+ const run = new AbortController();
180
+ controller = run;
181
+ try {
182
+ const result = await importNdjson(props.collectionName, file, { signal: run.signal });
183
+ if (controller === run) controller = null;
184
+ if (!isOpen.value) return;
185
+ serverResult.value = result;
186
+ if (result.inserted > 0) emit("imported", result.inserted);
187
+ } catch (e) {
188
+ if (controller === run) controller = null;
189
+ if (!isOpen.value) return;
190
+ if (e?.name === "AbortError") {
191
+ step.value = "preview";
192
+ return;
193
+ }
194
+ serverError.value = await failureReason(e);
195
+ }
196
+ step.value = "done";
197
+ }
128
198
  function backToSelect() {
199
+ serverFile.value = null;
129
200
  fileName.value = "";
130
201
  fileText.value = "";
131
202
  userColumnTypes.value = null;
@@ -143,15 +214,7 @@ function setColumnType(column, type) {
143
214
  userColumnTypes.value = { ...columnTypes.value, [column]: type };
144
215
  }
145
216
  async function failureReason(error) {
146
- const response = error?.response;
147
- if (response) {
148
- try {
149
- const body = await response.clone().json();
150
- if (typeof body?.msg === "string" && body.msg) return body.msg;
151
- } catch {
152
- }
153
- }
154
- return describeError(error).message;
217
+ return (await describeServerError(error)).message;
155
218
  }
156
219
  async function runImport(rows, sources) {
157
220
  attemptRows.value = rows;
@@ -238,7 +301,7 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
238
301
  ref="fileInputRef"
239
302
  type="file"
240
303
  class="hidden"
241
- accept=".json,.csv,.tsv,.txt,application/json,text/csv"
304
+ accept=".json,.ndjson,.jsonl,.csv,.tsv,.txt,application/json,application/x-ndjson,text/csv"
242
305
  data-testid="import-file-input"
243
306
  @change="handleFileSelected"
244
307
  >
@@ -256,6 +319,37 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
256
319
  />
257
320
  </div>
258
321
 
322
+ <div
323
+ v-else-if="step === 'preview' && serverFile"
324
+ class="flex flex-col gap-4"
325
+ data-test="ndjson-preview"
326
+ >
327
+ <span class="text-sm font-medium break-all">{{ fileName }} ({{ formatBytes(serverFile.size) }})</span>
328
+ <UAlert
329
+ color="info"
330
+ variant="subtle"
331
+ icon="i-lucide-info"
332
+ :description="t('nuxtUiMongocamp.import.ndjsonNote')"
333
+ />
334
+ <UAlert
335
+ v-if="serverPreview.unreadable > 0"
336
+ color="warning"
337
+ variant="subtle"
338
+ icon="i-lucide-triangle-alert"
339
+ :description="t('nuxtUiMongocamp.import.ndjsonUnreadable', { count: serverPreview.unreadable }, serverPreview.unreadable)"
340
+ />
341
+ <div v-if="serverPreview.rows.length > 0">
342
+ <p class="mb-1 text-sm font-medium">
343
+ {{ t("nuxtUiMongocamp.import.previewTitle", { count: serverPreview.rows.length }) }}
344
+ </p>
345
+ <UTable
346
+ :data="serverPreview.rows"
347
+ :columns="serverPreview.columns.map((column2) => ({ id: column2, header: column2, accessorFn: (row) => row[column2] }))"
348
+ class="max-h-64"
349
+ />
350
+ </div>
351
+ </div>
352
+
259
353
  <div
260
354
  v-else-if="step === 'preview' && prepared"
261
355
  class="flex flex-col gap-4"
@@ -375,6 +469,17 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
375
469
  </template>
376
470
  </div>
377
471
 
472
+ <div
473
+ v-else-if="step === 'importing' && serverFile"
474
+ class="flex flex-col gap-3"
475
+ data-test="ndjson-importing"
476
+ >
477
+ <p class="text-sm">
478
+ {{ t("nuxtUiMongocamp.import.ndjsonImporting") }}
479
+ </p>
480
+ <UProgress :aria-label="t('nuxtUiMongocamp.import.ndjsonImporting')" />
481
+ </div>
482
+
378
483
  <div
379
484
  v-else-if="step === 'importing'"
380
485
  class="flex flex-col gap-3"
@@ -388,6 +493,52 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
388
493
  />
389
494
  </div>
390
495
 
496
+ <div
497
+ v-else-if="step === 'done' && serverFile"
498
+ class="flex flex-col gap-3"
499
+ data-test="ndjson-result"
500
+ >
501
+ <UAlert
502
+ v-if="serverError"
503
+ color="error"
504
+ variant="subtle"
505
+ icon="i-lucide-circle-alert"
506
+ :description="serverError"
507
+ />
508
+ <template v-else-if="serverResult">
509
+ <UAlert
510
+ :color="serverResult.inserted > 0 ? 'success' : 'neutral'"
511
+ variant="subtle"
512
+ :icon="serverResult.inserted > 0 ? 'i-lucide-circle-check' : 'i-lucide-info'"
513
+ :title="t('nuxtUiMongocamp.import.result', { count: serverResult.inserted }, serverResult.inserted)"
514
+ />
515
+ <UAlert
516
+ v-if="serverResult.failed > 0"
517
+ color="error"
518
+ variant="subtle"
519
+ icon="i-lucide-circle-alert"
520
+ :title="t('nuxtUiMongocamp.import.ndjsonFailed', { failed: serverResult.failed, read: serverResult.read })"
521
+ >
522
+ <template #description>
523
+ <ul class="list-disc pl-5 text-sm">
524
+ <li
525
+ v-for="error in (serverResult.errors ?? []).slice(0, ERROR_LIMIT)"
526
+ :key="error.index"
527
+ >
528
+ {{ t("nuxtUiMongocamp.import.ndjsonLine", { line: error.index, reason: error.message }) }}
529
+ </li>
530
+ </ul>
531
+ <p
532
+ v-if="serverResult.errorsTruncated || (serverResult.errors ?? []).length > ERROR_LIMIT"
533
+ class="mt-1 text-sm"
534
+ >
535
+ {{ t("nuxtUiMongocamp.import.ndjsonMoreErrors") }}
536
+ </p>
537
+ </template>
538
+ </UAlert>
539
+ </template>
540
+ </div>
541
+
391
542
  <div
392
543
  v-else-if="step === 'done'"
393
544
  class="flex flex-col gap-3"
@@ -440,6 +591,13 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
440
591
  @click="backToSelect"
441
592
  />
442
593
  <UButton
594
+ v-if="serverFile"
595
+ :label="t('nuxtUiMongocamp.import.importFile')"
596
+ data-test="ndjson-import"
597
+ @click="startServerImport"
598
+ />
599
+ <UButton
600
+ v-else
443
601
  :label="t('nuxtUiMongocamp.import.importButton', { count: readyCount }, readyCount)"
444
602
  :disabled="readyCount === 0"
445
603
  @click="startImport"
@@ -455,7 +613,7 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
455
613
  </template>
456
614
  <template v-else-if="step === 'done'">
457
615
  <UButton
458
- v-if="failures.length > 0"
616
+ v-if="failures.length > 0 && !serverFile"
459
617
  :label="t('nuxtUiMongocamp.import.retryFailed')"
460
618
  color="neutral"
461
619
  variant="subtle"
@@ -0,0 +1,18 @@
1
+ type __VLS_Props = {
2
+ collectionName: string;
3
+ canManage?: boolean;
4
+ fields?: string[];
5
+ };
6
+ declare function load(): Promise<void>;
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
8
+ refresh: typeof load;
9
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ changed: () => any;
11
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
+ onChanged?: (() => any) | undefined;
13
+ }>, {
14
+ fields: string[];
15
+ canManage: boolean;
16
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: typeof __VLS_export;
18
+ export default _default;