@sfxcode/nuxt-ui-mongocamp 1.2.7 → 1.3.1

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/components/MongocampAccount.vue +10 -0
  4. package/dist/runtime/components/MongocampBucketFiles.vue +18 -3
  5. package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +16 -0
  6. package/dist/runtime/components/MongocampBulkDelete.vue +96 -0
  7. package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +16 -0
  8. package/dist/runtime/components/MongocampCollectionData.vue +258 -11
  9. package/dist/runtime/components/MongocampCollectionInfos.vue +11 -5
  10. package/dist/runtime/components/MongocampCollections.vue +18 -4
  11. package/dist/runtime/components/MongocampDashboard.d.vue.ts +25 -0
  12. package/dist/runtime/components/MongocampDashboard.vue +111 -0
  13. package/dist/runtime/components/MongocampDashboard.vue.d.ts +25 -0
  14. package/dist/runtime/components/MongocampDatabases.vue +16 -24
  15. package/dist/runtime/components/MongocampEmptyState.d.vue.ts +18 -0
  16. package/dist/runtime/components/MongocampEmptyState.vue +28 -0
  17. package/dist/runtime/components/MongocampEmptyState.vue.d.ts +18 -0
  18. package/dist/runtime/components/MongocampErrorAlert.d.vue.ts +15 -0
  19. package/dist/runtime/components/MongocampErrorAlert.vue +53 -0
  20. package/dist/runtime/components/MongocampErrorAlert.vue.d.ts +15 -0
  21. package/dist/runtime/components/MongocampFilterBuilder.d.vue.ts +20 -0
  22. package/dist/runtime/components/MongocampFilterBuilder.vue +201 -0
  23. package/dist/runtime/components/MongocampFilterBuilder.vue.d.ts +20 -0
  24. package/dist/runtime/components/MongocampJobs.vue +44 -8
  25. package/dist/runtime/components/MongocampLogin.vue +3 -2
  26. package/dist/runtime/components/MongocampRoleGrants.vue +95 -38
  27. package/dist/runtime/components/MongocampRoles.vue +153 -8
  28. package/dist/runtime/components/MongocampUsers.vue +108 -16
  29. package/dist/runtime/composables/useMongocampBulkDelete.d.ts +5 -0
  30. package/dist/runtime/composables/useMongocampBulkDelete.js +4 -0
  31. package/dist/runtime/composables/useMongocampError.d.ts +8 -0
  32. package/dist/runtime/composables/useMongocampError.js +20 -0
  33. package/dist/runtime/composables/useMongocampExport.d.ts +5 -0
  34. package/dist/runtime/composables/useMongocampExport.js +4 -0
  35. package/dist/runtime/composables/useMongocampExtendedJson.js +1 -4
  36. package/dist/runtime/composables/useMongocampFilterBuilder.d.ts +12 -0
  37. package/dist/runtime/composables/useMongocampFilterBuilder.js +13 -0
  38. package/dist/runtime/composables/useMongocampQuery.d.ts +31 -24
  39. package/dist/runtime/composables/useMongocampQuery.js +60 -16
  40. package/dist/runtime/locales/de.json +104 -7
  41. package/dist/runtime/locales/en.json +104 -7
  42. package/dist/runtime/utils/bulkDelete.d.ts +8 -0
  43. package/dist/runtime/utils/bulkDelete.js +23 -0
  44. package/dist/runtime/utils/createSelectColumn.d.ts +7 -0
  45. package/dist/runtime/utils/createSelectColumn.js +19 -0
  46. package/dist/runtime/utils/escapeFieldName.d.ts +5 -0
  47. package/dist/runtime/utils/escapeFieldName.js +3 -0
  48. package/dist/runtime/utils/exportRows.d.ts +2 -0
  49. package/dist/runtime/utils/exportRows.js +18 -0
  50. package/dist/runtime/utils/filterBuilder.d.ts +31 -0
  51. package/dist/runtime/utils/filterBuilder.js +120 -0
  52. package/dist/runtime/utils/isoDate.d.ts +1 -0
  53. package/dist/runtime/utils/isoDate.js +4 -0
  54. package/package.json +14 -14
