@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.
Files changed (224) hide show
  1. package/README.md +1 -1
  2. package/dist/module.d.mts +8 -0
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +6 -0
  5. package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
  6. package/dist/runtime/components/MongocampAggregationBuilder.vue +331 -5
  7. package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
  8. package/dist/runtime/components/MongocampAggregationChart.d.vue.ts +6 -0
  9. package/dist/runtime/components/MongocampAggregationChart.vue +93 -0
  10. package/dist/runtime/components/MongocampAggregationChart.vue.d.ts +6 -0
  11. package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +10 -0
  12. package/dist/runtime/components/MongocampAggregationStagePreview.vue +149 -0
  13. package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +10 -0
  14. package/dist/runtime/components/MongocampBucketFiles.vue +230 -48
  15. package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +9 -0
  16. package/dist/runtime/components/MongocampBulkDelete.vue +94 -25
  17. package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +9 -0
  18. package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +5 -0
  19. package/dist/runtime/components/MongocampBulkEdit.vue +41 -3
  20. package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +5 -0
  21. package/dist/runtime/components/MongocampChart.d.vue.ts +29 -0
  22. package/dist/runtime/components/MongocampChart.vue +129 -0
  23. package/dist/runtime/components/MongocampChart.vue.d.ts +29 -0
  24. package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +17 -0
  25. package/dist/runtime/components/MongocampCollectionCharts.vue +200 -0
  26. package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +17 -0
  27. package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +23 -0
  28. package/dist/runtime/components/MongocampCollectionCopy.vue +206 -0
  29. package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +23 -0
  30. package/dist/runtime/components/MongocampCollectionData.d.vue.ts +6 -0
  31. package/dist/runtime/components/MongocampCollectionData.vue +423 -138
  32. package/dist/runtime/components/MongocampCollectionData.vue.d.ts +6 -0
  33. package/dist/runtime/components/MongocampCollectionInfos.vue +106 -238
  34. package/dist/runtime/components/MongocampCollectionRename.d.vue.ts +22 -0
  35. package/dist/runtime/components/MongocampCollectionRename.vue +116 -0
  36. package/dist/runtime/components/MongocampCollectionRename.vue.d.ts +22 -0
  37. package/dist/runtime/components/MongocampCollections.vue +93 -12
  38. package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +40 -0
  39. package/dist/runtime/components/MongocampCommandPalette.vue +135 -0
  40. package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +40 -0
  41. package/dist/runtime/components/MongocampConfirmByName.vue +2 -2
  42. package/dist/runtime/components/MongocampDashboard.d.vue.ts +3 -1
  43. package/dist/runtime/components/MongocampDashboard.vue +39 -5
  44. package/dist/runtime/components/MongocampDashboard.vue.d.ts +3 -1
  45. package/dist/runtime/components/MongocampDatabases.vue +35 -2
  46. package/dist/runtime/components/MongocampDocumentCompare.d.vue.ts +20 -0
  47. package/dist/runtime/components/MongocampDocumentCompare.vue +146 -0
  48. package/dist/runtime/components/MongocampDocumentCompare.vue.d.ts +20 -0
  49. package/dist/runtime/components/MongocampDocumentView.d.vue.ts +22 -0
  50. package/dist/runtime/components/MongocampDocumentView.vue +202 -0
  51. package/dist/runtime/components/MongocampDocumentView.vue.d.ts +22 -0
  52. package/dist/runtime/components/MongocampErrorAlert.vue +12 -4
  53. package/dist/runtime/components/MongocampExportAll.d.vue.ts +18 -0
  54. package/dist/runtime/components/MongocampExportAll.vue +191 -0
  55. package/dist/runtime/components/MongocampExportAll.vue.d.ts +18 -0
  56. package/dist/runtime/components/MongocampFilePreview.d.vue.ts +16 -0
  57. package/dist/runtime/components/MongocampFilePreview.vue +162 -0
  58. package/dist/runtime/components/MongocampFilePreview.vue.d.ts +16 -0
  59. package/dist/runtime/components/MongocampFilterBuilder.vue +11 -0
  60. package/dist/runtime/components/MongocampImport.vue +171 -13
  61. package/dist/runtime/components/MongocampIndexes.d.vue.ts +18 -0
  62. package/dist/runtime/components/MongocampIndexes.vue +496 -0
  63. package/dist/runtime/components/MongocampIndexes.vue.d.ts +18 -0
  64. package/dist/runtime/components/MongocampJobs.d.vue.ts +6 -1
  65. package/dist/runtime/components/MongocampJobs.vue +36 -5
  66. package/dist/runtime/components/MongocampJobs.vue.d.ts +6 -1
  67. package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +12 -0
  68. package/dist/runtime/components/MongocampPermissionMatrix.vue +301 -0
  69. package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +12 -0
  70. package/dist/runtime/components/MongocampQueryBar.d.vue.ts +26 -0
  71. package/dist/runtime/components/MongocampQueryBar.vue +398 -0
  72. package/dist/runtime/components/MongocampQueryBar.vue.d.ts +26 -0
  73. package/dist/runtime/components/MongocampRoleGrants.vue +18 -5
  74. package/dist/runtime/components/MongocampRoles.vue +16 -5
  75. package/dist/runtime/components/MongocampServerOverview.d.vue.ts +20 -0
  76. package/dist/runtime/components/MongocampServerOverview.vue +420 -0
  77. package/dist/runtime/components/MongocampServerOverview.vue.d.ts +20 -0
  78. package/dist/runtime/components/MongocampSettings.d.vue.ts +28 -1
  79. package/dist/runtime/components/MongocampSettings.vue +83 -10
  80. package/dist/runtime/components/MongocampSettings.vue.d.ts +28 -1
  81. package/dist/runtime/components/MongocampUsers.vue +19 -6
  82. package/dist/runtime/composables/useMongocampAdmin.d.ts +2 -1
  83. package/dist/runtime/composables/useMongocampAdmin.js +6 -1
  84. package/dist/runtime/composables/useMongocampAdminGate.d.ts +12 -0
  85. package/dist/runtime/composables/useMongocampAdminGate.js +12 -0
  86. package/dist/runtime/composables/useMongocampAggregation.d.ts +23 -1
  87. package/dist/runtime/composables/useMongocampAggregation.js +41 -26
  88. package/dist/runtime/composables/useMongocampAutoRefresh.d.ts +26 -0
  89. package/dist/runtime/composables/useMongocampAutoRefresh.js +78 -0
  90. package/dist/runtime/composables/useMongocampBucket.d.ts +13 -1
  91. package/dist/runtime/composables/useMongocampBucket.js +34 -0
  92. package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +15 -0
  93. package/dist/runtime/composables/useMongocampBulkByFilter.js +32 -0
  94. package/dist/runtime/composables/useMongocampClientApi.js +2 -1
  95. package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +45 -0
  96. package/dist/runtime/composables/useMongocampCollectionCopy.js +48 -0
  97. package/dist/runtime/composables/useMongocampCollectionStats.d.ts +10 -0
  98. package/dist/runtime/composables/useMongocampCollectionStats.js +17 -0
  99. package/dist/runtime/composables/useMongocampError.d.ts +2 -1
  100. package/dist/runtime/composables/useMongocampError.js +16 -1
  101. package/dist/runtime/composables/useMongocampExportAll.d.ts +53 -0
  102. package/dist/runtime/composables/useMongocampExportAll.js +57 -0
  103. package/dist/runtime/composables/useMongocampExtendedJson.d.ts +7 -2
  104. package/dist/runtime/composables/useMongocampExtendedJson.js +44 -11
  105. package/dist/runtime/composables/useMongocampFetchAll.d.ts +25 -0
  106. package/dist/runtime/composables/useMongocampFetchAll.js +27 -0
  107. package/dist/runtime/composables/useMongocampFieldTypes.d.ts +24 -0
  108. package/dist/runtime/composables/useMongocampFieldTypes.js +44 -0
  109. package/dist/runtime/composables/useMongocampImport.d.ts +4 -0
  110. package/dist/runtime/composables/useMongocampImport.js +5 -2
  111. package/dist/runtime/composables/useMongocampIndex.d.ts +6 -1
  112. package/dist/runtime/composables/useMongocampIndex.js +7 -1
  113. package/dist/runtime/composables/useMongocampPermissions.d.ts +17 -0
  114. package/dist/runtime/composables/useMongocampPermissions.js +43 -0
  115. package/dist/runtime/composables/useMongocampPersistedState.d.ts +15 -0
  116. package/dist/runtime/composables/useMongocampPersistedState.js +21 -0
  117. package/dist/runtime/composables/useMongocampProxyApi.js +2 -1
  118. package/dist/runtime/composables/useMongocampQuery.d.ts +50 -2
  119. package/dist/runtime/composables/useMongocampQuery.js +72 -1
  120. package/dist/runtime/composables/useMongocampSavedPipelines.d.ts +25 -0
  121. package/dist/runtime/composables/useMongocampSavedPipelines.js +23 -0
  122. package/dist/runtime/composables/useMongocampSavedQueries.d.ts +37 -0
  123. package/dist/runtime/composables/useMongocampSavedQueries.js +50 -0
  124. package/dist/runtime/composables/useMongocampServerOverview.d.ts +35 -0
  125. package/dist/runtime/composables/useMongocampServerOverview.js +51 -0
  126. package/dist/runtime/composables/useMongocampSession.d.ts +2 -0
  127. package/dist/runtime/composables/useMongocampSession.js +16 -2
  128. package/dist/runtime/composables/useMongocampSystem.d.ts +7 -2
  129. package/dist/runtime/composables/useMongocampSystem.js +6 -2
  130. package/dist/runtime/locales/de.json +509 -25
  131. package/dist/runtime/locales/en.json +509 -25
  132. package/dist/runtime/plugin.js +6 -3
  133. package/dist/runtime/utils/aggregationErrors.d.ts +4 -0
  134. package/dist/runtime/utils/aggregationErrors.js +7 -0
  135. package/dist/runtime/utils/aggregationPipeline.d.ts +5 -4
  136. package/dist/runtime/utils/aggregationPipeline.js +23 -9
  137. package/dist/runtime/utils/aggregationPreview.d.ts +13 -0
  138. package/dist/runtime/utils/aggregationPreview.js +10 -0
  139. package/dist/runtime/utils/aggregationResult.d.ts +5 -0
  140. package/dist/runtime/utils/aggregationResult.js +4 -0
  141. package/dist/runtime/utils/aggregationTemplates.d.ts +34 -0
  142. package/dist/runtime/utils/aggregationTemplates.js +47 -0
  143. package/dist/runtime/utils/analyzeSamples.d.ts +1 -0
  144. package/dist/runtime/utils/analyzeSamples.js +1 -1
  145. package/dist/runtime/utils/autoRefresh.d.ts +14 -0
  146. package/dist/runtime/utils/autoRefresh.js +15 -0
  147. package/dist/runtime/utils/batchInsert.d.ts +6 -0
  148. package/dist/runtime/utils/batchInsert.js +31 -3
  149. package/dist/runtime/utils/bigIntJson.d.ts +15 -0
  150. package/dist/runtime/utils/bigIntJson.js +55 -0
  151. package/dist/runtime/utils/bsonTypes.d.ts +10 -0
  152. package/dist/runtime/utils/bsonTypes.js +42 -0
  153. package/dist/runtime/utils/bulkDelete.d.ts +9 -1
  154. package/dist/runtime/utils/bulkDelete.js +15 -3
  155. package/dist/runtime/utils/bulkEdit.d.ts +6 -0
  156. package/dist/runtime/utils/bulkEdit.js +7 -0
  157. package/dist/runtime/utils/chartData.d.ts +11 -0
  158. package/dist/runtime/utils/chartData.js +9 -0
  159. package/dist/runtime/utils/collectionChart.d.ts +36 -0
  160. package/dist/runtime/utils/collectionChart.js +73 -0
  161. package/dist/runtime/utils/collectionCopy.d.ts +24 -0
  162. package/dist/runtime/utils/collectionCopy.js +37 -0
  163. package/dist/runtime/utils/collectionStats.d.ts +31 -0
  164. package/dist/runtime/utils/collectionStats.js +42 -0
  165. package/dist/runtime/utils/commandPalette.d.ts +48 -0
  166. package/dist/runtime/utils/commandPalette.js +39 -0
  167. package/dist/runtime/utils/configRows.d.ts +7 -0
  168. package/dist/runtime/utils/configRows.js +4 -0
  169. package/dist/runtime/utils/documentCompare.d.ts +31 -0
  170. package/dist/runtime/utils/documentCompare.js +71 -0
  171. package/dist/runtime/utils/documentDiff.d.ts +19 -0
  172. package/dist/runtime/utils/documentDiff.js +71 -0
  173. package/dist/runtime/utils/documentPaths.d.ts +41 -0
  174. package/dist/runtime/utils/documentPaths.js +139 -0
  175. package/dist/runtime/utils/documentTree.d.ts +40 -0
  176. package/dist/runtime/utils/documentTree.js +102 -0
  177. package/dist/runtime/utils/exportDocuments.d.ts +33 -0
  178. package/dist/runtime/utils/exportDocuments.js +53 -0
  179. package/dist/runtime/utils/exportRows.d.ts +2 -0
  180. package/dist/runtime/utils/exportRows.js +6 -3
  181. package/dist/runtime/utils/fieldDetails.d.ts +51 -0
  182. package/dist/runtime/utils/fieldDetails.js +113 -0
  183. package/dist/runtime/utils/filePreview.d.ts +27 -0
  184. package/dist/runtime/utils/filePreview.js +50 -0
  185. package/dist/runtime/utils/filterBuilder.d.ts +6 -1
  186. package/dist/runtime/utils/filterBuilder.js +6 -5
  187. package/dist/runtime/utils/formatBytes.d.ts +2 -0
  188. package/dist/runtime/utils/formatBytes.js +11 -0
  189. package/dist/runtime/utils/grantMatching.d.ts +8 -0
  190. package/dist/runtime/utils/grantMatching.js +15 -0
  191. package/dist/runtime/utils/importRows.js +12 -2
  192. package/dist/runtime/utils/indexForm.d.ts +83 -0
  193. package/dist/runtime/utils/indexForm.js +74 -0
  194. package/dist/runtime/utils/luceneExpression.d.ts +15 -0
  195. package/dist/runtime/utils/luceneExpression.js +74 -0
  196. package/dist/runtime/utils/pagedFetch.d.ts +46 -0
  197. package/dist/runtime/utils/pagedFetch.js +58 -0
  198. package/dist/runtime/utils/paginationHeaders.d.ts +4 -0
  199. package/dist/runtime/utils/paginationHeaders.js +4 -0
  200. package/dist/runtime/utils/permissionDenied.d.ts +10 -0
  201. package/dist/runtime/utils/permissionDenied.js +23 -0
  202. package/dist/runtime/utils/permissionMatrix.d.ts +55 -0
  203. package/dist/runtime/utils/permissionMatrix.js +85 -0
  204. package/dist/runtime/utils/persistedState.d.ts +25 -0
  205. package/dist/runtime/utils/persistedState.js +47 -0
  206. package/dist/runtime/utils/queryState.d.ts +45 -0
  207. package/dist/runtime/utils/queryState.js +75 -0
  208. package/dist/runtime/utils/requestLimits.d.ts +2 -0
  209. package/dist/runtime/utils/requestLimits.js +4 -0
  210. package/dist/runtime/utils/resultChart.d.ts +32 -0
  211. package/dist/runtime/utils/resultChart.js +59 -0
  212. package/dist/runtime/utils/savedPipelines.d.ts +22 -0
  213. package/dist/runtime/utils/savedPipelines.js +46 -0
  214. package/dist/runtime/utils/savedQueries.d.ts +60 -0
  215. package/dist/runtime/utils/savedQueries.js +143 -0
  216. package/dist/runtime/utils/schemaAnalysis.d.ts +16 -0
  217. package/dist/runtime/utils/schemaAnalysis.js +57 -0
  218. package/dist/runtime/utils/serverError.d.ts +19 -0
  219. package/dist/runtime/utils/serverError.js +19 -0
  220. package/dist/runtime/utils/serverOverview.d.ts +47 -0
  221. package/dist/runtime/utils/serverOverview.js +40 -0
  222. package/dist/runtime/utils/sessionGuard.d.ts +3 -0
  223. package/dist/runtime/utils/sessionGuard.js +18 -1
  224. package/package.json +15 -14
