@payloadcms/db-mongodb 3.0.0-canary.03427d3 → 3.0.0-canary.0374de4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +13 -4
  3. package/dist/connect.js.map +1 -1
  4. package/dist/count.d.ts.map +1 -1
  5. package/dist/count.js +1 -1
  6. package/dist/count.js.map +1 -1
  7. package/dist/create.d.ts.map +1 -1
  8. package/dist/create.js +14 -4
  9. package/dist/create.js.map +1 -1
  10. package/dist/createGlobal.d.ts.map +1 -1
  11. package/dist/createGlobal.js +11 -6
  12. package/dist/createGlobal.js.map +1 -1
  13. package/dist/createGlobalVersion.d.ts +1 -1
  14. package/dist/createGlobalVersion.d.ts.map +1 -1
  15. package/dist/createGlobalVersion.js +14 -5
  16. package/dist/createGlobalVersion.js.map +1 -1
  17. package/dist/createMigration.d.ts.map +1 -1
  18. package/dist/createMigration.js +1 -1
  19. package/dist/createMigration.js.map +1 -1
  20. package/dist/createVersion.d.ts +1 -1
  21. package/dist/createVersion.d.ts.map +1 -1
  22. package/dist/createVersion.js +15 -6
  23. package/dist/createVersion.js.map +1 -1
  24. package/dist/deleteMany.d.ts.map +1 -1
  25. package/dist/deleteMany.js +1 -1
  26. package/dist/deleteMany.js.map +1 -1
  27. package/dist/deleteOne.d.ts.map +1 -1
  28. package/dist/deleteOne.js +2 -2
  29. package/dist/deleteOne.js.map +1 -1
  30. package/dist/deleteVersions.d.ts.map +1 -1
  31. package/dist/deleteVersions.js +1 -1
  32. package/dist/deleteVersions.js.map +1 -1
  33. package/dist/destroy.js.map +1 -1
  34. package/dist/find.d.ts.map +1 -1
  35. package/dist/find.js +28 -5
  36. package/dist/find.js.map +1 -1
  37. package/dist/findGlobal.d.ts.map +1 -1
  38. package/dist/findGlobal.js +2 -2
  39. package/dist/findGlobal.js.map +1 -1
  40. package/dist/findGlobalVersions.d.ts.map +1 -1
  41. package/dist/findGlobalVersions.js +11 -5
  42. package/dist/findGlobalVersions.js.map +1 -1
  43. package/dist/findOne.d.ts.map +1 -1
  44. package/dist/findOne.js +20 -4
  45. package/dist/findOne.js.map +1 -1
  46. package/dist/findVersions.d.ts.map +1 -1
  47. package/dist/findVersions.js +9 -3
  48. package/dist/findVersions.js.map +1 -1
  49. package/dist/index.d.ts +48 -34
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +7 -3
  52. package/dist/index.js.map +1 -1
  53. package/dist/init.d.ts.map +1 -1
  54. package/dist/init.js +10 -7
  55. package/dist/init.js.map +1 -1
  56. package/dist/migrateFresh.js.map +1 -1
  57. package/dist/models/buildCollectionSchema.d.ts +1 -27
  58. package/dist/models/buildCollectionSchema.d.ts.map +1 -1
  59. package/dist/models/buildCollectionSchema.js +16 -4
  60. package/dist/models/buildCollectionSchema.js.map +1 -1
  61. package/dist/models/buildGlobalModel.js +2 -2
  62. package/dist/models/buildGlobalModel.js.map +1 -1
  63. package/dist/models/buildSchema.d.ts +1 -27
  64. package/dist/models/buildSchema.d.ts.map +1 -1
  65. package/dist/models/buildSchema.js +96 -21
  66. package/dist/models/buildSchema.js.map +1 -1
  67. package/dist/predefinedMigrations/versions-v1-v2.js.map +1 -1
  68. package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
  69. package/dist/queries/buildAndOrConditions.js +0 -2
  70. package/dist/queries/buildAndOrConditions.js.map +1 -1
  71. package/dist/queries/buildQuery.d.ts +2 -2
  72. package/dist/queries/buildQuery.d.ts.map +1 -1
  73. package/dist/queries/buildQuery.js +1 -2
  74. package/dist/queries/buildQuery.js.map +1 -1
  75. package/dist/queries/buildSearchParams.d.ts.map +1 -1
  76. package/dist/queries/buildSearchParams.js +19 -11
  77. package/dist/queries/buildSearchParams.js.map +1 -1
  78. package/dist/queries/buildSortParam.d.ts +1 -26
  79. package/dist/queries/buildSortParam.d.ts.map +1 -1
  80. package/dist/queries/buildSortParam.js.map +1 -1
  81. package/dist/queries/getLocalizedSortProperty.js.map +1 -1
  82. package/dist/queries/getLocalizedSortProperty.spec.js +43 -43
  83. package/dist/queries/getLocalizedSortProperty.spec.js.map +1 -1
  84. package/dist/queries/mock.js.map +1 -1
  85. package/dist/queries/operatorMap.js.map +1 -1
  86. package/dist/queries/parseParams.d.ts.map +1 -1
  87. package/dist/queries/parseParams.js +5 -6
  88. package/dist/queries/parseParams.js.map +1 -1
  89. package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
  90. package/dist/queries/sanitizeQueryValue.js +83 -24
  91. package/dist/queries/sanitizeQueryValue.js.map +1 -1
  92. package/dist/queryDrafts.d.ts.map +1 -1
  93. package/dist/queryDrafts.js +9 -3
  94. package/dist/queryDrafts.js.map +1 -1
  95. package/dist/testCredentials.js.map +1 -1
  96. package/dist/transactions/beginTransaction.d.ts.map +1 -1
  97. package/dist/transactions/beginTransaction.js +2 -0
  98. package/dist/transactions/beginTransaction.js.map +1 -1
  99. package/dist/transactions/commitTransaction.d.ts.map +1 -1
  100. package/dist/transactions/commitTransaction.js +3 -0
  101. package/dist/transactions/commitTransaction.js.map +1 -1
  102. package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
  103. package/dist/transactions/rollbackTransaction.js +13 -7
  104. package/dist/transactions/rollbackTransaction.js.map +1 -1
  105. package/dist/types.d.ts +5 -29
  106. package/dist/types.d.ts.map +1 -1
  107. package/dist/types.js.map +1 -1
  108. package/dist/updateGlobal.d.ts.map +1 -1
  109. package/dist/updateGlobal.js +9 -3
  110. package/dist/updateGlobal.js.map +1 -1
  111. package/dist/updateGlobalVersion.d.ts +2 -2
  112. package/dist/updateGlobalVersion.d.ts.map +1 -1
  113. package/dist/updateGlobalVersion.js +11 -4
  114. package/dist/updateGlobalVersion.js.map +1 -1
  115. package/dist/updateOne.d.ts.map +1 -1
  116. package/dist/updateOne.js +15 -5
  117. package/dist/updateOne.js.map +1 -1
  118. package/dist/updateVersion.d.ts +1 -1
  119. package/dist/updateVersion.d.ts.map +1 -1
  120. package/dist/updateVersion.js +9 -2
  121. package/dist/updateVersion.js.map +1 -1
  122. package/dist/utilities/buildJoinAggregation.d.ts +15 -0
  123. package/dist/utilities/buildJoinAggregation.d.ts.map +1 -0
  124. package/dist/utilities/buildJoinAggregation.js +148 -0
  125. package/dist/utilities/buildJoinAggregation.js.map +1 -0
  126. package/dist/utilities/getDBName.d.ts.map +1 -1
  127. package/dist/utilities/getDBName.js +3 -1
  128. package/dist/utilities/getDBName.js.map +1 -1
  129. package/dist/utilities/handleError.d.ts +6 -2
  130. package/dist/utilities/handleError.d.ts.map +1 -1
  131. package/dist/utilities/handleError.js +11 -8
  132. package/dist/utilities/handleError.js.map +1 -1
  133. package/dist/utilities/sanitizeInternalFields.d.ts +1 -2
  134. package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
  135. package/dist/utilities/sanitizeInternalFields.js +1 -2
  136. package/dist/utilities/sanitizeInternalFields.js.map +1 -1
  137. package/dist/utilities/sanitizeRelationshipIDs.d.ts +9 -0
  138. package/dist/utilities/sanitizeRelationshipIDs.d.ts.map +1 -0
  139. package/dist/utilities/sanitizeRelationshipIDs.js +111 -0
  140. package/dist/utilities/sanitizeRelationshipIDs.js.map +1 -0
  141. package/dist/withSession.d.ts +3 -27
  142. package/dist/withSession.d.ts.map +1 -1
  143. package/dist/withSession.js +10 -4
  144. package/dist/withSession.js.map +1 -1
  145. package/package.json +11 -9
