@sfxcode/nuxt-ui-mongocamp 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/module.json +1 -1
- package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampAggregationBuilder.vue +29 -2
- package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.vue +4 -3
- package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampBucketFiles.vue +61 -0
- package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +2 -12
- package/dist/runtime/components/MongocampBulkDelete.vue +14 -40
- package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +2 -12
- package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +5 -6
- package/dist/runtime/components/MongocampBulkEdit.vue +43 -26
- package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +5 -6
- package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +2 -0
- package/dist/runtime/components/MongocampCollectionCharts.vue +9 -8
- package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +2 -0
- package/dist/runtime/components/MongocampCollectionCopy.vue +19 -258
- package/dist/runtime/components/MongocampCollectionData.d.vue.ts +2 -0
- package/dist/runtime/components/MongocampCollectionData.vue +206 -126
- package/dist/runtime/components/MongocampCollectionData.vue.d.ts +2 -0
- package/dist/runtime/components/MongocampCollectionRename.d.vue.ts +22 -0
- package/dist/runtime/components/MongocampCollectionRename.vue +116 -0
- package/dist/runtime/components/MongocampCollectionRename.vue.d.ts +22 -0
- package/dist/runtime/components/MongocampCollections.vue +31 -12
- package/dist/runtime/components/MongocampCommandPalette.vue +2 -2
- package/dist/runtime/components/MongocampDashboard.vue +19 -4
- package/dist/runtime/components/MongocampDatabases.vue +13 -2
- package/dist/runtime/components/MongocampExportAll.vue +13 -26
- package/dist/runtime/components/MongocampImport.vue +169 -3
- package/dist/runtime/components/MongocampIndexes.vue +54 -13
- package/dist/runtime/components/MongocampJobs.vue +14 -3
- package/dist/runtime/components/MongocampRoleGrants.vue +16 -3
- package/dist/runtime/components/MongocampRoles.vue +13 -2
- package/dist/runtime/components/MongocampServerOverview.vue +16 -39
- package/dist/runtime/components/MongocampSettings.d.vue.ts +3 -0
- package/dist/runtime/components/MongocampSettings.vue +14 -2
- package/dist/runtime/components/MongocampSettings.vue.d.ts +3 -0
- package/dist/runtime/components/MongocampUsers.vue +16 -3
- package/dist/runtime/composables/useMongocampAdminGate.d.ts +12 -0
- package/dist/runtime/composables/useMongocampAdminGate.js +12 -0
- package/dist/runtime/composables/useMongocampAggregation.d.ts +11 -0
- package/dist/runtime/composables/useMongocampAggregation.js +12 -5
- package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +15 -0
- package/dist/runtime/composables/useMongocampBulkByFilter.js +32 -0
- package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +25 -65
- package/dist/runtime/composables/useMongocampCollectionCopy.js +27 -84
- package/dist/runtime/composables/useMongocampExportAll.d.ts +27 -21
- package/dist/runtime/composables/useMongocampExportAll.js +51 -21
- package/dist/runtime/composables/useMongocampExtendedJson.d.ts +2 -1
- package/dist/runtime/composables/useMongocampExtendedJson.js +32 -5
- package/dist/runtime/composables/useMongocampFetchAll.js +1 -1
- package/dist/runtime/composables/useMongocampFieldTypes.d.ts +24 -0
- package/dist/runtime/composables/useMongocampFieldTypes.js +44 -0
- package/dist/runtime/composables/useMongocampImport.d.ts +4 -0
- package/dist/runtime/composables/useMongocampImport.js +5 -2
- package/dist/runtime/composables/useMongocampIndex.d.ts +6 -1
- package/dist/runtime/composables/useMongocampIndex.js +7 -1
- package/dist/runtime/composables/useMongocampPermissions.d.ts +8 -5
- package/dist/runtime/composables/useMongocampPermissions.js +24 -2
- package/dist/runtime/composables/useMongocampQuery.d.ts +3 -3
- package/dist/runtime/composables/useMongocampServerOverview.d.ts +4 -11
- package/dist/runtime/composables/useMongocampServerOverview.js +12 -22
- package/dist/runtime/locales/de.json +69 -71
- package/dist/runtime/locales/en.json +69 -71
- package/dist/runtime/utils/aggregationErrors.d.ts +4 -0
- package/dist/runtime/utils/aggregationErrors.js +7 -0
- package/dist/runtime/utils/batchInsert.d.ts +6 -0
- package/dist/runtime/utils/batchInsert.js +31 -3
- package/dist/runtime/utils/bsonTypes.d.ts +10 -0
- package/dist/runtime/utils/bsonTypes.js +42 -0
- package/dist/runtime/utils/collectionCopy.d.ts +0 -2
- package/dist/runtime/utils/collectionCopy.js +0 -1
- package/dist/runtime/utils/configRows.d.ts +7 -0
- package/dist/runtime/utils/configRows.js +4 -0
- package/dist/runtime/utils/documentCompare.js +2 -1
- package/dist/runtime/utils/documentPaths.d.ts +5 -8
- package/dist/runtime/utils/documentPaths.js +5 -10
- package/dist/runtime/utils/documentTree.js +9 -1
- package/dist/runtime/utils/exportDocuments.d.ts +0 -2
- package/dist/runtime/utils/exportDocuments.js +0 -1
- package/dist/runtime/utils/exportRows.d.ts +2 -0
- package/dist/runtime/utils/exportRows.js +5 -2
- package/dist/runtime/utils/fieldDetails.d.ts +51 -0
- package/dist/runtime/utils/fieldDetails.js +113 -0
- package/dist/runtime/utils/indexForm.d.ts +47 -33
- package/dist/runtime/utils/indexForm.js +32 -21
- package/package.json +8 -8
- package/dist/runtime/utils/indexCopy.d.ts +0 -26
- package/dist/runtime/utils/indexCopy.js +0 -22
- package/dist/runtime/utils/limitedMap.d.ts +0 -17
- package/dist/runtime/utils/limitedMap.js +0 -19
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
export const MAX_INDEX_FIELDS = 8;
|
|
2
2
|
export function indexKeys(index) {
|
|
3
|
-
return
|
|
3
|
+
return (index.keys ?? []).map(({ field, direction }) => ({
|
|
4
|
+
field,
|
|
5
|
+
direction: direction === "1" ? 1 : direction === "-1" ? -1 : direction === "text" ? "text" : "other"
|
|
6
|
+
}));
|
|
4
7
|
}
|
|
5
|
-
export function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (entries.length <= 1) return { keys: entries.map((e) => ({ field: e.field, direction: e.direction })), orderKnown: true };
|
|
11
|
-
const positions = entries.map((e) => ({ e, at: index.name.indexOf(`${e.field}_${String(e.value)}`) }));
|
|
12
|
-
if (positions.every((p) => p.at >= 0)) {
|
|
13
|
-
const sorted = [...positions].sort((a, b) => a.at - b.at);
|
|
14
|
-
if (sorted.map((p) => `${p.e.field}_${String(p.e.value)}`).join("_") === index.name) {
|
|
15
|
-
return { keys: sorted.map((p) => ({ field: p.e.field, direction: p.e.direction })), orderKnown: true };
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return { keys: entries.map((e) => ({ field: e.field, direction: e.direction })), orderKnown: false };
|
|
8
|
+
export function isTextIndex(index) {
|
|
9
|
+
return indexKeys(index).some((key) => key.direction === "text");
|
|
10
|
+
}
|
|
11
|
+
export function isExpiringIndex(index) {
|
|
12
|
+
return typeof index.expireAfterSeconds === "number";
|
|
19
13
|
}
|
|
20
14
|
export function describeKey(key) {
|
|
21
15
|
if (key.direction === "text") return `${key.field} (text)`;
|
|
@@ -26,28 +20,45 @@ const DURATION = /^[1-9]\d{0,8}[smhd]$/;
|
|
|
26
20
|
export function isValidExpireAfter(text) {
|
|
27
21
|
return DURATION.test(text.trim());
|
|
28
22
|
}
|
|
23
|
+
export function parsePartialFilter(text) {
|
|
24
|
+
if (text.trim() === "") return void 0;
|
|
25
|
+
try {
|
|
26
|
+
const value = JSON.parse(text);
|
|
27
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length > 0 ? value : null;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const takesOptions = (kind) => kind !== "expiring";
|
|
29
33
|
export function validateIndexForm(form) {
|
|
30
34
|
const problems = [];
|
|
31
|
-
const rows = form.kind === "
|
|
35
|
+
const rows = form.kind === "expiring" ? form.fields.slice(0, 1) : form.fields;
|
|
32
36
|
if (rows.length === 0) return ["no-field"];
|
|
33
37
|
const names = rows.map((r) => r.field.trim());
|
|
34
38
|
if (names.includes("")) problems.push("empty-field");
|
|
35
39
|
if (new Set(names.filter(Boolean)).size !== names.filter(Boolean).length) problems.push("duplicate-field");
|
|
36
40
|
if (rows.length > MAX_INDEX_FIELDS) problems.push("too-many-fields");
|
|
37
41
|
if (form.kind === "expiring" && !isValidExpireAfter(form.expireAfter)) problems.push("bad-duration");
|
|
38
|
-
if ((form.kind
|
|
42
|
+
if (takesOptions(form.kind) && form.name.trim().length > 100) problems.push("bad-name");
|
|
43
|
+
if (takesOptions(form.kind)) {
|
|
44
|
+
const partial = parsePartialFilter(form.partialFilter);
|
|
45
|
+
if (partial === null) problems.push("bad-partial-filter");
|
|
46
|
+
else if (partial !== void 0 && form.sparse) problems.push("sparse-and-partial");
|
|
47
|
+
}
|
|
39
48
|
return problems;
|
|
40
49
|
}
|
|
41
50
|
export function buildIndexRequest(form) {
|
|
42
51
|
const rows = form.fields.map((r) => ({ field: r.field.trim(), descending: r.descending }));
|
|
43
|
-
if (form.kind === "text") return { call: "createTextIndex", field: rows[0].field };
|
|
44
52
|
if (form.kind === "expiring") return { call: "createExpiringIndex", field: rows[0].field, duration: form.expireAfter.trim() };
|
|
45
|
-
const keys = {};
|
|
46
|
-
for (const row of rows) keys[row.field] = row.descending ? -1 : 1;
|
|
53
|
+
const keys = rows.map((row) => ({ field: row.field, direction: form.kind === "text" ? "text" : row.descending ? "-1" : "1" }));
|
|
47
54
|
const options = {};
|
|
48
55
|
if (form.kind === "unique") options.unique = true;
|
|
49
56
|
if (form.name.trim() !== "") options.name = form.name.trim();
|
|
50
|
-
|
|
57
|
+
if (form.sparse) options.sparse = true;
|
|
58
|
+
if (form.hidden) options.hidden = true;
|
|
59
|
+
const partial = parsePartialFilter(form.partialFilter);
|
|
60
|
+
if (partial) options.partialFilterExpression = partial;
|
|
61
|
+
return Object.keys(options).length > 0 ? { call: "createOrderedIndex", keys, options } : { call: "createOrderedIndex", keys };
|
|
51
62
|
}
|
|
52
63
|
export function classifyIndexError(message) {
|
|
53
64
|
if (/11000|duplicate key|E11000/i.test(message)) return "duplicate-values";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sfxcode/nuxt-ui-mongocamp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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/",
|
|
@@ -55,27 +55,27 @@
|
|
|
55
55
|
"docs:preview": "vitepress preview docs"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@formkit/nuxt": "^2.
|
|
58
|
+
"@formkit/nuxt": "^2.5.0",
|
|
59
59
|
"@internationalized/date": "^3.12.4",
|
|
60
60
|
"@nuxt/ui": "^4.12.0",
|
|
61
61
|
"@nuxtjs/i18n": "^10.6.0",
|
|
62
|
-
"@sfxcode/nuxt-mongocamp-server": "^1.
|
|
62
|
+
"@sfxcode/nuxt-mongocamp-server": "^1.8.0",
|
|
63
63
|
"@sfxcode/nuxt-ui-formkit": "^1.4.2",
|
|
64
|
-
"@tanstack/charts": "^1.
|
|
64
|
+
"@tanstack/charts": "^1.5.0",
|
|
65
65
|
"consola": "^3.4.2",
|
|
66
66
|
"defu": "^6.1.7",
|
|
67
|
-
"minimatch": "^11.0.
|
|
67
|
+
"minimatch": "^11.0.5",
|
|
68
68
|
"unocss-nuxt-ui": "^1.2.2"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@iconify-json/lucide": "^1.2.
|
|
71
|
+
"@iconify-json/lucide": "^1.2.152",
|
|
72
72
|
"@nuxt/devtools": "^4.1.0",
|
|
73
73
|
"@nuxt/eslint-config": "^1.17.0",
|
|
74
74
|
"@nuxt/kit": "^4.6.4",
|
|
75
75
|
"@nuxt/module-builder": "^1.0.3",
|
|
76
76
|
"@nuxt/schema": "^4.6.4",
|
|
77
|
-
"@nuxt/test-utils": "^4.
|
|
78
|
-
"@playwright/test": "^1.
|
|
77
|
+
"@nuxt/test-utils": "^4.4.0",
|
|
78
|
+
"@playwright/test": "^1.65.0",
|
|
79
79
|
"@types/node": "latest",
|
|
80
80
|
"@unhead/vue": "^3.4.3",
|
|
81
81
|
"@vue/test-utils": "^2.5.1",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { IndexLike } from './indexForm.js';
|
|
2
|
-
export type IndexCopySkipReason = 'multi-field-text' | 'unsupported-key' | 'unknown-key-order' | 'custom-weights';
|
|
3
|
-
export type IndexCopyPlan = {
|
|
4
|
-
call: 'createIndex';
|
|
5
|
-
name: string;
|
|
6
|
-
keys: Record<string, 1 | -1>;
|
|
7
|
-
options: {
|
|
8
|
-
name: string;
|
|
9
|
-
unique?: boolean;
|
|
10
|
-
expireAfter?: string;
|
|
11
|
-
};
|
|
12
|
-
} | {
|
|
13
|
-
call: 'createTextIndex';
|
|
14
|
-
name: string;
|
|
15
|
-
field: string;
|
|
16
|
-
} | {
|
|
17
|
-
call: 'skip';
|
|
18
|
-
name: string;
|
|
19
|
-
reason: IndexCopySkipReason;
|
|
20
|
-
};
|
|
21
|
-
/** The index MongoDB creates by itself on every collection; never copied. */
|
|
22
|
-
export declare const DEFAULT_INDEX_NAME = "_id_";
|
|
23
|
-
/** What recreating `index` takes: a `createIndex` with name, `unique` and `expireAfter`, a text index, or a skip with the reason. */
|
|
24
|
-
export declare function planIndexCopy(index: IndexLike): IndexCopyPlan;
|
|
25
|
-
/** The plans for every index of a collection, without the default `_id_` index. */
|
|
26
|
-
export declare function planIndexCopies(indexes: IndexLike[]): IndexCopyPlan[];
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { indexKeysWithOrder } from "./indexForm.js";
|
|
2
|
-
export const DEFAULT_INDEX_NAME = "_id_";
|
|
3
|
-
export function planIndexCopy(index) {
|
|
4
|
-
const { keys, orderKnown } = indexKeysWithOrder(index);
|
|
5
|
-
if (index.text) {
|
|
6
|
-
const weights = Object.entries(index.weights ?? {});
|
|
7
|
-
if (weights.length !== 1) return { call: "skip", name: index.name, reason: "multi-field-text" };
|
|
8
|
-
if (weights[0][1] !== 1) return { call: "skip", name: index.name, reason: "custom-weights" };
|
|
9
|
-
return { call: "createTextIndex", name: index.name, field: weights[0][0] };
|
|
10
|
-
}
|
|
11
|
-
if (keys.length === 0 || keys.some((k) => k.direction !== 1 && k.direction !== -1)) return { call: "skip", name: index.name, reason: "unsupported-key" };
|
|
12
|
-
if (!orderKnown) return { call: "skip", name: index.name, reason: "unknown-key-order" };
|
|
13
|
-
const orderedKeys = {};
|
|
14
|
-
for (const key of keys) orderedKeys[key.field] = key.direction;
|
|
15
|
-
const options = { name: index.name };
|
|
16
|
-
if (index.unique) options.unique = true;
|
|
17
|
-
if (index.expire && typeof index.expireAfterSeconds === "number" && index.expireAfterSeconds >= 0) options.expireAfter = `${index.expireAfterSeconds}s`;
|
|
18
|
-
return { call: "createIndex", name: index.name, keys: orderedKeys, options };
|
|
19
|
-
}
|
|
20
|
-
export function planIndexCopies(indexes) {
|
|
21
|
-
return indexes.filter((i) => i.name !== DEFAULT_INDEX_NAME).map(planIndexCopy);
|
|
22
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type Settled<R> = {
|
|
2
|
-
ok: true;
|
|
3
|
-
value: R;
|
|
4
|
-
} | {
|
|
5
|
-
ok: false;
|
|
6
|
-
error: unknown;
|
|
7
|
-
};
|
|
8
|
-
export interface LimitedMapOptions {
|
|
9
|
-
signal?: AbortSignal;
|
|
10
|
-
/** Called after every finished item with how many are done so far. */
|
|
11
|
-
onProgress?: (done: number, total: number) => void;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* The result of every item that was started, in input order; an item that never started (the run was aborted first) is
|
|
15
|
-
* `undefined`. A rejected call is `{ ok: false, error }`, never thrown.
|
|
16
|
-
*/
|
|
17
|
-
export declare function mapLimit<T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>, options?: LimitedMapOptions): Promise<Array<Settled<R> | undefined>>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export async function mapLimit(items, limit, fn, options = {}) {
|
|
2
|
-
const results = Array.from({ length: items.length });
|
|
3
|
-
const workers = Math.max(1, Math.min(Math.floor(limit) || 1, items.length));
|
|
4
|
-
let next = 0;
|
|
5
|
-
let done = 0;
|
|
6
|
-
async function worker() {
|
|
7
|
-
while (next < items.length && !options.signal?.aborted) {
|
|
8
|
-
const index = next++;
|
|
9
|
-
try {
|
|
10
|
-
results[index] = { ok: true, value: await fn(items[index], index) };
|
|
11
|
-
} catch (error) {
|
|
12
|
-
results[index] = { ok: false, error };
|
|
13
|
-
}
|
|
14
|
-
options.onProgress?.(++done, items.length);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
await Promise.all(Array.from({ length: workers }, worker));
|
|
18
|
-
return results;
|
|
19
|
-
}
|