@sfxcode/nuxt-ui-mongocamp 1.3.5 → 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.d.mts +8 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +6 -0
- package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
- package/dist/runtime/components/MongocampAggregationBuilder.vue +331 -5
- package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
- package/dist/runtime/components/MongocampAggregationChart.d.vue.ts +6 -0
- package/dist/runtime/components/MongocampAggregationChart.vue +93 -0
- package/dist/runtime/components/MongocampAggregationChart.vue.d.ts +6 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +10 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.vue +149 -0
- package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +10 -0
- package/dist/runtime/components/MongocampBucketFiles.vue +230 -48
- package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +9 -0
- package/dist/runtime/components/MongocampBulkDelete.vue +94 -25
- package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +9 -0
- package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +5 -0
- package/dist/runtime/components/MongocampBulkEdit.vue +41 -3
- package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +5 -0
- package/dist/runtime/components/MongocampChart.d.vue.ts +29 -0
- package/dist/runtime/components/MongocampChart.vue +129 -0
- package/dist/runtime/components/MongocampChart.vue.d.ts +29 -0
- package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +17 -0
- package/dist/runtime/components/MongocampCollectionCharts.vue +200 -0
- package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +17 -0
- package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +23 -0
- package/dist/runtime/components/MongocampCollectionCopy.vue +206 -0
- package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +23 -0
- package/dist/runtime/components/MongocampCollectionData.d.vue.ts +6 -0
- package/dist/runtime/components/MongocampCollectionData.vue +423 -138
- package/dist/runtime/components/MongocampCollectionData.vue.d.ts +6 -0
- package/dist/runtime/components/MongocampCollectionInfos.vue +106 -238
- 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 +93 -12
- package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +40 -0
- package/dist/runtime/components/MongocampCommandPalette.vue +135 -0
- package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +40 -0
- package/dist/runtime/components/MongocampConfirmByName.vue +2 -2
- package/dist/runtime/components/MongocampDashboard.d.vue.ts +3 -1
- package/dist/runtime/components/MongocampDashboard.vue +39 -5
- package/dist/runtime/components/MongocampDashboard.vue.d.ts +3 -1
- package/dist/runtime/components/MongocampDatabases.vue +35 -2
- package/dist/runtime/components/MongocampDocumentCompare.d.vue.ts +20 -0
- package/dist/runtime/components/MongocampDocumentCompare.vue +146 -0
- package/dist/runtime/components/MongocampDocumentCompare.vue.d.ts +20 -0
- package/dist/runtime/components/MongocampDocumentView.d.vue.ts +22 -0
- package/dist/runtime/components/MongocampDocumentView.vue +202 -0
- package/dist/runtime/components/MongocampDocumentView.vue.d.ts +22 -0
- package/dist/runtime/components/MongocampErrorAlert.vue +12 -4
- package/dist/runtime/components/MongocampExportAll.d.vue.ts +18 -0
- package/dist/runtime/components/MongocampExportAll.vue +191 -0
- package/dist/runtime/components/MongocampExportAll.vue.d.ts +18 -0
- package/dist/runtime/components/MongocampFilePreview.d.vue.ts +16 -0
- package/dist/runtime/components/MongocampFilePreview.vue +162 -0
- package/dist/runtime/components/MongocampFilePreview.vue.d.ts +16 -0
- package/dist/runtime/components/MongocampFilterBuilder.vue +11 -0
- package/dist/runtime/components/MongocampImport.vue +171 -13
- package/dist/runtime/components/MongocampIndexes.d.vue.ts +18 -0
- package/dist/runtime/components/MongocampIndexes.vue +496 -0
- package/dist/runtime/components/MongocampIndexes.vue.d.ts +18 -0
- package/dist/runtime/components/MongocampJobs.d.vue.ts +6 -1
- package/dist/runtime/components/MongocampJobs.vue +36 -5
- package/dist/runtime/components/MongocampJobs.vue.d.ts +6 -1
- package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +12 -0
- package/dist/runtime/components/MongocampPermissionMatrix.vue +301 -0
- package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +12 -0
- package/dist/runtime/components/MongocampQueryBar.d.vue.ts +26 -0
- package/dist/runtime/components/MongocampQueryBar.vue +398 -0
- package/dist/runtime/components/MongocampQueryBar.vue.d.ts +26 -0
- package/dist/runtime/components/MongocampRoleGrants.vue +18 -5
- package/dist/runtime/components/MongocampRoles.vue +16 -5
- package/dist/runtime/components/MongocampServerOverview.d.vue.ts +20 -0
- package/dist/runtime/components/MongocampServerOverview.vue +420 -0
- package/dist/runtime/components/MongocampServerOverview.vue.d.ts +20 -0
- package/dist/runtime/components/MongocampSettings.d.vue.ts +28 -1
- package/dist/runtime/components/MongocampSettings.vue +83 -10
- package/dist/runtime/components/MongocampSettings.vue.d.ts +28 -1
- package/dist/runtime/components/MongocampUsers.vue +19 -6
- package/dist/runtime/composables/useMongocampAdmin.d.ts +2 -1
- package/dist/runtime/composables/useMongocampAdmin.js +6 -1
- package/dist/runtime/composables/useMongocampAdminGate.d.ts +12 -0
- package/dist/runtime/composables/useMongocampAdminGate.js +12 -0
- package/dist/runtime/composables/useMongocampAggregation.d.ts +23 -1
- package/dist/runtime/composables/useMongocampAggregation.js +41 -26
- package/dist/runtime/composables/useMongocampAutoRefresh.d.ts +26 -0
- package/dist/runtime/composables/useMongocampAutoRefresh.js +78 -0
- package/dist/runtime/composables/useMongocampBucket.d.ts +13 -1
- package/dist/runtime/composables/useMongocampBucket.js +34 -0
- package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +15 -0
- package/dist/runtime/composables/useMongocampBulkByFilter.js +32 -0
- package/dist/runtime/composables/useMongocampClientApi.js +2 -1
- package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +45 -0
- package/dist/runtime/composables/useMongocampCollectionCopy.js +48 -0
- package/dist/runtime/composables/useMongocampCollectionStats.d.ts +10 -0
- package/dist/runtime/composables/useMongocampCollectionStats.js +17 -0
- package/dist/runtime/composables/useMongocampError.d.ts +2 -1
- package/dist/runtime/composables/useMongocampError.js +16 -1
- package/dist/runtime/composables/useMongocampExportAll.d.ts +53 -0
- package/dist/runtime/composables/useMongocampExportAll.js +57 -0
- package/dist/runtime/composables/useMongocampExtendedJson.d.ts +7 -2
- package/dist/runtime/composables/useMongocampExtendedJson.js +44 -11
- package/dist/runtime/composables/useMongocampFetchAll.d.ts +25 -0
- package/dist/runtime/composables/useMongocampFetchAll.js +27 -0
- 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 +17 -0
- package/dist/runtime/composables/useMongocampPermissions.js +43 -0
- package/dist/runtime/composables/useMongocampPersistedState.d.ts +15 -0
- package/dist/runtime/composables/useMongocampPersistedState.js +21 -0
- package/dist/runtime/composables/useMongocampProxyApi.js +2 -1
- package/dist/runtime/composables/useMongocampQuery.d.ts +50 -2
- package/dist/runtime/composables/useMongocampQuery.js +72 -1
- package/dist/runtime/composables/useMongocampSavedPipelines.d.ts +25 -0
- package/dist/runtime/composables/useMongocampSavedPipelines.js +23 -0
- package/dist/runtime/composables/useMongocampSavedQueries.d.ts +37 -0
- package/dist/runtime/composables/useMongocampSavedQueries.js +50 -0
- package/dist/runtime/composables/useMongocampServerOverview.d.ts +35 -0
- package/dist/runtime/composables/useMongocampServerOverview.js +51 -0
- package/dist/runtime/composables/useMongocampSession.d.ts +2 -0
- package/dist/runtime/composables/useMongocampSession.js +16 -2
- package/dist/runtime/composables/useMongocampSystem.d.ts +7 -2
- package/dist/runtime/composables/useMongocampSystem.js +6 -2
- package/dist/runtime/locales/de.json +509 -25
- package/dist/runtime/locales/en.json +509 -25
- package/dist/runtime/plugin.js +6 -3
- package/dist/runtime/utils/aggregationErrors.d.ts +4 -0
- package/dist/runtime/utils/aggregationErrors.js +7 -0
- package/dist/runtime/utils/aggregationPipeline.d.ts +5 -4
- package/dist/runtime/utils/aggregationPipeline.js +23 -9
- package/dist/runtime/utils/aggregationPreview.d.ts +13 -0
- package/dist/runtime/utils/aggregationPreview.js +10 -0
- package/dist/runtime/utils/aggregationResult.d.ts +5 -0
- package/dist/runtime/utils/aggregationResult.js +4 -0
- package/dist/runtime/utils/aggregationTemplates.d.ts +34 -0
- package/dist/runtime/utils/aggregationTemplates.js +47 -0
- package/dist/runtime/utils/analyzeSamples.d.ts +1 -0
- package/dist/runtime/utils/analyzeSamples.js +1 -1
- package/dist/runtime/utils/autoRefresh.d.ts +14 -0
- package/dist/runtime/utils/autoRefresh.js +15 -0
- package/dist/runtime/utils/batchInsert.d.ts +6 -0
- package/dist/runtime/utils/batchInsert.js +31 -3
- package/dist/runtime/utils/bigIntJson.d.ts +15 -0
- package/dist/runtime/utils/bigIntJson.js +55 -0
- package/dist/runtime/utils/bsonTypes.d.ts +10 -0
- package/dist/runtime/utils/bsonTypes.js +42 -0
- package/dist/runtime/utils/bulkDelete.d.ts +9 -1
- package/dist/runtime/utils/bulkDelete.js +15 -3
- package/dist/runtime/utils/bulkEdit.d.ts +6 -0
- package/dist/runtime/utils/bulkEdit.js +7 -0
- package/dist/runtime/utils/chartData.d.ts +11 -0
- package/dist/runtime/utils/chartData.js +9 -0
- package/dist/runtime/utils/collectionChart.d.ts +36 -0
- package/dist/runtime/utils/collectionChart.js +73 -0
- package/dist/runtime/utils/collectionCopy.d.ts +24 -0
- package/dist/runtime/utils/collectionCopy.js +37 -0
- package/dist/runtime/utils/collectionStats.d.ts +31 -0
- package/dist/runtime/utils/collectionStats.js +42 -0
- package/dist/runtime/utils/commandPalette.d.ts +48 -0
- package/dist/runtime/utils/commandPalette.js +39 -0
- package/dist/runtime/utils/configRows.d.ts +7 -0
- package/dist/runtime/utils/configRows.js +4 -0
- package/dist/runtime/utils/documentCompare.d.ts +31 -0
- package/dist/runtime/utils/documentCompare.js +71 -0
- package/dist/runtime/utils/documentDiff.d.ts +19 -0
- package/dist/runtime/utils/documentDiff.js +71 -0
- package/dist/runtime/utils/documentPaths.d.ts +41 -0
- package/dist/runtime/utils/documentPaths.js +139 -0
- package/dist/runtime/utils/documentTree.d.ts +40 -0
- package/dist/runtime/utils/documentTree.js +102 -0
- package/dist/runtime/utils/exportDocuments.d.ts +33 -0
- package/dist/runtime/utils/exportDocuments.js +53 -0
- package/dist/runtime/utils/exportRows.d.ts +2 -0
- package/dist/runtime/utils/exportRows.js +6 -3
- package/dist/runtime/utils/fieldDetails.d.ts +51 -0
- package/dist/runtime/utils/fieldDetails.js +113 -0
- package/dist/runtime/utils/filePreview.d.ts +27 -0
- package/dist/runtime/utils/filePreview.js +50 -0
- package/dist/runtime/utils/filterBuilder.d.ts +6 -1
- package/dist/runtime/utils/filterBuilder.js +6 -5
- package/dist/runtime/utils/formatBytes.d.ts +2 -0
- package/dist/runtime/utils/formatBytes.js +11 -0
- package/dist/runtime/utils/grantMatching.d.ts +8 -0
- package/dist/runtime/utils/grantMatching.js +15 -0
- package/dist/runtime/utils/importRows.js +12 -2
- package/dist/runtime/utils/indexForm.d.ts +83 -0
- package/dist/runtime/utils/indexForm.js +74 -0
- package/dist/runtime/utils/luceneExpression.d.ts +15 -0
- package/dist/runtime/utils/luceneExpression.js +74 -0
- package/dist/runtime/utils/pagedFetch.d.ts +46 -0
- package/dist/runtime/utils/pagedFetch.js +58 -0
- package/dist/runtime/utils/paginationHeaders.d.ts +4 -0
- package/dist/runtime/utils/paginationHeaders.js +4 -0
- package/dist/runtime/utils/permissionDenied.d.ts +10 -0
- package/dist/runtime/utils/permissionDenied.js +23 -0
- package/dist/runtime/utils/permissionMatrix.d.ts +55 -0
- package/dist/runtime/utils/permissionMatrix.js +85 -0
- package/dist/runtime/utils/persistedState.d.ts +25 -0
- package/dist/runtime/utils/persistedState.js +47 -0
- package/dist/runtime/utils/queryState.d.ts +45 -0
- package/dist/runtime/utils/queryState.js +75 -0
- package/dist/runtime/utils/requestLimits.d.ts +2 -0
- package/dist/runtime/utils/requestLimits.js +4 -0
- package/dist/runtime/utils/resultChart.d.ts +32 -0
- package/dist/runtime/utils/resultChart.js +59 -0
- package/dist/runtime/utils/savedPipelines.d.ts +22 -0
- package/dist/runtime/utils/savedPipelines.js +46 -0
- package/dist/runtime/utils/savedQueries.d.ts +60 -0
- package/dist/runtime/utils/savedQueries.js +143 -0
- package/dist/runtime/utils/schemaAnalysis.d.ts +16 -0
- package/dist/runtime/utils/schemaAnalysis.js +57 -0
- package/dist/runtime/utils/serverError.d.ts +19 -0
- package/dist/runtime/utils/serverError.js +19 -0
- package/dist/runtime/utils/serverOverview.d.ts +47 -0
- package/dist/runtime/utils/serverOverview.js +40 -0
- package/dist/runtime/utils/sessionGuard.d.ts +3 -0
- package/dist/runtime/utils/sessionGuard.js +18 -1
- package/package.json +15 -14
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const OPERATOR_NOT_ALLOWED_CODE = 4031;
|
|
2
|
+
export interface ServerError {
|
|
3
|
+
/** HTTP status of the response, when there was one. */
|
|
4
|
+
status?: number;
|
|
5
|
+
/** The server's own error code from the body. */
|
|
6
|
+
code?: number;
|
|
7
|
+
/** The server's message with every database address removed (`parseServerError`); `undefined` when there is none. */
|
|
8
|
+
message?: string;
|
|
9
|
+
/** `mongo` when the message is MongoDB's own text for a failed command. */
|
|
10
|
+
kind?: 'mongo' | 'other';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reads what the server said about a failed request from the error the generated client threw. The client only
|
|
14
|
+
* keeps the `Response`, so the body is read from a clone, best-effort: anything unreadable (no response, a network
|
|
15
|
+
* failure, a non-JSON body such as a proxy's 503) just yields what is known. Never throws.
|
|
16
|
+
*/
|
|
17
|
+
export declare function readServerError(error: unknown): Promise<ServerError>;
|
|
18
|
+
/** `$function` out of "the operator $function is not allowed in an aggregation" (code 4031). */
|
|
19
|
+
export declare function notAllowedOperator(message: string | undefined): string | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { parseServerError } from "./aggregationErrors.js";
|
|
2
|
+
export const OPERATOR_NOT_ALLOWED_CODE = 4031;
|
|
3
|
+
export async function readServerError(error) {
|
|
4
|
+
const response = error?.response;
|
|
5
|
+
const status = typeof response?.status === "number" ? response.status : void 0;
|
|
6
|
+
if (!response || typeof response.clone !== "function") return { status };
|
|
7
|
+
try {
|
|
8
|
+
const body = await response.clone().json();
|
|
9
|
+
const code = typeof body?.code === "number" ? body.code : void 0;
|
|
10
|
+
if (typeof body?.msg !== "string" || !body.msg) return { status, code };
|
|
11
|
+
const info = parseServerError(body.msg);
|
|
12
|
+
return { status, code, message: info.message || void 0, kind: info.kind };
|
|
13
|
+
} catch {
|
|
14
|
+
return { status };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function notAllowedOperator(message) {
|
|
18
|
+
return /operator (\$[A-Za-z]+) is not allowed/.exec(message ?? "")?.[1];
|
|
19
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DatabaseInfo, JobInformation } from '@sfxcode/nuxt-mongocamp-server';
|
|
2
|
+
export interface CollectionStat {
|
|
3
|
+
name: string;
|
|
4
|
+
count: number;
|
|
5
|
+
/** Uncompressed size of the documents, bytes. */
|
|
6
|
+
size: number;
|
|
7
|
+
/** Size on disk, bytes. */
|
|
8
|
+
storageSize: number;
|
|
9
|
+
avgObjSize: number;
|
|
10
|
+
indexCount: number;
|
|
11
|
+
totalIndexSize: number;
|
|
12
|
+
}
|
|
13
|
+
export type RankBy = 'storageSize' | 'count' | 'avgObjSize' | 'totalIndexSize';
|
|
14
|
+
export declare const RANK_METRICS: readonly RankBy[];
|
|
15
|
+
/** Metrics that are byte sizes (the others are plain counts). */
|
|
16
|
+
export declare const BYTE_METRICS: ReadonlySet<RankBy>;
|
|
17
|
+
/** The `n` collections with the highest value of `by`, highest first (ties by name); collections with nothing in them are left out. */
|
|
18
|
+
export declare function rankCollections(stats: readonly CollectionStat[], by: RankBy, n: number): CollectionStat[];
|
|
19
|
+
export interface OverviewTotals {
|
|
20
|
+
databases: number;
|
|
21
|
+
/** Sum of the databases' size on disk, bytes (0 when they could not be read). */
|
|
22
|
+
diskBytes: number;
|
|
23
|
+
collections: number;
|
|
24
|
+
documents: number;
|
|
25
|
+
/** Sum of the collections' size on disk, bytes. */
|
|
26
|
+
storageBytes: number;
|
|
27
|
+
indexBytes: number;
|
|
28
|
+
indexes: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function overviewTotals(stats: readonly CollectionStat[], databases: readonly DatabaseInfo[] | null): OverviewTotals;
|
|
31
|
+
export interface ShareSlice {
|
|
32
|
+
/** The collection name, or `null` for the slice that sums up all the others. */
|
|
33
|
+
name: string | null;
|
|
34
|
+
value: number;
|
|
35
|
+
}
|
|
36
|
+
/** The `top` biggest collections by `by` and one slice for everything else (a donut stays readable with 6 slices). */
|
|
37
|
+
export declare function shareSlices(stats: readonly CollectionStat[], by: RankBy, top?: number): ShareSlice[];
|
|
38
|
+
export interface UpcomingJob {
|
|
39
|
+
group: string;
|
|
40
|
+
name: string;
|
|
41
|
+
cronExpression: string;
|
|
42
|
+
next: Date;
|
|
43
|
+
}
|
|
44
|
+
/** The next `n` scheduled runs, soonest first; a job without a (valid) next fire time is not scheduled and is left out. */
|
|
45
|
+
export declare function nextJobs(jobs: readonly JobInformation[], n: number): UpcomingJob[];
|
|
46
|
+
/** A collection's statistics from the server's collection information; missing or malformed numbers count as 0. */
|
|
47
|
+
export declare function toCollectionStat(name: string, info: Partial<Record<'count' | 'size' | 'storageSize' | 'avgObjSize' | 'nindexes' | 'totalIndexSize', unknown>>): CollectionStat;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const RANK_METRICS = ["storageSize", "count", "avgObjSize", "totalIndexSize"];
|
|
2
|
+
export const BYTE_METRICS = /* @__PURE__ */ new Set(["storageSize", "avgObjSize", "totalIndexSize"]);
|
|
3
|
+
export function rankCollections(stats, by, n) {
|
|
4
|
+
return stats.filter((s) => s[by] > 0).sort((a, b) => b[by] - a[by] || a.name.localeCompare(b.name)).slice(0, Math.max(0, Math.floor(n)));
|
|
5
|
+
}
|
|
6
|
+
export function overviewTotals(stats, databases) {
|
|
7
|
+
const sum = (pick) => stats.reduce((total, s) => total + pick(s), 0);
|
|
8
|
+
return {
|
|
9
|
+
databases: databases?.length ?? 0,
|
|
10
|
+
diskBytes: databases?.reduce((total, d) => total + (Number.isFinite(d.sizeOnDisk) ? d.sizeOnDisk : 0), 0) ?? 0,
|
|
11
|
+
collections: stats.length,
|
|
12
|
+
documents: sum((s) => s.count),
|
|
13
|
+
storageBytes: sum((s) => s.storageSize),
|
|
14
|
+
indexBytes: sum((s) => s.totalIndexSize),
|
|
15
|
+
indexes: sum((s) => s.indexCount)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function shareSlices(stats, by, top = 5) {
|
|
19
|
+
const ranked = rankCollections(stats, by, stats.length);
|
|
20
|
+
const slices = ranked.slice(0, top).map((s) => ({ name: s.name, value: s[by] }));
|
|
21
|
+
const rest = ranked.slice(top).reduce((total, s) => total + s[by], 0);
|
|
22
|
+
if (rest > 0) slices.push({ name: null, value: rest });
|
|
23
|
+
return slices;
|
|
24
|
+
}
|
|
25
|
+
function toDate(value) {
|
|
26
|
+
const date = value instanceof Date ? value : typeof value === "string" || typeof value === "number" ? new Date(value) : void 0;
|
|
27
|
+
return date && !Number.isNaN(date.getTime()) ? date : void 0;
|
|
28
|
+
}
|
|
29
|
+
export function nextJobs(jobs, n) {
|
|
30
|
+
const upcoming = [];
|
|
31
|
+
for (const job of jobs) {
|
|
32
|
+
const next = toDate(job.nextScheduledFireTime);
|
|
33
|
+
if (next) upcoming.push({ group: job.group, name: job.name, cronExpression: job.cronExpression, next });
|
|
34
|
+
}
|
|
35
|
+
return upcoming.sort((a, b) => a.next.getTime() - b.next.getTime() || `${a.group}/${a.name}`.localeCompare(`${b.group}/${b.name}`)).slice(0, Math.max(0, Math.floor(n)));
|
|
36
|
+
}
|
|
37
|
+
export function toCollectionStat(name, info) {
|
|
38
|
+
const n = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
39
|
+
return { name, count: n(info.count), size: n(info.size), storageSize: n(info.storageSize), avgObjSize: n(info.avgObjSize), indexCount: n(info.nindexes), totalIndexSize: n(info.totalIndexSize) };
|
|
40
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { TokenExpiryState } from './jwtExpiry.js';
|
|
2
|
+
export type VerifyResult = 'valid' | 'invalid' | 'unknown';
|
|
2
3
|
interface SessionGuardDeps {
|
|
3
4
|
path: string;
|
|
4
5
|
loginPath: string;
|
|
5
6
|
checkExpiry: () => TokenExpiryState;
|
|
6
7
|
invalidate: () => Promise<void>;
|
|
8
|
+
verify?: () => Promise<VerifyResult>;
|
|
7
9
|
isAllowed: (path: string) => boolean;
|
|
8
10
|
}
|
|
9
11
|
export declare function runSessionGuard(deps: SessionGuardDeps): Promise<'continue' | 'redirect'>;
|
|
12
|
+
export declare function createVerifyCache(ttlMs: number, now?: () => number): (key: string, run: () => Promise<VerifyResult>) => Promise<VerifyResult>;
|
|
10
13
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export async function runSessionGuard(deps) {
|
|
2
|
-
|
|
2
|
+
const expiry = deps.checkExpiry();
|
|
3
|
+
if (expiry !== "expired" && !(expiry === "valid" && deps.verify && await isRejectedByServer(deps.verify))) return "continue";
|
|
3
4
|
try {
|
|
4
5
|
await deps.invalidate();
|
|
5
6
|
} catch {
|
|
@@ -8,3 +9,19 @@ export async function runSessionGuard(deps) {
|
|
|
8
9
|
if (deps.path === deps.loginPath) return "continue";
|
|
9
10
|
return deps.isAllowed(deps.path) ? "continue" : "redirect";
|
|
10
11
|
}
|
|
12
|
+
async function isRejectedByServer(verify) {
|
|
13
|
+
try {
|
|
14
|
+
return await verify() === "invalid";
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function createVerifyCache(ttlMs, now = Date.now) {
|
|
20
|
+
let last = null;
|
|
21
|
+
return async function cached(key, run) {
|
|
22
|
+
if (last && last.key === key && now() - last.at < ttlMs) return "valid";
|
|
23
|
+
const result = await run();
|
|
24
|
+
last = result === "valid" ? { key, at: now() } : null;
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
}
|
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/",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dev": "npm run dev:prepare && nuxt dev playground",
|
|
45
45
|
"dev:build": "nuxt build playground",
|
|
46
46
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
|
|
47
|
-
"release": "npm run lint && npm run test && npm run prepack && changelogen --
|
|
47
|
+
"release": "npm run lint && npm run test && npm run prepack && changelogen --minor --release && npm publish && git push --follow-tags",
|
|
48
48
|
"lint": "eslint .",
|
|
49
49
|
"test": "vitest run --project unit --project components",
|
|
50
50
|
"test:watch": "vitest watch",
|
|
@@ -55,36 +55,37 @@
|
|
|
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.
|
|
63
|
-
"@sfxcode/nuxt-ui-formkit": "^1.4.
|
|
62
|
+
"@sfxcode/nuxt-mongocamp-server": "^1.8.0",
|
|
63
|
+
"@sfxcode/nuxt-ui-formkit": "^1.4.2",
|
|
64
|
+
"@tanstack/charts": "^1.5.0",
|
|
64
65
|
"consola": "^3.4.2",
|
|
65
66
|
"defu": "^6.1.7",
|
|
66
|
-
"minimatch": "^11.0.
|
|
67
|
+
"minimatch": "^11.0.5",
|
|
67
68
|
"unocss-nuxt-ui": "^1.2.2"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
|
-
"@iconify-json/lucide": "^1.2.
|
|
71
|
-
"@nuxt/devtools": "^4.
|
|
71
|
+
"@iconify-json/lucide": "^1.2.152",
|
|
72
|
+
"@nuxt/devtools": "^4.1.0",
|
|
72
73
|
"@nuxt/eslint-config": "^1.17.0",
|
|
73
|
-
"@nuxt/kit": "^4.6.
|
|
74
|
+
"@nuxt/kit": "^4.6.4",
|
|
74
75
|
"@nuxt/module-builder": "^1.0.3",
|
|
75
|
-
"@nuxt/schema": "^4.6.
|
|
76
|
-
"@nuxt/test-utils": "^4.
|
|
77
|
-
"@playwright/test": "^1.
|
|
76
|
+
"@nuxt/schema": "^4.6.4",
|
|
77
|
+
"@nuxt/test-utils": "^4.4.0",
|
|
78
|
+
"@playwright/test": "^1.65.0",
|
|
78
79
|
"@types/node": "latest",
|
|
79
80
|
"@unhead/vue": "^3.4.3",
|
|
80
81
|
"@vue/test-utils": "^2.5.1",
|
|
81
82
|
"changelogen": "^0.6.2",
|
|
82
83
|
"eslint": "^10.14.0",
|
|
83
84
|
"happy-dom": "^21.0.4",
|
|
84
|
-
"nuxt": "^4.6.
|
|
85
|
+
"nuxt": "^4.6.4",
|
|
85
86
|
"typescript": "~6.0.3",
|
|
86
87
|
"vitepress": "2.0.0-alpha.18",
|
|
87
|
-
"vitest": "^5.0
|
|
88
|
+
"vitest": "^5.1.0",
|
|
88
89
|
"vue-tsc": "^3.3.14"
|
|
89
90
|
},
|
|
90
91
|
"packageManager": "pnpm@11.21.0+sha512.521705bce689924eac72f5a3587122f362689ef6571e55ba80076fd637c11132ecffada26fad4ea79c485bfddbfd3d5a2a5b05805a77e893de71ec8a6cca3bb1"
|