@sfxcode/nuxt-ui-mongocamp 1.5.8 → 2.0.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 +5 -5
- package/dist/module.json +1 -1
- package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampAggregationBuilder.vue +5 -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 -2
- package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampBucketFiles.vue +4 -6
- package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampCollectionCharts.vue +4 -2
- package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampCollectionCopy.vue +5 -3
- package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampCollectionData.vue +60 -25
- package/dist/runtime/components/MongocampCollectionInfos.vue +16 -1
- package/dist/runtime/components/MongocampDocumentView.vue +6 -1
- package/dist/runtime/components/MongocampExportAll.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampExportAll.vue +12 -0
- package/dist/runtime/components/MongocampExportAll.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampImport.vue +3 -0
- package/dist/runtime/components/MongocampIndexes.vue +7 -3
- package/dist/runtime/components/MongocampQueryBar.vue +15 -0
- package/dist/runtime/components/MongocampServerInfo.vue +1 -14
- package/dist/runtime/components/MongocampServerStatus.vue +7 -2
- package/dist/runtime/components/MongocampVersion.d.vue.ts +1 -1
- package/dist/runtime/components/MongocampVersion.vue +14 -7
- package/dist/runtime/components/MongocampVersion.vue.d.ts +1 -1
- package/dist/runtime/composables/useMongocampAdmin.js +6 -5
- package/dist/runtime/composables/useMongocampAggregation.d.ts +10 -1
- package/dist/runtime/composables/useMongocampAggregation.js +17 -5
- package/dist/runtime/composables/useMongocampBucket.d.ts +4 -0
- package/dist/runtime/composables/useMongocampBucket.js +7 -6
- package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +6 -4
- package/dist/runtime/composables/useMongocampBulkByFilter.js +11 -6
- package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +3 -1
- package/dist/runtime/composables/useMongocampCollectionCopy.js +4 -2
- package/dist/runtime/composables/useMongocampCollectionStats.js +2 -4
- package/dist/runtime/composables/useMongocampError.d.ts +1 -1
- package/dist/runtime/composables/useMongocampError.js +4 -1
- package/dist/runtime/composables/useMongocampExportAll.d.ts +10 -1
- package/dist/runtime/composables/useMongocampExportAll.js +4 -1
- package/dist/runtime/composables/useMongocampFetchAll.d.ts +11 -5
- package/dist/runtime/composables/useMongocampFetchAll.js +8 -8
- package/dist/runtime/composables/useMongocampJobs.js +3 -2
- package/dist/runtime/composables/useMongocampQuery.d.ts +26 -36
- package/dist/runtime/composables/useMongocampQuery.js +45 -48
- package/dist/runtime/composables/useMongocampSchema.js +2 -0
- package/dist/runtime/locales/de.json +12 -4
- package/dist/runtime/locales/en.json +12 -4
- package/dist/runtime/publicUtils.d.ts +1 -0
- package/dist/runtime/publicUtils.js +1 -0
- package/dist/runtime/server/handlers/mongocampProxy.d.ts +1 -1
- package/dist/runtime/server/handlers/mongocampProxy.js +12 -12
- package/dist/runtime/utils/aggregationPipeline.d.ts +2 -1
- package/dist/runtime/utils/aggregationPipeline.js +2 -3
- package/dist/runtime/utils/caseInsensitive.d.ts +10 -0
- package/dist/runtime/utils/caseInsensitive.js +8 -0
- package/dist/runtime/utils/collectionStats.d.ts +4 -1
- package/dist/runtime/utils/collectionStats.js +2 -2
- package/dist/runtime/utils/configRows.d.ts +3 -3
- package/dist/runtime/utils/cursorPaging.d.ts +16 -0
- package/dist/runtime/utils/cursorPaging.js +17 -0
- package/dist/runtime/utils/documentCompare.js +2 -3
- package/dist/runtime/utils/documentPaths.d.ts +5 -5
- package/dist/runtime/utils/documentPaths.js +9 -2
- package/dist/runtime/utils/documentTree.js +3 -0
- package/dist/runtime/utils/fileFilter.d.ts +7 -0
- package/dist/runtime/utils/fileFilter.js +11 -0
- package/dist/runtime/utils/filterBuilder.d.ts +1 -1
- package/dist/runtime/utils/filterBuilder.js +5 -11
- package/dist/runtime/utils/filterSuggestions.js +1 -1
- package/dist/runtime/utils/indexForm.d.ts +7 -0
- package/dist/runtime/utils/indexForm.js +9 -0
- package/dist/runtime/utils/pagedFetch.d.ts +13 -0
- package/dist/runtime/utils/pagedFetch.js +44 -0
- package/dist/runtime/utils/queryState.d.ts +5 -0
- package/dist/runtime/utils/queryState.js +3 -2
- package/dist/runtime/utils/relaxedValues.d.ts +17 -0
- package/dist/runtime/utils/relaxedValues.js +51 -0
- package/dist/runtime/utils/requestLimits.d.ts +1 -1
- package/dist/runtime/utils/requestLimits.js +1 -1
- package/dist/runtime/utils/savedQueries.d.ts +2 -0
- package/dist/runtime/utils/savedQueries.js +1 -0
- package/dist/runtime/utils/schemaAnalysis.d.ts +4 -4
- package/dist/runtime/utils/schemaAnalysis.js +2 -2
- package/dist/runtime/utils/sensitiveFields.d.ts +20 -0
- package/dist/runtime/utils/sensitiveFields.js +63 -0
- package/dist/runtime/utils/serverError.d.ts +7 -0
- package/dist/runtime/utils/serverError.js +11 -0
- package/dist/runtime/utils/serverStatus.d.ts +2 -2
- package/package.json +12 -6
- package/dist/runtime/utils/luceneExpression.d.ts +0 -15
- package/dist/runtime/utils/luceneExpression.js +0 -74
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMongocampClientApi } from "#imports";
|
|
2
2
|
import { readJsonKeepingLongs } from "../utils/bigIntJson.js";
|
|
3
|
-
import {
|
|
3
|
+
import { fetchAllByCursor } from "../utils/pagedFetch.js";
|
|
4
4
|
import { headerNumber } from "../utils/paginationHeaders.js";
|
|
5
5
|
const PAGE_TIMEOUT_MS = 6e4;
|
|
6
6
|
function requestInit(signal) {
|
|
@@ -10,17 +10,17 @@ function requestInit(signal) {
|
|
|
10
10
|
export function useMongocampFetchAll() {
|
|
11
11
|
const { documentApi, fileApi } = useMongocampClientApi();
|
|
12
12
|
async function fetchAllDocuments(collectionName, options = {}) {
|
|
13
|
-
const { filter, sort, projection, ...paging } = options;
|
|
14
|
-
return
|
|
15
|
-
const response = await documentApi.searchDocumentsRaw({ collectionName, searchRequest: { filter, sort, projection },
|
|
16
|
-
return { rows: await readJsonKeepingLongs(response), total: headerNumber(response.raw?.headers, "x-pagination-count-rows") };
|
|
13
|
+
const { filter, filterCaseInsensitive, sort, projection, ...paging } = options;
|
|
14
|
+
return fetchAllByCursor(async (after, pageSize, first) => {
|
|
15
|
+
const response = await documentApi.searchDocumentsRaw({ collectionName, searchRequest: { filter, sort, projection }, after, count: first ? "exact" : "none", rowsPerPage: pageSize, extendedJson: "relaxed", filterCaseInsensitive }, requestInit(options.signal));
|
|
16
|
+
return { rows: await readJsonKeepingLongs(response), next: response.raw?.headers.get("x-pagination-next") || void 0, total: headerNumber(response.raw?.headers, "x-pagination-count-rows") };
|
|
17
17
|
}, paging);
|
|
18
18
|
}
|
|
19
19
|
async function fetchAllFiles(bucketName, options = {}) {
|
|
20
20
|
const { filter, sort, projection, ...paging } = options;
|
|
21
|
-
return
|
|
22
|
-
const response = await fileApi.listFilesRaw({ bucketName, filter, sort, projection,
|
|
23
|
-
return { rows: await readJsonKeepingLongs(response), total: headerNumber(response.raw?.headers, "x-pagination-count-rows") };
|
|
21
|
+
return fetchAllByCursor(async (after, pageSize, first) => {
|
|
22
|
+
const response = await fileApi.listFilesRaw({ bucketName, filter, sort, projection, after, count: first ? "exact" : "none", rowsPerPage: pageSize }, requestInit(options.signal));
|
|
23
|
+
return { rows: await readJsonKeepingLongs(response), next: response.raw?.headers.get("x-pagination-next") || void 0, total: headerNumber(response.raw?.headers, "x-pagination-count-rows") };
|
|
24
24
|
}, paging);
|
|
25
25
|
}
|
|
26
26
|
return { fetchAllDocuments, fetchAllFiles };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMongocampClientApi } from "#imports";
|
|
2
|
+
import { ignoringNotFound } from "../utils/serverError.js";
|
|
2
3
|
export function useMongocampJobs() {
|
|
3
4
|
const { jobApi } = useMongocampClientApi();
|
|
4
5
|
async function listJobs() {
|
|
@@ -18,8 +19,8 @@ export function useMongocampJobs() {
|
|
|
18
19
|
return result.value;
|
|
19
20
|
}
|
|
20
21
|
async function deleteJob(jobGroup, jobName) {
|
|
21
|
-
const result = await jobApi.deleteJob({ jobGroup, jobName });
|
|
22
|
-
return result.value;
|
|
22
|
+
const result = await ignoringNotFound(() => jobApi.deleteJob({ jobGroup, jobName }));
|
|
23
|
+
return result ? result.value : true;
|
|
23
24
|
}
|
|
24
25
|
return { listJobs, listPossibleJobs, registerJob, updateJob, executeJob, deleteJob };
|
|
25
26
|
}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
/** Scalar value accepted by all query helpers. `null` and `undefined` produce an empty (no-op) expression. */
|
|
2
2
|
export type QueryValue = string | number | boolean | null | undefined;
|
|
3
3
|
/**
|
|
4
|
-
* What kind of values a field holds
|
|
5
|
-
*
|
|
4
|
+
* What kind of values a field holds. Server 2.0 tests existence the same way for every type, so this no longer changes the
|
|
5
|
+
* query; it is still accepted so existing calls keep compiling.
|
|
6
|
+
* @deprecated not needed with MongoCamp 2.0
|
|
6
7
|
*/
|
|
7
8
|
export type ExistsFieldType = 'text' | 'number' | 'date';
|
|
8
9
|
export interface MongocampQueryHelper {
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* MongoCamp (last verified on 1.6.3, not re-checked on 1.8) does not understand `_exists_:field` (it matches nothing), and `field:*` only matches text,
|
|
14
|
-
* which is why this is not just a wildcard.
|
|
11
|
+
* `_exists_:field` — the field is present, whatever its type (text, number, date, boolean, array, object). Like
|
|
12
|
+
* MongoDB's `$exists`, a field holding `null`, `''` or `[]` exists too. `type` is ignored (kept for older calls).
|
|
15
13
|
*/
|
|
16
14
|
exists: (fieldName: string, type?: ExistsFieldType) => string;
|
|
17
|
-
/**
|
|
18
|
-
* Matches documents where the field is absent: every `exists` clause negated and ANDed (negating the
|
|
19
|
-
* whole group is silently ignored by the server).
|
|
20
|
-
*/
|
|
15
|
+
/** `-_exists_:field` — the field is absent. */
|
|
21
16
|
notExists: (fieldName: string, type?: ExistsFieldType) => string;
|
|
22
17
|
/** Alias for `notExists`. */
|
|
23
18
|
isEmpty: (fieldName: string, type?: ExistsFieldType) => string;
|
|
@@ -36,14 +31,11 @@ export interface MongocampQueryHelper {
|
|
|
36
31
|
/**
|
|
37
32
|
* `field:[from TO to]` — inclusive range.
|
|
38
33
|
*
|
|
39
|
-
* Pass `null` (or `'*'`) for an open end
|
|
40
|
-
* the far bound of the other bound's type: the 64-bit integer limits for numbers, year 0001 / 9999 for
|
|
41
|
-
* dates. Both ends open means "has a value" and returns `exists(field)`. An open end next to a *text*
|
|
42
|
-
* bound can't be expressed and still becomes `*`, which the server rejects.
|
|
34
|
+
* Pass `null` (or `'*'`) for an open end (`[x TO *]`); both ends open is `exists(field)`.
|
|
43
35
|
*
|
|
44
|
-
* A date without a time is
|
|
45
|
-
*
|
|
46
|
-
*
|
|
36
|
+
* A date without a time is midnight UTC for the server, so as the **upper** bound it is widened to the end of that day
|
|
37
|
+
* (`T23:59:59.999Z`) — "up to 2024-06-15" includes the 15th. Characters that would break out of the range (brackets,
|
|
38
|
+
* quotes, whitespace…) in a bound are escaped.
|
|
47
39
|
*/
|
|
48
40
|
inRange: (fieldName: string, from: QueryValue, to: QueryValue) => string;
|
|
49
41
|
/**
|
|
@@ -105,14 +97,19 @@ export interface MongocampQueryHelper {
|
|
|
105
97
|
/**
|
|
106
98
|
* `_id:"<hex>"` — the document with this id. The id must be a 24-character hex ObjectId (any case); anything else
|
|
107
99
|
* **throws** a `TypeError` instead of returning `''`, because "no filter" would match every document. (A wildcard on
|
|
108
|
-
* `_id` matches nothing on the server, so there is no `like` for ids.)
|
|
100
|
+
* `_id` matches nothing on the server, so there is no `like` for ids.) Takes the id as text or as a relaxed read returns
|
|
101
|
+
* it, `{ $oid }`.
|
|
109
102
|
*/
|
|
110
|
-
byId: (id: string
|
|
103
|
+
byId: (id: string | {
|
|
104
|
+
$oid: string;
|
|
105
|
+
}) => string;
|
|
111
106
|
/**
|
|
112
107
|
* `_id:("a" OR "b")` — any of these documents. Every id must be a 24-character hex ObjectId or it throws, like `byId`.
|
|
113
108
|
* An empty array returns `''` (no clause), as `inClause` does.
|
|
114
109
|
*/
|
|
115
|
-
byIds: (ids: string
|
|
110
|
+
byIds: (ids: Array<string | {
|
|
111
|
+
$oid: string;
|
|
112
|
+
}>) => string;
|
|
116
113
|
/** `field:true` — a boolean field that is true. A document without the field does not match. */
|
|
117
114
|
isTrue: (fieldName: string) => string;
|
|
118
115
|
/** `field:false` — a boolean field that is false. A document without the field does not match. */
|
|
@@ -123,32 +120,25 @@ export interface MongocampQueryHelper {
|
|
|
123
120
|
*/
|
|
124
121
|
arrayContains: (fieldName: string, value: QueryValue) => string;
|
|
125
122
|
/**
|
|
126
|
-
*
|
|
127
|
-
* `
|
|
128
|
-
* arrays of *text* (verified: `nums:*` matched no array of numbers). Pass `type` when you know the element type for the
|
|
129
|
-
* shorter clause. Arrays of booleans and of objects are not covered (nothing matches them).
|
|
123
|
+
* `field.0:*` — the field is an array with at least one element, of any type (an empty array and a missing field do
|
|
124
|
+
* not match). `type` is ignored (kept for older calls).
|
|
130
125
|
*/
|
|
131
126
|
hasItems: (fieldName: string, type?: ExistsFieldType) => string;
|
|
132
127
|
/**
|
|
133
|
-
* The whole UTC day `YYYY-MM-DD`: `field:[YYYY-MM-
|
|
134
|
-
*
|
|
135
|
-
* real calendar date.
|
|
128
|
+
* The whole UTC day `YYYY-MM-DD`: `field:[YYYY-MM-DD TO YYYY-MM-DDT23:59:59.999Z]` (a bare date is midnight, so the upper
|
|
129
|
+
* bound is the end of the day). Throws a `TypeError` for anything that is not a real calendar date.
|
|
136
130
|
*/
|
|
137
131
|
onDay: (fieldName: string, day: string) => string;
|
|
138
132
|
/** `-field:[the whole UTC day]` — everything except that day (documents without the field included). */
|
|
139
133
|
notOnDay: (fieldName: string, day: string) => string;
|
|
140
134
|
/**
|
|
141
|
-
* The negation of any expression
|
|
142
|
-
*
|
|
143
|
-
* De Morgan's law as `((-A) OR (-B))` — each negated clause in its own parentheses, which the server needs — and a
|
|
144
|
-
* negated `OR` group as `((-A) AND (-B))`, recursively. A single clause becomes `-clause` (and `-clause` becomes
|
|
145
|
-
* `clause`). Returns `''` for an empty expression. Throws `UnsupportedExpressionError` for text it cannot read
|
|
146
|
-
* (`NOT …`, `AND`/`OR` mixed without parentheses) rather than guessing.
|
|
135
|
+
* The negation of any expression: `-(expression)` — server 2.0 follows Lucene, so `-(A AND B)` is "not both". A single
|
|
136
|
+
* clause becomes `-clause` and `-clause` becomes `clause`. Returns `''` for an empty expression.
|
|
147
137
|
*/
|
|
148
138
|
not: (queryPart: string | null | undefined) => string;
|
|
149
|
-
/** The negation of "all of these": `notAnd(a, b)` =
|
|
139
|
+
/** The negation of "all of these": `notAnd(a, b)` = `-(a AND b)`. Empty parts are ignored. */
|
|
150
140
|
notAnd: (...queryParts: (string | null | undefined)[]) => string;
|
|
151
|
-
/** The negation of "any of these": `notOr(a, b)` =
|
|
141
|
+
/** The negation of "any of these": `notOr(a, b)` = `-(a OR b)`. Empty parts are ignored. */
|
|
152
142
|
notOr: (...queryParts: (string | null | undefined)[]) => string;
|
|
153
143
|
}
|
|
154
144
|
export declare function useMongocampQuery(): MongocampQueryHelper;
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { escapeFieldName } from "../utils/escapeFieldName.js";
|
|
2
2
|
import { isIsoDateTimeString } from "../utils/isoDate.js";
|
|
3
3
|
import { isObjectIdHex } from "../utils/objectId.js";
|
|
4
|
-
import { parseLuceneExpression } from "../utils/luceneExpression.js";
|
|
5
4
|
import { useMongocampQueryBuilder } from "./useMongocampQueryBuilder.js";
|
|
6
|
-
|
|
7
|
-
const DATE_BOUNDS = { from: "0001-01-01T00:00:00Z", to: "9999-12-31T23:59:59.999Z" };
|
|
8
|
-
const PLAIN_NUMBER_REGEX = /^-?(?:\d+(?:\.\d+)?|\.\d+)$/;
|
|
5
|
+
import { idOf } from "../utils/relaxedValues.js";
|
|
9
6
|
const DATE_ONLY_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
10
|
-
function boundKind(value) {
|
|
11
|
-
if (PLAIN_NUMBER_REGEX.test(value)) return "number";
|
|
12
|
-
if (isIsoDateTimeString(value)) return "date";
|
|
13
|
-
return "other";
|
|
14
|
-
}
|
|
15
7
|
function boundText(value) {
|
|
16
8
|
if (value == null) return null;
|
|
17
9
|
const text = value.toString().trim();
|
|
@@ -20,33 +12,48 @@ function boundText(value) {
|
|
|
20
12
|
function escapeBound(value) {
|
|
21
13
|
return value.replace(/[\s[\]{}()"\\^~!&|]/g, "\\$&");
|
|
22
14
|
}
|
|
23
|
-
function
|
|
24
|
-
return DATE_ONLY_REGEX.test(value) ? `${value}
|
|
15
|
+
function endOfDay(value) {
|
|
16
|
+
return DATE_ONLY_REGEX.test(value) && isIsoDateTimeString(value) ? `${value}T23:59:59.999Z` : value;
|
|
17
|
+
}
|
|
18
|
+
function isSingleTerm(text) {
|
|
19
|
+
if (text.startsWith("(") || text.startsWith("-(")) return false;
|
|
20
|
+
let quoted = false;
|
|
21
|
+
let depth = 0;
|
|
22
|
+
for (let i = 0; i < text.length; i++) {
|
|
23
|
+
const char = text[i];
|
|
24
|
+
if (char === "\\") i++;
|
|
25
|
+
else if (char === '"') quoted = !quoted;
|
|
26
|
+
else if (quoted) continue;
|
|
27
|
+
else if (char === "[" || char === "{" || char === "(") depth++;
|
|
28
|
+
else if (char === "]" || char === "}" || char === ")") depth--;
|
|
29
|
+
else if (depth === 0 && /\s/.test(char)) return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
25
32
|
}
|
|
26
|
-
function
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
function isWrappedGroup(text) {
|
|
34
|
+
if (!text.startsWith("(") || !text.endsWith(")")) return false;
|
|
35
|
+
let quoted = false;
|
|
36
|
+
let depth = 0;
|
|
37
|
+
for (let i = 0; i < text.length; i++) {
|
|
38
|
+
const char = text[i];
|
|
39
|
+
if (char === "\\") i++;
|
|
40
|
+
else if (char === '"') quoted = !quoted;
|
|
41
|
+
else if (quoted) continue;
|
|
42
|
+
else if (char === "(") depth++;
|
|
43
|
+
else if (char === ")" && --depth === 0 && i < text.length - 1) return false;
|
|
44
|
+
}
|
|
45
|
+
return depth === 0;
|
|
30
46
|
}
|
|
31
47
|
export function useMongocampQuery() {
|
|
32
48
|
const { q } = useMongocampQueryBuilder();
|
|
33
49
|
function fieldTerm(fieldName, value) {
|
|
34
50
|
return q.field(escapeFieldName(fieldName), value);
|
|
35
51
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
if (!type || type === "text") clauses.push(fieldTerm(fieldName, "*"));
|
|
39
|
-
if (!type || type === "number") clauses.push(fieldTerm(fieldName, q.range(NUMBER_BOUNDS.from, NUMBER_BOUNDS.to)));
|
|
40
|
-
if (!type || type === "date") clauses.push(fieldTerm(fieldName, q.range(DATE_BOUNDS.from, DATE_BOUNDS.to)));
|
|
41
|
-
return clauses;
|
|
42
|
-
}
|
|
43
|
-
function exists(fieldName, type) {
|
|
44
|
-
const clauses = existsClauses(fieldName, type);
|
|
45
|
-
return clauses.length === 1 ? clauses[0] : `(${clauses.join(" OR ")})`;
|
|
52
|
+
function exists(fieldName, _type) {
|
|
53
|
+
return q.field("_exists_", escapeFieldName(fieldName));
|
|
46
54
|
}
|
|
47
55
|
function notExists(fieldName, type) {
|
|
48
|
-
|
|
49
|
-
return clauses.length === 1 ? clauses[0] : and(...clauses);
|
|
56
|
+
return `-${exists(fieldName, type)}`;
|
|
50
57
|
}
|
|
51
58
|
function isEmpty(fieldName, type) {
|
|
52
59
|
return notExists(fieldName, type);
|
|
@@ -66,9 +73,8 @@ export function useMongocampQuery() {
|
|
|
66
73
|
const lower = boundText(from);
|
|
67
74
|
const upper = boundText(to);
|
|
68
75
|
if (lower === null && upper === null) return exists(fieldName);
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const toStr = upper === null ? farBound(kind, "to") : escapeBound(boundKind(upper) === "date" ? widenDate(upper, "to") : upper);
|
|
76
|
+
const fromStr = lower === null ? "*" : escapeBound(lower);
|
|
77
|
+
const toStr = upper === null ? "*" : escapeBound(endOfDay(upper));
|
|
72
78
|
return fieldTerm(fieldName, q.range(fromStr, toStr));
|
|
73
79
|
}
|
|
74
80
|
function notInRange(fieldName, from, to) {
|
|
@@ -134,10 +140,10 @@ export function useMongocampQuery() {
|
|
|
134
140
|
return id;
|
|
135
141
|
}
|
|
136
142
|
function byId(id) {
|
|
137
|
-
return equals("_id", requireObjectId(id, "byId"));
|
|
143
|
+
return equals("_id", requireObjectId(idOf(id) ?? id, "byId"));
|
|
138
144
|
}
|
|
139
145
|
function byIds(ids) {
|
|
140
|
-
return inClause("_id", ids.map((id) => requireObjectId(id, "byIds")));
|
|
146
|
+
return inClause("_id", ids.map((id) => requireObjectId(idOf(id) ?? id, "byIds")));
|
|
141
147
|
}
|
|
142
148
|
function isTrue(fieldName) {
|
|
143
149
|
return fieldTerm(fieldName, "true");
|
|
@@ -149,8 +155,8 @@ export function useMongocampQuery() {
|
|
|
149
155
|
if (value == null || value.toString().length === 0) return "";
|
|
150
156
|
return inClause(fieldName, [value]);
|
|
151
157
|
}
|
|
152
|
-
function hasItems(fieldName,
|
|
153
|
-
return
|
|
158
|
+
function hasItems(fieldName, _type) {
|
|
159
|
+
return q.field(`${escapeFieldName(fieldName)}.0`, "*");
|
|
154
160
|
}
|
|
155
161
|
function requireDay(day, helper) {
|
|
156
162
|
const parsed = DATE_ONLY_REGEX.test(day) ? /* @__PURE__ */ new Date(`${day}T00:00:00Z`) : null;
|
|
@@ -165,21 +171,12 @@ export function useMongocampQuery() {
|
|
|
165
171
|
function notOnDay(fieldName, day) {
|
|
166
172
|
return `-${onDay(fieldName, requireDay(day, "notOnDay"))}`;
|
|
167
173
|
}
|
|
168
|
-
function render(node) {
|
|
169
|
-
if (node.kind === "clause") return node.text;
|
|
170
|
-
if (node.kind === "not") return negate(node.node);
|
|
171
|
-
const parts = node.parts.map(render);
|
|
172
|
-
return node.kind === "and" ? and(...parts) : or(...parts);
|
|
173
|
-
}
|
|
174
|
-
function negate(node) {
|
|
175
|
-
if (node.kind === "clause") return node.text.startsWith("-") ? node.text.slice(1) : `-${node.text}`;
|
|
176
|
-
if (node.kind === "not") return render(node.node);
|
|
177
|
-
const negated = node.parts.map(negate);
|
|
178
|
-
return node.kind === "and" ? or(...negated) : and(...negated);
|
|
179
|
-
}
|
|
180
174
|
function not(queryPart) {
|
|
181
|
-
const
|
|
182
|
-
|
|
175
|
+
const text = (queryPart ?? "").trim();
|
|
176
|
+
if (text === "" || text === "()") return "";
|
|
177
|
+
if (isSingleTerm(text)) return text.startsWith("-") ? text.slice(1) : `-${text}`;
|
|
178
|
+
if (text.startsWith("-") && isWrappedGroup(text.slice(1))) return text.slice(1);
|
|
179
|
+
return isWrappedGroup(text) ? `-${text}` : `-(${text})`;
|
|
183
180
|
}
|
|
184
181
|
function notAnd(...queryParts) {
|
|
185
182
|
return not(and(...queryParts));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isTextValue, leafWrapperText } from "../utils/relaxedValues.js";
|
|
1
2
|
const DATE_TIME_STRING_REGEX = /^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;
|
|
2
3
|
function isDateTimeString(value) {
|
|
3
4
|
return DATE_TIME_STRING_REGEX.test(value);
|
|
@@ -12,6 +13,7 @@ function detectValueType(value) {
|
|
|
12
13
|
if (typeof value === "string") return isDateTimeString(value) ? "date-time" : "string";
|
|
13
14
|
if (Array.isArray(value)) return "array";
|
|
14
15
|
if (isPlainObject(value)) {
|
|
16
|
+
if (isTextValue(value) || leafWrapperText(value) !== void 0) return "string";
|
|
15
17
|
if ("$date" in value) return "date-time";
|
|
16
18
|
if ("$oid" in value) return "string";
|
|
17
19
|
if ("$numberInt" in value || "$numberLong" in value || "$numberDouble" in value || "$numberDecimal" in value) return "number";
|
|
@@ -200,7 +200,8 @@
|
|
|
200
200
|
"chartsPick": "Wählen Sie ein Feld, um seine Verteilung zu sehen",
|
|
201
201
|
"presenceSummary": "Diagramm Feldhäufigkeit",
|
|
202
202
|
"presenceLabel": "Anteil der Dokumente mit dem Feld (%)",
|
|
203
|
-
"presenceDescription": "Die {count} Felder, die in den wenigsten Dokumenten vorkommen"
|
|
203
|
+
"presenceDescription": "Die {count} Felder, die in den wenigsten Dokumenten vorkommen",
|
|
204
|
+
"loadFailedTitle": "{name} konnte nicht geladen werden"
|
|
204
205
|
},
|
|
205
206
|
"collectionData": {
|
|
206
207
|
"filterPlaceholder": "Zeilen filtern...",
|
|
@@ -256,7 +257,8 @@
|
|
|
256
257
|
"chartScopeAll": "Alle {count} Dokumente der Sammlung. | Alle {count} Dokumente der Sammlung.",
|
|
257
258
|
"chartScopeFiltered": "Das {count} Dokument, das zum aktuellen Filter passt. | Die {count} Dokumente, die zum aktuellen Filter passen.",
|
|
258
259
|
"chartTooLong": "Der aktuelle Filter ist zu lang für eine Diagrammanfrage. Bitte zuerst einschränken.",
|
|
259
|
-
"aggregateTooltip": "Die passenden Dokumente aggregieren"
|
|
260
|
+
"aggregateTooltip": "Die passenden Dokumente aggregieren",
|
|
261
|
+
"sensitiveFieldsNote": "Passwörter und API-Keys sind ausgeblendet, und die Collection ist hier schreibgeschützt – Benutzer werden auf der Benutzerseite verwaltet."
|
|
260
262
|
},
|
|
261
263
|
"bucketFiles": {
|
|
262
264
|
"filterPlaceholder": "Nach Dateiname filtern...",
|
|
@@ -399,7 +401,6 @@
|
|
|
399
401
|
"importMaxBytes": "Größter Import",
|
|
400
402
|
"grantDeniedStatus": "Status bei fehlender Berechtigung",
|
|
401
403
|
"deniedStages": "Abgelehnte Aggregations-Operatoren",
|
|
402
|
-
"olderServer": "Dieser Server hat keine Capabilities-Route (älter als 1.9.0).",
|
|
403
404
|
"partFailed": "{part} konnte nicht geladen werden.",
|
|
404
405
|
"partStats": "Die Datenbanklast",
|
|
405
406
|
"partCapabilities": "Die Fähigkeiten",
|
|
@@ -443,6 +444,7 @@
|
|
|
443
444
|
"network": "Der Server ist nicht erreichbar oder deine Sitzung ist abgelaufen. Erneut versuchen oder neu anmelden.",
|
|
444
445
|
"unauthorized": "Deine Sitzung ist abgelaufen. Bitte melde dich erneut an.",
|
|
445
446
|
"forbidden": "Dafür fehlt dir die Berechtigung.",
|
|
447
|
+
"notFound": "Es existiert nicht (mehr). Vielleicht wurde es gelöscht oder umbenannt.",
|
|
446
448
|
"notAllowed": "Der Server erlaubt diese Anfrage nicht.",
|
|
447
449
|
"notAllowedOperator": "Der Server erlaubt den Operator {operator} nicht.",
|
|
448
450
|
"serverMessage": "Meldung des Servers: {message}",
|
|
@@ -615,12 +617,14 @@
|
|
|
615
617
|
"importFile": "Datei importieren",
|
|
616
618
|
"ndjsonImporting": "Der Server liest die Datei …",
|
|
617
619
|
"ndjsonFailed": "{failed} von {read} Zeilen konnten nicht importiert werden",
|
|
620
|
+
"ndjsonAborted": "Nichts wurde importiert – der Server hat nichts aus der Datei behalten. Ursache beheben und die ganze Datei erneut senden.",
|
|
618
621
|
"ndjsonLine": "Zeile {line}: {reason}",
|
|
619
622
|
"ndjsonMoreErrors": "Nur die ersten fehlgeschlagenen Zeilen werden genannt."
|
|
620
623
|
},
|
|
621
624
|
"aggregation": {
|
|
622
625
|
"errors": {
|
|
623
626
|
"forbidden": "Diese Pipeline verwendet {operator}, was hier nicht erlaubt ist.",
|
|
627
|
+
"sensitiveField": "Diese Pipeline liest {field}, ein ausgeblendetes Feld der MongoCamp-Benutzer (Passwort-Hash oder API-Key).",
|
|
624
628
|
"retryable": "Die Anfrage wurde auf dem Weg zum Server blockiert. Bitte erneut versuchen.",
|
|
625
629
|
"unavailable": "Der Server hat diese Anfrage nicht beantwortet. Versuche es erneut.",
|
|
626
630
|
"filterTooLong": "Der Filter ist zu lang für ein Diagramm (höchstens {max} Zeichen). Bitte zuerst einschränken."
|
|
@@ -774,7 +778,9 @@
|
|
|
774
778
|
"wordFilter": "Filter",
|
|
775
779
|
"wordSort": "Sortierung",
|
|
776
780
|
"wordFields": "Felder",
|
|
777
|
-
"customFilter": "Filtertext: {query}"
|
|
781
|
+
"customFilter": "Filtertext: {query}",
|
|
782
|
+
"matchCase": "Groß-/Kleinschreibung beachten",
|
|
783
|
+
"matchCaseHint": "Aus: Suche und Platzhalter im Filter ignorieren Groß- und Kleinschreibung. An: sie müssen genau passen, was bei großen Collections schneller ist."
|
|
778
784
|
},
|
|
779
785
|
"indexes": {
|
|
780
786
|
"columnUsage": "Nutzung",
|
|
@@ -876,6 +882,8 @@
|
|
|
876
882
|
"scopeFiltered": "Die Dokumente von {collection}, die zum aktuellen Filter passen",
|
|
877
883
|
"count": "{count} Dokument | {count} Dokumente",
|
|
878
884
|
"formatLabel": "Format",
|
|
885
|
+
"exactTypes": "Genaue Zahlentypen behalten",
|
|
886
|
+
"exactTypesHint": "Größere Datei; ein erneuter Import behält ganze Zahlen genau als Int32 bzw. Int64. Ohne diese Option ist die Datei leichter lesbar und ein erneuter Import speichert ganze Zahlen als Int64.",
|
|
879
887
|
"formatJson": "JSON (ein Array)",
|
|
880
888
|
"formatNdjson": "NDJSON (ein Dokument pro Zeile)",
|
|
881
889
|
"formatCsv": "CSV",
|
|
@@ -200,7 +200,8 @@
|
|
|
200
200
|
"chartsPick": "Choose a field to see its distribution",
|
|
201
201
|
"presenceSummary": "Field presence chart",
|
|
202
202
|
"presenceLabel": "Share of documents that have the field (%)",
|
|
203
|
-
"presenceDescription": "The {count} fields found in the fewest documents"
|
|
203
|
+
"presenceDescription": "The {count} fields found in the fewest documents",
|
|
204
|
+
"loadFailedTitle": "Could not load {name}"
|
|
204
205
|
},
|
|
205
206
|
"collectionData": {
|
|
206
207
|
"filterPlaceholder": "Filter rows...",
|
|
@@ -256,7 +257,8 @@
|
|
|
256
257
|
"chartScopeAll": "All {count} document of the collection. | All {count} documents of the collection.",
|
|
257
258
|
"chartScopeFiltered": "The {count} document that match the current filter. | The {count} documents that match the current filter.",
|
|
258
259
|
"chartTooLong": "The current filter is too long to send with a chart request. Narrow it first.",
|
|
259
|
-
"aggregateTooltip": "Aggregate the matching documents"
|
|
260
|
+
"aggregateTooltip": "Aggregate the matching documents",
|
|
261
|
+
"sensitiveFieldsNote": "Passwords and API keys are hidden, and the collection is read-only here — manage users on the users page."
|
|
260
262
|
},
|
|
261
263
|
"bucketFiles": {
|
|
262
264
|
"filterPlaceholder": "Filter by filename...",
|
|
@@ -399,7 +401,6 @@
|
|
|
399
401
|
"importMaxBytes": "Largest import",
|
|
400
402
|
"grantDeniedStatus": "Status for a missing grant",
|
|
401
403
|
"deniedStages": "Refused aggregation operators",
|
|
402
|
-
"olderServer": "This server has no capabilities route (older than 1.9.0).",
|
|
403
404
|
"partFailed": "{part} could not be loaded.",
|
|
404
405
|
"partStats": "The database load",
|
|
405
406
|
"partCapabilities": "The capabilities",
|
|
@@ -443,6 +444,7 @@
|
|
|
443
444
|
"network": "The server could not be reached, or your session has expired. Try again, or log in again.",
|
|
444
445
|
"unauthorized": "Your session has expired. Please log in again.",
|
|
445
446
|
"forbidden": "You do not have permission to do this.",
|
|
447
|
+
"notFound": "It does not exist (any more). It may have been deleted or renamed.",
|
|
446
448
|
"notAllowed": "The server does not allow this request.",
|
|
447
449
|
"notAllowedOperator": "The server does not allow the operator {operator}.",
|
|
448
450
|
"serverMessage": "Server message: {message}",
|
|
@@ -615,12 +617,14 @@
|
|
|
615
617
|
"importFile": "Import file",
|
|
616
618
|
"ndjsonImporting": "The server is reading the file…",
|
|
617
619
|
"ndjsonFailed": "{failed} of {read} lines could not be imported",
|
|
620
|
+
"ndjsonAborted": "Nothing was imported — the server kept none of the file. Fix the cause and send the whole file again.",
|
|
618
621
|
"ndjsonLine": "Line {line}: {reason}",
|
|
619
622
|
"ndjsonMoreErrors": "Only the first failed lines are named."
|
|
620
623
|
},
|
|
621
624
|
"aggregation": {
|
|
622
625
|
"errors": {
|
|
623
626
|
"forbidden": "This pipeline uses {operator}, which is not allowed here.",
|
|
627
|
+
"sensitiveField": "This pipeline reads {field}, a hidden field of MongoCamp's users (password hash or API key).",
|
|
624
628
|
"retryable": "The request was blocked on its way to the server. Try again.",
|
|
625
629
|
"unavailable": "The server did not answer this request. Try again.",
|
|
626
630
|
"filterTooLong": "The filter is too long to chart ({max} characters at most). Narrow it first."
|
|
@@ -774,7 +778,9 @@
|
|
|
774
778
|
"wordFilter": "Filter",
|
|
775
779
|
"wordSort": "Sort",
|
|
776
780
|
"wordFields": "Fields",
|
|
777
|
-
"customFilter": "Filter text: {query}"
|
|
781
|
+
"customFilter": "Filter text: {query}",
|
|
782
|
+
"matchCase": "Match case",
|
|
783
|
+
"matchCaseHint": "Off: the search and filter wildcards ignore upper and lower case. On: they match the case exactly, which is faster on large collections."
|
|
778
784
|
},
|
|
779
785
|
"indexes": {
|
|
780
786
|
"columnUsage": "Usage",
|
|
@@ -876,6 +882,8 @@
|
|
|
876
882
|
"scopeFiltered": "The documents of {collection} that match the current filter",
|
|
877
883
|
"count": "{count} document | {count} documents",
|
|
878
884
|
"formatLabel": "Format",
|
|
885
|
+
"exactTypes": "Keep exact number types",
|
|
886
|
+
"exactTypesHint": "Larger file; a re-import keeps whole numbers as Int32 and Int64 exactly as stored. Without it the file is easier to read and a re-import stores whole numbers as Int64.",
|
|
879
887
|
"formatJson": "JSON (one array)",
|
|
880
888
|
"formatNdjson": "NDJSON (one document per line)",
|
|
881
889
|
"formatCsv": "CSV",
|
|
@@ -3,3 +3,4 @@ export { connectionUsage, formatCount, formatUptime } from './utils/serverInfo.j
|
|
|
3
3
|
export { groupCollectionNames } from './utils/collectionNames.js';
|
|
4
4
|
export { bucketNameOf, isBucketMemberCollection, isProtectedCollection } from './utils/collectionProtection.js';
|
|
5
5
|
export { isNetworkFailure } from './utils/connection.js';
|
|
6
|
+
export { idOf } from './utils/relaxedValues.js';
|
|
@@ -3,3 +3,4 @@ export { connectionUsage, formatCount, formatUptime } from "./utils/serverInfo.j
|
|
|
3
3
|
export { groupCollectionNames } from "./utils/collectionNames.js";
|
|
4
4
|
export { bucketNameOf, isBucketMemberCollection, isProtectedCollection } from "./utils/collectionProtection.js";
|
|
5
5
|
export { isNetworkFailure } from "./utils/connection.js";
|
|
6
|
+
export { idOf } from "./utils/relaxedValues.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("h3").
|
|
1
|
+
declare const _default: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<import("h3").HTTPResponse>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { createError,
|
|
2
|
-
import { useNitroApp
|
|
1
|
+
import { createError, defineHandler, getRequestURL, proxyRequest } from "h3";
|
|
2
|
+
import { useNitroApp } from "nitro/app";
|
|
3
|
+
import { useRuntimeConfig } from "nitro/runtime-config";
|
|
3
4
|
import { consola } from "consola";
|
|
4
5
|
let warnedMissingAuthorizeHook = false;
|
|
5
6
|
function hasAuthorizeHookRegistered(hooks) {
|
|
7
|
+
if (!hooks) return false;
|
|
6
8
|
const bag = hooks._hooks;
|
|
7
9
|
if (!bag) return true;
|
|
8
10
|
return (bag["mongocamp-proxy:authorize"]?.length ?? 0) > 0;
|
|
9
11
|
}
|
|
10
|
-
export default
|
|
11
|
-
const config = useRuntimeConfig(
|
|
12
|
+
export default defineHandler(async (event) => {
|
|
13
|
+
const config = useRuntimeConfig();
|
|
12
14
|
const options = config.public.nuxtUiMongocampOptions;
|
|
13
15
|
if (!options?.useServerProxy) {
|
|
14
16
|
throw createError({ statusCode: 404, statusMessage: "Not Found" });
|
|
@@ -20,7 +22,7 @@ export default defineEventHandler(async (event) => {
|
|
|
20
22
|
"[nuxt-ui-mongocamp] `useServerProxy` is enabled but no `mongocamp-proxy:authorize` hook is registered. The proxy route is unguarded: any caller who can reach it gets the full power of the configured MongoCamp api key. Register a guard from your own `server/plugins/*.ts` \u2014 see docs/guide/server-proxy-auth.md."
|
|
21
23
|
);
|
|
22
24
|
}
|
|
23
|
-
await nitroHooks
|
|
25
|
+
await nitroHooks?.callHook("mongocamp-proxy:authorize", event);
|
|
24
26
|
const serverProxyPath = (options.serverProxyPath ?? "/api/_mongocamp").replace(/\/+$/, "");
|
|
25
27
|
const mongocampUrl = config.public.mongocamp?.url;
|
|
26
28
|
const apiKey = config.mongocampApiKey ?? "";
|
|
@@ -34,12 +36,10 @@ export default defineEventHandler(async (event) => {
|
|
|
34
36
|
const subPath = requestUrl.pathname.slice(serverProxyPath.length);
|
|
35
37
|
const target = `${mongocampUrl}${subPath}${requestUrl.search}`;
|
|
36
38
|
return proxyRequest(event, target, {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"Authorization": ""
|
|
43
|
-
}
|
|
39
|
+
// Drop any Authorization header (and the app's cookies) the caller sent — auth against
|
|
40
|
+
// MongoCamp in proxy mode must only ever come from the server-side api key below, never
|
|
41
|
+
// from whatever a caller (legitimate or not) put on their own request.
|
|
42
|
+
filterHeaders: ["authorization", "cookie"],
|
|
43
|
+
headers: { "X-AUTH-APIKEY": apiKey }
|
|
44
44
|
});
|
|
45
45
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const FORBIDDEN_OPERATORS: readonly ["$out", "$merge", "$function", "$accumulator", "$where", "$
|
|
1
|
+
export declare const FORBIDDEN_OPERATORS: readonly ["$out", "$merge", "$function", "$accumulator", "$where", "$currentOp", "$listSessions", "$collStats", "$indexStats"];
|
|
2
2
|
export declare const STATS_OPERATORS: readonly ["$collStats", "$indexStats"];
|
|
3
3
|
export declare const VISUAL_STAGE_TYPES: readonly ["$match", "$group", "$sort", "$project", "$limit", "$unwind", "$addFields", "$count", "$bucketAuto"];
|
|
4
4
|
export type AggregationStageType = typeof VISUAL_STAGE_TYPES[number];
|
|
@@ -15,6 +15,7 @@ export interface ForbiddenUse {
|
|
|
15
15
|
stageIndex: number;
|
|
16
16
|
operator: string;
|
|
17
17
|
path: string;
|
|
18
|
+
sensitive?: boolean;
|
|
18
19
|
}
|
|
19
20
|
export type PipelineErrorCode = 'too-large' | 'invalid-json' | 'not-array' | 'too-many-stages' | 'stage-shape' | 'forbidden-operator' | 'too-deep';
|
|
20
21
|
export interface PipelineError {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** `true` when the server should match the wildcards of `filter` without regard to case; `undefined` = send nothing. */
|
|
2
|
+
export declare function caseInsensitiveFlag(filter: string | undefined, matchCase?: boolean): true | undefined;
|
|
3
|
+
/** The options a filtered request takes besides the filter itself. */
|
|
4
|
+
export interface FilterCallOptions {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
/** Match the filter's wildcards without regard to case (see `caseInsensitiveFlag`). */
|
|
7
|
+
filterCaseInsensitive?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** Accepts the old positional `AbortSignal` as well as the options object. */
|
|
10
|
+
export declare function filterCallOptions(value: AbortSignal | FilterCallOptions | undefined): FilterCallOptions;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const UNESCAPED_WILDCARD = /(?:^|[^\\])[*?]/;
|
|
2
|
+
export function caseInsensitiveFlag(filter, matchCase = false) {
|
|
3
|
+
return !matchCase && filter !== void 0 && UNESCAPED_WILDCARD.test(filter) ? true : void 0;
|
|
4
|
+
}
|
|
5
|
+
export function filterCallOptions(value) {
|
|
6
|
+
if (value === void 0) return {};
|
|
7
|
+
return typeof AbortSignal !== "undefined" && value instanceof AbortSignal ? { signal: value } : value;
|
|
8
|
+
}
|
|
@@ -27,5 +27,8 @@ export interface IndexUsage {
|
|
|
27
27
|
/** A non-negative finite number, else 0 (a missing or malformed number is not worth failing a card for). */
|
|
28
28
|
export declare function toCount(value: unknown): number;
|
|
29
29
|
export declare function mapStorage(status: Partial<CollectionStatus>): CollectionStorage;
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Index usage as typed rows: from `GET …/index/stats` (`{ name, key, ops, since }`, server 2.0) or from raw `$indexStats`
|
|
32
|
+
* rows (`accesses.ops` / `accesses.since`); rows without a name are skipped.
|
|
33
|
+
*/
|
|
31
34
|
export declare function mapIndexUsage(rows: Array<Record<string, unknown>>): IndexUsage[];
|
|
@@ -29,12 +29,12 @@ export function mapIndexUsage(rows) {
|
|
|
29
29
|
for (const row of rows) {
|
|
30
30
|
if (typeof row.name !== "string" || row.name === "") continue;
|
|
31
31
|
const accesses = isRecord(row.accesses) ? row.accesses : {};
|
|
32
|
-
const ops = toCount(accesses.ops);
|
|
32
|
+
const ops = toCount(row.ops ?? accesses.ops);
|
|
33
33
|
out.push({
|
|
34
34
|
name: row.name,
|
|
35
35
|
key: isRecord(row.key) ? row.key : {},
|
|
36
36
|
ops,
|
|
37
|
-
since: isoOrNull(accesses.since),
|
|
37
|
+
since: isoOrNull(row.since ?? accesses.since),
|
|
38
38
|
unused: ops === 0
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -11,8 +11,8 @@ export declare function isSecretConfigKey(key: string): boolean;
|
|
|
11
11
|
export declare function buildConfigRows(configurations: unknown): ConfigRow[];
|
|
12
12
|
export declare const GRANT_STATUS_KEY = "AUTH_GRANT_DENIED_STATUS";
|
|
13
13
|
/**
|
|
14
|
-
* Whether the server
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Whether the server answers a missing grant with `401` (the default of server 2.0, `AUTH_GRANT_DENIED_STATUS`): a generated
|
|
15
|
+
* client clears the session on a 401, which this module works around by turning that 401 into a 403 itself. `false` when the
|
|
16
|
+
* setting is `403`, absent or unreadable.
|
|
17
17
|
*/
|
|
18
18
|
export declare function grantStatusHint(rows: readonly ConfigRow[]): boolean;
|