@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
@@ -2,6 +2,19 @@ type __VLS_Props = {
2
2
  selected: string[];
3
3
  deleting?: boolean;
4
4
  error?: string;
5
+ pageCount?: number;
6
+ total?: number;
7
+ allMatching?: boolean;
8
+ collecting?: {
9
+ loaded: number;
10
+ target?: number;
11
+ } | null;
12
+ note?: string;
13
+ confirmName?: string;
14
+ progress?: {
15
+ done: number;
16
+ total: number;
17
+ } | null;
5
18
  };
6
19
  declare const __VLS_template: () => {
7
20
  __VLS_Slots: {
@@ -12,11 +25,17 @@ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
12
25
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
26
  open: () => any;
14
27
  clear: () => any;
28
+ stop: () => any;
15
29
  confirm: () => any;
30
+ selectAll: () => any;
31
+ cancelCollect: () => any;
16
32
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
17
33
  onOpen?: (() => any) | undefined;
18
34
  onClear?: (() => any) | undefined;
35
+ onStop?: (() => any) | undefined;
19
36
  onConfirm?: (() => any) | undefined;
37
+ onSelectAll?: (() => any) | undefined;
38
+ onCancelCollect?: (() => any) | undefined;
20
39
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
40
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
22
41
  declare const _default: typeof __VLS_export;
@@ -7,6 +7,10 @@ type __VLS_Props = {
7
7
  }[];
8
8
  saving?: boolean;
9
9
  error?: string;
10
+ progress?: {
11
+ done: number;
12
+ total: number;
13
+ } | null;
10
14
  };
11
15
  type __VLS_ModelProps = {
12
16
  'open'?: boolean;
@@ -14,12 +18,14 @@ type __VLS_ModelProps = {
14
18
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
15
19
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
16
20
  "update:open": (value: boolean) => any;
21
+ stop: () => any;
17
22
  apply: (edit: {
18
23
  field: string;
19
24
  value: unknown;
20
25
  }) => any;
21
26
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
22
27
  "onUpdate:open"?: ((value: boolean) => any) | undefined;
28
+ onStop?: (() => any) | undefined;
23
29
  onApply?: ((edit: {
24
30
  field: string;
25
31
  value: unknown;
@@ -6,9 +6,10 @@ const props = defineProps({
6
6
  selected: { type: Number, required: true },
7
7
  fields: { type: Array, required: true },
8
8
  saving: { type: Boolean, required: false },
9
- error: { type: String, required: false }
9
+ error: { type: String, required: false },
10
+ progress: { type: [Object, null], required: false }
10
11
  });
11
- const emit = defineEmits(["apply"]);
12
+ const emit = defineEmits(["apply", "stop"]);
12
13
  const isOpen = defineModel("open", { type: Boolean, ...{ default: false } });
13
14
  const { t } = useI18n();
14
15
  const field = ref("");
@@ -118,9 +119,29 @@ watch(() => props.saving, (now, before) => {
118
119
  :description="error"
119
120
  />
120
121
  </div>
122
+ <div
123
+ v-if="saving && progress"
124
+ class="mt-3 flex flex-col gap-1"
125
+ role="status"
126
+ data-test="edit-progress"
127
+ >
128
+ <UProgress
129
+ :model-value="progress.done"
130
+ :max="progress.total"
131
+ />
132
+ <span class="text-sm text-dimmed">{{ t("nuxtUiMongocamp.bulk.progressEdit", progress) }}</span>
133
+ </div>
121
134
  </template>
122
135
  <template #footer>
123
136
  <UButton
137
+ v-if="saving && progress"
138
+ :label="t('nuxtUiMongocamp.bulk.stop')"
139
+ color="neutral"
140
+ variant="soft"
141
+ @click="emit('stop')"
142
+ />
143
+ <UButton
144
+ v-else
124
145
  :label="t('nuxtUiMongocamp.common.cancel')"
125
146
  color="neutral"
126
147
  variant="ghost"
@@ -7,6 +7,10 @@ type __VLS_Props = {
7
7
  }[];
8
8
  saving?: boolean;
9
9
  error?: string;
10
+ progress?: {
11
+ done: number;
12
+ total: number;
13
+ } | null;
10
14
  };
11
15
  type __VLS_ModelProps = {
12
16
  'open'?: boolean;
@@ -14,12 +18,14 @@ type __VLS_ModelProps = {
14
18
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
15
19
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
16
20
  "update:open": (value: boolean) => any;
21
+ stop: () => any;
17
22
  apply: (edit: {
18
23
  field: string;
19
24
  value: unknown;
20
25
  }) => any;
21
26
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
22
27
  "onUpdate:open"?: ((value: boolean) => any) | undefined;
28
+ onStop?: (() => any) | undefined;
23
29
  onApply?: ((edit: {
24
30
  field: string;
25
31
  value: unknown;
@@ -0,0 +1,29 @@
1
+ type __VLS_Props = {
2
+ type?: 'bar' | 'area' | 'line' | 'donut';
3
+ data: Record<string, unknown>[];
4
+ index: string;
5
+ categories: {
6
+ key: string;
7
+ label: string;
8
+ }[];
9
+ chartLabel: string;
10
+ chartDescription?: string;
11
+ indexLabel?: string;
12
+ format?: (value: number) => string;
13
+ height?: number;
14
+ showTable?: boolean;
15
+ legend?: boolean;
16
+ emptyText?: string;
17
+ };
18
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
19
+ type: "area" | "line" | "bar" | "donut";
20
+ legend: boolean;
21
+ format: (value: number) => string;
22
+ indexLabel: string;
23
+ chartDescription: string;
24
+ height: number;
25
+ showTable: boolean;
26
+ emptyText: string;
27
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
+ declare const _default: typeof __VLS_export;
29
+ export default _default;
@@ -0,0 +1,129 @@
1
+ <script setup>
2
+ import { computed, onBeforeUnmount, onMounted, ref } from "vue";
3
+ import { useI18n } from "#imports";
4
+ import { shortenLabel } from "../utils/chartData";
5
+ const props = defineProps({
6
+ type: { type: String, required: false, default: "bar" },
7
+ data: { type: Array, required: true },
8
+ index: { type: String, required: true },
9
+ categories: { type: Array, required: true },
10
+ chartLabel: { type: String, required: true },
11
+ chartDescription: { type: String, required: false, default: void 0 },
12
+ indexLabel: { type: String, required: false, default: void 0 },
13
+ format: { type: Function, required: false, default: void 0 },
14
+ height: { type: Number, required: false, default: 260 },
15
+ showTable: { type: Boolean, required: false, default: true },
16
+ legend: { type: Boolean, required: false, default: void 0 },
17
+ emptyText: { type: String, required: false, default: void 0 }
18
+ });
19
+ const { t } = useI18n();
20
+ const root = ref(null);
21
+ const visible = ref(typeof IntersectionObserver === "undefined");
22
+ let observer;
23
+ onMounted(() => {
24
+ if (visible.value || !root.value) return;
25
+ observer = new IntersectionObserver((entries) => {
26
+ if (entries.some((e) => e.isIntersecting)) {
27
+ visible.value = true;
28
+ observer?.disconnect();
29
+ }
30
+ });
31
+ observer.observe(root.value);
32
+ });
33
+ onBeforeUnmount(() => observer?.disconnect());
34
+ const FALLBACK_COLORS = ["var(--ui-primary, #16a34a)", "#3b82f6", "#8b5cf6", "#f59e0b", "#f43f5e", "#06b6d4"];
35
+ const COLORS = FALLBACK_COLORS.map((fallback, i) => `var(--ui-chart-${i + 1}, ${fallback})`);
36
+ const CHART_UI = { base: "opacity-100" };
37
+ const AXIS_LABEL_MAX = 18;
38
+ const chartData = computed(() => {
39
+ if (props.type === "donut") return props.data;
40
+ const names = props.data.map((row) => String(row[props.index] ?? ""));
41
+ const short = names.map((name) => shortenLabel(name, AXIS_LABEL_MAX));
42
+ const counts = /* @__PURE__ */ new Map();
43
+ for (const name of short) counts.set(name, (counts.get(name) ?? 0) + 1);
44
+ return props.data.map((row, i) => ({ ...row, [props.index]: counts.get(short[i]) > 1 ? names[i] : short[i] }));
45
+ });
46
+ const columns = computed(() => props.type === "donut" ? props.categories.slice(0, 1) : props.categories);
47
+ const show = (value) => typeof value === "number" && props.format ? props.format(value) : String(value ?? "");
48
+ </script>
49
+
50
+ <template>
51
+ <div
52
+ ref="root"
53
+ class="flex flex-col gap-2"
54
+ >
55
+ <p
56
+ v-if="data.length === 0 && emptyText"
57
+ class="text-sm text-dimmed"
58
+ data-test="chart-empty-text"
59
+ >
60
+ {{ emptyText }}
61
+ </p>
62
+ <template v-else-if="data.length > 0">
63
+ <LazyUChart
64
+ v-if="visible"
65
+ :type="type"
66
+ :data="chartData"
67
+ :index="index"
68
+ :categories="categories"
69
+ :colors="COLORS"
70
+ :ui="CHART_UI"
71
+ :aria-label="chartLabel"
72
+ :aria-description="chartDescription"
73
+ :format="format"
74
+ :legend="legend ?? (type === 'donut' || categories.length > 1)"
75
+ :height="height"
76
+ :points="false"
77
+ />
78
+ <div
79
+ v-else
80
+ :style="{ height: `${height}px` }"
81
+ aria-hidden="true"
82
+ />
83
+ <details
84
+ v-if="showTable"
85
+ class="text-sm"
86
+ >
87
+ <summary class="cursor-pointer text-dimmed">
88
+ {{ t("nuxtUiMongocamp.charts.showData") }}
89
+ </summary>
90
+ <table
91
+ class="mt-2 w-full text-left text-xs"
92
+ data-test="chart-table"
93
+ >
94
+ <thead>
95
+ <tr>
96
+ <th class="pr-3 font-medium">
97
+ {{ indexLabel ?? t("nuxtUiMongocamp.charts.columnValue") }}
98
+ </th>
99
+ <th
100
+ v-for="column in columns"
101
+ :key="column.key"
102
+ class="pr-3 font-medium"
103
+ >
104
+ {{ column.label }}
105
+ </th>
106
+ </tr>
107
+ </thead>
108
+ <tbody>
109
+ <tr
110
+ v-for="(row, rowIndex) in data"
111
+ :key="rowIndex"
112
+ >
113
+ <td class="pr-3 font-mono">
114
+ {{ String(row[index] ?? "") }}
115
+ </td>
116
+ <td
117
+ v-for="column in columns"
118
+ :key="column.key"
119
+ class="pr-3"
120
+ >
121
+ {{ show(row[column.key]) }}
122
+ </td>
123
+ </tr>
124
+ </tbody>
125
+ </table>
126
+ </details>
127
+ </template>
128
+ </div>
129
+ </template>
@@ -0,0 +1,29 @@
1
+ type __VLS_Props = {
2
+ type?: 'bar' | 'area' | 'line' | 'donut';
3
+ data: Record<string, unknown>[];
4
+ index: string;
5
+ categories: {
6
+ key: string;
7
+ label: string;
8
+ }[];
9
+ chartLabel: string;
10
+ chartDescription?: string;
11
+ indexLabel?: string;
12
+ format?: (value: number) => string;
13
+ height?: number;
14
+ showTable?: boolean;
15
+ legend?: boolean;
16
+ emptyText?: string;
17
+ };
18
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
19
+ type: "area" | "line" | "bar" | "donut";
20
+ legend: boolean;
21
+ format: (value: number) => string;
22
+ indexLabel: string;
23
+ chartDescription: string;
24
+ height: number;
25
+ showTable: boolean;
26
+ emptyText: string;
27
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
+ declare const _default: typeof __VLS_export;
29
+ export default _default;
@@ -0,0 +1,15 @@
1
+ import type { ChartKind } from '../utils/collectionChart.js';
2
+ type __VLS_Props = {
3
+ collectionName: string;
4
+ field: string;
5
+ kind?: ChartKind;
6
+ top?: number;
7
+ buckets?: number;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
10
+ kind: ChartKind;
11
+ buckets: number;
12
+ top: number;
13
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
@@ -0,0 +1,199 @@
1
+ <script setup>
2
+ import { computed, onBeforeUnmount, ref, watch } from "vue";
3
+ import { useI18n } from "#imports";
4
+ import { useMongocampAggregation } from "../composables/useMongocampAggregation";
5
+ import { analyzeSamples } from "../utils/analyzeSamples";
6
+ import { chartKindFor, chartRequest, chartTypeFor, DEFAULT_BUCKETS, DEFAULT_TOP, dominantKind, highestPoint, MAX_PERIODS, rowsToPoints } from "../utils/collectionChart";
7
+ const props = defineProps({
8
+ collectionName: { type: String, required: true },
9
+ field: { type: String, required: true },
10
+ kind: { type: String, required: false, default: void 0 },
11
+ top: { type: Number, required: false, default: DEFAULT_TOP },
12
+ buckets: { type: Number, required: false, default: DEFAULT_BUCKETS }
13
+ });
14
+ const { t } = useI18n();
15
+ const { runAggregation, sampleDocuments, describeAggregationError } = useMongocampAggregation();
16
+ const status = ref("loading");
17
+ const current = ref(void 0);
18
+ const detectedType = ref(void 0);
19
+ const points = ref([]);
20
+ const total = ref(0);
21
+ const unit = ref("month");
22
+ const error = ref(null);
23
+ let detected;
24
+ let run = 0;
25
+ let controller;
26
+ const unitItems = computed(() => ["year", "month", "day"].map((value) => ({ value, label: t(`nuxtUiMongocamp.charts.unit${value.charAt(0).toUpperCase()}${value.slice(1)}`) })));
27
+ async function load() {
28
+ controller?.abort();
29
+ const own = new AbortController();
30
+ controller = own;
31
+ const mine = ++run;
32
+ status.value = "loading";
33
+ error.value = null;
34
+ points.value = [];
35
+ try {
36
+ let chartKind = props.kind;
37
+ if (!chartKind) {
38
+ const key = `${props.collectionName}\0${props.field}`;
39
+ if (detected?.key !== key) {
40
+ const { rows } = await sampleDocuments(props.collectionName, 200);
41
+ if (mine !== run) return;
42
+ const found = dominantKind(analyzeSamples(rows), props.field);
43
+ detected = { key, kind: chartKindFor(found), type: found };
44
+ }
45
+ detectedType.value = detected.type;
46
+ chartKind = detected.kind;
47
+ if (!chartKind) {
48
+ status.value = detected.type === void 0 ? "unknown" : "unsupported";
49
+ return;
50
+ }
51
+ }
52
+ current.value = chartKind;
53
+ const request = chartRequest(chartKind, props.field, { top: props.top, buckets: props.buckets, unit: unit.value });
54
+ if (!request) {
55
+ status.value = "invalid";
56
+ return;
57
+ }
58
+ const result = await runAggregation(props.collectionName, request.pipeline, { page: 1, rowsPerPage: request.rowsPerPage }, { signal: own.signal });
59
+ if (mine !== run) return;
60
+ points.value = rowsToPoints(chartKind, result.rows, t("nuxtUiMongocamp.charts.noneLabel"));
61
+ total.value = result.total;
62
+ status.value = points.value.length === 0 ? "empty" : "ready";
63
+ } catch (e) {
64
+ if (mine !== run || own.signal.aborted) return;
65
+ error.value = await describeAggregationError(e);
66
+ if (mine === run) status.value = "error";
67
+ }
68
+ }
69
+ watch(() => [props.collectionName, props.field, props.kind, props.top, props.buckets], load, { immediate: true });
70
+ watch(unit, () => {
71
+ if (current.value === "dates") void load();
72
+ });
73
+ onBeforeUnmount(() => {
74
+ controller?.abort();
75
+ run++;
76
+ });
77
+ const titleKey = computed(() => ({ values: "titleValues", dates: "titleDates", numbers: "titleNumbers" })[current.value ?? "values"]);
78
+ const title = computed(() => t(`nuxtUiMongocamp.charts.${titleKey.value}`));
79
+ const chartType = computed(() => chartTypeFor(current.value ?? "values", points.value.length));
80
+ const categories = computed(() => [{ key: "count", label: t("nuxtUiMongocamp.charts.seriesLabel") }]);
81
+ const ariaLabel = computed(() => t("nuxtUiMongocamp.charts.ariaLabel", { title: title.value, field: props.field }));
82
+ const ariaDescription = computed(() => {
83
+ const best = highestPoint(points.value);
84
+ if (!best) return "";
85
+ const common = { shown: points.value.length, label: best.label, count: best.count };
86
+ if (current.value === "dates") return t("nuxtUiMongocamp.charts.ariaDescriptionDates", { ...common, first: points.value[0].label, last: points.value.at(-1).label });
87
+ return t(current.value === "numbers" ? "nuxtUiMongocamp.charts.ariaDescriptionNumbers" : "nuxtUiMongocamp.charts.ariaDescriptionValues", common);
88
+ });
89
+ const note = computed(() => {
90
+ if (current.value === "values") return total.value > points.value.length ? t("nuxtUiMongocamp.charts.noteValues", { shown: points.value.length, total: total.value }) : t("nuxtUiMongocamp.charts.noteValuesAll", { total: total.value });
91
+ if (current.value === "dates") return total.value > MAX_PERIODS ? t("nuxtUiMongocamp.charts.notePeriods", { shown: points.value.length, total: total.value }) : "";
92
+ return t("nuxtUiMongocamp.charts.noteNumbers");
93
+ });
94
+ const unsupportedType = computed(() => t(`nuxtUiMongocamp.charts.type${(detectedType.value ?? "null").charAt(0).toUpperCase()}${(detectedType.value ?? "null").slice(1)}`));
95
+ </script>
96
+
97
+ <template>
98
+ <div
99
+ class="flex flex-col gap-3"
100
+ data-test="collection-chart"
101
+ >
102
+ <div class="flex flex-wrap items-center justify-between gap-2">
103
+ <h3 class="text-sm font-semibold">
104
+ {{ title }} <span class="font-mono font-normal text-dimmed">{{ field }}</span>
105
+ </h3>
106
+ <div
107
+ v-if="current === 'dates'"
108
+ class="flex items-center gap-2"
109
+ >
110
+ <span class="text-xs text-dimmed">{{ t("nuxtUiMongocamp.charts.unitLabel") }}</span>
111
+ <USelect
112
+ v-model="unit"
113
+ :items="unitItems"
114
+ size="sm"
115
+ class="w-28"
116
+ :aria-label="t('nuxtUiMongocamp.charts.unitLabel')"
117
+ />
118
+ </div>
119
+ </div>
120
+
121
+ <p
122
+ v-if="status === 'loading'"
123
+ class="text-sm text-dimmed"
124
+ role="status"
125
+ data-test="chart-loading"
126
+ >
127
+ {{ t("nuxtUiMongocamp.charts.loading") }}
128
+ </p>
129
+
130
+ <UAlert
131
+ v-else-if="status === 'error' && error"
132
+ color="error"
133
+ variant="subtle"
134
+ icon="i-lucide-circle-alert"
135
+ :title="t('nuxtUiMongocamp.charts.failedTitle')"
136
+ :description="error.message"
137
+ data-test="chart-error"
138
+ >
139
+ <template #actions>
140
+ <UButton
141
+ :label="t('nuxtUiMongocamp.charts.retry')"
142
+ color="error"
143
+ variant="subtle"
144
+ icon="i-lucide-refresh-cw"
145
+ @click="load"
146
+ />
147
+ </template>
148
+ </UAlert>
149
+
150
+ <p
151
+ v-else-if="status === 'unsupported'"
152
+ class="text-sm text-dimmed"
153
+ data-test="chart-unsupported"
154
+ >
155
+ {{ t("nuxtUiMongocamp.charts.unsupported", { type: unsupportedType }) }}
156
+ </p>
157
+ <p
158
+ v-else-if="status === 'unknown'"
159
+ class="text-sm text-dimmed"
160
+ data-test="chart-unknown"
161
+ >
162
+ {{ t("nuxtUiMongocamp.charts.unknownField", { field }) }}
163
+ </p>
164
+ <p
165
+ v-else-if="status === 'invalid'"
166
+ class="text-sm text-error"
167
+ data-test="chart-invalid"
168
+ >
169
+ {{ t("nuxtUiMongocamp.charts.invalidField") }}
170
+ </p>
171
+ <p
172
+ v-else-if="status === 'empty'"
173
+ class="text-sm text-dimmed"
174
+ data-test="chart-empty"
175
+ >
176
+ {{ t("nuxtUiMongocamp.charts.empty", { field }) }}
177
+ </p>
178
+
179
+ <template v-else>
180
+ <MongocampChart
181
+ :type="chartType"
182
+ :data="points"
183
+ index="label"
184
+ :categories="categories"
185
+ :chart-label="ariaLabel"
186
+ :chart-description="ariaDescription"
187
+ :legend="false"
188
+ :height="260"
189
+ />
190
+ <p
191
+ v-if="note"
192
+ class="text-xs text-dimmed"
193
+ data-test="chart-note"
194
+ >
195
+ {{ note }}
196
+ </p>
197
+ </template>
198
+ </div>
199
+ </template>
@@ -0,0 +1,15 @@
1
+ import type { ChartKind } from '../utils/collectionChart.js';
2
+ type __VLS_Props = {
3
+ collectionName: string;
4
+ field: string;
5
+ kind?: ChartKind;
6
+ top?: number;
7
+ buckets?: number;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
10
+ kind: ChartKind;
11
+ buckets: number;
12
+ top: number;
13
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
@@ -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;