@@ -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 (still, as of 1.6.3) does not understand `_exists_:field` (it matches nothing), and `field:*` only matches text,
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
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 (still, as of 1.6.3) rejects `[x TO *]`, so the open end is replaced by
39
+ * Pass `null` (or `'*'`) for an open end. MongoCamp (last verified on 1.6.3, not re-checked on 1.8) 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.
@@ -102,5 +102,53 @@ export interface MongocampQueryHelper {
102
102
  * A single surviving part is returned unwrapped (no outer parens).
103
103
  */
104
104
  or: (...queryParts: (string | null | undefined)[]) => string;
105
+ /**
106
+ * `_id:"<hex>"` — the document with this id. The id must be a 24-character hex ObjectId (any case); anything else
107
+ * **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.)
109
+ */
110
+ byId: (id: string) => string;
111
+ /**
112
+ * `_id:("a" OR "b")` — any of these documents. Every id must be a 24-character hex ObjectId or it throws, like `byId`.
113
+ * An empty array returns `''` (no clause), as `inClause` does.
114
+ */
115
+ byIds: (ids: string[]) => string;
116
+ /** `field:true` — a boolean field that is true. A document without the field does not match. */
117
+ isTrue: (fieldName: string) => string;
118
+ /** `field:false` — a boolean field that is false. A document without the field does not match. */
119
+ isFalse: (fieldName: string) => string;
120
+ /**
121
+ * `field:"x"` / `field:5` — the array contains this element (text quoted, numbers not). Any one array element
122
+ * matching is enough, so `arrayContains('tags', 'a')` finds `["a","b"]`.
123
+ */
124
+ arrayContains: (fieldName: string, value: QueryValue) => string;
125
+ /**
126
+ * The field is an array with at least one element (an empty array and a missing field do not match). Written like
127
+ * `exists` — a text wildcard ORed with a full number and a full date range — because `field:*` alone only finds
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).
130
+ */
131
+ hasItems: (fieldName: string, type?: ExistsFieldType) => string;
132
+ /**
133
+ * The whole UTC day `YYYY-MM-DD`: `field:[YYYY-MM-DDT00:00:00Z TO YYYY-MM-DDT23:59:59.999Z]`. The server matches nothing
134
+ * for a bare one-day range, so the bounds are widened to the full day. Throws a `TypeError` for anything that is not a
135
+ * real calendar date.
136
+ */
137
+ onDay: (fieldName: string, day: string) => string;
138
+ /** `-field:[the whole UTC day]` — everything except that day (documents without the field included). */
139
+ notOnDay: (fieldName: string, day: string) => string;
140
+ /**
141
+ * The negation of any expression these helpers produced, written so the server evaluates it correctly.
142
+ * MongoCamp (last verified on 1.6.3, not re-checked on 1.8) evaluates `-(A AND B)` as `-A AND -B`, so a negated `AND` group is rewritten with
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.
147
+ */
148
+ not: (queryPart: string | null | undefined) => string;
149
+ /** The negation of "all of these": `notAnd(a, b)` = `not(and(a, b))` = `((-a) OR (-b))`. Empty parts are ignored. */
150
+ notAnd: (...queryParts: (string | null | undefined)[]) => string;
151
+ /** The negation of "any of these": `notOr(a, b)` = `not(or(a, b))` = `((-a) AND (-b))`. Empty parts are ignored. */
152
+ notOr: (...queryParts: (string | null | undefined)[]) => string;
105
153
  }