@@ -1,35 +1,11 @@
1
- /// <reference types="mongoose/types/aggregate.js" />
2
- /// <reference types="mongoose/types/callback.js" />
3
- /// <reference types="mongoose/types/collection.js" />
4
- /// <reference types="mongoose/types/connection.js" />
5
- /// <reference types="mongoose/types/cursor.js" />
6
- /// <reference types="mongoose/types/document.js" />
7
- /// <reference types="mongoose/types/error.js" />
8
- /// <reference types="mongoose/types/expressions.js" />
9
- /// <reference types="mongoose/types/helpers.js" />
10
- /// <reference types="mongoose/types/middlewares.js" />
11
- /// <reference types="mongoose/types/indexes.js" />
12
- /// <reference types="mongoose/types/models.js" />
13
- /// <reference types="mongoose/types/mongooseoptions.js" />
14
- /// <reference types="mongoose/types/pipelinestage.js" />
15
- /// <reference types="mongoose/types/populate.js" />
16
- /// <reference types="mongoose/types/query.js" />
17
- /// <reference types="mongoose/types/schemaoptions.js" />
18
- /// <reference types="mongoose/types/schematypes.js" />
19
- /// <reference types="mongoose/types/session.js" />
20
- /// <reference types="mongoose/types/types.js" />
21
- /// <reference types="mongoose/types/utility.js" />
22
- /// <reference types="mongoose/types/validation.js" />
23
- /// <reference types="mongoose/types/virtuals.js" />
24
- /// <reference types="mongoose/types/inferschematype.js" />
25
- /// <reference types="mongoose-paginate-v2" />
26
1
  import type { ClientSession } from 'mongoose';
