@payloadcms/db-mongodb 3.0.0-canary.ee6d727 → 3.0.0-canary.ef0a8d0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/README.md +1 -1
  2. package/dist/connect.d.ts +1 -1
  3. package/dist/connect.d.ts.map +1 -1
  4. package/dist/connect.js +1 -1
  5. package/dist/connect.js.map +1 -1
  6. package/dist/count.d.ts +1 -1
  7. package/dist/count.d.ts.map +1 -1
  8. package/dist/count.js +2 -2
  9. package/dist/count.js.map +1 -1
  10. package/dist/create.d.ts +1 -1
  11. package/dist/create.d.ts.map +1 -1
  12. package/dist/create.js +7 -3
  13. package/dist/create.js.map +1 -1
  14. package/dist/createGlobal.d.ts +1 -1
  15. package/dist/createGlobal.d.ts.map +1 -1
  16. package/dist/createGlobal.js +1 -1
  17. package/dist/createGlobal.js.map +1 -1
  18. package/dist/createGlobalVersion.d.ts +1 -1
  19. package/dist/createGlobalVersion.d.ts.map +1 -1
  20. package/dist/createGlobalVersion.js +1 -1
  21. package/dist/createGlobalVersion.js.map +1 -1
  22. package/dist/createMigration.d.ts +1 -1
  23. package/dist/createMigration.d.ts.map +1 -1
  24. package/dist/createMigration.js +2 -2
  25. package/dist/createMigration.js.map +1 -1
  26. package/dist/createVersion.d.ts +1 -1
  27. package/dist/createVersion.d.ts.map +1 -1
  28. package/dist/createVersion.js +1 -1
  29. package/dist/createVersion.js.map +1 -1
  30. package/dist/deleteMany.d.ts +1 -1
  31. package/dist/deleteMany.d.ts.map +1 -1
  32. package/dist/deleteMany.js +1 -1
  33. package/dist/deleteMany.js.map +1 -1
  34. package/dist/deleteOne.d.ts +1 -1
  35. package/dist/deleteOne.d.ts.map +1 -1
  36. package/dist/deleteOne.js +1 -1
  37. package/dist/deleteOne.js.map +1 -1
  38. package/dist/deleteVersions.d.ts +1 -1
  39. package/dist/deleteVersions.d.ts.map +1 -1
  40. package/dist/deleteVersions.js +1 -1
  41. package/dist/deleteVersions.js.map +1 -1
  42. package/dist/destroy.d.ts +1 -1
  43. package/dist/destroy.d.ts.map +1 -1
  44. package/dist/destroy.js.map +1 -1
  45. package/dist/find.d.ts +1 -1
  46. package/dist/find.d.ts.map +1 -1
  47. package/dist/find.js +2 -3
  48. package/dist/find.js.map +1 -1
  49. package/dist/findGlobal.d.ts +1 -1
  50. package/dist/findGlobal.d.ts.map +1 -1
  51. package/dist/findGlobal.js +2 -2
  52. package/dist/findGlobal.js.map +1 -1
  53. package/dist/findGlobalVersions.d.ts +1 -1
  54. package/dist/findGlobalVersions.d.ts.map +1 -1
  55. package/dist/findGlobalVersions.js +2 -4
  56. package/dist/findGlobalVersions.js.map +1 -1
  57. package/dist/findOne.d.ts +1 -1
  58. package/dist/findOne.d.ts.map +1 -1
  59. package/dist/findOne.js +1 -1
  60. package/dist/findOne.js.map +1 -1
  61. package/dist/findVersions.d.ts +1 -1
  62. package/dist/findVersions.d.ts.map +1 -1
  63. package/dist/findVersions.js +2 -3
  64. package/dist/findVersions.js.map +1 -1
  65. package/dist/index.d.ts +5 -30
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +1 -1
  68. package/dist/index.js.map +1 -1
  69. package/dist/init.d.ts +1 -1
  70. package/dist/init.d.ts.map +1 -1
  71. package/dist/init.js +2 -2
  72. package/dist/init.js.map +1 -1
  73. package/dist/migrateFresh.d.ts.map +1 -1
  74. package/dist/migrateFresh.js +1 -1
  75. package/dist/migrateFresh.js.map +1 -1
  76. package/dist/models/buildCollectionSchema.d.ts +1 -27
  77. package/dist/models/buildCollectionSchema.d.ts.map +1 -1
  78. package/dist/models/buildCollectionSchema.js.map +1 -1
  79. package/dist/models/buildGlobalModel.d.ts +1 -1
  80. package/dist/models/buildGlobalModel.d.ts.map +1 -1
  81. package/dist/models/buildGlobalModel.js.map +1 -1
  82. package/dist/models/buildSchema.d.ts +1 -27
  83. package/dist/models/buildSchema.d.ts.map +1 -1
  84. package/dist/models/buildSchema.js +2 -4
  85. package/dist/models/buildSchema.js.map +1 -1
  86. package/dist/predefinedMigrations/versions-v1-v2.js.map +1 -1
  87. package/dist/queries/buildAndOrConditions.d.ts +1 -2
  88. package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
  89. package/dist/queries/buildAndOrConditions.js +0 -2
  90. package/dist/queries/buildAndOrConditions.js.map +1 -1
  91. package/dist/queries/buildQuery.d.ts +1 -2
  92. package/dist/queries/buildQuery.d.ts.map +1 -1
  93. package/dist/queries/buildQuery.js +1 -1
  94. package/dist/queries/buildQuery.js.map +1 -1
  95. package/dist/queries/buildSearchParams.d.ts +1 -2
  96. package/dist/queries/buildSearchParams.d.ts.map +1 -1
  97. package/dist/queries/buildSearchParams.js +2 -2
  98. package/dist/queries/buildSearchParams.js.map +1 -1
  99. package/dist/queries/buildSortParam.d.ts +2 -28
  100. package/dist/queries/buildSortParam.d.ts.map +1 -1
  101. package/dist/queries/buildSortParam.js.map +1 -1
  102. package/dist/queries/getLocalizedSortProperty.d.ts +1 -2
  103. package/dist/queries/getLocalizedSortProperty.d.ts.map +1 -1
  104. package/dist/queries/getLocalizedSortProperty.js +2 -2
  105. package/dist/queries/getLocalizedSortProperty.js.map +1 -1
  106. package/dist/queries/getLocalizedSortProperty.spec.js +43 -43
  107. package/dist/queries/getLocalizedSortProperty.spec.js.map +1 -1
  108. package/dist/queries/mock.js.map +1 -1
  109. package/dist/queries/operatorMap.js.map +1 -1
  110. package/dist/queries/parseParams.d.ts +1 -3
  111. package/dist/queries/parseParams.d.ts.map +1 -1
  112. package/dist/queries/parseParams.js +3 -3
  113. package/dist/queries/parseParams.js.map +1 -1
  114. package/dist/queries/sanitizeQueryValue.d.ts +1 -1
  115. package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
  116. package/dist/queries/sanitizeQueryValue.js +1 -1
  117. package/dist/queries/sanitizeQueryValue.js.map +1 -1
  118. package/dist/queryDrafts.d.ts +1 -1
  119. package/dist/queryDrafts.d.ts.map +1 -1
  120. package/dist/queryDrafts.js +2 -3
  121. package/dist/queryDrafts.js.map +1 -1
  122. package/dist/testCredentials.js.map +1 -1
  123. package/dist/transactions/beginTransaction.d.ts +1 -1
  124. package/dist/transactions/beginTransaction.d.ts.map +1 -1
  125. package/dist/transactions/beginTransaction.js +1 -1
  126. package/dist/transactions/beginTransaction.js.map +1 -1
  127. package/dist/transactions/commitTransaction.d.ts +1 -1
  128. package/dist/transactions/commitTransaction.d.ts.map +1 -1
  129. package/dist/transactions/commitTransaction.js +1 -0
  130. package/dist/transactions/commitTransaction.js.map +1 -1
  131. package/dist/transactions/rollbackTransaction.d.ts +1 -1
  132. package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
  133. package/dist/transactions/rollbackTransaction.js +13 -7
  134. package/dist/transactions/rollbackTransaction.js.map +1 -1
  135. package/dist/types.d.ts +1 -28
  136. package/dist/types.d.ts.map +1 -1
  137. package/dist/types.js.map +1 -1
  138. package/dist/updateGlobal.d.ts +1 -1
  139. package/dist/updateGlobal.d.ts.map +1 -1
  140. package/dist/updateGlobal.js +1 -1
  141. package/dist/updateGlobal.js.map +1 -1
  142. package/dist/updateGlobalVersion.d.ts +1 -2
  143. package/dist/updateGlobalVersion.d.ts.map +1 -1
  144. package/dist/updateGlobalVersion.js +1 -1
  145. package/dist/updateGlobalVersion.js.map +1 -1
  146. package/dist/updateOne.d.ts +1 -1
  147. package/dist/updateOne.d.ts.map +1 -1
  148. package/dist/updateOne.js +7 -3
  149. package/dist/updateOne.js.map +1 -1
  150. package/dist/updateVersion.d.ts +1 -1
  151. package/dist/updateVersion.d.ts.map +1 -1
  152. package/dist/updateVersion.js +1 -1
  153. package/dist/updateVersion.js.map +1 -1
  154. package/dist/utilities/getDBName.d.ts +1 -1
  155. package/dist/utilities/getDBName.d.ts.map +1 -1
  156. package/dist/utilities/getDBName.js.map +1 -1
  157. package/dist/utilities/handleError.d.ts +6 -2
  158. package/dist/utilities/handleError.d.ts.map +1 -1
  159. package/dist/utilities/handleError.js +12 -9
  160. package/dist/utilities/handleError.js.map +1 -1
  161. package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
  162. package/dist/utilities/sanitizeInternalFields.js.map +1 -1
  163. package/dist/withSession.d.ts +3 -27
  164. package/dist/withSession.d.ts.map +1 -1
  165. package/dist/withSession.js +6 -2
  166. package/dist/withSession.js.map +1 -1
  167. package/package.json +9 -9
