payload 3.65.0-internal.5b33fe0 → 3.65.0-internal.cebb1a8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/auth/getAccessResults.d.ts.map +1 -1
  2. package/dist/auth/getAccessResults.js +12 -10
  3. package/dist/auth/getAccessResults.js.map +1 -1
  4. package/dist/auth/types.d.ts +12 -10
  5. package/dist/auth/types.d.ts.map +1 -1
  6. package/dist/auth/types.js.map +1 -1
  7. package/dist/collections/operations/countVersions.d.ts.map +1 -1
  8. package/dist/collections/operations/countVersions.js +2 -1
  9. package/dist/collections/operations/countVersions.js.map +1 -1
  10. package/dist/collections/operations/docAccess.d.ts +9 -2
  11. package/dist/collections/operations/docAccess.d.ts.map +1 -1
  12. package/dist/collections/operations/docAccess.js +8 -6
  13. package/dist/collections/operations/docAccess.js.map +1 -1
  14. package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
  15. package/dist/collections/operations/restoreVersion.js +9 -7
  16. package/dist/collections/operations/restoreVersion.js.map +1 -1
  17. package/dist/config/types.d.ts +2 -2
  18. package/dist/config/types.d.ts.map +1 -1
  19. package/dist/config/types.js.map +1 -1
  20. package/dist/database/queryValidation/types.d.ts.map +1 -1
  21. package/dist/database/queryValidation/types.js.map +1 -1
  22. package/dist/database/queryValidation/validateQueryPaths.d.ts.map +1 -1
  23. package/dist/database/queryValidation/validateQueryPaths.js.map +1 -1
  24. package/dist/database/queryValidation/validateSearchParams.d.ts.map +1 -1
  25. package/dist/database/queryValidation/validateSearchParams.js +10 -8
  26. package/dist/database/queryValidation/validateSearchParams.js.map +1 -1
  27. package/dist/exports/internal.d.ts +6 -0
  28. package/dist/exports/internal.d.ts.map +1 -0
  29. package/dist/exports/internal.js +6 -0
  30. package/dist/exports/internal.js.map +1 -0
  31. package/dist/globals/operations/docAccess.d.ts +5 -1
  32. package/dist/globals/operations/docAccess.d.ts.map +1 -1
  33. package/dist/globals/operations/docAccess.js +8 -11
  34. package/dist/globals/operations/docAccess.js.map +1 -1
  35. package/dist/index.bundled.d.ts +27 -12
  36. package/dist/types/index.d.ts +2 -0
  37. package/dist/types/index.d.ts.map +1 -1
  38. package/dist/types/index.js.map +1 -1
  39. package/dist/utilities/getEntityPermissions/entityDocExists.d.ts +14 -0
  40. package/dist/utilities/getEntityPermissions/entityDocExists.d.ts.map +1 -0
  41. package/dist/utilities/getEntityPermissions/entityDocExists.js +45 -0
  42. package/dist/utilities/getEntityPermissions/entityDocExists.js.map +1 -0
  43. package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts +52 -0
  44. package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -0
  45. package/dist/utilities/getEntityPermissions/getEntityPermissions.js +193 -0
  46. package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -0
  47. package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts +24 -0
  48. package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts.map +1 -0
  49. package/dist/utilities/getEntityPermissions/populateFieldPermissions.js +236 -0
  50. package/dist/utilities/getEntityPermissions/populateFieldPermissions.js.map +1 -0
  51. package/dist/utilities/sanitizePermissions.d.ts +2 -0
  52. package/dist/utilities/sanitizePermissions.d.ts.map +1 -1
  53. package/dist/utilities/sanitizePermissions.js +4 -0
  54. package/dist/utilities/sanitizePermissions.js.map +1 -1
  55. package/package.json +7 -2
  56. package/dist/utilities/getEntityPolicies.d.ts +0 -21
  57. package/dist/utilities/getEntityPolicies.d.ts.map +0 -1
  58. package/dist/utilities/getEntityPolicies.js +0 -306
  59. package/dist/utilities/getEntityPolicies.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"getAccessResults.d.ts","sourceRoot":"","sources":["../../src/auth/getAccessResults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAKnE,KAAK,oBAAoB,GAAG;IAC1B,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AACD,wBAAsB,gBAAgB,CAAC,EACrC,GAAG,GACJ,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAmEtD"}