106
154
  export declare function useMongocampQuery(): MongocampQueryHelper;
@@ -1,5 +1,7 @@
1
1
  import { escapeFieldName } from "../utils/escapeFieldName.js";
2
2
  import { isIsoDateTimeString } from "../utils/isoDate.js";
3
+ import { isObjectIdHex } from "../utils/objectId.js";
4
+ import { parseLuceneExpression } from "../utils/luceneExpression.js";
3
5
  import { useMongocampQueryBuilder } from "./useMongocampQueryBuilder.js";
4
6
  const NUMBER_BOUNDS = { from: "-9223372036854775808", to: "9223372036854775807" };
5
7
  const DATE_BOUNDS = { from: "0001-01-01T00:00:00Z", to: "9999-12-31T23:59:59.999Z" };
@@ -127,6 +129,64 @@ export function useMongocampQuery() {
127
129
  function or(...queryParts) {
128
130
  return logicalOperators("OR", queryParts);
129
131
  }
132
+ function requireObjectId(id, helper) {
133
+ if (!isObjectIdHex(id)) throw new TypeError(`${helper} needs a 24-character hex ObjectId, got ${typeof id === "string" ? `"${id}"` : String(id)}`);
134
+ return id;
135
+ }
136
+ function byId(id) {
137
+ return equals("_id", requireObjectId(id, "byId"));
138
+ }
139
+ function byIds(ids) {
140
+ return inClause("_id", ids.map((id) => requireObjectId(id, "byIds")));
141
+ }
142
+ function isTrue(fieldName) {
143
+ return fieldTerm(fieldName, "true");
144
+ }
145
+ function isFalse(fieldName) {
146
+ return fieldTerm(fieldName, "false");
147
+ }
148
+ function arrayContains(fieldName, value) {
149
+ if (value == null || value.toString().length === 0) return "";
150
+ return inClause(fieldName, [value]);
151
+ }
152
+ function hasItems(fieldName, type) {
153
+ return exists(fieldName, type);
154
+ }
155
+ function requireDay(day, helper) {
156
+ const parsed = DATE_ONLY_REGEX.test(day) ? /* @__PURE__ */ new Date(`${day}T00:00:00Z`) : null;
157
+ const valid = parsed !== null && !Number.isNaN(parsed.getTime()) && parsed.toISOString().startsWith(day);
158
+ if (!valid) throw new TypeError(`${helper} needs a calendar date like 2024-03-01, got "${day}"`);
159
+ return day;
160
+ }
161
+ function onDay(fieldName, day) {
162
+ const checked = requireDay(day, "onDay");
163
+ return inRange(fieldName, checked, checked);
164
+ }
165
+ function notOnDay(fieldName, day) {
166
+ return `-${onDay(fieldName, requireDay(day, "notOnDay"))}`;
167
+ }
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
+ function not(queryPart) {
181
+ const node = parseLuceneExpression(queryPart ?? "");
182
+ return node === null ? "" : negate(node);
183
+ }
184
+ function notAnd(...queryParts) {
185
+ return not(and(...queryParts));
186
+ }
187
+ function notOr(...queryParts) {
188
+ return not(or(...queryParts));
189
+ }
130
190
  return {
131
191
  exists,
132
192
  notExists,
@@ -146,7 +206,18 @@ export function useMongocampQuery() {
146
206
  inClause,
147
207
  notInClause,
148
208
  containsAll,
209
+ byId,
210
+ byIds,
211
+ isTrue,
212
+ isFalse,
213
+ arrayContains,
214
+ hasItems,
215
+ onDay,
216
+ notOnDay,
149
217
  and,
150
- or
218
+ or,
219
+ not,
220
+ notAnd,
221
+ notOr
151
222
  };
152
223
  }
@@ -0,0 +1,25 @@
1
+ import type { ComputedRef, MaybeRefOrGetter } from 'vue';
2
+ import type { RequestStage } from '../utils/aggregationPipeline.js';
3
+ import type { SavePipelineFailure, SavedPipelineEntry } from '../utils/savedPipelines.js';
4
+ import type { PersistedStateOptions } from './useMongocampPersistedState.js';
5
+ type Store = {
6
+ pipelines: SavedPipelineEntry[];
7
+ };
8
+ export type SavedPipelinesSaveResult = {
9
+ ok: true;
10
+ } | {
11
+ ok: false;
12
+ reason: SavePipelineFailure | 'too-large';
13
+ };
14
+ /**
15
+ * Saved aggregation pipelines of one collection, kept in this browser only (`localStorage` through
16
+ * `useMongocampPersistedState`; nothing is sent to the server). Up to 50 per collection. Everything read back is checked like
17
+ * a pipeline typed into the JSON tab — a stored `$out`, `$function` or `$lookup` is dropped — so edited storage cannot smuggle
18
+ * a denied operator past the builder.
19
+ */
20
+ export declare function useMongocampSavedPipelines(collection: MaybeRefOrGetter<string>, options?: Pick<PersistedStateOptions<Store>, 'storage'>): {
21
+ saved: ComputedRef<SavedPipelineEntry[]>;
22
+ save: (name: string, pipeline: RequestStage[]) => SavedPipelinesSaveResult;
23
+ remove: (name: string) => void;
24
+ };
25
+ export {};
@@ -0,0 +1,23 @@
1
+ import { computed, toValue } from "vue";
2
+ import { MAX_PIPELINE_BYTES, MAX_SAVED, sanitizePipelineList, upsertPipeline } from "../utils/savedPipelines.js";
3
+ import { useMongocampPersistedState } from "./useMongocampPersistedState.js";
4
+ export function useMongocampSavedPipelines(collection, options = {}) {
5
+ const { state } = useMongocampPersistedState(
6
+ () => `savedPipelines:${toValue(collection)}`,
7
+ { pipelines: [] },
8
+ { ...options, maxBytes: MAX_PIPELINE_BYTES * MAX_SAVED }
9
+ );
10
+ const saved = computed(() => sanitizePipelineList(state.value.pipelines));
11
+ function save(name, pipeline) {
12
+ const result = upsertPipeline(saved.value, name, pipeline);
13
+ if (!result.ok) return result;
14
+ if (JSON.stringify({ pipelines: result.list }).length > MAX_PIPELINE_BYTES * MAX_SAVED) return { ok: false, reason: "too-large" };
15
+ state.value = { pipelines: result.list };
16
+ return { ok: true };
17
+ }
18
+ function remove(name) {
19
+ const lower = name.toLowerCase();
20
+ state.value = { pipelines: saved.value.filter((e) => e.name.toLowerCase() !== lower) };
21
+ }
22
+ return { saved, save, remove };
23
+ }
@@ -0,0 +1,37 @@
1
+ import type { ComputedRef, MaybeRefOrGetter } from 'vue';
2
+ import type { ImportFailure, SaveFailure, SavedQuery, SavedQueryEntry } from '../utils/savedQueries.js';
3
+ import type { PersistedStateOptions } from './useMongocampPersistedState.js';
4
+ type Store = {
5
+ saved: SavedQueryEntry[];
6
+ recent: SavedQuery[];
7
+ };
8
+ export type SavedQueriesSaveResult = {
9
+ ok: true;
10
+ } | {
11
+ ok: false;
12
+ reason: SaveFailure | 'too-large';
13
+ };
14
+ export type SavedQueriesImportResult = {
15
+ ok: true;
16
+ imported: number;
17
+ skipped: number;
18
+ } | {
19
+ ok: false;
20
+ reason: ImportFailure | 'too-large';
21
+ };
22
+ /**
23
+ * Saved queries and a short history for one collection, kept in this browser only (`localStorage`, through
24
+ * `useMongocampPersistedState`; nothing is sent to the server). A query is `{ filterGroup?, lucene?, sort?, projection? }`.
25
+ * Everything read back — from storage or an imported file — is validated and bounded: 50 saved, 20 recent.
26
+ */
27
+ export declare function useMongocampSavedQueries(collection: MaybeRefOrGetter<string>, options?: Pick<PersistedStateOptions<Store>, 'storage'>): {
28
+ saved: ComputedRef<SavedQueryEntry[]>;
29
+ recent: ComputedRef<SavedQuery[]>;
30
+ save: (name: string, query: SavedQuery) => SavedQueriesSaveResult;
31
+ remove: (name: string) => void;
32
+ record: (query: SavedQuery) => boolean;
33
+ clearRecent: () => void;
34
+ exportJson: () => string;
35
+ importJson: (text: string) => SavedQueriesImportResult;
36
+ };
37
+ export {};
@@ -0,0 +1,50 @@
1
+ import { computed, toValue } from "vue";
2
+ import { MAX_STORE_BYTES, parseSavedImport, pushRecent, sanitizeRecentList, sanitizeSavedList, serializeSaved, upsertSaved } from "../utils/savedQueries.js";
3
+ import { useMongocampPersistedState } from "./useMongocampPersistedState.js";
4
+ export function useMongocampSavedQueries(collection, options = {}) {
5
+ const { state } = useMongocampPersistedState(
6
+ () => `savedQueries:${toValue(collection)}`,
7
+ { saved: [], recent: [] },
8
+ { ...options, maxBytes: MAX_STORE_BYTES }
9
+ );
10
+ const saved = computed(() => sanitizeSavedList(state.value.saved));
11
+ const recent = computed(() => sanitizeRecentList(state.value.recent));
12
+ function fits(next) {
13
+ return JSON.stringify(next).length <= MAX_STORE_BYTES;
14
+ }
15
+ function save(name, query) {
16
+ const result = upsertSaved(saved.value, name, query);
17
+ if (!result.ok) return result;
18
+ const next = { saved: result.list, recent: recent.value };
19
+ if (!fits(next)) return { ok: false, reason: "too-large" };
20
+ state.value = next;
21
+ return { ok: true };
22
+ }
23
+ function remove(name) {
24
+ const lower = name.toLowerCase();
25
+ state.value = { saved: saved.value.filter((e) => e.name.toLowerCase() !== lower), recent: recent.value };
26
+ }
27
+ function record(query) {
28
+ const clean = sanitizeRecentList([query])[0];
29
+ if (!clean) return false;
30
+ const next = { saved: saved.value, recent: pushRecent(recent.value, clean) };
31
+ if (!fits(next)) return false;
32
+ state.value = next;
33
+ return true;
34
+ }
35
+ function clearRecent() {
36
+ state.value = { saved: saved.value, recent: [] };
37
+ }
38
+ function exportJson() {
39
+ return serializeSaved(saved.value);
40
+ }
41
+ function importJson(text) {
42
+ const result = parseSavedImport(text, saved.value);
43
+ if (!result.ok) return result;
44
+ const next = { saved: result.list, recent: recent.value };
45
+ if (!fits(next)) return { ok: false, reason: "too-large" };
46
+ state.value = next;
47
+ return { ok: true, imported: result.imported, skipped: result.skipped };
48
+ }
49
+ return { saved, recent, save, remove, record, clearRecent, exportJson, importJson };
50
+ }
@@ -0,0 +1,35 @@
1
+ import type { DatabaseInfo, JobInformation } from '@sfxcode/nuxt-mongocamp-server';
2
+ import type { CollectionStat } from '../utils/serverOverview.js';
3
+ import type { ServerCluster } from './useMongocampSystem.js';
4
+ export type { CollectionStat } from '../utils/serverOverview.js';
5
+ export interface ServerOverviewOptions {
6
+ /** Read at most this many collections (default 200); the rest is counted in `skipped`. */
7
+ maxCollections?: number;
8
+ /** Aborting rejects with an `AbortError`. */
9
+ signal?: AbortSignal;
10
+ }
11
+ export interface ServerOverview {
12
+ /** `null` when the databases could not be read (see `errors.databases`). */
13
+ databases: DatabaseInfo[] | null;
14
+ /** The collections that were read, in the server's order (MongoCamp's own `mc_*` collections are left out). */
15
+ collections: CollectionStat[];
16
+ /** How many collections there are in all. */
17
+ collectionCount: number;
18
+ /** Collections not read because of `maxCollections`. */
19
+ skipped: number;
20
+ /** Collections the server listed but could not read the numbers of (`available: false`). */
21
+ failed: string[];
22
+ cluster: ServerCluster | null;
23
+ jobs: JobInformation[] | null;
24
+ /** The first error of each part that failed; the other parts still hold their data. */
25
+ errors: Partial<Record<'databases' | 'collections' | 'cluster' | 'jobs', unknown>>;
26
+ }
27
+ /**
28
+ * What an admin wants to see first: the databases, the size of every collection, the cluster and the scheduled jobs. The
29
+ * parts are independent — one that fails is reported in `errors` and leaves the others intact. The numbers of **all**
30
+ * collections come in one request (`GET /mongodb/collections/info`, server 1.7.0); `maxCollections` only limits how many of
31
+ * them are kept. Aborting rejects with an `AbortError`.
32
+ */
33
+ export declare function useMongocampServerOverview(): {
34
+ loadOverview: (options?: ServerOverviewOptions) => Promise<ServerOverview>;
35
+ };
@@ -0,0 +1,51 @@
1
+ import { useMongocampClientApi } from "#imports";
2
+ import { toCollectionStat } from "../utils/serverOverview.js";
3
+ import { useMongocampJobs } from "./useMongocampJobs.js";
4
+ import { useMongocampSystem } from "./useMongocampSystem.js";
5
+ const REQUEST_TIMEOUT_MS = 15e3;
6
+ const DEFAULT_MAX_COLLECTIONS = 200;
7
+ function abortError() {
8
+ return new DOMException("The operation was aborted.", "AbortError");
9
+ }
10
+ export function useMongocampServerOverview() {
11
+ const { collectionApi } = useMongocampClientApi();
12
+ const { getDatabaseInfos, getCluster } = useMongocampSystem();
13
+ const { listJobs } = useMongocampJobs();
14
+ async function loadOverview(options = {}) {
15
+ const { signal } = options;
16
+ if (signal?.aborted) throw abortError();
17
+ const maxCollections = Math.max(0, Math.floor(options.maxCollections ?? DEFAULT_MAX_COLLECTIONS));
18
+ const errors = {};
19
+ const timeout = AbortSignal.timeout(REQUEST_TIMEOUT_MS);
20
+ const init = { signal: signal ? AbortSignal.any([signal, timeout]) : timeout };
21
+ const [databases, summaries, cluster, jobs] = await Promise.allSettled([getDatabaseInfos(), collectionApi.listCollectionInformation({}, init), getCluster(), listJobs()]);
22
+ if (signal?.aborted) throw abortError();
23
+ const result = {
24
+ databases: databases.status === "fulfilled" ? databases.value : null,
25
+ collections: [],
26
+ collectionCount: 0,
27
+ skipped: 0,
28
+ failed: [],
29
+ cluster: cluster.status === "fulfilled" ? cluster.value : null,
30
+ jobs: jobs.status === "fulfilled" ? jobs.value : null,
31
+ errors
32
+ };
33
+ if (databases.status === "rejected") errors.databases = databases.reason;
34
+ if (cluster.status === "rejected") errors.cluster = cluster.reason;
35
+ if (jobs.status === "rejected") errors.jobs = jobs.reason;
36
+ if (summaries.status === "rejected") {
37
+ errors.collections = summaries.reason;
38
+ return result;
39
+ }
40
+ const own = summaries.value.filter((summary) => !summary.name.startsWith("mc_"));
41
+ result.collectionCount = own.length;
42
+ const kept = own.slice(0, maxCollections);
43
+ result.skipped = own.length - kept.length;
44
+ for (const summary of kept) {
45
+ if (summary.available === false) result.failed.push(summary.name);
46
+ else result.collections.push(toCollectionStat(summary.name, summary));
47
+ }
48
+ return result;
49
+ }
50
+ return { loadOverview };
51
+ }
@@ -1,7 +1,9 @@
1
1
  import type { TokenExpiryState } from '../utils/jwtExpiry.js';
2
2
  export type SessionState = 'active' | 'expired' | 'unknown';
3
+ export type SessionVerification = 'valid' | 'invalid' | 'unknown';
3
4
  export declare function useMongocampSession(): {
4
5
  checkExpiry: () => TokenExpiryState;
5
6
  currentState: () => SessionState;
7
+ verify: () => Promise<SessionVerification>;
6
8
  invalidateSession: () => Promise<void>;
7
9
  };
@@ -1,10 +1,12 @@
1
1
  import { useRuntimeConfig } from "#app";
2
- import { useMongocampAuth, useMongocampStorage } from "#imports";
2
+ import { useMongocampAuth, useMongocampClientApi, useMongocampStorage } from "#imports";
3
3
  import { tokenExpiryState } from "../utils/jwtExpiry.js";
4
+ const VERIFY_TIMEOUT_MS = 15e3;
4
5
  export function useMongocampSession() {
5
6
  const config = useRuntimeConfig();
6
7
  const { logout } = useMongocampAuth();
7
8
  const storage = useMongocampStorage();
9
+ const { authApi } = useMongocampClientApi();
8
10
  const isProxyMode = config.public.nuxtUiMongocampOptions?.useServerProxy ?? false;
9
11
  function checkExpiry() {
10
12
  if (isProxyMode) return "unknown";
@@ -15,9 +17,21 @@ export function useMongocampSession() {
15
17
  const expiry = checkExpiry();
16
18
  return expiry === "valid" ? "active" : expiry;
17
19
  }
20
+ async function verify() {
21
+ if (isProxyMode) return "unknown";
22
+ const token = storage.value?.token;
23
+ if (typeof token !== "string" || !token) return "unknown";
24
+ try {
25
+ const result = await authApi.isAuthenticated({ signal: AbortSignal.timeout(VERIFY_TIMEOUT_MS) });
26
+ if (result.value === true) return "valid";
27
+ return result.value === false ? "invalid" : "unknown";
28
+ } catch (e) {
29
+ return e?.response?.status === 401 ? "invalid" : "unknown";
30
+ }
31
+ }
18
32
  async function invalidateSession() {
19
33
  if (isProxyMode) return;
20
34
  await logout();
21
35
  }
22
- return { checkExpiry, currentState, invalidateSession };
36
+ return { checkExpiry, currentState, verify, invalidateSession };
23
37
  }
@@ -1,12 +1,16 @@
1
- import type { DatabaseInfo } from '@sfxcode/nuxt-mongocamp-server';
1
+ import type { ClusterMemberInformation, DatabaseInfo } from '@sfxcode/nuxt-mongocamp-server';
2
2
  import type { ConfigRow } from '../utils/configRows.js';
3
+ export interface ServerCluster {
4
+ coordinator: ClusterMemberInformation;
5
+ members: ClusterMemberInformation[];
6
+ }
3
7
  export interface ServerPlugins {
4
8
  routesPlugins: string[];
5
9
  filePlugins: string[];
6
10
  ignoredPlugins: string[];
7
11
  }
8
12
  /**
9
- * Read-only wrapper for databaseApi and applicationApi. Deliberately read-only —
13
+ * Read-only wrapper for databaseApi, applicationApi and the cluster view of systemApi. Deliberately read-only —
10
14
  * deleteDatabase, shutdown and updateConfiguration are out of scope (cross-cutting, highly
11
15
  * destructive) and not exposed. The server's settings and configuration payloads contain real secrets
12
16
  * (auth secret, database credentials and host), so the settings methods never hand them out:
@@ -14,6 +18,7 @@ export interface ServerPlugins {
14
18
  * already masked (see utils/configRows.ts).
15
19
  */
16
20
  export declare function useMongocampSystem(): {
21
+ getCluster: () => Promise<ServerCluster>;
17
22
  listDatabases: () => Promise<string[]>;
18
23
  getDatabaseInfos: () => Promise<DatabaseInfo[]>;
19
24
  getDatabaseInfo: (databaseName: string) => Promise<DatabaseInfo>;
@@ -5,7 +5,7 @@ function withTimeout() {
5
5
  return { signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) };
6
6
  }
7
7
  export function useMongocampSystem() {
8
- const { databaseApi, applicationApi } = useMongocampClientApi();
8
+ const { databaseApi, applicationApi, systemApi } = useMongocampClientApi();
9
9
  async function listDatabases() {
10
10
  return databaseApi.listDatabases(withTimeout());
11
11
  }
@@ -34,5 +34,9 @@ export function useMongocampSystem() {
34
34
  if (!row) throw new Error(`The server returned no usable configuration for "${configurationKey}"`);
35
35
  return row;
36
36
  }
37
- return { listDatabases, getDatabaseInfos, getDatabaseInfo, listCollectionsByDatabase, getSettings, listConfigurations, getConfig };
37
+ async function getCluster() {
38
+ const cluster = await systemApi.viewCluster(withTimeout());
39
+ return { coordinator: cluster.coordinator, members: cluster.members?.length ? cluster.members : [cluster.coordinator] };
40
+ }
41
+ return { getCluster, listDatabases, getDatabaseInfos, getDatabaseInfo, listCollectionsByDatabase, getSettings, listConfigurations, getConfig };
38
42
  }