@sfxcode/nuxt-ui-mongocamp 1.5.8 → 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.
Files changed (104) hide show
  1. package/README.md +5 -5
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
  4. package/dist/runtime/components/MongocampAggregationBuilder.vue +5 -2
  5. package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
  6. package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +1 -0
  7. package/dist/runtime/components/MongocampAggregationStagePreview.vue +4 -2
  8. package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +1 -0
  9. package/dist/runtime/components/MongocampBucketFiles.vue +4 -6
  10. package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +1 -0
  11. package/dist/runtime/components/MongocampCollectionCharts.vue +4 -2
  12. package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +1 -0
  13. package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +1 -0
  14. package/dist/runtime/components/MongocampCollectionCopy.vue +5 -3
  15. package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +1 -0
  16. package/dist/runtime/components/MongocampCollectionData.vue +63 -36
  17. package/dist/runtime/components/MongocampCollectionInfos.vue +16 -1
  18. package/dist/runtime/components/MongocampDocumentView.vue +6 -1
  19. package/dist/runtime/components/MongocampExportAll.d.vue.ts +1 -0
  20. package/dist/runtime/components/MongocampExportAll.vue +12 -0
  21. package/dist/runtime/components/MongocampExportAll.vue.d.ts +1 -0
  22. package/dist/runtime/components/MongocampImport.vue +3 -0
  23. package/dist/runtime/components/MongocampIndexes.vue +7 -3
  24. package/dist/runtime/components/MongocampQueryBar.vue +15 -0
  25. package/dist/runtime/components/MongocampServerInfo.vue +1 -14
  26. package/dist/runtime/components/MongocampServerStatus.vue +7 -2
  27. package/dist/runtime/components/MongocampSettings.d.vue.ts +0 -3
  28. package/dist/runtime/components/MongocampSettings.vue +2 -48
  29. package/dist/runtime/components/MongocampSettings.vue.d.ts +0 -3
  30. package/dist/runtime/components/MongocampVersion.d.vue.ts +1 -1
  31. package/dist/runtime/components/MongocampVersion.vue +14 -7
  32. package/dist/runtime/components/MongocampVersion.vue.d.ts +1 -1
  33. package/dist/runtime/composables/useMongocampAdmin.js +6 -5
  34. package/dist/runtime/composables/useMongocampAggregation.d.ts +11 -3
  35. package/dist/runtime/composables/useMongocampAggregation.js +19 -10
  36. package/dist/runtime/composables/useMongocampBucket.d.ts +4 -0
  37. package/dist/runtime/composables/useMongocampBucket.js +7 -6
  38. package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +6 -4
  39. package/dist/runtime/composables/useMongocampBulkByFilter.js +11 -6
  40. package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +3 -1
  41. package/dist/runtime/composables/useMongocampCollectionCopy.js +4 -2
  42. package/dist/runtime/composables/useMongocampCollectionStats.js +2 -4
  43. package/dist/runtime/composables/useMongocampError.d.ts +1 -1
  44. package/dist/runtime/composables/useMongocampError.js +4 -1
  45. package/dist/runtime/composables/useMongocampExportAll.d.ts +17 -7
  46. package/dist/runtime/composables/useMongocampExportAll.js +19 -20
  47. package/dist/runtime/composables/useMongocampFetchAll.d.ts +11 -5
  48. package/dist/runtime/composables/useMongocampFetchAll.js +8 -8
  49. package/dist/runtime/composables/useMongocampJobs.js +3 -2
  50. package/dist/runtime/composables/useMongocampQuery.d.ts +26 -36
  51. package/dist/runtime/composables/useMongocampQuery.js +42 -49
  52. package/dist/runtime/composables/useMongocampSchema.js +2 -0
  53. package/dist/runtime/composables/useMongocampSystem.d.ts +3 -9
  54. package/dist/runtime/composables/useMongocampSystem.js +1 -9
  55. package/dist/runtime/locales/de.json +13 -12
  56. package/dist/runtime/locales/en.json +13 -12
  57. package/dist/runtime/publicUtils.d.ts +1 -0
  58. package/dist/runtime/publicUtils.js +1 -0
  59. package/dist/runtime/server/handlers/mongocampProxy.d.ts +1 -1
  60. package/dist/runtime/server/handlers/mongocampProxy.js +12 -12
  61. package/dist/runtime/utils/aggregationErrors.d.ts +0 -4
  62. package/dist/runtime/utils/aggregationErrors.js +0 -7
  63. package/dist/runtime/utils/aggregationPipeline.d.ts +2 -1
  64. package/dist/runtime/utils/aggregationPipeline.js +2 -3
  65. package/dist/runtime/utils/caseInsensitive.d.ts +10 -0
  66. package/dist/runtime/utils/caseInsensitive.js +8 -0
  67. package/dist/runtime/utils/collectionStats.d.ts +4 -1
  68. package/dist/runtime/utils/collectionStats.js +2 -2
  69. package/dist/runtime/utils/configRows.d.ts +3 -3
  70. package/dist/runtime/utils/cursorPaging.d.ts +16 -0
  71. package/dist/runtime/utils/cursorPaging.js +17 -0
  72. package/dist/runtime/utils/documentCompare.js +2 -3
  73. package/dist/runtime/utils/documentPaths.d.ts +5 -5
  74. package/dist/runtime/utils/documentPaths.js +9 -2
  75. package/dist/runtime/utils/documentTree.js +3 -0
  76. package/dist/runtime/utils/exportTrailer.d.ts +10 -0
  77. package/dist/runtime/utils/exportTrailer.js +28 -0
  78. package/dist/runtime/utils/fileFilter.d.ts +7 -0
  79. package/dist/runtime/utils/fileFilter.js +11 -0
  80. package/dist/runtime/utils/filterBuilder.d.ts +1 -1
  81. package/dist/runtime/utils/filterBuilder.js +12 -12
  82. package/dist/runtime/utils/filterSuggestions.js +1 -1
  83. package/dist/runtime/utils/indexForm.d.ts +7 -0
  84. package/dist/runtime/utils/indexForm.js +9 -0
  85. package/dist/runtime/utils/pagedFetch.d.ts +13 -0
  86. package/dist/runtime/utils/pagedFetch.js +44 -0
  87. package/dist/runtime/utils/queryState.d.ts +5 -0
  88. package/dist/runtime/utils/queryState.js +3 -2
  89. package/dist/runtime/utils/relaxedValues.d.ts +17 -0
  90. package/dist/runtime/utils/relaxedValues.js +51 -0
  91. package/dist/runtime/utils/requestLimits.d.ts +1 -1
  92. package/dist/runtime/utils/requestLimits.js +1 -1
  93. package/dist/runtime/utils/savedQueries.d.ts +2 -0
  94. package/dist/runtime/utils/savedQueries.js +1 -0
  95. package/dist/runtime/utils/schemaAnalysis.d.ts +4 -4
  96. package/dist/runtime/utils/schemaAnalysis.js +2 -2
  97. package/dist/runtime/utils/sensitiveFields.d.ts +20 -0
  98. package/dist/runtime/utils/sensitiveFields.js +63 -0
  99. package/dist/runtime/utils/serverError.d.ts +7 -0
  100. package/dist/runtime/utils/serverError.js +11 -0
  101. package/dist/runtime/utils/serverStatus.d.ts +2 -2
  102. package/package.json +12 -6
  103. package/dist/runtime/utils/luceneExpression.d.ts +0 -15
  104. package/dist/runtime/utils/luceneExpression.js +0 -74