2
+ import type { PayloadRequest } from 'payload';
27
3
  import type { MongooseAdapter } from './index.js';
28
4
  /**
29
5
  * returns the session belonging to the transaction of the req.session if exists
30
6
  * @returns ClientSession
31
7
  */
32
- export declare function withSession(db: MongooseAdapter, transactionID?: number | string): {
8
+ export declare function withSession(db: MongooseAdapter, req: PayloadRequest): Promise<{
33
9
  session: ClientSession;
34
- } | object;
10
+ } | Record<string, never>>;
35
11
  //# sourceMappingURL=withSession.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withSession.d.ts","sourceRoot":"","sources":["../src/withSession.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;GAGG;AACH,wBAAgB,WAAW,CACzB,EAAE,EAAE,eAAe,EACnB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,GAC9B;IAAE,OAAO,EAAE,aAAa,CAAA;CAAE,GAAG,MAAM,CAErC"}
1
+ {"version":3,"file":"withSession.d.ts","sourceRoot":"","sources":["../src/withSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,EAAE,EAAE,eAAe,EACnB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC;IAAE,OAAO,EAAE,aAAa,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAU7D"}
@@ -1,10 +1,16 @@
1
1
  /**
2
2
  * returns the session belonging to the transaction of the req.session if exists
3
3
  * @returns ClientSession
4
- */ export function withSession(db, transactionID) {
5
- return db.sessions[transactionID] ? {
6
- session: db.sessions[transactionID]
7
- } : {};
4
+ */ export async function withSession(db, req) {
5
+ let transactionID = req.transactionID;
6
+ if (transactionID instanceof Promise) {
7
+ transactionID = await req.transactionID;
8
+ }
9
+ if (req) {
10
+ return db.sessions[transactionID] ? {
11
+ session: db.sessions[transactionID]
12
+ } : {};
13
+ }
8
14
  }
9
15
 
10
16
  //# sourceMappingURL=withSession.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/withSession.ts"],"sourcesContent":["import type { ClientSession } from 'mongoose'\n\nimport type { MongooseAdapter } from './index.js'\n\n/**\n * returns the session belonging to the transaction of the req.session if exists\n * @returns ClientSession\n */\nexport function withSession(\n db: MongooseAdapter,\n transactionID?: number | string,\n): { session: ClientSession } | object {\n return db.sessions[transactionID] ? { session: db.sessions[transactionID] } : {}\n}\n"],"names":["withSession","db","transactionID","sessions","session"],"rangeMappings":";;;;;;;","mappings":"AAIA;;;CAGC,GACD,OAAO,SAASA,YACdC,EAAmB,EACnBC,aAA+B;IAE/B,OAAOD,GAAGE,QAAQ,CAACD,cAAc,GAAG;QAAEE,SAASH,GAAGE,QAAQ,CAACD,cAAc;IAAC,IAAI,CAAC;AACjF"}
1
+ {"version":3,"sources":["../src/withSession.ts"],"sourcesContent":["import type { ClientSession } from 'mongoose'\nimport type { PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\n/**\n * returns the session belonging to the transaction of the req.session if exists\n * @returns ClientSession\n */\nexport async function withSession(\n db: MongooseAdapter,\n req: PayloadRequest,\n): Promise<{ session: ClientSession } | Record<string, never>> {\n let transactionID = req.transactionID\n\n if (transactionID instanceof Promise) {\n transactionID = await req.transactionID\n }\n\n if (req) {\n return db.sessions[transactionID] ? { session: db.sessions[transactionID] } : {}\n }\n}\n"],"names":["withSession","db","req","transactionID","Promise","sessions","session"],"mappings":"AAKA;;;CAGC,GACD,OAAO,eAAeA,YACpBC,EAAmB,EACnBC,GAAmB;IAEnB,IAAIC,gBAAgBD,IAAIC,aAAa;IAErC,IAAIA,yBAAyBC,SAAS;QACpCD,gBAAgB,MAAMD,IAAIC,aAAa;IACzC;IAEA,IAAID,KAAK;QACP,OAAOD,GAAGI,QAAQ,CAACF,cAAc,GAAG;YAAEG,SAASL,GAAGI,QAAQ,CAACF,cAAc;QAAC,IAAI,CAAC;IACjF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-mongodb",
3
- "version": "3.0.0-canary.03427d3",
3
+ "version": "3.0.0-canary.0374de4",
4
4
  "description": "The officially supported MongoDB database adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -14,8 +14,8 @@
14
14
  "exports": {
15
15
  ".": {
16
16
  "import": "./dist/index.js",
17
- "require": "./dist/index.js",
18
- "types": "./dist/index.d.ts"
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
19
  }
20
20
  },
21
21
  "main": "./dist/index.js",
@@ -27,27 +27,29 @@
27
27
  ],
28
28
  "dependencies": {
29
29
  "bson-objectid": "2.0.4",
30
- "deepmerge": "4.3.1",
31
30
  "http-status": "1.6.2",
32
31
  "mongoose": "6.12.3",
32
+ "mongoose-aggregate-paginate-v2": "1.0.6",
33
33
  "mongoose-paginate-v2": "1.7.22",
34
34
  "prompts": "2.4.2",
35
35
  "uuid": "10.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@types/mongoose-aggregate-paginate-v2": "1.0.9",
38
+ "@types/mongoose-aggregate-paginate-v2": "1.0.6",
39
39
  "mongodb": "4.17.1",
40
40
  "mongodb-memory-server": "^9",
41
- "@payloadcms/eslint-config": "1.1.1",
42
- "payload": "3.0.0-canary.03427d3"
41
+ "@payloadcms/eslint-config": "3.0.0-beta.97",
42
+ "payload": "3.0.0-canary.0374de4"
43
43
  },
44
44
  "peerDependencies": {
45
- "payload": "3.0.0-canary.03427d3"
45
+ "payload": "3.0.0-canary.0374de4"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "pnpm build:types && pnpm build:swc",
49
49
  "build:swc": "swc ./src -d ./dist --config-file .swcrc-build --strip-leading-paths",
50
50
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
51
- "clean": "rimraf {dist,*.tsbuildinfo}"
51
+ "clean": "rimraf {dist,*.tsbuildinfo}",
52
+ "lint": "eslint .",
53
+ "lint:fix": "eslint . --fix"
52
54
  }
53
55
  }