@coldsmirk/inkstone-mongodb 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/dist/document-CVB9YunA.js +408 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +90 -0
- package/dist/markers-Bdvbut2O.js +1023 -0
- package/dist/markers-CQOm7diu.d.ts +218 -0
- package/dist/monaco.d.ts +40 -0
- package/dist/monaco.js +170 -0
- package/dist/react.d.ts +93 -0
- package/dist/react.js +104 -0
- package/package.json +78 -0
|
@@ -0,0 +1,1023 @@
|
|
|
1
|
+
import { i as readDocument } from "./document-CVB9YunA.js";
|
|
2
|
+
//#region src/commands.ts
|
|
3
|
+
const COMMON = ["comment", "maxTimeMS"];
|
|
4
|
+
const MONGO_COMMANDS = [
|
|
5
|
+
{
|
|
6
|
+
name: "find",
|
|
7
|
+
summary: "Read documents from a collection under a filter.",
|
|
8
|
+
collection: true,
|
|
9
|
+
fields: [
|
|
10
|
+
"filter",
|
|
11
|
+
"sort",
|
|
12
|
+
"projection",
|
|
13
|
+
"hint",
|
|
14
|
+
"skip",
|
|
15
|
+
"limit",
|
|
16
|
+
"batchSize",
|
|
17
|
+
"singleBatch",
|
|
18
|
+
"readConcern",
|
|
19
|
+
"max",
|
|
20
|
+
"min",
|
|
21
|
+
"returnKey",
|
|
22
|
+
"showRecordId",
|
|
23
|
+
"tailable",
|
|
24
|
+
"awaitData",
|
|
25
|
+
"noCursorTimeout",
|
|
26
|
+
"allowPartialResults",
|
|
27
|
+
"collation",
|
|
28
|
+
"allowDiskUse",
|
|
29
|
+
"let",
|
|
30
|
+
...COMMON
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "aggregate",
|
|
35
|
+
summary: "Run an aggregation pipeline over a collection (or `1` for a database-level pipeline).",
|
|
36
|
+
collection: true,
|
|
37
|
+
fields: [
|
|
38
|
+
"pipeline",
|
|
39
|
+
"cursor",
|
|
40
|
+
"explain",
|
|
41
|
+
"allowDiskUse",
|
|
42
|
+
"bypassDocumentValidation",
|
|
43
|
+
"readConcern",
|
|
44
|
+
"collation",
|
|
45
|
+
"hint",
|
|
46
|
+
"writeConcern",
|
|
47
|
+
"let",
|
|
48
|
+
...COMMON
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "count",
|
|
53
|
+
summary: "Count the documents a query matches.",
|
|
54
|
+
collection: true,
|
|
55
|
+
fields: [
|
|
56
|
+
"query",
|
|
57
|
+
"limit",
|
|
58
|
+
"skip",
|
|
59
|
+
"hint",
|
|
60
|
+
"readConcern",
|
|
61
|
+
"collation",
|
|
62
|
+
...COMMON
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "distinct",
|
|
67
|
+
summary: "The distinct values of a field across the documents a query matches.",
|
|
68
|
+
collection: true,
|
|
69
|
+
fields: [
|
|
70
|
+
"key",
|
|
71
|
+
"query",
|
|
72
|
+
"readConcern",
|
|
73
|
+
"collation",
|
|
74
|
+
"comment"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "insert",
|
|
79
|
+
summary: "Insert documents into a collection.",
|
|
80
|
+
collection: true,
|
|
81
|
+
fields: [
|
|
82
|
+
"documents",
|
|
83
|
+
"ordered",
|
|
84
|
+
"writeConcern",
|
|
85
|
+
"bypassDocumentValidation",
|
|
86
|
+
...COMMON
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "update",
|
|
91
|
+
summary: "Update the documents each update statement's query matches.",
|
|
92
|
+
collection: true,
|
|
93
|
+
fields: [
|
|
94
|
+
"updates",
|
|
95
|
+
"ordered",
|
|
96
|
+
"writeConcern",
|
|
97
|
+
"bypassDocumentValidation",
|
|
98
|
+
"let",
|
|
99
|
+
...COMMON
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "delete",
|
|
104
|
+
summary: "Delete the documents each delete statement's query matches.",
|
|
105
|
+
collection: true,
|
|
106
|
+
fields: [
|
|
107
|
+
"deletes",
|
|
108
|
+
"ordered",
|
|
109
|
+
"writeConcern",
|
|
110
|
+
"let",
|
|
111
|
+
...COMMON
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "findAndModify",
|
|
116
|
+
summary: "Update or remove one document and return it, before or after.",
|
|
117
|
+
collection: true,
|
|
118
|
+
fields: [
|
|
119
|
+
"query",
|
|
120
|
+
"sort",
|
|
121
|
+
"remove",
|
|
122
|
+
"update",
|
|
123
|
+
"new",
|
|
124
|
+
"fields",
|
|
125
|
+
"upsert",
|
|
126
|
+
"bypassDocumentValidation",
|
|
127
|
+
"writeConcern",
|
|
128
|
+
"collation",
|
|
129
|
+
"arrayFilters",
|
|
130
|
+
"hint",
|
|
131
|
+
"let",
|
|
132
|
+
...COMMON
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "bulkWrite",
|
|
137
|
+
summary: "Insert, update and delete across collections in one command (8.0).",
|
|
138
|
+
collection: false,
|
|
139
|
+
fields: [
|
|
140
|
+
"ops",
|
|
141
|
+
"nsInfo",
|
|
142
|
+
"ordered",
|
|
143
|
+
"bypassDocumentValidation",
|
|
144
|
+
"errorsOnly",
|
|
145
|
+
"cursor",
|
|
146
|
+
"writeConcern",
|
|
147
|
+
"let",
|
|
148
|
+
"comment"
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "getMore",
|
|
153
|
+
summary: "The next batch of an open cursor.",
|
|
154
|
+
collection: false,
|
|
155
|
+
fields: [
|
|
156
|
+
"collection",
|
|
157
|
+
"batchSize",
|
|
158
|
+
...COMMON
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "killCursors",
|
|
163
|
+
summary: "Close open cursors.",
|
|
164
|
+
collection: true,
|
|
165
|
+
fields: ["cursors", "comment"]
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "explain",
|
|
169
|
+
summary: "The plan for a command, run or not by `verbosity`.",
|
|
170
|
+
collection: false,
|
|
171
|
+
fields: ["verbosity", "comment"]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: "listCollections",
|
|
175
|
+
summary: "The collections and views of the database.",
|
|
176
|
+
collection: false,
|
|
177
|
+
fields: [
|
|
178
|
+
"filter",
|
|
179
|
+
"nameOnly",
|
|
180
|
+
"authorizedCollections",
|
|
181
|
+
"comment"
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "listIndexes",
|
|
186
|
+
summary: "The indexes of a collection.",
|
|
187
|
+
collection: true,
|
|
188
|
+
fields: ["cursor", "comment"]
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: "listDatabases",
|
|
192
|
+
summary: "The databases of the server (run on `admin`).",
|
|
193
|
+
collection: false,
|
|
194
|
+
fields: [
|
|
195
|
+
"filter",
|
|
196
|
+
"nameOnly",
|
|
197
|
+
"authorizedDatabases",
|
|
198
|
+
"comment"
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "collStats",
|
|
203
|
+
summary: "Storage statistics of a collection.",
|
|
204
|
+
collection: true,
|
|
205
|
+
fields: ["scale"]
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: "dbStats",
|
|
209
|
+
summary: "Storage statistics of the database.",
|
|
210
|
+
collection: false,
|
|
211
|
+
fields: ["scale"]
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "create",
|
|
215
|
+
summary: "Create a collection or a view, with its options.",
|
|
216
|
+
collection: true,
|
|
217
|
+
fields: [
|
|
218
|
+
"capped",
|
|
219
|
+
"timeseries",
|
|
220
|
+
"expireAfterSeconds",
|
|
221
|
+
"clusteredIndex",
|
|
222
|
+
"changeStreamPreAndPostImages",
|
|
223
|
+
"size",
|
|
224
|
+
"max",
|
|
225
|
+
"storageEngine",
|
|
226
|
+
"validator",
|
|
227
|
+
"validationLevel",
|
|
228
|
+
"validationAction",
|
|
229
|
+
"indexOptionDefaults",
|
|
230
|
+
"viewOn",
|
|
231
|
+
"pipeline",
|
|
232
|
+
"collation",
|
|
233
|
+
"writeConcern",
|
|
234
|
+
"comment"
|
|
235
|
+
]
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: "drop",
|
|
239
|
+
summary: "Drop a collection.",
|
|
240
|
+
collection: true,
|
|
241
|
+
fields: ["writeConcern", "comment"]
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: "dropDatabase",
|
|
245
|
+
summary: "Drop the database.",
|
|
246
|
+
collection: false,
|
|
247
|
+
fields: ["writeConcern", "comment"]
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: "renameCollection",
|
|
251
|
+
summary: "Rename a collection (run on `admin`, names as `db.coll`).",
|
|
252
|
+
collection: false,
|
|
253
|
+
fields: [
|
|
254
|
+
"to",
|
|
255
|
+
"dropTarget",
|
|
256
|
+
"writeConcern",
|
|
257
|
+
"comment"
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "createIndexes",
|
|
262
|
+
summary: "Build indexes on a collection.",
|
|
263
|
+
collection: true,
|
|
264
|
+
fields: [
|
|
265
|
+
"indexes",
|
|
266
|
+
"writeConcern",
|
|
267
|
+
"commitQuorum",
|
|
268
|
+
"comment"
|
|
269
|
+
]
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
name: "dropIndexes",
|
|
273
|
+
summary: "Drop indexes of a collection, by name or key, `*` for all but `_id`.",
|
|
274
|
+
collection: true,
|
|
275
|
+
fields: [
|
|
276
|
+
"index",
|
|
277
|
+
"writeConcern",
|
|
278
|
+
"comment"
|
|
279
|
+
]
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: "validate",
|
|
283
|
+
summary: "Check a collection's data and indexes.",
|
|
284
|
+
collection: true,
|
|
285
|
+
fields: [
|
|
286
|
+
"full",
|
|
287
|
+
"repair",
|
|
288
|
+
"metadata"
|
|
289
|
+
]
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
name: "ping",
|
|
293
|
+
summary: "Whether the server answers.",
|
|
294
|
+
collection: false,
|
|
295
|
+
fields: []
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: "hello",
|
|
299
|
+
summary: "The server's role, its wire versions and its topology.",
|
|
300
|
+
collection: false,
|
|
301
|
+
fields: []
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
name: "buildInfo",
|
|
305
|
+
summary: "The server's build: version, git hash, modules.",
|
|
306
|
+
collection: false,
|
|
307
|
+
fields: []
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: "serverStatus",
|
|
311
|
+
summary: "The server's runtime statistics.",
|
|
312
|
+
collection: false,
|
|
313
|
+
fields: []
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
name: "hostInfo",
|
|
317
|
+
summary: "The host's system and OS.",
|
|
318
|
+
collection: false,
|
|
319
|
+
fields: []
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
name: "connectionStatus",
|
|
323
|
+
summary: "The connection's authenticated users and their roles.",
|
|
324
|
+
collection: false,
|
|
325
|
+
fields: ["showPrivileges"]
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: "currentOp",
|
|
329
|
+
summary: "The operations in progress (run on `admin`).",
|
|
330
|
+
collection: false,
|
|
331
|
+
fields: [
|
|
332
|
+
"$all",
|
|
333
|
+
"$ownOps",
|
|
334
|
+
"comment"
|
|
335
|
+
]
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: "killOp",
|
|
339
|
+
summary: "End an operation by its id (run on `admin`).",
|
|
340
|
+
collection: false,
|
|
341
|
+
fields: ["op", "comment"]
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: "top",
|
|
345
|
+
summary: "Usage statistics per collection (run on `admin`).",
|
|
346
|
+
collection: false,
|
|
347
|
+
fields: []
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
name: "getLog",
|
|
351
|
+
summary: "The server's recent log lines (`global`, `startupWarnings`).",
|
|
352
|
+
collection: false,
|
|
353
|
+
fields: []
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
name: "getParameter",
|
|
357
|
+
summary: "A server parameter's value, or `*` for all.",
|
|
358
|
+
collection: false,
|
|
359
|
+
fields: ["comment"]
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
name: "setParameter",
|
|
363
|
+
summary: "Set a server parameter (run on `admin`).",
|
|
364
|
+
collection: false,
|
|
365
|
+
fields: []
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
name: "usersInfo",
|
|
369
|
+
summary: "The users of the database and their roles.",
|
|
370
|
+
collection: false,
|
|
371
|
+
fields: [
|
|
372
|
+
"showCredentials",
|
|
373
|
+
"showPrivileges",
|
|
374
|
+
"showAuthenticationRestrictions",
|
|
375
|
+
"filter",
|
|
376
|
+
"comment"
|
|
377
|
+
]
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
name: "rolesInfo",
|
|
381
|
+
summary: "The roles of the database.",
|
|
382
|
+
collection: false,
|
|
383
|
+
fields: [
|
|
384
|
+
"showPrivileges",
|
|
385
|
+
"showBuiltinRoles",
|
|
386
|
+
"comment"
|
|
387
|
+
]
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
name: "replSetGetStatus",
|
|
391
|
+
summary: "The replica set's members and their states (run on `admin`).",
|
|
392
|
+
collection: false,
|
|
393
|
+
fields: []
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
name: "profile",
|
|
397
|
+
summary: "The profiling level, read or set (`-1` reads).",
|
|
398
|
+
collection: false,
|
|
399
|
+
fields: [
|
|
400
|
+
"slowms",
|
|
401
|
+
"sampleRate",
|
|
402
|
+
"filter"
|
|
403
|
+
]
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
name: "dbHash",
|
|
407
|
+
summary: "Hashes of the collections, for comparing replicas.",
|
|
408
|
+
collection: false,
|
|
409
|
+
fields: ["collections"]
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
name: "collMod",
|
|
413
|
+
summary: "Change a collection's or view's options.",
|
|
414
|
+
collection: true,
|
|
415
|
+
fields: [
|
|
416
|
+
"index",
|
|
417
|
+
"validator",
|
|
418
|
+
"validationLevel",
|
|
419
|
+
"validationAction",
|
|
420
|
+
"viewOn",
|
|
421
|
+
"pipeline",
|
|
422
|
+
"expireAfterSeconds",
|
|
423
|
+
"changeStreamPreAndPostImages",
|
|
424
|
+
"writeConcern",
|
|
425
|
+
"comment"
|
|
426
|
+
]
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
name: "convertToCapped",
|
|
430
|
+
summary: "Convert a collection to a capped one.",
|
|
431
|
+
collection: true,
|
|
432
|
+
fields: [
|
|
433
|
+
"size",
|
|
434
|
+
"writeConcern",
|
|
435
|
+
"comment"
|
|
436
|
+
]
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
name: "compact",
|
|
440
|
+
summary: "Rewrite and defragment a collection's storage.",
|
|
441
|
+
collection: true,
|
|
442
|
+
fields: ["force", "comment"]
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
name: "reIndex",
|
|
446
|
+
summary: "Rebuild every index of a collection.",
|
|
447
|
+
collection: true,
|
|
448
|
+
fields: []
|
|
449
|
+
}
|
|
450
|
+
];
|
|
451
|
+
const QUERY_OPERATORS = [
|
|
452
|
+
"$and",
|
|
453
|
+
"$or",
|
|
454
|
+
"$nor",
|
|
455
|
+
"$not",
|
|
456
|
+
"$expr",
|
|
457
|
+
"$jsonSchema",
|
|
458
|
+
"$text",
|
|
459
|
+
"$where",
|
|
460
|
+
"$comment"
|
|
461
|
+
];
|
|
462
|
+
const FIELD_OPERATORS = [
|
|
463
|
+
"$eq",
|
|
464
|
+
"$ne",
|
|
465
|
+
"$gt",
|
|
466
|
+
"$gte",
|
|
467
|
+
"$lt",
|
|
468
|
+
"$lte",
|
|
469
|
+
"$in",
|
|
470
|
+
"$nin",
|
|
471
|
+
"$exists",
|
|
472
|
+
"$type",
|
|
473
|
+
"$regex",
|
|
474
|
+
"$options",
|
|
475
|
+
"$mod",
|
|
476
|
+
"$all",
|
|
477
|
+
"$elemMatch",
|
|
478
|
+
"$size",
|
|
479
|
+
"$not",
|
|
480
|
+
"$geoWithin",
|
|
481
|
+
"$geoIntersects",
|
|
482
|
+
"$near",
|
|
483
|
+
"$nearSphere",
|
|
484
|
+
"$bitsAllSet",
|
|
485
|
+
"$bitsAnySet",
|
|
486
|
+
"$bitsAllClear",
|
|
487
|
+
"$bitsAnyClear"
|
|
488
|
+
];
|
|
489
|
+
const UPDATE_OPERATORS = [
|
|
490
|
+
"$set",
|
|
491
|
+
"$unset",
|
|
492
|
+
"$inc",
|
|
493
|
+
"$mul",
|
|
494
|
+
"$rename",
|
|
495
|
+
"$setOnInsert",
|
|
496
|
+
"$min",
|
|
497
|
+
"$max",
|
|
498
|
+
"$currentDate",
|
|
499
|
+
"$push",
|
|
500
|
+
"$pop",
|
|
501
|
+
"$pull",
|
|
502
|
+
"$pullAll",
|
|
503
|
+
"$addToSet",
|
|
504
|
+
"$bit"
|
|
505
|
+
];
|
|
506
|
+
const PUSH_MODIFIERS = [
|
|
507
|
+
"$each",
|
|
508
|
+
"$slice",
|
|
509
|
+
"$sort",
|
|
510
|
+
"$position"
|
|
511
|
+
];
|
|
512
|
+
const STAGES = [
|
|
513
|
+
"$match",
|
|
514
|
+
"$project",
|
|
515
|
+
"$group",
|
|
516
|
+
"$sort",
|
|
517
|
+
"$limit",
|
|
518
|
+
"$skip",
|
|
519
|
+
"$unwind",
|
|
520
|
+
"$lookup",
|
|
521
|
+
"$addFields",
|
|
522
|
+
"$set",
|
|
523
|
+
"$unset",
|
|
524
|
+
"$count",
|
|
525
|
+
"$facet",
|
|
526
|
+
"$bucket",
|
|
527
|
+
"$bucketAuto",
|
|
528
|
+
"$sortByCount",
|
|
529
|
+
"$replaceRoot",
|
|
530
|
+
"$replaceWith",
|
|
531
|
+
"$sample",
|
|
532
|
+
"$out",
|
|
533
|
+
"$merge",
|
|
534
|
+
"$graphLookup",
|
|
535
|
+
"$redact",
|
|
536
|
+
"$collStats",
|
|
537
|
+
"$indexStats",
|
|
538
|
+
"$geoNear",
|
|
539
|
+
"$unionWith",
|
|
540
|
+
"$densify",
|
|
541
|
+
"$fill",
|
|
542
|
+
"$setWindowFields",
|
|
543
|
+
"$documents",
|
|
544
|
+
"$search",
|
|
545
|
+
"$searchMeta",
|
|
546
|
+
"$vectorSearch",
|
|
547
|
+
"$changeStream",
|
|
548
|
+
"$listSessions",
|
|
549
|
+
"$planCacheStats"
|
|
550
|
+
];
|
|
551
|
+
const EXPRESSION_OPERATORS = [
|
|
552
|
+
"$eq",
|
|
553
|
+
"$ne",
|
|
554
|
+
"$gt",
|
|
555
|
+
"$gte",
|
|
556
|
+
"$lt",
|
|
557
|
+
"$lte",
|
|
558
|
+
"$in",
|
|
559
|
+
"$and",
|
|
560
|
+
"$or",
|
|
561
|
+
"$not",
|
|
562
|
+
"$add",
|
|
563
|
+
"$subtract",
|
|
564
|
+
"$multiply",
|
|
565
|
+
"$divide",
|
|
566
|
+
"$mod",
|
|
567
|
+
"$abs",
|
|
568
|
+
"$ceil",
|
|
569
|
+
"$floor",
|
|
570
|
+
"$round",
|
|
571
|
+
"$concat",
|
|
572
|
+
"$substr",
|
|
573
|
+
"$toLower",
|
|
574
|
+
"$toUpper",
|
|
575
|
+
"$trim",
|
|
576
|
+
"$split",
|
|
577
|
+
"$strLenCP",
|
|
578
|
+
"$regexMatch",
|
|
579
|
+
"$cond",
|
|
580
|
+
"$ifNull",
|
|
581
|
+
"$switch",
|
|
582
|
+
"$size",
|
|
583
|
+
"$arrayElemAt",
|
|
584
|
+
"$filter",
|
|
585
|
+
"$map",
|
|
586
|
+
"$reduce",
|
|
587
|
+
"$in",
|
|
588
|
+
"$concatArrays",
|
|
589
|
+
"$slice",
|
|
590
|
+
"$year",
|
|
591
|
+
"$month",
|
|
592
|
+
"$dayOfMonth",
|
|
593
|
+
"$hour",
|
|
594
|
+
"$dateToString",
|
|
595
|
+
"$dateFromString",
|
|
596
|
+
"$dateAdd",
|
|
597
|
+
"$dateDiff",
|
|
598
|
+
"$toString",
|
|
599
|
+
"$toInt",
|
|
600
|
+
"$toLong",
|
|
601
|
+
"$toDouble",
|
|
602
|
+
"$toDate",
|
|
603
|
+
"$toObjectId",
|
|
604
|
+
"$type",
|
|
605
|
+
"$literal",
|
|
606
|
+
"$let",
|
|
607
|
+
"$sum",
|
|
608
|
+
"$avg",
|
|
609
|
+
"$min",
|
|
610
|
+
"$max",
|
|
611
|
+
"$first",
|
|
612
|
+
"$last",
|
|
613
|
+
"$push",
|
|
614
|
+
"$addToSet",
|
|
615
|
+
"$count",
|
|
616
|
+
"$stdDevPop",
|
|
617
|
+
"$stdDevSamp",
|
|
618
|
+
"$mergeObjects",
|
|
619
|
+
"$objectToArray",
|
|
620
|
+
"$arrayToObject",
|
|
621
|
+
"$getField",
|
|
622
|
+
"$setField",
|
|
623
|
+
"$rand"
|
|
624
|
+
];
|
|
625
|
+
const STAGE_KEYS = {
|
|
626
|
+
$lookup: [
|
|
627
|
+
"from",
|
|
628
|
+
"localField",
|
|
629
|
+
"foreignField",
|
|
630
|
+
"as",
|
|
631
|
+
"let",
|
|
632
|
+
"pipeline"
|
|
633
|
+
],
|
|
634
|
+
$unwind: [
|
|
635
|
+
"path",
|
|
636
|
+
"includeArrayIndex",
|
|
637
|
+
"preserveNullAndEmptyArrays"
|
|
638
|
+
],
|
|
639
|
+
$group: ["_id"],
|
|
640
|
+
$merge: [
|
|
641
|
+
"into",
|
|
642
|
+
"on",
|
|
643
|
+
"let",
|
|
644
|
+
"whenMatched",
|
|
645
|
+
"whenNotMatched"
|
|
646
|
+
],
|
|
647
|
+
$out: [
|
|
648
|
+
"db",
|
|
649
|
+
"coll",
|
|
650
|
+
"timeseries"
|
|
651
|
+
],
|
|
652
|
+
$bucket: [
|
|
653
|
+
"groupBy",
|
|
654
|
+
"boundaries",
|
|
655
|
+
"default",
|
|
656
|
+
"output"
|
|
657
|
+
],
|
|
658
|
+
$bucketAuto: [
|
|
659
|
+
"groupBy",
|
|
660
|
+
"buckets",
|
|
661
|
+
"output",
|
|
662
|
+
"granularity"
|
|
663
|
+
],
|
|
664
|
+
$graphLookup: [
|
|
665
|
+
"from",
|
|
666
|
+
"startWith",
|
|
667
|
+
"connectFromField",
|
|
668
|
+
"connectToField",
|
|
669
|
+
"as",
|
|
670
|
+
"maxDepth",
|
|
671
|
+
"depthField",
|
|
672
|
+
"restrictSearchWithMatch"
|
|
673
|
+
],
|
|
674
|
+
$setWindowFields: [
|
|
675
|
+
"partitionBy",
|
|
676
|
+
"sortBy",
|
|
677
|
+
"output"
|
|
678
|
+
],
|
|
679
|
+
$geoNear: [
|
|
680
|
+
"near",
|
|
681
|
+
"distanceField",
|
|
682
|
+
"spherical",
|
|
683
|
+
"maxDistance",
|
|
684
|
+
"minDistance",
|
|
685
|
+
"query",
|
|
686
|
+
"distanceMultiplier",
|
|
687
|
+
"includeLocs",
|
|
688
|
+
"key"
|
|
689
|
+
],
|
|
690
|
+
$replaceRoot: ["newRoot"],
|
|
691
|
+
$sample: ["size"],
|
|
692
|
+
$unionWith: ["coll", "pipeline"],
|
|
693
|
+
$densify: [
|
|
694
|
+
"field",
|
|
695
|
+
"partitionByFields",
|
|
696
|
+
"range"
|
|
697
|
+
],
|
|
698
|
+
$fill: [
|
|
699
|
+
"partitionBy",
|
|
700
|
+
"partitionByFields",
|
|
701
|
+
"sortBy",
|
|
702
|
+
"output"
|
|
703
|
+
],
|
|
704
|
+
$vectorSearch: [
|
|
705
|
+
"index",
|
|
706
|
+
"path",
|
|
707
|
+
"queryVector",
|
|
708
|
+
"numCandidates",
|
|
709
|
+
"limit",
|
|
710
|
+
"filter",
|
|
711
|
+
"exact"
|
|
712
|
+
],
|
|
713
|
+
$search: [
|
|
714
|
+
"index",
|
|
715
|
+
"text",
|
|
716
|
+
"compound",
|
|
717
|
+
"autocomplete",
|
|
718
|
+
"equals",
|
|
719
|
+
"range",
|
|
720
|
+
"near",
|
|
721
|
+
"phrase",
|
|
722
|
+
"queryString",
|
|
723
|
+
"wildcard",
|
|
724
|
+
"regex",
|
|
725
|
+
"exists",
|
|
726
|
+
"moreLikeThis",
|
|
727
|
+
"returnStoredSource",
|
|
728
|
+
"highlight",
|
|
729
|
+
"count",
|
|
730
|
+
"sort"
|
|
731
|
+
],
|
|
732
|
+
$searchMeta: [
|
|
733
|
+
"index",
|
|
734
|
+
"facet",
|
|
735
|
+
"count"
|
|
736
|
+
],
|
|
737
|
+
$collStats: [
|
|
738
|
+
"latencyStats",
|
|
739
|
+
"storageStats",
|
|
740
|
+
"count",
|
|
741
|
+
"queryExecStats"
|
|
742
|
+
],
|
|
743
|
+
$changeStream: [
|
|
744
|
+
"fullDocument",
|
|
745
|
+
"fullDocumentBeforeChange",
|
|
746
|
+
"resumeAfter",
|
|
747
|
+
"startAfter",
|
|
748
|
+
"startAtOperationTime",
|
|
749
|
+
"showExpandedEvents"
|
|
750
|
+
],
|
|
751
|
+
$documents: [],
|
|
752
|
+
$facet: [],
|
|
753
|
+
$project: [],
|
|
754
|
+
$sort: [],
|
|
755
|
+
$addFields: [],
|
|
756
|
+
$set: [],
|
|
757
|
+
$unset: [],
|
|
758
|
+
$sortByCount: [],
|
|
759
|
+
$redact: [],
|
|
760
|
+
$indexStats: [],
|
|
761
|
+
$limit: [],
|
|
762
|
+
$skip: [],
|
|
763
|
+
$count: [],
|
|
764
|
+
$replaceWith: [],
|
|
765
|
+
$listSessions: [],
|
|
766
|
+
$planCacheStats: []
|
|
767
|
+
};
|
|
768
|
+
const FIELD_KEYS = {
|
|
769
|
+
updates: [
|
|
770
|
+
"q",
|
|
771
|
+
"u",
|
|
772
|
+
"c",
|
|
773
|
+
"upsert",
|
|
774
|
+
"multi",
|
|
775
|
+
"collation",
|
|
776
|
+
"arrayFilters",
|
|
777
|
+
"hint",
|
|
778
|
+
"sort"
|
|
779
|
+
],
|
|
780
|
+
deletes: [
|
|
781
|
+
"q",
|
|
782
|
+
"limit",
|
|
783
|
+
"collation",
|
|
784
|
+
"hint"
|
|
785
|
+
],
|
|
786
|
+
indexes: [
|
|
787
|
+
"key",
|
|
788
|
+
"name",
|
|
789
|
+
"unique",
|
|
790
|
+
"sparse",
|
|
791
|
+
"expireAfterSeconds",
|
|
792
|
+
"partialFilterExpression",
|
|
793
|
+
"collation",
|
|
794
|
+
"hidden",
|
|
795
|
+
"weights",
|
|
796
|
+
"default_language",
|
|
797
|
+
"language_override",
|
|
798
|
+
"wildcardProjection",
|
|
799
|
+
"storageEngine",
|
|
800
|
+
"textIndexVersion",
|
|
801
|
+
"2dsphereIndexVersion",
|
|
802
|
+
"bits",
|
|
803
|
+
"min",
|
|
804
|
+
"max"
|
|
805
|
+
],
|
|
806
|
+
cursor: ["batchSize"],
|
|
807
|
+
collation: [
|
|
808
|
+
"locale",
|
|
809
|
+
"strength",
|
|
810
|
+
"caseLevel",
|
|
811
|
+
"caseFirst",
|
|
812
|
+
"numericOrdering",
|
|
813
|
+
"alternate",
|
|
814
|
+
"maxVariable",
|
|
815
|
+
"backwards",
|
|
816
|
+
"normalization"
|
|
817
|
+
],
|
|
818
|
+
readConcern: ["level"],
|
|
819
|
+
writeConcern: [
|
|
820
|
+
"w",
|
|
821
|
+
"j",
|
|
822
|
+
"wtimeout"
|
|
823
|
+
],
|
|
824
|
+
timeseries: [
|
|
825
|
+
"timeField",
|
|
826
|
+
"metaField",
|
|
827
|
+
"granularity",
|
|
828
|
+
"bucketMaxSpanSeconds",
|
|
829
|
+
"bucketRoundingSeconds"
|
|
830
|
+
],
|
|
831
|
+
clusteredIndex: [
|
|
832
|
+
"key",
|
|
833
|
+
"unique",
|
|
834
|
+
"name"
|
|
835
|
+
],
|
|
836
|
+
changeStreamPreAndPostImages: ["enabled"],
|
|
837
|
+
ops: [
|
|
838
|
+
"insert",
|
|
839
|
+
"update",
|
|
840
|
+
"delete",
|
|
841
|
+
"document",
|
|
842
|
+
"filter",
|
|
843
|
+
"updateMods",
|
|
844
|
+
"multi",
|
|
845
|
+
"upsert",
|
|
846
|
+
"arrayFilters",
|
|
847
|
+
"hint",
|
|
848
|
+
"collation",
|
|
849
|
+
"constants",
|
|
850
|
+
"sort"
|
|
851
|
+
],
|
|
852
|
+
nsInfo: ["ns"],
|
|
853
|
+
storageEngine: ["wiredTiger"],
|
|
854
|
+
validator: QUERY_OPERATORS,
|
|
855
|
+
$jsonSchema: [
|
|
856
|
+
"bsonType",
|
|
857
|
+
"required",
|
|
858
|
+
"properties",
|
|
859
|
+
"additionalProperties",
|
|
860
|
+
"items",
|
|
861
|
+
"enum",
|
|
862
|
+
"minimum",
|
|
863
|
+
"maximum",
|
|
864
|
+
"minLength",
|
|
865
|
+
"maxLength",
|
|
866
|
+
"pattern",
|
|
867
|
+
"description",
|
|
868
|
+
"title",
|
|
869
|
+
"type",
|
|
870
|
+
"anyOf",
|
|
871
|
+
"allOf",
|
|
872
|
+
"oneOf",
|
|
873
|
+
"not"
|
|
874
|
+
],
|
|
875
|
+
$text: [
|
|
876
|
+
"$search",
|
|
877
|
+
"$language",
|
|
878
|
+
"$caseSensitive",
|
|
879
|
+
"$diacriticSensitive"
|
|
880
|
+
],
|
|
881
|
+
$regex: [],
|
|
882
|
+
$elemMatch: FIELD_OPERATORS,
|
|
883
|
+
$not: FIELD_OPERATORS,
|
|
884
|
+
$expr: EXPRESSION_OPERATORS,
|
|
885
|
+
$cond: [
|
|
886
|
+
"if",
|
|
887
|
+
"then",
|
|
888
|
+
"else"
|
|
889
|
+
],
|
|
890
|
+
$switch: ["branches", "default"],
|
|
891
|
+
$filter: [
|
|
892
|
+
"input",
|
|
893
|
+
"as",
|
|
894
|
+
"cond",
|
|
895
|
+
"limit"
|
|
896
|
+
],
|
|
897
|
+
$map: [
|
|
898
|
+
"input",
|
|
899
|
+
"as",
|
|
900
|
+
"in"
|
|
901
|
+
],
|
|
902
|
+
$reduce: [
|
|
903
|
+
"input",
|
|
904
|
+
"initialValue",
|
|
905
|
+
"in"
|
|
906
|
+
],
|
|
907
|
+
$let: ["vars", "in"],
|
|
908
|
+
$dateToString: [
|
|
909
|
+
"format",
|
|
910
|
+
"date",
|
|
911
|
+
"timezone",
|
|
912
|
+
"onNull"
|
|
913
|
+
],
|
|
914
|
+
$dateFromString: [
|
|
915
|
+
"dateString",
|
|
916
|
+
"format",
|
|
917
|
+
"timezone",
|
|
918
|
+
"onError",
|
|
919
|
+
"onNull"
|
|
920
|
+
],
|
|
921
|
+
$dateAdd: [
|
|
922
|
+
"startDate",
|
|
923
|
+
"unit",
|
|
924
|
+
"amount",
|
|
925
|
+
"timezone"
|
|
926
|
+
],
|
|
927
|
+
$dateDiff: [
|
|
928
|
+
"startDate",
|
|
929
|
+
"endDate",
|
|
930
|
+
"unit",
|
|
931
|
+
"timezone",
|
|
932
|
+
"startOfWeek"
|
|
933
|
+
],
|
|
934
|
+
$regexMatch: [
|
|
935
|
+
"input",
|
|
936
|
+
"regex",
|
|
937
|
+
"options"
|
|
938
|
+
],
|
|
939
|
+
$getField: ["field", "input"],
|
|
940
|
+
$setField: [
|
|
941
|
+
"field",
|
|
942
|
+
"input",
|
|
943
|
+
"value"
|
|
944
|
+
],
|
|
945
|
+
$trim: ["input", "chars"],
|
|
946
|
+
$round: [],
|
|
947
|
+
range: [
|
|
948
|
+
"step",
|
|
949
|
+
"unit",
|
|
950
|
+
"bounds"
|
|
951
|
+
],
|
|
952
|
+
output: [],
|
|
953
|
+
window: [
|
|
954
|
+
"documents",
|
|
955
|
+
"range",
|
|
956
|
+
"unit"
|
|
957
|
+
]
|
|
958
|
+
};
|
|
959
|
+
const QUERY_HOLDERS = /* @__PURE__ */ new Set([
|
|
960
|
+
"filter",
|
|
961
|
+
"query",
|
|
962
|
+
"q",
|
|
963
|
+
"$match",
|
|
964
|
+
"$and",
|
|
965
|
+
"$or",
|
|
966
|
+
"$nor",
|
|
967
|
+
"partialFilterExpression",
|
|
968
|
+
"restrictSearchWithMatch",
|
|
969
|
+
"validator"
|
|
970
|
+
]);
|
|
971
|
+
const UPDATE_HOLDERS = /* @__PURE__ */ new Set([
|
|
972
|
+
"u",
|
|
973
|
+
"update",
|
|
974
|
+
"updateMods"
|
|
975
|
+
]);
|
|
976
|
+
const PIPELINE_HOLDERS = /* @__PURE__ */ new Set(["pipeline"]);
|
|
977
|
+
function keysAt(path, siblings, commands = MONGO_COMMANDS) {
|
|
978
|
+
const last = path.at(-1);
|
|
979
|
+
if (last === void 0) {
|
|
980
|
+
const named = siblings.find((key) => key !== "$db");
|
|
981
|
+
const command = named === void 0 ? void 0 : commands.find((candidate) => candidate.name === named);
|
|
982
|
+
if (command === void 0) return [...commands.map((candidate) => candidate.name), "$db"];
|
|
983
|
+
return [...command.fields, "$db"].filter((key) => !siblings.includes(key));
|
|
984
|
+
}
|
|
985
|
+
if (QUERY_HOLDERS.has(last)) return QUERY_OPERATORS;
|
|
986
|
+
if (UPDATE_HOLDERS.has(last)) return UPDATE_OPERATORS;
|
|
987
|
+
if (PIPELINE_HOLDERS.has(last)) return STAGES;
|
|
988
|
+
if (last.startsWith("$")) return STAGE_KEYS[last] ?? FIELD_KEYS[last] ?? [];
|
|
989
|
+
const parent = path.at(-2);
|
|
990
|
+
if (parent !== void 0 && QUERY_HOLDERS.has(parent)) return FIELD_OPERATORS;
|
|
991
|
+
if (parent === "$push" || parent === "$addToSet") return PUSH_MODIFIERS;
|
|
992
|
+
if (parent === "$group") return EXPRESSION_OPERATORS;
|
|
993
|
+
return FIELD_KEYS[last] ?? [];
|
|
994
|
+
}
|
|
995
|
+
//#endregion
|
|
996
|
+
//#region src/markers.ts
|
|
997
|
+
function documentMarkers(text, commands = MONGO_COMMANDS) {
|
|
998
|
+
const read = readDocument(text);
|
|
999
|
+
if (read.refusal === "empty") return [];
|
|
1000
|
+
if (read.refusal === "not-a-document") {
|
|
1001
|
+
const lineEnd = text.indexOf("\n", read.at);
|
|
1002
|
+
return [{
|
|
1003
|
+
from: read.at,
|
|
1004
|
+
to: Math.max(read.at + 1, lineEnd === -1 ? text.length : lineEnd),
|
|
1005
|
+
code: "not-a-document",
|
|
1006
|
+
severity: "error"
|
|
1007
|
+
}];
|
|
1008
|
+
}
|
|
1009
|
+
if (read.refusal === "no-command" || read.commandSpan === null) return [{
|
|
1010
|
+
from: text.length - text.trimStart().length,
|
|
1011
|
+
to: text.trimEnd().length,
|
|
1012
|
+
code: "no-command",
|
|
1013
|
+
severity: "error"
|
|
1014
|
+
}];
|
|
1015
|
+
if (commands.every((command) => command.name !== read.command)) return [{
|
|
1016
|
+
...read.commandSpan,
|
|
1017
|
+
code: "unknown-command",
|
|
1018
|
+
severity: "hint"
|
|
1019
|
+
}];
|
|
1020
|
+
return [];
|
|
1021
|
+
}
|
|
1022
|
+
//#endregion
|
|
1023
|
+
export { PUSH_MODIFIERS as a, UPDATE_OPERATORS as c, MONGO_COMMANDS as i, keysAt as l, EXPRESSION_OPERATORS as n, QUERY_OPERATORS as o, FIELD_OPERATORS as r, STAGES as s, documentMarkers as t };
|