@sfxcode/nuxt-mongocamp-server 2.2.0 → 2.4.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 (77) hide show
  1. package/README.md +74 -1
  2. package/dist/module.d.mts +10 -0
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +95 -11
  5. package/dist/runtime/api/.openapi-generator/FILES +22 -0
  6. package/dist/runtime/api/apis/CollectionApi.d.ts +124 -0
  7. package/dist/runtime/api/apis/CollectionApi.js +205 -0
  8. package/dist/runtime/api/apis/DocumentApi.d.ts +162 -0
  9. package/dist/runtime/api/apis/DocumentApi.js +229 -0
  10. package/dist/runtime/api/docs/AuditEntry.md +52 -0
  11. package/dist/runtime/api/docs/CollectionApi.md +269 -2
  12. package/dist/runtime/api/docs/CollectionDeclaration.md +56 -0
  13. package/dist/runtime/api/docs/CollectionDeclarationAudit.md +34 -0
  14. package/dist/runtime/api/docs/CollectionDeclarationIndexesInner.md +38 -0
  15. package/dist/runtime/api/docs/CollectionDeclarationOwner.md +36 -0
  16. package/dist/runtime/api/docs/CollectionDeclarationRefsInner.md +38 -0
  17. package/dist/runtime/api/docs/CollectionDeclarationSoftDelete.md +36 -0
  18. package/dist/runtime/api/docs/CollectionDeclarationTimestamps.md +40 -0
  19. package/dist/runtime/api/docs/CollectionDeclarationVersioned.md +38 -0
  20. package/dist/runtime/api/docs/DocumentApi.md +303 -8
  21. package/dist/runtime/api/docs/ErrorDescription.md +4 -0
  22. package/dist/runtime/api/docs/ExportRequest.md +2 -0
  23. package/dist/runtime/api/docs/MongoFindRequest.md +2 -0
  24. package/dist/runtime/api/docs/SearchRequest.md +2 -0
  25. package/dist/runtime/api/docs/SuggestedValidator.md +40 -0
  26. package/dist/runtime/api/docs/ValidationIssue.md +36 -0
  27. package/dist/runtime/api/models/AuditEntry.d.ts +88 -0
  28. package/dist/runtime/api/models/AuditEntry.js +56 -0
  29. package/dist/runtime/api/models/CollectionDeclaration.d.ts +90 -0
  30. package/dist/runtime/api/models/CollectionDeclaration.js +87 -0
  31. package/dist/runtime/api/models/CollectionDeclarationAudit.d.ts +30 -0
  32. package/dist/runtime/api/models/CollectionDeclarationAudit.js +26 -0
  33. package/dist/runtime/api/models/CollectionDeclarationIndexesInner.d.ts +40 -0
  34. package/dist/runtime/api/models/CollectionDeclarationIndexesInner.js +32 -0
  35. package/dist/runtime/api/models/CollectionDeclarationOwner.d.ts +43 -0
  36. package/dist/runtime/api/models/CollectionDeclarationOwner.js +34 -0
  37. package/dist/runtime/api/models/CollectionDeclarationRefsInner.d.ts +38 -0
  38. package/dist/runtime/api/models/CollectionDeclarationRefsInner.js +31 -0
  39. package/dist/runtime/api/models/CollectionDeclarationSoftDelete.d.ts +34 -0
  40. package/dist/runtime/api/models/CollectionDeclarationSoftDelete.js +28 -0
  41. package/dist/runtime/api/models/CollectionDeclarationTimestamps.d.ts +42 -0
  42. package/dist/runtime/api/models/CollectionDeclarationTimestamps.js +33 -0
  43. package/dist/runtime/api/models/CollectionDeclarationVersioned.d.ts +46 -0
  44. package/dist/runtime/api/models/CollectionDeclarationVersioned.js +36 -0
  45. package/dist/runtime/api/models/ErrorDescription.d.ts +11 -0
  46. package/dist/runtime/api/models/ErrorDescription.js +10 -2
  47. package/dist/runtime/api/models/ExportRequest.d.ts +4 -0
  48. package/dist/runtime/api/models/ExportRequest.js +4 -2
  49. package/dist/runtime/api/models/MongoFindRequest.d.ts +4 -0
  50. package/dist/runtime/api/models/MongoFindRequest.js +4 -2
  51. package/dist/runtime/api/models/SearchRequest.d.ts +4 -0
  52. package/dist/runtime/api/models/SearchRequest.js +4 -2
  53. package/dist/runtime/api/models/SuggestedValidator.d.ts +44 -0
  54. package/dist/runtime/api/models/SuggestedValidator.js +35 -0
  55. package/dist/runtime/api/models/ValidationIssue.d.ts +34 -0
  56. package/dist/runtime/api/models/ValidationIssue.js +29 -0
  57. package/dist/runtime/api/models/index.d.ts +11 -0
  58. package/dist/runtime/api/models/index.js +11 -0
  59. package/dist/runtime/composables/mongocampApiCollection.d.ts +14 -15
  60. package/dist/runtime/composables/mongocampApiCollection.js +4 -1
  61. package/dist/runtime/composables/mongocampCollection.d.ts +144 -0
  62. package/dist/runtime/composables/mongocampCollection.js +241 -0
  63. package/dist/runtime/composables/mongocampLive.d.ts +36 -0
  64. package/dist/runtime/composables/mongocampLive.js +155 -0
  65. package/dist/runtime/composables/mongocampSearch.d.ts +12 -9
  66. package/dist/runtime/server/composables/mongocampServerCollection.d.ts +20 -0
  67. package/dist/runtime/server/composables/mongocampServerCollection.js +12 -0
  68. package/dist/runtime/server/mongocamp/plugin.d.ts +2 -2
  69. package/dist/runtime/server/mongocamp/plugin.js +10 -1
  70. package/dist/runtime/types/collections.d.ts +30 -0
  71. package/dist/runtime/types/collections.js +0 -0
  72. package/dist/runtime/utils/sse.d.ts +10 -0
  73. package/dist/runtime/utils/sse.js +33 -0
  74. package/dist/runtime/utils/toMongocampError.d.ts +7 -0
  75. package/dist/runtime/utils/toMongocampError.js +18 -1
  76. package/dist/types.d.mts +6 -0
  77. package/package.json +4 -3