@@ -77,6 +77,13 @@ export type IndexRequest = {
77
77
  export declare function buildIndexRequest(form: IndexForm): IndexRequest;
78
78
  export type IndexErrorKind = 'duplicate-values' | 'conflict' | 'empty-keys' | 'other';
79
79
  /** What a create/drop failure means, from the server's message (MongoDB error codes 11000, 85/86 and 67). */
80
+ /**
81
+ * The partial filter of an index as compact JSON for a tooltip (`{"n":{"$gt":0}}`); `undefined` when there is none or when it
82
+ * is not a readable object (the `{ "underlying": null }` form of older servers).
83
+ */
84
+ export declare function partialFilterText(value: unknown): string | undefined;
85
+ /** The locale of an index collation (`de`), or `undefined`. */
86
+ export declare function collationLocale(value: unknown): string | undefined;
80
87
  export declare function classifyIndexError(message: string): IndexErrorKind;
81
88
  /** Never used since the counter started — a hint, not proof (counters restart with the server). `_id_` is never flagged. */
82
89
  export declare function isUnusedIndex(name: string, ops: number | undefined): boolean;
@@ -60,6 +60,15 @@ export function buildIndexRequest(form) {
60
60
  if (partial) options.partialFilterExpression = partial;
61
61
  return Object.keys(options).length > 0 ? { call: "createOrderedIndex", keys, options } : { call: "createOrderedIndex", keys };
62
62
  }
63
+ export function partialFilterText(value) {
64
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
65
+ const text = JSON.stringify(value);
66
+ return text === "{}" || text.includes('"underlying"') ? void 0 : text;
67
+ }
68
+ export function collationLocale(value) {
69
+ const locale = value?.locale;
70
+ return typeof locale === "string" && locale !== "" ? locale : void 0;
71
+ }
63
72
  export function classifyIndexError(message) {
64
73
  if (/11000|duplicate key|E11000/i.test(message)) return "duplicate-values";
65
74
  if (/equivalent index already exists|IndexOptionsConflict|IndexKeySpecsConflict|already exists with a different name/i.test(message)) return "conflict";
@@ -44,3 +44,16 @@ export interface FetchAllResult<T> {
44
44
  * Sequential by design: the pages are cheap to compute and the page size is what makes it fast.
45
45
  */
46
46
  export declare function fetchAllPages<T>(fetchPage: (page: number, pageSize: number) => Promise<PageResult<T>>, options?: FetchAllOptions<T>): Promise<FetchAllResult<T>>;
47
+ export interface CursorPageResult<T> {
48
+ rows: T[];
49
+ /** The cursor of the next page (`x-pagination-next`); absent on the last page. */
50
+ next?: string;
51
+ /** The total, when the page reports one (the first page asks for it, the others skip the count). */
52
+ total?: number;
53
+ }
54
+ /**
55
+ * Calls `fetchPage(after, pageSize, first)` with `after = ''` and then each page's `next` until a page has no `next`, the cap
56
+ * is reached or `signal` aborts. `first` is true only for the first call, so the caller can ask for the count once (progress)
57
+ * and skip it afterwards. Same options and result as `fetchAllPages`; `totalChanged` is always false here.
58
+ */
59
+ export declare function fetchAllByCursor<T>(fetchPage: (after: string, pageSize: number, first: boolean) => Promise<CursorPageResult<T>>, options?: FetchAllOptions<T>): Promise<FetchAllResult<T>>;
@@ -56,3 +56,47 @@ export async function fetchAllPages(fetchPage, options = {}) {
56
56
  }
57
57
  return { rows, total, truncated, totalChanged, duplicates, pages: page };
58
58
  }
59
+ export async function fetchAllByCursor(fetchPage, options = {}) {
60
+ const pageSize = Math.max(1, Math.floor(options.pageSize ?? DEFAULT_PAGE_SIZE) || DEFAULT_PAGE_SIZE);
61
+ const maxRows = Math.max(1, Math.floor(options.maxRows ?? DEFAULT_MAX_ROWS) || DEFAULT_MAX_ROWS);
62
+ const { signal, onProgress, keyOf } = options;
63
+ const rows = [];
64
+ const seen = keyOf ? /* @__PURE__ */ new Set() : void 0;
65
+ let total;
66
+ let duplicates = 0;
67
+ let truncated = false;
68
+ let page = 0;
69
+ let after = "";
70
+ for (; ; ) {
71
+ if (signal?.aborted) throw abortError(signal);
72
+ page++;
73
+ const result = await fetchPage(after, pageSize, page === 1);
74
+ if (signal?.aborted) throw abortError(signal);
75
+ if (typeof result.total === "number" && Number.isFinite(result.total)) total = result.total;
76
+ for (const row of result.rows) {
77
+ if (seen && keyOf) {
78
+ const key = keyOf(row);
79
+ if (seen.has(key)) {
80
+ duplicates++;
81
+ continue;
82
+ }
83
+ seen.add(key);
84
+ }
85
+ if (rows.length >= maxRows) {
86
+ truncated = true;
87
+ break;
88
+ }
89
+ rows.push(row);
90
+ }
91
+ onProgress?.({ loaded: rows.length, total, target: total === void 0 ? void 0 : Math.min(total, maxRows), page });
92
+ if (truncated) break;
93
+ const next = result.next;
94
+ if (rows.length >= maxRows) {
95
+ truncated = Boolean(next);
96
+ break;
97
+ }
98
+ if (!next || next === after || result.rows.length === 0) break;
99
+ after = next;
100
+ }
101
+ return { rows, total, truncated, totalChanged: false, duplicates, pages: page };
102
+ }
@@ -7,6 +7,11 @@ export interface QueryState {
7
7
  /** `['name', '-age']`: a leading `-` is descending (the server's own syntax). */
8
8
  sort: string[];
9
9
  projection: string[];
10
+ /**
11
+ * Match the case of wildcard terms (`name:Ali*`): fast, a prefix can use an index. Off (the default) sends
12
+ * `filterCaseInsensitive=true` with every wildcard filter, so `ali` also finds `Alice` (server 2.0).
13
+ */
14
+ matchCase: boolean;
10
15
  }
11
16
  export declare const MAX_SORT_ENTRIES = 5;
12
17
  export declare function emptyGroup(): FilterGroup;
@@ -4,7 +4,7 @@ export function emptyGroup() {
4
4
  return { match: "all", conditions: [] };
5
5
  }
6
6
  export function emptyQueryState() {
7
- return { filterGroup: emptyGroup(), lucene: "", sort: [], projection: [] };
7
+ return { filterGroup: emptyGroup(), lucene: "", sort: [], projection: [], matchCase: false };
8
8
  }
9
9
  export function isEmptyQuery(state) {
10
10
  return state.lucene === "" && state.sort.length === 0 && state.projection.length === 0;
@@ -15,12 +15,13 @@ export function toSavedQuery(state) {
15
15
  if (state.lucene !== "") query.lucene = state.lucene;
16
16
  if (state.sort.length > 0) query.sort = [...state.sort];
17
17
  if (state.projection.length > 0) query.projection = [...state.projection];
18
+ if (state.matchCase && (query.filterGroup || query.lucene)) query.matchCase = true;
18
19
  return query;
19
20
  }
20
21
  export function fromSavedQuery(query, fieldTypes) {
21
22
  const filterGroup = query.filterGroup ? { ...query.filterGroup, conditions: query.filterGroup.conditions.map((c) => ({ ...c })) } : emptyGroup();
22
23
  const lucene = query.filterGroup ? buildFilterQuery(filterGroup, fieldTypes) : query.lucene ?? "";
23
- return { filterGroup, lucene, sort: [...query.sort ?? []], projection: [...query.projection ?? []] };
24
+ return { filterGroup, lucene, sort: [...query.sort ?? []], projection: [...query.projection ?? []], matchCase: query.matchCase === true };
24
25
  }
25
26
  export function parseSortEntry(entry) {
26
27
  return entry.startsWith("-") ? { field: entry.slice(1), desc: true } : { field: entry, desc: false };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A document id as text: the hex of `{ $oid }`, the value of `{ $numberLong }` / `{ $numberInt }` / `{ $string }`, a plain
3
+ * string or number as it is. `undefined` for anything else (an object id, a binary id). Mirrors `documentId` of
4
+ * `@sfxcode/nuxt-mongocamp-server`, without needing `bson`.
5
+ */
6
+ export declare function idOf(value: unknown): string | undefined;
7
+ /** `true` for `{ $string: '…' }`, the server's marker for text that would otherwise be read as a date. */
8
+ export declare function isStringWrapper(value: unknown): value is {
9
+ $string: string;
10
+ };
11
+ /** `true` for a plain string or a `{ $string }` wrapper — a field that holds text. */
12
+ export declare function isTextValue(value: unknown): boolean;
13
+ /**
14
+ * A short text for the wrappers that have no plain JavaScript value: `Binary(00, 12 bytes)`, `/a.c/i`,
15
+ * `Timestamp(1700000000, 1)`, `MinKey`, `MaxKey`; also the text of `{ $string }`. `undefined` for anything else.
16
+ */
17
+ export declare function leafWrapperText(value: unknown): string | undefined;
@@ -0,0 +1,51 @@
1
+ function isRecord(value) {
2
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3
+ }
4
+ function onlyKey(value) {
5
+ const keys = Object.keys(value);
6
+ return keys.length === 1 ? keys[0] : void 0;
7
+ }
8
+ const ID_WRAPPERS = /* @__PURE__ */ new Set(["$oid", "$numberLong", "$numberInt", "$string"]);
9
+ export function idOf(value) {
10
+ if (typeof value === "string") return value;
11
+ if (typeof value === "number" && Number.isFinite(value)) return String(value);
12
+ if (isRecord(value)) {
13
+ const key = onlyKey(value);
14
+ const inner = key && ID_WRAPPERS.has(key) ? value[key] : void 0;
15
+ if (typeof inner === "string" || typeof inner === "number") return String(inner);
16
+ }
17
+ return void 0;
18
+ }
19
+ export function isStringWrapper(value) {
20
+ return isRecord(value) && onlyKey(value) === "$string" && typeof value.$string === "string";
21
+ }
22
+ export function isTextValue(value) {
23
+ return typeof value === "string" || isStringWrapper(value);
24
+ }
25
+ export function leafWrapperText(value) {
26
+ if (!isRecord(value)) return void 0;
27
+ const key = onlyKey(value);
28
+ const inner = key ? value[key] : void 0;
29
+ switch (key) {
30
+ case "$string":
31
+ return typeof inner === "string" ? inner : void 0;
32
+ case "$binary": {
33
+ if (!isRecord(inner)) return void 0;
34
+ const base64 = typeof inner.base64 === "string" ? inner.base64 : "";
35
+ const bytes = Math.floor(base64.replace(/=+$/, "").length * 3 / 4);
36
+ return `Binary(${String(inner.subType ?? "00")}, ${bytes} bytes)`;
37
+ }
38
+ case "$uuid":
39
+ return typeof inner === "string" ? `UUID(${inner})` : void 0;
40
+ case "$regularExpression":
41
+ return isRecord(inner) ? `/${String(inner.pattern ?? "")}/${String(inner.options ?? "")}` : void 0;
42
+ case "$timestamp":
43
+ return isRecord(inner) ? `Timestamp(${String(inner.t ?? "")}, ${String(inner.i ?? "")})` : void 0;
44
+ case "$minKey":
45
+ return "MinKey";
46
+ case "$maxKey":
47
+ return "MaxKey";
48
+ default:
49
+ return void 0;
50
+ }
51
+ }
@@ -1,2 +1,2 @@
1
- export declare const MAX_ENCODED_FILTER_LENGTH = 1800;
1
+ export declare const MAX_ENCODED_FILTER_LENGTH = 6000;
2
2
  export declare function isFilterTooLong(filter: string | undefined): boolean;
@@ -1,4 +1,4 @@
1
- export const MAX_ENCODED_FILTER_LENGTH = 1800;
1
+ export const MAX_ENCODED_FILTER_LENGTH = 6e3;
2
2
  export function isFilterTooLong(filter) {
3
3
  return filter !== void 0 && encodeURIComponent(filter).length > MAX_ENCODED_FILTER_LENGTH;
4
4
  }
@@ -6,6 +6,8 @@ export interface SavedQuery {
6
6
  lucene?: string;
7
7
  sort?: string[];
8
8
  projection?: string[];
9
+ /** The filter's wildcards match case exactly (see `QueryState.matchCase`); absent = case-insensitive. */
10
+ matchCase?: true;
9
11
  }
10
12
  export interface SavedQueryEntry {
11
13
  name: string;
@@ -55,6 +55,7 @@ export function sanitizeQuery(value) {
55
55
  if (sort) query.sort = sort;
56
56
  const projection = sanitizeStrings(value.projection, MAX_FIELDS);
57
57
  if (projection) query.projection = projection;
58
+ if (Object.keys(query).length > 0 && value.matchCase === true) query.matchCase = true;
58
59
  return Object.keys(query).length > 0 ? query : void 0;
59
60
  }
60
61
  function stable(value) {
@@ -1,10 +1,10 @@
1
1
  import type { SchemaAnalysis } from '@sfxcode/nuxt-mongocamp-server';
2
2
  import type { SampleAnalysis, ValueKind } from './analyzeSamples.js';
3
- /** More documents than this are never analysed in one request (≈ 20 s on the dev server); use a sample instead. */
4
- export declare const FULL_ANALYSIS_MAX_DOCUMENTS = 200000;
5
- /** Time to wait for an analysis of `documents` documents: a fixed allowance plus 0.4 ms each (measured: 0.11 ms), at most 2 minutes. */
3
+ /** More documents than this are never analysed in one request; use a sample instead. */
4
+ export declare const FULL_ANALYSIS_MAX_DOCUMENTS = 1000000;
5
+ /** Time to wait for an analysis of `documents` documents: a fixed allowance plus 0.05 ms each (measured: 0.012 ms), at most 2 minutes. */
6
6
  export declare function analysisTimeoutMs(documents: number): number;
7
- /** What to ask for: the server needs a positive size, and more than the collection holds is the same as all of it. */
7
+ /** What to ask for: the count (every document; more than the collection holds is the same), capped, never 0. */
8
8
  export declare function analysisSampleSize(documents: number): number;
9
9
  export declare function kindOfServerType(serverType: string): ValueKind;
10
10
  /**
@@ -1,7 +1,7 @@
1
1
  import { comparePaths } from "./analyzeSamples.js";
2
- export const FULL_ANALYSIS_MAX_DOCUMENTS = 2e5;
2
+ export const FULL_ANALYSIS_MAX_DOCUMENTS = 1e6;
3
3
  const BASE_TIMEOUT_MS = 15e3;
4
- const MS_PER_DOCUMENT = 0.4;
4
+ const MS_PER_DOCUMENT = 0.05;
5
5
  const MAX_TIMEOUT_MS = 12e4;
6
6
  export function analysisTimeoutMs(documents) {
7
7
  return Math.min(MAX_TIMEOUT_MS, Math.round(BASE_TIMEOUT_MS + Math.max(0, documents) * MS_PER_DOCUMENT));
@@ -0,0 +1,20 @@
1
+ /** The top-level fields of `collection` that are never shown; `[]` for ordinary collections. */
2
+ export declare function sensitiveFieldsOf(collection: string): readonly string[];
3
+ /** A copy of `row` without the sensitive fields of `collection` (the row itself when there are none). */
4
+ export declare function withoutSensitiveFields<T extends Record<string, unknown>>(row: T, collection: string): T;
5
+ interface PipelineStageLike {
6
+ stage: string;
7
+ value: unknown;
8
+ }
9
+ /** The hidden fields a pipeline over `collection` can reach (its own collection and every collection it joins). */
10
+ export declare function sensitiveFieldsOfPipeline(collection: string, pipeline: readonly PipelineStageLike[]): string[];
11
+ export interface SensitiveFieldUse {
12
+ stageIndex: number;
13
+ /** The path as written, e.g. `$password` or `$u.apiKey`. */
14
+ reference: string;
15
+ }
16
+ /** Every string `'$…'` (a field path, not a `'$$variable'`) whose last segment is one of `fields`. */
17
+ export declare function sensitiveFieldReferences(pipeline: readonly PipelineStageLike[], fields: readonly string[]): SensitiveFieldUse[];
18
+ /** A copy of `value` without any key named in `fields`, at any depth. */
19
+ export declare function withoutFieldsDeep<T>(value: T, fields: readonly string[]): T;
20
+ export {};
@@ -0,0 +1,63 @@
1
+ const SENSITIVE_FIELDS = {
2
+ mc_users: ["password", "apiKey"]
3
+ };
4
+ export function sensitiveFieldsOf(collection) {
5
+ return Object.hasOwn(SENSITIVE_FIELDS, collection) ? SENSITIVE_FIELDS[collection] : [];
6
+ }
7
+ export function withoutSensitiveFields(row, collection) {
8
+ const hidden = sensitiveFieldsOf(collection);
9
+ if (hidden.length === 0 || !hidden.some((field) => Object.hasOwn(row, field))) return row;
10
+ return Object.fromEntries(Object.entries(row).filter(([key]) => !hidden.includes(key)));
11
+ }
12
+ function isRecord(value) {
13
+ return typeof value === "object" && value !== null && !Array.isArray(value);
14
+ }
15
+ function joinedCollections(value, into, depth = 0) {
16
+ if (depth > 32) return;
17
+ if (Array.isArray(value)) {
18
+ for (const entry of value) joinedCollections(entry, into, depth + 1);
19
+ return;
20
+ }
21
+ if (!isRecord(value)) return;
22
+ for (const [key, entry] of Object.entries(value)) {
23
+ if (key === "from" && typeof entry === "string") into.add(entry);
24
+ if (key === "$unionWith") {
25
+ if (typeof entry === "string") into.add(entry);
26
+ else if (isRecord(entry) && typeof entry.coll === "string") into.add(entry.coll);
27
+ }
28
+ joinedCollections(entry, into, depth + 1);
29
+ }
30
+ }
31
+ export function sensitiveFieldsOfPipeline(collection, pipeline) {
32
+ const read = /* @__PURE__ */ new Set([collection]);
33
+ for (const stage of pipeline) {
34
+ if (stage.stage === "$unionWith" || stage.stage === "unionWith") joinedCollections({ $unionWith: stage.value }, read);
35
+ joinedCollections(stage.value, read);
36
+ }
37
+ return [...new Set([...read].flatMap((name) => [...sensitiveFieldsOf(name)]))];
38
+ }
39
+ export function sensitiveFieldReferences(pipeline, fields) {
40
+ if (fields.length === 0) return [];
41
+ const found = [];
42
+ const visit = (value, stageIndex, depth) => {
43
+ if (depth > 32 || found.length >= 20) return;
44
+ if (typeof value === "string") {
45
+ if (value.startsWith("$") && !value.startsWith("$$") && fields.includes(value.slice(1).split(".").pop())) found.push({ stageIndex, reference: value });
46
+ return;
47
+ }
48
+ if (Array.isArray(value)) value.forEach((entry) => visit(entry, stageIndex, depth + 1));
49
+ else if (isRecord(value)) Object.values(value).forEach((entry) => visit(entry, stageIndex, depth + 1));
50
+ };
51
+ pipeline.forEach((stage, index) => visit(stage.value, index, 0));
52
+ return found;
53
+ }
54
+ export function withoutFieldsDeep(value, fields) {
55
+ if (fields.length === 0) return value;
56
+ const strip = (entry, depth) => {
57
+ if (depth > 64) return entry;
58
+ if (Array.isArray(entry)) return entry.map((item) => strip(item, depth + 1));
59
+ if (!isRecord(entry)) return entry;
60
+ return Object.fromEntries(Object.entries(entry).filter(([key]) => !fields.includes(key)).map(([key, inner]) => [key, strip(inner, depth + 1)]));
61
+ };
62
+ return strip(value, 0);
63
+ }
@@ -1,4 +1,11 @@
1
1
  export declare const OPERATOR_NOT_ALLOWED_CODE = 4031;
2
+ /** The request was answered 404: what it asked for does not exist (any more). */
3
+ export declare function isNotFound(error: unknown): boolean;
4
+ /**
5
+ * Runs a delete-like request for which "it is already gone" is success: a 404 resolves with `undefined` instead of
6
+ * rejecting (server 2.0 answers 404 where 1.x answered `200 false` / a count of 0). Any other failure still rejects.
7
+ */
8
+ export declare function ignoringNotFound<T>(run: () => Promise<T>): Promise<T | undefined>;
2
9
  export interface ServerError {
3
10
  /** HTTP status of the response, when there was one. */
4
11
  status?: number;
@@ -1,5 +1,16 @@
1
1
  import { parseServerError } from "./aggregationErrors.js";
2
2
  export const OPERATOR_NOT_ALLOWED_CODE = 4031;
3
+ export function isNotFound(error) {
4
+ return error?.response?.status === 404;
5
+ }
6
+ export async function ignoringNotFound(run) {
7
+ try {
8
+ return await run();
9
+ } catch (error) {
10
+ if (isNotFound(error)) return void 0;
11
+ throw error;
12
+ }
13
+ }
3
14
  export async function readServerError(error) {
4
15
  const response = error?.response;
5
16
  const status = typeof response?.status === "number" ? response.status : void 0;
@@ -1,7 +1,7 @@
1
1
  export type ServerHealth = 'ok' | 'partial' | 'down';
2
2
  /**
3
- * What one request did: it answered (`ok`), the server answered with an error (`refused` — no right, or a server older than
4
- * 1.9.0 without the route), nothing came back (`failed`), or it was not sent (`skipped` — not signed in, not allowed).
3
+ * What one request did: it answered (`ok`), the server answered with an error (`refused` — e.g. no right: `/system/stats` is
4
+ * for administrators), nothing came back (`failed`), or it was not sent (`skipped` — not signed in, not allowed).
5
5
  */
6
6
  export type Outcome = 'ok' | 'refused' | 'failed' | 'skipped';
7
7
  /** An error that carries an HTTP response proves the server is there; anything else (network, timeout) does not. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-ui-mongocamp",
3
- "version": "1.5.8",
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 --patch --release && npm publish && git push --follow-tags",
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": "^1.9.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",
@@ -76,7 +76,7 @@
76
76
  "unocss-nuxt-ui": "^1.3.0"
77
77
  },
78
78
  "devDependencies": {
79
- "@iconify-json/lucide": "^1.2.160",
79
+ "@iconify-json/lucide": "^1.2.161",
80
80
  "@nuxt/devtools": "^4.2.2",
81
81
  "@nuxt/eslint-config": "^1.17.0",
82
82
  "@nuxt/kit": "^4.7.0",
@@ -85,16 +85,22 @@
85
85
  "@nuxt/test-utils": "^4.4.0",
86
86
  "@playwright/test": "^1.65.1",
87
87
  "@types/node": "latest",
88
- "@unhead/vue": "^3.5.3",
88
+ "@unhead/vue": "^3.5.4",
89
89
  "@vue/test-utils": "^2.6.0",
90
90
  "changelogen": "^0.6.2",
91
- "eslint": "^10.15.0",
91
+ "eslint": "^10.16.0",
92
+ "h3": "2.0.8",
92
93
  "happy-dom": "^21.0.4",
94
+ "nitro": "3.0.261103-rc",
93
95
  "nuxt": "^4.7.0",
94
96
  "typescript": "~6.0.3",
95
97
  "vitepress": "2.0.0-alpha.18",
96
98
  "vitest": "^5.1.2",
97
99
  "vue-tsc": "^3.3.14"
98
100
  },
101
+ "peerDependencies": {
102
+ "nitro": ">=3.0.261103-rc",
103
+ "nuxt": ">=4.7.0"
104
+ },
99
105
  "packageManager": "pnpm@11.21.0+sha512.521705bce689924eac72f5a3587122f362689ef6571e55ba80076fd637c11132ecffada26fad4ea79c485bfddbfd3d5a2a5b05805a77e893de71ec8a6cca3bb1"
100
106
  }
@@ -1,15 +0,0 @@
1
- export type LuceneNode = {
2
- kind: 'clause';
3
- text: string;
4
- } | {
5
- kind: 'and' | 'or';
6
- parts: LuceneNode[];
7
- } | {
8
- kind: 'not';
9
- node: LuceneNode;
10
- };
11
- export declare class UnsupportedExpressionError extends Error {
12
- constructor(expression: string, reason: string);
13
- }
14
- /** `null` for an empty expression; throws {@link UnsupportedExpressionError} for anything it cannot read. */
15
- export declare function parseLuceneExpression(expression: string): LuceneNode | null;
@@ -1,74 +0,0 @@
1
- export class UnsupportedExpressionError extends Error {
2
- constructor(expression, reason) {
3
- super(`Cannot negate this expression (${reason}): ${expression}`);
4
- this.name = "UnsupportedExpressionError";
5
- }
6
- }
7
- const OPEN = /* @__PURE__ */ new Set(["(", "[", "{"]);
8
- const CLOSE = /* @__PURE__ */ new Set([")", "]", "}"]);
9
- function scan(text, visit) {
10
- let depth = 0;
11
- let inQuote = false;
12
- for (let i = 0; i < text.length; i++) {
13
- const char = text[i];
14
- if (char === "\\") {
15
- i++;
16
- continue;
17
- }
18
- if (char === '"') {
19
- inQuote = !inQuote;
20
- continue;
21
- }
22
- if (inQuote) continue;
23
- if (CLOSE.has(char)) depth--;
24
- const found = visit(char, i, depth);
25
- if (found !== void 0) return found;
26
- if (OPEN.has(char)) depth++;
27
- }
28
- return void 0;
29
- }
30
- function matchingClose(text, start) {
31
- const index = scan(text.slice(start), (char, i, depth) => char === ")" && depth === 0 ? i : void 0);
32
- return index === void 0 ? -1 : start + index;
33
- }
34
- function splitTopLevel(text) {
35
- const parts = [];
36
- const operators = /* @__PURE__ */ new Set();
37
- let last = 0;
38
- scan(text, (char, i, depth) => {
39
- if (char !== " " || depth !== 0) return void 0;
40
- for (const operator of ["AND", "OR"]) {
41
- const token = ` ${operator} `;
42
- if (text.startsWith(token, i)) {
43
- parts.push(text.slice(last, i));
44
- operators.add(operator);
45
- last = i + token.length;
46
- return void 0;
47
- }
48
- }
49
- return void 0;
50
- });
51
- parts.push(text.slice(last));
52
- return { parts: parts.map((part) => part.trim()), operators };
53
- }
54
- export function parseLuceneExpression(expression) {
55
- const text = expression.trim();
56
- if (text === "" || text === "()") return null;
57
- return parse(text, expression);
58
- }
59
- function parse(text, original) {
60
- if (text.startsWith("NOT ") || text.startsWith("!")) throw new UnsupportedExpressionError(original, "NOT is not supported");
61
- if (text.startsWith("-(") && matchingClose(text, 1) === text.length - 1) {
62
- return { kind: "not", node: parse(text.slice(2, -1).trim(), original) };
63
- }
64
- if (text.startsWith("(")) {
65
- const close = matchingClose(text, 0);
66
- if (close === -1) throw new UnsupportedExpressionError(original, "unbalanced parentheses");
67
- if (close === text.length - 1) return parse(text.slice(1, -1).trim(), original);
68
- }
69
- const { parts, operators } = splitTopLevel(text);
70
- if (operators.size === 0) return { kind: "clause", text };
71
- if (operators.size > 1) throw new UnsupportedExpressionError(original, "AND and OR mixed without parentheses");
72
- if (parts.includes("")) throw new UnsupportedExpressionError(original, "empty operand");
73
- return { kind: operators.has("AND") ? "and" : "or", parts: parts.map((part) => parse(part, original)) };
74
- }