@sfxcode/nuxt-mongocamp-server 1.10.0 → 2.1.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 (107) hide show
  1. package/README.md +22 -5
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +3 -2
  4. package/dist/runtime/api/apis/AdminApi.d.ts +9 -9
  5. package/dist/runtime/api/apis/AdminApi.js +6 -6
  6. package/dist/runtime/api/apis/ApplicationApi.d.ts +6 -6
  7. package/dist/runtime/api/apis/ApplicationApi.js +4 -4
  8. package/dist/runtime/api/apis/AuthApi.d.ts +7 -7
  9. package/dist/runtime/api/apis/AuthApi.js +6 -6
  10. package/dist/runtime/api/apis/BucketApi.d.ts +7 -7
  11. package/dist/runtime/api/apis/BucketApi.js +6 -6
  12. package/dist/runtime/api/apis/CollectionApi.d.ts +69 -28
  13. package/dist/runtime/api/apis/CollectionApi.js +46 -21
  14. package/dist/runtime/api/apis/DatabaseApi.d.ts +5 -5
  15. package/dist/runtime/api/apis/DatabaseApi.js +4 -4
  16. package/dist/runtime/api/apis/DocumentApi.d.ts +141 -24
  17. package/dist/runtime/api/apis/DocumentApi.js +85 -12
  18. package/dist/runtime/api/apis/FileApi.d.ts +38 -6
  19. package/dist/runtime/api/apis/FileApi.js +24 -4
  20. package/dist/runtime/api/apis/IndexApi.d.ts +6 -6
  21. package/dist/runtime/api/apis/IndexApi.js +4 -4
  22. package/dist/runtime/api/apis/JobsApi.d.ts +5 -5
  23. package/dist/runtime/api/apis/JobsApi.js +4 -4
  24. package/dist/runtime/api/apis/SystemApi.d.ts +1 -1
  25. package/dist/runtime/api/docs/AdminApi.md +7 -7
  26. package/dist/runtime/api/docs/ApplicationApi.md +4 -4
  27. package/dist/runtime/api/docs/AuthApi.md +3 -3
  28. package/dist/runtime/api/docs/BucketApi.md +3 -3
  29. package/dist/runtime/api/docs/CollectionApi.md +48 -36
  30. package/dist/runtime/api/docs/DatabaseApi.md +2 -2
  31. package/dist/runtime/api/docs/DocumentApi.md +64 -28
  32. package/dist/runtime/api/docs/FileApi.md +20 -8
  33. package/dist/runtime/api/docs/IndexApi.md +4 -4
  34. package/dist/runtime/api/docs/JobsApi.md +2 -2
  35. package/dist/runtime/api/models/BucketInformation.d.ts +1 -1
  36. package/dist/runtime/api/models/Capabilities.d.ts +1 -1
  37. package/dist/runtime/api/models/CapabilityLimits.d.ts +1 -1
  38. package/dist/runtime/api/models/ClusterInformation.d.ts +1 -1
  39. package/dist/runtime/api/models/ClusterMemberInformation.d.ts +7 -4
  40. package/dist/runtime/api/models/CollectionCollation.d.ts +1 -1
  41. package/dist/runtime/api/models/CollectionOptions.d.ts +1 -1
  42. package/dist/runtime/api/models/CollectionPermission.d.ts +1 -1
  43. package/dist/runtime/api/models/CollectionStatus.d.ts +1 -1
  44. package/dist/runtime/api/models/CollectionSummary.d.ts +1 -1
  45. package/dist/runtime/api/models/ConnectionStats.d.ts +1 -1
  46. package/dist/runtime/api/models/CopyRequest.d.ts +1 -1
  47. package/dist/runtime/api/models/CopyResponse.d.ts +1 -1
  48. package/dist/runtime/api/models/CountResponse.d.ts +1 -1
  49. package/dist/runtime/api/models/CreateCollectionResponse.d.ts +1 -1
  50. package/dist/runtime/api/models/DatabaseInfo.d.ts +1 -1
  51. package/dist/runtime/api/models/DeleteResponse.d.ts +1 -1
  52. package/dist/runtime/api/models/ErrorDescription.d.ts +1 -1
  53. package/dist/runtime/api/models/FieldInfo.d.ts +1 -1
  54. package/dist/runtime/api/models/FieldTypeCount.d.ts +1 -1
  55. package/dist/runtime/api/models/FileInformation.d.ts +1 -1
  56. package/dist/runtime/api/models/Grant.d.ts +1 -1
  57. package/dist/runtime/api/models/ImportResponse.d.ts +1 -1
  58. package/dist/runtime/api/models/IndexCreateRequest.d.ts +1 -1
  59. package/dist/runtime/api/models/IndexCreateResponse.d.ts +1 -1
  60. package/dist/runtime/api/models/IndexDropResponse.d.ts +1 -1
  61. package/dist/runtime/api/models/IndexInfo.d.ts +1 -1
  62. package/dist/runtime/api/models/IndexKey.d.ts +1 -1
  63. package/dist/runtime/api/models/IndexOptionsRequest.d.ts +3 -2
  64. package/dist/runtime/api/models/IndexUsage.d.ts +1 -1
  65. package/dist/runtime/api/models/InsertError.d.ts +1 -1
  66. package/dist/runtime/api/models/InsertResponse.d.ts +1 -1
  67. package/dist/runtime/api/models/JobConfig.d.ts +1 -1
  68. package/dist/runtime/api/models/JobInformation.d.ts +1 -1
  69. package/dist/runtime/api/models/JsonSchema.d.ts +1 -1
  70. package/dist/runtime/api/models/JsonSchemaDefinition.d.ts +1 -1
  71. package/dist/runtime/api/models/JsonValueAny.d.ts +1 -1
  72. package/dist/runtime/api/models/JsonValueBoolean.d.ts +1 -1
  73. package/dist/runtime/api/models/JsonValueString.d.ts +1 -1
  74. package/dist/runtime/api/models/Login.d.ts +1 -1
  75. package/dist/runtime/api/models/LoginResult.d.ts +1 -1
  76. package/dist/runtime/api/models/MongoAggregateRequest.d.ts +1 -1
  77. package/dist/runtime/api/models/MongoCampConfiguration.d.ts +1 -1
  78. package/dist/runtime/api/models/MongoFindRequest.d.ts +1 -1
  79. package/dist/runtime/api/models/MongoIndex.d.ts +1 -1
  80. package/dist/runtime/api/models/OpCounters.d.ts +1 -1
  81. package/dist/runtime/api/models/PasswordUpdateRequest.d.ts +1 -1
  82. package/dist/runtime/api/models/PipelineStage.d.ts +1 -1
  83. package/dist/runtime/api/models/RenameRequest.d.ts +1 -1
  84. package/dist/runtime/api/models/RenameResponse.d.ts +1 -1
  85. package/dist/runtime/api/models/ReplicaSetState.d.ts +1 -1
  86. package/dist/runtime/api/models/Role.d.ts +1 -1
  87. package/dist/runtime/api/models/SchemaAnalysis.d.ts +1 -1
  88. package/dist/runtime/api/models/SchemaAnalysisField.d.ts +1 -1
  89. package/dist/runtime/api/models/SchemaAnalysisFieldType.d.ts +1 -1
  90. package/dist/runtime/api/models/SearchRequest.d.ts +1 -1
  91. package/dist/runtime/api/models/SettingsResponse.d.ts +5 -3
  92. package/dist/runtime/api/models/SystemInfo.d.ts +1 -1
  93. package/dist/runtime/api/models/SystemStats.d.ts +1 -1
  94. package/dist/runtime/api/models/UpdateFileInformationRequest.d.ts +1 -1
  95. package/dist/runtime/api/models/UpdateRequest.d.ts +1 -1
  96. package/dist/runtime/api/models/UpdateResponse.d.ts +1 -1
  97. package/dist/runtime/api/models/UpdateRoleRequest.d.ts +1 -1
  98. package/dist/runtime/api/models/UserInformation.d.ts +1 -1
  99. package/dist/runtime/api/models/UserProfile.d.ts +1 -1
  100. package/dist/runtime/api/models/Version.d.ts +1 -1
  101. package/dist/runtime/api/runtime.d.ts +1 -1
  102. package/dist/runtime/composables/mongocampSearch.d.ts +3 -1
  103. package/dist/runtime/composables/mongocampSearch.js +3 -3
  104. package/dist/runtime/server/mongocamp/handler.js +9 -1
  105. package/dist/runtime/utils/extendedJson.d.ts +12 -0
  106. package/dist/runtime/utils/extendedJson.js +60 -0
  107. package/package.json +9 -3