@@ -1,4 +1,7 @@
1
1
  import * as runtime from "../runtime.js";
2
+ import {
3
+ AuditEntryFromJSON
4
+ } from "../models/AuditEntry.js";
2
5
  import {
3
6
  CountRequestToJSON
4
7
  } from "../models/CountRequest.js";
@@ -99,6 +102,9 @@ export class DocumentApi extends runtime.BaseAPI {
99
102
  );
100
103
  }
101
104
  const queryParameters = {};
105
+ if (requestParameters["withDeleted"] != null) {
106
+ queryParameters["withDeleted"] = requestParameters["withDeleted"];
107
+ }
102
108
  if (requestParameters["filter"] != null) {
103
109
  queryParameters["filter"] = requestParameters["filter"];
104
110
  }
@@ -162,6 +168,9 @@ export class DocumentApi extends runtime.BaseAPI {
162
168
  );
163
169
  }
164
170
  const queryParameters = {};
171
+ if (requestParameters["withDeleted"] != null) {
172
+ queryParameters["withDeleted"] = requestParameters["withDeleted"];
173
+ }
165
174
  if (requestParameters["filterCaseInsensitive"] != null) {
166
175
  queryParameters["filterCaseInsensitive"] = requestParameters["filterCaseInsensitive"];
167
176
  }
@@ -286,6 +295,12 @@ export class DocumentApi extends runtime.BaseAPI {
286
295
  );
287
296
  }
288
297
  const queryParameters = {};
298
+ if (requestParameters["expand"] != null) {
299
+ queryParameters["expand"] = requestParameters["expand"];
300
+ }
301
+ if (requestParameters["withDeleted"] != null) {
302
+ queryParameters["withDeleted"] = requestParameters["withDeleted"];
303
+ }
289
304
  if (requestParameters["format"] != null) {
290
305
  queryParameters["format"] = requestParameters["format"];
291
306
  }
