payload 3.91.0-internal.c1569dc → 3.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/bin.js +3 -14
  2. package/dist/bin/index.d.ts.map +1 -1
  3. package/dist/bin/index.js +15 -0
  4. package/dist/bin/index.js.map +1 -1
  5. package/dist/bin/index.spec.js +54 -0
  6. package/dist/bin/index.spec.js.map +1 -0
  7. package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
  8. package/dist/collections/operations/findVersionByID.js +7 -0
  9. package/dist/collections/operations/findVersionByID.js.map +1 -1
  10. package/dist/collections/operations/findVersions.d.ts.map +1 -1
  11. package/dist/collections/operations/findVersions.js +5 -0
  12. package/dist/collections/operations/findVersions.js.map +1 -1
  13. package/dist/database/createSchemaBuildContext.d.ts +12 -0
  14. package/dist/database/createSchemaBuildContext.d.ts.map +1 -0
  15. package/dist/database/createSchemaBuildContext.js +24 -0
  16. package/dist/database/createSchemaBuildContext.js.map +1 -0
  17. package/dist/database/createSchemaBuildContext.spec.js +146 -0
  18. package/dist/database/createSchemaBuildContext.spec.js.map +1 -0
  19. package/dist/database/sanitizeJoinQuery.d.ts.map +1 -1
  20. package/dist/database/sanitizeJoinQuery.js +2 -1
  21. package/dist/database/sanitizeJoinQuery.js.map +1 -1
  22. package/dist/errors/APIError.d.ts +4 -0
  23. package/dist/errors/APIError.d.ts.map +1 -1
  24. package/dist/errors/APIError.js +5 -1
  25. package/dist/errors/APIError.js.map +1 -1
  26. package/dist/errors/AuthenticationError.d.ts.map +1 -1
  27. package/dist/errors/AuthenticationError.js +1 -0
  28. package/dist/errors/AuthenticationError.js.map +1 -1
  29. package/dist/errors/DuplicateCollection.d.ts.map +1 -1
  30. package/dist/errors/DuplicateCollection.js +1 -0
  31. package/dist/errors/DuplicateCollection.js.map +1 -1
  32. package/dist/errors/DuplicateFieldName.d.ts.map +1 -1
  33. package/dist/errors/DuplicateFieldName.js +1 -0
  34. package/dist/errors/DuplicateFieldName.js.map +1 -1
  35. package/dist/errors/DuplicateGlobal.d.ts.map +1 -1
  36. package/dist/errors/DuplicateGlobal.js +1 -0
  37. package/dist/errors/DuplicateGlobal.js.map +1 -1
  38. package/dist/errors/ErrorDeletingFile.d.ts.map +1 -1
  39. package/dist/errors/ErrorDeletingFile.js +1 -0
  40. package/dist/errors/ErrorDeletingFile.js.map +1 -1
  41. package/dist/errors/FileRetrievalError.d.ts.map +1 -1
  42. package/dist/errors/FileRetrievalError.js +1 -0
  43. package/dist/errors/FileRetrievalError.js.map +1 -1
  44. package/dist/errors/FileUploadError.d.ts.map +1 -1
  45. package/dist/errors/FileUploadError.js +1 -0
  46. package/dist/errors/FileUploadError.js.map +1 -1
  47. package/dist/errors/Forbidden.d.ts.map +1 -1
  48. package/dist/errors/Forbidden.js +1 -0
  49. package/dist/errors/Forbidden.js.map +1 -1
  50. package/dist/errors/InvalidConfiguration.d.ts.map +1 -1
  51. package/dist/errors/InvalidConfiguration.js +1 -0
  52. package/dist/errors/InvalidConfiguration.js.map +1 -1
  53. package/dist/errors/InvalidFieldJoin.d.ts.map +1 -1
  54. package/dist/errors/InvalidFieldJoin.js +1 -0
  55. package/dist/errors/InvalidFieldJoin.js.map +1 -1
  56. package/dist/errors/InvalidFieldName.d.ts.map +1 -1
  57. package/dist/errors/InvalidFieldName.js +1 -0
  58. package/dist/errors/InvalidFieldName.js.map +1 -1
  59. package/dist/errors/InvalidFieldRelationship.d.ts.map +1 -1
  60. package/dist/errors/InvalidFieldRelationship.js +1 -0
  61. package/dist/errors/InvalidFieldRelationship.js.map +1 -1
  62. package/dist/errors/InvalidSchema.d.ts.map +1 -1
  63. package/dist/errors/InvalidSchema.js +1 -0
  64. package/dist/errors/InvalidSchema.js.map +1 -1
  65. package/dist/errors/Locked.d.ts.map +1 -1
  66. package/dist/errors/Locked.js +1 -0
  67. package/dist/errors/Locked.js.map +1 -1
  68. package/dist/errors/LockedAuth.d.ts.map +1 -1
  69. package/dist/errors/LockedAuth.js +1 -0
  70. package/dist/errors/LockedAuth.js.map +1 -1
  71. package/dist/errors/MissingCollectionLabel.d.ts.map +1 -1
  72. package/dist/errors/MissingCollectionLabel.js +1 -0
  73. package/dist/errors/MissingCollectionLabel.js.map +1 -1
  74. package/dist/errors/MissingEditorProp.d.ts.map +1 -1
  75. package/dist/errors/MissingEditorProp.js +1 -0
  76. package/dist/errors/MissingEditorProp.js.map +1 -1
  77. package/dist/errors/MissingFieldInputOptions.d.ts.map +1 -1
  78. package/dist/errors/MissingFieldInputOptions.js +1 -0
  79. package/dist/errors/MissingFieldInputOptions.js.map +1 -1
  80. package/dist/errors/MissingFieldType.d.ts.map +1 -1
  81. package/dist/errors/MissingFieldType.js +1 -0
  82. package/dist/errors/MissingFieldType.js.map +1 -1
  83. package/dist/errors/MissingFile.d.ts.map +1 -1
  84. package/dist/errors/MissingFile.js +1 -0
  85. package/dist/errors/MissingFile.js.map +1 -1
  86. package/dist/errors/NotFound.d.ts.map +1 -1
  87. package/dist/errors/NotFound.js +1 -0
  88. package/dist/errors/NotFound.js.map +1 -1
  89. package/dist/errors/QueryError.d.ts.map +1 -1
  90. package/dist/errors/QueryError.js +1 -0
  91. package/dist/errors/QueryError.js.map +1 -1
  92. package/dist/errors/ReservedFieldName.d.ts.map +1 -1
  93. package/dist/errors/ReservedFieldName.js +1 -0
  94. package/dist/errors/ReservedFieldName.js.map +1 -1
  95. package/dist/errors/TimestampsRequired.d.ts.map +1 -1
  96. package/dist/errors/TimestampsRequired.js +1 -0
  97. package/dist/errors/TimestampsRequired.js.map +1 -1
  98. package/dist/errors/UnauthorizedError.d.ts.map +1 -1
  99. package/dist/errors/UnauthorizedError.js +1 -0
  100. package/dist/errors/UnauthorizedError.js.map +1 -1
  101. package/dist/errors/UnverifiedEmail.d.ts.map +1 -1
  102. package/dist/errors/UnverifiedEmail.js +1 -0
  103. package/dist/errors/UnverifiedEmail.js.map +1 -1
  104. package/dist/errors/ValidationError.d.ts.map +1 -1
  105. package/dist/errors/ValidationError.js +1 -0
  106. package/dist/errors/ValidationError.js.map +1 -1
  107. package/dist/exports/internal.d.ts +2 -0
  108. package/dist/exports/internal.d.ts.map +1 -1
  109. package/dist/exports/internal.js +1 -0
  110. package/dist/exports/internal.js.map +1 -1
  111. package/dist/fields/hooks/beforeChange/flattenValidationData.d.ts +14 -0
  112. package/dist/fields/hooks/beforeChange/flattenValidationData.d.ts.map +1 -0
  113. package/dist/fields/hooks/beforeChange/flattenValidationData.js +36 -0
  114. package/dist/fields/hooks/beforeChange/flattenValidationData.js.map +1 -0
  115. package/dist/fields/hooks/beforeChange/promise.d.ts +2 -1
  116. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  117. package/dist/fields/hooks/beforeChange/promise.js +96 -22
  118. package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
  119. package/dist/fields/hooks/beforeChange/traverseFields.d.ts +2 -1
  120. package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
  121. package/dist/fields/hooks/beforeChange/traverseFields.js +2 -1
  122. package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
  123. package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
  124. package/dist/globals/operations/findVersionByID.js +7 -0
  125. package/dist/globals/operations/findVersionByID.js.map +1 -1
  126. package/dist/globals/operations/findVersions.d.ts.map +1 -1
  127. package/dist/globals/operations/findVersions.js +5 -0
  128. package/dist/globals/operations/findVersions.js.map +1 -1
  129. package/dist/index.bundled.d.ts +6 -1
  130. package/dist/queues/utilities/updateJob.d.ts.map +1 -1
  131. package/dist/queues/utilities/updateJob.js +15 -0
  132. package/dist/queues/utilities/updateJob.js.map +1 -1
  133. package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
  134. package/dist/utilities/getEntityPermissions/getEntityPermissions.js +1 -0
  135. package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
  136. package/dist/utilities/getNextJsHMRURL.d.ts.map +1 -1
  137. package/dist/utilities/getNextJsHMRURL.js +4 -2
  138. package/dist/utilities/getNextJsHMRURL.js.map +1 -1
  139. package/dist/utilities/getNextJsHMRURL.spec.js +11 -0
  140. package/dist/utilities/getNextJsHMRURL.spec.js.map +1 -1
  141. package/dist/utilities/getVersionsConfig.d.ts +4 -0
  142. package/dist/utilities/getVersionsConfig.d.ts.map +1 -1
  143. package/dist/utilities/getVersionsConfig.js +5 -0
  144. package/dist/utilities/getVersionsConfig.js.map +1 -1
  145. package/lexicalLoader.mjs +26 -0
  146. package/package.json +10 -9
