@sfxcode/nuxt-ui-mongocamp 1.3.3 → 1.3.5

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 (34) hide show
  1. package/README.md +4 -0
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +5 -3
  4. package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +5 -3
  5. package/dist/runtime/components/MongocampCollectionData.vue +3 -11
  6. package/dist/runtime/components/MongocampDashboard.d.vue.ts +5 -3
  7. package/dist/runtime/components/MongocampDashboard.vue.d.ts +5 -3
  8. package/dist/runtime/components/MongocampEmptyState.d.vue.ts +5 -3
  9. package/dist/runtime/components/MongocampEmptyState.vue.d.ts +5 -3
  10. package/dist/runtime/components/MongocampErrorAlert.vue +3 -15
  11. package/dist/runtime/components/MongocampJobs.vue +1 -1
  12. package/dist/runtime/composables/useMongocampAdmin.d.ts +6 -6
  13. package/dist/runtime/composables/useMongocampAggregation.js +8 -30
  14. package/dist/runtime/composables/useMongocampClientApi.d.ts +1 -1
  15. package/dist/runtime/composables/useMongocampProxyApi.d.ts +1 -1
  16. package/dist/runtime/composables/useMongocampQuery.d.ts +2 -2
  17. package/dist/runtime/composables/useMongocampSession.d.ts +1 -2
  18. package/dist/runtime/composables/useMongocampSession.js +2 -24
  19. package/dist/runtime/locales/de.json +1 -2
  20. package/dist/runtime/locales/en.json +1 -2
  21. package/dist/runtime/plugin.js +2 -2
  22. package/dist/runtime/utils/aggregationErrors.d.ts +1 -1
  23. package/dist/runtime/utils/aggregationErrors.js +0 -1
  24. package/dist/runtime/utils/createProxyMongocampApis.d.ts +2 -2
  25. package/dist/runtime/utils/createProxyMongocampApis.js +2 -2
  26. package/dist/runtime/utils/filterBuilder.d.ts +1 -1
  27. package/dist/runtime/utils/filterBuilder.js +8 -0
  28. package/package.json +11 -11
  29. package/dist/runtime/utils/failureKind.d.ts +0 -3
  30. package/dist/runtime/utils/failureKind.js +0 -11
  31. package/dist/runtime/utils/serverProbe.d.ts +0 -10
  32. package/dist/runtime/utils/serverProbe.js +0 -25
  33. package/dist/runtime/utils/throttled.d.ts +0 -6
  34. package/dist/runtime/utils/throttled.js +0 -16
package/README.md CHANGED
@@ -10,6 +10,10 @@ A Nuxt module that wraps [`@sfxcode/nuxt-mongocamp-server`](https://www.npmjs.co
10
10
 
11
11
  - [✨ Release Notes](/CHANGELOG.md)
12
12
 
13
+ ## Requirements
14
+
15
+ MongoCamp server **1.6.3 or later** (with `@sfxcode/nuxt-mongocamp-server` ^1.6.3). Older servers are not supported.
16
+
13
17
  ## Features
14
18
 
15
19
  - **Auth middleware** — global route guard that protects `/secured/**` (login required) and `/admin/**` (admin role required)
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "1.3.3",
7
+ "version": "1.3.5",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "3.6.1"
@@ -3,10 +3,12 @@ type __VLS_Props = {
3
3
  deleting?: boolean;
4
4
  error?: string;
5
5
  };
6
- declare var __VLS_8: {};
7
- type __VLS_Slots = {} & {
8
- actions?: (props: typeof __VLS_8) => any;
6
+ declare const __VLS_template: () => {
7
+ __VLS_Slots: {
8
+ actions?: (props: {}) => any;
9
+ };
9
10
  };
11
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
10
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
11
13
  open: () => any;
12
14
  clear: () => any;
@@ -3,10 +3,12 @@ type __VLS_Props = {
3
3
  deleting?: boolean;
4
4
  error?: string;
5
5
  };
6
- declare var __VLS_8: {};
7
- type __VLS_Slots = {} & {
8
- actions?: (props: typeof __VLS_8) => any;
6
+ declare const __VLS_template: () => {
7
+ __VLS_Slots: {
8
+ actions?: (props: {}) => any;
9
+ };
9
10
  };
11
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
10
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
11
13
  open: () => any;
12
14
  clear: () => any;
@@ -452,7 +452,7 @@ async function handleBulkDelete() {
452
452
  }
453
453
  }
454
454
  const editableFields = computed(
455
- () => filterFields.value.filter((f) => f.key !== "metaData" && isEditableField(f.key)).map((f) => ({ key: f.key, type: f.type === "array" || f.type === "object" ? "json" : f.type }))
455
+ () => filterFields.value.filter((f) => f.key !== "metaData" && isEditableField(f.key)).flatMap((f) => f.type === "objectId" ? [] : [{ key: f.key, type: f.type === "array" || f.type === "object" ? "json" : f.type }])
456
456
  );
457
457
  function bulkEditFailureReason(error) {
458
458
  if (error instanceof BulkMatchShortfall) return t("nuxtUiMongocamp.bulk.editShortfall", { matched: error.matched, expected: error.expected });
@@ -516,7 +516,7 @@ async function fetchDocuments() {
516
516
  ...index === 0 ? { meta: { class: { th: "sticky left-0 z-10 bg-default", td: "sticky left-0 z-10 bg-default" } } } : {}
517
517
  }));
518
518
  filterableColumns.value = orderedKeys.filter((k) => k !== "_id" && k !== "metaData" && typeof firstRow[k] === "string");
519
- filterFields.value = schemaFromSamples(rows).filter((c) => c.columnKey !== "_id").map((c) => ({ key: c.columnKey, type: toFilterFieldType(c.columnType) })).filter((f) => operatorsFor(f.type).length > 0);
519
+ filterFields.value = schemaFromSamples(rows).map((c) => ({ key: c.columnKey, type: c.columnKey === "_id" ? "objectId" : toFilterFieldType(c.columnType) })).filter((f) => operatorsFor(f.type).length > 0);
520
520
  if (!isBucketCollection(props.collectionName)) {
521
521
  columns.value.unshift(createSelectColumn(UCheckbox, { selectAll: t("nuxtUiMongocamp.bulk.selectAll"), selectRow: t("nuxtUiMongocamp.bulk.selectRow") }));
522
522
  }
@@ -526,19 +526,11 @@ async function fetchDocuments() {
526
526
  loadError.value = e;
527
527
  documents.value = [];
528
528
  total.value = 0;
529
- if (filter && describeError(e).kind !== "unauthorized") filterRejected.value = await loadsWithoutFilter();
529
+ filterRejected.value = Boolean(filter) && e?.response?.status === 400;
530
530
  } finally {
531
531
  loading.value = false;
532
532
  }
533
533
  }