@@ -371,6 +386,12 @@ export class DocumentApi extends runtime.BaseAPI {
371
386
  );
372
387
  }
373
388
  const queryParameters = {};
389
+ if (requestParameters["expand"] != null) {
390
+ queryParameters["expand"] = requestParameters["expand"];
391
+ }
392
+ if (requestParameters["withDeleted"] != null) {
393
+ queryParameters["withDeleted"] = requestParameters["withDeleted"];
394
+ }
374
395
  if (requestParameters["format"] != null) {
375
396
  queryParameters["format"] = requestParameters["format"];
376
397
  }
@@ -446,6 +467,12 @@ export class DocumentApi extends runtime.BaseAPI {
446
467
  );
447
468
  }
448
469
  const queryParameters = {};
470
+ if (requestParameters["expand"] != null) {
471
+ queryParameters["expand"] = requestParameters["expand"];
472
+ }
473
+ if (requestParameters["withDeleted"] != null) {
474
+ queryParameters["withDeleted"] = requestParameters["withDeleted"];
475
+ }
449
476
  if (requestParameters["rowsPerPage"] != null) {
450
477
  queryParameters["rowsPerPage"] = requestParameters["rowsPerPage"];
451
478
  }
@@ -520,6 +547,12 @@ export class DocumentApi extends runtime.BaseAPI {
520
547
  );
521
548
  }
522
549
  const queryParameters = {};
550
+ if (requestParameters["expand"] != null) {
551
+ queryParameters["expand"] = requestParameters["expand"];
552
+ }
553
+ if (requestParameters["withDeleted"] != null) {
554
+ queryParameters["withDeleted"] = requestParameters["withDeleted"];
555
+ }
523
556
  if (requestParameters["extendedJson"] != null) {
524
557
  queryParameters["extendedJson"] = requestParameters["extendedJson"];
525
558
  }
@@ -564,6 +597,73 @@ export class DocumentApi extends runtime.BaseAPI {
564
597
  const response = await this.getDocumentRaw(requestParameters, initOverrides);
565
598
  return await response.value();
566
599
  }
600
+ /**
601
+ * Creates request options for getDocumentHistory without sending the request
602
+ */
603
+ async getDocumentHistoryRequestOpts(requestParameters) {
604
+ if (requestParameters["collectionName"] == null) {
605
+ throw new runtime.RequiredError(
606
+ "collectionName",
607
+ 'Required parameter "collectionName" was null or undefined when calling getDocumentHistory().'
608
+ );
609
+ }
610
+ if (requestParameters["documentId"] == null) {
611
+ throw new runtime.RequiredError(
612
+ "documentId",
613
+ 'Required parameter "documentId" was null or undefined when calling getDocumentHistory().'
614
+ );
615
+ }
616
+ const queryParameters = {};
617
+ if (requestParameters["rowsPerPage"] != null) {
618
+ queryParameters["rowsPerPage"] = requestParameters["rowsPerPage"];
619
+ }
620
+ if (requestParameters["page"] != null) {
621
+ queryParameters["page"] = requestParameters["page"];
622
+ }
623
+ if (requestParameters["extendedJson"] != null) {
624
+ queryParameters["extendedJson"] = requestParameters["extendedJson"];
625
+ }
626
+ const headerParameters = {};
627
+ if (this.configuration && (this.configuration.username !== void 0 || this.configuration.password !== void 0)) {
628
+ headerParameters["Authorization"] = "Basic " + btoa((this.configuration.username || "") + ":" + (this.configuration.password || ""));
629
+ }
630
+ if (this.configuration && this.configuration.accessToken) {
631
+ const token = this.configuration.accessToken;
632
+ const tokenString = await token("httpAuth", []);
633
+ if (tokenString) {
634
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
635
+ }
636
+ }
637
+ if (this.configuration && this.configuration.apiKey) {
638
+ headerParameters["X-AUTH-APIKEY"] = await this.configuration.apiKey("X-AUTH-APIKEY");
639
+ }
640
+ let urlPath = `/mongodb/collections/{collectionName}/documents/{documentId}/history`;
641
+ urlPath = urlPath.replace("{collectionName}", encodeURIComponent(String(requestParameters["collectionName"])));
642
+ urlPath = urlPath.replace("{documentId}", encodeURIComponent(String(requestParameters["documentId"])));
643
+ return {
644
+ path: urlPath,
645
+ method: "GET",
646
+ headers: headerParameters,
647
+ query: queryParameters
648
+ };
649
+ }
650
+ /**
651
+ * The audit records of a document of a collection declared with audit, newest first (2.3.0). For users who can read the document; administrators of the collection also get the history of deleted documents. 404 for a collection without audit.
652
+ * History of a Document
653
+ */
654
+ async getDocumentHistoryRaw(requestParameters, initOverrides) {
655
+ const requestOptions = await this.getDocumentHistoryRequestOpts(requestParameters);
656
+ const response = await this.request(requestOptions, initOverrides);
657
+ return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(AuditEntryFromJSON));
658
+ }
659
+ /**
660
+ * The audit records of a document of a collection declared with audit, newest first (2.3.0). For users who can read the document; administrators of the collection also get the history of deleted documents. 404 for a collection without audit.
661
+ * History of a Document
662
+ */
663
+ async getDocumentHistory(requestParameters, initOverrides) {
664
+ const response = await this.getDocumentHistoryRaw(requestParameters, initOverrides);
665
+ return await response.value();
666
+ }
567
667
  /**
568
668
  * Creates request options for importDocuments without sending the request
569
669
  */
