@sfxcode/nuxt-ui-mongocamp 2.0.0 → 2.1.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.
- package/dist/module.json +1 -1
- package/dist/runtime/components/MongocampCollectionData.vue +3 -11
- package/dist/runtime/components/MongocampSettings.d.vue.ts +0 -3
- package/dist/runtime/components/MongocampSettings.vue +2 -48
- package/dist/runtime/components/MongocampSettings.vue.d.ts +0 -3
- package/dist/runtime/composables/useMongocampAggregation.d.ts +1 -2
- package/dist/runtime/composables/useMongocampAggregation.js +3 -6
- package/dist/runtime/composables/useMongocampBulkByFilter.js +1 -1
- package/dist/runtime/composables/useMongocampExportAll.d.ts +7 -6
- package/dist/runtime/composables/useMongocampExportAll.js +18 -22
- package/dist/runtime/composables/useMongocampQuery.d.ts +5 -5
- package/dist/runtime/composables/useMongocampQuery.js +1 -5
- package/dist/runtime/composables/useMongocampSystem.d.ts +3 -9
- package/dist/runtime/composables/useMongocampSystem.js +1 -9
- package/dist/runtime/locales/de.json +1 -8
- package/dist/runtime/locales/en.json +1 -8
- package/dist/runtime/utils/aggregationErrors.d.ts +0 -4
- package/dist/runtime/utils/aggregationErrors.js +0 -7
- package/dist/runtime/utils/exportTrailer.d.ts +10 -0
- package/dist/runtime/utils/exportTrailer.js +28 -0
- package/dist/runtime/utils/filterBuilder.js +7 -1
- package/package.json +3 -3
package/dist/module.json
CHANGED
|
@@ -783,7 +783,7 @@ const chartField = ref("");
|
|
|
783
783
|
const chartFields = computed(() => filterFields.value.filter((f) => f.type === "string" || f.type === "number" || f.type === "date-time" || f.type === "boolean").map((f) => f.key));
|
|
784
784
|
const chartItems = computed(() => chartFields.value.map((key) => ({ label: key, value: key })));
|
|
785
785
|
const chartFilter = computed(() => buildLuceneFilter(filterText.value));
|
|
786
|
-
const
|
|
786
|
+
const aggregateLinkTooLong = computed(() => isFilterTooLong(chartFilter.value));
|
|
787
787
|
function openChart() {
|
|
788
788
|
if (!chartFields.value.includes(chartField.value)) chartField.value = chartFields.value[0] ?? "";
|
|
789
789
|
chartOpen.value = true;
|
|
@@ -944,7 +944,7 @@ defineExpose({ refresh: init });
|
|
|
944
944
|
v-if="aggregatePath && !isBucketCollection(collectionName)"
|
|
945
945
|
icon="i-lucide-sigma"
|
|
946
946
|
v-bind="ui.iconButton"
|
|
947
|
-
:disabled="
|
|
947
|
+
:disabled="aggregateLinkTooLong"
|
|
948
948
|
:to="{ path: `${aggregatePath}/${collectionName}/aggregate`, query: chartFilter ? { filter: chartFilter, ...query.matchCase ? { matchCase: 'true' } : {} } : {} }"
|
|
949
949
|
:aria-label="t('nuxtUiMongocamp.collectionData.aggregateTooltip')"
|
|
950
950
|
data-test="aggregate-link"
|
|
@@ -1103,16 +1103,8 @@ defineExpose({ refresh: init });
|
|
|
1103
1103
|
:aria-label="t('nuxtUiMongocamp.collectionData.chartField')"
|
|
1104
1104
|
/>
|
|
1105
1105
|
</UFormField>
|
|
1106
|
-
<UAlert
|
|
1107
|
-
v-if="chartFilterTooLong"
|
|
1108
|
-
color="warning"
|
|
1109
|
-
:variant="ui.alert.variant"
|
|
1110
|
-
icon="i-lucide-triangle-alert"
|
|
1111
|
-
:description="t('nuxtUiMongocamp.collectionData.chartTooLong')"
|
|
1112
|
-
data-test="chart-too-long"
|
|
1113
|
-
/>
|
|
1114
1106
|
<MongocampCollectionCharts
|
|
1115
|
-
v-
|
|
1107
|
+
v-if="chartOpen && chartField"
|
|
1116
1108
|
:collection-name="collectionName"
|
|
1117
1109
|
:field="chartField"
|
|
1118
1110
|
:filter="chartFilter"
|
|
@@ -3,8 +3,6 @@ type __VLS_Props = {
|
|
|
3
3
|
hideHeading?: boolean;
|
|
4
4
|
/** Hide the refresh button. */
|
|
5
5
|
hideRefresh?: boolean;
|
|
6
|
-
/** Hide the plugins card (the plugins request is skipped too). */
|
|
7
|
-
hidePlugins?: boolean;
|
|
8
6
|
/** Hide the cluster card (the cluster request is skipped too). */
|
|
9
7
|
hideCluster?: boolean;
|
|
10
8
|
/** Hide the whole configuration section — search, note and table (the configuration request is skipped too). */
|
|
@@ -28,7 +26,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
28
26
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
29
27
|
hideRefresh: boolean;
|
|
30
28
|
hideHeading: boolean;
|
|
31
|
-
hidePlugins: boolean;
|
|
32
29
|
hideCluster: boolean;
|
|
33
30
|
hideConfigurations: boolean;
|
|
34
31
|
hideSearch: boolean;
|
|
@@ -7,7 +7,6 @@ const PAGE_SIZE = 10;
|
|
|
7
7
|
const props = defineProps({
|
|
8
8
|
hideHeading: { type: Boolean, required: false, default: false },
|
|
9
9
|
hideRefresh: { type: Boolean, required: false, default: false },
|
|
10
|
-
hidePlugins: { type: Boolean, required: false, default: false },
|
|
11
10
|
hideCluster: { type: Boolean, required: false, default: false },
|
|
12
11
|
hideConfigurations: { type: Boolean, required: false, default: false },
|
|
13
12
|
hideSearch: { type: Boolean, required: false, default: false },
|
|
@@ -16,10 +15,9 @@ const props = defineProps({
|
|
|
16
15
|
});
|
|
17
16
|
const { t } = useI18n();
|
|
18
17
|
const ui = useMongocampUi();
|
|
19
|
-
const {
|
|
18
|
+
const { listConfigurations, getCluster } = useMongocampSystem();
|
|
20
19
|
const { isAdmin } = useMongocampRoles();
|
|
21
20
|
const configurations = ref([]);
|
|
22
|
-
const plugins = ref(null);
|
|
23
21
|
const cluster = ref(null);
|
|
24
22
|
const loading = ref(false);
|
|
25
23
|
const loadError = ref(null);
|
|
@@ -31,18 +29,15 @@ async function fetchSettings() {
|
|
|
31
29
|
loading.value = true;
|
|
32
30
|
loadError.value = null;
|
|
33
31
|
try {
|
|
34
|
-
const [
|
|
35
|
-
props.hidePlugins ? Promise.resolve(null) : getSettings(),
|
|
32
|
+
const [rows, loadedCluster] = await Promise.all([
|
|
36
33
|
props.hideConfigurations ? Promise.resolve([]) : listConfigurations(),
|
|
37
34
|
// optional context: a failing cluster endpoint must not take the settings page down
|
|
38
35
|
props.hideCluster ? Promise.resolve(null) : getCluster().catch(() => null)
|
|
39
36
|
]);
|
|
40
|
-
plugins.value = loadedPlugins;
|
|
41
37
|
cluster.value = loadedCluster;
|
|
42
38
|
configurations.value = rows;
|
|
43
39
|
} catch (e) {
|
|
44
40
|
loadError.value = e;
|
|
45
|
-
plugins.value = null;
|
|
46
41
|
cluster.value = null;
|
|
47
42
|
configurations.value = [];
|
|
48
43
|
} finally {
|
|
@@ -82,11 +77,6 @@ const columns = computed(() => [
|
|
|
82
77
|
cell: ({ row }) => row.original.needsRestart ? h(UBadge, { label: t("nuxtUiMongocamp.settings.restartNeeded"), color: "warning", variant: ui.value.badge.variant }) : h("span", { class: "text-dimmed" }, "\u2014")
|
|
83
78
|
}
|
|
84
79
|
]);
|
|
85
|
-
const pluginGroups = computed(() => [
|
|
86
|
-
{ key: "routes", label: t("nuxtUiMongocamp.settings.routesPlugins"), items: plugins.value?.routesPlugins ?? [] },
|
|
87
|
-
{ key: "file", label: t("nuxtUiMongocamp.settings.filePlugins"), items: plugins.value?.filePlugins ?? [] },
|
|
88
|
-
{ key: "ignored", label: t("nuxtUiMongocamp.settings.ignoredPlugins"), items: plugins.value?.ignoredPlugins ?? [] }
|
|
89
|
-
]);
|
|
90
80
|
fetchSettings();
|
|
91
81
|
defineExpose({ refresh: fetchSettings });
|
|
92
82
|
</script>
|
|
@@ -136,42 +126,6 @@ defineExpose({ refresh: fetchSettings });
|
|
|
136
126
|
@retry="fetchSettings"
|
|
137
127
|
/>
|
|
138
128
|
|
|
139
|
-
<UCard v-if="plugins && !hidePlugins">
|
|
140
|
-
<template #header>
|
|
141
|
-
<span class="font-semibold">{{ t("nuxtUiMongocamp.settings.pluginsHeading") }}</span>
|
|
142
|
-
</template>
|
|
143
|
-
<div class="grid gap-4 sm:grid-cols-3">
|
|
144
|
-
<section
|
|
145
|
-
v-for="group in pluginGroups"
|
|
146
|
-
:key="group.key"
|
|
147
|
-
class="flex flex-col gap-1"
|
|
148
|
-
>
|
|
149
|
-
<h3 class="text-sm font-semibold">
|
|
150
|
-
{{ group.label }}
|
|
151
|
-
</h3>
|
|
152
|
-
<div
|
|
153
|
-
v-if="group.items.length"
|
|
154
|
-
class="flex flex-wrap gap-1"
|
|
155
|
-
>
|
|
156
|
-
<UBadge
|
|
157
|
-
v-for="item in group.items"
|
|
158
|
-
:key="item"
|
|
159
|
-
:label="item"
|
|
160
|
-
color="neutral"
|
|
161
|
-
:variant="ui.badge.variant"
|
|
162
|
-
size="sm"
|
|
163
|
-
/>
|
|
164
|
-
</div>
|
|
165
|
-
<p
|
|
166
|
-
v-else
|
|
167
|
-
class="text-sm text-dimmed"
|
|
168
|
-
>
|
|
169
|
-
{{ t("nuxtUiMongocamp.settings.noPlugins") }}
|
|
170
|
-
</p>
|
|
171
|
-
</section>
|
|
172
|
-
</div>
|
|
173
|
-
</UCard>
|
|
174
|
-
|
|
175
129
|
<UCard v-if="cluster && !hideCluster">
|
|
176
130
|
<template #header>
|
|
177
131
|
<span class="font-semibold">{{ t("nuxtUiMongocamp.settings.clusterHeading") }}</span>
|
|
@@ -3,8 +3,6 @@ type __VLS_Props = {
|
|
|
3
3
|
hideHeading?: boolean;
|
|
4
4
|
/** Hide the refresh button. */
|
|
5
5
|
hideRefresh?: boolean;
|
|
6
|
-
/** Hide the plugins card (the plugins request is skipped too). */
|
|
7
|
-
hidePlugins?: boolean;
|
|
8
6
|
/** Hide the cluster card (the cluster request is skipped too). */
|
|
9
7
|
hideCluster?: boolean;
|
|
10
8
|
/** Hide the whole configuration section — search, note and table (the configuration request is skipped too). */
|
|
@@ -28,7 +26,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
28
26
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
29
27
|
hideRefresh: boolean;
|
|
30
28
|
hideHeading: boolean;
|
|
31
|
-
hidePlugins: boolean;
|
|
32
29
|
hideCluster: boolean;
|
|
33
30
|
hideConfigurations: boolean;
|
|
34
31
|
hideSearch: boolean;
|
|
@@ -15,8 +15,7 @@ export interface AggregationOptions {
|
|
|
15
15
|
allowStatsStages?: boolean;
|
|
16
16
|
/**
|
|
17
17
|
* A Lucene filter (the syntax of the document list) applied by the server as the first `$match` (server 1.7.0), so an
|
|
18
|
-
* aggregation can follow what a table shows. It travels in the
|
|
19
|
-
* with a `FilterTooLongError` instead of becoming an opaque network failure.
|
|
18
|
+
* aggregation can follow what a table shows. It travels in the request body (server 2.2), so its length has no limit.
|
|
20
19
|
*/
|
|
21
20
|
filter?: string;
|
|
22
21
|
/** Match the wildcards of `filter` without regard to case (server 2.0 matches them case-sensitively otherwise). */
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { useMongocampClientApi, useI18n } from "#imports";
|
|
2
2
|
import { useMongocampError } from "./useMongocampError.js";
|
|
3
3
|
import { findForbidden, STATS_OPERATORS } from "../utils/aggregationPipeline.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ForbiddenPipelineError } from "../utils/aggregationErrors.js";
|
|
5
5
|
import { sensitiveFieldReferences, sensitiveFieldsOf, sensitiveFieldsOfPipeline, withoutFieldsDeep } from "../utils/sensitiveFields.js";
|
|
6
6
|
import { fieldPathsOf } from "../utils/fieldDetails.js";
|
|
7
|
-
import { isFilterTooLong, MAX_ENCODED_FILTER_LENGTH } from "../utils/requestLimits.js";
|
|
8
7
|
import { stripServerFields } from "../utils/aggregationResult.js";
|
|
9
8
|
import { readJsonKeepingLongs } from "../utils/bigIntJson.js";
|
|
10
9
|
import { headerNumber } from "../utils/paginationHeaders.js";
|
|
@@ -37,15 +36,14 @@ export function useMongocampAggregation() {
|
|
|
37
36
|
if (hiddenUses.length > 0) {
|
|
38
37
|
throw new ForbiddenPipelineError(hiddenUses.map((use) => ({ stageIndex: use.stageIndex, operator: use.reference, path: use.reference, sensitive: true })));
|
|
39
38
|
}
|
|
40
|
-
if (isFilterTooLong(options.filter)) throw new FilterTooLongError(MAX_ENCODED_FILTER_LENGTH);
|
|
41
39
|
const page = paging.page ?? 1;
|
|
42
40
|
const response = await collectionApi.aggregateRaw({
|
|
43
41
|
collectionName,
|
|
44
42
|
// the generated type says string values; the server takes any JSON. allowDiskUse is required.
|
|
45
|
-
|
|
43
|
+
// the filter goes in the body (server 2.2) — no URL limit; in both places the server answers 400 (code 4004)
|
|
44
|
+
mongoAggregateRequest: { pipeline, allowDiskUse: false, filter: options.filter?.trim() ? options.filter : void 0 },
|
|
46
45
|
rowsPerPage: paging.rowsPerPage,
|
|
47
46
|
page,
|
|
48
|
-
filter: options.filter?.trim() ? options.filter : void 0,
|
|
49
47
|
filterCaseInsensitive: options.filter?.trim() ? options.filterCaseInsensitive : void 0,
|
|
50
48
|
count: options.skipCount ? "none" : void 0,
|
|
51
49
|
extendedJson: "relaxed"
|
|
@@ -80,7 +78,6 @@ export function useMongocampAggregation() {
|
|
|
80
78
|
return runAggregation(collectionName, [{ stage: "$sample", value: { size: clamped } }], { page: 1, rowsPerPage: clamped }, { skipCount: true });
|
|
81
79
|
}
|
|
82
80
|
async function describeAggregationError(error) {
|
|
83
|
-
if (error instanceof FilterTooLongError) return { kind: "other", message: t("nuxtUiMongocamp.aggregation.errors.filterTooLong", { max: error.max }) };
|
|
84
81
|
if (error instanceof ForbiddenPipelineError) {
|
|
85
82
|
const first = error.findings[0];
|
|
86
83
|
if (first?.sensitive) return { kind: "forbidden", message: t("nuxtUiMongocamp.aggregation.errors.sensitiveField", { field: first.operator }) };
|
|
@@ -5,7 +5,7 @@ export function useMongocampBulkByFilter() {
|
|
|
5
5
|
const clean = (filter) => filter && filter.trim() !== "" ? filter : void 0;
|
|
6
6
|
async function countDocuments(collectionName, filter, options) {
|
|
7
7
|
const { signal, filterCaseInsensitive } = filterCallOptions(options);
|
|
8
|
-
const response = await documentApi.
|
|
8
|
+
const response = await documentApi.countDocumentsByBody({ collectionName, countRequest: { filter: clean(filter) }, filterCaseInsensitive }, signal ? { signal } : void 0);
|
|
9
9
|
return response.count;
|
|
10
10
|
}
|
|
11
11
|
async function deleteByFilter(collectionName, filter, options) {
|
|
@@ -2,7 +2,7 @@ import type { ExportFormat } from '../utils/exportDocuments.js';
|
|
|
2
2
|
export interface ExportCollectionOptions {
|
|
3
3
|
collection: string;
|
|
4
4
|
format: ExportFormat;
|
|
5
|
-
/** Lucene filter: export only the documents that match (the current filter of a table).
|
|
5
|
+
/** Lucene filter: export only the documents that match (the current filter of a table). Sent in the request body (server 2.2), so any length. */
|
|
6
6
|
filter?: string;
|
|
7
7
|
/** Match the wildcards of `filter` without regard to case (server 2.0 matches them case-sensitively otherwise). */
|
|
8
8
|
filterCaseInsensitive?: boolean;
|
|
@@ -19,7 +19,7 @@ export interface ExportCollectionOptions {
|
|
|
19
19
|
* exactly (larger files). Ignored for CSV, which stays plain.
|
|
20
20
|
*/
|
|
21
21
|
extendedJson?: 'relaxed' | 'canonical';
|
|
22
|
-
/** How many documents the caller expects (the count of the filter): a file
|
|
22
|
+
/** How many documents the caller expects (the count of the filter): the document count of a complete JSON file (NDJSON and CSV report their own). */
|
|
23
23
|
expected?: number;
|
|
24
24
|
/** After every chunk of the stream. */
|
|
25
25
|
onProgress?: (progress: ExportProgress) => void;
|
|
@@ -42,17 +42,18 @@ export interface ExportResult {
|
|
|
42
42
|
mimeType: string;
|
|
43
43
|
format: ExportFormat;
|
|
44
44
|
bytes: number;
|
|
45
|
-
/** Documents in the file: exact for NDJSON (
|
|
45
|
+
/** Documents in the file: exact for NDJSON and CSV (the server's end marker); for JSON the expected count when the file is complete. */
|
|
46
46
|
documents?: number;
|
|
47
47
|
/**
|
|
48
|
-
* The file is
|
|
49
|
-
*
|
|
48
|
+
* The file is **cut short**: the server ends a stream that fails midway with a normal `200`, so the file is checked — JSON
|
|
49
|
+
* must end with `]`, NDJSON and CSV must end with the server's end marker (`trailer=true`, server 2.2; the marker itself is
|
|
50
|
+
* removed from the file). Tell the user.
|
|
50
51
|
*/
|
|
51
52
|
incomplete: boolean;
|
|
52
53
|
}
|
|
53
54
|
/**
|
|
54
55
|
* Exports a whole collection, or every document matching a filter, as JSON, NDJSON or CSV — not just the rows on screen.
|
|
55
|
-
* The server streams the file (`
|
|
56
|
+
* The server streams the file (`POST …/documents/export`, server 2.2: filter, sort, projection and limit in the body): there is no document cap and the browser never parses
|
|
56
57
|
* a document. JSON and NDJSON files are relaxed Extended JSON (`{ "$oid" }`, `{ "$date" }`, `{ "$numberLong" }`, …), so they go
|
|
57
58
|
* back in through the importer with every type; CSV stays plain text (an integer beyond 2^53 keeps every digit).
|
|
58
59
|
* The file ends up in a `Blob` (the browser may keep it on disk) and is handed to the browser as a download.
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { useMongocampClientApi } from "#imports";
|
|
2
2
|
import { downloadBlob } from "../utils/exportRows.js";
|
|
3
3
|
import { EXPORT_MIME_TYPES, exportFilename } from "../utils/exportDocuments.js";
|
|
4
|
-
import {
|
|
5
|
-
import { isFilterTooLong, MAX_ENCODED_FILTER_LENGTH } from "../utils/requestLimits.js";
|
|
4
|
+
import { readExportTrailer } from "../utils/exportTrailer.js";
|
|
6
5
|
function countingStream(onProgress) {
|
|
7
6
|
const state = { bytes: 0, newlines: 0, last: 0 };
|
|
8
7
|
const stream = new TransformStream({
|
|
@@ -20,38 +19,35 @@ export function useMongocampExportAll() {
|
|
|
20
19
|
const { documentApi } = useMongocampClientApi();
|
|
21
20
|
async function exportCollection(options) {
|
|
22
21
|
const { collection, format, download = true } = options;
|
|
23
|
-
if (isFilterTooLong(options.filter)) throw new FilterTooLongError(MAX_ENCODED_FILTER_LENGTH);
|
|
24
22
|
const projection = options.projection?.length ? options.projection : options.columns?.length ? options.columns : void 0;
|
|
25
|
-
const
|
|
23
|
+
const filter = options.filter?.trim() ? options.filter : void 0;
|
|
24
|
+
const response = await documentApi.exportDocumentsByBodyRaw({
|
|
26
25
|
collectionName: collection,
|
|
26
|
+
exportRequest: { filter, sort: options.sort?.length ? options.sort : void 0, projection, limit: options.maxRows },
|
|
27
27
|
format,
|
|
28
|
-
|
|
29
|
-
filterCaseInsensitive: options.filter?.trim() ? options.filterCaseInsensitive : void 0,
|
|
30
|
-
sort: options.sort?.length ? options.sort : void 0,
|
|
31
|
-
projection,
|
|
32
|
-
limit: options.maxRows,
|
|
28
|
+
filterCaseInsensitive: filter ? options.filterCaseInsensitive : void 0,
|
|
33
29
|
// CSV is plain unless a format is asked for; the JSON formats keep their types
|
|
34
|
-
extendedJson: format === "csv" ? void 0 : options.extendedJson ?? "relaxed"
|
|
30
|
+
extendedJson: format === "csv" ? void 0 : options.extendedJson ?? "relaxed",
|
|
31
|
+
// an end (or error) marker as the last line, so a cut-off file can be told from a complete one; JSON has its `]`
|
|
32
|
+
trailer: format === "json" ? void 0 : true
|
|
35
33
|
}, options.signal ? { signal: options.signal } : void 0);
|
|
36
34
|
const mimeType = EXPORT_MIME_TYPES[format];
|
|
37
|
-
const { stream
|
|
35
|
+
const { stream } = countingStream(options.onProgress);
|
|
38
36
|
const body = response.raw.body;
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
const lines = body ? state.newlines + (state.last !== 10 && state.bytes > 0 ? 1 : 0) : 0;
|
|
42
|
-
const wanted = options.expected === void 0 ? void 0 : Math.min(options.expected, options.maxRows ?? Infinity);
|
|
37
|
+
const received = body ? await new Response(body.pipeThrough(stream), { headers: { "content-type": mimeType } }).blob() : await response.raw.blob();
|
|
38
|
+
let blob = received;
|
|
43
39
|
let incomplete;
|
|
44
40
|
let documents;
|
|
45
41
|
if (format === "json") {
|
|
46
|
-
incomplete = !(await blob.slice(Math.max(0,
|
|
47
|
-
if (!incomplete) documents =
|
|
48
|
-
} else if (format === "ndjson") {
|
|
49
|
-
documents = lines;
|
|
50
|
-
incomplete = wanted !== void 0 && lines < wanted;
|
|
42
|
+
incomplete = !(await blob.slice(Math.max(0, blob.size - 8)).text()).trimEnd().endsWith("]");
|
|
43
|
+
if (!incomplete) documents = options.expected === void 0 ? void 0 : Math.min(options.expected, options.maxRows ?? Infinity);
|
|
51
44
|
} else {
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
const trailer = await readExportTrailer(received, format);
|
|
46
|
+
blob = trailer.marker ? received.slice(0, trailer.cut, mimeType) : received;
|
|
47
|
+
incomplete = trailer.count === void 0;
|
|
48
|
+
documents = trailer.count;
|
|
54
49
|
}
|
|
50
|
+
const bytes = blob.size;
|
|
55
51
|
const filename = options.filename ?? exportFilename(collection, format);
|
|
56
52
|
if (download) downloadBlob(filename, blob);
|
|
57
53
|
return { blob, filename, mimeType, format, bytes, documents, incomplete };
|
|
@@ -33,9 +33,9 @@ export interface MongocampQueryHelper {
|
|
|
33
33
|
*
|
|
34
34
|
* Pass `null` (or `'*'`) for an open end (`[x TO *]`); both ends open is `exists(field)`.
|
|
35
35
|
*
|
|
36
|
-
* A date without a time is midnight UTC for the server
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* A date without a time is midnight UTC for the server; as the inclusive **upper** bound the server (2.2) covers that whole
|
|
37
|
+
* day — "up to 2024-06-15" includes the 15th. Characters that would break out of the range (brackets, quotes,
|
|
38
|
+
* whitespace…) in a bound are escaped.
|
|
39
39
|
*/
|
|
40
40
|
inRange: (fieldName: string, from: QueryValue, to: QueryValue) => string;
|
|
41
41
|
/**
|
|
@@ -125,8 +125,8 @@ export interface MongocampQueryHelper {
|
|
|
125
125
|
*/
|
|
126
126
|
hasItems: (fieldName: string, type?: ExistsFieldType) => string;
|
|
127
127
|
/**
|
|
128
|
-
* The whole UTC day `YYYY-MM-DD`: `field:[YYYY-MM-DD TO YYYY-MM-
|
|
129
|
-
*
|
|
128
|
+
* The whole UTC day `YYYY-MM-DD`: `field:[YYYY-MM-DD TO YYYY-MM-DD]` (the server, 2.2, lets a bare inclusive upper date
|
|
129
|
+
* cover its whole day). Throws a `TypeError` for anything that is not a real calendar date.
|
|
130
130
|
*/
|
|
131
131
|
onDay: (fieldName: string, day: string) => string;
|
|
132
132
|
/** `-field:[the whole UTC day]` — everything except that day (documents without the field included). */
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { escapeFieldName } from "../utils/escapeFieldName.js";
|
|
2
|
-
import { isIsoDateTimeString } from "../utils/isoDate.js";
|
|
3
2
|
import { isObjectIdHex } from "../utils/objectId.js";
|
|
4
3
|
import { useMongocampQueryBuilder } from "./useMongocampQueryBuilder.js";
|
|
5
4
|
import { idOf } from "../utils/relaxedValues.js";
|
|
@@ -12,9 +11,6 @@ function boundText(value) {
|
|
|
12
11
|
function escapeBound(value) {
|
|
13
12
|
return value.replace(/[\s[\]{}()"\\^~!&|]/g, "\\$&");
|
|
14
13
|
}
|
|
15
|
-
function endOfDay(value) {
|
|
16
|
-
return DATE_ONLY_REGEX.test(value) && isIsoDateTimeString(value) ? `${value}T23:59:59.999Z` : value;
|
|
17
|
-
}
|
|
18
14
|
function isSingleTerm(text) {
|
|
19
15
|
if (text.startsWith("(") || text.startsWith("-(")) return false;
|
|
20
16
|
let quoted = false;
|
|
@@ -74,7 +70,7 @@ export function useMongocampQuery() {
|
|
|
74
70
|
const upper = boundText(to);
|
|
75
71
|
if (lower === null && upper === null) return exists(fieldName);
|
|
76
72
|
const fromStr = lower === null ? "*" : escapeBound(lower);
|
|
77
|
-
const toStr = upper === null ? "*" : escapeBound(
|
|
73
|
+
const toStr = upper === null ? "*" : escapeBound(upper);
|
|
78
74
|
return fieldTerm(fieldName, q.range(fromStr, toStr));
|
|
79
75
|
}
|
|
80
76
|
function notInRange(fieldName, from, to) {
|
|
@@ -10,18 +10,13 @@ export interface ServerInfo {
|
|
|
10
10
|
/** The same version as numbers (`[9, 0, 4, 0]`), empty if the server sent none. */
|
|
11
11
|
mongoDbVersionArray: number[];
|
|
12
12
|
}
|
|
13
|
-
export interface ServerPlugins {
|
|
14
|
-
routesPlugins: string[];
|
|
15
|
-
filePlugins: string[];
|
|
16
|
-
ignoredPlugins: string[];
|
|
17
|
-
}
|
|
18
13
|
/**
|
|
19
14
|
* Read-only wrapper for databaseApi, applicationApi and the cluster view of systemApi. Deliberately read-only —
|
|
20
15
|
* deleteDatabase, shutdown and updateConfiguration are out of scope (cross-cutting, highly
|
|
21
16
|
* destructive) and not exposed. The server's settings and configuration payloads contain real secrets
|
|
22
|
-
* (auth secret, database credentials and host), so the settings methods never hand them out:
|
|
23
|
-
*
|
|
24
|
-
*
|
|
17
|
+
* (auth secret, database credentials and host), so the settings methods never hand them out: the
|
|
18
|
+
* configuration methods return rows that are already masked (see utils/configRows.ts). `GET /system/settings`
|
|
19
|
+
* is not used at all — since server 2.2 it holds nothing but that configuration map, secrets included.
|
|
25
20
|
*/
|
|
26
21
|
export declare function useMongocampSystem(): {
|
|
27
22
|
getCluster: () => Promise<ServerCluster>;
|
|
@@ -32,7 +27,6 @@ export declare function useMongocampSystem(): {
|
|
|
32
27
|
getDatabaseInfos: () => Promise<DatabaseInfo[]>;
|
|
33
28
|
getDatabaseInfo: (databaseName: string) => Promise<DatabaseInfo>;
|
|
34
29
|
listCollectionsByDatabase: (databaseName: string) => Promise<string[]>;
|
|
35
|
-
getSettings: () => Promise<ServerPlugins>;
|
|
36
30
|
listConfigurations: () => Promise<ConfigRow[]>;
|
|
37
31
|
getConfig: (configurationKey: string) => Promise<ConfigRow>;
|
|
38
32
|
};
|
|
@@ -18,14 +18,6 @@ export function useMongocampSystem() {
|
|
|
18
18
|
async function listCollectionsByDatabase(databaseName) {
|
|
19
19
|
return databaseApi.listCollectionsByDatabase({ databaseName }, withTimeout());
|
|
20
20
|
}
|
|
21
|
-
async function getSettings() {
|
|
22
|
-
const settings = await applicationApi.settings(withTimeout());
|
|
23
|
-
return {
|
|
24
|
-
routesPlugins: settings.routesPlugins ?? [],
|
|
25
|
-
filePlugins: settings.filePlugins ?? [],
|
|
26
|
-
ignoredPlugins: settings.ignoredPlugins ?? []
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
21
|
async function listConfigurations() {
|
|
30
22
|
return buildConfigRows(await applicationApi.listConfigurations(withTimeout()));
|
|
31
23
|
}
|
|
@@ -48,5 +40,5 @@ export function useMongocampSystem() {
|
|
|
48
40
|
async function getCapabilities() {
|
|
49
41
|
return systemApi.systemCapabilities(withTimeout());
|
|
50
42
|
}
|
|
51
|
-
return { getCluster, getServerInfo, getStats, getCapabilities, listDatabases, getDatabaseInfos, getDatabaseInfo, listCollectionsByDatabase,
|
|
43
|
+
return { getCluster, getServerInfo, getStats, getCapabilities, listDatabases, getDatabaseInfos, getDatabaseInfo, listCollectionsByDatabase, listConfigurations, getConfig };
|
|
52
44
|
}
|
|
@@ -256,7 +256,6 @@
|
|
|
256
256
|
"chartField": "Feld",
|
|
257
257
|
"chartScopeAll": "Alle {count} Dokumente der Sammlung. | Alle {count} Dokumente der Sammlung.",
|
|
258
258
|
"chartScopeFiltered": "Das {count} Dokument, das zum aktuellen Filter passt. | Die {count} Dokumente, die zum aktuellen Filter passen.",
|
|
259
|
-
"chartTooLong": "Der aktuelle Filter ist zu lang für eine Diagrammanfrage. Bitte zuerst einschränken.",
|
|
260
259
|
"aggregateTooltip": "Die passenden Dokumente aggregieren",
|
|
261
260
|
"sensitiveFieldsNote": "Passwörter und API-Keys sind ausgeblendet, und die Collection ist hier schreibgeschützt – Benutzer werden auf der Benutzerseite verwaltet."
|
|
262
261
|
},
|
|
@@ -348,11 +347,6 @@
|
|
|
348
347
|
"clusterHeading": "Cluster",
|
|
349
348
|
"clusterCoordinator": "Koordinator",
|
|
350
349
|
"clusterSiteMaster": "Site-Master",
|
|
351
|
-
"pluginsHeading": "Plugins",
|
|
352
|
-
"routesPlugins": "Routen-Plugins",
|
|
353
|
-
"filePlugins": "Datei-Plugins",
|
|
354
|
-
"ignoredPlugins": "Ignorierte Plugins",
|
|
355
|
-
"noPlugins": "Keine",
|
|
356
350
|
"searchPlaceholder": "Einstellungen durchsuchen...",
|
|
357
351
|
"maskedNote": "Geheime Werte (Passwörter, Schlüssel, Zugangsdaten, Hosts) werden nie angezeigt.",
|
|
358
352
|
"maskedHint": "Verborgen: dieser Wert ist geheim",
|
|
@@ -626,8 +620,7 @@
|
|
|
626
620
|
"forbidden": "Diese Pipeline verwendet {operator}, was hier nicht erlaubt ist.",
|
|
627
621
|
"sensitiveField": "Diese Pipeline liest {field}, ein ausgeblendetes Feld der MongoCamp-Benutzer (Passwort-Hash oder API-Key).",
|
|
628
622
|
"retryable": "Die Anfrage wurde auf dem Weg zum Server blockiert. Bitte erneut versuchen.",
|
|
629
|
-
"unavailable": "Der Server hat diese Anfrage nicht beantwortet. Versuche es erneut."
|
|
630
|
-
"filterTooLong": "Der Filter ist zu lang für ein Diagramm (höchstens {max} Zeichen). Bitte zuerst einschränken."
|
|
623
|
+
"unavailable": "Der Server hat diese Anfrage nicht beantwortet. Versuche es erneut."
|
|
631
624
|
},
|
|
632
625
|
"modeVisual": "Stufen",
|
|
633
626
|
"modeJson": "JSON",
|
|
@@ -256,7 +256,6 @@
|
|
|
256
256
|
"chartField": "Field",
|
|
257
257
|
"chartScopeAll": "All {count} document of the collection. | All {count} documents of the collection.",
|
|
258
258
|
"chartScopeFiltered": "The {count} document that match the current filter. | The {count} documents that match the current filter.",
|
|
259
|
-
"chartTooLong": "The current filter is too long to send with a chart request. Narrow it first.",
|
|
260
259
|
"aggregateTooltip": "Aggregate the matching documents",
|
|
261
260
|
"sensitiveFieldsNote": "Passwords and API keys are hidden, and the collection is read-only here — manage users on the users page."
|
|
262
261
|
},
|
|
@@ -348,11 +347,6 @@
|
|
|
348
347
|
"clusterHeading": "Cluster",
|
|
349
348
|
"clusterCoordinator": "coordinator",
|
|
350
349
|
"clusterSiteMaster": "site master",
|
|
351
|
-
"pluginsHeading": "Plugins",
|
|
352
|
-
"routesPlugins": "Route plugins",
|
|
353
|
-
"filePlugins": "File plugins",
|
|
354
|
-
"ignoredPlugins": "Ignored plugins",
|
|
355
|
-
"noPlugins": "None",
|
|
356
350
|
"searchPlaceholder": "Search settings...",
|
|
357
351
|
"maskedNote": "Secret values (passwords, keys, credentials, hosts) are never shown.",
|
|
358
352
|
"maskedHint": "Hidden: this value is a secret",
|
|
@@ -626,8 +620,7 @@
|
|
|
626
620
|
"forbidden": "This pipeline uses {operator}, which is not allowed here.",
|
|
627
621
|
"sensitiveField": "This pipeline reads {field}, a hidden field of MongoCamp's users (password hash or API key).",
|
|
628
622
|
"retryable": "The request was blocked on its way to the server. Try again.",
|
|
629
|
-
"unavailable": "The server did not answer this request. Try again."
|
|
630
|
-
"filterTooLong": "The filter is too long to chart ({max} characters at most). Narrow it first."
|
|
623
|
+
"unavailable": "The server did not answer this request. Try again."
|
|
631
624
|
},
|
|
632
625
|
"modeVisual": "Stages",
|
|
633
626
|
"modeJson": "JSON",
|
|
@@ -3,10 +3,6 @@ export declare class ForbiddenPipelineError extends Error {
|
|
|
3
3
|
findings: ForbiddenUse[];
|
|
4
4
|
constructor(findings: ForbiddenUse[]);
|
|
5
5
|
}
|
|
6
|
-
export declare class FilterTooLongError extends Error {
|
|
7
|
-
max: number;
|
|
8
|
-
constructor(max: number);
|
|
9
|
-
}
|
|
10
6
|
export interface ServerErrorInfo {
|
|
11
7
|
kind: 'mongo' | 'other';
|
|
12
8
|
message: string;
|
|
@@ -5,13 +5,6 @@ export class ForbiddenPipelineError extends Error {
|
|
|
5
5
|
this.name = "ForbiddenPipelineError";
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
export class FilterTooLongError extends Error {
|
|
9
|
-
constructor(max) {
|
|
10
|
-
super(`The filter is longer than ${max} characters`);
|
|
11
|
-
this.max = max;
|
|
12
|
-
this.name = "FilterTooLongError";
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
8
|
const MONGO_COMMAND_FAILED = /^Command failed with error \d+ \([^)]*\): '([\s\S]*?)' on server \S+?\.\s+The full response is[\s\S]*$/;
|
|
16
9
|
const SERVER_ADDRESS = / on server \S+?(?=\.(?:\s|$)|\s|$)/g;
|
|
17
10
|
const BARE_ADDRESS = /\b(?:\d{1,3}\.){3}\d{1,3}(?::\d+)?\b|\b[a-z0-9-]+(?:\.[a-z0-9-]+)+:\d{2,5}\b/gi;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ExportTrailer {
|
|
2
|
+
/** Documents the server wrote — only for a complete file (an end marker). */
|
|
3
|
+
count?: number;
|
|
4
|
+
/** The last line was a marker (end or error); `cut` is then where the file without it ends. */
|
|
5
|
+
marker: boolean;
|
|
6
|
+
/** Byte offset of the marker line: `blob.slice(0, cut)` is the file without it. */
|
|
7
|
+
cut: number;
|
|
8
|
+
}
|
|
9
|
+
/** Reads the marker from the end of an NDJSON or CSV export; only the last bytes are read. */
|
|
10
|
+
export declare function readExportTrailer(blob: Blob, format: 'ndjson' | 'csv'): Promise<ExportTrailer>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const TAIL_BYTES = 64 * 1024;
|
|
2
|
+
function parseMarker(line, format) {
|
|
3
|
+
if (format === "csv") {
|
|
4
|
+
const end = /^# end (\d+)$/.exec(line);
|
|
5
|
+
if (end) return { marker: true, count: Number(end[1]) };
|
|
6
|
+
return { marker: line.startsWith("# error") };
|
|
7
|
+
}
|
|
8
|
+
if (!line.startsWith('{"$')) return { marker: false };
|
|
9
|
+
try {
|
|
10
|
+
const parsed = JSON.parse(line);
|
|
11
|
+
if (parsed.$end === true && Number.isSafeInteger(parsed.count)) return { marker: true, count: parsed.count };
|
|
12
|
+
return { marker: typeof parsed.$error === "string" };
|
|
13
|
+
} catch {
|
|
14
|
+
return { marker: false };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export async function readExportTrailer(blob, format) {
|
|
18
|
+
const start = Math.max(0, blob.size - TAIL_BYTES);
|
|
19
|
+
const tail = new Uint8Array(await blob.slice(start).arrayBuffer());
|
|
20
|
+
let end = tail.length;
|
|
21
|
+
while (end > 0 && (tail[end - 1] === 10 || tail[end - 1] === 13)) end--;
|
|
22
|
+
if (end === 0) return { marker: false, cut: blob.size };
|
|
23
|
+
const lineStart = tail.lastIndexOf(10, end - 1) + 1;
|
|
24
|
+
if (lineStart === 0 && start > 0) return { marker: false, cut: blob.size };
|
|
25
|
+
const line = new TextDecoder().decode(tail.subarray(lineStart, end));
|
|
26
|
+
const { marker, count } = parseMarker(line, format);
|
|
27
|
+
return marker ? { marker, count, cut: start + lineStart } : { marker: false, cut: blob.size };
|
|
28
|
+
}
|
|
@@ -2,12 +2,13 @@ import { useMongocampQuery } from "../composables/useMongocampQuery.js";
|
|
|
2
2
|
import { escapeFieldName } from "./escapeFieldName.js";
|
|
3
3
|
import { isIsoDateTimeString } from "./isoDate.js";
|
|
4
4
|
import { isObjectIdHex } from "./objectId.js";
|
|
5
|
+
const OBJECT_ID_PART = /^[0-9a-f]{1,24}$/i;
|
|
5
6
|
export const FILTER_OPERATORS_BY_TYPE = {
|
|
6
7
|
"string": ["contains", "equals", "notEquals", "startsWith", "endsWith", "oneOf", "isEmpty", "isNotEmpty"],
|
|
7
8
|
"number": ["equals", "notEquals", "gte", "lte", "between", "oneOf", "isEmpty", "isNotEmpty"],
|
|
8
9
|
"date-time": ["gte", "lte", "between", "isEmpty", "isNotEmpty"],
|
|
9
10
|
"boolean": ["isTrue", "isFalse", "isEmpty", "isNotEmpty"],
|
|
10
|
-
"objectId": ["equals", "notEquals", "oneOf"],
|
|
11
|
+
"objectId": ["equals", "notEquals", "oneOf", "startsWith", "endsWith", "contains"],
|
|
11
12
|
"array": ["isEmpty", "isNotEmpty"],
|
|
12
13
|
"object": ["isEmpty", "isNotEmpty"]
|
|
13
14
|
};
|
|
@@ -56,6 +57,11 @@ export function buildCondition(condition, type) {
|
|
|
56
57
|
const value = (condition.value ?? "").trim();
|
|
57
58
|
const value2 = (condition.value2 ?? "").trim();
|
|
58
59
|
if (type === "objectId") {
|
|
60
|
+
if (condition.operator === "startsWith" || condition.operator === "endsWith" || condition.operator === "contains") {
|
|
61
|
+
if (!OBJECT_ID_PART.test(value)) return "";
|
|
62
|
+
if (condition.operator === "startsWith") return h.startsWith(field, value);
|
|
63
|
+
return condition.operator === "endsWith" ? h.endsWith(field, value) : h.like(field, value);
|
|
64
|
+
}
|
|
59
65
|
const ids = condition.operator === "oneOf" ? splitList(value) : [value];
|
|
60
66
|
if (ids.length === 0 || !ids.every(isObjectIdHex)) return "";
|
|
61
67
|
if (condition.operator === "oneOf") return h.byIds(ids);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sfxcode/nuxt-ui-mongocamp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A Nuxt module that wraps @sfxcode/nuxt-mongocamp-server with ready-made UI components, composables, and a runtime plugin",
|
|
5
5
|
"repository": "sfxcode/nuxt-ui-mongocamp",
|
|
6
6
|
"homepage": "https://sfxcode.github.io/nuxt-ui-mongocamp/",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"dev": "npm run dev:prepare && nuxt dev playground",
|
|
52
52
|
"dev:build": "nuxt build playground",
|
|
53
53
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
|
|
54
|
-
"release": "npm run lint && npm run test && npm run prepack && changelogen --
|
|
54
|
+
"release": "npm run lint && npm run test && npm run prepack && changelogen --minor --release && npm publish && git push --follow-tags",
|
|
55
55
|
"lint": "eslint .",
|
|
56
56
|
"test": "vitest run --project unit --project components",
|
|
57
57
|
"test:watch": "vitest watch",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@internationalized/date": "^3.12.4",
|
|
67
67
|
"@nuxt/ui": "^4.13.1",
|
|
68
68
|
"@nuxtjs/i18n": "^10.7.0",
|
|
69
|
-
"@sfxcode/nuxt-mongocamp-server": "^2.
|
|
69
|
+
"@sfxcode/nuxt-mongocamp-server": "^2.2.0",
|
|
70
70
|
"@sfxcode/nuxt-ui-formkit": "^1.5.0",
|
|
71
71
|
"@tanstack/charts": "^1.5.0",
|
|
72
72
|
"@tanstack/vue-table": "^8.21.3",
|