@@ -1 +1 @@
1
- {"version":3,"file":"MissingFile.d.ts","sourceRoot":"","sources":["../../src/errors/MissingFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAKzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,WAAY,SAAQ,QAAQ;gBAC3B,CAAC,CAAC,EAAE,SAAS;CAM1B"}
1
+ {"version":3,"file":"MissingFile.d.ts","sourceRoot":"","sources":["../../src/errors/MissingFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAKzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,WAAY,SAAQ,QAAQ;gBAC3B,CAAC,CAAC,EAAE,SAAS;CAO1B"}
@@ -4,6 +4,7 @@ import { APIError } from './APIError.js';
4
4
  export class MissingFile extends APIError {
5
5
  constructor(t){
6
6
  super(t ? t('error:noFilesUploaded') : en.translations.error.noFilesUploaded, httpStatus.BAD_REQUEST);
7
+ this.name = 'MissingFile';
7
8
  }
8
9
  }
9
10
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/errors/MissingFile.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class MissingFile extends APIError {\n constructor(t?: TFunction) {\n super(\n t ? t('error:noFilesUploaded') : en.translations.error.noFilesUploaded,\n httpStatus.BAD_REQUEST,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","MissingFile","t","translations","error","noFilesUploaded","BAD_REQUEST"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,oBAAoBD;IAC/B,YAAYE,CAAa,CAAE;QACzB,KAAK,CACHA,IAAIA,EAAE,2BAA2BL,GAAGM,YAAY,CAACC,KAAK,CAACC,eAAe,EACtEN,WAAWO,WAAW;IAE1B;AACF"}
1
+ {"version":3,"sources":["../../src/errors/MissingFile.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class MissingFile extends APIError {\n constructor(t?: TFunction) {\n super(\n t ? t('error:noFilesUploaded') : en.translations.error.noFilesUploaded,\n httpStatus.BAD_REQUEST,\n )\n this.name = 'MissingFile'\n }\n}\n"],"names":["en","status","httpStatus","APIError","MissingFile","t","translations","error","noFilesUploaded","BAD_REQUEST","name"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,oBAAoBD;IAC/B,YAAYE,CAAa,CAAE;QACzB,KAAK,CACHA,IAAIA,EAAE,2BAA2BL,GAAGM,YAAY,CAACC,KAAK,CAACC,eAAe,EACtEN,WAAWO,WAAW;QAExB,IAAI,CAACC,IAAI,GAAG;IACd;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"NotFound.d.ts","sourceRoot":"","sources":["../../src/errors/NotFound.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAKzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,QAAS,SAAQ,QAAQ;gBACxB,CAAC,CAAC,EAAE,SAAS;CAG1B"}
1
+ {"version":3,"file":"NotFound.d.ts","sourceRoot":"","sources":["../../src/errors/NotFound.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAKzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,QAAS,SAAQ,QAAQ;gBACxB,CAAC,CAAC,EAAE,SAAS;CAI1B"}
@@ -4,6 +4,7 @@ import { APIError } from './APIError.js';
4
4
  export class NotFound extends APIError {
5
5
  constructor(t){
6
6
  super(t ? t('general:notFound') : en.translations.general.notFound, httpStatus.NOT_FOUND);
7
+ this.name = 'NotFound';
7
8
  }
8
9
  }
9
10
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/errors/NotFound.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class NotFound extends APIError {\n constructor(t?: TFunction) {\n super(t ? t('general:notFound') : en.translations.general.notFound, httpStatus.NOT_FOUND)\n }\n}\n"],"names":["en","status","httpStatus","APIError","NotFound","t","translations","general","notFound","NOT_FOUND"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,iBAAiBD;IAC5B,YAAYE,CAAa,CAAE;QACzB,KAAK,CAACA,IAAIA,EAAE,sBAAsBL,GAAGM,YAAY,CAACC,OAAO,CAACC,QAAQ,EAAEN,WAAWO,SAAS;IAC1F;AACF"}
1
+ {"version":3,"sources":["../../src/errors/NotFound.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class NotFound extends APIError {\n constructor(t?: TFunction) {\n super(t ? t('general:notFound') : en.translations.general.notFound, httpStatus.NOT_FOUND)\n this.name = 'NotFound'\n }\n}\n"],"names":["en","status","httpStatus","APIError","NotFound","t","translations","general","notFound","NOT_FOUND","name"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,iBAAiBD;IAC5B,YAAYE,CAAa,CAAE;QACzB,KAAK,CAACA,IAAIA,EAAE,sBAAsBL,GAAGM,YAAY,CAACC,OAAO,CAACC,QAAQ,EAAEN,WAAWO,SAAS;QACxF,IAAI,CAACC,IAAI,GAAG;IACd;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"QueryError.d.ts","sourceRoot":"","sources":["../../src/errors/QueryError.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,UAAW,SAAQ,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC;gBAC9C,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE;CASxC"}
1
+ {"version":3,"file":"QueryError.d.ts","sourceRoot":"","sources":["../../src/errors/QueryError.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,UAAW,SAAQ,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC;gBAC9C,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE;CAUxC"}
@@ -4,6 +4,7 @@ export class QueryError extends APIError {
4
4
  constructor(results){
5
5
  const message = `The following path${results.length === 1 ? '' : 's'} cannot be queried:`;
6
6
  super(`${message} ${results.map((err)=>err.path).join(', ')}`, httpStatus.BAD_REQUEST, results);
7
+ this.name = 'QueryError';
7
8
  }
8
9
  }
9
10
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/errors/QueryError.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class QueryError extends APIError<{ path: string }[]> {\n constructor(results: { path: string }[]) {\n const message = `The following path${results.length === 1 ? '' : 's'} cannot be queried:`\n\n super(\n `${message} ${results.map((err) => err.path).join(', ')}`,\n httpStatus.BAD_REQUEST,\n results,\n )\n }\n}\n"],"names":["status","httpStatus","APIError","QueryError","results","message","length","map","err","path","join","BAD_REQUEST"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,mBAAmBD;IAC9B,YAAYE,OAA2B,CAAE;QACvC,MAAMC,UAAU,CAAC,kBAAkB,EAAED,QAAQE,MAAM,KAAK,IAAI,KAAK,IAAI,mBAAmB,CAAC;QAEzF,KAAK,CACH,GAAGD,QAAQ,CAAC,EAAED,QAAQG,GAAG,CAAC,CAACC,MAAQA,IAAIC,IAAI,EAAEC,IAAI,CAAC,OAAO,EACzDT,WAAWU,WAAW,EACtBP;IAEJ;AACF"}
1
+ {"version":3,"sources":["../../src/errors/QueryError.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class QueryError extends APIError<{ path: string }[]> {\n constructor(results: { path: string }[]) {\n const message = `The following path${results.length === 1 ? '' : 's'} cannot be queried:`\n\n super(\n `${message} ${results.map((err) => err.path).join(', ')}`,\n httpStatus.BAD_REQUEST,\n results,\n )\n this.name = 'QueryError'\n }\n}\n"],"names":["status","httpStatus","APIError","QueryError","results","message","length","map","err","path","join","BAD_REQUEST","name"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,mBAAmBD;IAC9B,YAAYE,OAA2B,CAAE;QACvC,MAAMC,UAAU,CAAC,kBAAkB,EAAED,QAAQE,MAAM,KAAK,IAAI,KAAK,IAAI,mBAAmB,CAAC;QAEzF,KAAK,CACH,GAAGD,QAAQ,CAAC,EAAED,QAAQG,GAAG,CAAC,CAACC,MAAQA,IAAIC,IAAI,EAAEC,IAAI,CAAC,OAAO,EACzDT,WAAWU,WAAW,EACtBP;QAEF,IAAI,CAACQ,IAAI,GAAG;IACd;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReservedFieldName.d.ts","sourceRoot":"","sources":["../../src/errors/ReservedFieldName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM;CAGzD"}
1
+ {"version":3,"file":"ReservedFieldName.d.ts","sourceRoot":"","sources":["../../src/errors/ReservedFieldName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM;CAIzD"}
@@ -2,6 +2,7 @@ import { APIError } from './APIError.js';
2
2
  export class ReservedFieldName extends APIError {
3
3
  constructor(field, fieldName){
4
4
  super(`Field ${field.label} has reserved name '${fieldName}'.`);
5
+ this.name = 'ReservedFieldName';
5
6
  }
6
7
  }
7
8
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/errors/ReservedFieldName.ts"],"sourcesContent":["import type { FieldAffectingData } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class ReservedFieldName extends APIError {\n constructor(field: FieldAffectingData, fieldName: string) {\n super(`Field ${field.label} has reserved name '${fieldName}'.`)\n }\n}\n"],"names":["APIError","ReservedFieldName","field","fieldName","label"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,0BAA0BD;IACrC,YAAYE,KAAyB,EAAEC,SAAiB,CAAE;QACxD,KAAK,CAAC,CAAC,MAAM,EAAED,MAAME,KAAK,CAAC,oBAAoB,EAAED,UAAU,EAAE,CAAC;IAChE;AACF"}
1
+ {"version":3,"sources":["../../src/errors/ReservedFieldName.ts"],"sourcesContent":["import type { FieldAffectingData } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class ReservedFieldName extends APIError {\n constructor(field: FieldAffectingData, fieldName: string) {\n super(`Field ${field.label} has reserved name '${fieldName}'.`)\n this.name = 'ReservedFieldName'\n }\n}\n"],"names":["APIError","ReservedFieldName","field","fieldName","label","name"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,0BAA0BD;IACrC,YAAYE,KAAyB,EAAEC,SAAiB,CAAE;QACxD,KAAK,CAAC,CAAC,MAAM,EAAED,MAAME,KAAK,CAAC,oBAAoB,EAAED,UAAU,EAAE,CAAC;QAC9D,IAAI,CAACE,IAAI,GAAG;IACd;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"TimestampsRequired.d.ts","sourceRoot":"","sources":["../../src/errors/TimestampsRequired.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,kBAAmB,SAAQ,QAAQ;gBAClC,UAAU,EAAE,gBAAgB;CAKzC"}
1
+ {"version":3,"file":"TimestampsRequired.d.ts","sourceRoot":"","sources":["../../src/errors/TimestampsRequired.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,kBAAmB,SAAQ,QAAQ;gBAClC,UAAU,EAAE,gBAAgB;CAMzC"}
@@ -2,6 +2,7 @@ import { APIError } from './APIError.js';
2
2
  export class TimestampsRequired extends APIError {
3
3
  constructor(collection){
4
4
  super(`Timestamps are required in the collection ${collection.slug} because you have opted in to Versions.`);
5
+ this.name = 'TimestampsRequired';
5
6
  }
6
7
  }
7
8
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/errors/TimestampsRequired.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class TimestampsRequired extends APIError {\n constructor(collection: CollectionConfig) {\n super(\n `Timestamps are required in the collection ${collection.slug} because you have opted in to Versions.`,\n )\n }\n}\n"],"names":["APIError","TimestampsRequired","collection","slug"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,2BAA2BD;IACtC,YAAYE,UAA4B,CAAE;QACxC,KAAK,CACH,CAAC,0CAA0C,EAAEA,WAAWC,IAAI,CAAC,uCAAuC,CAAC;IAEzG;AACF"}
1
+ {"version":3,"sources":["../../src/errors/TimestampsRequired.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class TimestampsRequired extends APIError {\n constructor(collection: CollectionConfig) {\n super(\n `Timestamps are required in the collection ${collection.slug} because you have opted in to Versions.`,\n )\n this.name = 'TimestampsRequired'\n }\n}\n"],"names":["APIError","TimestampsRequired","collection","slug","name"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,2BAA2BD;IACtC,YAAYE,UAA4B,CAAE;QACxC,KAAK,CACH,CAAC,0CAA0C,EAAEA,WAAWC,IAAI,CAAC,uCAAuC,CAAC;QAEvG,IAAI,CAACC,IAAI,GAAG;IACd;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"UnauthorizedError.d.ts","sourceRoot":"","sources":["../../src/errors/UnauthorizedError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAKzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,CAAC,CAAC,EAAE,SAAS;CAG1B"}
1
+ {"version":3,"file":"UnauthorizedError.d.ts","sourceRoot":"","sources":["../../src/errors/UnauthorizedError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAKzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,CAAC,CAAC,EAAE,SAAS;CAI1B"}
@@ -4,6 +4,7 @@ import { APIError } from './APIError.js';
4
4
  export class UnauthorizedError extends APIError {
5
5
  constructor(t){
6
6
  super(t ? t('error:unauthorized') : en.translations.error.unauthorized, httpStatus.UNAUTHORIZED);
7
+ this.name = 'UnauthorizedError';
7
8
  }
8
9
  }
9
10
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/errors/UnauthorizedError.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class UnauthorizedError extends APIError {\n constructor(t?: TFunction) {\n super(t ? t('error:unauthorized') : en.translations.error.unauthorized, httpStatus.UNAUTHORIZED)\n }\n}\n"],"names":["en","status","httpStatus","APIError","UnauthorizedError","t","translations","error","unauthorized","UNAUTHORIZED"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,0BAA0BD;IACrC,YAAYE,CAAa,CAAE;QACzB,KAAK,CAACA,IAAIA,EAAE,wBAAwBL,GAAGM,YAAY,CAACC,KAAK,CAACC,YAAY,EAAEN,WAAWO,YAAY;IACjG;AACF"}
1
+ {"version":3,"sources":["../../src/errors/UnauthorizedError.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class UnauthorizedError extends APIError {\n constructor(t?: TFunction) {\n super(t ? t('error:unauthorized') : en.translations.error.unauthorized, httpStatus.UNAUTHORIZED)\n this.name = 'UnauthorizedError'\n }\n}\n"],"names":["en","status","httpStatus","APIError","UnauthorizedError","t","translations","error","unauthorized","UNAUTHORIZED","name"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,0BAA0BD;IACrC,YAAYE,CAAa,CAAE;QACzB,KAAK,CAACA,IAAIA,EAAE,wBAAwBL,GAAGM,YAAY,CAACC,KAAK,CAACC,YAAY,EAAEN,WAAWO,YAAY;QAC/F,IAAI,CAACC,IAAI,GAAG;IACd;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"UnverifiedEmail.d.ts","sourceRoot":"","sources":["../../src/errors/UnverifiedEmail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAKzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,EAAE,CAAC,EAAE,EAAE;QAAE,CAAC,CAAC,EAAE,SAAS,CAAA;KAAE;CAMrC"}
1
+ {"version":3,"file":"UnverifiedEmail.d.ts","sourceRoot":"","sources":["../../src/errors/UnverifiedEmail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAKzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,EAAE,CAAC,EAAE,EAAE;QAAE,CAAC,CAAC,EAAE,SAAS,CAAA;KAAE;CAOrC"}
@@ -4,6 +4,7 @@ import { APIError } from './APIError.js';
4
4
  export class UnverifiedEmail extends APIError {
5
5
  constructor({ t }){
6
6
  super(t ? t('error:unverifiedEmail') : en.translations.error.unverifiedEmail, httpStatus.FORBIDDEN);
7
+ this.name = 'UnverifiedEmail';
7
8
  }
8
9
  }
9
10
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/errors/UnverifiedEmail.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class UnverifiedEmail extends APIError {\n constructor({ t }: { t?: TFunction }) {\n super(\n t ? t('error:unverifiedEmail') : en.translations.error.unverifiedEmail,\n httpStatus.FORBIDDEN,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","UnverifiedEmail","t","translations","error","unverifiedEmail","FORBIDDEN"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,wBAAwBD;IACnC,YAAY,EAAEE,CAAC,EAAqB,CAAE;QACpC,KAAK,CACHA,IAAIA,EAAE,2BAA2BL,GAAGM,YAAY,CAACC,KAAK,CAACC,eAAe,EACtEN,WAAWO,SAAS;IAExB;AACF"}
1
+ {"version":3,"sources":["../../src/errors/UnverifiedEmail.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class UnverifiedEmail extends APIError {\n constructor({ t }: { t?: TFunction }) {\n super(\n t ? t('error:unverifiedEmail') : en.translations.error.unverifiedEmail,\n httpStatus.FORBIDDEN,\n )\n this.name = 'UnverifiedEmail'\n }\n}\n"],"names":["en","status","httpStatus","APIError","UnverifiedEmail","t","translations","error","unverifiedEmail","FORBIDDEN","name"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,wBAAwBD;IACnC,YAAY,EAAEE,CAAC,EAAqB,CAAE;QACpC,KAAK,CACHA,IAAIA,EAAE,2BAA2BL,GAAGM,YAAY,CAACC,KAAK,CAACC,eAAe,EACtEN,WAAWO,SAAS;QAEtB,IAAI,CAACC,IAAI,GAAG;IACd;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationError.d.ts","sourceRoot":"","sources":["../../src/errors/ValidationError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAKzD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,oBAAoB,CAAA;AAEpD,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,CAAC,EAAE,aAAa,GAAG,WAAW,CAAA;IAEnC,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,qBAAa,eAAgB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,oBAAoB,EAAE,CAAA;QAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;QACpB;;WAEG;QACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;KAC9B,EACD,CAAC,CAAC,EAAE,SAAS;CA2ChB"}
@@ -31,6 +31,7 @@ export class ValidationError extends APIError {
31
31
  }
32
32
  return f.path;
33
33
  }).join(', ')}`, httpStatus.BAD_REQUEST, results);
34
+ this.name = 'ValidationError';
34
35
  }
35
36
  }
36
37
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/errors/ValidationError.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport type { LabelFunction, StaticLabel } from '../config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nimport { APIError } from './APIError.js'\n\n/** @deprecated Use `instanceof ValidationError` instead of name comparison. */\nexport const ValidationErrorName = 'ValidationError'\n\nexport type ValidationFieldError = {\n label?: LabelFunction | StaticLabel\n // The error message to display for this field\n message: string\n path: string\n tableName?: string\n}\n\nexport class ValidationError extends APIError<{\n collection?: string\n errors: ValidationFieldError[]\n global?: string\n}> {\n constructor(\n results: {\n collection?: string\n errors: ValidationFieldError[]\n global?: string\n id?: number | string\n /**\n * req needs to be passed through (if you have one) in order to resolve label functions that may be part of the errors array\n */\n req?: Partial<PayloadRequest>\n },\n t?: TFunction,\n ) {\n const message = t\n ? t('error:followingFieldsInvalid', { count: results.errors.length })\n : results.errors.length === 1\n ? en.translations.error.followingFieldsInvalid_one\n : en.translations.error.followingFieldsInvalid_other\n\n const req = results.req\n // delete to avoid logging the whole req\n delete results['req']\n\n super(\n `${message} ${results.errors\n .map((f) => {\n if (f.label) {\n if (typeof f.label === 'function') {\n if (!req || !req.i18n || !req.t) {\n return f.path\n }\n\n return f.label({ i18n: req.i18n, t: req.t })\n }\n\n if (typeof f.label === 'object') {\n if (req?.i18n?.language) {\n return f.label[req.i18n.language]\n }\n\n return f.label[Object.keys(f.label)[0]!]\n }\n\n return f.label\n }\n\n return f.path\n })\n .join(', ')}`,\n httpStatus.BAD_REQUEST,\n results,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","ValidationErrorName","ValidationError","results","t","message","count","errors","length","translations","error","followingFieldsInvalid_one","followingFieldsInvalid_other","req","map","f","label","i18n","path","language","Object","keys","join","BAD_REQUEST"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,6EAA6E,GAC7E,OAAO,MAAMC,sBAAsB,kBAAiB;AAUpD,OAAO,MAAMC,wBAAwBF;IAKnC,YACEG,OASC,EACDC,CAAa,CACb;QACA,MAAMC,UAAUD,IACZA,EAAE,gCAAgC;YAAEE,OAAOH,QAAQI,MAAM,CAACC,MAAM;QAAC,KACjEL,QAAQI,MAAM,CAACC,MAAM,KAAK,IACxBX,GAAGY,YAAY,CAACC,KAAK,CAACC,0BAA0B,GAChDd,GAAGY,YAAY,CAACC,KAAK,CAACE,4BAA4B;QAExD,MAAMC,MAAMV,QAAQU,GAAG;QACvB,wCAAwC;QACxC,OAAOV,OAAO,CAAC,MAAM;QAErB,KAAK,CACH,GAAGE,QAAQ,CAAC,EAAEF,QAAQI,MAAM,CACzBO,GAAG,CAAC,CAACC;YACJ,IAAIA,EAAEC,KAAK,EAAE;gBACX,IAAI,OAAOD,EAAEC,KAAK,KAAK,YAAY;oBACjC,IAAI,CAACH,OAAO,CAACA,IAAII,IAAI,IAAI,CAACJ,IAAIT,CAAC,EAAE;wBAC/B,OAAOW,EAAEG,IAAI;oBACf;oBAEA,OAAOH,EAAEC,KAAK,CAAC;wBAAEC,MAAMJ,IAAII,IAAI;wBAAEb,GAAGS,IAAIT,CAAC;oBAAC;gBAC5C;gBAEA,IAAI,OAAOW,EAAEC,KAAK,KAAK,UAAU;oBAC/B,IAAIH,KAAKI,MAAME,UAAU;wBACvB,OAAOJ,EAAEC,KAAK,CAACH,IAAII,IAAI,CAACE,QAAQ,CAAC;oBACnC;oBAEA,OAAOJ,EAAEC,KAAK,CAACI,OAAOC,IAAI,CAACN,EAAEC,KAAK,CAAC,CAAC,EAAE,CAAE;gBAC1C;gBAEA,OAAOD,EAAEC,KAAK;YAChB;YAEA,OAAOD,EAAEG,IAAI;QACf,GACCI,IAAI,CAAC,OAAO,EACfvB,WAAWwB,WAAW,EACtBpB;IAEJ;AACF"}
1
+ {"version":3,"sources":["../../src/errors/ValidationError.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport type { LabelFunction, StaticLabel } from '../config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nimport { APIError } from './APIError.js'\n\n/** @deprecated Use `instanceof ValidationError` instead of name comparison. */\nexport const ValidationErrorName = 'ValidationError'\n\nexport type ValidationFieldError = {\n label?: LabelFunction | StaticLabel\n // The error message to display for this field\n message: string\n path: string\n tableName?: string\n}\n\nexport class ValidationError extends APIError<{\n collection?: string\n errors: ValidationFieldError[]\n global?: string\n}> {\n constructor(\n results: {\n collection?: string\n errors: ValidationFieldError[]\n global?: string\n id?: number | string\n /**\n * req needs to be passed through (if you have one) in order to resolve label functions that may be part of the errors array\n */\n req?: Partial<PayloadRequest>\n },\n t?: TFunction,\n ) {\n const message = t\n ? t('error:followingFieldsInvalid', { count: results.errors.length })\n : results.errors.length === 1\n ? en.translations.error.followingFieldsInvalid_one\n : en.translations.error.followingFieldsInvalid_other\n\n const req = results.req\n // delete to avoid logging the whole req\n delete results['req']\n\n super(\n `${message} ${results.errors\n .map((f) => {\n if (f.label) {\n if (typeof f.label === 'function') {\n if (!req || !req.i18n || !req.t) {\n return f.path\n }\n\n return f.label({ i18n: req.i18n, t: req.t })\n }\n\n if (typeof f.label === 'object') {\n if (req?.i18n?.language) {\n return f.label[req.i18n.language]\n }\n\n return f.label[Object.keys(f.label)[0]!]\n }\n\n return f.label\n }\n\n return f.path\n })\n .join(', ')}`,\n httpStatus.BAD_REQUEST,\n results,\n )\n this.name = 'ValidationError'\n }\n}\n"],"names":["en","status","httpStatus","APIError","ValidationErrorName","ValidationError","results","t","message","count","errors","length","translations","error","followingFieldsInvalid_one","followingFieldsInvalid_other","req","map","f","label","i18n","path","language","Object","keys","join","BAD_REQUEST","name"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,6EAA6E,GAC7E,OAAO,MAAMC,sBAAsB,kBAAiB;AAUpD,OAAO,MAAMC,wBAAwBF;IAKnC,YACEG,OASC,EACDC,CAAa,CACb;QACA,MAAMC,UAAUD,IACZA,EAAE,gCAAgC;YAAEE,OAAOH,QAAQI,MAAM,CAACC,MAAM;QAAC,KACjEL,QAAQI,MAAM,CAACC,MAAM,KAAK,IACxBX,GAAGY,YAAY,CAACC,KAAK,CAACC,0BAA0B,GAChDd,GAAGY,YAAY,CAACC,KAAK,CAACE,4BAA4B;QAExD,MAAMC,MAAMV,QAAQU,GAAG;QACvB,wCAAwC;QACxC,OAAOV,OAAO,CAAC,MAAM;QAErB,KAAK,CACH,GAAGE,QAAQ,CAAC,EAAEF,QAAQI,MAAM,CACzBO,GAAG,CAAC,CAACC;YACJ,IAAIA,EAAEC,KAAK,EAAE;gBACX,IAAI,OAAOD,EAAEC,KAAK,KAAK,YAAY;oBACjC,IAAI,CAACH,OAAO,CAACA,IAAII,IAAI,IAAI,CAACJ,IAAIT,CAAC,EAAE;wBAC/B,OAAOW,EAAEG,IAAI;oBACf;oBAEA,OAAOH,EAAEC,KAAK,CAAC;wBAAEC,MAAMJ,IAAII,IAAI;wBAAEb,GAAGS,IAAIT,CAAC;oBAAC;gBAC5C;gBAEA,IAAI,OAAOW,EAAEC,KAAK,KAAK,UAAU;oBAC/B,IAAIH,KAAKI,MAAME,UAAU;wBACvB,OAAOJ,EAAEC,KAAK,CAACH,IAAII,IAAI,CAACE,QAAQ,CAAC;oBACnC;oBAEA,OAAOJ,EAAEC,KAAK,CAACI,OAAOC,IAAI,CAACN,EAAEC,KAAK,CAAC,CAAC,EAAE,CAAE;gBAC1C;gBAEA,OAAOD,EAAEC,KAAK;YAChB;YAEA,OAAOD,EAAEG,IAAI;QACf,GACCI,IAAI,CAAC,OAAO,EACfvB,WAAWwB,WAAW,EACtBpB;QAEF,IAAI,CAACqB,IAAI,GAAG;IACd;AACF"}
@@ -2,6 +2,8 @@
2
2
  * Modules exported here are not part of the public API and are subject to change without notice and without a major version bump.
3
3
  */
4
4
  export { applyUserReadAccess } from '../auth/applyUserReadAccess.js';
5
+ export { createSchemaBuildContext } from '../database/createSchemaBuildContext.js';
6
+ export type { SchemaBuildContext } from '../database/createSchemaBuildContext.js';
5
7
  export { assertClientUploadAccess } from '../uploads/assertClientUploadAccess.js';
6
8
  export { assertClientUploadAllowed, assertClientUploadFileSize, } from '../uploads/assertClientUploadAllowed.js';
7
9
  export { createClientUploadReceipt, verifyClientUploadReceipt, } from '../uploads/clientUploadReceipt.js';
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/exports/internal.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAA;AACjF,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,yCAAyC,CAAA;AAChD,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,mCAAmC,CAAA;AAC1C,YAAY,EACV,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,eAAe,E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AA;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,2DAA2D,CAAA;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA"}
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Modules exported here are not part of the public API and are subject to change without notice and without a major version bump.
3
3
  */ export { applyUserReadAccess } from '../auth/applyUserReadAccess.js';
4
+ export { createSchemaBuildContext } from '../database/createSchemaBuildContext.js';
4
5
  export { assertClientUploadAccess } from '../uploads/assertClientUploadAccess.js';
5
6
  export { assertClientUploadAllowed, assertClientUploadFileSize } from '../uploads/assertClientUploadAllowed.js';
6
7
  export { createClientUploadReceipt, verifyClientUploadReceipt } from '../uploads/clientUploadReceipt.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/internal.ts"],"sourcesContent":["/**\n * Modules exported here are not part of the public API and are subject to change without notice and without a major version bump.\n */\n\nexport { applyUserReadAccess } from '../auth/applyUserReadAccess.js'\nexport { assertClientUploadAccess } from '../uploads/assertClientUploadAccess.js'\nexport {\n assertClientUploadAllowed,\n assertClientUploadFileSize,\n} from '../uploads/assertClientUploadAllowed.js'\nexport {\n createClientUploadReceipt,\n verifyClientUploadReceipt,\n} from '../uploads/clientUploadReceipt.js'\nexport type {\n ClientUploadReceipt,\n SignedClientUploadReceipt,\n} from '../uploads/clientUploadReceipt.js'\nexport { getExternalFile } from '../uploads/getExternalFile.js'\nexport { isSvgMimeType, isXmlMimeType } from '../uploads/getFileTypeIdentity.js'\nexport { getRangeRequestInfo } from '../uploads/getRangeRequestInfo.js'\nexport { getSafeFileName } from '../uploads/getSafeFilename.js'\nexport { parseRangeHeader } from '../uploads/parseRangeHeader.js'\nexport { UPLOAD_CONTENT_SECURITY_POLICY } from '../uploads/uploadContentSecurityPolicy.js'\nexport { getEntityPermissions } from '../utilities/getEntityPermissions/getEntityPermissions.js'\nexport { sanitizePermissions } from '../utilities/sanitizePermissions.js'\n"],"names":["applyUserReadAccess","assertClientUploadAccess","assertClientUploadAllowed","assertClientUploadFileSize","createClientUploadReceipt","verifyClientUploadReceipt","getExternalFile","isSvgMimeType","isXmlMimeType","getRangeRequestInfo","getSafeFileName","parseRangeHeader","UPLOAD_CONTENT_SECURITY_POLICY","getEntityPermissions","sanitizePermissions"],"mappings":"AAAA;;CAEC,GAED,SAASA,mBAAmB,QAAQ,iCAAgC;AACpE,SAASC,wBAAwB,QAAQ,yCAAwC;AACjF,SACEC,yBAAyB,EACzBC,0BAA0B,QACrB,0CAAyC;AAChD,SACEC,yBAAyB,EACzBC,yBAAyB,QACpB,oCAAmC;AAK1C,SAASC,eAAe,QAAQ,gCAA+B;AAC/D,SAASC,aAAa,EAAEC,aAAa,QAAQ,oCAAmC;AAChF,SAASC,mBAAmB,QAAQ,oCAAmC;AACvE,SAASC,eAAe,QAAQ,gCAA+B;AAC/D,SAASC,gBAAgB,QAAQ,iCAAgC;AACjE,SAASC,8BAA8B,QAAQ,4CAA2C;AAC1F,SAASC,oBAAoB,QAAQ,4DAA2D;AAChG,SAASC,mBAAmB,QAAQ,sCAAqC"}
1
+ {"version":3,"sources":["../../src/exports/internal.ts"],"sourcesContent":["/**\n * Modules exported here are not part of the public API and are subject to change without notice and without a major version bump.\n */\n\nexport { applyUserReadAccess } from '../auth/applyUserReadAccess.js'\nexport { createSchemaBuildContext } from '../database/createSchemaBuildContext.js'\nexport type { SchemaBuildContext } from '../database/createSchemaBuildContext.js'\nexport { assertClientUploadAccess } from '../uploads/assertClientUploadAccess.js'\nexport {\n assertClientUploadAllowed,\n assertClientUploadFileSize,\n} from '../uploads/assertClientUploadAllowed.js'\nexport {\n createClientUploadReceipt,\n verifyClientUploadReceipt,\n} from '../uploads/clientUploadReceipt.js'\nexport type {\n ClientUploadReceipt,\n SignedClientUploadReceipt,\n} from '../uploads/clientUploadReceipt.js'\nexport { getExternalFile } from '../uploads/getExternalFile.js'\nexport { isSvgMimeType, isXmlMimeType } from '../uploads/getFileTypeIdentity.js'\nexport { getRangeRequestInfo } from '../uploads/getRangeRequestInfo.js'\nexport { getSafeFileName } from '../uploads/getSafeFilename.js'\nexport { parseRangeHeader } from '../uploads/parseRangeHeader.js'\nexport { UPLOAD_CONTENT_SECURITY_POLICY } from '../uploads/uploadContentSecurityPolicy.js'\nexport { getEntityPermissions } from '../utilities/getEntityPermissions/getEntityPermissions.js'\nexport { sanitizePermissions } from '../utilities/sanitizePermissions.js'\n"],"names":["applyUserReadAccess","createSchemaBuildContext","assertClientUploadAccess","assertClientUploadAllowed","assertClientUploadFileSize","createClientUploadReceipt","verifyClientUploadReceipt","getExternalFile","isSvgMimeType","isXmlMimeType","getRangeRequestInfo","getSafeFileName","parseRangeHeader","UPLOAD_CONTENT_SECURITY_POLICY","getEntityPermissions","sanitizePermissions"],"mappings":"AAAA;;CAEC,GAED,SAASA,mBAAmB,QAAQ,iCAAgC;AACpE,SAASC,wBAAwB,QAAQ,0CAAyC;AAElF,SAASC,wBAAwB,QAAQ,yCAAwC;AACjF,SACEC,yBAAyB,EACzBC,0BAA0B,QACrB,0CAAyC;AAChD,SACEC,yBAAyB,EACzBC,yBAAyB,QACpB,oCAAmC;AAK1C,SAASC,eAAe,QAAQ,gCAA+B;AAC/D,SAASC,aAAa,EAAEC,aAAa,QAAQ,oCAAmC;AAChF,SAASC,mBAAmB,QAAQ,oCAAmC;AACvE,SAASC,eAAe,QAAQ,gCAA+B;AAC/D,SAASC,gBAAgB,QAAQ,iCAAgC;AACjE,SAASC,8BAA8B,QAAQ,4CAA2C;AAC1F,SAASC,oBAAoB,QAAQ,4DAA2D;AAChG,SAASC,mBAAmB,QAAQ,sCAAqC"}
@@ -0,0 +1,14 @@
1
+ import type { Payload } from '../../../index.js';
2
+ import type { JsonObject } from '../../../types/index.js';
3
+ import type { Field, TabAsField } from '../../config/types.js';
4
+ type Args = {
5
+ config: Payload['config'];
6
+ data: JsonObject;
7
+ fields: (Field | TabAsField)[];
8
+ locale: string;
9
+ parentIsLocalized?: boolean;
10
+ };
11
+ /** Projects validation context to one locale without running hooks or changing the write data. */
12
+ export declare function flattenValidationData({ config, data, fields, locale, parentIsLocalized, }: Args): JsonObject;
13
+ export {};
14
+ //# sourceMappingURL=flattenValidationData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flattenValidationData.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/flattenValidationData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAM9D,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IACzB,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,kGAAkG;AAClG,wBAAgB,qBAAqB,CAAC,EACpC,MAAM,EACN,IAAI,EACJ,MAAM,EACN,MAAM,EACN,iBAAyB,GAC1B,EAAE,IAAI,GAAG,UAAU,CAgCnB"}
@@ -0,0 +1,36 @@
1
+ import { deepCopyObjectSimple } from '../../../utilities/deepCopyObject.js';
2
+ import { traverseFields } from '../../../utilities/traverseFields.js';
3
+ import { fieldAffectsData, fieldShouldBeLocalized } from '../../config/types.js';
4
+ /** Projects validation context to one locale without running hooks or changing the write data. */ export function flattenValidationData({ config, data, fields, locale, parentIsLocalized = false }) {
5
+ // Each locale needs its own projection. Merged contexts also retain source array references.
6
+ const result = deepCopyObjectSimple(data);
7
+ const localizedFields = [];
8
+ traverseFields({
9
+ callback: ({ field, parentIsLocalized, ref })=>{
10
+ if (fieldAffectsData(field) && field.name && fieldShouldBeLocalized({
11
+ field,
12
+ parentIsLocalized
13
+ })) {
14
+ localizedFields.push({
15
+ name: field.name,
16
+ ref: ref
17
+ });
18
+ }
19
+ },
20
+ config,
21
+ fields,
22
+ fillEmpty: false,
23
+ parentIsLocalized,
24
+ ref: result
25
+ });
26
+ // Keep locale maps intact while traversing, then project children before their containers.
27
+ for (const { name, ref } of localizedFields.reverse()){
28
+ const value = ref[name];
29
+ if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
30
+ ref[name] = value[locale];
31
+ }
32
+ }
33
+ return result;
34
+ }
35
+
36
+ //# sourceMappingURL=flattenValidationData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/fields/hooks/beforeChange/flattenValidationData.ts"],"sourcesContent":["import type { Payload } from '../../../index.js'\nimport type { JsonObject } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { deepCopyObjectSimple } from '../../../utilities/deepCopyObject.js'\nimport { traverseFields } from '../../../utilities/traverseFields.js'\nimport { fieldAffectsData, fieldShouldBeLocalized } from '../../config/types.js'\n\ntype Args = {\n config: Payload['config']\n data: JsonObject\n fields: (Field | TabAsField)[]\n locale: string\n parentIsLocalized?: boolean\n}\n\n/** Projects validation context to one locale without running hooks or changing the write data. */\nexport function flattenValidationData({\n config,\n data,\n fields,\n locale,\n parentIsLocalized = false,\n}: Args): JsonObject {\n // Each locale needs its own projection. Merged contexts also retain source array references.\n const result = deepCopyObjectSimple(data)\n const localizedFields: { name: string; ref: JsonObject }[] = []\n\n traverseFields({\n callback: ({ field, parentIsLocalized, ref }) => {\n if (\n fieldAffectsData(field) &&\n field.name &&\n fieldShouldBeLocalized({ field, parentIsLocalized })\n ) {\n localizedFields.push({ name: field.name, ref: ref as JsonObject })\n }\n },\n config,\n fields,\n fillEmpty: false,\n parentIsLocalized,\n ref: result,\n })\n\n // Keep locale maps intact while traversing, then project children before their containers.\n for (const { name, ref } of localizedFields.reverse()) {\n const value = ref[name]\n\n if (value !== null && typeof value === 'object' && !Array.isArray(value)) {\n ref[name] = value[locale]\n }\n }\n\n return result\n}\n"],"names":["deepCopyObjectSimple","traverseFields","fieldAffectsData","fieldShouldBeLocalized","flattenValidationData","config","data","fields","locale","parentIsLocalized","result","localizedFields","callback","field","ref","name","push","fillEmpty","reverse","value","Array","isArray"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,EAAEC,sBAAsB,QAAQ,wBAAuB;AAUhF,gGAAgG,GAChG,OAAO,SAASC,sBAAsB,EACpCC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,MAAM,EACNC,oBAAoB,KAAK,EACpB;IACL,6FAA6F;IAC7F,MAAMC,SAASV,qBAAqBM;IACpC,MAAMK,kBAAuD,EAAE;IAE/DV,eAAe;QACbW,UAAU,CAAC,EAAEC,KAAK,EAAEJ,iBAAiB,EAAEK,GAAG,EAAE;YAC1C,IACEZ,iBAAiBW,UACjBA,MAAME,IAAI,IACVZ,uBAAuB;gBAAEU;gBAAOJ;YAAkB,IAClD;gBACAE,gBAAgBK,IAAI,CAAC;oBAAED,MAAMF,MAAME,IAAI;oBAAED,KAAKA;gBAAkB;YAClE;QACF;QACAT;QACAE;QACAU,WAAW;QACXR;QACAK,KAAKJ;IACP;IAEA,2FAA2F;IAC3F,KAAK,MAAM,EAAEK,IAAI,EAAED,GAAG,EAAE,IAAIH,gBAAgBO,OAAO,GAAI;QACrD,MAAMC,QAAQL,GAAG,CAACC,KAAK;QAEvB,IAAII,UAAU,QAAQ,OAAOA,UAAU,YAAY,CAACC,MAAMC,OAAO,CAACF,QAAQ;YACxEL,GAAG,CAACC,KAAK,GAAGI,KAAK,CAACX,OAAO;QAC3B;IACF;IAEA,OAAOE;AACT"}
@@ -9,6 +9,7 @@ type Args = {
9
9
  * Data of the nearest parent block. If no parent block exists, this will be the `undefined`
10
10
  */
11
11
  blockData?: JsonObject;
12
+ blockFields?: Field[];
12
13
  collection: null | SanitizedCollectionConfig;
13
14
  context: RequestContext;
14
15
  data: JsonObject;
@@ -40,6 +41,6 @@ type Args = {
40
41
  skipValidation: boolean;
41
42
  submittedTopLevelFieldNames?: ReadonlySet<string>;
42
43
  };
43
- export declare const promise: ({ id, blockData, collection, context, data, doc, docWithLocales, errors, field, fieldIndex, fieldLabelPath, global, mergeLocaleActions, operation, overrideAccess, parentIndexPath, parentIsLocalized, parentPath, parentSchemaPath, req, siblingData, siblingDoc, siblingDocWithLocales, siblingFields, skipValidation, submittedTopLevelFieldNames, }: Args) => Promise<void>;
44
+ export declare const promise: ({ id, blockData, blockFields, collection, context, data, doc, docWithLocales, errors, field, fieldIndex, fieldLabelPath, global, mergeLocaleActions, operation, overrideAccess, parentIndexPath, parentIsLocalized, parentPath, parentSchemaPath, req, siblingData, siblingDoc, siblingDocWithLocales, siblingFields, skipValidation, submittedTopLevelFieldNames, }: Args) => Promise<void>;
44
45
  export {};
45
46
  //# sourceMappingURL=promise.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/promise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACpF,OAAO,KAAK,EAAS,KAAK,EAAE,UAAU,EAAY,MAAM,uBAAuB,CAAA;AAG/E,OAAO,EAAE,KAAK,cAAc,EAA+B,MAAM,mBAAmB,CAAA;AAkBpF,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;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cAAc,EAAE,OAAO,CAAA;IACvB,2BAA2B,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAClD,CAAA;AAUD,eAAO,MAAM,OAAO,yWA4BjB,IAAI,KAAG,OAAO,CAAC,IAAI,CAisBrB,CAAA"}
@@ -2,8 +2,10 @@ import { MissingEditorProp } from '../../../errors/index.js';
2
2
  import { validateBlocksFilterOptions } from '../../../index.js';
3
3
  import { deepMergeWithSourceArrays } from '../../../utilities/deepMerge.js';
4
4
  import { getTranslatedLabel } from '../../../utilities/getTranslatedLabel.js';
5
+ import { isolateObjectProperty } from '../../../utilities/isolateObjectProperty.js';
5
6
  import { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../../config/types.js';
6
7
  import { getFieldPaths } from '../../getFieldPaths.js';
8
+ import { flattenValidationData } from './flattenValidationData.js';
7
9
  import { getExistingRowDoc } from './getExistingRowDoc.js';
8
10
  import { traverseFields } from './traverseFields.js';
9
11
  function buildFieldLabel(parentLabel, label) {
@@ -20,7 +22,7 @@ function buildFieldLabel(parentLabel, label) {
20
22
  // - Transform data for storage
21
23
  // - beforeDuplicate hooks (if duplicate)
22
24
  // - Unflatten locales
23
- export const promise = async ({ id, blockData, collection, context, data, doc, docWithLocales, errors, field, fieldIndex, fieldLabelPath, global, mergeLocaleActions, operation, overrideAccess, parentIndexPath, parentIsLocalized, parentPath, parentSchemaPath, req, siblingData, siblingDoc, siblingDocWithLocales, siblingFields, skipValidation, submittedTopLevelFieldNames })=>{
25
+ export const promise = async ({ id, blockData, blockFields, collection, context, data, doc, docWithLocales, errors, field, fieldIndex, fieldLabelPath, global, mergeLocaleActions, operation, overrideAccess, parentIndexPath, parentIsLocalized, parentPath, parentSchemaPath, req, siblingData, siblingDoc, siblingDocWithLocales, siblingFields, skipValidation, submittedTopLevelFieldNames })=>{
24
26
  const { indexPath, path, schemaPath } = getFieldPaths({
25
27
  field,
26
28
  index: fieldIndex,
@@ -97,6 +99,26 @@ export const promise = async ({ id, blockData, collection, context, data, doc, d
97
99
  // Validate
98
100
  if (!skipValidationFromHere && 'validate' in field && field.validate) {
99
101
  const valueToValidate = siblingData[field.name];
102
+ // With `locale: 'all'` a localized scalar is a locale-keyed object; validate each locale, not the
103
+ // wrapper. Containers (`group`/`array`/`blocks`) are excluded - per-locale child validation is a follow-up.
104
+ const isLocaleKeyedValue = operationLocale === 'all' && localization && fieldShouldBeLocalized({
105
+ field,
106
+ parentIsLocalized
107
+ }) && field.type !== 'group' && valueToValidate !== null && typeof valueToValidate === 'object' && !Array.isArray(valueToValidate);
108
+ const localizedValuesToValidate = isLocaleKeyedValue ? localization.localeCodes.filter((locale)=>locale in valueToValidate).map((locale)=>({
109
+ locale,
110
+ value: valueToValidate[locale]
111
+ })) : [
112
+ {
113
+ value: valueToValidate
114
+ }
115
+ ];
116
+ // No recognized locales (e.g. `{}`): validate `undefined` once so required/optional still apply.
117
+ if (localizedValuesToValidate.length === 0) {
118
+ localizedValuesToValidate.push({
119
+ value: undefined
120
+ });
121
+ }
100
122
  let jsonError;
101
123
  if (field.type === 'json' && typeof siblingData[field.name] === 'string') {
102
124
  try {
@@ -106,25 +128,66 @@ export const promise = async ({ id, blockData, collection, context, data, doc, d
106
128
  }
107
129
  }
108
130
  const validateFn = field.validate;
109
- const validationResult = await validateFn(valueToValidate, {
110
- ...field,
111
- id,
112
- blockData: blockData,
113
- collectionSlug: collection?.slug,
114
- data: deepMergeWithSourceArrays(doc, data),
115
- event: 'submit',
116
- // @ts-expect-error
117
- jsonError,
118
- operation,
119
- overrideAccess,
120
- path: pathSegments,
121
- preferences: {
122
- fields: {}
123
- },
124
- previousValue: siblingDoc[field.name],
125
- req,
126
- siblingData: deepMergeWithSourceArrays(siblingDoc, siblingData)
127
- });
131
+ let validationResult = true;
132
+ let failedLocale;
133
+ const validationData = deepMergeWithSourceArrays(doc, data);
134
+ const validationSiblingData = deepMergeWithSourceArrays(siblingDoc, siblingData);
135
+ for (const { locale, value } of localizedValuesToValidate){
136
+ // Scope `req.locale` to the current locale via a proxy, without mutating the shared request.
137
+ const validationReq = locale ? isolateObjectProperty(req, 'locale') : req;
138
+ if (locale) {
139
+ validationReq.locale = locale;
140
+ }
141
+ const localeContext = locale ? {
142
+ blockData: blockData && blockFields ? flattenValidationData({
143
+ config: req.payload.config,
144
+ data: blockData,
145
+ fields: blockFields,
146
+ locale,
147
+ parentIsLocalized
148
+ }) : blockData,
149
+ data: flattenValidationData({
150
+ config: req.payload.config,
151
+ data: validationData,
152
+ fields: collection?.fields || global?.fields,
153
+ locale
154
+ }),
155
+ siblingData: flattenValidationData({
156
+ config: req.payload.config,
157
+ data: validationSiblingData,
158
+ fields: siblingFields,
159
+ locale,
160
+ parentIsLocalized
161
+ })
162
+ } : {
163
+ blockData,
164
+ data: validationData,
165
+ siblingData: validationSiblingData
166
+ };
167
+ validationResult = await validateFn(value, {
168
+ ...field,
169
+ id,
170
+ blockData: localeContext.blockData,
171
+ collectionSlug: collection?.slug,
172
+ data: localeContext.data,
173
+ event: 'submit',
174
+ // @ts-expect-error generic validation options cannot infer JSON fields
175
+ jsonError,
176
+ operation,
177
+ overrideAccess,
178
+ path: pathSegments,
179
+ preferences: {
180
+ fields: {}
181
+ },
182
+ previousValue: locale ? siblingDoc[field.name]?.[locale] : siblingDoc[field.name],
183
+ req: validationReq,
184
+ siblingData: localeContext.siblingData
185
+ });
186
+ if (typeof validationResult === 'string') {
187
+ failedLocale = locale;
188
+ break;
189
+ }
190
+ }
128
191
  if (typeof validationResult === 'string') {
129
192
  let filterOptionsError = false;
130
193
  if (field.type === 'blocks' && field.filterOptions) {
@@ -163,7 +226,7 @@ export const promise = async ({ id, blockData, collection, context, data, doc, d
163
226
  // field itself => only push the error if the field is not a block field with validation failure due to filterOptions
164
227
  const fieldLabel = buildFieldLabel(fieldLabelPath, getTranslatedLabel(field?.label || field?.name, req.i18n));
165
228
  errors.push({
166
- label: fieldLabel,
229
+ label: failedLocale ? `${fieldLabel} (${failedLocale})` : fieldLabel,
167
230
  message: validationResult,
168
231
  path
169
232
  });
@@ -177,8 +240,13 @@ export const promise = async ({ id, blockData, collection, context, data, doc, d
177
240
  })) {
178
241
  mergeLocaleActions.push(()=>{
179
242
  const localeData = {};
243
+ // With `locale: 'all'`, siblingData holds a locale-keyed object (`{ en, es }`) rather than a single
244
+ // locale's value - take each submitted locale, falling back to the existing doc for ones not sent.
245
+ const submittedValue = siblingData[field.name];
246
+ const isAllLocales = req.locale === 'all' && submittedValue !== null && typeof submittedValue === 'object' && !Array.isArray(submittedValue);
180
247
  for (const locale of localization.localeCodes){
181
- const fieldValue = locale === req.locale ? siblingData[field.name] : siblingDocWithLocales?.[field.name]?.[locale];
248
+ const existingValue = siblingDocWithLocales?.[field.name]?.[locale];
249
+ const fieldValue = isAllLocales ? locale in submittedValue ? submittedValue[locale] : existingValue : locale === req.locale ? submittedValue : existingValue;
182
250
  // update locale value if it's not undefined
183
251
  if (typeof fieldValue !== 'undefined') {
184
252
  localeData[locale] = fieldValue;
@@ -201,6 +269,7 @@ export const promise = async ({ id, blockData, collection, context, data, doc, d
201
269
  promises.push(traverseFields({
202
270
  id,
203
271
  blockData,
272
+ blockFields,
204
273
  collection,
205
274
  context,
206
275
  data,
@@ -244,6 +313,7 @@ export const promise = async ({ id, blockData, collection, context, data, doc, d
244
313
  promises.push(traverseFields({
245
314
  id,
246
315
  blockData: row,
316
+ blockFields: block.fields,
247
317
  collection,
248
318
  context,
249
319
  data,
@@ -279,6 +349,7 @@ export const promise = async ({ id, blockData, collection, context, data, doc, d
279
349
  await traverseFields({
280
350
  id,
281
351
  blockData,
352
+ blockFields,
282
353
  collection,
283
354
  context,
284
355
  data,
@@ -337,6 +408,7 @@ export const promise = async ({ id, blockData, collection, context, data, doc, d
337
408
  await traverseFields({
338
409
  id,
339
410
  blockData,
411
+ blockFields,
340
412
  collection,
341
413
  context,
342
414
  data,
@@ -443,6 +515,7 @@ export const promise = async ({ id, blockData, collection, context, data, doc, d
443
515
  await traverseFields({
444
516
  id,
445
517
  blockData,
518
+ blockFields,
446
519
  collection,
447
520
  context,
448
521
  data,
@@ -473,6 +546,7 @@ export const promise = async ({ id, blockData, collection, context, data, doc, d
473
546
  await traverseFields({
474
547
  id,
475
548
  blockData,
549
+ blockFields,
476
550
  collection,
477
551
  context,
478
552
  data,