@@ -749,6 +849,12 @@ export class DocumentApi extends runtime.BaseAPI {
749
849
  );
750
850
  }
751
851
  const queryParameters = {};
852
+ if (requestParameters["expand"] != null) {
853
+ queryParameters["expand"] = requestParameters["expand"];
854
+ }
855
+ if (requestParameters["withDeleted"] != null) {
856
+ queryParameters["withDeleted"] = requestParameters["withDeleted"];
857
+ }
752
858
  if (requestParameters["filter"] != null) {
753
859
  queryParameters["filter"] = requestParameters["filter"];
754
860
  }
@@ -816,6 +922,64 @@ export class DocumentApi extends runtime.BaseAPI {
816
922
  const response = await this.listDocumentsRaw(requestParameters, initOverrides);
817
923
  return await response.value();
818
924
  }
925
+ /**
926
+ * Creates request options for restoreDocument without sending the request
927
+ */
928
+ async restoreDocumentRequestOpts(requestParameters) {
929
+ if (requestParameters["collectionName"] == null) {
930
+ throw new runtime.RequiredError(
931
+ "collectionName",
932
+ 'Required parameter "collectionName" was null or undefined when calling restoreDocument().'
933
+ );
934
+ }
935
+ if (requestParameters["documentId"] == null) {
936
+ throw new runtime.RequiredError(
937
+ "documentId",
938
+ 'Required parameter "documentId" was null or undefined when calling restoreDocument().'
939
+ );
940
+ }
941
+ const queryParameters = {};
942
+ const headerParameters = {};
943
+ if (this.configuration && (this.configuration.username !== void 0 || this.configuration.password !== void 0)) {
944
+ headerParameters["Authorization"] = "Basic " + btoa((this.configuration.username || "") + ":" + (this.configuration.password || ""));
945
+ }
946
+ if (this.configuration && this.configuration.accessToken) {
947
+ const token = this.configuration.accessToken;
948
+ const tokenString = await token("httpAuth", []);
949
+ if (tokenString) {
950
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
951
+ }
952
+ }
953
+ if (this.configuration && this.configuration.apiKey) {
954
+ headerParameters["X-AUTH-APIKEY"] = await this.configuration.apiKey("X-AUTH-APIKEY");
955
+ }
956
+ let urlPath = `/mongodb/collections/{collectionName}/documents/{documentId}/restore`;
957
+ urlPath = urlPath.replace("{collectionName}", encodeURIComponent(String(requestParameters["collectionName"])));
958
+ urlPath = urlPath.replace("{documentId}", encodeURIComponent(String(requestParameters["documentId"])));
959
+ return {
960
+ path: urlPath,
961
+ method: "POST",
962
+ headers: headerParameters,
963
+ query: queryParameters
964
+ };
965
+ }
966
+ /**
967
+ * Removes the deleted mark of a document of a collection declared with softDelete (2.3.0). 404 for a collection without soft delete and for a document that is missing or not deleted.
968
+ * Restore a soft-deleted Document
969
+ */
970
+ async restoreDocumentRaw(requestParameters, initOverrides) {
971
+ const requestOptions = await this.restoreDocumentRequestOpts(requestParameters);
972
+ const response = await this.request(requestOptions, initOverrides);
973
+ return new runtime.JSONApiResponse(response, (jsonValue) => UpdateResponseFromJSON(jsonValue));
974
+ }
975
+ /**
976
+ * Removes the deleted mark of a document of a collection declared with softDelete (2.3.0). 404 for a collection without soft delete and for a document that is missing or not deleted.
977
+ * Restore a soft-deleted Document
978
+ */
979
+ async restoreDocument(requestParameters, initOverrides) {
980
+ const response = await this.restoreDocumentRaw(requestParameters, initOverrides);
981
+ return await response.value();
982
+ }
819
983
  /**
820
984
  * Creates request options for searchDocuments without sending the request
821
985
  */
