@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,445 @@
1
+ <script setup>
2
+ import { computed, ref, watch } from "vue";
3
+ import { useI18n, useMongocampError } from "#imports";
4
+ import { useMongocampCollectionCopy } from "../composables/useMongocampCollectionCopy";
5
+ import { backupName, canCopyCollection, MAX_COLLECTION_NAME_LENGTH, MAX_COPY_DOCUMENTS, validateTargetName } from "../utils/collectionCopy";
6
+ const props = defineProps({
7
+ source: { type: String, required: true },
8
+ filter: { type: String, required: false }
9
+ });
10
+ const emit = defineEmits(["done"]);
11
+ const isOpen = defineModel("open", { type: Boolean, ...{ default: false } });
12
+ const { t } = useI18n();
13
+ const { describeServerError } = useMongocampError();
14
+ const { copyCollection, copyIndexes, backupCollection, retryBatches, listCollectionNames, countDocuments, collectionCount } = useMongocampCollectionCopy();
15
+ const step = ref("form");
16
+ const target = ref("");
17
+ const existing = ref([]);
18
+ const sourceCount = ref(void 0);
19
+ const countFailed = ref(false);
20
+ const progress = ref({ phase: "reading", done: 0, total: 0 });
21
+ const result = ref(null);
22
+ const failures = ref([]);
23
+ const totalInserted = ref(0);
24
+ const aborted = ref(false);
25
+ const skipped = ref(0);
26
+ const finalCount = ref(void 0);
27
+ const errorText = ref("");
28
+ const withIndexes = ref(true);
29
+ const indexResult = ref(null);
30
+ const indexesError = ref(false);
31
+ const indexFailureReasons = ref({});
32
+ let controller;
33
+ let opened = 0;
34
+ watch(isOpen, async (open) => {
35
+ if (!open) {
36
+ controller?.abort();
37
+ return;
38
+ }
39
+ const mine = ++opened;
40
+ step.value = "form";
41
+ target.value = "";
42
+ result.value = null;
43
+ failures.value = [];
44
+ totalInserted.value = 0;
45
+ aborted.value = false;
46
+ skipped.value = 0;
47
+ finalCount.value = void 0;
48
+ errorText.value = "";
49
+ indexResult.value = null;
50
+ indexesError.value = false;
51
+ indexFailureReasons.value = {};
52
+ sourceCount.value = void 0;
53
+ countFailed.value = false;
54
+ const [names, count] = await Promise.allSettled([listCollectionNames(), countDocuments(props.source, props.filter)]);
55
+ if (mine !== opened) return;
56
+ existing.value = names.status === "fulfilled" ? names.value : [];
57
+ if (count.status === "fulfilled") sourceCount.value = count.value;
58
+ else countFailed.value = true;
59
+ }, { immediate: true });
60
+ const problem = computed(() => target.value === "" ? void 0 : validateTargetName(target.value, props.source, existing.value));
61
+ const problemText = computed(() => {
62
+ const key = { "empty": "problemEmpty", "too-long": "problemTooLong", "invalid-characters": "problemInvalid", "protected": "problemProtected", "same-as-source": "problemSame", "exists": "problemExists" }[problem.value ?? "empty"];
63
+ return problem.value ? t(`nuxtUiMongocamp.collectionCopy.${key}`, { max: MAX_COLLECTION_NAME_LENGTH }) : "";
64
+ });
65
+ const tooMany = computed(() => sourceCount.value !== void 0 && sourceCount.value > MAX_COPY_DOCUMENTS);
66
+ const canStart = computed(() => target.value.trim() !== "" && problem.value === void 0 && sourceCount.value !== void 0 && !tooMany.value);
67
+ const targetName = computed(() => target.value.trim());
68
+ const canBackup = computed(() => canCopyCollection(props.source) && sourceCount.value !== void 0 && !tooMany.value);
69
+ const backupPreview = computed(() => backupName(props.source, existing.value));
70
+ const percent = computed(() => progress.value.total === 0 ? 0 : Math.round(progress.value.done / progress.value.total * 100));
71
+ async function reasonOf(error) {
72
+ return (await describeServerError(error, "nuxtUiMongocamp.collectionCopy.failedGeneric")).message;
73
+ }
74
+ const SKIP_KEYS = {
75
+ "multi-field-text": "skipMultiText",
76
+ "custom-weights": "skipWeights",
77
+ "unsupported-key": "skipKeyType",
78
+ "unknown-key-order": "skipOrder"
79
+ };
80
+ const skipText = (reason) => t(`nuxtUiMongocamp.collectionCopy.${SKIP_KEYS[reason]}`);
81
+ async function applyIndexes(indexes, failedToList) {
82
+ indexResult.value = indexes ?? null;
83
+ indexesError.value = failedToList !== void 0;
84
+ indexFailureReasons.value = Object.fromEntries(await Promise.all((indexes?.failed ?? []).map(async (f) => [f.name, await reasonOf(f.error)])));
85
+ }
86
+ async function describeFailures(failed) {
87
+ failures.value = await Promise.all(failed.map(async (batch) => ({
88
+ from: batch.start + 1,
89
+ to: batch.start + batch.count,
90
+ reason: await reasonOf(batch.error),
91
+ mayBePartial: batch.mayBePartial,
92
+ batch
93
+ })));
94
+ }
95
+ async function finish(copied) {
96
+ step.value = "done";
97
+ if (copied > 0) {
98
+ emit("done", { target: targetName.value, copied });
99
+ try {
100
+ finalCount.value = await collectionCount(targetName.value);
101
+ } catch {
102
+ finalCount.value = void 0;
103
+ }
104
+ }
105
+ }
106
+ async function start(quick = false) {
107
+ if (quick ? !canBackup.value : !canStart.value) return;
108
+ errorText.value = "";
109
+ step.value = "running";
110
+ progress.value = { phase: "reading", done: 0, total: sourceCount.value ?? 0 };
111
+ const run = new AbortController();
112
+ controller = run;
113
+ try {
114
+ const common = {
115
+ source: props.source,
116
+ filter: props.filter,
117
+ copyIndexes: withIndexes.value,
118
+ signal: run.signal,
119
+ onProgress: (p) => {
120
+ progress.value = p;
121
+ }
122
+ };
123
+ const outcome = quick ? await backupCollection({ ...common, onTarget: (name) => {
124
+ target.value = name;
125
+ } }) : await copyCollection({ ...common, target: targetName.value });
126
+ if (!isOpen.value) return;
127
+ result.value = outcome;
128
+ if (outcome.refused === "target-exists") {
129
+ existing.value = [...existing.value, targetName.value];
130
+ step.value = "form";
131
+ errorText.value = t("nuxtUiMongocamp.collectionCopy.refusedExists", { target: targetName.value });
132
+ return;
133
+ }
134
+ if (outcome.refused === "too-many-documents") {
135
+ sourceCount.value = outcome.sourceTotal;
136
+ step.value = "form";
137
+ return;
138
+ }
139
+ totalInserted.value = outcome.inserted;
140
+ aborted.value = outcome.aborted;
141
+ skipped.value = outcome.skipped;
142
+ await applyIndexes(outcome.indexes, outcome.indexesError);
143
+ await describeFailures(outcome.failedBatches);
144
+ await finish(outcome.inserted);
145
+ } catch (e) {
146
+ if (!isOpen.value) return;
147
+ if (e?.name === "AbortError") {
148
+ step.value = "form";
149
+ return;
150
+ }
151
+ errorText.value = await reasonOf(e);
152
+ step.value = "form";
153
+ } finally {
154
+ if (controller === run) controller = void 0;
155
+ }
156
+ }
157
+ async function retry() {
158
+ if (!result.value) return;
159
+ const rows = result.value.rows;
160
+ const failed = failures.value.map((f) => f.batch);
161
+ step.value = "running";
162
+ progress.value = { phase: "writing", done: 0, total: failed.reduce((sum, f) => sum + f.count, 0) };
163
+ const run = new AbortController();
164
+ controller = run;
165
+ try {
166
+ const again = await retryBatches(targetName.value, rows, failed, { signal: run.signal, onProgress: (p) => {
167
+ progress.value = p;
168
+ } });
169
+ if (!isOpen.value) return;
170
+ totalInserted.value += again.inserted;
171
+ skipped.value = again.skipped;
172
+ aborted.value = again.aborted;
173
+ const originals = failed.flatMap((f) => Array.from({ length: f.count }, (_, i) => f.start + i));
174
+ failures.value = await Promise.all(again.failedBatches.map(async (batch) => ({
175
+ from: originals[batch.start] + 1,
176
+ to: originals[batch.start + batch.count - 1] + 1,
177
+ reason: await reasonOf(batch.error),
178
+ mayBePartial: batch.mayBePartial,
179
+ batch: { ...batch, start: originals[batch.start] }
180
+ })));
181
+ if (withIndexes.value && failures.value.length === 0 && !aborted.value && !indexResult.value) {
182
+ try {
183
+ await applyIndexes(await copyIndexes(props.source, targetName.value), void 0);
184
+ } catch (e) {
185
+ await applyIndexes(void 0, e);
186
+ }
187
+ }
188
+ await finish(totalInserted.value);
189
+ } finally {
190
+ if (controller === run) controller = void 0;
191
+ }
192
+ }
193
+ function stop() {
194
+ controller?.abort();
195
+ }
196
+ const anyMayBePartial = computed(() => failures.value.some((f) => f.mayBePartial));
197
+ const failedCount = computed(() => failures.value.reduce((sum, f) => sum + (f.to - f.from + 1), 0));
198
+ const complete = computed(() => step.value === "done" && failures.value.length === 0 && !aborted.value && totalInserted.value > 0);
199
+ const indexesPending = computed(() => withIndexes.value && failures.value.length > 0 && !indexResult.value && !indexesError.value);
200
+ const sourceTotal = computed(() => result.value?.sourceTotal ?? sourceCount.value ?? 0);
201
+ </script>
202
+
203
+ <template>
204
+ <UModal
205
+ v-model:open="isOpen"
206
+ :title="filter ? t('nuxtUiMongocamp.collectionCopy.titleFiltered', { source }) : t('nuxtUiMongocamp.collectionCopy.title', { source })"
207
+ :ui="{ footer: 'justify-end' }"
208
+ >
209
+ <template #body>
210
+ <div
211
+ v-if="step === 'form'"
212
+ class="flex flex-col gap-4"
213
+ >
214
+ <p class="text-sm text-dimmed">
215
+ {{ t("nuxtUiMongocamp.collectionCopy.intro") }}
216
+ </p>
217
+ <UFormField
218
+ :label="t('nuxtUiMongocamp.collectionCopy.targetLabel')"
219
+ :help="t('nuxtUiMongocamp.collectionCopy.targetHelp')"
220
+ :error="problemText || void 0"
221
+ >
222
+ <UInput
223
+ v-model="target"
224
+ class="w-full"
225
+ autocomplete="off"
226
+ :placeholder="t('nuxtUiMongocamp.collectionCopy.targetPlaceholder')"
227
+ :aria-label="t('nuxtUiMongocamp.collectionCopy.targetLabel')"
228
+ @keydown.enter.prevent="start()"
229
+ />
230
+ </UFormField>
231
+ <p
232
+ v-if="sourceCount !== void 0 && !tooMany"
233
+ class="text-sm"
234
+ data-test="copy-count"
235
+ >
236
+ {{ t(filter ? "nuxtUiMongocamp.collectionCopy.countFiltered" : "nuxtUiMongocamp.collectionCopy.count", { count: sourceCount }, sourceCount) }}
237
+ </p>
238
+ <p
239
+ v-else-if="!tooMany && !countFailed"
240
+ class="text-sm text-dimmed"
241
+ >
242
+ {{ t("nuxtUiMongocamp.collectionCopy.countLoading") }}
243
+ </p>
244
+ <p
245
+ v-if="countFailed"
246
+ class="text-sm text-error"
247
+ role="alert"
248
+ >
249
+ {{ t("nuxtUiMongocamp.collectionCopy.countFailed") }}
250
+ </p>
251
+ <p
252
+ v-if="tooMany"
253
+ class="text-sm text-error"
254
+ role="alert"
255
+ >
256
+ {{ t("nuxtUiMongocamp.collectionCopy.tooMany", { count: sourceCount, cap: MAX_COPY_DOCUMENTS }) }}
257
+ </p>
258
+ <UCheckbox
259
+ v-model="withIndexes"
260
+ :label="t('nuxtUiMongocamp.collectionCopy.withIndexes')"
261
+ :description="t('nuxtUiMongocamp.collectionCopy.withIndexesHelp')"
262
+ />
263
+ <p
264
+ v-if="errorText"
265
+ class="text-sm text-error"
266
+ role="alert"
267
+ >
268
+ {{ errorText }}
269
+ </p>
270
+ </div>
271
+
272
+ <div
273
+ v-else-if="step === 'running'"
274
+ class="flex flex-col gap-2"
275
+ role="status"
276
+ data-test="copy-progress"
277
+ >
278
+ <UProgress
279
+ :model-value="percent"
280
+ :max="100"
281
+ />
282
+ <span class="text-sm text-dimmed">{{ t(`nuxtUiMongocamp.collectionCopy.${progress.phase}`, { done: progress.done, total: progress.total }) }}</span>
283
+ </div>
284
+
285
+ <div
286
+ v-else
287
+ class="flex flex-col gap-3"
288
+ data-test="copy-result"
289
+ >
290
+ <UAlert
291
+ v-if="complete"
292
+ color="success"
293
+ variant="subtle"
294
+ icon="i-lucide-circle-check"
295
+ :title="t('nuxtUiMongocamp.collectionCopy.doneTitle', { count: totalInserted, target: targetName }, totalInserted)"
296
+ />
297
+ <UAlert
298
+ v-else-if="aborted"
299
+ color="warning"
300
+ variant="subtle"
301
+ icon="i-lucide-circle-alert"
302
+ :title="t('nuxtUiMongocamp.collectionCopy.stopped', { done: totalInserted, total: sourceTotal, skipped, target: targetName })"
303
+ />
304
+ <UAlert
305
+ v-else-if="failures.length > 0"
306
+ color="error"
307
+ variant="subtle"
308
+ icon="i-lucide-circle-alert"
309
+ :title="t('nuxtUiMongocamp.collectionCopy.failedTitle', { failed: failedCount, total: sourceTotal })"
310
+ >
311
+ <template #description>
312
+ <p
313
+ v-for="failure in failures"
314
+ :key="failure.from"
315
+ class="text-sm"
316
+ >
317
+ {{ t("nuxtUiMongocamp.collectionCopy.failedRange", { from: failure.from, to: failure.to, reason: failure.reason }) }}
318
+ </p>
319
+ <p class="mt-1 text-sm">
320
+ {{ t("nuxtUiMongocamp.collectionCopy.incomplete", { target: targetName }) }}
321
+ </p>
322
+ <p
323
+ v-if="anyMayBePartial"
324
+ class="mt-1 text-sm"
325
+ >
326
+ {{ t("nuxtUiMongocamp.collectionCopy.maybePartial") }}
327
+ </p>
328
+ </template>
329
+ </UAlert>
330
+ <p
331
+ v-else
332
+ class="text-sm"
333
+ >
334
+ {{ t("nuxtUiMongocamp.collectionCopy.doneTitle", { count: 0, target: targetName }, 0) }}
335
+ </p>
336
+ <div
337
+ v-if="indexResult"
338
+ class="flex flex-col gap-1 text-sm"
339
+ data-test="copy-indexes"
340
+ >
341
+ <p v-if="indexResult.copied.length > 0 || indexResult.skipped.length === 0 && indexResult.failed.length === 0">
342
+ {{ indexResult.copied.length > 0 ? t("nuxtUiMongocamp.collectionCopy.indexesCopied", { count: indexResult.copied.length }) : t("nuxtUiMongocamp.collectionCopy.indexesNone") }}
343
+ </p>
344
+ <p
345
+ v-for="item in indexResult.skipped"
346
+ :key="`s-${item.name}`"
347
+ class="text-warning"
348
+ >
349
+ {{ t("nuxtUiMongocamp.collectionCopy.indexSkipped", { name: item.name, reason: skipText(item.reason) }) }}
350
+ </p>
351
+ <p
352
+ v-for="item in indexResult.failed"
353
+ :key="`f-${item.name}`"
354
+ class="text-error"
355
+ >
356
+ {{ t("nuxtUiMongocamp.collectionCopy.indexFailed", { name: item.name, reason: indexFailureReasons[item.name] ?? "" }) }}
357
+ </p>
358
+ </div>
359
+ <p
360
+ v-else-if="indexesError"
361
+ class="text-sm text-error"
362
+ role="alert"
363
+ >
364
+ {{ t("nuxtUiMongocamp.collectionCopy.indexesError") }}
365
+ </p>
366
+ <p
367
+ v-else-if="indexesPending"
368
+ class="text-sm text-dimmed"
369
+ >
370
+ {{ t("nuxtUiMongocamp.collectionCopy.indexesPending") }}
371
+ </p>
372
+ <p
373
+ v-if="finalCount !== void 0 && finalCount === totalInserted"
374
+ class="text-sm text-dimmed"
375
+ data-test="copy-verified"
376
+ >
377
+ {{ t("nuxtUiMongocamp.collectionCopy.verified", { count: finalCount }) }}
378
+ </p>
379
+ <p
380
+ v-else-if="finalCount !== void 0"
381
+ class="text-sm text-warning"
382
+ role="alert"
383
+ data-test="copy-mismatch"
384
+ >
385
+ {{ t("nuxtUiMongocamp.collectionCopy.verifyMismatch", { actual: finalCount, expected: totalInserted }) }}
386
+ </p>
387
+ <p
388
+ v-if="result?.totalChanged"
389
+ class="text-sm text-warning"
390
+ >
391
+ {{ t("nuxtUiMongocamp.collectionCopy.changed") }}
392
+ </p>
393
+ </div>
394
+ </template>
395
+
396
+ <template #footer>
397
+ <template v-if="step === 'running'">
398
+ <UButton
399
+ :label="t('nuxtUiMongocamp.collectionCopy.stop')"
400
+ color="neutral"
401
+ variant="soft"
402
+ @click="stop"
403
+ />
404
+ </template>
405
+ <template v-else-if="step === 'done'">
406
+ <UButton
407
+ v-if="failures.length > 0 && !aborted"
408
+ :label="t('nuxtUiMongocamp.collectionCopy.retry')"
409
+ icon="i-lucide-rotate-cw"
410
+ @click="retry"
411
+ />
412
+ <UButton
413
+ :label="t('nuxtUiMongocamp.collectionCopy.close')"
414
+ color="neutral"
415
+ variant="ghost"
416
+ @click="isOpen = false"
417
+ />
418
+ </template>
419
+ <template v-else>
420
+ <UButton
421
+ :label="t('nuxtUiMongocamp.common.cancel')"
422
+ color="neutral"
423
+ variant="ghost"
424
+ @click="isOpen = false"
425
+ />
426
+ <UButton
427
+ :label="t('nuxtUiMongocamp.collectionCopy.quickBackup')"
428
+ icon="i-lucide-archive"
429
+ color="neutral"
430
+ variant="soft"
431
+ :disabled="!canBackup"
432
+ :title="t('nuxtUiMongocamp.collectionCopy.quickBackupHint', { name: backupPreview })"
433
+ data-test="quick-backup"
434
+ @click="start(true)"
435
+ />
436
+ <UButton
437
+ :label="t('nuxtUiMongocamp.collectionCopy.start')"
438
+ icon="i-lucide-copy"
439
+ :disabled="!canStart"
440
+ @click="start()"
441
+ />
442
+ </template>
443
+ </template>
444
+ </UModal>
445
+ </template>
@@ -0,0 +1,23 @@
1
+ type __VLS_Props = {
2
+ source: string;
3
+ filter?: string;
4
+ };
5
+ type __VLS_ModelProps = {
6
+ 'open'?: boolean;
7
+ };
8
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ "update:open": (value: boolean) => any;
11
+ done: (payload: {
12
+ target: string;
13
+ copied: number;
14
+ }) => any;
15
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
16
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
17
+ onDone?: ((payload: {
18
+ target: string;
19
+ copied: number;
20
+ }) => any) | undefined;
21
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
+ declare const _default: typeof __VLS_export;
23
+ export default _default;
@@ -1,9 +1,13 @@
1
1
  type __VLS_Props = {
2
2
  collectionName: string;
3
3
  infoPath?: string;
4
+ persistState?: boolean;
5
+ stateKey?: string;
4
6
  };
5
7
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
8
  infoPath: string;
9
+ persistState: boolean;
10
+ stateKey: string;
7
11
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
12
  declare const _default: typeof __VLS_export;
9
13
  export default _default;