@sfxcode/nuxt-ui-mongocamp 1.3.3 → 1.3.4

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/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.4",
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
  }
@@ -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,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>;
@@ -51,8 +51,21 @@ export default () => {
51
51
  async function clearCollection(collectionName) {
52
52
  return collectionApi.clearCollection({ collectionName }, withTimeout());
53
53
  }
54
+ async function collectionIsGone(collectionName) {
55
+ try {
56
+ return !(await collectionApi.listCollections(withTimeout())).includes(collectionName);
57
+ } catch {
58
+ return false;
59
+ }
60
+ }
54
61
  async function deleteCollection(collectionName) {
55
- return collectionApi.deleteCollection({ collectionName }, withTimeout());
62
+ try {
63
+ return await collectionApi.deleteCollection({ collectionName }, withTimeout());
64
+ } catch (error) {
65
+ const status = error?.response?.status;
66
+ if (status === 500 && await collectionIsGone(collectionName)) return { value: true };
67
+ throw error;
68
+ }
56
69
  }
57
70
  async function getJsonSchema(collectionName) {
58
71
  return collectionApi.getJsonSchema({ collectionName }, withTimeout());
@@ -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
  }
@@ -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 (1.5 and still 1.6.1) 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 (1.5 and still 1.6.1) 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.
@@ -506,7 +506,7 @@
506
506
  "errors": {
507
507
  "forbidden": "Diese Pipeline verwendet {operator}, was hier nicht erlaubt ist.",
508
508
  "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."
509
+ "unavailable": "Der Server hat diese Anfrage nicht beantwortet. Versuche es erneut."
510
510
  },
511
511
  "modeVisual": "Stufen",
512
512
  "modeJson": "JSON",
@@ -506,7 +506,7 @@
506
506
  "errors": {
507
507
  "forbidden": "This pipeline uses {operator}, which is not allowed here.",
508
508
  "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."
509
+ "unavailable": "The server did not answer this request. Try again."
510
510
  },
511
511
  "modeVisual": "Stages",
512
512
  "modeJson": "JSON",
@@ -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
- 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.4",
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/",
@@ -63,29 +63,29 @@
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
  }