534
- async function loadsWithoutFilter() {
535
- try {
536
- await documentApi.listDocumentsRaw({ collectionName: props.collectionName, rowsPerPage: 1, page: 1 });
537
- return true;
538
- } catch {
539
- return false;
540
- }
541
- }
542
534
  function clearAllFilters() {
543
535
  filterText.value = "";
544
536
  filterDraft.value = emptyFilterGroup();
@@ -4,10 +4,12 @@ type __VLS_Props = {
4
4
  rolesPath?: string;
5
5
  };
6
6
  declare function refresh(): Promise<void>;
7
- declare var __VLS_44: {};
8
- type __VLS_Slots = {} & {
9
- default?: (props: typeof __VLS_44) => any;
7
+ declare const __VLS_template: () => {
8
+ __VLS_Slots: {
9
+ default?: (props: {}) => any;
10
+ };
10
11
  };
12
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
11
13
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
12
14
  refresh: typeof refresh;
13
15
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
@@ -4,10 +4,12 @@ type __VLS_Props = {
4
4
  rolesPath?: string;
5
5
  };
6
6
  declare function refresh(): Promise<void>;
7
- declare var __VLS_44: {};
8
- type __VLS_Slots = {} & {
9
- default?: (props: typeof __VLS_44) => any;
7
+ declare const __VLS_template: () => {
8
+ __VLS_Slots: {
9
+ default?: (props: {}) => any;
10
+ };
10
11
  };
12
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
11
13
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
12
14
  refresh: typeof refresh;
13
15
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
@@ -3,10 +3,12 @@ type __VLS_Props = {
3
3
  title?: string;
4
4
  description?: string;
5
5
  };
6
- declare var __VLS_6: {};
7
- type __VLS_Slots = {} & {
8
- default?: (props: typeof __VLS_6) => any;
6
+ declare const __VLS_template: () => {
7
+ __VLS_Slots: {
8
+ default?: (props: {}) => any;
9
+ };
9
10
  };
11
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
10
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
13
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
12
14
  declare const _default: typeof __VLS_export;
@@ -3,10 +3,12 @@ type __VLS_Props = {
3
3
  title?: string;
4
4
  description?: string;
5
5
  };
6
- declare var __VLS_6: {};
7
- type __VLS_Slots = {} & {
8
- default?: (props: typeof __VLS_6) => any;
6
+ declare const __VLS_template: () => {
7
+ __VLS_Slots: {
8
+ default?: (props: {}) => any;
9
+ };
9
10
  };
11
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
10
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
13
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
12
14
  declare const _default: typeof __VLS_export;
@@ -1,7 +1,6 @@
1
1
  <script setup>
2
- import { computed, ref, watch } from "vue";
2
+ import { computed } from "vue";
3
3
  import { navigateTo, useI18n, useMongocampError, useMongocampRoles, useMongocampSession } from "#imports";
4
- import { classifyFailure } from "../utils/failureKind";
5
4
  const props = defineProps({
6
5
  error: { type: null, required: true },
7
6
  title: { type: String, required: false },
@@ -11,24 +10,13 @@ const props = defineProps({
11
10
  const emit = defineEmits(["retry", "clearFilters"]);
12
11
  const { t } = useI18n();
13
12
  const { describeError } = useMongocampError();
14
- const { diagnoseFailure, invalidateSession } = useMongocampSession();
13
+ const { invalidateSession } = useMongocampSession();
15
14
  const { loginPath: configuredLoginPath } = useMongocampRoles();
16
15
  const described = computed(() => describeError(props.error));
17
- const failure = ref(null);
18
- let diagnosisRun = 0;
19
- watch(() => [props.error, props.filterRejected], async ([error, filterRejected]) => {
20
- const run = ++diagnosisRun;
21
- failure.value = null;
22
- if (!error || filterRejected) return;
23
- const kind = await classifyFailure(describeError(error).kind, diagnoseFailure);
24
- if (run === diagnosisRun) failure.value = kind;
25
- }, { immediate: true });
26
- const sessionGone = computed(() => described.value.kind === "unauthorized" || failure.value === "session-ended");
27
- const requestRefused = computed(() => failure.value === "rejected-request");
16
+ const sessionGone = computed(() => described.value.kind === "unauthorized");
28
17
  const description = computed(() => {
29
18
  if (props.filterRejected) return t("nuxtUiMongocamp.errors.filterRejected");
30
19
  if (sessionGone.value) return t("nuxtUiMongocamp.errors.unauthorized");
31
- if (requestRefused.value) return t("nuxtUiMongocamp.errors.requestRefused");
32
20
  return described.value.message;
33
21
  });
34
22
  async function loginAgain() {
@@ -134,7 +134,7 @@ function openEdit(job) {
134
134
  editJob.value = {
135
135
  name: job.name,
136
136
  group: job.group,
137
- description: job.description,
137
+ description: job.description ?? "",
138
138
  cronExpression: job.cronExpression,
139
139
  priority: job.priority
140
140
  };
@@ -1,17 +1,17 @@
1
- import type { Grant, JsonSchema, Role, UserProfile } from '@sfxcode/nuxt-mongocamp-server';
1
+ import type { Grant, JsonSchema, JsonValueBoolean, Role, UserProfile } from '@sfxcode/nuxt-mongocamp-server';
2
2
  declare const _default: () => {
3
3
  listUsers: (filter?: string) => Promise<UserProfile[]>;
4
4
  addUser: (userId: string, password: string, apiKey?: string, roles?: string[]) => Promise<UserProfile>;
5
- deleteUser: (userId: string) => Promise<import("@sfxcode/nuxt-mongocamp-server").JsonValueBoolean>;
5
+ deleteUser: (userId: string) => Promise<JsonValueBoolean>;
6
6
  updateUserRoles: (userId: string, roles: string[]) => Promise<UserProfile>;
7
- updateUserPassword: (userId: string, password: string) => Promise<import("@sfxcode/nuxt-mongocamp-server").JsonValueBoolean>;
7
+ updateUserPassword: (userId: string, password: string) => Promise<JsonValueBoolean>;
8
8
  listRoles: (filter?: string) => Promise<Role[]>;
9
9
  addRole: (name: string, isAdmin?: boolean, collectionGrants?: Grant[]) => Promise<Role>;
10
10
  updateRole: (roleName: string, isAdmin: boolean, collectionGrants?: Grant[]) => Promise<Role>;
11
- deleteRole: (roleName: string) => Promise<import("@sfxcode/nuxt-mongocamp-server").JsonValueBoolean>;
11
+ deleteRole: (roleName: string) => Promise<JsonValueBoolean>;
12
12
  listCollections: () => Promise<string[]>;
13
- clearCollection: (collectionName: string) => Promise<import("@sfxcode/nuxt-mongocamp-server").JsonValueBoolean>;
14
- deleteCollection: (collectionName: string) => Promise<import("@sfxcode/nuxt-mongocamp-server").JsonValueBoolean>;
13
+ clearCollection: (collectionName: string) => Promise<JsonValueBoolean>;
14
+ deleteCollection: (collectionName: string) => Promise<JsonValueBoolean>;
15
15
  getJsonSchema: (collectionName: string) => Promise<JsonSchema>;
16
16
  getUser: (userId: string) => Promise<UserProfile>;
17
17
  getRole: (roleName: string) => Promise<Role>;
@@ -17,22 +17,6 @@ function headerNumber(headers, name) {
17
17
  const parsed = Number.parseInt(headers?.get(name) ?? "", 10);
18
18
  return Number.isNaN(parsed) ? void 0 : parsed;
19
19
  }
20
- async function responseMessage(error) {
21
- const response = error?.response;
22
- if (!response) return void 0;
23
- try {
24
- const body = await response.clone().json();
25
- return typeof body?.msg === "string" ? body.msg : void 0;
26
- } catch {
27
- return void 0;
28
- }
29
- }
30
- async function isEmptyResultError(error) {
31
- const status = error?.response?.status;
32
- if (status !== 500) return false;
33
- const message = await responseMessage(error);
34
- return message !== void 0 && parseServerError(message).kind === "empty-result";
35
- }
36
20
  export function useMongocampAggregation() {
37
21
  const { collectionApi } = useMongocampClientApi();
38
22
  const { describeError } = useMongocampError();
@@ -41,19 +25,13 @@ export function useMongocampAggregation() {
41
25
  const findings = findForbidden(pipeline);
42
26
  if (findings.length > 0) throw new ForbiddenPipelineError(findings);
43
27
  const page = paging.page ?? 1;
44
- let response;
45
- try {
46
- response = await collectionApi.aggregateRaw({
47
- collectionName,
48
- // the generated type says string values; the server takes any JSON. allowDiskUse is required.
49
- mongoAggregateRequest: { pipeline, allowDiskUse: false },
50
- rowsPerPage: paging.rowsPerPage,
51
- page
52
- }, withTimeout(AGGREGATE_TIMEOUT_MS));
53
- } catch (error) {
54
- if (await isEmptyResultError(error)) return { rows: [], total: 0, pages: 0, page };
55
- throw error;
56
- }
28
+ const response = await collectionApi.aggregateRaw({
29
+ collectionName,
30
+ // the generated type says string values; the server takes any JSON. allowDiskUse is required.
31
+ mongoAggregateRequest: { pipeline, allowDiskUse: false },
32
+ rowsPerPage: paging.rowsPerPage,
33
+ page
34
+ }, withTimeout(AGGREGATE_TIMEOUT_MS));
57
35
  const value = await response.value();
58
36
  const rows = Array.isArray(value) ? value.filter(isPlainObject) : [];
59
37
  const headers = response.raw?.headers;
@@ -88,7 +66,7 @@ export function useMongocampAggregation() {
88
66
  const body = await response.clone().json();
89
67
  if (typeof body?.msg === "string" && body.msg) {
90
68
  const info = parseServerError(body.msg);
91
- if (info.kind !== "empty-result" && info.message) return { kind: info.kind, message: info.message };
69
+ if (info.message) return { kind: info.kind, message: info.message };
92
70
  }
93
71
  } catch {
94
72
  }
@@ -8,6 +8,6 @@ export declare function useMongocampClientApi(): {
8
8
  documentApi: import("@sfxcode/nuxt-mongocamp-server").DocumentApi;
9
9
  fileApi: import("@sfxcode/nuxt-mongocamp-server").FileApi;
10
10
  indexApi: import("@sfxcode/nuxt-mongocamp-server").IndexApi;
11
- informationApi: import("@sfxcode/nuxt-mongocamp-server").InformationApi;
11
+ systemApi: import("@sfxcode/nuxt-mongocamp-server").SystemApi;
12
12
  jobApi: import("@sfxcode/nuxt-mongocamp-server").JobsApi;
13
13
  };
@@ -8,6 +8,6 @@ export declare function useMongocampProxyApi(): {
8
8
  documentApi: import("@sfxcode/nuxt-mongocamp-server").DocumentApi;
9
9
  fileApi: import("@sfxcode/nuxt-mongocamp-server").FileApi;
10
10
  indexApi: import("@sfxcode/nuxt-mongocamp-server").IndexApi;
11
- informationApi: import("@sfxcode/nuxt-mongocamp-server").InformationApi;
11
+ systemApi: import("@sfxcode/nuxt-mongocamp-server").SystemApi;
12
12
  jobApi: import("@sfxcode/nuxt-mongocamp-server").JobsApi;
13
13
  };
@@ -10,7 +10,7 @@ export interface MongocampQueryHelper {
10
10
  * Matches documents where the field has a value. Without `type` this ORs a text wildcard with a
11
11
  * full-range number and a full-range date clause, so it works for any of those types.
12
12
  *
13
- * MongoCamp 1.5 does not understand `_exists_:field` (it matches nothing), and `field:*` only matches text,
13
+ * MongoCamp (still, as of 1.6.3) does not understand `_exists_:field` (it matches nothing), and `field:*` only matches text,
14
14
  * which is why this is not just a wildcard.
15
15
  */
16
16
  exists: (fieldName: string, type?: ExistsFieldType) => string;
@@ -36,7 +36,7 @@ export interface MongocampQueryHelper {
36
36
  /**
37
37
  * `field:[from TO to]` — inclusive range.
38
38
  *
39
- * Pass `null` (or `'*'`) for an open end. MongoCamp 1.5 rejects `[x TO *]`, so the open end is replaced by
39
+ * Pass `null` (or `'*'`) for an open end. MongoCamp (still, as of 1.6.3) rejects `[x TO *]`, so the open end is replaced by
40
40
  * the far bound of the other bound's type: the 64-bit integer limits for numbers, year 0001 / 9999 for
41
41
  * dates. Both ends open means "has a value" and returns `exists(field)`. An open end next to a *text*
42
42
  * bound can't be expressed and still becomes `*`, which the server rejects.
@@ -1,8 +1,7 @@
1
1
  import type { TokenExpiryState } from '../utils/jwtExpiry.js';
2
- export type SessionState = 'active' | 'expired' | 'rejected' | 'unknown';
2
+ export type SessionState = 'active' | 'expired' | 'unknown';
3
3
  export declare function useMongocampSession(): {
4
4
  checkExpiry: () => TokenExpiryState;
5
5
  currentState: () => SessionState;
6
- diagnoseFailure: () => Promise<SessionState>;
7
6
  invalidateSession: () => Promise<void>;
8
7
  };
@@ -1,26 +1,11 @@
1
1
  import { useRuntimeConfig } from "#app";
2
- import { useMongocampAuth, useMongocampClientApi, useMongocampStorage } from "#imports";
2
+ import { useMongocampAuth, useMongocampStorage } from "#imports";
3
3
  import { tokenExpiryState } from "../utils/jwtExpiry.js";
4
- import { createServerProbe } from "../utils/serverProbe.js";
5
- import { createThrottled } from "../utils/throttled.js";
6
- let probe;
7
- let tokenAccepted;
8
- let authApi;
9
- const TOKEN_CHECK_TIMEOUT_MS = 5e3;
10
4
  export function useMongocampSession() {
11
5
  const config = useRuntimeConfig();
12
6
  const { logout } = useMongocampAuth();
13
7
  const storage = useMongocampStorage();
14
8
  const isProxyMode = config.public.nuxtUiMongocampOptions?.useServerProxy ?? false;
15
- probe ??= createServerProbe({ getUrl: () => config.public.mongocamp?.url });
16
- if (!isProxyMode) authApi = useMongocampClientApi().authApi;
17
- tokenAccepted ??= createThrottled(async () => {
18
- try {
19
- return (await authApi.isAuthenticated({ signal: AbortSignal.timeout(TOKEN_CHECK_TIMEOUT_MS) })).value === true;
20
- } catch {
21
- return false;
22
- }
23
- });
24
9
  function checkExpiry() {
25
10
  if (isProxyMode) return "unknown";
26
11
  const token = storage.value?.token;
@@ -30,16 +15,9 @@ export function useMongocampSession() {
30
15
  const expiry = checkExpiry();
31
16
  return expiry === "valid" ? "active" : expiry;
32
17
  }
33
- async function diagnoseFailure() {
34
- const expiry = checkExpiry();
35
- if (expiry === "expired") return "expired";
36
- if (isProxyMode || !storage.value?.token) return "unknown";
37
- if (await probe() !== "reachable") return "unknown";
38
- return await tokenAccepted() ? "active" : "rejected";
39
- }
40
18
  async function invalidateSession() {
41
19
  if (isProxyMode) return;
42
20
  await logout();
43
21
  }
44
- return { checkExpiry, currentState, diagnoseFailure, invalidateSession };
22
+ return { checkExpiry, currentState, invalidateSession };
45
23
  }
@@ -355,7 +355,6 @@
355
355
  "forbidden": "Dafür fehlt dir die Berechtigung.",
356
356
  "generic": "Etwas ist schiefgelaufen.",
357
357
  "loginAgain": "Erneut anmelden",
358
- "requestRefused": "Der Server ist erreichbar und Ihre Sitzung ist gültig, hat diese Anfrage aber abgelehnt. Versuchen Sie es erneut oder ändern Sie Ihre Anfrage.",
359
358
  "filterRejectedTitle": "Der Filter konnte nicht angewendet werden",
360
359
  "filterRejected": "Der Server hat die aktuelle Suche oder die Filter abgelehnt, obwohl die Collection selbst lädt. Setze sie zurück oder entferne die letzte Bedingung und versuche es erneut.",
361
360
  "clearFilters": "Filter zurücksetzen"
@@ -506,7 +505,7 @@
506
505
  "errors": {
507
506
  "forbidden": "Diese Pipeline verwendet {operator}, was hier nicht erlaubt ist.",
508
507
  "retryable": "Die Anfrage wurde auf dem Weg zum Server blockiert. Bitte erneut versuchen.",
509
- "unavailable": "Der Server hat diese Anfrage nicht beantwortet. Möglicherweise liefert die Pipeline keine Ergebnisse; versuche es erneut oder lockere den Filter."
508
+ "unavailable": "Der Server hat diese Anfrage nicht beantwortet. Versuche es erneut."
510
509
  },
511
510
  "modeVisual": "Stufen",
512
511
  "modeJson": "JSON",
@@ -355,7 +355,6 @@
355
355
  "forbidden": "You do not have permission to do this.",
356
356
  "generic": "Something went wrong.",
357
357
  "loginAgain": "Log in again",
358
- "requestRefused": "The server is reachable and your session is valid, but it refused this request. Try again, or change what you asked for.",
359
358
  "filterRejectedTitle": "The filter could not be applied",
360
359
  "filterRejected": "The server rejected the current search or filters, although the collection itself loads. Clear them, or remove the last condition, and try again.",
361
360
  "clearFilters": "Clear filters"
@@ -506,7 +505,7 @@
506
505
  "errors": {
507
506
  "forbidden": "This pipeline uses {operator}, which is not allowed here.",
508
507
  "retryable": "The request was blocked on its way to the server. Try again.",
509
- "unavailable": "The server did not answer this request. The pipeline may simply have no results; try again or loosen the filter."
508
+ "unavailable": "The server did not answer this request. Try again."
510
509
  },
511
510
  "modeVisual": "Stages",
512
511
  "modeJson": "JSON",
@@ -4,12 +4,12 @@ import { useMongocampRoles } from "./composables/useMongocampRoles.js";
4
4
  import { useMongocampSession } from "./composables/useMongocampSession.js";
5
5
  import { runSessionGuard } from "./utils/sessionGuard.js";
6
6
  export default defineNuxtPlugin(async (_nuxtApp) => {
7
- const { informationApi } = useMongocampClientApi();
7
+ const { systemApi } = useMongocampClientApi();
8
8
  const config = useRuntimeConfig();
9
9
  const useGlobalAuthMiddleware = config.public.nuxtUiMongocampOptions.useGlobalAuthMiddleware ?? false;
10
10
  const useServerProxy = config.public.nuxtUiMongocampOptions.useServerProxy ?? false;
11
11
  const sessionGuard = config.public.nuxtUiMongocampOptions.sessionGuard ?? false;
12
- const { data: version } = await useAsyncData("version", () => informationApi.version());
12
+ const { data: version } = await useAsyncData("version", () => systemApi.version());
13
13
  if (sessionGuard && !useServerProxy) {
14
14
  addRouteMiddleware("session-guard", async (to) => {
15
15
  const { checkExpiry, invalidateSession } = useMongocampSession();
@@ -4,7 +4,7 @@ export declare class ForbiddenPipelineError extends Error {
4
4
  constructor(findings: ForbiddenUse[]);
5
5
  }
6
6
  export interface ServerErrorInfo {
7
- kind: 'mongo' | 'empty-result' | 'other';
7
+ kind: 'mongo' | 'other';
8
8
  message: string;
9
9
  }
10
10
  export declare function parseServerError(msg: string): ServerErrorInfo;
@@ -12,6 +12,5 @@ export function parseServerError(msg) {
12
12
  const text = msg.trim();
13
13
  const command = MONGO_COMMAND_FAILED.exec(text);
14
14
  if (command) return { kind: "mongo", message: command[1].trim() };
15
- if (/^Index 0 out of bounds for length 0$/.test(text)) return { kind: "empty-result", message: text };
16
15
  return { kind: "other", message: text.replace(SERVER_ADDRESS, "").replace(BARE_ADDRESS, "").replace(/\s{2,}/g, " ").trim() };
17
16
  }
@@ -1,4 +1,4 @@
1
- import { AdminApi, ApplicationApi, AuthApi, BucketApi, CollectionApi, DatabaseApi, DocumentApi, FileApi, IndexApi, InformationApi, JobsApi } from '@sfxcode/nuxt-mongocamp-server/api';
1
+ import { AdminApi, ApplicationApi, AuthApi, BucketApi, CollectionApi, DatabaseApi, DocumentApi, FileApi, IndexApi, SystemApi, JobsApi } from '@sfxcode/nuxt-mongocamp-server/api';
2
2
  import type { Configuration } from '@sfxcode/nuxt-mongocamp-server/api';
3
3
  export declare function createProxyMongocampApis(configuration: Configuration): {
4
4
  adminApi: AdminApi;
@@ -10,6 +10,6 @@ export declare function createProxyMongocampApis(configuration: Configuration):
10
10
  documentApi: DocumentApi;
11
11
  fileApi: FileApi;
12
12
  indexApi: IndexApi;
13
- informationApi: InformationApi;
13
+ systemApi: SystemApi;
14
14
  jobApi: JobsApi;
15
15
  };
@@ -8,7 +8,7 @@ import {
8
8
  DocumentApi,
9
9
  FileApi,
10
10
  IndexApi,
11
- InformationApi,
11
+ SystemApi,
12
12
  JobsApi
13
13
  } from "@sfxcode/nuxt-mongocamp-server/api";
14
14
  export function createProxyMongocampApis(configuration) {
@@ -22,7 +22,7 @@ export function createProxyMongocampApis(configuration) {
22
22
  documentApi: new DocumentApi(configuration),
23
23
  fileApi: new FileApi(configuration),
24
24
  indexApi: new IndexApi(configuration),
25
- informationApi: new InformationApi(configuration),
25
+ systemApi: new SystemApi(configuration),
26
26
  jobApi: new JobsApi(configuration)
27
27
  };
28
28
  }
@@ -1,4 +1,4 @@
1
- export type FilterFieldType = 'string' | 'number' | 'date-time' | 'boolean' | 'array' | 'object';
1
+ export type FilterFieldType = 'string' | 'number' | 'date-time' | 'boolean' | 'array' | 'object' | 'objectId';
2
2
  export type FilterOperator = 'contains' | 'equals' | 'notEquals' | 'startsWith' | 'endsWith' | 'oneOf' | 'gte' | 'lte' | 'between' | 'isTrue' | 'isFalse' | 'isEmpty' | 'isNotEmpty';
3
3
  export interface FilterCondition {
4
4
  id: string;
@@ -1,11 +1,13 @@
1
1
  import { useMongocampQuery } from "../composables/useMongocampQuery.js";
2
2
  import { escapeFieldName } from "./escapeFieldName.js";
3
3
  import { isIsoDateTimeString } from "./isoDate.js";
4
+ import { isObjectIdHex } from "./objectId.js";
4
5
  export const FILTER_OPERATORS_BY_TYPE = {
5
6
  "string": ["contains", "equals", "notEquals", "startsWith", "endsWith", "oneOf", "isEmpty", "isNotEmpty"],
6
7
  "number": ["equals", "notEquals", "gte", "lte", "between", "oneOf", "isEmpty", "isNotEmpty"],
7
8
  "date-time": ["gte", "lte", "between", "isEmpty", "isNotEmpty"],
8
9
  "boolean": ["isTrue", "isFalse"],
10
+ "objectId": ["equals", "notEquals", "oneOf"],
9
11
  "array": [],
10
12
  "object": []
11
13
  };
@@ -59,6 +61,12 @@ export function buildCondition(condition, type) {
59
61
  const escapedField = escapeFieldName(condition.field);
60
62
  const value = (condition.value ?? "").trim();
61
63
  const value2 = (condition.value2 ?? "").trim();
64
+ if (type === "objectId") {
65
+ const ids = condition.operator === "oneOf" ? splitList(value) : [value];
66
+ if (ids.length === 0 || !ids.every(isObjectIdHex)) return "";
67
+ if (condition.operator === "oneOf") return h.inClause(field, ids);
68
+ return condition.operator === "notEquals" ? h.notEquals(field, value) : h.equals(field, value);
69
+ }
62
70
  switch (condition.operator) {
63
71
  case "isEmpty":
64
72
  return h.notExists(field, existsType(type));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-ui-mongocamp",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
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/",
@@ -59,33 +59,33 @@
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.5.2",
62
+ "@sfxcode/nuxt-mongocamp-server": "^1.6.3",
63
63
  "@sfxcode/nuxt-ui-formkit": "^1.4.1",
64
64
  "consola": "^3.4.2",
65
65
  "defu": "^6.1.7",
66
- "minimatch": "^10.2.6",
66
+ "minimatch": "^11.0.3",
67
67
  "unocss-nuxt-ui": "^1.2.2"
68
68
  },
69
69
  "devDependencies": {
70
- "@iconify-json/lucide": "^1.2.145",
71
- "@nuxt/devtools": "4.0.0-beta.5",
70
+ "@iconify-json/lucide": "^1.2.150",
71
+ "@nuxt/devtools": "^4.0.0",
72
72
  "@nuxt/eslint-config": "^1.17.0",
73
- "@nuxt/kit": "^4.6.2",
73
+ "@nuxt/kit": "^4.6.3",
74
74
  "@nuxt/module-builder": "^1.0.3",
75
- "@nuxt/schema": "^4.6.2",
75
+ "@nuxt/schema": "^4.6.3",
76
76
  "@nuxt/test-utils": "^4.3.4",
77
77
  "@playwright/test": "^1.64.1",
78
78
  "@types/node": "latest",
79
79
  "@unhead/vue": "^3.4.3",
80
80
  "@vue/test-utils": "^2.5.1",
81
81
  "changelogen": "^0.6.2",
82
- "eslint": "^10.13.0",
83
- "happy-dom": "^21.0.3",
84
- "nuxt": "^4.6.2",
82
+ "eslint": "^10.14.0",
83
+ "happy-dom": "^21.0.4",
84
+ "nuxt": "^4.6.3",
85
85
  "typescript": "~6.0.3",
86
86
  "vitepress": "2.0.0-alpha.18",
87
87
  "vitest": "^5.0.5",
88
- "vue-tsc": "^3.3.13"
88
+ "vue-tsc": "^3.3.14"
89
89
  },
90
90
  "packageManager": "pnpm@11.21.0+sha512.521705bce689924eac72f5a3587122f362689ef6571e55ba80076fd637c11132ecffada26fad4ea79c485bfddbfd3d5a2a5b05805a77e893de71ec8a6cca3bb1"
91
91
  }
@@ -1,3 +0,0 @@
1
- import type { SessionState } from '../composables/useMongocampSession.js';
2
- export type FailureKind = 'session-ended' | 'rejected-request' | 'network' | 'other';
3
- export declare function classifyFailure(kind: 'network' | 'unauthorized' | 'forbidden' | 'other', diagnose: () => Promise<SessionState>): Promise<FailureKind>;
@@ -1,11 +0,0 @@
1
- export async function classifyFailure(kind, diagnose) {
2
- if (kind === "unauthorized") return "session-ended";
3
- if (kind !== "network") return "other";
4
- try {
5
- const state = await diagnose();
6
- if (state === "expired" || state === "rejected") return "session-ended";
7
- return state === "active" ? "rejected-request" : "network";
8
- } catch {
9
- return "network";
10
- }
11
- }
@@ -1,10 +0,0 @@
1
- export type ProbeResult = 'reachable' | 'unreachable' | 'skipped';
2
- interface ServerProbeOptions {
3
- getUrl: () => string | undefined;
4
- fetchFn?: typeof fetch;
5
- now?: () => number;
6
- cooldownMs?: number;
7
- timeoutMs?: number;
8
- }
9
- export declare function createServerProbe(options: ServerProbeOptions): () => Promise<ProbeResult>;
10
- export {};
@@ -1,25 +0,0 @@
1
- import { createThrottled } from "./throttled.js";
2
- export function createServerProbe(options) {
3
- const { getUrl, fetchFn = (...args) => fetch(...args), now, cooldownMs, timeoutMs = 5e3 } = options;
4
- async function ask(url) {
5
- try {
6
- const response = await fetchFn(`${url.replace(/\/+$/, "")}/version`, {
7
- method: "GET",
8
- credentials: "omit",
9
- cache: "no-store",
10
- signal: AbortSignal.timeout(timeoutMs)
11
- });
12
- return response.ok ? "reachable" : "unreachable";
13
- } catch {
14
- return "unreachable";
15
- }
16
- }
17
- let currentUrl = "";
18
- const throttled = createThrottled(() => ask(currentUrl), { now, cooldownMs });
19
- return function probe() {
20
- const url = getUrl();
21
- if (!url) return Promise.resolve("skipped");
22
- currentUrl = url;
23
- return throttled();
24
- };
25
- }
@@ -1,6 +0,0 @@
1
- interface ThrottleOptions {
2
- now?: () => number;
3
- cooldownMs?: number;
4
- }
5
- export declare function createThrottled<T>(fn: () => Promise<T>, options?: ThrottleOptions): () => Promise<T>;
6
- export {};
@@ -1,16 +0,0 @@
1
- export function createThrottled(fn, options = {}) {
2
- const { now = Date.now, cooldownMs = 5e3 } = options;
3
- let inFlight = null;
4
- let last = null;
5
- return function throttled() {
6
- if (inFlight) return inFlight;
7
- if (last && now() - last.at < cooldownMs) return Promise.resolve(last.value);
8
- inFlight = fn().then((value) => {
9
- last = { value, at: now() };
10
- return value;
11
- }).finally(() => {
12
- inFlight = null;
13
- });
14
- return inFlight;
15
- };
16
- }