payload 0.17.2 → 0.18.1

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 (252) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/admin/components/elements/Autosave/index.js +3 -3
  3. package/dist/admin/components/elements/DeleteDocument/index.js +5 -2
  4. package/dist/admin/components/forms/Form/context.js +25 -12
  5. package/dist/admin/components/forms/Form/types.js +3 -1
  6. package/dist/admin/components/forms/withCondition/index.js +34 -8
  7. package/dist/admin/components/utilities/RenderCustomComponent/index.js +1 -3
  8. package/dist/auth/getExtractJWT.js +1 -1
  9. package/dist/auth/graphql/resolvers/access.d.ts +3 -2
  10. package/dist/auth/graphql/resolvers/access.js +14 -10
  11. package/dist/auth/graphql/resolvers/forgotPassword.d.ts +2 -2
  12. package/dist/auth/graphql/resolvers/forgotPassword.js +12 -7
  13. package/dist/auth/graphql/resolvers/init.d.ts +3 -4
  14. package/dist/auth/graphql/resolvers/init.js +11 -8
  15. package/dist/auth/graphql/resolvers/login.d.ts +5 -2
  16. package/dist/auth/graphql/resolvers/login.js +9 -6
  17. package/dist/auth/graphql/resolvers/logout.d.ts +2 -2
  18. package/dist/auth/graphql/resolvers/logout.js +10 -7
  19. package/dist/auth/graphql/resolvers/me.d.ts +3 -2
  20. package/dist/auth/graphql/resolvers/me.js +13 -9
  21. package/dist/auth/graphql/resolvers/refresh.d.ts +3 -2
  22. package/dist/auth/graphql/resolvers/refresh.js +7 -7
  23. package/dist/auth/graphql/resolvers/resetPassword.d.ts +3 -2
  24. package/dist/auth/graphql/resolvers/resetPassword.js +9 -7
  25. package/dist/auth/graphql/resolvers/unlock.d.ts +3 -2
  26. package/dist/auth/graphql/resolvers/unlock.js +10 -7
  27. package/dist/auth/graphql/resolvers/verifyEmail.d.ts +3 -2
  28. package/dist/auth/graphql/resolvers/verifyEmail.js +9 -7
  29. package/dist/auth/operations/access.d.ts +1 -2
  30. package/dist/auth/operations/access.js +2 -3
  31. package/dist/auth/operations/forgotPassword.d.ts +1 -0
  32. package/dist/auth/operations/forgotPassword.js +2 -3
  33. package/dist/auth/operations/init.d.ts +4 -2
  34. package/dist/auth/operations/init.js +2 -4
  35. package/dist/auth/operations/local/forgotPassword.d.ts +3 -2
  36. package/dist/auth/operations/local/forgotPassword.js +10 -8
  37. package/dist/auth/operations/local/login.d.ts +3 -2
  38. package/dist/auth/operations/local/login.js +10 -6
  39. package/dist/auth/operations/local/resetPassword.d.ts +14 -2
  40. package/dist/auth/operations/local/resetPassword.js +13 -10
  41. package/dist/auth/operations/local/unlock.d.ts +12 -2
  42. package/dist/auth/operations/local/unlock.js +14 -6
  43. package/dist/auth/operations/local/verifyEmail.d.ts +7 -2
  44. package/dist/auth/operations/local/verifyEmail.js +9 -5
  45. package/dist/auth/operations/login.d.ts +3 -2
  46. package/dist/auth/operations/login.js +4 -4
  47. package/dist/auth/operations/logout.js +2 -3
  48. package/dist/auth/operations/me.d.ts +3 -2
  49. package/dist/auth/operations/me.js +4 -4
  50. package/dist/auth/operations/refresh.d.ts +2 -0
  51. package/dist/auth/operations/refresh.js +5 -5
  52. package/dist/auth/operations/registerFirstUser.d.ts +3 -2
  53. package/dist/auth/operations/registerFirstUser.js +1 -1
  54. package/dist/auth/operations/resetPassword.d.ts +3 -0
  55. package/dist/auth/operations/resetPassword.js +6 -4
  56. package/dist/auth/operations/unlock.d.ts +11 -1
  57. package/dist/auth/operations/unlock.js +1 -1
  58. package/dist/auth/operations/verifyEmail.d.ts +6 -1
  59. package/dist/auth/operations/verifyEmail.js +1 -1
  60. package/dist/auth/requestHandlers/access.d.ts +0 -1
  61. package/dist/auth/requestHandlers/access.js +3 -2
  62. package/dist/auth/requestHandlers/forgotPassword.js +3 -2
  63. package/dist/auth/requestHandlers/init.js +6 -2
  64. package/dist/auth/requestHandlers/login.js +4 -3
  65. package/dist/auth/requestHandlers/logout.js +8 -3
  66. package/dist/auth/requestHandlers/me.d.ts +1 -1
  67. package/dist/auth/requestHandlers/me.js +9 -6
  68. package/dist/auth/requestHandlers/refresh.js +4 -3
  69. package/dist/auth/requestHandlers/registerFirstUser.d.ts +1 -1
  70. package/dist/auth/requestHandlers/registerFirstUser.js +8 -4
  71. package/dist/auth/requestHandlers/resetPassword.d.ts +2 -2
  72. package/dist/auth/requestHandlers/resetPassword.js +7 -6
  73. package/dist/auth/requestHandlers/unlock.js +3 -2
  74. package/dist/auth/requestHandlers/verifyEmail.d.ts +2 -2
  75. package/dist/auth/requestHandlers/verifyEmail.js +5 -4
  76. package/dist/auth/strategies/apiKey.d.ts +2 -4
  77. package/dist/auth/strategies/apiKey.js +6 -4
  78. package/dist/auth/strategies/jwt.d.ts +2 -6
  79. package/dist/auth/strategies/jwt.js +4 -3
  80. package/dist/bin/generateTypes.js +15 -2
  81. package/dist/collections/buildEndpoints.d.ts +4 -0
  82. package/dist/collections/buildEndpoints.js +132 -0
  83. package/dist/collections/config/defaults.d.ts +1 -0
  84. package/dist/collections/config/defaults.js +2 -1
  85. package/dist/collections/config/schema.js +6 -1
  86. package/dist/collections/config/types.d.ts +12 -3
  87. package/dist/collections/graphql/init.d.ts +3 -2
  88. package/dist/collections/graphql/init.js +104 -62
  89. package/dist/collections/graphql/resolvers/create.d.ts +2 -1
  90. package/dist/collections/graphql/resolvers/create.js +10 -8
  91. package/dist/collections/graphql/resolvers/delete.js +7 -4
  92. package/dist/collections/graphql/resolvers/find.d.ts +18 -1
  93. package/dist/collections/graphql/resolvers/find.js +10 -9
  94. package/dist/collections/graphql/resolvers/findByID.d.ts +12 -1
  95. package/dist/collections/graphql/resolvers/findByID.js +14 -12
  96. package/dist/collections/graphql/resolvers/findVersionByID.d.ts +3 -1
  97. package/dist/collections/graphql/resolvers/findVersionByID.js +10 -8
  98. package/dist/collections/graphql/resolvers/findVersions.d.ts +3 -2
  99. package/dist/collections/graphql/resolvers/findVersions.js +9 -6
  100. package/dist/collections/graphql/resolvers/restoreVersion.d.ts +4 -2
  101. package/dist/collections/graphql/resolvers/restoreVersion.js +9 -6
  102. package/dist/collections/graphql/resolvers/update.d.ts +14 -1
  103. package/dist/collections/graphql/resolvers/update.js +9 -7
  104. package/dist/collections/init.js +7 -53
  105. package/dist/collections/operations/create.d.ts +1 -2
  106. package/dist/collections/operations/create.js +4 -5
  107. package/dist/collections/operations/delete.d.ts +2 -2
  108. package/dist/collections/operations/delete.js +7 -7
  109. package/dist/collections/operations/find.js +4 -3
  110. package/dist/collections/operations/findByID.d.ts +1 -2
  111. package/dist/collections/operations/findByID.js +4 -3
  112. package/dist/collections/operations/findVersionByID.d.ts +2 -3
  113. package/dist/collections/operations/findVersionByID.js +3 -3
  114. package/dist/collections/operations/findVersions.d.ts +1 -2
  115. package/dist/collections/operations/findVersions.js +3 -3
  116. package/dist/collections/operations/local/create.d.ts +2 -1
  117. package/dist/collections/operations/local/create.js +11 -10
  118. package/dist/collections/operations/local/delete.d.ts +2 -1
  119. package/dist/collections/operations/local/delete.js +11 -7
  120. package/dist/collections/operations/local/find.d.ts +2 -1
  121. package/dist/collections/operations/local/find.js +12 -7
  122. package/dist/collections/operations/local/findByID.d.ts +2 -1
  123. package/dist/collections/operations/local/findByID.js +14 -9
  124. package/dist/collections/operations/local/findVersionByID.d.ts +2 -1
  125. package/dist/collections/operations/local/findVersionByID.js +15 -11
  126. package/dist/collections/operations/local/findVersions.d.ts +2 -1
  127. package/dist/collections/operations/local/findVersions.js +11 -7
  128. package/dist/collections/operations/local/restoreVersion.d.ts +2 -1
  129. package/dist/collections/operations/local/restoreVersion.js +12 -7
  130. package/dist/collections/operations/local/update.d.ts +2 -1
  131. package/dist/collections/operations/local/update.js +9 -7
  132. package/dist/collections/operations/restoreVersion.d.ts +2 -3
  133. package/dist/collections/operations/restoreVersion.js +3 -3
  134. package/dist/collections/operations/update.d.ts +1 -2
  135. package/dist/collections/operations/update.js +6 -7
  136. package/dist/collections/requestHandlers/create.d.ts +1 -1
  137. package/dist/collections/requestHandlers/create.js +6 -5
  138. package/dist/collections/requestHandlers/delete.js +4 -3
  139. package/dist/collections/requestHandlers/find.d.ts +1 -1
  140. package/dist/collections/requestHandlers/find.js +9 -8
  141. package/dist/collections/requestHandlers/findByID.d.ts +1 -1
  142. package/dist/collections/requestHandlers/findByID.js +14 -11
  143. package/dist/collections/requestHandlers/findVersionByID.d.ts +1 -1
  144. package/dist/collections/requestHandlers/findVersionByID.js +10 -5
  145. package/dist/collections/requestHandlers/findVersions.d.ts +1 -1
  146. package/dist/collections/requestHandlers/findVersions.js +8 -6
  147. package/dist/collections/requestHandlers/restoreVersion.d.ts +1 -1
  148. package/dist/collections/requestHandlers/restoreVersion.js +7 -5
  149. package/dist/collections/requestHandlers/update.d.ts +1 -1
  150. package/dist/collections/requestHandlers/update.js +6 -5
  151. package/dist/collections/tests/collections.spec.js +11 -2
  152. package/dist/collections/tests/endpoints.spec.d.ts +1 -0
  153. package/dist/collections/tests/endpoints.spec.js +71 -0
  154. package/dist/collections/tests/uploads.spec.js +2 -2
  155. package/dist/config/types.d.ts +6 -1
  156. package/dist/config/validate.js +1 -2
  157. package/dist/express/mountEndpoints.d.ts +4 -0
  158. package/dist/express/mountEndpoints.js +9 -0
  159. package/dist/fields/config/sanitize.js +10 -2
  160. package/dist/fields/hooks/beforeChange/promise.js +4 -4
  161. package/dist/globals/buildEndpoints.d.ts +4 -0
  162. package/dist/globals/buildEndpoints.js +47 -0
  163. package/dist/globals/config/sanitize.js +3 -1
  164. package/dist/globals/config/schema.js +6 -1
  165. package/dist/globals/config/types.d.ts +2 -4
  166. package/dist/globals/graphql/init.d.ts +3 -2
  167. package/dist/globals/graphql/init.js +38 -30
  168. package/dist/globals/graphql/resolvers/findOne.d.ts +1 -2
  169. package/dist/globals/graphql/resolvers/findOne.js +10 -8
  170. package/dist/globals/graphql/resolvers/findVersionByID.d.ts +3 -2
  171. package/dist/globals/graphql/resolvers/findVersionByID.js +10 -8
  172. package/dist/globals/graphql/resolvers/findVersions.d.ts +1 -2
  173. package/dist/globals/graphql/resolvers/findVersions.js +10 -8
  174. package/dist/globals/graphql/resolvers/restoreVersion.d.ts +9 -1
  175. package/dist/globals/graphql/resolvers/restoreVersion.js +10 -8
  176. package/dist/globals/graphql/resolvers/update.d.ts +13 -2
  177. package/dist/globals/graphql/resolvers/update.js +10 -8
  178. package/dist/globals/init.js +8 -14
  179. package/dist/globals/operations/findOne.d.ts +13 -1
  180. package/dist/globals/operations/findOne.js +4 -4
  181. package/dist/globals/operations/findVersionByID.d.ts +1 -1
  182. package/dist/globals/operations/findVersionByID.js +4 -4
  183. package/dist/globals/operations/findVersions.js +3 -3
  184. package/dist/globals/operations/local/findOne.d.ts +14 -2
  185. package/dist/globals/operations/local/findOne.js +12 -8
  186. package/dist/globals/operations/local/findVersionByID.d.ts +2 -2
  187. package/dist/globals/operations/local/findVersionByID.js +11 -8
  188. package/dist/globals/operations/local/findVersions.d.ts +2 -2
  189. package/dist/globals/operations/local/findVersions.js +12 -9
  190. package/dist/globals/operations/local/restoreVersion.d.ts +2 -1
  191. package/dist/globals/operations/local/restoreVersion.js +10 -6
  192. package/dist/globals/operations/local/update.d.ts +15 -2
  193. package/dist/globals/operations/local/update.js +12 -8
  194. package/dist/globals/operations/restoreVersion.d.ts +2 -4
  195. package/dist/globals/operations/restoreVersion.js +3 -4
  196. package/dist/globals/operations/update.d.ts +14 -3
  197. package/dist/globals/operations/update.js +6 -7
  198. package/dist/globals/requestHandlers/findOne.d.ts +1 -1
  199. package/dist/globals/requestHandlers/findOne.js +8 -9
  200. package/dist/globals/requestHandlers/findVersionByID.d.ts +1 -1
  201. package/dist/globals/requestHandlers/findVersionByID.js +11 -9
  202. package/dist/globals/requestHandlers/findVersions.d.ts +5 -1
  203. package/dist/globals/requestHandlers/findVersions.js +9 -10
  204. package/dist/globals/requestHandlers/globals.spec.js +14 -1
  205. package/dist/globals/requestHandlers/restoreVersion.d.ts +4 -1
  206. package/dist/globals/requestHandlers/restoreVersion.js +8 -9
  207. package/dist/globals/requestHandlers/update.d.ts +1 -2
  208. package/dist/globals/requestHandlers/update.js +8 -9
  209. package/dist/graphql/index.d.ts +6 -57
  210. package/dist/graphql/index.js +88 -107
  211. package/dist/graphql/schema/buildBlockType.d.ts +2 -1
  212. package/dist/graphql/schema/buildBlockType.js +5 -4
  213. package/dist/graphql/schema/buildMutationInputType.d.ts +2 -1
  214. package/dist/graphql/schema/buildMutationInputType.js +5 -6
  215. package/dist/graphql/schema/buildObjectType.d.ts +3 -2
  216. package/dist/graphql/schema/buildObjectType.js +32 -32
  217. package/dist/graphql/schema/buildPoliciesType.d.ts +2 -1
  218. package/dist/graphql/schema/buildPoliciesType.js +4 -4
  219. package/dist/index.d.ts +43 -17
  220. package/dist/index.js +44 -65
  221. package/dist/preferences/graphql/init.d.ts +3 -2
  222. package/dist/preferences/graphql/init.js +16 -10
  223. package/dist/preferences/init.js +7 -5
  224. package/dist/preferences/operations/delete.d.ts +3 -3
  225. package/dist/preferences/operations/delete.js +4 -9
  226. package/dist/preferences/operations/findOne.js +2 -3
  227. package/dist/preferences/operations/update.js +2 -3
  228. package/dist/preferences/requestHandlers/delete.js +3 -2
  229. package/dist/preferences/requestHandlers/findOne.d.ts +1 -1
  230. package/dist/preferences/requestHandlers/findOne.js +5 -4
  231. package/dist/preferences/requestHandlers/update.d.ts +1 -1
  232. package/dist/preferences/requestHandlers/update.js +5 -4
  233. package/dist/preferences/types.d.ts +2 -2
  234. package/dist/versions/drafts/saveCollectionDraft.js +2 -2
  235. package/dist/versions/ensurePublishedCollectionVersion.js +2 -2
  236. package/dist/versions/saveCollectionVersion.js +2 -2
  237. package/dist/webpack/getDevConfig.js +7 -1
  238. package/docs/access-control/collections.mdx +80 -8
  239. package/docs/access-control/overview.mdx +2 -2
  240. package/docs/admin/customizing-css.mdx +0 -10
  241. package/docs/authentication/using-middleware.mdx +1 -1
  242. package/docs/configuration/collections.mdx +8 -7
  243. package/docs/configuration/globals.mdx +1 -0
  244. package/docs/fields/overview.mdx +1 -30
  245. package/docs/rest-api/overview.mdx +46 -0
  246. package/package.json +4 -6
  247. package/dist/graphql/bindResolvers.d.ts +0 -57
  248. package/dist/graphql/bindResolvers.js +0 -65
  249. package/dist/init/bindOperations.d.ts +0 -67
  250. package/dist/init/bindOperations.js +0 -73
  251. package/dist/init/bindRequestHandlers.d.ts +0 -67
  252. package/dist/init/bindRequestHandlers.js +0 -73