package/dist/types.d.ts CHANGED
@@ -1,32 +1,5 @@
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 { IndexDefinition, IndexOptions, Model, PaginateModel, SchemaOptions } from 'mongoose';
27
- import type { Payload } from 'payload';
28
- import type { SanitizedConfig } from 'payload/config';
29
- import type { ArrayField, BlockField, CheckboxField, CodeField, CollapsibleField, DateField, EmailField, Field, GroupField, JSONField, NumberField, PointField, RadioField, RelationshipField, RichTextField, RowField, SelectField, TabsField, TextField, TextareaField, UploadField } from 'payload/types';
2
+ import type { ArrayField, BlockField, CheckboxField, CodeField, CollapsibleField, DateField, EmailField, Field, GroupField, JSONField, NumberField, Payload, PointField, RadioField, RelationshipField, RichTextField, RowField, SanitizedConfig, SelectField, TabsField, TextField, TextareaField, UploadField } from 'payload';
30
3
  import type { BuildQueryArgs } from './queries/buildQuery.js';
31
4
  export interface CollectionModel extends Model<any>, PaginateModel<any> {
32
5
  /** buildQuery is used to transform payload's where operator into what can be used by mongoose (e.g. id => _id) */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAClG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,KAAK,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,WAAW,EACX,SAAS,EACT,SAAS,EACT,aAAa,EACb,WAAW,EACZ,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAE7D,MAAM,WAAW,eAAgB,SAAQ,KAAK,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC;IACrE,kHAAkH;IAClH,UAAU,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CACvE;AAED,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,uBAAuB,EAAE,IAAI,CAAA;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sB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IAClD,KAAK,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IAClD,IAAI,EAAE,sBAAsB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAChD,MAAM,EAAE,sBAAsB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;IACpD,KAAK,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IAClD,KAAK,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IAClD,YAAY,EAAE,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAA;IAChE,QAAQ,EAAE,sBAAsB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAA;IACxD,GAAG,EAAE,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC9C,MAAM,EAAE,sBAAsB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;IACpD,IAAI,EAAE,sBAAsB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAChD,IAAI,EAAE,sBAAsB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAChD,QAAQ,EAAE,sBAAsB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAA;IACxD,MAAM,EAAE,sBAAsB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;CACrD,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAA;AAChD,MAAM,MAAM,eAAe,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { IndexDefinition, IndexOptions, Model, PaginateModel, SchemaOptions } from 'mongoose'\nimport type { Payload } from 'payload'\nimport type { SanitizedConfig } from 'payload/config'\nimport type {\n ArrayField,\n BlockField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GroupField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SelectField,\n TabsField,\n TextField,\n TextareaField,\n UploadField,\n} from 'payload/types'\n\nimport type { BuildQueryArgs } from './queries/buildQuery.js'\n\nexport interface CollectionModel extends Model<any>, PaginateModel<any> {\n /** buildQuery is used to transform payload's where operator into what can be used by mongoose (e.g. id => _id) */\n buildQuery: (args: BuildQueryArgs) => Promise<Record<string, unknown>> // TODO: Delete this\n}\n\nexport interface AuthCollectionModel extends CollectionModel {\n resetPasswordExpiration: Date\n resetPasswordToken: string\n}\n\nexport type TypeOfIndex = {\n fields: IndexDefinition\n options?: IndexOptions\n}\n\nexport interface GlobalModel extends Model<Document> {\n buildQuery: (query: unknown, locale?: string) => Promise<Record<string, unknown>>\n}\n\nexport type BuildSchema<TSchema> = (args: {\n config: SanitizedConfig\n fields: Field[]\n options: BuildSchemaOptions\n}) => TSchema\n\nexport type BuildSchemaOptions = {\n allowIDField?: boolean\n disableUnique?: boolean\n draftsEnabled?: boolean\n indexSortableFields?: boolean\n options?: SchemaOptions\n}\n\nexport type FieldGenerator<TSchema, TField> = {\n config: SanitizedConfig\n field: TField\n options: BuildSchemaOptions\n schema: TSchema\n}\n\n/**\n * Field config types that need representation in the database\n */\ntype FieldType =\n | 'array'\n | 'blocks'\n | 'checkbox'\n | 'code'\n | 'collapsible'\n | 'date'\n | 'email'\n | 'group'\n | 'json'\n | 'number'\n | 'point'\n | 'radio'\n | 'relationship'\n | 'richText'\n | 'row'\n | 'select'\n | 'tabs'\n | 'text'\n | 'textarea'\n | 'upload'\n\nexport type FieldGeneratorFunction<TSchema, TField extends Field> = (\n args: FieldGenerator<TSchema, TField>,\n) => void\n\n/**\n * Object mapping types to a schema based on TSchema\n */\nexport type FieldToSchemaMap<TSchema> = {\n array: FieldGeneratorFunction<TSchema, ArrayField>\n blocks: FieldGeneratorFunction<TSchema, BlockField>\n checkbox: FieldGeneratorFunction<TSchema, CheckboxField>\n code: FieldGeneratorFunction<TSchema, CodeField>\n collapsible: FieldGeneratorFunction<TSchema, CollapsibleField>\n date: FieldGeneratorFunction<TSchema, DateField>\n email: FieldGeneratorFunction<TSchema, EmailField>\n group: FieldGeneratorFunction<TSchema, GroupField>\n json: FieldGeneratorFunction<TSchema, JSONField>\n number: FieldGeneratorFunction<TSchema, NumberField>\n point: FieldGeneratorFunction<TSchema, PointField>\n radio: FieldGeneratorFunction<TSchema, RadioField>\n relationship: FieldGeneratorFunction<TSchema, RelationshipField>\n richText: FieldGeneratorFunction<TSchema, RichTextField>\n row: FieldGeneratorFunction<TSchema, RowField>\n select: FieldGeneratorFunction<TSchema, SelectField>\n tabs: FieldGeneratorFunction<TSchema, TabsField>\n text: FieldGeneratorFunction<TSchema, TextField>\n textarea: FieldGeneratorFunction<TSchema, TextareaField>\n upload: FieldGeneratorFunction<TSchema, UploadField>\n}\n\nexport type MigrateUpArgs = { payload: Payload }\nexport type MigrateDownArgs = { payload: Payload }\n"],"names":[],"rangeMappings":"","mappings":"AA6HA,WAAkD"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { IndexDefinition, IndexOptions, Model, PaginateModel, SchemaOptions } from 'mongoose'\nimport type {\n ArrayField,\n BlockField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GroupField,\n JSONField,\n NumberField,\n Payload,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedConfig,\n SelectField,\n TabsField,\n TextField,\n TextareaField,\n UploadField,\n} from 'payload'\n\nimport type { BuildQueryArgs } from './queries/buildQuery.js'\n\nexport interface CollectionModel extends Model<any>, PaginateModel<any> {\n /** buildQuery is used to transform payload's where operator into what can be used by mongoose (e.g. id => _id) */\n buildQuery: (args: BuildQueryArgs) => Promise<Record<string, unknown>> // TODO: Delete this\n}\n\nexport interface AuthCollectionModel extends CollectionModel {\n resetPasswordExpiration: Date\n resetPasswordToken: string\n}\n\nexport type TypeOfIndex = {\n fields: IndexDefinition\n options?: IndexOptions\n}\n\nexport interface GlobalModel extends Model<Document> {\n buildQuery: (query: unknown, locale?: string) => Promise<Record<string, unknown>>\n}\n\nexport type BuildSchema<TSchema> = (args: {\n config: SanitizedConfig\n fields: Field[]\n options: BuildSchemaOptions\n}) => TSchema\n\nexport type BuildSchemaOptions = {\n allowIDField?: boolean\n disableUnique?: boolean\n draftsEnabled?: boolean\n indexSortableFields?: boolean\n options?: SchemaOptions\n}\n\nexport type FieldGenerator<TSchema, TField> = {\n config: SanitizedConfig\n field: TField\n options: BuildSchemaOptions\n schema: TSchema\n}\n\n/**\n * Field config types that need representation in the database\n */\ntype FieldType =\n | 'array'\n | 'blocks'\n | 'checkbox'\n | 'code'\n | 'collapsible'\n | 'date'\n | 'email'\n | 'group'\n | 'json'\n | 'number'\n | 'point'\n | 'radio'\n | 'relationship'\n | 'richText'\n | 'row'\n | 'select'\n | 'tabs'\n | 'text'\n | 'textarea'\n | 'upload'\n\nexport type FieldGeneratorFunction<TSchema, TField extends Field> = (\n args: FieldGenerator<TSchema, TField>,\n) => void\n\n/**\n * Object mapping types to a schema based on TSchema\n */\nexport type FieldToSchemaMap<TSchema> = {\n array: FieldGeneratorFunction<TSchema, ArrayField>\n blocks: FieldGeneratorFunction<TSchema, BlockField>\n checkbox: FieldGeneratorFunction<TSchema, CheckboxField>\n code: FieldGeneratorFunction<TSchema, CodeField>\n collapsible: FieldGeneratorFunction<TSchema, CollapsibleField>\n date: FieldGeneratorFunction<TSchema, DateField>\n email: FieldGeneratorFunction<TSchema, EmailField>\n group: FieldGeneratorFunction<TSchema, GroupField>\n json: FieldGeneratorFunction<TSchema, JSONField>\n number: FieldGeneratorFunction<TSchema, NumberField>\n point: FieldGeneratorFunction<TSchema, PointField>\n radio: FieldGeneratorFunction<TSchema, RadioField>\n relationship: FieldGeneratorFunction<TSchema, RelationshipField>\n richText: FieldGeneratorFunction<TSchema, RichTextField>\n row: FieldGeneratorFunction<TSchema, RowField>\n select: FieldGeneratorFunction<TSchema, SelectField>\n tabs: FieldGeneratorFunction<TSchema, TabsField>\n text: FieldGeneratorFunction<TSchema, TextField>\n textarea: FieldGeneratorFunction<TSchema, TextareaField>\n upload: FieldGeneratorFunction<TSchema, UploadField>\n}\n\nexport type MigrateUpArgs = { payload: Payload }\nexport type MigrateDownArgs = { payload: Payload }\n"],"names":[],"mappings":"AA6HA,WAAkD"}
@@ -1,3 +1,3 @@
1
- import type { UpdateGlobal } from 'payload/database';
1
+ import type { UpdateGlobal } from 'payload';
2
2
  export declare const updateGlobal: UpdateGlobal;
3
3
  //# sourceMappingURL=updateGlobal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAQpD,eAAO,MAAM,YAAY,EAAE,YAqB1B,CAAA"}
1
+ {"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,SAAS,CAAA;AAO3D,eAAO,MAAM,YAAY,EAAE,YAqB1B,CAAA"}
@@ -3,7 +3,7 @@ import { withSession } from './withSession.js';
3
3
  export const updateGlobal = async function updateGlobal({ slug, data, req = {} }) {
4
4
  const Model = this.globals;
5
5
  const options = {
6
- ...withSession(this, req.transactionID),
6
+ ...await withSession(this, req),
7
7
  lean: true,
8
8
  new: true
9
9
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { UpdateGlobal } from 'payload/database'\nimport type { PayloadRequestWithData } from 'payload/types'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport sanitizeInternalFields from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const updateGlobal: UpdateGlobal = async function updateGlobal(\n this: MongooseAdapter,\n { slug, data, req = {} as PayloadRequestWithData },\n) {\n const Model = this.globals\n const options = {\n ...withSession(this, req.transactionID),\n lean: true,\n new: true,\n }\n\n let result\n result = await Model.findOneAndUpdate({ globalType: slug }, data, options)\n\n result = JSON.parse(JSON.stringify(result))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["sanitizeInternalFields","withSession","updateGlobal","slug","data","req","Model","globals","options","transactionID","lean","new","result","findOneAndUpdate","globalType","JSON","parse","stringify","id","_id"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAKA,OAAOA,4BAA4B,wCAAuC;AAC1E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EAAEC,IAAI,EAAEC,IAAI,EAAEC,MAAM,CAAC,CAA2B,EAAE;IAElD,MAAMC,QAAQ,IAAI,CAACC,OAAO;IAC1B,MAAMC,UAAU;QACd,GAAGP,YAAY,IAAI,EAAEI,IAAII,aAAa,CAAC;QACvCC,MAAM;QACNC,KAAK;IACP;IAEA,IAAIC;IACJA,SAAS,MAAMN,MAAMO,gBAAgB,CAAC;QAAEC,YAAYX;IAAK,GAAGC,MAAMI;IAElEI,SAASG,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IAEnC,uBAAuB;IACvBA,OAAOM,EAAE,GAAGN,OAAOO,GAAG;IACtBP,SAASZ,uBAAuBY;IAEhC,OAAOA;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { PayloadRequest, UpdateGlobal } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport sanitizeInternalFields from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const updateGlobal: UpdateGlobal = async function updateGlobal(\n this: MongooseAdapter,\n { slug, data, req = {} as PayloadRequest },\n) {\n const Model = this.globals\n const options = {\n ...(await withSession(this, req)),\n lean: true,\n new: true,\n }\n\n let result\n result = await Model.findOneAndUpdate({ globalType: slug }, data, options)\n\n result = JSON.parse(JSON.stringify(result))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["sanitizeInternalFields","withSession","updateGlobal","slug","data","req","Model","globals","options","lean","new","result","findOneAndUpdate","globalType","JSON","parse","stringify","id","_id"],"mappings":"AAIA,OAAOA,4BAA4B,wCAAuC;AAC1E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EAAEC,IAAI,EAAEC,IAAI,EAAEC,MAAM,CAAC,CAAmB,EAAE;IAE1C,MAAMC,QAAQ,IAAI,CAACC,OAAO;IAC1B,MAAMC,UAAU;QACd,GAAI,MAAMP,YAAY,IAAI,EAAEI,IAAI;QAChCI,MAAM;QACNC,KAAK;IACP;IAEA,IAAIC;IACJA,SAAS,MAAML,MAAMM,gBAAgB,CAAC;QAAEC,YAAYV;IAAK,GAAGC,MAAMI;IAElEG,SAASG,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IAEnC,uBAAuB;IACvBA,OAAOM,EAAE,GAAGN,OAAOO,GAAG;IACtBP,SAASX,uBAAuBW;IAEhC,OAAOA;AACT,EAAC"}
@@ -1,5 +1,4 @@
1
- import type { UpdateGlobalVersionArgs } from 'payload/database';
2
- import type { TypeWithID } from 'payload/types';
1
+ import type { TypeWithID, UpdateGlobalVersionArgs } from 'payload';
3
2
  import type { MongooseAdapter } from './index.js';
4
3
  export declare function updateGlobalVersion<T extends TypeWithID>(this: MongooseAdapter, { id, global, locale, req, versionData, where, }: UpdateGlobalVersionArgs<T>): Promise<any>;
5
4
  //# sourceMappingURL=updateGlobalVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"updateGlobalVersion.d.ts","sourceRoot":"","sources":["../src/updateGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,KAAK,EAA0B,UAAU,EAAE,MAAM,eAAe,CAAA;AAEvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,eAAe,EACrB,EACE,EAAE,EACF,MAAM,EACN,MAAM,EACN,GAAkC,EAClC,WAAW,EACX,KAAK,GACN,EAAE,uBAAuB,CAAC,CAAC,CAAC,gBA4B9B"}
1
+ {"version":3,"file":"updateGlobalVersion.d.ts","sourceRoot":"","sources":["../src/updateGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,UAAU,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAElF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,eAAe,EACrB,EACE,EAAE,EACF,MAAM,EACN,MAAM,EACN,GAA0B,EAC1B,WAAW,EACX,KAAK,GACN,EAAE,uBAAuB,CAAC,CAAC,CAAC,gBA4B9B"}
@@ -7,7 +7,7 @@ export async function updateGlobalVersion({ id, global, locale, req = {}, versio
7
7
  }
8
8
  };
9
9
  const options = {
10
- ...withSession(this, req.transactionID),
10
+ ...await withSession(this, req),
11
11
  lean: true,
12
12
  new: true
13
13
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import type { UpdateGlobalVersionArgs } from 'payload/database'\nimport type { PayloadRequestWithData, TypeWithID } from 'payload/types'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { withSession } from './withSession.js'\n\nexport async function updateGlobalVersion<T extends TypeWithID>(\n this: MongooseAdapter,\n {\n id,\n global,\n locale,\n req = {} as PayloadRequestWithData,\n versionData,\n where,\n }: UpdateGlobalVersionArgs<T>,\n) {\n const VersionModel = this.versions[global]\n const whereToUse = where || { id: { equals: id } }\n const options = {\n ...withSession(this, req.transactionID),\n lean: true,\n new: true,\n }\n\n const query = await VersionModel.buildQuery({\n locale,\n payload: this.payload,\n where: whereToUse,\n })\n\n const doc = await VersionModel.findOneAndUpdate(query, versionData, options)\n\n const result = JSON.parse(JSON.stringify(doc))\n\n const verificationToken = doc._verificationToken\n\n // custom id type reset\n result.id = result._id\n if (verificationToken) {\n result._verificationToken = verificationToken\n }\n return result\n}\n"],"names":["withSession","updateGlobalVersion","id","global","locale","req","versionData","where","VersionModel","versions","whereToUse","equals","options","transactionID","lean","new","query","buildQuery","payload","doc","findOneAndUpdate","result","JSON","parse","stringify","verificationToken","_verificationToken","_id"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,eAAeC,oBAEpB,EACEC,EAAE,EACFC,MAAM,EACNC,MAAM,EACNC,MAAM,CAAC,CAA2B,EAClCC,WAAW,EACXC,KAAK,EACsB;IAE7B,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACN,OAAO;IAC1C,MAAMO,aAAaH,SAAS;QAAEL,IAAI;YAAES,QAAQT;QAAG;IAAE;IACjD,MAAMU,UAAU;QACd,GAAGZ,YAAY,IAAI,EAAEK,IAAIQ,aAAa,CAAC;QACvCC,MAAM;QACNC,KAAK;IACP;IAEA,MAAMC,QAAQ,MAAMR,aAAaS,UAAU,CAAC;QAC1Cb;QACAc,SAAS,IAAI,CAACA,OAAO;QACrBX,OAAOG;IACT;IAEA,MAAMS,MAAM,MAAMX,aAAaY,gBAAgB,CAACJ,OAAOV,aAAaM;IAEpE,MAAMS,SAASC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IAEzC,MAAMM,oBAAoBN,IAAIO,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAOnB,EAAE,GAAGmB,OAAOM,GAAG;IACtB,IAAIF,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IACA,OAAOJ;AACT"}
1
+ {"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import type { PayloadRequest, TypeWithID, UpdateGlobalVersionArgs } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { withSession } from './withSession.js'\n\nexport async function updateGlobalVersion<T extends TypeWithID>(\n this: MongooseAdapter,\n {\n id,\n global,\n locale,\n req = {} as PayloadRequest,\n versionData,\n where,\n }: UpdateGlobalVersionArgs<T>,\n) {\n const VersionModel = this.versions[global]\n const whereToUse = where || { id: { equals: id } }\n const options = {\n ...(await withSession(this, req)),\n lean: true,\n new: true,\n }\n\n const query = await VersionModel.buildQuery({\n locale,\n payload: this.payload,\n where: whereToUse,\n })\n\n const doc = await VersionModel.findOneAndUpdate(query, versionData, options)\n\n const result = JSON.parse(JSON.stringify(doc))\n\n const verificationToken = doc._verificationToken\n\n // custom id type reset\n result.id = result._id\n if (verificationToken) {\n result._verificationToken = verificationToken\n }\n return result\n}\n"],"names":["withSession","updateGlobalVersion","id","global","locale","req","versionData","where","VersionModel","versions","whereToUse","equals","options","lean","new","query","buildQuery","payload","doc","findOneAndUpdate","result","JSON","parse","stringify","verificationToken","_verificationToken","_id"],"mappings":"AAIA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,eAAeC,oBAEpB,EACEC,EAAE,EACFC,MAAM,EACNC,MAAM,EACNC,MAAM,CAAC,CAAmB,EAC1BC,WAAW,EACXC,KAAK,EACsB;IAE7B,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACN,OAAO;IAC1C,MAAMO,aAAaH,SAAS;QAAEL,IAAI;YAAES,QAAQT;QAAG;IAAE;IACjD,MAAMU,UAAU;QACd,GAAI,MAAMZ,YAAY,IAAI,EAAEK,IAAI;QAChCQ,MAAM;QACNC,KAAK;IACP;IAEA,MAAMC,QAAQ,MAAMP,aAAaQ,UAAU,CAAC;QAC1CZ;QACAa,SAAS,IAAI,CAACA,OAAO;QACrBV,OAAOG;IACT;IAEA,MAAMQ,MAAM,MAAMV,aAAaW,gBAAgB,CAACJ,OAAOT,aAAaM;IAEpE,MAAMQ,SAASC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IAEzC,MAAMM,oBAAoBN,IAAIO,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAOlB,EAAE,GAAGkB,OAAOM,GAAG;IACtB,IAAIF,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IACA,OAAOJ;AACT"}
@@ -1,3 +1,3 @@
1
- import type { UpdateOne } from 'payload/database';
1
+ import type { UpdateOne } from 'payload';
2
2
  export declare const updateOne: UpdateOne;
3
3
  //# sourceMappingURL=updateOne.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"updateOne.d.ts","sourceRoot":"","sources":["../src/updateOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AASjD,eAAO,MAAM,SAAS,EAAE,SA+BvB,CAAA"}
1
+ {"version":3,"file":"updateOne.d.ts","sourceRoot":"","sources":["../src/updateOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,SAAS,EAAE,MAAM,SAAS,CAAA;AAQxD,eAAO,MAAM,SAAS,EAAE,SA+BvB,CAAA"}
package/dist/updateOne.js CHANGED
@@ -1,4 +1,4 @@
1
- import handleError from './utilities/handleError.js';
1
+ import { handleError } from './utilities/handleError.js';
2
2
  import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';
3
3
  import { withSession } from './withSession.js';
4
4
  export const updateOne = async function updateOne({ id, collection, data, locale, req = {}, where: whereArg }) {
@@ -9,7 +9,7 @@ export const updateOne = async function updateOne({ id, collection, data, locale
9
9
  } : whereArg;
10
10
  const Model = this.collections[collection];
11
11
  const options = {
12
- ...withSession(this, req.transactionID),
12
+ ...await withSession(this, req),
13
13
  lean: true,
14
14
  new: true
15
15
  };
@@ -22,7 +22,11 @@ export const updateOne = async function updateOne({ id, collection, data, locale
22
22
  try {
23
23
  result = await Model.findOneAndUpdate(query, data, options);
24
24
  } catch (error) {
25
- handleError(error, req);
25
+ handleError({
26
+ collection,
27
+ error,
28
+ req
29
+ });
26
30
  }
27
31
  result = JSON.parse(JSON.stringify(result));
28
32
  result.id = result._id;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type { UpdateOne } from 'payload/database'\nimport type { PayloadRequestWithData } from 'payload/types'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport handleError from './utilities/handleError.js'\nimport sanitizeInternalFields from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: MongooseAdapter,\n { id, collection, data, locale, req = {} as PayloadRequestWithData, where: whereArg },\n) {\n const where = id ? { id: { equals: id } } : whereArg\n const Model = this.collections[collection]\n const options = {\n ...withSession(this, req.transactionID),\n lean: true,\n new: true,\n }\n\n const query = await Model.buildQuery({\n locale,\n payload: this.payload,\n where,\n })\n\n let result\n\n try {\n result = await Model.findOneAndUpdate(query, data, options)\n } catch (error) {\n handleError(error, req)\n }\n\n result = JSON.parse(JSON.stringify(result))\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["handleError","sanitizeInternalFields","withSession","updateOne","id","collection","data","locale","req","where","whereArg","equals","Model","collections","options","transactionID","lean","new","query","buildQuery","payload","result","findOneAndUpdate","error","JSON","parse","stringify","_id"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,OAAOA,iBAAiB,6BAA4B;AACpD,OAAOC,4BAA4B,wCAAuC;AAC1E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EAAEC,EAAE,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAA2B,EAAEC,OAAOC,QAAQ,EAAE;IAErF,MAAMD,QAAQL,KAAK;QAAEA,IAAI;YAAEO,QAAQP;QAAG;IAAE,IAAIM;IAC5C,MAAME,QAAQ,IAAI,CAACC,WAAW,CAACR,WAAW;IAC1C,MAAMS,UAAU;QACd,GAAGZ,YAAY,IAAI,EAAEM,IAAIO,aAAa,CAAC;QACvCC,MAAM;QACNC,KAAK;IACP;IAEA,MAAMC,QAAQ,MAAMN,MAAMO,UAAU,CAAC;QACnCZ;QACAa,SAAS,IAAI,CAACA,OAAO;QACrBX;IACF;IAEA,IAAIY;IAEJ,IAAI;QACFA,SAAS,MAAMT,MAAMU,gBAAgB,CAACJ,OAAOZ,MAAMQ;IACrD,EAAE,OAAOS,OAAO;QACdvB,YAAYuB,OAAOf;IACrB;IAEAa,SAASG,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IACnCA,OAAOjB,EAAE,GAAGiB,OAAOM,GAAG;IACtBN,SAASpB,uBAAuBoB;IAEhC,OAAOA;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type { PayloadRequest, UpdateOne } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { handleError } from './utilities/handleError.js'\nimport sanitizeInternalFields from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: MongooseAdapter,\n { id, collection, data, locale, req = {} as PayloadRequest, where: whereArg },\n) {\n const where = id ? { id: { equals: id } } : whereArg\n const Model = this.collections[collection]\n const options = {\n ...(await withSession(this, req)),\n lean: true,\n new: true,\n }\n\n const query = await Model.buildQuery({\n locale,\n payload: this.payload,\n where,\n })\n\n let result\n\n try {\n result = await Model.findOneAndUpdate(query, data, options)\n } catch (error) {\n handleError({ collection, error, req })\n }\n\n result = JSON.parse(JSON.stringify(result))\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["handleError","sanitizeInternalFields","withSession","updateOne","id","collection","data","locale","req","where","whereArg","equals","Model","collections","options","lean","new","query","buildQuery","payload","result","findOneAndUpdate","error","JSON","parse","stringify","_id"],"mappings":"AAIA,SAASA,WAAW,QAAQ,6BAA4B;AACxD,OAAOC,4BAA4B,wCAAuC;AAC1E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EAAEC,EAAE,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,OAAOC,QAAQ,EAAE;IAE7E,MAAMD,QAAQL,KAAK;QAAEA,IAAI;YAAEO,QAAQP;QAAG;IAAE,IAAIM;IAC5C,MAAME,QAAQ,IAAI,CAACC,WAAW,CAACR,WAAW;IAC1C,MAAMS,UAAU;QACd,GAAI,MAAMZ,YAAY,IAAI,EAAEM,IAAI;QAChCO,MAAM;QACNC,KAAK;IACP;IAEA,MAAMC,QAAQ,MAAML,MAAMM,UAAU,CAAC;QACnCX;QACAY,SAAS,IAAI,CAACA,OAAO;QACrBV;IACF;IAEA,IAAIW;IAEJ,IAAI;QACFA,SAAS,MAAMR,MAAMS,gBAAgB,CAACJ,OAAOX,MAAMQ;IACrD,EAAE,OAAOQ,OAAO;QACdtB,YAAY;YAAEK;YAAYiB;YAAOd;QAAI;IACvC;IAEAY,SAASG,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IACnCA,OAAOhB,EAAE,GAAGgB,OAAOM,GAAG;IACtBN,SAASnB,uBAAuBmB;IAEhC,OAAOA;AACT,EAAC"}
@@ -1,3 +1,3 @@
1
- import type { UpdateVersion } from 'payload/database';
1
+ import type { UpdateVersion } from 'payload';
2
2
  export declare const updateVersion: UpdateVersion;
3
3
  //# sourceMappingURL=updateVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"updateVersion.d.ts","sourceRoot":"","sources":["../src/updateVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAOrD,eAAO,MAAM,aAAa,EAAE,aA8B3B,CAAA"}
1
+ {"version":3,"file":"updateVersion.d.ts","sourceRoot":"","sources":["../src/updateVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,SAAS,CAAA;AAM5D,eAAO,MAAM,aAAa,EAAE,aA8B3B,CAAA"}
@@ -7,7 +7,7 @@ export const updateVersion = async function updateVersion({ id, collection, loca
7
7
  }
8
8
  };
9
9
  const options = {
10
- ...withSession(this, req.transactionID),
10
+ ...await withSession(this, req),
11
11
  lean: true,
12
12
  new: true
13
13
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import type { UpdateVersion } from 'payload/database'\nimport type { PayloadRequestWithData } from 'payload/types'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { withSession } from './withSession.js'\n\nexport const updateVersion: UpdateVersion = async function updateVersion(\n this: MongooseAdapter,\n { id, collection, locale, req = {} as PayloadRequestWithData, versionData, where },\n) {\n const VersionModel = this.versions[collection]\n const whereToUse = where || { id: { equals: id } }\n const options = {\n ...withSession(this, req.transactionID),\n lean: true,\n new: true,\n }\n\n const query = await VersionModel.buildQuery({\n locale,\n payload: this.payload,\n where: whereToUse,\n })\n\n const doc = await VersionModel.findOneAndUpdate(query, versionData, options)\n\n const result = JSON.parse(JSON.stringify(doc))\n\n const verificationToken = doc._verificationToken\n\n // custom id type reset\n result.id = result._id\n if (verificationToken) {\n result._verificationToken = verificationToken\n }\n return result\n}\n"],"names":["withSession","updateVersion","id","collection","locale","req","versionData","where","VersionModel","versions","whereToUse","equals","options","transactionID","lean","new","query","buildQuery","payload","doc","findOneAndUpdate","result","JSON","parse","stringify","verificationToken","_verificationToken","_id"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EAAEC,EAAE,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAA2B,EAAEC,WAAW,EAAEC,KAAK,EAAE;IAElF,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACN,WAAW;IAC9C,MAAMO,aAAaH,SAAS;QAAEL,IAAI;YAAES,QAAQT;QAAG;IAAE;IACjD,MAAMU,UAAU;QACd,GAAGZ,YAAY,IAAI,EAAEK,IAAIQ,aAAa,CAAC;QACvCC,MAAM;QACNC,KAAK;IACP;IAEA,MAAMC,QAAQ,MAAMR,aAAaS,UAAU,CAAC;QAC1Cb;QACAc,SAAS,IAAI,CAACA,OAAO;QACrBX,OAAOG;IACT;IAEA,MAAMS,MAAM,MAAMX,aAAaY,gBAAgB,CAACJ,OAAOV,aAAaM;IAEpE,MAAMS,SAASC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IAEzC,MAAMM,oBAAoBN,IAAIO,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAOnB,EAAE,GAAGmB,OAAOM,GAAG;IACtB,IAAIF,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IACA,OAAOJ;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import type { PayloadRequest, UpdateVersion } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { withSession } from './withSession.js'\n\nexport const updateVersion: UpdateVersion = async function updateVersion(\n this: MongooseAdapter,\n { id, collection, locale, req = {} as PayloadRequest, versionData, where },\n) {\n const VersionModel = this.versions[collection]\n const whereToUse = where || { id: { equals: id } }\n const options = {\n ...(await withSession(this, req)),\n lean: true,\n new: true,\n }\n\n const query = await VersionModel.buildQuery({\n locale,\n payload: this.payload,\n where: whereToUse,\n })\n\n const doc = await VersionModel.findOneAndUpdate(query, versionData, options)\n\n const result = JSON.parse(JSON.stringify(doc))\n\n const verificationToken = doc._verificationToken\n\n // custom id type reset\n result.id = result._id\n if (verificationToken) {\n result._verificationToken = verificationToken\n }\n return result\n}\n"],"names":["withSession","updateVersion","id","collection","locale","req","versionData","where","VersionModel","versions","whereToUse","equals","options","lean","new","query","buildQuery","payload","doc","findOneAndUpdate","result","JSON","parse","stringify","verificationToken","_verificationToken","_id"],"mappings":"AAIA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EAAEC,EAAE,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,WAAW,EAAEC,KAAK,EAAE;IAE1E,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACN,WAAW;IAC9C,MAAMO,aAAaH,SAAS;QAAEL,IAAI;YAAES,QAAQT;QAAG;IAAE;IACjD,MAAMU,UAAU;QACd,GAAI,MAAMZ,YAAY,IAAI,EAAEK,IAAI;QAChCQ,MAAM;QACNC,KAAK;IACP;IAEA,MAAMC,QAAQ,MAAMP,aAAaQ,UAAU,CAAC;QAC1CZ;QACAa,SAAS,IAAI,CAACA,OAAO;QACrBV,OAAOG;IACT;IAEA,MAAMQ,MAAM,MAAMV,aAAaW,gBAAgB,CAACJ,OAAOT,aAAaM;IAEpE,MAAMQ,SAASC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IAEzC,MAAMM,oBAAoBN,IAAIO,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAOlB,EAAE,GAAGkB,OAAOM,GAAG;IACtB,IAAIF,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IACA,OAAOJ;AACT,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { DBIdentifierName } from 'payload/database';
1
+ import type { DBIdentifierName } from 'payload';
2
2
  type Args = {
3
3
  config: {
4
4
  dbName?: DBIdentifierName;
@@ -1 +1 @@
1
- {"version":3,"file":"getDBName.d.ts","sourceRoot":"","sources":["../../src/utilities/getDBName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExD,KAAK,IAAI,GAAG;IACV,MAAM,EAAE;QACN,MAAM,CAAC,EAAE,gBAAgB,CAAA;QACzB,QAAQ,CAAC,EAAE,gBAAgB,CAAA;QAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;IACD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,0DAKnB,IAAI,KAAG,MAiBT,CAAA"}
1
+ {"version":3,"file":"getDBName.d.ts","sourceRoot":"","sources":["../../src/utilities/getDBName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,KAAK,IAAI,GAAG;IACV,MAAM,EAAE;QACN,MAAM,CAAC,EAAE,gBAAgB,CAAA;QACzB,QAAQ,CAAC,EAAE,gBAAgB,CAAA;QAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;IACD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,0DAKnB,IAAI,KAAG,MAiBT,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getDBName.ts"],"sourcesContent":["import type { DBIdentifierName } from 'payload/database'\n\ntype Args = {\n config: {\n dbName?: DBIdentifierName\n enumName?: DBIdentifierName\n name?: string\n slug?: string\n }\n locales?: boolean\n target?: 'dbName' | 'enumName'\n versions?: boolean\n}\n\n/**\n * Used to name database enums and collections\n * Returns the collection or enum name for a given entity\n */\nexport const getDBName = ({\n config: { name, slug },\n config,\n target = 'dbName',\n versions = false,\n}: Args): string => {\n let result: string\n let custom = config[target]\n\n if (!custom && target === 'enumName') {\n custom = config['dbName']\n }\n\n if (custom) {\n result = typeof custom === 'function' ? custom({}) : custom\n } else {\n result = name ?? slug\n }\n\n if (versions) result = `_${result}_versions`\n\n return result\n}\n"],"names":["getDBName","config","name","slug","target","versions","result","custom"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAcA;;;CAGC,GACD,OAAO,MAAMA,YAAY,CAAC,EACxBC,QAAQ,EAAEC,IAAI,EAAEC,IAAI,EAAE,EACtBF,MAAM,EACNG,SAAS,QAAQ,EACjBC,WAAW,KAAK,EACX;IACL,IAAIC;IACJ,IAAIC,SAASN,MAAM,CAACG,OAAO;IAE3B,IAAI,CAACG,UAAUH,WAAW,YAAY;QACpCG,SAASN,MAAM,CAAC,SAAS;IAC3B;IAEA,IAAIM,QAAQ;QACVD,SAAS,OAAOC,WAAW,aAAaA,OAAO,CAAC,KAAKA;IACvD,OAAO;QACLD,SAASJ,QAAQC;IACnB;IAEA,IAAIE,UAAUC,SAAS,CAAC,CAAC,EAAEA,OAAO,SAAS,CAAC;IAE5C,OAAOA;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/getDBName.ts"],"sourcesContent":["import type { DBIdentifierName } from 'payload'\n\ntype Args = {\n config: {\n dbName?: DBIdentifierName\n enumName?: DBIdentifierName\n name?: string\n slug?: string\n }\n locales?: boolean\n target?: 'dbName' | 'enumName'\n versions?: boolean\n}\n\n/**\n * Used to name database enums and collections\n * Returns the collection or enum name for a given entity\n */\nexport const getDBName = ({\n config: { name, slug },\n config,\n target = 'dbName',\n versions = false,\n}: Args): string => {\n let result: string\n let custom = config[target]\n\n if (!custom && target === 'enumName') {\n custom = config['dbName']\n }\n\n if (custom) {\n result = typeof custom === 'function' ? custom({}) : custom\n } else {\n result = name ?? slug\n }\n\n if (versions) result = `_${result}_versions`\n\n return result\n}\n"],"names":["getDBName","config","name","slug","target","versions","result","custom"],"mappings":"AAcA;;;CAGC,GACD,OAAO,MAAMA,YAAY,CAAC,EACxBC,QAAQ,EAAEC,IAAI,EAAEC,IAAI,EAAE,EACtBF,MAAM,EACNG,SAAS,QAAQ,EACjBC,WAAW,KAAK,EACX;IACL,IAAIC;IACJ,IAAIC,SAASN,MAAM,CAACG,OAAO;IAE3B,IAAI,CAACG,UAAUH,WAAW,YAAY;QACpCG,SAASN,MAAM,CAAC,SAAS;IAC3B;IAEA,IAAIM,QAAQ;QACVD,SAAS,OAAOC,WAAW,aAAaA,OAAO,CAAC,KAAKA;IACvD,OAAO;QACLD,SAASJ,QAAQC;IACnB;IAEA,IAAIE,UAAUC,SAAS,CAAC,CAAC,EAAEA,OAAO,SAAS,CAAC;IAE5C,OAAOA;AACT,EAAC"}
@@ -1,3 +1,7 @@
1
- declare const handleError: (error: any, req: any) => never;
2
- export default handleError;
1
+ export declare const handleError: ({ collection, error, global, req, }: {
2
+ collection?: string;
3
+ error: any;
4
+ global?: string;
5
+ req: any;
6
+ }) => never;
3
7
  //# sourceMappingURL=handleError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleError.d.ts","sourceRoot":"","sources":["../../src/utilities/handleError.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,WAAW,iCAiBhB,CAAA;AAED,eAAe,WAAW,CAAA"}
1
+ {"version":3,"file":"handleError.d.ts","sourceRoot":"","sources":["../../src/utilities/handleError.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,wCAKrB;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,MAAA;IACL,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,MAAA;CACJ,UAqBA,CAAA"}
@@ -1,20 +1,23 @@
1
1
  import httpStatus from 'http-status';
2
- import { APIError, ValidationError } from 'payload/errors';
3
- const handleError = (error, req)=>{
2
+ import { APIError, ValidationError } from 'payload';
3
+ export const handleError = ({ collection, error, global, req })=>{
4
4
  // Handle uniqueness error from MongoDB
5
5
  if (error.code === 11000 && error.keyValue) {
6
- throw new ValidationError([
7
- {
8
- field: Object.keys(error.keyValue)[0],
9
- message: req.t('error:valueMustBeUnique')
10
- }
11
- ], req.t);
6
+ throw new ValidationError({
7
+ collection,
8
+ errors: [
9
+ {
10
+ field: Object.keys(error.keyValue)[0],
11
+ message: req.t('error:valueMustBeUnique')
12
+ }
13
+ ],
14
+ global
15
+ }, req.t);
12
16
  } else if (error.code === 11000) {
13
17
  throw new APIError(req.t('error:valueMustBeUnique'), httpStatus.BAD_REQUEST);
14
18
  } else {
15
19
  throw error;
16
20
  }
17
21
  };
18
- export default handleError;
19
22
 
20
23
  //# sourceMappingURL=handleError.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/handleError.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { APIError, ValidationError } from 'payload/errors'\n\nconst handleError = (error, req) => {\n // Handle uniqueness error from MongoDB\n if (error.code === 11000 && error.keyValue) {\n throw new ValidationError(\n [\n {\n field: Object.keys(error.keyValue)[0],\n message: req.t('error:valueMustBeUnique'),\n },\n ],\n req.t,\n )\n } else if (error.code === 11000) {\n throw new APIError(req.t('error:valueMustBeUnique'), httpStatus.BAD_REQUEST)\n } else {\n throw error\n }\n}\n\nexport default handleError\n"],"names":["httpStatus","APIError","ValidationError","handleError","error","req","code","keyValue","field","Object","keys","message","t","BAD_REQUEST"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,QAAQ,EAAEC,eAAe,QAAQ,iBAAgB;AAE1D,MAAMC,cAAc,CAACC,OAAOC;IAC1B,uCAAuC;IACvC,IAAID,MAAME,IAAI,KAAK,SAASF,MAAMG,QAAQ,EAAE;QAC1C,MAAM,IAAIL,gBACR;YACE;gBACEM,OAAOC,OAAOC,IAAI,CAACN,MAAMG,QAAQ,CAAC,CAAC,EAAE;gBACrCI,SAASN,IAAIO,CAAC,CAAC;YACjB;SACD,EACDP,IAAIO,CAAC;IAET,OAAO,IAAIR,MAAME,IAAI,KAAK,OAAO;QAC/B,MAAM,IAAIL,SAASI,IAAIO,CAAC,CAAC,4BAA4BZ,WAAWa,WAAW;IAC7E,OAAO;QACL,MAAMT;IACR;AACF;AAEA,eAAeD,YAAW"}
1
+ {"version":3,"sources":["../../src/utilities/handleError.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { APIError, ValidationError } from 'payload'\n\nexport const handleError = ({\n collection,\n error,\n global,\n req,\n}: {\n collection?: string\n error\n global?: string\n req\n}) => {\n // Handle uniqueness error from MongoDB\n if (error.code === 11000 && error.keyValue) {\n throw new ValidationError(\n {\n collection,\n errors: [\n {\n field: Object.keys(error.keyValue)[0],\n message: req.t('error:valueMustBeUnique'),\n },\n ],\n global,\n },\n req.t,\n )\n } else if (error.code === 11000) {\n throw new APIError(req.t('error:valueMustBeUnique'), httpStatus.BAD_REQUEST)\n } else {\n throw error\n }\n}\n"],"names":["httpStatus","APIError","ValidationError","handleError","collection","error","global","req","code","keyValue","errors","field","Object","keys","message","t","BAD_REQUEST"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,QAAQ,EAAEC,eAAe,QAAQ,UAAS;AAEnD,OAAO,MAAMC,cAAc,CAAC,EAC1BC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,GAAG,EAMJ;IACC,uCAAuC;IACvC,IAAIF,MAAMG,IAAI,KAAK,SAASH,MAAMI,QAAQ,EAAE;QAC1C,MAAM,IAAIP,gBACR;YACEE;YACAM,QAAQ;gBACN;oBACEC,OAAOC,OAAOC,IAAI,CAACR,MAAMI,QAAQ,CAAC,CAAC,EAAE;oBACrCK,SAASP,IAAIQ,CAAC,CAAC;gBACjB;aACD;YACDT;QACF,GACAC,IAAIQ,CAAC;IAET,OAAO,IAAIV,MAAMG,IAAI,KAAK,OAAO;QAC/B,MAAM,IAAIP,SAASM,IAAIQ,CAAC,CAAC,4BAA4Bf,WAAWgB,WAAW;IAC7E,OAAO;QACL,MAAMX;IACR;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizeInternalFields.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizeInternalFields.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,sBAAsB,mDAAoD,CAAC,KAAG,CAiBvE,CAAA;AAEb,eAAe,sBAAsB,CAAA"}
1
+ {"version":3,"file":"sanitizeInternalFields.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizeInternalFields.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,sBAAsB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,KAAG,CAiBvE,CAAA;AAEb,eAAe,sBAAsB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/sanitizeInternalFields.ts"],"sourcesContent":["const internalFields = ['__v']\n\nconst sanitizeInternalFields = <T extends Record<string, unknown>>(incomingDoc: T): T =>\n Object.entries(incomingDoc).reduce((newDoc, [key, val]): T => {\n if (key === '_id') {\n return {\n ...newDoc,\n id: val,\n }\n }\n\n if (internalFields.indexOf(key) > -1) {\n return newDoc\n }\n\n return {\n ...newDoc,\n [key]: val,\n }\n }, {} as T)\n\nexport default sanitizeInternalFields\n"],"names":["internalFields","sanitizeInternalFields","incomingDoc","Object","entries","reduce","newDoc","key","val","id","indexOf"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAAA,MAAMA,iBAAiB;IAAC;CAAM;AAE9B,MAAMC,yBAAyB,CAAoCC,cACjEC,OAAOC,OAAO,CAACF,aAAaG,MAAM,CAAC,CAACC,QAAQ,CAACC,KAAKC,IAAI;QACpD,IAAID,QAAQ,OAAO;YACjB,OAAO;gBACL,GAAGD,MAAM;gBACTG,IAAID;YACN;QACF;QAEA,IAAIR,eAAeU,OAAO,CAACH,OAAO,CAAC,GAAG;YACpC,OAAOD;QACT;QAEA,OAAO;YACL,GAAGA,MAAM;YACT,CAACC,IAAI,EAAEC;QACT;IACF,GAAG,CAAC;AAEN,eAAeP,uBAAsB"}
1
+ {"version":3,"sources":["../../src/utilities/sanitizeInternalFields.ts"],"sourcesContent":["const internalFields = ['__v']\n\nconst sanitizeInternalFields = <T extends Record<string, unknown>>(incomingDoc: T): T =>\n Object.entries(incomingDoc).reduce((newDoc, [key, val]): T => {\n if (key === '_id') {\n return {\n ...newDoc,\n id: val,\n }\n }\n\n if (internalFields.indexOf(key) > -1) {\n return newDoc\n }\n\n return {\n ...newDoc,\n [key]: val,\n }\n }, {} as T)\n\nexport default sanitizeInternalFields\n"],"names":["internalFields","sanitizeInternalFields","incomingDoc","Object","entries","reduce","newDoc","key","val","id","indexOf"],"mappings":"AAAA,MAAMA,iBAAiB;IAAC;CAAM;AAE9B,MAAMC,yBAAyB,CAAoCC,cACjEC,OAAOC,OAAO,CAACF,aAAaG,MAAM,CAAC,CAACC,QAAQ,CAACC,KAAKC,IAAI;QACpD,IAAID,QAAQ,OAAO;YACjB,OAAO;gBACL,GAAGD,MAAM;gBACTG,IAAID;YACN;QACF;QAEA,IAAIR,eAAeU,OAAO,CAACH,OAAO,CAAC,GAAG;YACpC,OAAOD;QACT;QAEA,OAAO;YACL,GAAGA,MAAM;YACT,CAACC,IAAI,EAAEC;QACT;IACF,GAAG,CAAC;AAEN,eAAeP,uBAAsB"}
@@ -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
+ } | object>;
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,CAQ9C"}
@@ -1,8 +1,12 @@
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] ? {
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) return db.sessions[transactionID] ? {
6
10
  session: db.sessions[transactionID]
7
11
  } : {};
8
12
  }
@@ -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 } | object> {\n let transactionID = req.transactionID\n\n if (transactionID instanceof Promise) {\n transactionID = await req.transactionID\n }\n\n if (req) return db.sessions[transactionID] ? { session: db.sessions[transactionID] } : {}\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,OAAOD,GAAGI,QAAQ,CAACF,cAAc,GAAG;QAAEG,SAASL,GAAGI,QAAQ,CAACF,cAAc;IAAC,IAAI,CAAC;AAC1F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-mongodb",
3
- "version": "3.0.0-canary.ee6d727",
3
+ "version": "3.0.0-canary.ef0a8d0",
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",
@@ -32,21 +32,21 @@
32
32
  "mongoose": "6.12.3",
33
33
  "mongoose-paginate-v2": "1.7.22",
34
34
  "prompts": "2.4.2",
35
- "uuid": "^9.0.1"
35
+ "uuid": "10.0.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/mongoose-aggregate-paginate-v2": "1.0.9",
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.ee6d727"
41
+ "@payloadcms/eslint-config": "3.0.0-beta.59",
42
+ "payload": "3.0.0-canary.ef0a8d0"
43
43
  },
44
44
  "peerDependencies": {
45
- "payload": "3.0.0-canary.ee6d727"
45
+ "payload": "3.0.0-canary.ef0a8d0"
46
46
  },
47
47
  "scripts": {
48
- "build": "pnpm build:swc && pnpm build:types",
49
- "build:swc": "swc ./src -d ./dist --config-file .swcrc-build",
48
+ "build": "pnpm build:types && pnpm build:swc",
49
+ "build:swc": "swc ./src -d ./dist --config-file .swcrc-build --strip-leading-paths",
50
50
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
51
51
  "clean": "rimraf {dist,*.tsbuildinfo}"
52
52
  }