@@ -11,8 +11,8 @@ export function useMongocampSearch() {
11
11
  const findRequest = (collection, searchParameter = mongoFindRequest(), rows = config.public.mongocamp?.paginationSize, actualPage = 1) => {
12
12
  return { collectionName: collection, mongoFindRequest: searchParameter, rowsPerPage: rows, page: actualPage };
13
13
  };
14
- function find(collectionName, filter, page = 1, sort = void 0, projection = void 0, rowsPerPage = config.public.mongocamp?.paginationSize) {
15
- return documentApi.listDocuments({ collectionName, filter, sort, projection, page, rowsPerPage });
14
+ function find(collectionName, filter, page = 1, sort = void 0, projection = void 0, rowsPerPage = config.public.mongocamp?.paginationSize, filterCaseInsensitive) {
15
+ return documentApi.listDocuments({ collectionName, filter, sort, projection, page, rowsPerPage, filterCaseInsensitive });
16
16
  }
17
17
  function findAll(collectionName, page = 1, sort = void 0, projection = void 0, rowsPerPage = config.public.mongocamp?.paginationSize) {
18
18
  return find(collectionName, void 0, page, sort, projection, rowsPerPage);
@@ -35,7 +35,7 @@ export function usePaginatedFind(collectionName, options = {}) {
35
35
  pending.value = true;
36
36
  error.value = null;
37
37
  try {
38
- documents.value = await find(collectionName, options.filter, page.value, options.sort, options.projection, rowsPerPage.value);
38
+ documents.value = await find(collectionName, options.filter, page.value, options.sort, options.projection, rowsPerPage.value, options.filterCaseInsensitive);
39
39
  } catch (e) {
40
40
  error.value = e;
41
41
  } finally {
@@ -1,8 +1,16 @@
1
1
  import { defineHandler } from "nitro";
2
2
  import { useRuntimeConfig } from "nitro/runtime-config";
3
3
  import { toCoreRequest, useMongocampCore } from "./core.js";
4
+ function fetchOptionsOf(request) {
5
+ const log = request.context?.log;
6
+ if (!log || typeof log.set !== "function") {
7
+ return void 0;
8
+ }
9
+ const requestId = log.getContext?.().requestId;
10
+ return { log, requestId: typeof requestId === "string" ? requestId : void 0 };
11
+ }
4
12
  export default defineHandler(async (event) => {
5
13
  const settings = useRuntimeConfig().mongocampServer;
6
14
  const core = await useMongocampCore(settings);
7
- return core.fetch(toCoreRequest(event.req, settings.prefix));
15
+ return core.fetch(toCoreRequest(event.req, settings.prefix), fetchOptionsOf(event.req));
8
16
  });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A document of the server with typed values: `ObjectId`, `Date`, `Decimal128`, `Binary`, `BSONRegExp`, ...; numbers stay numbers, an
3
+ * integer beyond 2^53 is a `bigint`.
4
+ */
5
+ export declare function fromExtendedJson<T = Record<string, unknown>>(document: unknown): T;
6
+ /**
7
+ * A document with typed values (as `fromExtendedJson` gives it) for a request body: relaxed Extended JSON, a text that looks like a date
8
+ * keeps the marker so that the server stores a text, an integer beyond 2^53 (`bigint`, `Long`) is `{"$numberLong": ...}`.
9
+ */
10
+ export declare function toExtendedJson(document: unknown): Record<string, unknown>;
11
+ /** The id of a document (or the id itself) as text: the hex string of an ObjectId, the value of any other id. */
12
+ export declare function documentId(documentOrId: unknown): string;
@@ -0,0 +1,60 @@
1
+ import { EJSON, Long, ObjectId } from "bson";
2
+ const TextMarker = "$string";
3
+ const isoInstant = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;
4
+ function isPlainObject(value) {
5
+ return value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype;
6
+ }
7
+ function unwrapTexts(value) {
8
+ if (Array.isArray(value)) {
9
+ return value.map(unwrapTexts);
10
+ }
11
+ if (isPlainObject(value)) {
12
+ const keys = Object.keys(value);
13
+ if (keys.length === 1 && keys[0] === TextMarker && typeof value[TextMarker] === "string") {
14
+ return value[TextMarker];
15
+ }
16
+ return Object.fromEntries(keys.map((key) => [key, unwrapTexts(value[key])]));
17
+ }
18
+ return value;
19
+ }
20
+ const maxSafe = BigInt(Number.MAX_SAFE_INTEGER);
21
+ function exactInteger(value) {
22
+ return value > maxSafe || value < -maxSafe ? { $numberLong: value.toString() } : Number(value);
23
+ }
24
+ function markTexts(value) {
25
+ if (typeof value === "string") {
26
+ return isoInstant.test(value) ? { [TextMarker]: value } : value;
27
+ }
28
+ if (typeof value === "bigint") {
29
+ return exactInteger(value);
30
+ }
31
+ if (value instanceof Long) {
32
+ return exactInteger(value.toBigInt());
33
+ }
34
+ if (Array.isArray(value)) {
35
+ return value.map(markTexts);
36
+ }
37
+ if (isPlainObject(value)) {
38
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, markTexts(entry)]));
39
+ }
40
+ return value;
41
+ }
42
+ export function fromExtendedJson(document) {
43
+ return EJSON.deserialize(unwrapTexts(document), { relaxed: true, useBigInt64: true });
44
+ }
45
+ export function toExtendedJson(document) {
46
+ return EJSON.serialize(markTexts(document), { relaxed: true });
47
+ }
48
+ export function documentId(documentOrId) {
49
+ const id = isPlainObject(documentOrId) && "_id" in documentOrId ? documentOrId._id : documentOrId;
50
+ if (id instanceof ObjectId) {
51
+ return id.toHexString();
52
+ }
53
+ if (isPlainObject(id)) {
54
+ const [key, value] = Object.entries(id)[0] ?? [];
55
+ if ((key === "$oid" || key === "$numberLong" || key === TextMarker) && typeof value === "string") {
56
+ return value;
57
+ }
58
+ }
59
+ return String(id);
60
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-mongocamp-server",
3
- "version": "1.10.0",
3
+ "version": "2.1.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -29,8 +29,9 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@nuxt/kit": "^4.7.0",
32
- "@sfxcode/mongocamp-server-core": "1.10.0",
32
+ "@sfxcode/mongocamp-server-core": "2.1.0",
33
33
  "@vueuse/nuxt": "^15.1.0",
34
+ "bson": "^7.3.4",
34
35
  "consola": "^3.4.2",
35
36
  "defu": "^6.1.7"
36
37
  },
@@ -45,6 +46,7 @@
45
46
  "@unocss/nuxt": "^66.13.0",
46
47
  "changelogen": "^0.6.2",
47
48
  "eslint": "^10.16.0",
49
+ "evlog": "2.37.1",
48
50
  "h3": "2.0.8",
49
51
  "mongodb": "7.9.1",
50
52
  "nitro": "3.0.261103-rc",
@@ -62,6 +64,7 @@
62
64
  "dev:build": "nuxi build playground",
63
65
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
64
66
  "release": "npm run lint && npm run test && npm run prepack && changelogen --minor --release --no-commit --no-tag && node scripts/sync-versions.mjs --commit && pnpm -r --include-workspace-root --filter @sfxcode/mongocamp-server-core --filter @sfxcode/nuxt-mongocamp-server publish --access public && git push --follow-tags",
67
+ "release:next": "npm run lint && npm run test && npm run prepack && changelogen --prerelease=alpha --release --no-commit --no-tag && node scripts/sync-versions.mjs --commit && pnpm -r --include-workspace-root --filter @sfxcode/mongocamp-server-core --filter @sfxcode/nuxt-mongocamp-server publish --access public --tag next && git push --follow-tags",
65
68
  "lint": "eslint .",
66
69
  "lint:fix": "eslint --fix .",
67
70
  "test": "vitest run",
@@ -72,6 +75,9 @@
72
75
  "api-codegen": "openapi-generator-cli generate -i ./openapi/docs.yaml -g typescript-fetch -o src/runtime/api --additional-properties=typescriptThreePlus=true,supportsES6=true",
73
76
  "test:contract": "vitest run --config vitest.contract.config.ts",
74
77
  "typecheck:server": "pnpm --filter @sfxcode/mongocamp-server-core typecheck",
75
- "sync-versions": "node scripts/sync-versions.mjs"
78
+ "sync-versions": "node scripts/sync-versions.mjs",
79
+ "docs:dev": "pnpm --filter mongocamp-docs dev",
80
+ "docs:build": "pnpm --filter mongocamp-docs build",
81
+ "docs:preview": "pnpm --filter mongocamp-docs preview"
76
82
  }
77
83
  }