@@ -64,7 +64,7 @@ const saveCollectionVersion = async ({ payload, config, req, id, docWithLocales,
64
64
  if (config.versions.maxPerDoc) {
65
65
  (0, enforceMaxVersions_1.enforceMaxVersions)({
66
66
  id,
67
- payload: this,
67
+ payload,
68
68
  Model: VersionModel,
69
69
  entityLabel: config.labels.plural,
70
70
  entityType: 'collection',
@@ -78,4 +78,4 @@ const saveCollectionVersion = async ({ payload, config, req, id, docWithLocales,
78
78
  return createdVersion;
79
79
  };
80
80
  exports.saveCollectionVersion = saveCollectionVersion;
81
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2F2ZUNvbGxlY3Rpb25WZXJzaW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3ZlcnNpb25zL3NhdmVDb2xsZWN0aW9uVmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFFQSw2REFBMEQ7QUFFMUQsaUdBQXlFO0FBQ3pFLHlEQUFzRDtBQVUvQyxNQUFNLHFCQUFxQixHQUFHLEtBQUssRUFBRSxFQUMxQyxPQUFPLEVBQ1AsTUFBTSxFQUNOLEdBQUcsRUFDSCxFQUFFLEVBQ0YsY0FBYyxHQUNULEVBQWlCLEVBQUU7O0lBQ3hCLE1BQU0sWUFBWSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDO0lBRW5ELElBQUksT0FBTyxHQUFHLGNBQWMsQ0FBQztJQUU3QixJQUFJLE1BQUEsTUFBTSxDQUFDLFFBQVEs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FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLHFEQUFxRCxNQUFNLENBQUMsTUFBTSxDQUFDLFFBQVEsWUFBWSxFQUFFLEdBQUcsQ0FBQyxDQUFDO1FBQ25ILE9BQU8sQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0tBQzNCO0lBRUQsSUFBSSxNQUFNLENBQUMsUUFBUSxDQUFDLFNBQVMsRUFBRTtRQUM3QixJQUFBLHVDQUFrQixFQUFDO1lBQ2pCLEVBQUU7WUFDRixPQUFPO1lBQ1AsS0FBSyxFQUFFLFlBQVk7WUFDbkIsV0FBVyxFQUFFLE1BQU0sQ0FBQyxNQUFNLENBQUMsTUFBTTtZQUNqQyxVQUFVLEVBQUUsWUFBWTtZQUN4QixHQUFHLEVBQUUsTUFBTSxDQUFDLFFBQVEsQ0FBQyxTQUFTO1NBQy9CLENBQUMsQ0FBQztLQUNKO0lBRUQsSUFBSSxjQUFjLEVBQUU7UUFDbEIsY0FBYyxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxjQUFjLENBQUMsQ0FBQyxDQUFDO1FBQzVELGNBQWMsR0FBRyxJQUFBLGdDQUFzQixFQUFDLGNBQWMsQ0FBQyxDQUFDO0tBQ3pEO0lBRUQsT0FBTyxjQUFjLENBQUM7QUFDeEIsQ0FBQyxDQUFDO0FBckZXLFFBQUEscUJBQXFCLHlCQXFGaEMifQ==
@@ -9,6 +9,12 @@ exports.default = (payloadConfig) => {
9
9
  const baseConfig = (0, getBaseConfig_1.default)(payloadConfig);
10
10
  let config = {
11
11
  ...baseConfig,
12
+ cache: {
13
+ type: 'filesystem',
14
+ buildDependencies: {
15
+ config: [__filename],
16
+ },
17
+ },
12
18
  entry: {
13
19
  ...baseConfig.entry,
14
20
  main: [
@@ -51,4 +57,4 @@ exports.default = (payloadConfig) => {
51
57
  }
52
58
  return config;
53
59
  };
54
- //# sourceMappingURL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yxFQUFFLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxvQkFBb0IsQ0FBQyxDQUFDO3FCQUNqRDtpQkFDRjthQUNGO1lBQ0QsT0FBTyxDQUFDLE9BQU8sQ0FBQyxhQUFhLENBQUM7U0FDL0I7S0FDRixDQUFDLENBQUM7SUFFSCxJQUFJLGFBQWEsQ0FBQyxLQUFLLENBQUMsT0FBTyxJQUFJLE9BQU8sYUFBYSxDQUFDLEtBQUssQ0FBQyxPQUFPLEtBQUssVUFBVSxFQUFFO1FBQ3BGLE1BQU0sR0FBRyxhQUFhLENBQUMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztLQUM5QztJQUVELE9BQU8sTUFBTSxDQUFDO0FBQ2hCLENBQUMsQ0FBQyJ9
@@ -46,52 +46,124 @@ export default {
46
46
 
47
47
  Returns a boolean which allows/denies access to the `create` request.
48
48
 
49
- **Available argument properties :**
49
+ **Available argument properties:**
50
50
 
51
51
  | Option | Description |
52
52
  | ---------- | ----------- |
53
53
  | **`req`** | The Express `request` object containing the currently authenticated `user` |
54
54
  | **`data`** | The data passed to create the document with. |
55
55
 
56
+ **Example:**
57
+
58
+ ```js
59
+ const PublicUsers = {
60
+ slug: 'public-users',
61
+ access: {
62
+ // highlight-start
63
+ // allow guest users to self-registration
64
+ create: () => true,
65
+ // highlight-end
66
+ ...
67
+ },
68
+ fields: [ ... ],
69
+ }
70
+ ```
71
+
56
72
  ### Read
57
73
 
58
74
  Read access functions can return a boolean result or optionally return a [query constraint](/docs/queries/overview) which limits the documents that are returned to only those that match the constraint you provide. This can be helpful to restrict users' access to only certain documents however you specify.
59
75
 
60
- **Available argument properties :**
76
+ **Available argument properties:**
61
77
 
62
78
  | Option | Description |
63
79
  | --------- | ----------- |
64
80
  | **`req`** | The Express `request` object containing the currently authenticated `user` |
65
- | **`id`** | `id` of document requested, if within `findByID`. |
81
+ | **`id`** | `id` of document requested, if within `findByID` |
82
+
83
+ **Example:**
84
+
85
+ ```js
86
+ const canReadPage = ({ req: { user } }) => {
87
+ // allow authenticated users
88
+ if (user) {
89
+ return true;
90
+ }
91
+ // using a query constraint, guest users can access when a field named 'isPublic' is set to true
92
+ return {
93
+ where: {
94
+ // assumes we have a checkbox field named 'isPublic'
95
+ isPublic: {
96
+ equals: true
97
+ }
98
+ }
99
+ }
100
+ };
101
+ ```
66
102
 
67
103
  ### Update
68
104
 
69
105
  Update access functions can return a boolean result or optionally return a [query constraint](/docs/queries/overview) to limit the document(s) that can be updated by the currently authenticated user. For example, returning a `query` from the `update` Access Control is helpful in cases where you would like to restrict a user to only being able to update the documents containing a `createdBy` relationship field equal to the user's ID.
70
106
 
71
- **Available argument properties :**
107
+ **Available argument properties:**
72
108
 
73
109
  | Option | Description |
74
110
  | ---------- | ----------- |
75
111
  | **`req`** | The Express `request` object containing the currently authenticated `user` |
76
112
  | **`id`** | `id` of document requested to update |
77
- | **`data`** | The data passed to update the document with. |
113
+ | **`data`** | The data passed to update the document with |
114
+
115
+ **Example:**
116
+
117
+ ```js
118
+
119
+ const canUpdateUser = ({ req: { user }, id }) => {
120
+ // allow users with a role of 'admin'
121
+ if (user.roles && user.roles.some((role) => role === 'admin')) {
122
+ return true;
123
+ }
124
+ // allow any other users to update only oneself
125
+ return user.id === id;
126
+ };
127
+ ```
78
128
 
79
129
  ### Delete
80
130
 
81
131
  Similarly to the Update function, returns a boolean or a [query constraint](/docs/queries/overview) to limit which documents can be deleted by which users.
82
132
 
83
- **Available argument properties :**
133
+ **Available argument properties:**
84
134
 
85
135
  | Option | Description |
86
136
  | --------- | ----------- |
87
137
  | **`req`** | The Express `request` object with additional `user` property, which is the currently logged in user |
88
138
  | **`id`** | `id` of document requested to delete |
89
139
 
140
+ **Example:**
141
+
142
+ ```js
143
+ const canDeleteCustomer = async ({ req, id }) => {
144
+ if (!id) {
145
+ // allow the admin UI to show controls to delete since it is indeterminate without the id
146
+ return true;
147
+ }
148
+ // query another collection using the id
149
+ const result = await req.payload.find({
150
+ collection: 'contracts',
151
+ limit: 0,
152
+ depth: 0,
153
+ where: {
154
+ customer: { equals: id },
155
+ },
156
+ });
157
+
158
+ return result.totalDocs === 0;
159
+ };
160
+ ```
161
+
90
162
  ### Admin
91
163
 
92
164
  If the Collection is [used to access the Payload Admin panel](/docs/admin/overview#the-admin-user-collection), the `Admin` Access Control function determines whether or not the currently logged in user can access the admin UI.
93
165
 
94
- **Available argument properties :**
166
+ **Available argument properties:**
95
167
 
96
168
  | Option | Description |
97
169
  | --------- | ----------- |
@@ -101,7 +173,7 @@ If the Collection is [used to access the Payload Admin panel](/docs/admin/overvi
101
173
 
102
174
  Determines which users can [unlock](/docs/authentication/operations#unlock) other users who may be blocked from authenticating successfully due to [failing too many login attempts](/docs/authentication/config#options).
103
175
 
104
- **Available argument properties :**
176
+ **Available argument properties:**
105
177
 
106
178
  | Option | Description |
107
179
  | --------- | ----------- |
@@ -50,7 +50,7 @@ You can manage access within Payload on three different levels:
50
50
  <Banner type="success">
51
51
  <strong>Note:</strong><br/>
52
52
  Access control functions are utilized in two places. It's important to understand how and when your access control is executed.
53
- <Banner />
53
+ </Banner>
54
54
 
55
55
  #### As you execute operations
56
56
 
@@ -67,6 +67,6 @@ To accomplish this, Payload ships with an `Access` operation, which is executed
67
67
  <Banner type="warning">
68
68
  <strong>Important:</strong><br/>
69
69
  When your access control functions are executed via the <strong>access</strong> operation, the <strong>id</strong> and <strong>data</strong> arguments will be <strong>undefined</strong>, because Payload is executing your functions without referencing a specific document.
70
- <Banner />
70
+ </Banner>
71
71
 
72
72
  If you use `id` or `data` within your access control functions, make sure to check that they are defined first. If they are not, then you can assume that your access control is being executed via the `access` operation, to determine solely what the user can do within the Admin UI.
@@ -35,16 +35,6 @@ You can specify your own SCSS variable stylesheet that will allow for the overri
35
35
 
36
36
  To do so, provide your base Payload config with a path to your own SCSS variable sheet.
37
37
 
38
- **NOTE: Before you start editing your SCSS file, make sure you install 'sass-loader' & 'node-sass' as dev dependencies.**
39
- **Node**
40
- ```
41
- npm install sass-loader node-sass --save-dev
42
- ```
43
- **YARN**
44
- ```
45
- yarn add sass-loader node-sass --save-dev
46
- ```
47
-
48
38
  **Example in payload.config.js:**
49
39
  ```js
50
40
  import { buildConfig } from 'payload/config';
@@ -6,7 +6,7 @@ desc: Make full use of Payload's built-in authentication with your own custom Ex
6
6
  keywords: authentication, middleware, config, configuration, documentation, Content Management System, cms, headless, javascript, node, react, express
7
7
  ---
8
8
 
9
- Because Payload uses your existing Express server, you are free to add whatever logic you need to your app through endpoints of your own. However, Payload does not add its middleware to your Express app itself—instead, ist scopes all of its middleware to Payload-specific routers.
9
+ Because Payload uses your existing Express server, you are free to add whatever logic you need to your app through endpoints of your own. However, Payload does not add its middleware to your Express app itself—instead, it scopes all of its middleware to Payload-specific routers.
10
10
 
11
11
  This approach has a ton of benefits - it's great for isolation of concerns and limiting scope, but it also means that your additional routes won't have access to Payload's user authentication.
12
12
 
@@ -25,6 +25,7 @@ It's often best practice to write your Collections in separate files and then im
25
25
  | **`upload`** | Specify options if you would like this Collection to support file uploads. For more, consult the [Uploads](/docs/upload/overview) documentation. |
26
26
  | **`timestamps`** | Set to false to disable documents' automatically generated `createdAt` and `updatedAt` timestamps. |
27
27
  | **`versions`** | Set to true to enable default options, or configure with object properties. [More](/docs/versions/overview#collection-config)|
28
+ | **`endpoints`** | Add custom routes to the REST API. [More](/docs/rest-api#custom-endpoints) |
28
29
 
29
30
  *\* An asterisk denotes that a property is required.*
30
31
 
@@ -80,25 +81,25 @@ If the function is specified, a Preview button will automatically appear in the
80
81
  **Example collection with preview function:**
81
82
 
82
83
  ```js
83
- {
84
+ const Posts = {
84
85
  slug: 'posts',
85
86
  fields: [
86
87
  {
87
88
  name: 'slug',
88
89
  type: 'text',
89
90
  required: true,
90
- }
91
- ]
91
+ },
92
+ ],
92
93
  admin: {
93
94
  preview: (doc, { locale }) => {
94
95
  if (doc?.slug) {
95
- return `https://bigbird.com/preview/posts/${doc.slug}?locale=${locale}`,
96
+ return `https://bigbird.com/preview/posts/${doc.slug}?locale=${locale}`;
96
97
  }
97
98
 
98
99
  return null;
99
- }
100
- }
101
- }
100
+ },
101
+ },
102
+ };
102
103
  ```
103
104
 
104
105
  ### Access control
@@ -22,6 +22,7 @@ As with Collection configs, it's often best practice to write your Globals in se
22
22
  | **`hooks`** | Entry points to "tie in" to collection actions at specific points. [More](/docs/hooks/overview#global-hooks) |
23
23
  | **`access`** | Provide access control functions to define exactly who should be able to do what with this Global. [More](/docs/access-control/overview/#globals) |
24
24
  | **`versions`** | Set to true to enable default options, or configure with object properties. [More](/docs/versions/overview#globals-config)|
25
+ | **`endpoints`** | Add custom routes to the REST API. [More](/docs/rest-api#custom-endpoints)|
25
26
 
26
27
  *\* An asterisk denotes that a property is required.*
27
28
 
@@ -200,35 +200,6 @@ The `condition` function should return a boolean that will control if the field
200
200
  }
201
201
  ```
202
202
 
203
- If you are building custom components, and you'd like for your custom components to support conditional logic as well, you can utilize Payload's `withCondition` higher-order function by importing it and using it as follows:
204
-
205
- ```js
206
- import { withCondition } from 'payload/components/forms';
207
-
208
- const CustomComponent = () => {
209
- return (
210
- <div>
211
- <p>Hello, on my own, I won't respect my field's conditional logic.<p/>
212
- <p>But, I will if I'm wrapped with the withCondition HOC as shown below!</p>
213
- </div>
214
- )
215
- }
216
-
217
- const CustomComponentWithCondition = withCondition(CustomComponent);
218
-
219
- const customFieldWithCondition = {
220
- name: 'myCustomField',
221
- type: 'text',
222
- admin: {
223
- condition: (data) => Boolean(data.enableCustomField),
224
- components: {
225
- Field: CustomComponentWithCondition,
226
- }
227
- }
228
- }
229
-
230
- ```
231
-
232
203
  ### Default values
233
204
 
234
205
  Fields can be prefilled with starting values using the `defaultValue` property. This is used in the admin UI and also on the backend as API requests will be populated with missing or undefined field values. You can assign the defaultValue directly in the field configuration or supply a function for dynamic behavior. Values assigned during a create request on the server are added before validation occurs.
@@ -243,7 +214,7 @@ Here is an example of a defaultValue function that uses both:
243
214
  ```js
244
215
  const translation: {
245
216
  en: 'Written by',
246
- es: 'escrito por',
217
+ es: 'Escrito por',
247
218
  };
248
219
 
249
220
  const field = {
@@ -43,6 +43,8 @@ The `find` endpoint supports the following additional query parameters:
43
43
 
44
44
  ## Auth Operations
45
45
 
46
+ Auth enabled collections are also given the following endpoints:
47
+
46
48
  | Method | Path | Description |
47
49
  | -------- | --------------------------- | ----------- |
48
50
  | `POST` | `/api/{collectionSlug}/verify/:token` | [Email verification](/docs/authentication/operations#verify-by-email), if enabled. |
@@ -72,3 +74,47 @@ In addition to the dynamically generated endpoints above Payload also has REST e
72
74
  | `GET` | `/api/_preferences/{key}` | Get a preference by key |
73
75
  | `POST` | `/api/_preferences/{key}` | Create or update by key |
74
76
  | `DELETE` | `/api/_preferences/{key}` | Delete a user preference by key |
77
+
78
+ ## Custom Endpoints
79
+
80
+ Additional REST API endpoints can be added to `collections` and `globals` by providing array of `endpoints` in the configuration. These can be used to write additional middleware on existing routes or build custom functionality into Payload apps and plugins.
81
+
82
+ Each endpoint object needs to have:
83
+
84
+ | Property | Description |
85
+ | ---------- | ----------------------------------------- |
86
+ | **`path`** | A string for the endpoint route after the collection or globals slug |
87
+ | **`method`** | The lowercase HTTP verb to use: 'get', 'head', 'post', 'put', 'delete', 'connect' or 'options' |
88
+ | **`handler`** | A function or array of functions to be called with **req**, **res** and **next** arguments. [Express](https://expressjs.com/en/guide/routing.html#route-handlers) |
89
+
90
+ Example:
91
+
92
+ ```js
93
+
94
+ // a collection of 'orders' with an additional route for tracking details, reachable at /api/orders/:id/tracking
95
+ const Orders = {
96
+ slug: 'orders',
97
+ fields: [ /* ... */ ],
98
+ // highlight-start
99
+ endpoints: [
100
+ {
101
+ path: '/:id/tracking',
102
+ method: 'get',
103
+ handler: async (req, res, next) => {
104
+ const tracking = await getTrackingInfo(req.params.id);
105
+ if (tracking) {
106
+ res.status('200').send({ tracking });
107
+ } else {
108
+ res.status('404').send({ error: 'not found' });
109
+ }
110
+ }
111
+ }
112
+ ],
113
+ // highlight-end
114
+ }
115
+ ```
116
+
117
+ <Banner>
118
+ <strong>Note:</strong><br/>
119
+ **req** will have the **payload** object and can be used inside your endpoint handlers for making calls like req.payload.find() that will make use of access control and hooks.
120
+ </Banner>
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "0.17.2",
3
+ "version": "0.18.1",
4
4
  "description": "Node, React and MongoDB Headless CMS and Application Framework",
5
- "license": "SEE LICENSE IN license.md",
5
+ "license": "MIT",
6
6
  "author": {
7
7
  "email": "info@payloadcms.com",
8
8
  "name": "Payload CMS",
@@ -135,7 +135,6 @@
135
135
  "mkdirp": "^1.0.4",
136
136
  "mongoose": "^6.2.0",
137
137
  "mongoose-paginate-v2": "^1.6.1",
138
- "node-sass": "^6.0.1",
139
138
  "nodemailer": "^6.4.2",
140
139
  "object-to-formdata": "^4.1.0",
141
140
  "passport": "^0.4.1",
@@ -169,8 +168,8 @@
169
168
  "react-simple-code-editor": "^0.11.0",
170
169
  "react-toastify": "^8.2.0",
171
170
  "sanitize-filename": "^1.6.3",
172
- "sass": "^1.42.0",
173
- "sass-loader": "^10.1.0",
171
+ "sass": "^1.52.1",
172
+ "sass-loader": "^12.6.0",
174
173
  "sharp": "^0.29.3",
175
174
  "slate": "^0.72.8",
176
175
  "slate-history": "^0.66.0",
@@ -222,7 +221,6 @@
222
221
  "@types/mkdirp": "^1.0.1",
223
222
  "@types/mongoose-paginate-v2": "^1.3.8",
224
223
  "@types/node-fetch": "^2.5.7",
225
- "@types/node-sass": "^4.11.1",
226
224
  "@types/nodemailer": "^6.4.0",
227
225
  "@types/nodemon": "^1.19.0",
228
226
  "@types/optimize-css-assets-webpack-plugin": "^5.0.1",
@@ -1,57 +0,0 @@
1
- import access from '../auth/graphql/resolvers/access';
2
- import forgotPassword from '../auth/graphql/resolvers/forgotPassword';
3
- import init from '../auth/graphql/resolvers/init';
4
- import login from '../auth/graphql/resolvers/login';
5
- import logout from '../auth/graphql/resolvers/logout';
6
- import me from '../auth/graphql/resolvers/me';
7
- import refresh from '../auth/graphql/resolvers/refresh';
8
- import resetPassword from '../auth/graphql/resolvers/resetPassword';
9
- import verifyEmail from '../auth/graphql/resolvers/verifyEmail';
10
- import unlock from '../auth/graphql/resolvers/unlock';
11
- import create from '../collections/graphql/resolvers/create';
12
- import find from '../collections/graphql/resolvers/find';
13
- import findByID from '../collections/graphql/resolvers/findByID';
14
- import update from '../collections/graphql/resolvers/update';
15
- import deleteResolver from '../collections/graphql/resolvers/delete';
16
- import findVersions from '../collections/graphql/resolvers/findVersions';
17
- import findVersionByID from '../collections/graphql/resolvers/findVersionByID';
18
- import restoreVersion from '../collections/graphql/resolvers/restoreVersion';
19
- import findOne from '../globals/graphql/resolvers/findOne';
20
- import globalUpdate from '../globals/graphql/resolvers/update';
21
- import globalFindVersionByID from '../globals/graphql/resolvers/findVersionByID';
22
- import globalFindVersions from '../globals/graphql/resolvers/findVersions';
23
- import globalRestoreVersion from '../globals/graphql/resolvers/restoreVersion';
24
- import { Payload } from '../index';
25
- export declare type GraphQLResolvers = {
26
- collections: {
27
- create: typeof create;
28
- find: typeof find;
29
- findVersions: typeof findVersions;
30
- findByID: typeof findByID;
31
- findVersionByID: typeof findVersionByID;
32
- restoreVersion: typeof restoreVersion;
33
- update: typeof update;
34
- deleteResolver: typeof deleteResolver;
35
- auth: {
36
- access: typeof access;
37
- forgotPassword: typeof forgotPassword;
38
- init: typeof init;
39
- login: typeof login;
40
- logout: typeof logout;
41
- me: typeof me;
42
- refresh: typeof refresh;
43
- resetPassword: typeof resetPassword;
44
- verifyEmail: typeof verifyEmail;
45
- unlock: typeof unlock;
46
- };
47
- };
48
- globals: {
49
- findOne: typeof findOne;
50
- update: typeof globalUpdate;
51
- findVersionByID: typeof globalFindVersionByID;
52
- findVersions: typeof globalFindVersions;
53
- restoreVersion: typeof globalRestoreVersion;
54
- };
55
- };
56
- declare function bindResolvers(ctx: Payload): void;
57
- export default bindResolvers;
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const access_1 = __importDefault(require("../auth/graphql/resolvers/access"));
7
- const forgotPassword_1 = __importDefault(require("../auth/graphql/resolvers/forgotPassword"));
8
- const init_1 = __importDefault(require("../auth/graphql/resolvers/init"));
9
- const login_1 = __importDefault(require("../auth/graphql/resolvers/login"));
10
- const logout_1 = __importDefault(require("../auth/graphql/resolvers/logout"));
11
- const me_1 = __importDefault(require("../auth/graphql/resolvers/me"));
12
- const refresh_1 = __importDefault(require("../auth/graphql/resolvers/refresh"));
13
- const resetPassword_1 = __importDefault(require("../auth/graphql/resolvers/resetPassword"));
14
- const verifyEmail_1 = __importDefault(require("../auth/graphql/resolvers/verifyEmail"));
15
- const unlock_1 = __importDefault(require("../auth/graphql/resolvers/unlock"));
16
- const create_1 = __importDefault(require("../collections/graphql/resolvers/create"));
17
- const find_1 = __importDefault(require("../collections/graphql/resolvers/find"));
18
- const findByID_1 = __importDefault(require("../collections/graphql/resolvers/findByID"));
19
- const update_1 = __importDefault(require("../collections/graphql/resolvers/update"));
20
- const delete_1 = __importDefault(require("../collections/graphql/resolvers/delete"));
21
- const findVersions_1 = __importDefault(require("../collections/graphql/resolvers/findVersions"));
22
- const findVersionByID_1 = __importDefault(require("../collections/graphql/resolvers/findVersionByID"));
23
- const restoreVersion_1 = __importDefault(require("../collections/graphql/resolvers/restoreVersion"));
24
- const findOne_1 = __importDefault(require("../globals/graphql/resolvers/findOne"));
25
- const update_2 = __importDefault(require("../globals/graphql/resolvers/update"));
26
- const findVersionByID_2 = __importDefault(require("../globals/graphql/resolvers/findVersionByID"));
27
- const findVersions_2 = __importDefault(require("../globals/graphql/resolvers/findVersions"));
28
- const restoreVersion_2 = __importDefault(require("../globals/graphql/resolvers/restoreVersion"));
29
- function bindResolvers(ctx) {
30
- ctx.graphQL = {
31
- resolvers: {
32
- collections: {
33
- create: create_1.default.bind(ctx),
34
- find: find_1.default.bind(ctx),
35
- findVersions: findVersions_1.default.bind(ctx),
36
- findByID: findByID_1.default.bind(ctx),
37
- findVersionByID: findVersionByID_1.default.bind(ctx),
38
- restoreVersion: restoreVersion_1.default.bind(ctx),
39
- update: update_1.default.bind(ctx),
40
- deleteResolver: delete_1.default.bind(ctx),
41
- auth: {
42
- access: access_1.default.bind(ctx),
43
- forgotPassword: forgotPassword_1.default.bind(ctx),
44
- init: init_1.default.bind(ctx),
45
- login: login_1.default.bind(ctx),
46
- logout: logout_1.default.bind(ctx),
47
- me: me_1.default.bind(ctx),
48
- refresh: refresh_1.default.bind(ctx),
49
- resetPassword: resetPassword_1.default.bind(ctx),
50
- verifyEmail: verifyEmail_1.default.bind(ctx),
51
- unlock: unlock_1.default.bind(ctx),
52
- },
53
- },
54
- globals: {
55
- findOne: findOne_1.default.bind(ctx),
56
- update: update_2.default.bind(ctx),
57
- findVersionByID: findVersionByID_2.default.bind(ctx),
58
- findVersions: findVersions_2.default.bind(ctx),
59
- restoreVersion: restoreVersion_2.default.bind(ctx),
60
- },
61
- },
62
- };
63
- }
64
- exports.default = bindResolvers;
65
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmluZFJlc29sdmVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ncmFwaHFsL2JpbmRSZXNvbHZlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSw4RUFBc0Q7QUFDdEQsOEZBQXNFO0FBQ3RFLDBFQUFrRDtBQUNsRCw0RUFBb0Q7QUFDcEQsOEVBQXNEO0FBQ3RELHNFQUE4QztBQUM5QyxnRkFBd0Q7QUFDeEQsNEZBQW9FO0FBQ3BFLHdGQUFnRTtBQUNoRSw4RUFBc0Q7QUFFdEQscUZBQTZEO0FBQzdELGlGQUF5RDtBQUN6R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UUsZUFBSyxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUM7b0JBQ3RCLE1BQU0sRUFBRSxnQkFBTSxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUM7b0JBQ3hCLEVBQUUsRUFBRSxZQUFFLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQztvQkFDaEIsT0FBTyxFQUFFLGlCQUFPLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQztvQkFDMUIsYUFBYSxFQUFFLHVCQUFhLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQztvQkFDdEMsV0FBVyxFQUFFLHFCQUFXLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQztvQkFDbEMsTUFBTSxFQUFFLGdCQUFNLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQztpQkFDekI7YUFDRjtZQUNELE9BQU8sRUFBRTtnQkFDUCxPQUFPLEVBQUUsaUJBQU8sQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDO2dCQUMxQixNQUFNLEVBQUUsZ0JBQVksQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDO2dCQUM5QixlQUFlLEVBQUUseUJBQXFCLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQztnQkFDaEQsWUFBWSxFQUFFLHNCQUFrQixDQUFDLElBQUksQ0FBQyxHQUFHLENBQUM7Z0JBQzFDLGNBQWMsRUFBRSx3QkFBb0IsQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDO2FBQy9DO1NBQ0Y7S0FDRixDQUFDO0FBQ0osQ0FBQztBQUVELGtCQUFlLGFBQWEsQ0FBQyJ9
@@ -1,67 +0,0 @@
1
- import { Payload } from '../index';
2
- import access from '../auth/operations/access';
3
- import forgotPassword from '../auth/operations/forgotPassword';
4
- import init from '../auth/operations/init';
5
- import login from '../auth/operations/login';
6
- import logout from '../auth/operations/logout';
7
- import me from '../auth/operations/me';
8
- import refresh from '../auth/operations/refresh';
9
- import registerFirstUser from '../auth/operations/registerFirstUser';
10
- import resetPassword from '../auth/operations/resetPassword';
11
- import verifyEmail from '../auth/operations/verifyEmail';
12
- import unlock from '../auth/operations/unlock';
13
- import create from '../collections/operations/create';
14
- import find from '../collections/operations/find';
15
- import findByID from '../collections/operations/findByID';
16
- import findVersions from '../collections/operations/findVersions';
17
- import findVersionByID from '../collections/operations/findVersionByID';
18
- import restoreVersion from '../collections/operations/restoreVersion';
19
- import update from '../collections/operations/update';
20
- import deleteHandler from '../collections/operations/delete';
21
- import findOne from '../globals/operations/findOne';
22
- import findGlobalVersions from '../globals/operations/findVersions';
23
- import findGlobalVersionByID from '../globals/operations/findVersionByID';
24
- import restoreGlobalVersion from '../globals/operations/restoreVersion';
25
- import globalUpdate from '../globals/operations/update';
26
- import preferenceUpdate from '../preferences/operations/update';
27
- import preferenceFindOne from '../preferences/operations/findOne';
28
- import preferenceDelete from '../preferences/operations/delete';
29
- export declare type Operations = {
30
- collections: {
31
- create: typeof create;
32
- find: typeof find;
33
- findByID: typeof findByID;
34
- findVersions: typeof findVersions;
35
- findVersionByID: typeof findVersionByID;
36
- restoreVersion: typeof restoreVersion;
37
- update: typeof update;
38
- delete: typeof deleteHandler;
39
- auth: {
40
- access: typeof access;
41
- forgotPassword: typeof forgotPassword;
42
- init: typeof init;
43
- login: typeof login;
44
- logout: typeof logout;
45
- me: typeof me;
46
- refresh: typeof refresh;
47
- registerFirstUser: typeof registerFirstUser;
48
- resetPassword: typeof resetPassword;
49
- verifyEmail: typeof verifyEmail;
50
- unlock: typeof unlock;
51
- };
52
- };
53
- globals: {
54
- findOne: typeof findOne;
55
- findVersions: typeof findGlobalVersions;
56
- findVersionByID: typeof findGlobalVersionByID;
57
- restoreVersion: typeof restoreGlobalVersion;
58
- update: typeof globalUpdate;
59
- };
60
- preferences: {
61
- update: typeof preferenceUpdate;
62
- findOne: typeof preferenceFindOne;
63
- delete: typeof preferenceDelete;
64
- };
65
- };
66
- declare function bindOperations(ctx: Payload): void;
67
- export default bindOperations;