@@ -833,6 +997,12 @@ export class DocumentApi extends runtime.BaseAPI {
833
997
  );
834
998
  }
835
999
  const queryParameters = {};
1000
+ if (requestParameters["expand"] != null) {
1001
+ queryParameters["expand"] = requestParameters["expand"];
1002
+ }
1003
+ if (requestParameters["withDeleted"] != null) {
1004
+ queryParameters["withDeleted"] = requestParameters["withDeleted"];
1005
+ }
836
1006
  if (requestParameters["rowsPerPage"] != null) {
837
1007
  queryParameters["rowsPerPage"] = requestParameters["rowsPerPage"];
838
1008
  }
@@ -1093,6 +1263,60 @@ export class DocumentApi extends runtime.BaseAPI {
1093
1263
  const response = await this.updateManyRaw(requestParameters, initOverrides);
1094
1264
  return await response.value();
1095
1265
  }
1266
+ /**
1267
+ * Creates request options for watchDocuments without sending the request
1268
+ */
1269
+ async watchDocumentsRequestOpts(requestParameters) {
1270
+ if (requestParameters["collectionName"] == null) {
1271
+ throw new runtime.RequiredError(
1272
+ "collectionName",
1273
+ 'Required parameter "collectionName" was null or undefined when calling watchDocuments().'
1274
+ );
1275
+ }
1276
+ const queryParameters = {};
1277
+ if (requestParameters["expand"] != null) {
1278
+ queryParameters["expand"] = requestParameters["expand"];
1279
+ }
1280
+ if (requestParameters["filter"] != null) {
1281
+ queryParameters["filter"] = requestParameters["filter"];
1282
+ }
1283
+ if (requestParameters["filterCaseInsensitive"] != null) {
1284
+ queryParameters["filterCaseInsensitive"] = requestParameters["filterCaseInsensitive"];
1285
+ }
1286
+ const headerParameters = {};
1287
+ if (requestParameters["lastEventID"] != null) {
1288
+ headerParameters["Last-Event-ID"] = String(requestParameters["lastEventID"]);
1289
+ }
1290
+ let urlPath = `/mongodb/collections/{collectionName}/documents/watch`;
1291
+ urlPath = urlPath.replace("{collectionName}", encodeURIComponent(String(requestParameters["collectionName"])));
1292
+ return {
1293
+ path: urlPath,
1294
+ method: "GET",
1295
+ headers: headerParameters,
1296
+ query: queryParameters
1297
+ };
1298
+ }
1299
+ /**
1300
+ * The changes of the documents as Server-Sent Events (2.3.0), scoped like every read and by `filter`. Events: `upsert` (data `{ id, document }`, a document that is in the scope), `remove` (data `{ id }`, deleted or left the scope), `reset` (the client loads again). The `id` of an event is the resume token: send it as `Last-Event-ID` to resume. A comment every 25 seconds. Needs a replica set or a sharded cluster: 501 (code 5011) otherwise; at most `WATCH_MAX_STREAMS` streams per instance (503).
1301
+ * Live Updates of a Collection
1302
+ */
1303
+ async watchDocumentsRaw(requestParameters, initOverrides) {
1304
+ const requestOptions = await this.watchDocumentsRequestOpts(requestParameters);
1305
+ const response = await this.request(requestOptions, initOverrides);
1306
+ if (this.isJsonMime(response.headers.get("content-type"))) {
1307
+ return new runtime.JSONApiResponse(response);
1308
+ } else {
1309
+ return new runtime.TextApiResponse(response);
1310
+ }
1311
+ }
1312
+ /**
1313
+ * The changes of the documents as Server-Sent Events (2.3.0), scoped like every read and by `filter`. Events: `upsert` (data `{ id, document }`, a document that is in the scope), `remove` (data `{ id }`, deleted or left the scope), `reset` (the client loads again). The `id` of an event is the resume token: send it as `Last-Event-ID` to resume. A comment every 25 seconds. Needs a replica set or a sharded cluster: 501 (code 5011) otherwise; at most `WATCH_MAX_STREAMS` streams per instance (503).
1314
+ * Live Updates of a Collection
1315
+ */
1316
+ async watchDocuments(requestParameters, initOverrides) {
1317
+ const response = await this.watchDocumentsRaw(requestParameters, initOverrides);
1318
+ return await response.value();
1319
+ }
1096
1320
  }
