@payloadcms/db-mongodb 3.0.0-canary.f83d96a → 3.0.0-canary.ff8c8fd

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +6 -1
  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 +1 -1
  9. package/dist/create.js.map +1 -1
  10. package/dist/createGlobal.d.ts.map +1 -1
  11. package/dist/createGlobal.js +1 -1
  12. package/dist/createGlobal.js.map +1 -1
  13. package/dist/createGlobalVersion.d.ts.map +1 -1
  14. package/dist/createGlobalVersion.js +1 -1
  15. package/dist/createGlobalVersion.js.map +1 -1
  16. package/dist/createMigration.d.ts.map +1 -1
  17. package/dist/createMigration.js +1 -1
  18. package/dist/createMigration.js.map +1 -1
  19. package/dist/createVersion.d.ts.map +1 -1
  20. package/dist/createVersion.js +1 -1
  21. package/dist/createVersion.js.map +1 -1
  22. package/dist/deleteMany.d.ts.map +1 -1
  23. package/dist/deleteMany.js +1 -1
  24. package/dist/deleteMany.js.map +1 -1
  25. package/dist/deleteOne.d.ts.map +1 -1
  26. package/dist/deleteOne.js +1 -1
  27. package/dist/deleteOne.js.map +1 -1
  28. package/dist/deleteVersions.d.ts.map +1 -1
  29. package/dist/deleteVersions.js +1 -1
  30. package/dist/deleteVersions.js.map +1 -1
  31. package/dist/find.d.ts.map +1 -1
  32. package/dist/find.js +8 -2
  33. package/dist/find.js.map +1 -1
  34. package/dist/findGlobal.d.ts.map +1 -1
  35. package/dist/findGlobal.js +1 -1
  36. package/dist/findGlobal.js.map +1 -1
  37. package/dist/findGlobalVersions.d.ts.map +1 -1
  38. package/dist/findGlobalVersions.js +9 -3
  39. package/dist/findGlobalVersions.js.map +1 -1
  40. package/dist/findOne.d.ts.map +1 -1
  41. package/dist/findOne.js +1 -1
  42. package/dist/findOne.js.map +1 -1
  43. package/dist/findVersions.d.ts.map +1 -1
  44. package/dist/findVersions.js +8 -2
  45. package/dist/findVersions.js.map +1 -1
  46. package/dist/index.d.ts +46 -7
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +3 -1
  49. package/dist/index.js.map +1 -1
  50. package/dist/init.d.ts.map +1 -1
  51. package/dist/init.js +1 -1
  52. package/dist/init.js.map +1 -1
  53. package/dist/migrateFresh.js.map +1 -1
  54. package/dist/models/buildCollectionSchema.d.ts.map +1 -1
  55. package/dist/models/buildCollectionSchema.js +9 -0
  56. package/dist/models/buildCollectionSchema.js.map +1 -1
  57. package/dist/models/buildSchema.d.ts.map +1 -1
  58. package/dist/models/buildSchema.js +89 -17
  59. package/dist/models/buildSchema.js.map +1 -1
  60. package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
  61. package/dist/queries/buildAndOrConditions.js +0 -2
  62. package/dist/queries/buildAndOrConditions.js.map +1 -1
  63. package/dist/queries/getLocalizedSortProperty.spec.js +42 -42
  64. package/dist/queries/getLocalizedSortProperty.spec.js.map +1 -1
  65. package/dist/queries/parseParams.d.ts.map +1 -1
  66. package/dist/queries/parseParams.js +2 -5
  67. package/dist/queries/parseParams.js.map +1 -1
  68. package/dist/queryDrafts.d.ts.map +1 -1
  69. package/dist/queryDrafts.js +8 -2
  70. package/dist/queryDrafts.js.map +1 -1
  71. package/dist/transactions/commitTransaction.d.ts.map +1 -1
  72. package/dist/transactions/commitTransaction.js +1 -0
  73. package/dist/transactions/commitTransaction.js.map +1 -1
  74. package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
  75. package/dist/transactions/rollbackTransaction.js +13 -7
  76. package/dist/transactions/rollbackTransaction.js.map +1 -1
  77. package/dist/types.d.ts.map +1 -1
  78. package/dist/types.js.map +1 -1
  79. package/dist/updateGlobal.d.ts.map +1 -1
  80. package/dist/updateGlobal.js +1 -1
  81. package/dist/updateGlobal.js.map +1 -1
  82. package/dist/updateGlobalVersion.d.ts.map +1 -1
  83. package/dist/updateGlobalVersion.js +1 -1
  84. package/dist/updateGlobalVersion.js.map +1 -1
  85. package/dist/updateOne.d.ts.map +1 -1
  86. package/dist/updateOne.js +1 -1
  87. package/dist/updateOne.js.map +1 -1
  88. package/dist/updateVersion.d.ts.map +1 -1
  89. package/dist/updateVersion.js +1 -1
  90. package/dist/updateVersion.js.map +1 -1
  91. package/dist/withSession.d.ts +3 -2
  92. package/dist/withSession.d.ts.map +1 -1
  93. package/dist/withSession.js +6 -2
  94. package/dist/withSession.js.map +1 -1
  95. package/package.json +4 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/transactions/rollbackTransaction.ts"],"sourcesContent":["import type { RollbackTransaction } from 'payload'\n\nexport const rollbackTransaction: RollbackTransaction = async function rollbackTransaction(\n id = '',\n) {\n // if multiple operations are using the same transaction, the first will flow through and delete the session.\n // subsequent calls should be ignored.\n if (!this.sessions[id]) {\n return\n }\n\n // when session exists but is not inTransaction something unexpected is happening to the session\n if (!this.sessions[id].inTransaction()) {\n this.payload.logger.warn('rollbackTransaction called when no transaction exists')\n delete this.sessions[id]\n return\n }\n\n // the first call for rollback should be aborted and deleted causing any other operations with the same transaction to fail\n try {\n await this.sessions[id].abortTransaction()\n await this.sessions[id].endSession()\n } catch (error) {\n // ignore the error as it is likely a race condition from multiple errors\n }\n delete this.sessions[id]\n}\n"],"names":["rollbackTransaction","id","sessions","inTransaction","payload","logger","warn","abortTransaction","endSession","error"],"mappings":"AAEA,OAAO,MAAMA,sBAA2C,eAAeA,oBACrEC,KAAK,EAAE;IAEP,6GAA6G;IAC7G,sCAAsC;IACtC,IAAI,CAAC,IAAI,CAACC,QAAQ,CAACD,GAAG,EAAE;QACtB;IACF;IAEA,gGAAgG;IAChG,IAAI,CAAC,IAAI,CAACC,QAAQ,CAACD,GAAG,CAACE,aAAa,IAAI;QACtC,IAAI,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC;QACzB,OAAO,IAAI,CAACJ,QAAQ,CAACD,GAAG;QACxB;IACF;IAEA,2HAA2H;IAC3H,IAAI;QACF,MAAM,IAAI,CAACC,QAAQ,CAACD,GAAG,CAACM,gBAAgB;QACxC,MAAM,IAAI,CAACL,QAAQ,CAACD,GAAG,CAACO,UAAU;IACpC,EAAE,OAAOC,OAAO;IACd,yEAAyE;IAC3E;IACA,OAAO,IAAI,CAACP,QAAQ,CAACD,GAAG;AAC1B,EAAC"}
1
+ {"version":3,"sources":["../../src/transactions/rollbackTransaction.ts"],"sourcesContent":["import type { RollbackTransaction } from 'payload'\n\nexport const rollbackTransaction: RollbackTransaction = async function rollbackTransaction(\n incomingID = '',\n) {\n let transactionID: number | string\n\n if (incomingID instanceof Promise) {\n transactionID = await incomingID\n } else {\n transactionID = incomingID\n }\n\n // if multiple operations are using the same transaction, the first will flow through and delete the session.\n // subsequent calls should be ignored.\n if (!this.sessions[transactionID]) {\n return\n }\n\n // when session exists but is not inTransaction something unexpected is happening to the session\n if (!this.sessions[transactionID].inTransaction()) {\n this.payload.logger.warn('rollbackTransaction called when no transaction exists')\n delete this.sessions[transactionID]\n return\n }\n\n // the first call for rollback should be aborted and deleted causing any other operations with the same transaction to fail\n try {\n await this.sessions[transactionID].abortTransaction()\n await this.sessions[transactionID].endSession()\n } catch (error) {\n // ignore the error as it is likely a race condition from multiple errors\n }\n delete this.sessions[transactionID]\n}\n"],"names":["rollbackTransaction","incomingID","transactionID","Promise","sessions","inTransaction","payload","logger","warn","abortTransaction","endSession","error"],"mappings":"AAEA,OAAO,MAAMA,sBAA2C,eAAeA,oBACrEC,aAAa,EAAE;IAEf,IAAIC;IAEJ,IAAID,sBAAsBE,SAAS;QACjCD,gBAAgB,MAAMD;IACxB,OAAO;QACLC,gBAAgBD;IAClB;IAEA,6GAA6G;IAC7G,sCAAsC;IACtC,IAAI,CAAC,IAAI,CAACG,QAAQ,CAACF,cAAc,EAAE;QACjC;IACF;IAEA,gGAAgG;IAChG,IAAI,CAAC,IAAI,CAACE,QAAQ,CAACF,cAAc,CAACG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AClD,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 {\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
+ {"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\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":"AAoGA,WAAkD"}
@@ -1 +1 @@
1
- {"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,YAAY,EAAE,MAAM,SAAS,CAAA;AAOnE,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 { PayloadRequestWithData, 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 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"],"mappings":"AAIA,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 +1 @@
1
- {"version":3,"file":"updateGlobalVersion.d.ts","sourceRoot":"","sources":["../src/updateGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,UAAU,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAE1F,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 { PayloadRequestWithData, 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 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"],"mappings":"AAIA,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 +1 @@
1
- {"version":3,"file":"updateOne.d.ts","sourceRoot":"","sources":["../src/updateOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,SAAS,EAAE,MAAM,SAAS,CAAA;AAQhE,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
@@ -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
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type { PayloadRequestWithData, 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 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({ 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","transactionID","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,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,YAAY;YAAEK;YAAYkB;YAAOf;QAAI;IACvC;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 +1 @@
1
- {"version":3,"file":"updateVersion.d.ts","sourceRoot":"","sources":["../src/updateVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,aAAa,EAAE,MAAM,SAAS,CAAA;AAMpE,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 { PayloadRequestWithData, 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 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"],"mappings":"AAIA,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,10 +1,11 @@
1
1
  import type { ClientSession } from 'mongoose';
2
+ import type { PayloadRequest } from 'payload';
2
3
  import type { MongooseAdapter } from './index.js';
3
4
  /**
4
5
  * returns the session belonging to the transaction of the req.session if exists
5
6
  * @returns ClientSession
6
7
  */
7
- export declare function withSession(db: MongooseAdapter, transactionID?: number | string): {
8
+ export declare function withSession(db: MongooseAdapter, req: PayloadRequest): Promise<{
8
9
  session: ClientSession;
9
- } | object;
10
+ } | object>;
10
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"],"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.f83d96a",
3
+ "version": "3.0.0-canary.ff8c8fd",
4
4
  "description": "The officially supported MongoDB database adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -27,7 +27,6 @@
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",
33
32
  "mongoose-paginate-v2": "1.7.22",
@@ -38,11 +37,11 @@
38
37
  "@types/mongoose-aggregate-paginate-v2": "1.0.9",
39
38
  "mongodb": "4.17.1",
40
39
  "mongodb-memory-server": "^9",
41
- "@payloadcms/eslint-config": "1.1.1",
42
- "payload": "3.0.0-canary.f83d96a"
40
+ "@payloadcms/eslint-config": "3.0.0-beta.59",
41
+ "payload": "3.0.0-canary.ff8c8fd"
43
42
  },
44
43
  "peerDependencies": {
45
- "payload": "3.0.0-canary.f83d96a"
44
+ "payload": "3.0.0-canary.ff8c8fd"
46
45
  },
47
46
  "scripts": {
48
47
  "build": "pnpm build:types && pnpm build:swc",