@@ -0,0 +1,120 @@
1
+ import { useMongocampQuery } from "../composables/useMongocampQuery.js";
2
+ import { escapeFieldName } from "./escapeFieldName.js";
3
+ import { isIsoDateTimeString } from "./isoDate.js";
4
+ export const FILTER_OPERATORS_BY_TYPE = {
5
+ "string": ["contains", "equals", "notEquals", "startsWith", "endsWith", "oneOf", "isEmpty", "isNotEmpty"],
6
+ "number": ["equals", "notEquals", "gte", "lte", "between", "oneOf", "isEmpty", "isNotEmpty"],
7
+ "date-time": ["gte", "lte", "between", "isEmpty", "isNotEmpty"],
8
+ "boolean": ["isTrue", "isFalse"],
9
+ "array": [],
10
+ "object": []
11
+ };
12
+ export function operatorsFor(type) {
13
+ return Object.hasOwn(FILTER_OPERATORS_BY_TYPE, type) ? FILTER_OPERATORS_BY_TYPE[type] : FILTER_OPERATORS_BY_TYPE.string;
14
+ }
15
+ export function toFilterFieldType(columnType) {
16
+ if (columnType === "integer") return "number";
17
+ return Object.hasOwn(FILTER_OPERATORS_BY_TYPE, columnType) ? columnType : "string";
18
+ }
19
+ export function operatorLabelKey(operator, type) {
20
+ const dateWording = type === "date-time" && (operator === "gte" || operator === "lte" || operator === "between");
21
+ return `nuxtUiMongocamp.filterBuilder.operators.${operator}${dateWording ? "Date" : ""}`;
22
+ }
23
+ export function conditionValueText(condition) {
24
+ const count = valueCountFor(condition.operator);
25
+ if (count === 0) return "";
26
+ const value = (condition.value ?? "").trim();
27
+ return count === 2 ? `${value} \u2013 ${(condition.value2 ?? "").trim()}` : value;
28
+ }
29
+ export function valueCountFor(operator) {
30
+ if (operator === "between") return 2;
31
+ if (operator === "isTrue" || operator === "isFalse" || operator === "isEmpty" || operator === "isNotEmpty") return 0;
32
+ return 1;
33
+ }
34
+ const PLAIN_NUMBER_REGEX = /^-?(?:\d+(?:\.\d+)?|\.\d+)$/;
35
+ function parseNumber(raw) {
36
+ return PLAIN_NUMBER_REGEX.test(raw) ? raw : null;
37
+ }
38
+ function numericTerm(field, values) {
39
+ return values.length === 1 ? `${field}:${values[0]}` : `${field}:(${values.join(" OR ")})`;
40
+ }
41
+ function parseRangeBound(type, raw) {
42
+ if (type === "number") return parseNumber(raw);
43
+ if (type === "date-time") return isIsoDateTimeString(raw) ? raw : null;
44
+ return null;
45
+ }
46
+ function existsType(type) {
47
+ if (type === "string") return "text";
48
+ if (type === "number") return "number";
49
+ if (type === "date-time") return "date";
50
+ return void 0;
51
+ }
52
+ function splitList(raw) {
53
+ return raw.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
54
+ }
55
+ export function buildCondition(condition, type) {
56
+ if (!condition.field || !operatorsFor(type).includes(condition.operator)) return "";
57
+ const h = useMongocampQuery();
58
+ const field = condition.field;
59
+ const escapedField = escapeFieldName(condition.field);
60
+ const value = (condition.value ?? "").trim();
61
+ const value2 = (condition.value2 ?? "").trim();
62
+ switch (condition.operator) {
63
+ case "isEmpty":
64
+ return h.notExists(field, existsType(type));
65
+ case "isNotEmpty":
66
+ return h.exists(field, existsType(type));
67
+ case "isTrue":
68
+ return `${escapedField}:true`;
69
+ case "isFalse":
70
+ return `${escapedField}:false`;
71
+ case "gte": {
72
+ const from = parseRangeBound(type, value);
73
+ return from === null ? "" : h.inRange(field, from, null);
74
+ }
75
+ case "lte": {
76
+ const to = parseRangeBound(type, value);
77
+ return to === null ? "" : h.inRange(field, null, to);
78
+ }
79
+ case "between": {
80
+ const from = parseRangeBound(type, value);
81
+ const to = parseRangeBound(type, value2);
82
+ return from === null || to === null ? "" : h.inRange(field, from, to);
83
+ }
84
+ case "contains":
85
+ return value ? h.like(field, value) : "";
86
+ case "startsWith":
87
+ return value ? h.startsWith(field, value) : "";
88
+ case "endsWith":
89
+ return value ? h.endsWith(field, value) : "";
90
+ case "equals":
91
+ case "notEquals": {
92
+ const negate = condition.operator === "notEquals";
93
+ if (type === "number") {
94
+ const parsed = parseNumber(value);
95
+ if (parsed === null) return "";
96
+ const expression = numericTerm(escapedField, [parsed]);
97
+ return negate ? `-${expression}` : expression;
98
+ }
99
+ return negate ? h.notEquals(field, value) : h.equals(field, value);
100
+ }
101
+ case "oneOf": {
102
+ const items = splitList(value);
103
+ if (items.length === 0) return "";
104
+ if (type === "number") {
105
+ const numbers = items.map(parseNumber);
106
+ return numbers.includes(null) ? "" : numericTerm(escapedField, numbers);
107
+ }
108
+ return h.inClause(field, items);
109
+ }
110
+ }
111
+ return "";
112
+ }
113
+ export function buildFilterQuery(group, fieldTypes) {
114
+ const h = useMongocampQuery();
115
+ const parts = group.conditions.map((c) => buildCondition(c, fieldTypes[c.field] ?? "string"));
116
+ return group.match === "any" ? h.or(...parts) : h.and(...parts);
117
+ }
118
+ export function countActiveConditions(group, fieldTypes) {
119
+ return group.conditions.filter((c) => buildCondition(c, fieldTypes[c.field] ?? "string") !== "").length;
120
+ }
@@ -0,0 +1 @@
1
+ export declare function isIsoDateTimeString(value: string): boolean;
@@ -0,0 +1,4 @@
1
+ const ISO_DATE_TIME_REGEX = /^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;
2
+ export function isIsoDateTimeString(value) {
3
+ return ISO_DATE_TIME_REGEX.test(value) && !Number.isNaN(Date.parse(value));
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-ui-mongocamp",
3
- "version": "1.2.7",
3
+ "version": "1.3.1",
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/",
@@ -57,34 +57,34 @@
57
57
  "dependencies": {
58
58
  "@formkit/nuxt": "^2.1.2",
59
59
  "@internationalized/date": "^3.12.4",
60
- "@nuxt/ui": "^4.11.3",
60
+ "@nuxt/ui": "^4.12.0",
61
61
  "@nuxtjs/i18n": "^10.6.0",
62
62
  "@sfxcode/nuxt-mongocamp-server": "^1.5.2",
63
- "@sfxcode/nuxt-ui-formkit": "^1.3.6",
63
+ "@sfxcode/nuxt-ui-formkit": "^1.4.1",
64
64
  "consola": "^3.4.2",
65
65
  "defu": "^6.1.7",
66
66
  "minimatch": "^10.2.6",
67
67
  "unocss-nuxt-ui": "^1.2.2"
68
68
  },
69
69
  "devDependencies": {
70
- "@iconify-json/lucide": "^1.2.142",
71
- "@nuxt/devtools": "^4.0.0-beta.4",
70
+ "@iconify-json/lucide": "^1.2.145",
71
+ "@nuxt/devtools": "4.0.0-beta.5",
72
72
  "@nuxt/eslint-config": "^1.17.0",
73
- "@nuxt/kit": "^4.6.1",
73
+ "@nuxt/kit": "^4.6.2",
74
74
  "@nuxt/module-builder": "^1.0.3",
75
- "@nuxt/schema": "^4.6.1",
76
- "@nuxt/test-utils": "^4.3.3",
77
- "@playwright/test": "^1.64.0",
75
+ "@nuxt/schema": "^4.6.2",
76
+ "@nuxt/test-utils": "^4.3.4",
77
+ "@playwright/test": "^1.64.1",
78
78
  "@types/node": "latest",
79
- "@unhead/vue": "^3.4.2",
79
+ "@unhead/vue": "^3.4.3",
80
80
  "@vue/test-utils": "^2.5.1",
81
81
  "changelogen": "^0.6.2",
82
- "eslint": "^10.12.0",
83
- "happy-dom": "^20.14.6",
84
- "nuxt": "^4.6.1",
82
+ "eslint": "^10.13.0",
83
+ "happy-dom": "^21.0.3",
84
+ "nuxt": "^4.6.2",
85
85
  "typescript": "~6.0.3",
86
86
  "vitepress": "2.0.0-alpha.18",
87
- "vitest": "^5.0.3",
87
+ "vitest": "^5.0.5",
88
88
  "vue-tsc": "^3.3.13"
89
89
  },
90
90
  "packageManager": "pnpm@11.21.0+sha512.521705bce689924eac72f5a3587122f362689ef6571e55ba80076fd637c11132ecffada26fad4ea79c485bfddbfd3d5a2a5b05805a77e893de71ec8a6cca3bb1"