1097
1321
  export const ExportDocumentsExtendedJsonEnum = {
1098
1322
  Relaxed: "relaxed",
@@ -1118,6 +1342,11 @@ export const GetDocumentExtendedJsonEnum = {
1118
1342
  Canonical: "canonical",
1119
1343
  Plain: "plain"
1120
1344
  };
1345
+ export const GetDocumentHistoryExtendedJsonEnum = {
1346
+ Relaxed: "relaxed",
1347
+ Canonical: "canonical",
1348
+ Plain: "plain"
1349
+ };
1121
1350
  export const ListDocumentsCountEnum = {
1122
1351
  Exact: "exact",
1123
1352
  None: "none"
@@ -0,0 +1,52 @@
1
+
2
+ # AuditEntry
3
+
4
+
5
+ ## Properties
6
+
7
+ Name | Type
8
+ ------------ | -------------
9
+ `collection` | string
10
+ `database` | string
11
+ `documentId` | any
12
+ `operation` | string
13
+ `user` | string
14
+ `at` | { [key: string]: any; }
15
+ `before` | { [key: string]: any; }
16
+ `after` | { [key: string]: any; }
17
+ `summary` | { [key: string]: any; }
18
+ `expiresAt` | { [key: string]: any; }
19
+
20
+ ## Example
21
+
22
+ ```typescript
23
+ import type { AuditEntry } from ''
24
+
25
+ // TODO: Update the object below with actual values
26
+ const example = {
27
+ "collection": null,
28
+ "database": null,
29
+ "documentId": null,
30
+ "operation": null,
31
+ "user": null,
32
+ "at": null,
33
+ "before": null,
34
+ "after": null,
35
+ "summary": null,
36
+ "expiresAt": null,
37
+ } satisfies AuditEntry
38
+
39
+ console.log(example)
40
+
41
+ // Convert the instance to a JSON string
42
+ const exampleJSON: string = JSON.stringify(example)
43
+ console.log(exampleJSON)
44
+
45
+ // Parse the JSON string back to an object
46
+ const exampleParsed = JSON.parse(exampleJSON) as AuditEntry
47
+ console.log(exampleParsed)
48
+ ```
49
+
50
+ [[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
51
+
52
+