1
+ {"version":3,"file":"getAccessResults.d.ts","sourceRoot":"","sources":["../../src/auth/getAccessResults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAKnE,KAAK,oBAAoB,GAAG;IAC1B,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AACD,wBAAsB,gBAAgB,CAAC,EACrC,GAAG,GACJ,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAqEtD"}
@@ -1,4 +1,4 @@
1
- import { getEntityPolicies } from '../utilities/getEntityPolicies.js';
1
+ import { getEntityPermissions } from '../utilities/getEntityPermissions/getEntityPermissions.js';
2
2
  import { sanitizePermissions } from '../utilities/sanitizePermissions.js';
3
3
  export async function getAccessResults({ req }) {
4
4
  const results = {
@@ -15,7 +15,7 @@ export async function getAccessResults({ req }) {
15
15
  } else {
16
16
  results.canAccessAdmin = false;
17
17
  }
18
- const blockPolicies = {};
18
+ const blockReferencesPermissions = {};
19
19
  await Promise.all(payload.config.collections.map(async (collection)=>{
20
20
  const collectionOperations = [
21
21
  'create',
@@ -29,14 +29,15 @@ export async function getAccessResults({ req }) {
29
29
  if (collection.versions) {
30
30
  collectionOperations.push('readVersions');
31
31
  }
32
- const collectionPolicy = await getEntityPolicies({
33
- type: 'collection',
34
- blockPolicies,
32
+ const collectionPermissions = await getEntityPermissions({
33
+ blockReferencesPermissions,
35
34
  entity: collection,
35
+ entityType: 'collection',
36
+ fetchData: false,
36
37
  operations: collectionOperations,
37
38
  req
38
39
  });
39
- results.collections[collection.slug] = collectionPolicy;
40
+ results.collections[collection.slug] = collectionPermissions;
40
41
  }));
41
42
  await Promise.all(payload.config.globals.map(async (global)=>{
42
43
  const globalOperations = [
@@ -46,14 +47,15 @@ export async function getAccessResults({ req }) {
46
47
  if (global.versions) {
47
48
  globalOperations.push('readVersions');
48
49
  }
49
- const globalPolicy = await getEntityPolicies({
50
- type: 'global',
51
- blockPolicies,
50
+ const globalPermissions = await getEntityPermissions({
51
+ blockReferencesPermissions,
52
52
  entity: global,
53
+ entityType: 'global',
54
+ fetchData: false,
53
55
  operations: globalOperations,
54
56
  req
55
57
  });
56
- results.globals[global.slug] = globalPolicy;
58
+ results.globals[global.slug] = globalPermissions;
57
59
  }));
58
60
  return sanitizePermissions(results);
59
61
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/getAccessResults.ts"],"sourcesContent":["import type { AllOperations, PayloadRequest } from '../types/index.js'\nimport type { Permissions, SanitizedPermissions } from './types.js'\n\nimport { getEntityPolicies } from '../utilities/getEntityPolicies.js'\nimport { sanitizePermissions } from '../utilities/sanitizePermissions.js'\n\ntype GetAccessResultsArgs = {\n req: PayloadRequest\n}\nexport async function getAccessResults({\n req,\n}: GetAccessResultsArgs): Promise<SanitizedPermissions> {\n const results = {\n collections: {},\n globals: {},\n } as Permissions\n const { payload, user } = req\n\n const isLoggedIn = !!user\n const userCollectionConfig =\n user && user.collection ? payload?.collections?.[user.collection]?.config : null\n\n if (userCollectionConfig && payload.config.admin.user === user?.collection) {\n results.canAccessAdmin = userCollectionConfig.access.admin\n ? await userCollectionConfig.access.admin({ req })\n : isLoggedIn\n } else {\n results.canAccessAdmin = false\n }\n const blockPolicies = {}\n\n await Promise.all(\n payload.config.collections.map(async (collection) => {\n const collectionOperations: AllOperations[] = ['create', 'read', 'update', 'delete']\n\n if (\n collection.auth &&\n typeof collection.auth.maxLoginAttempts !== 'undefined' &&\n collection.auth.maxLoginAttempts !== 0\n ) {\n collectionOperations.push('unlock')\n }\n\n if (collection.versions) {\n collectionOperations.push('readVersions')\n }\n\n const collectionPolicy = await getEntityPolicies({\n type: 'collection',\n blockPolicies,\n entity: collection,\n operations: collectionOperations,\n req,\n })\n results.collections![collection.slug] = collectionPolicy\n }),\n )\n\n await Promise.all(\n payload.config.globals.map(async (global) => {\n const globalOperations: AllOperations[] = ['read', 'update']\n\n if (global.versions) {\n globalOperations.push('readVersions')\n }\n\n const globalPolicy = await getEntityPolicies({\n type: 'global',\n blockPolicies,\n entity: global,\n operations: globalOperations,\n req,\n })\n results.globals![global.slug] = globalPolicy\n }),\n )\n\n return sanitizePermissions(results)\n}\n"],"names":["getEntityPolicies","sanitizePermissions","getAccessResults","req","results","collections","globals","payload","user","isLoggedIn","userCollectionConfig","collection","config","admin","canAccessAdmin","access","blockPolicies","Promise","all","map","collectionOperations","auth","maxLoginAttempts","push","versions","collectionPolicy","type","entity","operations","slug","global","globalOperations","globalPolicy"],"mappings":"AAGA,SAASA,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,mBAAmB,QAAQ,sCAAqC;AAKzE,OAAO,eAAeC,iBAAiB,EACrCC,GAAG,EACkB;IACrB,MAAMC,UAAU;QACdC,aAAa,CAAC;QACdC,SAAS,CAAC;IACZ;IACA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAGL;IAE1B,MAAMM,aAAa,CAAC,CAACD;IACrB,MAAME,uBACJF,QAAQA,KAAKG,UAAU,GAAGJ,SAASF,aAAa,CAACG,KAAKG,UAAU,CAAC,EAAEC,SAAS;IAE9E,IAAIF,wBAAwBH,QAAQK,MAAM,CAACC,KAAK,CAACL,IAAI,KAAKA,MAAMG,YAAY;QAC1EP,QAAQU,cAAc,GAAGJ,qBAAqBK,MAAM,CAACF,KAAK,GACtD,MAAMH,qBAAqBK,MAAM,CAACF,KAAK,CAAC;YAAEV;QAAI,KAC9CM;IACN,OAAO;QACLL,QAAQU,cAAc,GAAG;IAC3B;IACA,MAAME,gBAAgB,CAAC;IAEvB,MAAMC,QAAQC,GAAG,CACfX,QAAQK,MAAM,CAACP,WAAW,CAACc,GAAG,CAAC,OAAOR;QACpC,MAAMS,uBAAwC;YAAC;YAAU;YAAQ;YAAU;SAAS;QAEpF,IACET,WAAWU,IAAI,IACf,OAAOV,WAAWU,IAAI,CAACC,gBAAgB,KAAK,eAC5CX,WAAWU,IAAI,CAACC,gBAAgB,KAAK,GACrC;YACAF,qBAAqBG,IAAI,CAAC;QAC5B;QAEA,IAAIZ,WAAWa,QAAQ,EAAE;YACvBJ,qBAAqBG,IAAI,CAAC;QAC5B;QAEA,MAAME,mBAAmB,MAAMzB,kBAAkB;YAC/C0B,MAAM;YACNV;YACAW,QAAQhB;YACRiB,YAAYR;YACZjB;QACF;QACAC,QAAQC,WAAW,AAAC,CAACM,WAAWkB,IAAI,CAAC,GAAGJ;IAC1C;IAGF,MAAMR,QAAQC,GAAG,CACfX,QAAQK,MAAM,CAACN,OAAO,CAACa,GAAG,CAAC,OAAOW;QAChC,MAAMC,mBAAoC;YAAC;YAAQ;SAAS;QAE5D,IAAID,OAAON,QAAQ,EAAE;YACnBO,iBAAiBR,IAAI,CAAC;QACxB;QAEA,MAAMS,eAAe,MAAMhC,kBAAkB;YAC3C0B,MAAM;YACNV;YACAW,QAAQG;YACRF,YAAYG;YACZ5B;QACF;QACAC,QAAQE,OAAO,AAAC,CAACwB,OAAOD,IAAI,CAAC,GAAGG;IAClC;IAGF,OAAO/B,oBAAoBG;AAC7B"}
1
+ {"version":3,"sources":["../../src/auth/getAccessResults.ts"],"sourcesContent":["import type { AllOperations, PayloadRequest } from '../types/index.js'\nimport type { Permissions, SanitizedPermissions } from './types.js'\n\nimport { getEntityPermissions } from '../utilities/getEntityPermissions/getEntityPermissions.js'\nimport { sanitizePermissions } from '../utilities/sanitizePermissions.js'\n\ntype GetAccessResultsArgs = {\n req: PayloadRequest\n}\nexport async function getAccessResults({\n req,\n}: GetAccessResultsArgs): Promise<SanitizedPermissions> {\n const results = {\n collections: {},\n globals: {},\n } as Permissions\n const { payload, user } = req\n\n const isLoggedIn = !!user\n const userCollectionConfig =\n user && user.collection ? payload?.collections?.[user.collection]?.config : null\n\n if (userCollectionConfig && payload.config.admin.user === user?.collection) {\n results.canAccessAdmin = userCollectionConfig.access.admin\n ? await userCollectionConfig.access.admin({ req })\n : isLoggedIn\n } else {\n results.canAccessAdmin = false\n }\n const blockReferencesPermissions = {}\n\n await Promise.all(\n payload.config.collections.map(async (collection) => {\n const collectionOperations: AllOperations[] = ['create', 'read', 'update', 'delete']\n\n if (\n collection.auth &&\n typeof collection.auth.maxLoginAttempts !== 'undefined' &&\n collection.auth.maxLoginAttempts !== 0\n ) {\n collectionOperations.push('unlock')\n }\n\n if (collection.versions) {\n collectionOperations.push('readVersions')\n }\n\n const collectionPermissions = await getEntityPermissions({\n blockReferencesPermissions,\n entity: collection,\n entityType: 'collection',\n fetchData: false,\n operations: collectionOperations,\n req,\n })\n results.collections![collection.slug] = collectionPermissions\n }),\n )\n\n await Promise.all(\n payload.config.globals.map(async (global) => {\n const globalOperations: AllOperations[] = ['read', 'update']\n\n if (global.versions) {\n globalOperations.push('readVersions')\n }\n\n const globalPermissions = await getEntityPermissions({\n blockReferencesPermissions,\n entity: global,\n entityType: 'global',\n fetchData: false,\n operations: globalOperations,\n req,\n })\n results.globals![global.slug] = globalPermissions\n }),\n )\n\n return sanitizePermissions(results)\n}\n"],"names":["getEntityPermissions","sanitizePermissions","getAccessResults","req","results","collections","globals","payload","user","isLoggedIn","userCollectionConfig","collection","config","admin","canAccessAdmin","access","blockReferencesPermissions","Promise","all","map","collectionOperations","auth","maxLoginAttempts","push","versions","collectionPermissions","entity","entityType","fetchData","operations","slug","global","globalOperations","globalPermissions"],"mappings":"AAGA,SAASA,oBAAoB,QAAQ,4DAA2D;AAChG,SAASC,mBAAmB,QAAQ,sCAAqC;AAKzE,OAAO,eAAeC,iBAAiB,EACrCC,GAAG,EACkB;IACrB,MAAMC,UAAU;QACdC,aAAa,CAAC;QACdC,SAAS,CAAC;IACZ;IACA,MAA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AU,QAAQK;YACRJ,YAAY;YACZC,WAAW;YACXC,YAAYG;YACZ7B;QACF;QACAC,QAAQE,OAAO,AAAC,CAACyB,OAAOD,IAAI,CAAC,GAAGG;IAClC;IAGF,OAAOhC,oBAAoBG;AAC7B"}
@@ -22,16 +22,16 @@ export type SanitizedBlockPermissions = {
22
22
  } | true;
23
23
  export type BlocksPermissions = {
24
24
  [blockSlug: string]: BlockPermissions;
25
- } | true;
25
+ };
26
26
  export type SanitizedBlocksPermissions = {
27
27
  [blockSlug: string]: SanitizedBlockPermissions;
28
28
  } | true;
29
29
  export type FieldPermissions = {
30
30
  blocks?: BlocksPermissions;
31
- create: Permission;
31
+ create?: Permission;
32
32
  fields?: FieldsPermissions;
33
- read: Permission;
34
- update: Permission;
33
+ read?: Permission;
34
+ update?: Permission;
35
35
  };
36
36
  export type SanitizedFieldPermissions = {
37
37
  blocks?: SanitizedBlocksPermissions;
@@ -44,12 +44,13 @@ export type SanitizedFieldsPermissions = {
44
44
  [fieldName: string]: SanitizedFieldPermissions;
45
45
  } | true;
46
46
  export type CollectionPermission = {
47
- create: Permission;
48
- delete: Permission;
47
+ create?: Permission;
48
+ delete?: Permission;
49
49
  fields: FieldsPermissions;
50
- read: Permission;
50
+ read?: Permission;
51
51
  readVersions?: Permission;
52
- update: Permission;
52
+ unlock?: Permission;
53
+ update?: Permission;
53
54
  };
54
55
  export type SanitizedCollectionPermission = {
55
56
  create?: true;
@@ -57,13 +58,14 @@ export type SanitizedCollectionPermission = {
57
58
  fields: SanitizedFieldsPermissions;
58
59
  read?: true;
59
60
  readVersions?: true;
61
+ unlock?: true;
60
62
  update?: true;
61
63
  };
62
64
  export type GlobalPermission = {
63
65
  fields: FieldsPermissions;
64
- read: Permission;
66
+ read?: Permission;
65
67
  readVersions?: Permission;
66
- update: Permission;
68
+ update?: Permission;
67
69
  };
68
70
  export type SanitizedGlobalPermission = {
69
71
  fields: SanitizedFieldsPermissions;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d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eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB;;;OAGG;IACH,MAAM,CAAC,EACH;QACE,iBAAiB,CAAC,EAAE,uBAAuB,CAAA;QAC3C,oBAAoB,CAAC,EAAE,0BAA0B,CAAA;KAClD,GACD,OAAO,CAAA;CACZ;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,iBAAiB,CAAC,EAAE,uBAAuB,CAAA;IAC3C,oBAAoB,CAAC,EAAE,0BAA0B,CAAA;CAClD,CAAA;AAED,MAAM,WAAW,IACf,SAAQ,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,mBAAmB,GAAG,QAAQ,CAAC;IAC/F,cAAc,CAAC,EAAE;QACf,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,iBAAiB,CAAC,EAAE,+BAA+B,CAAA;QACnD,oBAAoB,CAAC,EAAE,kCAAkC,CAAA;KAC1D,CAAA;IACD,iBAAiB,EAAE,KAAK,GAAG,wBAAwB,CAAA;IACnD,MAAM,CAAC,EAAE,OAAO,GAAG,YAAY,CAAA;CAChC;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,IAAI,KAAK,CAE7E"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/types.ts"],"sourcesContent":["import type { DeepRequired } from 'ts-essentials'\n\nimport type { CollectionSlug, GlobalSlug, Payload, TypedUser } from '../index.js'\nimport type { PayloadRequest, Where } from '../types/index.js'\n\n/**\n * A permission object that can be used to determine if a user has access to a specific operation.\n */\nexport type Permission = {\n permission: boolean\n where?: Where\n}\n\nexport type FieldsPermissions = {\n [fieldName: string]: FieldPermissions\n}\n\nexport type BlockPermissions = {\n create: Permission\n fields: FieldsPermissions\n read: Permission\n update: Permission\n}\n\nexport type SanitizedBlockPermissions =\n | {\n fields: SanitizedFieldsPermissions\n }\n | true\n\nexport type BlocksPermissions =\n | {\n [blockSlug: string]: BlockPermissions\n }\n | true\n\nexport type SanitizedBlocksPermissions =\n | {\n [blockSlug: string]: SanitizedBlockPermissions\n }\n | true\n\nexport type FieldPermissions = {\n blocks?: BlocksPermissions\n create: Permission\n fields?: FieldsPermissions\n read: Permission\n update: Permission\n}\n\nexport type SanitizedFieldPermissions =\n | {\n blocks?: SanitizedBlocksPermissions\n create: true\n fields?: SanitizedFieldsPermissions\n read: true\n update: true\n }\n | true\n\nexport type SanitizedFieldsPermissions =\n | {\n [fieldName: string]: SanitizedFieldPermissions\n }\n | true\n\nexport type CollectionPermission = {\n create: Permission\n delete: Permission\n fields: FieldsPermissions\n read: Permission\n readVersions?: Permission\n update: Permission\n}\n\nexport type SanitizedCollectionPermission = {\n create?: true\n delete?: true\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: true\n update?: true\n}\n\nexport type GlobalPermission = {\n fields: FieldsPermissions\n read: Permission\n readVersions?: Permission\n update: Permission\n}\n\nexport type SanitizedGlobalPermission = {\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: true\n update?: true\n}\n\nexport type DocumentPermissions = CollectionPermission | GlobalPermission\n\nexport type SanitizedDocumentPermissions = SanitizedCollectionPermission | SanitizedGlobalPermission\n\nexport type Permissions = {\n canAccessAdmin: boolean\n collections?: Record<CollectionSlug, CollectionPermission>\n globals?: Record<GlobalSlug, GlobalPermission>\n}\n\nexport type SanitizedPermissions = {\n canAccessAdmin?: boolean\n collections?: {\n [collectionSlug: string]: SanitizedCollectionPermission\n }\n globals?: {\n [globalSlug: string]: SanitizedGlobalPermission\n }\n}\n\ntype BaseUser = {\n collection: string\n email?: string\n id: number | string\n sessions?: Array<UserSession>\n username?: string\n}\n\n/**\n * @deprecated Use `TypedUser` instead. This will be removed in 4.0.\n */\nexport type UntypedUser = {\n [key: string]: any\n} & BaseUser\n\n/**\n * `collection` is not available one the client. It's only available on the server (req.user)\n * On the client, you can access the collection via config.admin.user. Config can be accessed using the useConfig() hook\n */\nexport type ClientUser = {\n [key: string]: any\n} & BaseUser\n\nexport type UserSession = { createdAt: Date | string; expiresAt: Date | string; id: string }\ntype GenerateVerifyEmailHTML<TUser = any> = (args: {\n req: PayloadRequest\n token: string\n user: TUser\n}) => Promise<string> | string\n\ntype GenerateVerifyEmailSubject<TUser = any> = (args: {\n req: PayloadRequest\n token: string\n user: TUser\n}) => Promise<string> | string\n\ntype GenerateForgotPasswordEmailHTML<TUser = any> = (args?: {\n req?: PayloadRequest\n token?: string\n user?: TUser\n}) => Promise<string> | string\n\ntype GenerateForgotPasswordEmailSubject<TUser = any> = (args?: {\n req?: PayloadRequest\n token?: string\n user?: TUser\n}) => Promise<string> | string\n\nexport type AuthStrategyFunctionArgs = {\n /**\n * Specifies whether or not response headers can be set from this strategy.\n */\n canSetHeaders?: boolean\n headers: Request['headers']\n isGraphQL?: boolean\n payload: Payload\n /**\n * The AuthStrategy name property from the payload config.\n */\n strategyName?: string\n}\n\nexport type AuthStrategyResult = {\n responseHeaders?: Headers\n user:\n | ({\n _strategy?: string\n collection?: string\n } & TypedUser)\n | null\n}\n\nexport type AuthStrategyFunction = (\n args: AuthStrategyFunctionArgs,\n) => AuthStrategyResult | Promise<AuthStrategyResult>\nexport type AuthStrategy = {\n authenticate: AuthStrategyFunction\n name: string\n}\n\nexport type LoginWithUsernameOptions =\n | {\n allowEmailLogin?: false\n requireEmail?: boolean\n // If `allowEmailLogin` is false, `requireUsername` must be true (default: true)\n requireUsername?: true\n }\n | {\n allowEmailLogin?: true\n requireEmail?: boolean\n requireUsername?: boolean\n }\n\nexport interface IncomingAuthType {\n /**\n * Set cookie options, including secure, sameSite, and domain. For advanced users.\n */\n cookies?: {\n domain?: string\n sameSite?: 'Lax' | 'None' | 'Strict' | boolean\n secure?: boolean\n }\n /**\n * How many levels deep a user document should be populated when creating the JWT and binding the user to the req. Defaults to 0 and should only be modified if absolutely necessary, as this will affect performance.\n * @default 0\n */\n depth?: number\n /**\n * Advanced - disable Payload's built-in local auth strategy. Only use this property if you have replaced Payload's auth mechanisms with your own.\n */\n disableLocalStrategy?:\n | {\n /**\n * Include auth fields on the collection even though the local strategy is disabled.\n * Useful when you do not want the database or types to vary depending on the auth configuration.\n */\n enableFields?: true\n optionalPassword?: true\n }\n | true\n /**\n * Customize the way that the forgotPassword operation functions.\n * @link https://payloadcms.com/docs/authentication/email#forgot-password\n */\n forgotPassword?: {\n /**\n * The number of milliseconds that the forgot password token should be valid for.\n * @default 3600000 // 1 hour\n */\n expiration?: number\n generateEmailHTML?: GenerateForgotPasswordEmailHTML\n generateEmailSubject?: GenerateForgotPasswordEmailSubject\n }\n /**\n * Set the time (in milliseconds) that a user should be locked out if they fail authentication more times than maxLoginAttempts allows for.\n */\n lockTime?: number\n /**\n * Ability to allow users to login with username/password.\n *\n * @link https://payloadcms.com/docs/authentication/overview#login-with-username\n */\n loginWithUsername?: boolean | LoginWithUsernameOptions\n /**\n * Only allow a user to attempt logging in X amount of times. Automatically locks out a user from authenticating if this limit is passed. Set to 0 to disable.\n */\n maxLoginAttempts?: number\n /***\n * Set to true if you want to remove the token from the returned authentication API responses such as login or refresh.\n */\n removeTokenFromResponses?: true\n /**\n * Advanced - an array of custom authentification strategies to extend this collection's authentication with.\n * @link https://payloadcms.com/docs/authentication/custom-strategies\n */\n strategies?: AuthStrategy[]\n /**\n * Controls how many seconds the token will be valid for. Default is 2 hours.\n * @default 7200\n * @link https://payloadcms.com/docs/authentication/overview#config-options\n */\n tokenExpiration?: number\n /**\n * Payload Authentication provides for API keys to be set on each user within an Authentication-enabled Collection.\n * @default false\n * @link https://payloadcms.com/docs/authentication/api-keys\n */\n useAPIKey?: boolean\n\n /**\n * Use sessions for authentication. Enabled by default.\n * @default true\n */\n useSessions?: boolean\n\n /**\n * Set to true or pass an object with verification options to require users to verify by email before they are allowed to log into your app.\n * @link https://payloadcms.com/docs/authentication/email#email-verification\n */\n verify?:\n | {\n generateEmailHTML?: GenerateVerifyEmailHTML\n generateEmailSubject?: GenerateVerifyEmailSubject\n }\n | boolean\n}\n\nexport type VerifyConfig = {\n generateEmailHTML?: GenerateVerifyEmailHTML\n generateEmailSubject?: GenerateVerifyEmailSubject\n}\n\nexport interface Auth\n extends Omit<DeepRequired<IncomingAuthType>, 'forgotPassword' | 'loginWithUsername' | 'verify'> {\n forgotPassword?: {\n expiration?: number\n generateEmailHTML?: GenerateForgotPasswordEmailHTML\n generateEmailSubject?: GenerateForgotPasswordEmailSubject\n }\n loginWithUsername: false | LoginWithUsernameOptions\n verify?: boolean | VerifyConfig\n}\n\nexport function hasWhereAccessResult(result: boolean | Where): result is Where {\n return result && typeof result === 'object'\n}\n"],"names":["hasWhereAccessResult","result"],"mappings":"AAiUA,OAAO,SAASA,qBAAqBC,MAAuB;IAC1D,OAAOA,UAAU,OAAOA,WAAW;AACrC"}
1
+ {"version":3,"sources":["../../src/auth/types.ts"],"sourcesContent":["import type { DeepRequired } from 'ts-essentials'\n\nimport type { CollectionSlug, GlobalSlug, Payload, TypedUser } from '../index.js'\nimport type { PayloadRequest, Where } from '../types/index.js'\n\n/**\n * A permission object that can be used to determine if a user has access to a specific operation.\n */\nexport type Permission = {\n permission: boolean\n where?: Where\n}\n\nexport type FieldsPermissions = {\n [fieldName: string]: FieldPermissions\n}\n\nexport type BlockPermissions = {\n create: Permission\n fields: FieldsPermissions\n read: Permission\n update: Permission\n}\n\nexport type SanitizedBlockPermissions =\n | {\n fields: SanitizedFieldsPermissions\n }\n | true\n\nexport type BlocksPermissions = {\n [blockSlug: string]: BlockPermissions\n}\n\nexport type SanitizedBlocksPermissions =\n | {\n [blockSlug: string]: SanitizedBlockPermissions\n }\n | true\n\nexport type FieldPermissions = {\n blocks?: BlocksPermissions\n create?: Permission\n fields?: FieldsPermissions\n read?: Permission\n update?: Permission\n}\n\nexport type SanitizedFieldPermissions =\n | {\n blocks?: SanitizedBlocksPermissions\n create: true\n fields?: SanitizedFieldsPermissions\n read: true\n update: true\n }\n | true\n\nexport type SanitizedFieldsPermissions =\n | {\n [fieldName: string]: SanitizedFieldPermissions\n }\n | true\n\nexport type CollectionPermission = {\n create?: Permission\n delete?: Permission\n fields: FieldsPermissions\n read?: Permission\n readVersions?: Permission\n // Auth-enabled Collections only\n unlock?: Permission\n update?: Permission\n}\n\nexport type SanitizedCollectionPermission = {\n create?: true\n delete?: true\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: true\n // Auth-enabled Collections only\n unlock?: true\n update?: true\n}\n\nexport type GlobalPermission = {\n fields: FieldsPermissions\n read?: Permission\n readVersions?: Permission\n update?: Permission\n}\n\nexport type SanitizedGlobalPermission = {\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: true\n update?: true\n}\n\nexport type DocumentPermissions = CollectionPermission | GlobalPermission\n\nexport type SanitizedDocumentPermissions = SanitizedCollectionPermission | SanitizedGlobalPermission\n\nexport type Permissions = {\n canAccessAdmin: boolean\n collections?: Record<CollectionSlug, CollectionPermission>\n globals?: Record<GlobalSlug, GlobalPermission>\n}\n\nexport type SanitizedPermissions = {\n canAccessAdmin?: boolean\n collections?: {\n [collectionSlug: string]: SanitizedCollectionPermission\n }\n globals?: {\n [globalSlug: string]: SanitizedGlobalPermission\n }\n}\n\ntype BaseUser = {\n collection: string\n email?: string\n id: number | string\n sessions?: Array<UserSession>\n username?: string\n}\n\n/**\n * @deprecated Use `TypedUser` instead. This will be removed in 4.0.\n */\nexport type UntypedUser = {\n [key: string]: any\n} & BaseUser\n\n/**\n * `collection` is not available one the client. It's only available on the server (req.user)\n * On the client, you can access the collection via config.admin.user. Config can be accessed using the useConfig() hook\n */\nexport type ClientUser = {\n [key: string]: any\n} & BaseUser\n\nexport type UserSession = { createdAt: Date | string; expiresAt: Date | string; id: string }\ntype GenerateVerifyEmailHTML<TUser = any> = (args: {\n req: PayloadRequest\n token: string\n user: TUser\n}) => Promise<string> | string\n\ntype GenerateVerifyEmailSubject<TUser = any> = (args: {\n req: PayloadRequest\n token: string\n user: TUser\n}) => Promise<string> | string\n\ntype GenerateForgotPasswordEmailHTML<TUser = any> = (args?: {\n req?: PayloadRequest\n token?: string\n user?: TUser\n}) => Promise<string> | string\n\ntype GenerateForgotPasswordEmailSubject<TUser = any> = (args?: {\n req?: PayloadRequest\n token?: string\n user?: TUser\n}) => Promise<string> | string\n\nexport type AuthStrategyFunctionArgs = {\n /**\n * Specifies whether or not response headers can be set from this strategy.\n */\n canSetHeaders?: boolean\n headers: Request['headers']\n isGraphQL?: boolean\n payload: Payload\n /**\n * The AuthStrategy name property from the payload config.\n */\n strategyName?: string\n}\n\nexport type AuthStrategyResult = {\n responseHeaders?: Headers\n user:\n | ({\n _strategy?: string\n collection?: string\n } & TypedUser)\n | null\n}\n\nexport type AuthStrategyFunction = (\n args: AuthStrategyFunctionArgs,\n) => AuthStrategyResult | Promise<AuthStrategyResult>\nexport type AuthStrategy = {\n authenticate: AuthStrategyFunction\n name: string\n}\n\nexport type LoginWithUsernameOptions =\n | {\n allowEmailLogin?: false\n requireEmail?: boolean\n // If `allowEmailLogin` is false, `requireUsername` must be true (default: true)\n requireUsername?: true\n }\n | {\n allowEmailLogin?: true\n requireEmail?: boolean\n requireUsername?: boolean\n }\n\nexport interface IncomingAuthType {\n /**\n * Set cookie options, including secure, sameSite, and domain. For advanced users.\n */\n cookies?: {\n domain?: string\n sameSite?: 'Lax' | 'None' | 'Strict' | boolean\n secure?: boolean\n }\n /**\n * How many levels deep a user document should be populated when creating the JWT and binding the user to the req. Defaults to 0 and should only be modified if absolutely necessary, as this will affect performance.\n * @default 0\n */\n depth?: number\n /**\n * Advanced - disable Payload's built-in local auth strategy. Only use this property if you have replaced Payload's auth mechanisms with your own.\n */\n disableLocalStrategy?:\n | {\n /**\n * Include auth fields on the collection even though the local strategy is disabled.\n * Useful when you do not want the database or types to vary depending on the auth configuration.\n */\n enableFields?: true\n optionalPassword?: true\n }\n | true\n /**\n * Customize the way that the forgotPassword operation functions.\n * @link https://payloadcms.com/docs/authentication/email#forgot-password\n */\n forgotPassword?: {\n /**\n * The number of milliseconds that the forgot password token should be valid for.\n * @default 3600000 // 1 hour\n */\n expiration?: number\n generateEmailHTML?: GenerateForgotPasswordEmailHTML\n generateEmailSubject?: GenerateForgotPasswordEmailSubject\n }\n /**\n * Set the time (in milliseconds) that a user should be locked out if they fail authentication more times than maxLoginAttempts allows for.\n */\n lockTime?: number\n /**\n * Ability to allow users to login with username/password.\n *\n * @link https://payloadcms.com/docs/authentication/overview#login-with-username\n */\n loginWithUsername?: boolean | LoginWithUsernameOptions\n /**\n * Only allow a user to attempt logging in X amount of times. Automatically locks out a user from authenticating if this limit is passed. Set to 0 to disable.\n */\n maxLoginAttempts?: number\n /***\n * Set to true if you want to remove the token from the returned authentication API responses such as login or refresh.\n */\n removeTokenFromResponses?: true\n /**\n * Advanced - an array of custom authentification strategies to extend this collection's authentication with.\n * @link https://payloadcms.com/docs/authentication/custom-strategies\n */\n strategies?: AuthStrategy[]\n /**\n * Controls how many seconds the token will be valid for. Default is 2 hours.\n * @default 7200\n * @link https://payloadcms.com/docs/authentication/overview#config-options\n */\n tokenExpiration?: number\n /**\n * Payload Authentication provides for API keys to be set on each user within an Authentication-enabled Collection.\n * @default false\n * @link https://payloadcms.com/docs/authentication/api-keys\n */\n useAPIKey?: boolean\n\n /**\n * Use sessions for authentication. Enabled by default.\n * @default true\n */\n useSessions?: boolean\n\n /**\n * Set to true or pass an object with verification options to require users to verify by email before they are allowed to log into your app.\n * @link https://payloadcms.com/docs/authentication/email#email-verification\n */\n verify?:\n | {\n generateEmailHTML?: GenerateVerifyEmailHTML\n generateEmailSubject?: GenerateVerifyEmailSubject\n }\n | boolean\n}\n\nexport type VerifyConfig = {\n generateEmailHTML?: GenerateVerifyEmailHTML\n generateEmailSubject?: GenerateVerifyEmailSubject\n}\n\nexport interface Auth\n extends Omit<DeepRequired<IncomingAuthType>, 'forgotPassword' | 'loginWithUsername' | 'verify'> {\n forgotPassword?: {\n expiration?: number\n generateEmailHTML?: GenerateForgotPasswordEmailHTML\n generateEmailSubject?: GenerateForgotPasswordEmailSubject\n }\n loginWithUsername: false | LoginWithUsernameOptions\n verify?: boolean | VerifyConfig\n}\n\nexport function hasWhereAccessResult(result: boolean | Where): result is Where {\n return result && typeof result === 'object'\n}\n"],"names":["hasWhereAccessResult","result"],"mappings":"AAmUA,OAAO,SAASA,qBAAqBC,MAAuB;IAC1D,OAAOA,UAAU,OAAOA,WAAW;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"countVersions.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/countVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAMpD,OAAO,EAAgC,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIlF,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAGD,eAAO,MAAM,sBAAsB,GAAU,KAAK,SAAS,cAAc,gBACzD,SAAS,KACtB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CA6F/B,CAAA"}
1
+ {"version":3,"file":"countVersions.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/countVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAMpD,OAAO,EAAgC,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIlF,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAGD,eAAO,MAAM,sBAAsB,GAAU,KAAK,SAAS,cAAc,gBACzD,SAAS,KACtB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CA8F/B,CAAA"}
@@ -24,7 +24,7 @@ export const countVersionsOperation = async (incomingArgs)=>{
24
24
  }
25
25
  }
26
26
  const { collection: { config: collectionConfig }, disableErrors, overrideAccess, req, where } = args;
27
- const { payload } = req;
27
+ const { locale, payload } = req;
28
28
  // /////////////////////////////////////
29
29
  // Access
30
30
  // /////////////////////////////////////
@@ -58,6 +58,7 @@ export const countVersionsOperation = async (incomingArgs)=>{
58
58
  });
59
59
  result = await payload.db.countVersions({
60
60
  collection: collectionConfig.slug,
61
+ locale: locale,
61
62
  req,
62
63
  where: fullWhere
63
64
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/operations/countVersions.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\nimport type { Collection } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { buildVersionCollectionFields, type CollectionSlug } from '../../index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { buildAfterOperation } from './utils.js'\n\nexport type Arguments = {\n collection: Collection\n disableErrors?: boolean\n overrideAccess?: boolean\n req?: PayloadRequest\n where?: Where\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const countVersionsOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments,\n): Promise<{ totalDocs: number }> => {\n let args = incomingArgs\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n if (args.collection.config.hooks.beforeOperation?.length) {\n for (const hook of args.collection.config.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req!.context,\n operation: 'countVersions',\n req: args.req!,\n })) || args\n }\n }\n\n const {\n collection: { config: collectionConfig },\n disableErrors,\n overrideAccess,\n req,\n where,\n } = args\n\n const { payload } = req!\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess(\n { disableErrors, req: req! },\n collectionConfig.access.readVersions,\n )\n\n // If errors are disabled, and access returns false, return empty results\n if (accessResult === false) {\n return {\n totalDocs: 0,\n }\n }\n }\n\n let result: { totalDocs: number }\n\n const fullWhere = combineQueries(where!, accessResult!)\n\n const versionFields = buildVersionCollectionFields(payload.config, collectionConfig, true)\n\n sanitizeWhereQuery({ fields: versionFields, payload, where: fullWhere })\n\n await validateQueryPaths({\n collectionConfig,\n overrideAccess: overrideAccess!,\n req: req!,\n versionFields,\n where: where!,\n })\n\n result = await payload.db.countVersions({\n collection: collectionConfig.slug,\n req,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'countVersions',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req!)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","sanitizeWhereQuery","buildVersionCollectionFields","killTransaction","buildAfterOperation","countVersionsOperation","incomingArgs","args","collection","config","hooks","beforeOperation","length","hook","context","req","operation","collectionConfig","disableErrors","overrideAccess","where","payload","accessResult","access","readVersions","totalDocs","result","fullWhere","versionFields","fields","db","countVersions","slug","error"],"mappings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AAQZ,MAAM,EAAEQ,kBAAkB;QAErFhB,mBAAmB;YAAE4B,QAAQD;YAAeP;YAASD,OAAOO;QAAU;QAEtE,MAAM3B,mBAAmB;YACvBiB;YACAE,gBAAgBA;YAChBJ,KAAKA;YACLa;YACAR,OAAOA;QACT;QAEAM,SAAS,MAAML,QAAQS,EAAE,CAACC,aAAa,CAAC;YACtCvB,YAAYS,iBAAiBe,IAAI;YACjCjB;YACAK,OAAOO;QACT;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCD,SAAS,MAAMtB,oBAAoB;YACjCG;YACAC,YAAYS;YACZD,WAAW;YACXU;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IACT,EAAE,OAAOO,OAAgB;QACvB,MAAM9B,gBAAgBI,KAAKQ,GAAG;QAC9B,MAAMkB;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/operations/countVersions.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\nimport type { Collection } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { buildVersionCollectionFields, type CollectionSlug } from '../../index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { buildAfterOperation } from './utils.js'\n\nexport type Arguments = {\n collection: Collection\n disableErrors?: boolean\n overrideAccess?: boolean\n req?: PayloadRequest\n where?: Where\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const countVersionsOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments,\n): Promise<{ totalDocs: number }> => {\n let args = incomingArgs\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n if (args.collection.config.hooks.beforeOperation?.length) {\n for (const hook of args.collection.config.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req!.context,\n operation: 'countVersions',\n req: args.req!,\n })) || args\n }\n }\n\n const {\n collection: { config: collectionConfig },\n disableErrors,\n overrideAccess,\n req,\n where,\n } = args\n\n const { locale, payload } = req!\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess(\n { disableErrors, req: req! },\n collectionConfig.access.readVersions,\n )\n\n // If errors are disabled, and access returns false, return empty results\n if (accessResult === false) {\n return {\n totalDocs: 0,\n }\n }\n }\n\n let result: { totalDocs: number }\n\n const fullWhere = combineQueries(where!, accessResult!)\n\n const versionFields = buildVersionCollectionFields(payload.config, collectionConfig, true)\n\n sanitizeWhereQuery({ fields: versionFields, payload, where: fullWhere })\n\n await validateQueryPaths({\n collectionConfig,\n overrideAccess: overrideAccess!,\n req: req!,\n versionFields,\n where: where!,\n })\n\n result = await payload.db.countVersions({\n collection: collectionConfig.slug,\n locale: locale!,\n req,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'countVersions',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req!)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","sanitizeWhereQuery","buildVersionCollectionFields","killTransaction","buildAfterOperation","countVersionsOperation","incomingArgs","args","collection","config","hooks","beforeOperation","length","hook","context","req","operation","collectionConfig","disableErrors","overrideAccess","where","locale","payload","accessResult","access","readVersions","totalDocs","result","fullWhere","versionFields","fields","db","countVersions","slug","error"],"mappings":"AAIA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD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AEtE,MAAM5B,mBAAmB;YACvBiB;YACAE,gBAAgBA;YAChBJ,KAAKA;YACLc;YACAT,OAAOA;QACT;QAEAO,SAAS,MAAML,QAAQS,EAAE,CAACC,aAAa,CAAC;YACtCxB,YAAYS,iBAAiBgB,IAAI;YACjCZ,QAAQA;YACRN;YACAK,OAAOQ;QACT;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCD,SAAS,MAAMvB,oBAAoB;YACjCG;YACAC,YAAYS;YACZD,WAAW;YACXW;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IACT,EAAE,OAAOO,OAAgB;QACvB,MAAM/B,gBAAgBI,KAAKQ,GAAG;QAC9B,MAAMmB;IACR;AACF,EAAC"}
@@ -1,9 +1,16 @@
1
1
  import type { SanitizedCollectionPermission } from '../../auth/index.js';
2
- import type { PayloadRequest } from '../../types/index.js';
2
+ import type { JsonObject, PayloadRequest } from '../../types/index.js';
3
3
  import type { Collection } from '../config/types.js';
4
4
  type Arguments = {
5
5
  collection: Collection;
6
- id: number | string;
6
+ /**
7
+ * If the document data is passed, it will be used to check access instead of fetching the document from the database.
8
+ */
9
+ data?: JsonObject;
10
+ /**
11
+ * When called for creating a new document, id is not provided.
12
+ */
13
+ id?: number | string;
7
14
  req: PayloadRequest;
8
15
  };
9
16
  export declare function docAccessOperation(args: Arguments): Promise<SanitizedCollectionPermission>;
@@ -1 +1 @@
1
- {"version":3,"file":"docAccess.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/docAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAQpD,KAAK,SAAS,GAAG;IACf,UAAU,EAAE,UAAU,CAAA;IACtB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,6BAA6B,CAAC,CA2ChG"}
1
+ {"version":3,"file":"docAccess.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/docAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,EAAiB,UAAU,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAQpD,KAAK,SAAS,GAAG;IACf,UAAU,EAAE,UAAU,CAAA;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,6BAA6B,CAAC,CA8ChG"}
@@ -1,4 +1,4 @@
1
- import { getEntityPolicies } from '../../utilities/getEntityPolicies.js';
1
+ import { getEntityPermissions } from '../../utilities/getEntityPermissions/getEntityPermissions.js';
2
2
  import { killTransaction } from '../../utilities/killTransaction.js';
3
3
  import { sanitizePermissions } from '../../utilities/sanitizePermissions.js';
4
4
  const allOperations = [
@@ -8,7 +8,7 @@ const allOperations = [
8
8
  'delete'
9
9
  ];
10
10
  export async function docAccessOperation(args) {
11
- const { id, collection: { config }, req } = args;
11
+ const { id, collection: { config }, data, req } = args;
12
12
  const collectionOperations = [
13
13
  ...allOperations
14
14
  ];
@@ -19,11 +19,13 @@ export async function docAccessOperation(args) {
19
19
  collectionOperations.push('readVersions');
20
20
  }
21
21
  try {
22
- const result = await getEntityPolicies({
23
- id,
24
- type: 'collection',
25
- blockPolicies: {},
22
+ const result = await getEntityPermissions({
23
+ id: id,
24
+ blockReferencesPermissions: {},
25
+ data,
26
26
  entity: config,
27
+ entityType: 'collection',
28
+ fetchData: id ? true : false,
27
29
  operations: collectionOperations,
28
30
  req
29
31
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/operations/docAccess.ts"],"sourcesContent":["import type { SanitizedCollectionPermission } from '../../auth/index.js'\nimport type { AllOperations, PayloadRequest } from '../../types/index.js'\nimport type { Collection } from '../config/types.js'\n\nimport { getEntityPolicies } from '../../utilities/getEntityPolicies.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizePermissions } from '../../utilities/sanitizePermissions.js'\n\nconst allOperations: AllOperations[] = ['create', 'read', 'update', 'delete']\n\ntype Arguments = {\n collection: Collection\n id: number | string\n req: PayloadRequest\n}\n\nexport async function docAccessOperation(args: Arguments): Promise<SanitizedCollectionPermission> {\n const {\n id,\n collection: { config },\n req,\n } = args\n\n const collectionOperations = [...allOperations]\n\n if (\n config.auth &&\n typeof config.auth.maxLoginAttempts !== 'undefined' &&\n config.auth.maxLoginAttempts !== 0\n ) {\n collectionOperations.push('unlock')\n }\n\n if (config.versions) {\n collectionOperations.push('readVersions')\n }\n\n try {\n const result = await getEntityPolicies({\n id,\n type: 'collection',\n blockPolicies: {},\n entity: config,\n operations: collectionOperations,\n req,\n })\n\n const sanitizedPermissions = sanitizePermissions({\n collections: {\n [config.slug]: result,\n },\n })\n\n const collectionPermissions = sanitizedPermissions?.collections?.[config.slug]\n return collectionPermissions ?? { fields: {} }\n } catch (e: unknown) {\n await killTransaction(req)\n throw e\n }\n}\n"],"names":["getEntityPolicies","killTransaction","sanitizePermissions","allOperations","docAccessOperation","args","id","collection","config","req","collectionOperations","auth","maxLoginAttempts","push","versions","result","type","blockPolicies","entity","operations","sanitizedPermissions","collections","slug","collectionPermissions","fields","e"],"mappings":"AAIA,SAASA,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,mBAAmB,QAAQ,yCAAwC;AAE5E,MAAMC,gBAAiC;IAAC;IAAU;IAAQ;IAAU;CAAS;AAQ7E,OAAO,eAAeC,mBAAmBC,IAAe;IACtD,MAAM,EACJC,EAAE,EACFC,YAAY,EAAEC,MAAM,EAAE,EACtBC,GAAG,EACJ,GAAGJ;IAEJ,MAAMK,uBAAuB;WAAIP;KAAc;IAE/C,IACEK,OAAOG,IAAI,IACX,OAAOH,OAAOG,IAAI,CAACC,gBAAgB,KAAK,eACxCJ,OAAOG,IAAI,CAACC,gBAAgB,KAAK,GACjC;QACAF,qBAAqBG,IAAI,CAAC;IAC5B;IAEA,IAAIL,OAAOM,QAAQ,EAAE;QACnBJ,qBAAqBG,IAAI,CAAC;IAC5B;IAEA,IAAI;QACF,MAAME,SAAS,MAAMf,kBAAkB;YACrCM;YACAU,MAAM;YACNC,eAAe,CAAC;YAChBC,QAAQV;YACRW,YAAYT;YACZD;QACF;QAEA,MAAMW,uBAAuBlB,oBAAoB;YAC/CmB,aAAa;gBACX,CAACb,OAAOc,IAAI,CAAC,EAAEP;YACjB;QACF;QAEA,MAAMQ,wBAAwBH,sBAAsBC,aAAa,CAACb,OAAOc,IAAI,CAAC;QAC9E,OAAOC,yBAAyB;YAAEC,QAAQ,CAAC;QAAE;IAC/C,EAAE,OAAOC,GAAY;QACnB,MAAMxB,gBAAgBQ;QACtB,MAAMgB;IACR;AACF"}
1
+ {"version":3,"sources":["../../../src/collections/operations/docAccess.ts"],"sourcesContent":["import type { SanitizedCollectionPermission } from '../../auth/index.js'\nimport type { AllOperations, JsonObject, PayloadRequest } from '../../types/index.js'\nimport type { Collection } from '../config/types.js'\n\nimport { getEntityPermissions } from '../../utilities/getEntityPermissions/getEntityPermissions.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizePermissions } from '../../utilities/sanitizePermissions.js'\n\nconst allOperations: AllOperations[] = ['create', 'read', 'update', 'delete']\n\ntype Arguments = {\n collection: Collection\n /**\n * If the document data is passed, it will be used to check access instead of fetching the document from the database.\n */\n data?: JsonObject\n /**\n * When called for creating a new document, id is not provided.\n */\n id?: number | string\n req: PayloadRequest\n}\n\nexport async function docAccessOperation(args: Arguments): Promise<SanitizedCollectionPermission> {\n const {\n id,\n collection: { config },\n data,\n req,\n } = args\n\n const collectionOperations = [...allOperations]\n\n if (\n config.auth &&\n typeof config.auth.maxLoginAttempts !== 'undefined' &&\n config.auth.maxLoginAttempts !== 0\n ) {\n collectionOperations.push('unlock')\n }\n\n if (config.versions) {\n collectionOperations.push('readVersions')\n }\n\n try {\n const result = await getEntityPermissions({\n id: id!,\n blockReferencesPermissions: {},\n data,\n entity: config,\n entityType: 'collection',\n fetchData: id ? true : (false as true),\n operations: collectionOperations,\n req,\n })\n\n const sanitizedPermissions = sanitizePermissions({\n collections: {\n [config.slug]: result,\n },\n })\n\n const collectionPermissions = sanitizedPermissions?.collections?.[config.slug]\n return collectionPermissions ?? { fields: {} }\n } catch (e: unknown) {\n await killTransaction(req)\n throw e\n }\n}\n"],"names":["getEntityPermissions","killTransaction","sanitizePermissions","allOperations","docAccessOperation","args","id","collection","config","data","req","collectionOperations","auth","maxLoginAttempts","push","versions","result","blockReferencesPermissions","entity","entityType","fetchData","operations","sanitizedPermissions","collections","slug","collectionPermissions","fields","e"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,+DAA8D;AACnG,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,mBAAmB,QAAQ,yCAAwC;AAE5E,MAAMC,gBAAiC;IAAC;IAAU;IAAQ;IAAU;CAAS;AAe7E,OAAO,eAAeC,mBAAmBC,IAAe;IACtD,MAAM,EACJC,EAAE,EACFC,YAAY,EAAEC,MAAM,EAAE,EACtBC,IAAI,EACJC,GAAG,EACJ,GAAGL;IAEJ,MAAMM,uBAAuB;WAAIR;KAAc;IAE/C,IACEK,OAAOI,IAAI,IACX,OAAOJ,OAAOI,IAAI,CAACC,gBAAgB,KAAK,eACxCL,OAAOI,IAAI,CAACC,gBAAgB,KAAK,GACjC;QACAF,qBAAqBG,IAAI,CAAC;IAC5B;IAEA,IAAIN,OAAOO,QAAQ,EAAE;QACnBJ,qBAAqBG,IAAI,CAAC;IAC5B;IAEA,IAAI;QACF,MAAME,SAAS,MAAMhB,qBAAqB;YACxCM,IAAIA;YACJW,4BAA4B,CAAC;YAC7BR;YACAS,QAAQV;YACRW,YAAY;YACZC,WAAWd,KAAK,OAAQ;YACxBe,YAAYV;YACZD;QACF;QAEA,MAAMY,uBAAuBpB,oBAAoB;YAC/CqB,aAAa;gBACX,CAACf,OAAOgB,IAAI,CAAC,EAAER;YACjB;QACF;QAEA,MAAMS,wBAAwBH,sBAAsBC,aAAa,CAACf,OAAOgB,IAAI,CAAC;QAC9E,OAAOC,yBAAyB;YAAEC,QAAQ,CAAC;QAAE;IAC/C,EAAE,OAAOC,GAAY;QACnB,MAAM1B,gBAAgBS;QACtB,MAAMiB;IACR;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/restoreVersion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAmBhE,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,uBAAuB,GAClC,KAAK,SAAS,UAAU,GAAG,UAAU,kCAE/B,SAAS,KACd,OAAO,CAAC,KAAK,CAiVf,CAAA"}
1
+ {"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/restoreVersion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAmBhE,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,uBAAuB,GAClC,KAAK,SAAS,UAAU,GAAG,UAAU,kCAE/B,SAAS,KACd,OAAO,CAAC,KAAK,CAmVf,CAAA"}
@@ -201,13 +201,15 @@ export const restoreVersionOperation = async (args)=>{
201
201
  result.updatedAt = new Date().toISOString();
202
202
  // Ensure status respects restoreAsDraft arg
203
203
  result._status = draftArg ? 'draft' : result._status;
204
- result = await req.payload.db.updateOne({
205
- id: parentDocID,
206
- collection: collectionConfig.slug,
207
- data: result,
208
- req,
209
- select
210
- });
204
+ if (!draftArg) {
205
+ result = await req.payload.db.updateOne({
206
+ id: parentDocID,
207
+ collection: collectionConfig.slug,
208
+ data: result,
209
+ req,
210
+ select
211
+ });
212
+ }
211
213
  // /////////////////////////////////////
212
214
  // Save restored doc as a new version
213
215
  // /////////////////////////////////////
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/operations/restoreVersion.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { FindOneArgs } from '../../database/types.js'\nimport type { JsonObject, PayloadRequest, PopulateType, SelectType } from '../../types/index.js'\nimport type { Collection, TypeWithID } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { hasWhereAccessResult } from '../../auth/types.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { APIError, Forbidden, NotFound } from '../../errors/index.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { getLatestCollectionVersion } from '../../versions/getLatestCollectionVersion.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\nimport { buildAfterOperation } from './utils.js'\n\nexport type Arguments = {\n collection: Collection\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n disableTransaction?: boolean\n draft?: boolean\n id: number | string\n overrideAccess?: boolean\n populate?: PopulateType\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n}\n\nexport const restoreVersionOperation = async <\n TData extends JsonObject & TypeWithID = JsonObject & TypeWithID,\n>(\n args: Arguments,\n): Promise<TData> => {\n const {\n id,\n collection: { config: collectionConfig },\n depth,\n draft: draftArg = false,\n overrideAccess = false,\n populate,\n req,\n req: { fallbackLocale, locale, payload },\n select: incomingSelect,\n showHiddenFields,\n } = args\n\n try {\n const shouldCommit = !args.disableTransaction && (await initTransaction(args.req))\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n if (args.collection.config.hooks?.beforeOperation?.length) {\n for (const hook of args.collection.config.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req.context,\n operation: 'restoreVersion',\n req: args.req,\n })) || args\n }\n }\n\n if (!id) {\n throw new APIError('Missing ID of version to restore.', httpStatus.BAD_REQUEST)\n }\n\n // /////////////////////////////////////\n // Retrieve original raw version\n // /////////////////////////////////////\n\n const { docs: versionDocs } = await req.payload.db.findVersions({\n collection: collectionConfig.slug,\n limit: 1,\n locale: locale!,\n pagination: false,\n req,\n where: { id: { equals: id } },\n })\n\n const [rawVersionToRestore] = versionDocs\n\n if (!rawVersionToRestore) {\n throw new NotFound(req.t)\n }\n\n const { parent: parentDocID, version: versionToRestoreWithLocales } = rawVersionToRestore\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ id: parentDocID, req }, collectionConfig.access.update)\n : true\n const hasWherePolicy = hasWhereAccessResult(accessResults)\n\n // /////////////////////////////////////\n // Retrieve document\n // /////////////////////////////////////\n\n const findOneArgs: FindOneArgs = {\n collection: collectionConfig.slug,\n locale: locale!,\n req,\n where: combineQueries({ id: { equals: parentDocID } }, accessResults),\n }\n\n // Get the document from the non versioned collection\n const doc = await req.payload.db.findOne<TData>(findOneArgs)\n\n if (!doc && !hasWherePolicy) {\n throw new NotFound(req.t)\n }\n if (!doc && hasWherePolicy) {\n throw new Forbidden(req.t)\n }\n\n if (collectionConfig.trash && doc?.deletedAt) {\n throw new APIError(\n `Cannot restore a version of a trashed document (ID: ${parentDocID}). Restore the document first.`,\n httpStatus.FORBIDDEN,\n )\n }\n\n // /////////////////////////////////////\n // fetch previousDoc\n // /////////////////////////////////////\n const prevDocWithLocales = await getLatestCollectionVersion({\n id: parentDocID,\n config: collectionConfig,\n payload,\n query: findOneArgs,\n req,\n })\n\n // originalDoc with hoisted localized data\n const originalDoc = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(prevDocWithLocales),\n draft: draftArg,\n fallbackLocale: null,\n global: null,\n locale: locale!,\n overrideAccess: true,\n req,\n showHiddenFields: true,\n })\n\n // version data with hoisted localized data\n const prevVersionDoc = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(rawVersionToRestore.version),\n draft: draftArg,\n fallbackLocale: null,\n global: null,\n locale: locale!,\n overrideAccess: true,\n req,\n showHiddenFields: true,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n let data = await beforeValidate({\n id: parentDocID,\n collection: collectionConfig,\n context: req.context,\n data: deepCopyObjectSimple(prevVersionDoc),\n doc: originalDoc,\n global: null,\n operation: 'update',\n overrideAccess,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeValidate?.length) {\n for (const hook of collectionConfig.hooks.beforeValidate) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'update',\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeChange?.length) {\n for (const hook of collectionConfig.hooks.beforeChange) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'update',\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n let result = await beforeChange({\n id: parentDocID,\n collection: collectionConfig,\n context: req.context,\n data: { ...data, id: parentDocID },\n doc: originalDoc,\n docWithLocales: versionToRestoreWithLocales,\n global: null,\n operation: 'update',\n overrideAccess,\n req,\n skipValidation:\n draftArg && collectionConfig.versions.drafts && !collectionConfig.versions.drafts.validate,\n })\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n const select = sanitizeSelect({\n fields: collectionConfig.flattenedFields,\n forceSelect: collectionConfig.forceSelect,\n select: incomingSelect,\n })\n\n // Ensure updatedAt date is always updated\n result.updatedAt = new Date().toISOString()\n // Ensure status respects restoreAsDraft arg\n result._status = draftArg ? 'draft' : result._status\n result = await req.payload.db.updateOne({\n id: parentDocID,\n collection: collectionConfig.slug,\n data: result,\n req,\n select,\n })\n\n // /////////////////////////////////////\n // Save restored doc as a new version\n // /////////////////////////////////////\n\n result = await saveVersion({\n id: parentDocID,\n autosave: false,\n collection: collectionConfig,\n docWithLocales: result,\n draft: draftArg,\n operation: 'restoreVersion',\n payload,\n req,\n select,\n })\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: depth!,\n doc: result,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n draft: undefined,\n fallbackLocale: fallbackLocale!,\n global: null,\n locale: locale!,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: collectionConfig,\n context: req.context,\n data: result,\n doc: result,\n global: null,\n operation: 'update',\n previousDoc: prevDocWithLocales,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterChange?.length) {\n for (const hook of collectionConfig.hooks.afterChange) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data: result,\n doc: result,\n operation: 'update',\n previousDoc: prevDocWithLocales,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'restoreVersion',\n result,\n })\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["status","httpStatus","executeAccess","hasWhereAccessResult","combineQueries","APIError","Forbidden","NotFound","afterChange","afterRead","beforeChange","beforeValidate","commitTransaction","deepCopyObjectSimple","initTransaction","killTransaction","sanitizeSelect","getLatestCollectionVersion","saveVersion","buildAfterOperation","restoreVersionOperation","args","id","collection","config","collectionConfig","depth","draft","draftArg","overrideAccess","populate","req","fallbackLocale","locale","payload","select","incomingSelect","showHiddenFields","shouldCommit","disableTransaction","hooks","beforeOperation","length","hook","context","operation","BAD_REQUEST","docs","versionDocs","db","findVersions","slug","limit","pagination","where","equals","rawVersionToRestore","t","parent","parentDocID","version","versionToRestoreWithLocales","accessResults","access","update","hasWherePolicy","findOneArgs","doc","findOne","trash","deletedAt","FORBIDDEN","prevDocWithLocales","query","originalDoc","global","prevVersionDoc","data","result","docWithLocales","skipValidation","versions","drafts","validate","fields","flattenedFields","forceSelect","updatedAt","Date","toISOString","_status","updateOne","autosave","undefined","previousDoc","error"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAMlD,SAASC,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,oBAAoB,QAAQ,sBAAqB;AAC1D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,wBAAuB;AACrE,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACj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ZoB,WAAW;YACXiC;QACF;QAEA,IAAIxC,cAAc;YAChB,MAAM1B,kBAAkBmB;QAC1B;QAEA,OAAO+C;IACT,EAAE,OAAOiB,OAAgB;QACvB,MAAMhF,gBAAgBgB;QACtB,MAAMgE;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/operations/restoreVersion.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { FindOneArgs } from '../../database/types.js'\nimport type { JsonObject, PayloadRequest, PopulateType, SelectType } from '../../types/index.js'\nimport type { Collection, TypeWithID } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { hasWhereAccessResult } from '../../auth/types.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { APIError, Forbidden, NotFound } from '../../errors/index.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { getLatestCollectionVersion } from '../../versions/getLatestCollectionVersion.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\nimport { buildAfterOperation } from './utils.js'\n\nexport type Arguments = {\n collection: Collection\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n disableTransaction?: boolean\n draft?: boolean\n id: number | string\n overrideAccess?: boolean\n populate?: PopulateType\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n}\n\nexport const restoreVersionOperation = async <\n TData extends JsonObject & TypeWithID = JsonObject & TypeWithID,\n>(\n args: Arguments,\n): Promise<TData> => {\n const {\n id,\n collection: { config: collectionConfig },\n depth,\n draft: draftArg = false,\n overrideAccess = false,\n populate,\n req,\n req: { fallbackLocale, locale, payload },\n select: incomingSelect,\n showHiddenFields,\n } = args\n\n try {\n const shouldCommit = !args.disableTransaction && (await initTransaction(args.req))\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n if (args.collection.config.hooks?.beforeOperation?.length) {\n for (const hook of args.collection.config.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req.context,\n operation: 'restoreVersion',\n req: args.req,\n })) || args\n }\n }\n\n if (!id) {\n throw new APIError('Missing ID of version to restore.', httpStatus.BAD_REQUEST)\n }\n\n // /////////////////////////////////////\n // Retrieve original raw version\n // /////////////////////////////////////\n\n const { docs: versionDocs } = await req.payload.db.findVersions({\n collection: collectionConfig.slug,\n limit: 1,\n locale: locale!,\n pagination: false,\n req,\n where: { id: { equals: id } },\n })\n\n const [rawVersionToRestore] = versionDocs\n\n if (!rawVersionToRestore) {\n throw new NotFound(req.t)\n }\n\n const { parent: parentDocID, version: versionToRestoreWithLocales } = rawVersionToRestore\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ id: parentDocID, req }, collectionConfig.access.update)\n : true\n const hasWherePolicy = hasWhereAccessResult(accessResults)\n\n // /////////////////////////////////////\n // Retrieve document\n // /////////////////////////////////////\n\n const findOneArgs: FindOneArgs = {\n collection: collectionConfig.slug,\n locale: locale!,\n req,\n where: combineQueries({ id: { equals: parentDocID } }, accessResults),\n }\n\n // Get the document from the non versioned collection\n const doc = await req.payload.db.findOne<TData>(findOneArgs)\n\n if (!doc && !hasWherePolicy) {\n throw new NotFound(req.t)\n }\n if (!doc && hasWherePolicy) {\n throw new Forbidden(req.t)\n }\n\n if (collectionConfig.trash && doc?.deletedAt) {\n throw new APIError(\n `Cannot restore a version of a trashed document (ID: ${parentDocID}). Restore the document first.`,\n httpStatus.FORBIDDEN,\n )\n }\n\n // /////////////////////////////////////\n // fetch previousDoc\n // /////////////////////////////////////\n const prevDocWithLocales = await getLatestCollectionVersion({\n id: parentDocID,\n config: collectionConfig,\n payload,\n query: findOneArgs,\n req,\n })\n\n // originalDoc with hoisted localized data\n const originalDoc = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(prevDocWithLocales),\n draft: draftArg,\n fallbackLocale: null,\n global: null,\n locale: locale!,\n overrideAccess: true,\n req,\n showHiddenFields: true,\n })\n\n // version data with hoisted localized data\n const prevVersionDoc = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(rawVersionToRestore.version),\n draft: draftArg,\n fallbackLocale: null,\n global: null,\n locale: locale!,\n overrideAccess: true,\n req,\n showHiddenFields: true,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n let data = await beforeValidate({\n id: parentDocID,\n collection: collectionConfig,\n context: req.context,\n data: deepCopyObjectSimple(prevVersionDoc),\n doc: originalDoc,\n global: null,\n operation: 'update',\n overrideAccess,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeValidate?.length) {\n for (const hook of collectionConfig.hooks.beforeValidate) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'update',\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeChange?.length) {\n for (const hook of collectionConfig.hooks.beforeChange) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'update',\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n let result = await beforeChange({\n id: parentDocID,\n collection: collectionConfig,\n context: req.context,\n data: { ...data, id: parentDocID },\n doc: originalDoc,\n docWithLocales: versionToRestoreWithLocales,\n global: null,\n operation: 'update',\n overrideAccess,\n req,\n skipValidation:\n draftArg && collectionConfig.versions.drafts && !collectionConfig.versions.drafts.validate,\n })\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n const select = sanitizeSelect({\n fields: collectionConfig.flattenedFields,\n forceSelect: collectionConfig.forceSelect,\n select: incomingSelect,\n })\n\n // Ensure updatedAt date is always updated\n result.updatedAt = new Date().toISOString()\n // Ensure status respects restoreAsDraft arg\n result._status = draftArg ? 'draft' : result._status\n if (!draftArg) {\n result = await req.payload.db.updateOne({\n id: parentDocID,\n collection: collectionConfig.slug,\n data: result,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // Save restored doc as a new version\n // /////////////////////////////////////\n\n result = await saveVersion({\n id: parentDocID,\n autosave: false,\n collection: collectionConfig,\n docWithLocales: result,\n draft: draftArg,\n operation: 'restoreVersion',\n payload,\n req,\n select,\n })\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: depth!,\n doc: result,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n draft: undefined,\n fallbackLocale: fallbackLocale!,\n global: null,\n locale: locale!,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: collectionConfig,\n context: req.context,\n data: result,\n doc: result,\n global: null,\n operation: 'update',\n previousDoc: prevDocWithLocales,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterChange?.length) {\n for (const hook of collectionConfig.hooks.afterChange) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data: result,\n doc: result,\n operation: 'update',\n previousDoc: prevDocWithLocales,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'restoreVersion',\n result,\n })\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["status","httpStatus","executeAccess","hasWhereAccessResult","combineQueries","APIError","Forbidden","NotFound","afterChange","afterRead","beforeChange","beforeValidate","commitTransaction","deepCopyObjectSimple","initTransaction","killTransaction","sanitizeSelect","getLatestCollectionVersion","saveVersion","buildAfterOperation","restoreVersionOperation","args","id","collection","config","collectionConfig","depth","draft","draftArg","overrideAccess","populate","req","fallbackLocale","locale","payload","select","incomingSelect","showHiddenFields","shouldCommit","disableTransaction","hooks","beforeOperation","length","hook","context","operation","BAD_REQUEST","docs","versionDocs","db","findVersions","slug","limit","pagination","where","equals","rawVersionToRestore","t","parent","parentDocID","version","versionToRestoreWithLocales","accessResults","access","update","hasWherePolicy","findOneArgs","doc","findOne","trash","deletedAt","FORBIDDEN","prevDocWithLocales","query","originalDoc","global","prevVersionDoc","data","result","docWithLocales","skipValidation","versions","drafts","validate","fields","flattenedFields","forceSelect","updatedAt","Date","toISOString","_status","updateOne","autosave","undefined","previousDoc","error"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAMlD,SAASC,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,oBAAoB,QAAQ,sBAAqB;AAC1D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,wBAAuB;AACrE,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SA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B,WAAW;YACXiC;QACF;QAEA,IAAIxC,cAAc;YAChB,MAAM1B,kBAAkBmB;QAC1B;QAEA,OAAO+C;IACT,EAAE,OAAOiB,OAAgB;QACvB,MAAMhF,gBAAgBgB;QACtB,MAAMgE;IACR;AACF,EAAC"}
@@ -19,7 +19,7 @@ import type { EmailAdapter, SendEmailOptions } from '../email/types.js';
19
19
  import type { ErrorName } from '../errors/types.js';
20
20
  import type { RootFoldersConfiguration } from '../folders/types.js';
21
21
  import type { GlobalConfig, Globals, SanitizedGlobalConfig } from '../globals/config/types.js';
22
- import type { Block, FlattenedBlock, JobsConfig, KVAdapterResult, Payload, RequestContext, SelectField, TypedUser } from '../index.js';
22
+ import type { Block, DefaultDocumentIDType, FlattenedBlock, JobsConfig, KVAdapterResult, Payload, RequestContext, SelectField, TypedUser } from '../index.js';
23
23
  import type { QueryPreset, QueryPresetConstraints } from '../query-presets/types.js';
24
24
  import type { SanitizedJobsConfig } from '../queues/config/types/index.js';
25
25
  import type { PayloadRequest, Where } from '../types/index.js';
@@ -209,7 +209,7 @@ export type AccessArgs<TData = any> = {
209
209
  */
210
210
  data?: TData;
211
211
  /** ID of the resource being accessed */
212
- id?: number | string;
212
+ id?: DefaultDocumentIDType;
213
213
  /** If true, the request is for a static file */
214
214
  isReadingStaticFile?: boolean;
215
215
  /** The original request that requires an access check */