@seshuk/payload-plugin-openapi 0.2.3 → 1.0.0-beta.2

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 (407) hide show
  1. package/README.md +72 -26
  2. package/dist/_tooling/telemetry.js +168 -0
  3. package/dist/_tooling/telemetry.js.map +1 -0
  4. package/dist/cli/generateSpec.d.ts +2 -0
  5. package/dist/cli/generateSpec.js +40 -0
  6. package/dist/cli/generateSpec.js.map +1 -0
  7. package/dist/index.d.ts +8 -9
  8. package/dist/index.js +76 -65
  9. package/dist/index.js.map +1 -0
  10. package/dist/{endpoints → server/endpoints}/interactiveAuth.d.ts +2 -2
  11. package/dist/server/endpoints/interactiveAuth.js +25 -0
  12. package/dist/server/endpoints/interactiveAuth.js.map +1 -0
  13. package/dist/server/endpoints/spec.d.ts +5 -0
  14. package/dist/server/endpoints/spec.js +39 -0
  15. package/dist/server/endpoints/spec.js.map +1 -0
  16. package/dist/server/options/resolveOptions.d.ts +4 -0
  17. package/dist/server/options/resolveOptions.js +65 -0
  18. package/dist/server/options/resolveOptions.js.map +1 -0
  19. package/dist/server/spec/build.d.ts +14 -0
  20. package/dist/server/spec/build.js +40 -0
  21. package/dist/server/spec/build.js.map +1 -0
  22. package/dist/server/spec/buildDocument.d.ts +16 -0
  23. package/dist/server/spec/buildDocument.js +340 -0
  24. package/dist/server/spec/buildDocument.js.map +1 -0
  25. package/dist/server/spec/components.d.ts +61 -0
  26. package/dist/server/spec/components.js +265 -0
  27. package/dist/server/spec/components.js.map +1 -0
  28. package/dist/{spec → server/spec}/downconvert.d.ts +2 -1
  29. package/dist/server/spec/downconvert.js +69 -0
  30. package/dist/server/spec/downconvert.js.map +1 -0
  31. package/dist/server/spec/entitySchemas.d.ts +15 -0
  32. package/dist/server/spec/entitySchemas.js +207 -0
  33. package/dist/server/spec/entitySchemas.js.map +1 -0
  34. package/dist/{spec → server/spec}/fields.d.ts +2 -1
  35. package/dist/server/spec/fields.js +47 -0
  36. package/dist/server/spec/fields.js.map +1 -0
  37. package/dist/server/spec/filters.d.ts +16 -0
  38. package/dist/server/spec/filters.js +102 -0
  39. package/dist/server/spec/filters.js.map +1 -0
  40. package/dist/server/spec/hierarchy.d.ts +11 -0
  41. package/dist/server/spec/hierarchy.js +43 -0
  42. package/dist/server/spec/hierarchy.js.map +1 -0
  43. package/dist/{spec → server/spec}/names.d.ts +2 -2
  44. package/dist/server/spec/names.js +43 -0
  45. package/dist/server/spec/names.js.map +1 -0
  46. package/dist/server/spec/params.d.ts +57 -0
  47. package/dist/server/spec/params.js +394 -0
  48. package/dist/server/spec/params.js.map +1 -0
  49. package/dist/server/spec/paths/auth.d.ts +10 -0
  50. package/dist/server/spec/paths/auth.js +190 -0
  51. package/dist/server/spec/paths/auth.js.map +1 -0
  52. package/dist/server/spec/paths/collections.d.ts +11 -0
  53. package/dist/server/spec/paths/collections.js +418 -0
  54. package/dist/server/spec/paths/collections.js.map +1 -0
  55. package/dist/server/spec/paths/custom.d.ts +12 -0
  56. package/dist/server/spec/paths/custom.js +42 -0
  57. package/dist/server/spec/paths/custom.js.map +1 -0
  58. package/dist/server/spec/paths/globals.d.ts +11 -0
  59. package/dist/server/spec/paths/globals.js +87 -0
  60. package/dist/server/spec/paths/globals.js.map +1 -0
  61. package/dist/server/spec/paths/jobs.d.ts +9 -0
  62. package/dist/server/spec/paths/jobs.js +98 -0
  63. package/dist/server/spec/paths/jobs.js.map +1 -0
  64. package/dist/server/spec/paths/system.d.ts +9 -0
  65. package/dist/server/spec/paths/system.js +203 -0
  66. package/dist/server/spec/paths/system.js.map +1 -0
  67. package/dist/server/spec/paths/versions.d.ts +22 -0
  68. package/dist/server/spec/paths/versions.js +185 -0
  69. package/dist/server/spec/paths/versions.js.map +1 -0
  70. package/dist/server/spec/plugins/ecommerce.d.ts +3 -0
  71. package/dist/server/spec/plugins/ecommerce.js +270 -0
  72. package/dist/server/spec/plugins/ecommerce.js.map +1 -0
  73. package/dist/server/spec/plugins/importExport.d.ts +3 -0
  74. package/dist/server/spec/plugins/importExport.js +202 -0
  75. package/dist/server/spec/plugins/importExport.js.map +1 -0
  76. package/dist/server/spec/plugins/index.d.ts +3 -0
  77. package/dist/server/spec/plugins/index.js +21 -0
  78. package/dist/server/spec/plugins/index.js.map +1 -0
  79. package/dist/server/spec/plugins/mcp.d.ts +3 -0
  80. package/dist/server/spec/plugins/mcp.js +118 -0
  81. package/dist/server/spec/plugins/mcp.js.map +1 -0
  82. package/dist/server/spec/plugins/multiTenant.d.ts +3 -0
  83. package/dist/server/spec/plugins/multiTenant.js +39 -0
  84. package/dist/server/spec/plugins/multiTenant.js.map +1 -0
  85. package/dist/server/spec/plugins/search.d.ts +3 -0
  86. package/dist/server/spec/plugins/search.js +43 -0
  87. package/dist/server/spec/plugins/search.js.map +1 -0
  88. package/dist/server/spec/plugins/seo.d.ts +3 -0
  89. package/dist/server/spec/plugins/seo.js +83 -0
  90. package/dist/server/spec/plugins/seo.js.map +1 -0
  91. package/dist/server/spec/plugins/shared.d.ts +35 -0
  92. package/dist/server/spec/plugins/shared.js +37 -0
  93. package/dist/server/spec/plugins/shared.js.map +1 -0
  94. package/dist/server/spec/plugins/storageR2.d.ts +3 -0
  95. package/dist/server/spec/plugins/storageR2.js +91 -0
  96. package/dist/server/spec/plugins/storageR2.js.map +1 -0
  97. package/dist/server/spec/plugins/stripe.d.ts +10 -0
  98. package/dist/server/spec/plugins/stripe.js +102 -0
  99. package/dist/server/spec/plugins/stripe.js.map +1 -0
  100. package/dist/server/spec/security.d.ts +34 -0
  101. package/dist/server/spec/security.js +100 -0
  102. package/dist/server/spec/security.js.map +1 -0
  103. package/dist/server/spec/tags.d.ts +37 -0
  104. package/dist/server/spec/tags.js +99 -0
  105. package/dist/server/spec/tags.js.map +1 -0
  106. package/dist/server/telemetry.d.ts +31 -0
  107. package/dist/server/telemetry.js +33 -0
  108. package/dist/server/telemetry.js.map +1 -0
  109. package/dist/server/ui/createUiPlugin.d.ts +16 -0
  110. package/dist/server/ui/createUiPlugin.js +33 -0
  111. package/dist/server/ui/createUiPlugin.js.map +1 -0
  112. package/dist/{ui → server/ui}/html.d.ts +5 -3
  113. package/dist/server/ui/html.js +11 -0
  114. package/dist/server/ui/html.js.map +1 -0
  115. package/dist/server/ui/scalar.d.ts +4 -0
  116. package/dist/server/ui/scalar.js +17 -0
  117. package/dist/server/ui/scalar.js.map +1 -0
  118. package/dist/server/ui/swagger.d.ts +4 -0
  119. package/dist/server/ui/swagger.js +18 -0
  120. package/dist/server/ui/swagger.js.map +1 -0
  121. package/dist/shared/constants.d.ts +4 -0
  122. package/dist/shared/constants.js +6 -0
  123. package/dist/shared/constants.js.map +1 -0
  124. package/dist/shared/translations/index.d.ts +5 -0
  125. package/dist/{translations → shared/translations}/index.js +49 -47
  126. package/dist/shared/translations/index.js.map +1 -0
  127. package/dist/shared/translations/locales/ar.d.ts +3 -0
  128. package/dist/shared/translations/locales/ar.js +173 -0
  129. package/dist/shared/translations/locales/ar.js.map +1 -0
  130. package/dist/shared/translations/locales/az.d.ts +3 -0
  131. package/dist/shared/translations/locales/az.js +173 -0
  132. package/dist/shared/translations/locales/az.js.map +1 -0
  133. package/dist/shared/translations/locales/bg.d.ts +3 -0
  134. package/dist/shared/translations/locales/bg.js +173 -0
  135. package/dist/shared/translations/locales/bg.js.map +1 -0
  136. package/dist/shared/translations/locales/bnBd.d.ts +3 -0
  137. package/dist/shared/translations/locales/bnBd.js +173 -0
  138. package/dist/shared/translations/locales/bnBd.js.map +1 -0
  139. package/dist/shared/translations/locales/bnIn.d.ts +3 -0
  140. package/dist/shared/translations/locales/bnIn.js +173 -0
  141. package/dist/shared/translations/locales/bnIn.js.map +1 -0
  142. package/dist/shared/translations/locales/ca.d.ts +3 -0
  143. package/dist/shared/translations/locales/ca.js +173 -0
  144. package/dist/shared/translations/locales/ca.js.map +1 -0
  145. package/dist/shared/translations/locales/cs.d.ts +3 -0
  146. package/dist/shared/translations/locales/cs.js +173 -0
  147. package/dist/shared/translations/locales/cs.js.map +1 -0
  148. package/dist/shared/translations/locales/da.d.ts +3 -0
  149. package/dist/shared/translations/locales/da.js +173 -0
  150. package/dist/shared/translations/locales/da.js.map +1 -0
  151. package/dist/shared/translations/locales/de.d.ts +3 -0
  152. package/dist/shared/translations/locales/de.js +173 -0
  153. package/dist/shared/translations/locales/de.js.map +1 -0
  154. package/dist/shared/translations/locales/en.d.ts +3 -0
  155. package/dist/shared/translations/locales/en.js +173 -0
  156. package/dist/shared/translations/locales/en.js.map +1 -0
  157. package/dist/shared/translations/locales/es.d.ts +3 -0
  158. package/dist/shared/translations/locales/es.js +173 -0
  159. package/dist/shared/translations/locales/es.js.map +1 -0
  160. package/dist/shared/translations/locales/et.d.ts +3 -0
  161. package/dist/shared/translations/locales/et.js +173 -0
  162. package/dist/shared/translations/locales/et.js.map +1 -0
  163. package/dist/shared/translations/locales/fa.d.ts +3 -0
  164. package/dist/shared/translations/locales/fa.js +173 -0
  165. package/dist/shared/translations/locales/fa.js.map +1 -0
  166. package/dist/shared/translations/locales/fr.d.ts +3 -0
  167. package/dist/shared/translations/locales/fr.js +173 -0
  168. package/dist/shared/translations/locales/fr.js.map +1 -0
  169. package/dist/shared/translations/locales/he.d.ts +3 -0
  170. package/dist/shared/translations/locales/he.js +173 -0
  171. package/dist/shared/translations/locales/he.js.map +1 -0
  172. package/dist/shared/translations/locales/hr.d.ts +3 -0
  173. package/dist/shared/translations/locales/hr.js +173 -0
  174. package/dist/shared/translations/locales/hr.js.map +1 -0
  175. package/dist/shared/translations/locales/hu.d.ts +3 -0
  176. package/dist/shared/translations/locales/hu.js +173 -0
  177. package/dist/shared/translations/locales/hu.js.map +1 -0
  178. package/dist/shared/translations/locales/hy.d.ts +3 -0
  179. package/dist/shared/translations/locales/hy.js +173 -0
  180. package/dist/shared/translations/locales/hy.js.map +1 -0
  181. package/dist/shared/translations/locales/id.d.ts +3 -0
  182. package/dist/shared/translations/locales/id.js +173 -0
  183. package/dist/shared/translations/locales/id.js.map +1 -0
  184. package/dist/shared/translations/locales/is.d.ts +3 -0
  185. package/dist/shared/translations/locales/is.js +173 -0
  186. package/dist/shared/translations/locales/is.js.map +1 -0
  187. package/dist/shared/translations/locales/it.d.ts +3 -0
  188. package/dist/shared/translations/locales/it.js +173 -0
  189. package/dist/shared/translations/locales/it.js.map +1 -0
  190. package/dist/shared/translations/locales/ja.d.ts +3 -0
  191. package/dist/shared/translations/locales/ja.js +173 -0
  192. package/dist/shared/translations/locales/ja.js.map +1 -0
  193. package/dist/shared/translations/locales/ko.d.ts +3 -0
  194. package/dist/shared/translations/locales/ko.js +173 -0
  195. package/dist/shared/translations/locales/ko.js.map +1 -0
  196. package/dist/shared/translations/locales/lt.d.ts +3 -0
  197. package/dist/shared/translations/locales/lt.js +173 -0
  198. package/dist/shared/translations/locales/lt.js.map +1 -0
  199. package/dist/shared/translations/locales/lv.d.ts +3 -0
  200. package/dist/shared/translations/locales/lv.js +173 -0
  201. package/dist/shared/translations/locales/lv.js.map +1 -0
  202. package/dist/shared/translations/locales/my.d.ts +3 -0
  203. package/dist/shared/translations/locales/my.js +173 -0
  204. package/dist/shared/translations/locales/my.js.map +1 -0
  205. package/dist/shared/translations/locales/nb.d.ts +3 -0
  206. package/dist/shared/translations/locales/nb.js +173 -0
  207. package/dist/shared/translations/locales/nb.js.map +1 -0
  208. package/dist/shared/translations/locales/nl.d.ts +3 -0
  209. package/dist/shared/translations/locales/nl.js +173 -0
  210. package/dist/shared/translations/locales/nl.js.map +1 -0
  211. package/dist/shared/translations/locales/pl.d.ts +3 -0
  212. package/dist/shared/translations/locales/pl.js +173 -0
  213. package/dist/shared/translations/locales/pl.js.map +1 -0
  214. package/dist/shared/translations/locales/pt.d.ts +3 -0
  215. package/dist/shared/translations/locales/pt.js +173 -0
  216. package/dist/shared/translations/locales/pt.js.map +1 -0
  217. package/dist/shared/translations/locales/ro.d.ts +3 -0
  218. package/dist/shared/translations/locales/ro.js +173 -0
  219. package/dist/shared/translations/locales/ro.js.map +1 -0
  220. package/dist/shared/translations/locales/rs.d.ts +3 -0
  221. package/dist/shared/translations/locales/rs.js +173 -0
  222. package/dist/shared/translations/locales/rs.js.map +1 -0
  223. package/dist/shared/translations/locales/rsLatin.d.ts +3 -0
  224. package/dist/shared/translations/locales/rsLatin.js +173 -0
  225. package/dist/shared/translations/locales/rsLatin.js.map +1 -0
  226. package/dist/shared/translations/locales/ru.d.ts +3 -0
  227. package/dist/shared/translations/locales/ru.js +173 -0
  228. package/dist/shared/translations/locales/ru.js.map +1 -0
  229. package/dist/shared/translations/locales/sk.d.ts +3 -0
  230. package/dist/shared/translations/locales/sk.js +173 -0
  231. package/dist/shared/translations/locales/sk.js.map +1 -0
  232. package/dist/shared/translations/locales/sl.d.ts +3 -0
  233. package/dist/shared/translations/locales/sl.js +173 -0
  234. package/dist/shared/translations/locales/sl.js.map +1 -0
  235. package/dist/shared/translations/locales/sv.d.ts +3 -0
  236. package/dist/shared/translations/locales/sv.js +173 -0
  237. package/dist/shared/translations/locales/sv.js.map +1 -0
  238. package/dist/shared/translations/locales/ta.d.ts +3 -0
  239. package/dist/shared/translations/locales/ta.js +173 -0
  240. package/dist/shared/translations/locales/ta.js.map +1 -0
  241. package/dist/shared/translations/locales/th.d.ts +3 -0
  242. package/dist/shared/translations/locales/th.js +173 -0
  243. package/dist/shared/translations/locales/th.js.map +1 -0
  244. package/dist/shared/translations/locales/tr.d.ts +3 -0
  245. package/dist/shared/translations/locales/tr.js +173 -0
  246. package/dist/shared/translations/locales/tr.js.map +1 -0
  247. package/dist/shared/translations/locales/uk.d.ts +3 -0
  248. package/dist/shared/translations/locales/uk.js +173 -0
  249. package/dist/shared/translations/locales/uk.js.map +1 -0
  250. package/dist/shared/translations/locales/vi.d.ts +3 -0
  251. package/dist/shared/translations/locales/vi.js +173 -0
  252. package/dist/shared/translations/locales/vi.js.map +1 -0
  253. package/dist/shared/translations/locales/zh.d.ts +3 -0
  254. package/dist/shared/translations/locales/zh.js +173 -0
  255. package/dist/shared/translations/locales/zh.js.map +1 -0
  256. package/dist/shared/translations/locales/zhTw.d.ts +3 -0
  257. package/dist/shared/translations/locales/zhTw.js +173 -0
  258. package/dist/shared/translations/locales/zhTw.js.map +1 -0
  259. package/dist/shared/translations/types.d.ts +180 -0
  260. package/dist/shared/translations/types.js +1 -0
  261. package/dist/shared/types/index.d.ts +412 -0
  262. package/dist/shared/types/index.js +1 -0
  263. package/dist/{utils.d.ts → shared/utils.d.ts} +1 -0
  264. package/dist/shared/utils.js +13 -0
  265. package/dist/shared/utils.js.map +1 -0
  266. package/package.json +70 -39
  267. package/dist/bin/generateSpec.d.ts +0 -25
  268. package/dist/bin/generateSpec.js +0 -61
  269. package/dist/constants.d.ts +0 -1
  270. package/dist/constants.js +0 -2
  271. package/dist/endpoints/interactiveAuth.js +0 -27
  272. package/dist/endpoints/spec.d.ts +0 -5
  273. package/dist/endpoints/spec.js +0 -39
  274. package/dist/options.d.ts +0 -2
  275. package/dist/options.js +0 -45
  276. package/dist/spec/build.d.ts +0 -14
  277. package/dist/spec/build.js +0 -36
  278. package/dist/spec/buildDocument.d.ts +0 -15
  279. package/dist/spec/buildDocument.js +0 -268
  280. package/dist/spec/components.d.ts +0 -44
  281. package/dist/spec/components.js +0 -265
  282. package/dist/spec/downconvert.js +0 -74
  283. package/dist/spec/entitySchemas.d.ts +0 -15
  284. package/dist/spec/entitySchemas.js +0 -250
  285. package/dist/spec/fields.js +0 -44
  286. package/dist/spec/filters.d.ts +0 -11
  287. package/dist/spec/filters.js +0 -83
  288. package/dist/spec/names.js +0 -37
  289. package/dist/spec/params.d.ts +0 -55
  290. package/dist/spec/params.js +0 -436
  291. package/dist/spec/paths/auth.d.ts +0 -9
  292. package/dist/spec/paths/auth.js +0 -274
  293. package/dist/spec/paths/collections.d.ts +0 -9
  294. package/dist/spec/paths/collections.js +0 -278
  295. package/dist/spec/paths/custom.d.ts +0 -9
  296. package/dist/spec/paths/custom.js +0 -41
  297. package/dist/spec/paths/globals.d.ts +0 -9
  298. package/dist/spec/paths/globals.js +0 -78
  299. package/dist/spec/paths/jobs.d.ts +0 -7
  300. package/dist/spec/paths/jobs.js +0 -130
  301. package/dist/spec/paths/versions.d.ts +0 -19
  302. package/dist/spec/paths/versions.js +0 -252
  303. package/dist/spec/security.d.ts +0 -19
  304. package/dist/spec/security.js +0 -96
  305. package/dist/spec/tags.d.ts +0 -27
  306. package/dist/spec/tags.js +0 -79
  307. package/dist/translations/index.d.ts +0 -6
  308. package/dist/translations/locales/ar.d.ts +0 -2
  309. package/dist/translations/locales/ar.js +0 -81
  310. package/dist/translations/locales/az.d.ts +0 -2
  311. package/dist/translations/locales/az.js +0 -81
  312. package/dist/translations/locales/bg.d.ts +0 -2
  313. package/dist/translations/locales/bg.js +0 -81
  314. package/dist/translations/locales/bnBd.d.ts +0 -2
  315. package/dist/translations/locales/bnBd.js +0 -81
  316. package/dist/translations/locales/bnIn.d.ts +0 -2
  317. package/dist/translations/locales/bnIn.js +0 -81
  318. package/dist/translations/locales/ca.d.ts +0 -2
  319. package/dist/translations/locales/ca.js +0 -81
  320. package/dist/translations/locales/cs.d.ts +0 -2
  321. package/dist/translations/locales/cs.js +0 -81
  322. package/dist/translations/locales/da.d.ts +0 -2
  323. package/dist/translations/locales/da.js +0 -81
  324. package/dist/translations/locales/de.d.ts +0 -2
  325. package/dist/translations/locales/de.js +0 -81
  326. package/dist/translations/locales/en.d.ts +0 -2
  327. package/dist/translations/locales/en.js +0 -81
  328. package/dist/translations/locales/es.d.ts +0 -2
  329. package/dist/translations/locales/es.js +0 -81
  330. package/dist/translations/locales/et.d.ts +0 -2
  331. package/dist/translations/locales/et.js +0 -81
  332. package/dist/translations/locales/fa.d.ts +0 -2
  333. package/dist/translations/locales/fa.js +0 -81
  334. package/dist/translations/locales/fr.d.ts +0 -2
  335. package/dist/translations/locales/fr.js +0 -81
  336. package/dist/translations/locales/he.d.ts +0 -2
  337. package/dist/translations/locales/he.js +0 -81
  338. package/dist/translations/locales/hr.d.ts +0 -2
  339. package/dist/translations/locales/hr.js +0 -81
  340. package/dist/translations/locales/hu.d.ts +0 -2
  341. package/dist/translations/locales/hu.js +0 -81
  342. package/dist/translations/locales/hy.d.ts +0 -2
  343. package/dist/translations/locales/hy.js +0 -81
  344. package/dist/translations/locales/id.d.ts +0 -2
  345. package/dist/translations/locales/id.js +0 -81
  346. package/dist/translations/locales/is.d.ts +0 -2
  347. package/dist/translations/locales/is.js +0 -81
  348. package/dist/translations/locales/it.d.ts +0 -2
  349. package/dist/translations/locales/it.js +0 -81
  350. package/dist/translations/locales/ja.d.ts +0 -2
  351. package/dist/translations/locales/ja.js +0 -81
  352. package/dist/translations/locales/ko.d.ts +0 -2
  353. package/dist/translations/locales/ko.js +0 -81
  354. package/dist/translations/locales/lt.d.ts +0 -2
  355. package/dist/translations/locales/lt.js +0 -81
  356. package/dist/translations/locales/lv.d.ts +0 -2
  357. package/dist/translations/locales/lv.js +0 -81
  358. package/dist/translations/locales/my.d.ts +0 -2
  359. package/dist/translations/locales/my.js +0 -81
  360. package/dist/translations/locales/nb.d.ts +0 -2
  361. package/dist/translations/locales/nb.js +0 -81
  362. package/dist/translations/locales/nl.d.ts +0 -2
  363. package/dist/translations/locales/nl.js +0 -81
  364. package/dist/translations/locales/pl.d.ts +0 -2
  365. package/dist/translations/locales/pl.js +0 -81
  366. package/dist/translations/locales/pt.d.ts +0 -2
  367. package/dist/translations/locales/pt.js +0 -81
  368. package/dist/translations/locales/ro.d.ts +0 -2
  369. package/dist/translations/locales/ro.js +0 -81
  370. package/dist/translations/locales/rs.d.ts +0 -2
  371. package/dist/translations/locales/rs.js +0 -81
  372. package/dist/translations/locales/rsLatin.d.ts +0 -2
  373. package/dist/translations/locales/rsLatin.js +0 -81
  374. package/dist/translations/locales/ru.d.ts +0 -2
  375. package/dist/translations/locales/ru.js +0 -81
  376. package/dist/translations/locales/sk.d.ts +0 -2
  377. package/dist/translations/locales/sk.js +0 -81
  378. package/dist/translations/locales/sl.d.ts +0 -2
  379. package/dist/translations/locales/sl.js +0 -81
  380. package/dist/translations/locales/sv.d.ts +0 -2
  381. package/dist/translations/locales/sv.js +0 -81
  382. package/dist/translations/locales/ta.d.ts +0 -2
  383. package/dist/translations/locales/ta.js +0 -81
  384. package/dist/translations/locales/th.d.ts +0 -2
  385. package/dist/translations/locales/th.js +0 -81
  386. package/dist/translations/locales/tr.d.ts +0 -2
  387. package/dist/translations/locales/tr.js +0 -81
  388. package/dist/translations/locales/uk.d.ts +0 -2
  389. package/dist/translations/locales/uk.js +0 -81
  390. package/dist/translations/locales/vi.d.ts +0 -2
  391. package/dist/translations/locales/vi.js +0 -81
  392. package/dist/translations/locales/zh.d.ts +0 -2
  393. package/dist/translations/locales/zh.js +0 -81
  394. package/dist/translations/locales/zhTw.d.ts +0 -2
  395. package/dist/translations/locales/zhTw.js +0 -81
  396. package/dist/translations/types.d.ts +0 -87
  397. package/dist/translations/types.js +0 -1
  398. package/dist/types.d.ts +0 -192
  399. package/dist/types.js +0 -1
  400. package/dist/ui/createUiPlugin.d.ts +0 -14
  401. package/dist/ui/createUiPlugin.js +0 -28
  402. package/dist/ui/html.js +0 -8
  403. package/dist/ui/scalar.d.ts +0 -1
  404. package/dist/ui/scalar.js +0 -12
  405. package/dist/ui/swagger.d.ts +0 -1
  406. package/dist/ui/swagger.js +0 -12
  407. package/dist/utils.js +0 -13
@@ -0,0 +1,418 @@
1
+ import { createSchemaName, listSchemaName, refTo, schemaName, updateSchemaName } from "../names.js";
2
+ import { ERRORS, docAccessOperation, errorResponses, jsonBody, jsonOk, jsonResponse, uploadRequestBody, validateOperation } from "../components.js";
3
+ import { makeT } from "../../../shared/translations/index.js";
4
+ import { buildListParams, buildParamSchemas, commonReadParams, validateParams, writeParams } from "../params.js";
5
+ import { securedRequirement } from "../security.js";
6
+ const buildCollectionPaths = ({ collection, ctx, security = {}, access = false }) => {
7
+ const t = makeT(ctx.i18n);
8
+ const name = schemaName(collection.slug);
9
+ const base = `${ctx.apiRoute}/${collection.slug}`;
10
+ const docRef = { $ref: refTo(name) };
11
+ const listRef = { $ref: refTo(listSchemaName(name)) };
12
+ const createRef = { $ref: refTo(createSchemaName(name)) };
13
+ const updateRef = { $ref: refTo(updateSchemaName(name)) };
14
+ const idType = ctx.defaultIDType === "number" ? "integer" : "string";
15
+ const { read: secRead, create: secCreate, update: secUpdate, delete: secDelete, validate: secValidate } = security;
16
+ const allowBulk = collection.disableBulkEdit !== true;
17
+ const allowDuplicate = collection.disableDuplicate !== true;
18
+ const paramSchemas = buildParamSchemas({
19
+ fields: collection.fields,
20
+ ctx
21
+ });
22
+ const refs = {
23
+ select: true,
24
+ populate: Boolean(paramSchemas.populate),
25
+ joins: Boolean(paramSchemas.joins)
26
+ };
27
+ const isUpload = Boolean(collection.upload);
28
+ const fileRequiredOnCreate = typeof collection.upload === "object" ? collection.upload.filesRequiredOnCreate !== false : true;
29
+ const requestBody = (ref, fileRequired) => isUpload ? uploadRequestBody({
30
+ bodyRef: ref,
31
+ fileRequired,
32
+ t
33
+ }) : { content: { "application/json": { schema: ref } } };
34
+ const mutationSchema = {
35
+ type: "object",
36
+ properties: {
37
+ message: { type: "string" },
38
+ doc: docRef
39
+ }
40
+ };
41
+ const listResponse = {
42
+ ...jsonOk(t("collectionList"), listRef),
43
+ ...errorResponses(ERRORS.list, t)
44
+ };
45
+ const findByIdResponse = {
46
+ ...jsonOk(t("collectionDoc"), docRef),
47
+ ...errorResponses(ERRORS.read, t)
48
+ };
49
+ const createResponse = {
50
+ "201": jsonResponse(t("collectionCreated"), mutationSchema),
51
+ ...errorResponses(ERRORS.create, t)
52
+ };
53
+ const updateResponse = {
54
+ ...jsonOk(t("collectionUpdated"), mutationSchema),
55
+ ...errorResponses(ERRORS.update, t)
56
+ };
57
+ const deleteResponse = {
58
+ ...jsonOk(t("collectionDeleted"), mutationSchema),
59
+ ...errorResponses(ERRORS.delete, t)
60
+ };
61
+ const bulkSchema = {
62
+ type: "object",
63
+ properties: {
64
+ message: { type: "string" },
65
+ docs: {
66
+ type: "array",
67
+ items: docRef
68
+ },
69
+ errors: {
70
+ type: "array",
71
+ items: {
72
+ type: "object",
73
+ properties: {
74
+ message: { type: "string" },
75
+ id: { type: idType }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ };
81
+ const bulkUpdateResponse = {
82
+ ...jsonOk(t("collectionBulkUpdate"), bulkSchema),
83
+ ...errorResponses(ERRORS.update, t)
84
+ };
85
+ const bulkDeleteResponse = {
86
+ ...jsonOk(t("collectionBulkDelete"), bulkSchema),
87
+ ...errorResponses(ERRORS.delete, t)
88
+ };
89
+ const countResponse = {
90
+ ...jsonOk(t("collectionCount"), {
91
+ type: "object",
92
+ properties: { totalDocs: { type: "integer" } }
93
+ }),
94
+ ...errorResponses(ERRORS.list, t)
95
+ };
96
+ const listParams = buildListParams({
97
+ base: name,
98
+ fields: collection.fields,
99
+ ctx,
100
+ refs
101
+ });
102
+ const bulkParams = listParams.filter((p) => p.name === "where");
103
+ const bulkUpdateParams = listParams.filter((p) => [
104
+ "limit",
105
+ "sort",
106
+ "where"
107
+ ].includes(p.name));
108
+ const write = (operation) => writeParams({
109
+ base: name,
110
+ entity: collection,
111
+ ctx,
112
+ refs,
113
+ operation
114
+ });
115
+ const deleteParams = write("delete");
116
+ const bulkOps = allowBulk ? {
117
+ patch: {
118
+ tags: [name],
119
+ operationId: `update${name}`,
120
+ parameters: [...bulkUpdateParams, ...write("update")],
121
+ requestBody: requestBody(updateRef, false),
122
+ responses: bulkUpdateResponse,
123
+ security: secUpdate
124
+ },
125
+ delete: {
126
+ tags: [name],
127
+ operationId: `delete${name}`,
128
+ parameters: [...bulkParams, ...deleteParams],
129
+ responses: bulkDeleteResponse,
130
+ security: secDelete
131
+ }
132
+ } : {};
133
+ const paths = {
134
+ [base]: {
135
+ get: {
136
+ tags: [name],
137
+ operationId: `find${name}`,
138
+ parameters: buildListParams({
139
+ base: name,
140
+ fields: collection.fields,
141
+ ctx,
142
+ refs
143
+ }),
144
+ responses: listResponse,
145
+ security: secRead
146
+ },
147
+ post: {
148
+ tags: [name],
149
+ operationId: `create${name}`,
150
+ parameters: write("create"),
151
+ requestBody: requestBody(createRef, fileRequiredOnCreate),
152
+ responses: createResponse,
153
+ security: secCreate
154
+ },
155
+ ...bulkOps
156
+ },
157
+ [`${base}/count`]: { get: {
158
+ tags: [name],
159
+ operationId: `count${name}`,
160
+ parameters: bulkParams,
161
+ responses: countResponse,
162
+ security: secRead
163
+ } },
164
+ [`${base}/validate`]: { post: validateOperation({
165
+ tag: name,
166
+ operationId: `validate${name}`,
167
+ parameters: validateParams(ctx),
168
+ requestBody: {
169
+ ...requestBody(createRef, false),
170
+ required: true
171
+ },
172
+ errors: ERRORS.create,
173
+ security: secValidate,
174
+ t
175
+ }) },
176
+ [`${base}/{id}`]: {
177
+ parameters: [{
178
+ name: "id",
179
+ in: "path",
180
+ required: true,
181
+ schema: { type: idType }
182
+ }],
183
+ get: {
184
+ tags: [name],
185
+ operationId: `find${name}ById`,
186
+ parameters: commonReadParams({
187
+ base: name,
188
+ ctx,
189
+ refs
190
+ }),
191
+ responses: findByIdResponse,
192
+ security: secRead
193
+ },
194
+ patch: {
195
+ tags: [name],
196
+ operationId: `update${name}ById`,
197
+ parameters: write("updateByID"),
198
+ requestBody: requestBody(updateRef, false),
199
+ responses: updateResponse,
200
+ security: secUpdate
201
+ },
202
+ delete: {
203
+ tags: [name],
204
+ operationId: `delete${name}ById`,
205
+ parameters: deleteParams,
206
+ responses: deleteResponse,
207
+ security: secDelete
208
+ }
209
+ }
210
+ };
211
+ paths[`${base}/{id}/validate`] = {
212
+ parameters: [{
213
+ name: "id",
214
+ in: "path",
215
+ required: true,
216
+ schema: { type: idType }
217
+ }],
218
+ post: validateOperation({
219
+ tag: name,
220
+ operationId: `validate${name}ById`,
221
+ parameters: validateParams(ctx),
222
+ requestBody: requestBody(updateRef, false),
223
+ errors: ERRORS.update,
224
+ security: secValidate,
225
+ t
226
+ })
227
+ };
228
+ if (allowDuplicate) paths[`${base}/{id}/duplicate`] = {
229
+ parameters: [{
230
+ name: "id",
231
+ in: "path",
232
+ required: true,
233
+ schema: { type: idType }
234
+ }],
235
+ post: {
236
+ tags: [name],
237
+ operationId: `duplicate${name}`,
238
+ parameters: write("duplicate"),
239
+ responses: {
240
+ ...jsonOk(t("collectionDuplicated"), mutationSchema),
241
+ ...errorResponses(ERRORS.create, t)
242
+ },
243
+ security: secCreate
244
+ }
245
+ };
246
+ if (access) {
247
+ const auth = collection.auth;
248
+ const operations = [
249
+ "create",
250
+ "read",
251
+ "update",
252
+ "delete",
253
+ "validate",
254
+ ...auth && auth.maxLoginAttempts ? ["unlock"] : [],
255
+ ...collection.versions ? ["readVersions"] : []
256
+ ];
257
+ const accessOp = (operationId, errors) => docAccessOperation({
258
+ tag: name,
259
+ operationId,
260
+ operations,
261
+ bodyRef: updateRef,
262
+ errors,
263
+ t
264
+ });
265
+ paths[`${base}/access`] = { post: accessOp(`access${name}`, ["500"]) };
266
+ paths[`${base}/access/{id}`] = {
267
+ parameters: [{
268
+ name: "id",
269
+ in: "path",
270
+ required: true,
271
+ schema: { type: idType }
272
+ }],
273
+ post: accessOp(`access${name}ById`, ["404", "500"])
274
+ };
275
+ }
276
+ if (isUpload) {
277
+ const file = { content: { "*/*": { schema: {
278
+ type: "string",
279
+ format: "binary"
280
+ } } } };
281
+ const fileParams = [{
282
+ name: "filename",
283
+ in: "path",
284
+ required: true,
285
+ schema: { type: "string" }
286
+ }];
287
+ if (collection.versions) fileParams.push({
288
+ name: "version",
289
+ in: "query",
290
+ description: t("paramFileVersion"),
291
+ schema: { type: idType }
292
+ });
293
+ paths[`${base}/file/{filename}`] = {
294
+ parameters: fileParams,
295
+ get: {
296
+ tags: [name],
297
+ operationId: `get${name}File`,
298
+ responses: {
299
+ "200": {
300
+ description: t("fileServe"),
301
+ ...file
302
+ },
303
+ "206": {
304
+ description: t("filePartial"),
305
+ ...file
306
+ },
307
+ ...errorResponses([
308
+ "400",
309
+ "403",
310
+ "404",
311
+ "500"
312
+ ], t)
313
+ },
314
+ security: secRead
315
+ }
316
+ };
317
+ paths[`${base}/{id}/rename`] = {
318
+ parameters: [{
319
+ name: "id",
320
+ in: "path",
321
+ required: true,
322
+ schema: { type: idType }
323
+ }],
324
+ post: {
325
+ tags: [name],
326
+ operationId: `rename${name}File`,
327
+ requestBody: {
328
+ required: true,
329
+ content: { "application/json": { schema: {
330
+ type: "object",
331
+ properties: {
332
+ filename: { type: "string" },
333
+ draft: { type: "boolean" }
334
+ },
335
+ required: ["filename"]
336
+ } } }
337
+ },
338
+ responses: updateResponse,
339
+ security: secUpdate
340
+ }
341
+ };
342
+ }
343
+ if (collection.slug === "payload-preferences") {
344
+ delete paths[`${base}/count`];
345
+ delete paths[`${base}/validate`];
346
+ delete paths[`${base}/access`];
347
+ const keyParam = [{
348
+ name: "id",
349
+ in: "path",
350
+ required: true,
351
+ description: t("paramPreferenceKey"),
352
+ schema: { type: "string" }
353
+ }];
354
+ const secured = securedRequirement();
355
+ paths[`${base}/{id}`] = {
356
+ ...paths[`${base}/{id}`],
357
+ get: {
358
+ tags: [name],
359
+ operationId: `find${name}ByKey`,
360
+ summary: t("preferenceGet"),
361
+ parameters: keyParam,
362
+ responses: {
363
+ ...jsonOk(t("preferenceGetResult"), { anyOf: [docRef, {
364
+ type: "object",
365
+ properties: {
366
+ message: { type: "string" },
367
+ value: { const: null }
368
+ },
369
+ required: ["message", "value"]
370
+ }] }),
371
+ ...errorResponses(["500"], t)
372
+ },
373
+ security: secured
374
+ },
375
+ post: {
376
+ tags: [name],
377
+ operationId: `upsert${name}ByKey`,
378
+ summary: t("preferenceSet"),
379
+ parameters: keyParam,
380
+ requestBody: {
381
+ ...jsonBody({
382
+ type: "object",
383
+ properties: { value: {} },
384
+ required: ["value"]
385
+ }),
386
+ description: t("preferenceSetBody")
387
+ },
388
+ responses: {
389
+ ...jsonOk(t("preferenceSetResult"), mutationSchema),
390
+ ...errorResponses(["401", "500"], t)
391
+ },
392
+ security: secured
393
+ },
394
+ delete: {
395
+ tags: [name],
396
+ operationId: `delete${name}ByKey`,
397
+ summary: t("preferenceDelete"),
398
+ parameters: keyParam,
399
+ responses: {
400
+ ...jsonOk(t("preferenceDeleteResult"), { allOf: [docRef, {
401
+ type: "object",
402
+ properties: { message: { type: "string" } }
403
+ }] }),
404
+ ...errorResponses([
405
+ "401",
406
+ "404",
407
+ "500"
408
+ ], t)
409
+ },
410
+ security: secured
411
+ }
412
+ };
413
+ }
414
+ return paths;
415
+ };
416
+ export { buildCollectionPaths };
417
+
418
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.js","names":[],"sources":["../../../../src/server/spec/paths/collections.ts"],"sourcesContent":["import type {\n ParameterObject,\n PathsObject,\n ReferenceObject,\n RequestBodyObject,\n ResponsesObject,\n SchemaObject,\n} from '@scalar/openapi-types/3.2'\nimport type { SanitizedCollectionConfig } from 'payload'\n\nimport {\n ERRORS,\n docAccessOperation,\n errorResponses,\n jsonBody,\n jsonOk,\n jsonResponse,\n uploadRequestBody,\n validateOperation,\n} from '@/server/spec/components.js'\nimport { createSchemaName, listSchemaName, refTo, schemaName, updateSchemaName } from '@/server/spec/names.js'\nimport {\n buildListParams,\n buildParamSchemas,\n commonReadParams,\n type ReadParamRefs,\n validateParams,\n writeParams,\n type WriteOperation,\n} from '@/server/spec/params.js'\nimport { type EntitySecurity, securedRequirement } from '@/server/spec/security.js'\nimport { makeT } from '@/shared/translations/index.js'\nimport type { BuildContext } from '@/shared/types/index.js'\n\nexport const buildCollectionPaths = ({\n collection,\n ctx,\n security = {},\n access = false,\n}: {\n collection: SanitizedCollectionConfig\n ctx: BuildContext\n security?: EntitySecurity\n access?: boolean\n}): PathsObject => {\n const t = makeT(ctx.i18n)\n const name = schemaName(collection.slug)\n const base = `${ctx.apiRoute}/${collection.slug}`\n const docRef: ReferenceObject = { $ref: refTo(name) }\n const listRef: ReferenceObject = { $ref: refTo(listSchemaName(name)) }\n const createRef: ReferenceObject = { $ref: refTo(createSchemaName(name)) }\n const updateRef: ReferenceObject = { $ref: refTo(updateSchemaName(name)) }\n const idType = ctx.defaultIDType === 'number' ? 'integer' : 'string'\n const { read: secRead, create: secCreate, update: secUpdate, delete: secDelete, validate: secValidate } = security\n\n const allowBulk = collection.disableBulkEdit !== true\n const allowDuplicate = collection.disableDuplicate !== true\n\n const paramSchemas = buildParamSchemas({ fields: collection.fields, ctx })\n const refs: ReadParamRefs = {\n select: true,\n populate: Boolean(paramSchemas.populate),\n joins: Boolean(paramSchemas.joins),\n }\n\n const isUpload = Boolean(collection.upload)\n const fileRequiredOnCreate =\n typeof collection.upload === 'object' ? collection.upload.filesRequiredOnCreate !== false : true\n\n const requestBody = (ref: ReferenceObject, fileRequired: boolean): RequestBodyObject =>\n isUpload\n ? uploadRequestBody({ bodyRef: ref, fileRequired, t })\n : { content: { 'application/json': { schema: ref } } }\n\n const mutationSchema: SchemaObject = {\n type: 'object',\n properties: { message: { type: 'string' }, doc: docRef },\n }\n\n const listResponse: ResponsesObject = {\n ...jsonOk(t('collectionList'), listRef),\n ...errorResponses(ERRORS.list, t),\n }\n const findByIdResponse: ResponsesObject = {\n ...jsonOk(t('collectionDoc'), docRef),\n ...errorResponses(ERRORS.read, t),\n }\n const createResponse: ResponsesObject = {\n '201': jsonResponse(t('collectionCreated'), mutationSchema),\n ...errorResponses(ERRORS.create, t),\n }\n const updateResponse: ResponsesObject = {\n ...jsonOk(t('collectionUpdated'), mutationSchema),\n ...errorResponses(ERRORS.update, t),\n }\n const deleteResponse: ResponsesObject = {\n ...jsonOk(t('collectionDeleted'), mutationSchema),\n ...errorResponses(ERRORS.delete, t),\n }\n\n const bulkSchema: SchemaObject = {\n type: 'object',\n properties: {\n message: { type: 'string' },\n docs: { type: 'array', items: docRef },\n errors: {\n type: 'array',\n items: {\n type: 'object',\n properties: { message: { type: 'string' }, id: { type: idType } },\n },\n },\n },\n }\n const bulkUpdateResponse: ResponsesObject = {\n ...jsonOk(t('collectionBulkUpdate'), bulkSchema),\n ...errorResponses(ERRORS.update, t),\n }\n const bulkDeleteResponse: ResponsesObject = {\n ...jsonOk(t('collectionBulkDelete'), bulkSchema),\n ...errorResponses(ERRORS.delete, t),\n }\n const countResponse: ResponsesObject = {\n ...jsonOk(t('collectionCount'), { type: 'object', properties: { totalDocs: { type: 'integer' } } }),\n ...errorResponses(ERRORS.list, t),\n }\n\n const listParams = buildListParams({ base: name, fields: collection.fields, ctx, refs })\n const bulkParams = listParams.filter((p) => p.name === 'where')\n const bulkUpdateParams = listParams.filter((p) => ['limit', 'sort', 'where'].includes(p.name))\n const write = (operation: WriteOperation) => writeParams({ base: name, entity: collection, ctx, refs, operation })\n const deleteParams = write('delete')\n\n const bulkOps = allowBulk\n ? {\n patch: {\n tags: [name],\n operationId: `update${name}`,\n parameters: [...bulkUpdateParams, ...write('update')],\n requestBody: requestBody(updateRef, false),\n responses: bulkUpdateResponse,\n security: secUpdate,\n },\n delete: {\n tags: [name],\n operationId: `delete${name}`,\n parameters: [...bulkParams, ...deleteParams],\n responses: bulkDeleteResponse,\n security: secDelete,\n },\n }\n : {}\n\n const paths: PathsObject = {\n [base]: {\n get: {\n tags: [name],\n operationId: `find${name}`,\n parameters: buildListParams({ base: name, fields: collection.fields, ctx, refs }),\n responses: listResponse,\n security: secRead,\n },\n post: {\n tags: [name],\n operationId: `create${name}`,\n parameters: write('create'),\n requestBody: requestBody(createRef, fileRequiredOnCreate),\n responses: createResponse,\n security: secCreate,\n },\n ...bulkOps,\n },\n [`${base}/count`]: {\n get: {\n tags: [name],\n operationId: `count${name}`,\n parameters: bulkParams,\n responses: countResponse,\n security: secRead,\n },\n },\n [`${base}/validate`]: {\n post: validateOperation({\n tag: name,\n operationId: `validate${name}`,\n parameters: validateParams(ctx),\n requestBody: { ...requestBody(createRef, false), required: true },\n errors: ERRORS.create,\n security: secValidate,\n t,\n }),\n },\n [`${base}/{id}`]: {\n parameters: [{ name: 'id', in: 'path', required: true, schema: { type: idType } }],\n get: {\n tags: [name],\n operationId: `find${name}ById`,\n parameters: commonReadParams({ base: name, ctx, refs }),\n responses: findByIdResponse,\n security: secRead,\n },\n patch: {\n tags: [name],\n operationId: `update${name}ById`,\n parameters: write('updateByID'),\n requestBody: requestBody(updateRef, false),\n responses: updateResponse,\n security: secUpdate,\n },\n delete: {\n tags: [name],\n operationId: `delete${name}ById`,\n parameters: deleteParams,\n responses: deleteResponse,\n security: secDelete,\n },\n },\n }\n\n paths[`${base}/{id}/validate`] = {\n parameters: [{ name: 'id', in: 'path', required: true, schema: { type: idType } }],\n post: validateOperation({\n tag: name,\n operationId: `validate${name}ById`,\n parameters: validateParams(ctx),\n requestBody: requestBody(updateRef, false),\n errors: ERRORS.update,\n security: secValidate,\n t,\n }),\n }\n\n if (allowDuplicate) {\n paths[`${base}/{id}/duplicate`] = {\n parameters: [{ name: 'id', in: 'path', required: true, schema: { type: idType } }],\n post: {\n tags: [name],\n operationId: `duplicate${name}`,\n parameters: write('duplicate'),\n responses: { ...jsonOk(t('collectionDuplicated'), mutationSchema), ...errorResponses(ERRORS.create, t) },\n security: secCreate,\n },\n }\n }\n\n if (access) {\n const auth = collection.auth\n const operations = [\n 'create',\n 'read',\n 'update',\n 'delete',\n 'validate',\n ...(auth && auth.maxLoginAttempts ? ['unlock'] : []),\n ...(collection.versions ? ['readVersions'] : []),\n ]\n const accessOp = (operationId: string, errors: typeof ERRORS.read) =>\n docAccessOperation({ tag: name, operationId, operations, bodyRef: updateRef, errors, t })\n paths[`${base}/access`] = { post: accessOp(`access${name}`, ['500']) }\n paths[`${base}/access/{id}`] = {\n parameters: [{ name: 'id', in: 'path', required: true, schema: { type: idType } }],\n post: accessOp(`access${name}ById`, ['404', '500']),\n }\n }\n\n if (isUpload) {\n const file = { content: { '*/*': { schema: { type: 'string', format: 'binary' } } } } as const\n const fileParams: ParameterObject[] = [{ name: 'filename', in: 'path', required: true, schema: { type: 'string' } }]\n if (collection.versions) {\n fileParams.push({ name: 'version', in: 'query', description: t('paramFileVersion'), schema: { type: idType } })\n }\n paths[`${base}/file/{filename}`] = {\n parameters: fileParams,\n get: {\n tags: [name],\n operationId: `get${name}File`,\n responses: {\n '200': { description: t('fileServe'), ...file },\n '206': { description: t('filePartial'), ...file },\n ...errorResponses(['400', '403', '404', '500'], t),\n },\n security: secRead,\n },\n }\n paths[`${base}/{id}/rename`] = {\n parameters: [{ name: 'id', in: 'path', required: true, schema: { type: idType } }],\n post: {\n tags: [name],\n operationId: `rename${name}File`,\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: { filename: { type: 'string' }, draft: { type: 'boolean' } },\n required: ['filename'],\n },\n },\n },\n },\n responses: updateResponse,\n security: secUpdate,\n },\n }\n }\n\n if (collection.slug === 'payload-preferences') {\n delete paths[`${base}/count`]\n delete paths[`${base}/validate`]\n delete paths[`${base}/access`]\n const keyParam: ParameterObject[] = [\n { name: 'id', in: 'path', required: true, description: t('paramPreferenceKey'), schema: { type: 'string' } },\n ]\n const secured = securedRequirement()\n paths[`${base}/{id}`] = {\n ...paths[`${base}/{id}`],\n get: {\n tags: [name],\n operationId: `find${name}ByKey`,\n summary: t('preferenceGet'),\n parameters: keyParam,\n responses: {\n ...jsonOk(t('preferenceGetResult'), {\n anyOf: [\n docRef,\n {\n type: 'object',\n properties: { message: { type: 'string' }, value: { const: null } },\n required: ['message', 'value'],\n },\n ],\n }),\n ...errorResponses(['500'], t),\n },\n security: secured,\n },\n post: {\n tags: [name],\n operationId: `upsert${name}ByKey`,\n summary: t('preferenceSet'),\n parameters: keyParam,\n requestBody: {\n ...jsonBody({ type: 'object', properties: { value: {} }, required: ['value'] }),\n description: t('preferenceSetBody'),\n },\n responses: { ...jsonOk(t('preferenceSetResult'), mutationSchema), ...errorResponses(['401', '500'], t) },\n security: secured,\n },\n delete: {\n tags: [name],\n operationId: `delete${name}ByKey`,\n summary: t('preferenceDelete'),\n parameters: keyParam,\n responses: {\n ...jsonOk(t('preferenceDeleteResult'), {\n allOf: [docRef, { type: 'object', properties: { message: { type: 'string' } } }],\n }),\n ...errorResponses(['401', '404', '500'], t),\n },\n security: secured,\n },\n }\n }\n\n return paths\n}\n"],"mappings":";;;;;AAkCA,MAAa,wBAAwB,EACnC,YACA,KACA,WAAW,CAAC,GACZ,SAAS,YAMQ;CACjB,MAAM,IAAI,MAAM,IAAI,IAAI;CACxB,MAAM,OAAO,WAAW,WAAW,IAAI;CACvC,MAAM,OAAO,GAAG,IAAI,SAAS,GAAG,WAAW;CAC3C,MAAM,SAA0B,EAAE,MAAM,MAAM,IAAI,EAAE;CACpD,MAAM,UAA2B,EAAE,MAAM,MAAM,eAAe,IAAI,CAAC,EAAE;CACrE,MAAM,YAA6B,EAAE,MAAM,MAAM,iBAAiB,IAAI,CAAC,EAAE;CACzE,MAAM,YAA6B,EAAE,MAAM,MAAM,iBAAiB,IAAI,CAAC,EAAE;CACzE,MAAM,SAAS,IAAI,kBAAkB,WAAW,YAAY;CAC5D,MAAM,EAAE,MAAM,SAAS,QAAQ,WAAW,QAAQ,WAAW,QAAQ,WAAW,UAAU,gBAAgB;CAE1G,MAAM,YAAY,WAAW,oBAAoB;CACjD,MAAM,iBAAiB,WAAW,qBAAqB;CAEvD,MAAM,eAAe,kBAAkB;EAAE,QAAQ,WAAW;EAAQ;CAAI,CAAC;CACzE,MAAM,OAAsB;EAC1B,QAAQ;EACR,UAAU,QAAQ,aAAa,QAAQ;EACvC,OAAO,QAAQ,aAAa,KAAK;CACnC;CAEA,MAAM,WAAW,QAAQ,WAAW,MAAM;CAC1C,MAAM,uBACJ,OAAO,WAAW,WAAW,WAAW,WAAW,OAAO,0BAA0B,QAAQ;CAE9F,MAAM,eAAe,KAAsB,iBACzC,WACI,kBAAkB;EAAE,SAAS;EAAK;EAAc;CAAE,CAAC,IACnD,EAAE,SAAS,EAAE,oBAAoB,EAAE,QAAQ,IAAI,EAAE,EAAE;CAEzD,MAAM,iBAA+B;EACnC,MAAM;EACN,YAAY;GAAE,SAA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CAAC,IAAI;IACX,aAAa,SAAS,KAAK;IAC3B,SAAS,EAAE,eAAe;IAC1B,YAAY;IACZ,aAAa;KACX,GAAG,SAAS;MAAE,MAAM;MAAU,YAAY,EAAE,OAAO,CAAC,EAAE;MAAG,UAAU,CAAC,OAAO;KAAE,CAAC;KAC9E,aAAa,EAAE,mBAAmB;IACpC;IACA,WAAW;KAAE,GAAG,OAAO,EAAE,qBAAqB,GAAG,cAAc;KAAG,GAAG,eAAe,CAAC,OAAO,KAAK,GAAG,CAAC;IAAE;IACvG,UAAU;GACZ;GACA,QAAQ;IACN,MAAM,CAAC,IAAI;IACX,aAAa,SAAS,KAAK;IAC3B,SAAS,EAAE,kBAAkB;IAC7B,YAAY;IACZ,WAAW;KACT,GAAG,OAAO,EAAE,wBAAwB,GAAG,EACrC,OAAO,CAAC,QAAQ;MAAE,MAAM;MAAU,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,EAAE;KAAE,CAAC,EACjF,CAAC;KACD,GAAG,eAAe;MAAC;MAAO;MAAO;KAAK,GAAG,CAAC;IAC5C;IACA,UAAU;GACZ;EACF;CACF;CAEA,OAAO;AACT"}
@@ -0,0 +1,12 @@
1
+ import { BuildContext } from "../../../shared/types/index.js";
2
+ import { Endpoint, SanitizedCollectionConfig, SanitizedConfig, SanitizedGlobalConfig } from "payload";
3
+ import { OperationObject, PathsObject } from "@scalar/openapi-types/3.2";
4
+ export declare const getOpenapiMeta: (endpoint: Endpoint) => OperationObject | undefined;
5
+ export declare const normalizePath: (prefix: string, path: string) => string;
6
+ export declare const buildCustomEndpointPaths: ({ config, collections, globals, ctx }: {
7
+ config: SanitizedConfig;
8
+ collections: SanitizedCollectionConfig[];
9
+ globals: SanitizedGlobalConfig[];
10
+ ctx: BuildContext;
11
+ }) => PathsObject;
12
+ //# sourceMappingURL=custom.d.ts.map
@@ -0,0 +1,42 @@
1
+ const getOpenapiMeta = (endpoint) => {
2
+ const meta = endpoint.custom?.openapi;
3
+ return meta && typeof meta === "object" ? meta : void 0;
4
+ };
5
+ const normalizePath = (prefix, path) => {
6
+ return `${prefix}${path.startsWith("/") ? path : `/${path}`}`.replace(/:([A-Za-z0-9_]+)/g, "{$1}");
7
+ };
8
+ const collect = ({ endpoints, prefix, out }) => {
9
+ if (!endpoints) return;
10
+ for (const endpoint of endpoints) {
11
+ const meta = getOpenapiMeta(endpoint);
12
+ if (!meta) continue;
13
+ const path = normalizePath(prefix, endpoint.path);
14
+ const method = endpoint.method.toLowerCase();
15
+ out[path] = {
16
+ ...out[path],
17
+ [method]: { ...meta }
18
+ };
19
+ }
20
+ };
21
+ const buildCustomEndpointPaths = ({ config, collections, globals, ctx }) => {
22
+ const out = {};
23
+ collect({
24
+ endpoints: config.endpoints,
25
+ prefix: ctx.apiRoute,
26
+ out
27
+ });
28
+ for (const collection of collections) collect({
29
+ endpoints: collection.endpoints,
30
+ prefix: `${ctx.apiRoute}/${collection.slug}`,
31
+ out
32
+ });
33
+ for (const global of globals) collect({
34
+ endpoints: global.endpoints,
35
+ prefix: `${ctx.apiRoute}/globals/${global.slug}`,
36
+ out
37
+ });
38
+ return out;
39
+ };
40
+ export { buildCustomEndpointPaths, getOpenapiMeta, normalizePath };
41
+
42
+ //# sourceMappingURL=custom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.js","names":[],"sources":["../../../../src/server/spec/paths/custom.ts"],"sourcesContent":["import type { OperationObject, PathsObject } from '@scalar/openapi-types/3.2'\nimport type { Endpoint, SanitizedCollectionConfig, SanitizedConfig, SanitizedGlobalConfig } from 'payload'\n\nimport type { BuildContext } from '@/shared/types/index.js'\n\nexport const getOpenapiMeta = (endpoint: Endpoint): OperationObject | undefined => {\n const meta = endpoint.custom?.openapi\n return meta && typeof meta === 'object' ? (meta as OperationObject) : undefined\n}\n\nexport const normalizePath = (prefix: string, path: string): string => {\n const joined = `${prefix}${path.startsWith('/') ? path : `/${path}`}`\n return joined.replace(/:([A-Za-z0-9_]+)/g, '{$1}')\n}\n\nconst collect = ({\n endpoints,\n prefix,\n out,\n}: {\n endpoints: Endpoint[] | false | undefined\n prefix: string\n out: PathsObject\n}): void => {\n if (!endpoints) return\n for (const endpoint of endpoints) {\n const meta = getOpenapiMeta(endpoint)\n if (!meta) continue\n const path = normalizePath(prefix, endpoint.path)\n const method = endpoint.method.toLowerCase()\n out[path] = { ...out[path], [method]: { ...meta } }\n }\n}\n\nexport const buildCustomEndpointPaths = ({\n config,\n collections,\n globals,\n ctx,\n}: {\n config: SanitizedConfig\n collections: SanitizedCollectionConfig[]\n globals: SanitizedGlobalConfig[]\n ctx: BuildContext\n}): PathsObject => {\n const out: PathsObject = {}\n collect({ endpoints: config.endpoints, prefix: ctx.apiRoute, out })\n for (const collection of collections) {\n collect({ endpoints: collection.endpoints, prefix: `${ctx.apiRoute}/${collection.slug}`, out })\n }\n for (const global of globals) {\n collect({ endpoints: global.endpoints, prefix: `${ctx.apiRoute}/globals/${global.slug}`, out })\n }\n return out\n}\n"],"mappings":"AAKA,MAAa,kBAAkB,aAAoD;CACjF,MAAM,OAAO,SAAS,QAAQ;CAC9B,OAAO,QAAQ,OAAO,SAAS,WAAY,OAA2B,KAAA;AACxE;AAEA,MAAa,iBAAiB,QAAgB,SAAyB;CAErE,OAAO,GADW,SAAS,KAAK,WAAW,GAAG,IAAI,OAAO,IAAI,SAC/C,QAAQ,qBAAqB,MAAM;AACnD;AAEA,MAAM,WAAW,EACf,WACA,QACA,UAKU;CACV,IAAI,CAAC,WAAW;CAChB,KAAK,MAAM,YAAY,WAAW;EAChC,MAAM,OAAO,eAAe,QAAQ;EACpC,IAAI,CAAC,MAAM;EACX,MAAM,OAAO,cAAc,QAAQ,SAAS,IAAI;EAChD,MAAM,SAAS,SAAS,OAAO,YAAY;EAC3C,IAAI,QAAQ;GAAE,GAAG,IAAI;IAAQ,SAAS,EAAE,GAAG,KAAK;EAAE;CACpD;AACF;AAEA,MAAa,4BAA4B,EACvC,QACA,aACA,SACA,UAMiB;CACjB,MAAM,MAAmB,CAAC;CAC1B,QAAQ;EAAE,WAAW,OAAO;EAAW,QAAQ,IAAI;EAAU;CAAI,CAAC;CAClE,KAAK,MAAM,cAAc,aACvB,QAAQ;EAAE,WAAW,WAAW;EAAW,QAAQ,GAAG,IAAI,SAAS,GAAG,WAAW;EAAQ;CAAI,CAAC;CAEhG,KAAK,MAAM,UAAU,SACnB,QAAQ;EAAE,WAAW,OAAO;EAAW,QAAQ,GAAG,IAAI,SAAS,WAAW,OAAO;EAAQ;CAAI,CAAC;CAEhG,OAAO;AACT"}
@@ -0,0 +1,11 @@
1
+ import { BuildContext } from "../../../shared/types/index.js";
2
+ import { EntitySecurity } from "../security.js";
3
+ import { SanitizedGlobalConfig } from "payload";
4
+ import { PathsObject } from "@scalar/openapi-types/3.2";
5
+ export declare const buildGlobalPaths: ({ global, ctx, security, access }: {
6
+ global: SanitizedGlobalConfig;
7
+ ctx: BuildContext;
8
+ security?: EntitySecurity;
9
+ access?: boolean;
10
+ }) => PathsObject;
11
+ //# sourceMappingURL=globals.d.ts.map
@@ -0,0 +1,87 @@
1
+ import { globalSchemaName, refTo, updateSchemaName } from "../names.js";
2
+ import { ERRORS, docAccessOperation, errorResponses, jsonOk, validateOperation } from "../components.js";
3
+ import { makeT } from "../../../shared/translations/index.js";
4
+ import { buildParamSchemas, commonReadParams, validateParams, writeParams } from "../params.js";
5
+ const buildGlobalPaths = ({ global, ctx, security = {}, access = false }) => {
6
+ const t = makeT(ctx.i18n);
7
+ const name = globalSchemaName(global.slug);
8
+ const docRef = { $ref: refTo(name) };
9
+ const updateRef = { $ref: refTo(updateSchemaName(name)) };
10
+ const { read: secRead, update: secUpdate, validate: secValidate } = security;
11
+ const paramSchemas = buildParamSchemas({
12
+ fields: global.fields,
13
+ ctx
14
+ });
15
+ const refs = {
16
+ select: true,
17
+ populate: Boolean(paramSchemas.populate),
18
+ joins: Boolean(paramSchemas.joins)
19
+ };
20
+ const paths = {
21
+ [`${ctx.apiRoute}/globals/${global.slug}`]: {
22
+ get: {
23
+ tags: [name],
24
+ operationId: `find${name}`,
25
+ parameters: commonReadParams({
26
+ base: name,
27
+ ctx,
28
+ refs
29
+ }),
30
+ responses: {
31
+ ...jsonOk(t("globalDoc"), docRef),
32
+ ...errorResponses(ERRORS.globalRead, t)
33
+ },
34
+ security: secRead
35
+ },
36
+ post: {
37
+ tags: [name],
38
+ operationId: `update${name}`,
39
+ parameters: writeParams({
40
+ base: name,
41
+ entity: global,
42
+ ctx,
43
+ refs,
44
+ operation: "globalUpdate"
45
+ }),
46
+ requestBody: { content: { "application/json": { schema: updateRef } } },
47
+ responses: {
48
+ ...jsonOk(t("globalDoc"), {
49
+ type: "object",
50
+ properties: {
51
+ message: { type: "string" },
52
+ result: docRef
53
+ }
54
+ }),
55
+ ...errorResponses(ERRORS.globalUpdate, t)
56
+ },
57
+ security: secUpdate
58
+ }
59
+ },
60
+ [`${ctx.apiRoute}/globals/${global.slug}/validate`]: { post: validateOperation({
61
+ tag: name,
62
+ operationId: `validate${name}`,
63
+ parameters: validateParams(ctx),
64
+ requestBody: { content: { "application/json": { schema: updateRef } } },
65
+ errors: ERRORS.globalUpdate,
66
+ security: secValidate,
67
+ t
68
+ }) }
69
+ };
70
+ if (access) paths[`${ctx.apiRoute}/globals/${global.slug}/access`] = { post: docAccessOperation({
71
+ tag: name,
72
+ operationId: `access${name}`,
73
+ operations: [
74
+ "read",
75
+ "update",
76
+ "validate",
77
+ ...global.versions ? ["readVersions"] : []
78
+ ],
79
+ bodyRef: updateRef,
80
+ errors: ["500"],
81
+ t
82
+ }) };
83
+ return paths;
84
+ };
85
+ export { buildGlobalPaths };
86
+
87
+ //# sourceMappingURL=globals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.js","names":[],"sources":["../../../../src/server/spec/paths/globals.ts"],"sourcesContent":["import type { PathsObject, ReferenceObject } from '@scalar/openapi-types/3.2'\nimport type { SanitizedGlobalConfig } from 'payload'\n\nimport { ERRORS, docAccessOperation, errorResponses, jsonOk, validateOperation } from '@/server/spec/components.js'\nimport { globalSchemaName, refTo, updateSchemaName } from '@/server/spec/names.js'\nimport {\n buildParamSchemas,\n commonReadParams,\n type ReadParamRefs,\n validateParams,\n writeParams,\n} from '@/server/spec/params.js'\nimport type { EntitySecurity } from '@/server/spec/security.js'\nimport { makeT } from '@/shared/translations/index.js'\nimport type { BuildContext } from '@/shared/types/index.js'\n\nexport const buildGlobalPaths = ({\n global,\n ctx,\n security = {},\n access = false,\n}: {\n global: SanitizedGlobalConfig\n ctx: BuildContext\n security?: EntitySecurity\n access?: boolean\n}): PathsObject => {\n const t = makeT(ctx.i18n)\n const name = globalSchemaName(global.slug)\n const docRef: ReferenceObject = { $ref: refTo(name) }\n const updateRef: ReferenceObject = { $ref: refTo(updateSchemaName(name)) }\n const { read: secRead, update: secUpdate, validate: secValidate } = security\n\n const paramSchemas = buildParamSchemas({ fields: global.fields, ctx })\n const refs: ReadParamRefs = {\n select: true,\n populate: Boolean(paramSchemas.populate),\n joins: Boolean(paramSchemas.joins),\n }\n\n const paths: PathsObject = {\n [`${ctx.apiRoute}/globals/${global.slug}`]: {\n get: {\n tags: [name],\n operationId: `find${name}`,\n parameters: commonReadParams({ base: name, ctx, refs }),\n responses: { ...jsonOk(t('globalDoc'), docRef), ...errorResponses(ERRORS.globalRead, t) },\n security: secRead,\n },\n post: {\n tags: [name],\n operationId: `update${name}`,\n parameters: writeParams({ base: name, entity: global, ctx, refs, operation: 'globalUpdate' }),\n requestBody: { content: { 'application/json': { schema: updateRef } } },\n responses: {\n ...jsonOk(t('globalDoc'), {\n type: 'object',\n properties: { message: { type: 'string' }, result: docRef },\n }),\n ...errorResponses(ERRORS.globalUpdate, t),\n },\n security: secUpdate,\n },\n },\n [`${ctx.apiRoute}/globals/${global.slug}/validate`]: {\n post: validateOperation({\n tag: name,\n operationId: `validate${name}`,\n parameters: validateParams(ctx),\n requestBody: { content: { 'application/json': { schema: updateRef } } },\n errors: ERRORS.globalUpdate,\n security: secValidate,\n t,\n }),\n },\n }\n\n if (access) {\n paths[`${ctx.apiRoute}/globals/${global.slug}/access`] = {\n post: docAccessOperation({\n tag: name,\n operationId: `access${name}`,\n operations: ['read', 'update', 'validate', ...(global.versions ? ['readVersions'] : [])],\n bodyRef: updateRef,\n errors: ['500'],\n t,\n }),\n }\n }\n\n return paths\n}\n"],"mappings":";;;;AAgBA,MAAa,oBAAoB,EAC/B,QACA,KACA,WAAW,CAAC,GACZ,SAAS,YAMQ;CACjB,MAAM,IAAI,MAAM,IAAI,IAAI;CACxB,MAAM,OAAO,iBAAiB,OAAO,IAAI;CACzC,MAAM,SAA0B,EAAE,MAAM,MAAM,IAAI,EAAE;CACpD,MAAM,YAA6B,EAAE,MAAM,MAAM,iBAAiB,IAAI,CAAC,EAAE;CACzE,MAAM,EAAE,MAAM,SAAS,QAAQ,WAAW,UAAU,gBAAgB;CAEpE,MAAM,eAAe,kBAAkB;EAAE,QAAQ,OAAO;EAAQ;CAAI,CAAC;CACrE,MAAM,OAAsB;EAC1B,QAAQ;EACR,UAAU,QAAQ,aAAa,QAAQ;EACvC,OAAO,QAAQ,aAAa,KAAK;CACnC;CAEA,MAAM,QAAqB;GACxB,GAAG,IAAI,SAAS,WAAW,OAAO,SAAS;GAC1C,KAAK;IACH,MAAM,CAAC,IAAI;IACX,aAAa,OAAO;IACpB,YAAY,iBAAiB;KAAE,MAAM;KAAM;KAAK;IAAK,CAAC;IACtD,WAAW;KAAE,GAAG,OAAO,EAAE,WAAW,GAAG,MAAM;KAAG,GAAG,eAAe,OAAO,YAAY,CAAC;IAAE;IACxF,UAAU;GACZ;GACA,MAAM;IACJ,MAAM,CAAC,IAAI;IACX,aAAa,SAAS;IACtB,YAAY,YAAY;KAAE,MAAM;KAAM,QAAQ;KAAQ;KAAK;KAAM,WAAW;IAAe,CAAC;IAC5F,aAAa,EAAE,SAAS,EAAE,oBAAoB,EAAE,QAAQ,UAAU,EAAE,EAAE;IACtE,WAAW;KACT,GAAG,OAAO,EAAE,WAAW,GAAG;MACxB,MAAM;MACN,YAAY;OAAE,SAAS,EAAE,MAAM,SAAS;OAAG,QAAQ;MAAO;KAC5D,CAAC;KACD,GAAG,eAAe,OAAO,cAAc,CAAC;IAC1C;IACA,UAAU;GACZ;EACF;GACC,GAAG,IAAI,SAAS,WAAW,OAAO,KAAK,aAAa,EACnD,MAAM,kBAAkB;GACtB,KAAK;GACL,aAAa,WAAW;GACxB,YAAY,eAAe,GAAG;GAC9B,aAAa,EAAE,SAAS,EAAE,oBAAoB,EAAE,QAAQ,UAAU,EAAE,EAAE;GACtE,QAAQ,OAAO;GACf,UAAU;GACV;EACF,CAAC,EACH;CACF;CAEA,IAAI,QACF,MAAM,GAAG,IAAI,SAAS,WAAW,OAAO,KAAK,YAAY,EACvD,MAAM,mBAAmB;EACvB,KAAK;EACL,aAAa,SAAS;EACtB,YAAY;GAAC;GAAQ;GAAU;GAAY,GAAI,OAAO,WAAW,CAAC,cAAc,IAAI,CAAC;EAAE;EACvF,SAAS;EACT,QAAQ,CAAC,KAAK;EACd;CACF,CAAC,EACH;CAGF,OAAO;AACT"}
@@ -0,0 +1,9 @@
1
+ import { BuildContext } from "../../../shared/types/index.js";
2
+ import { SanitizedConfig } from "payload";
3
+ import { PathsObject, SecurityRequirementObject } from "@scalar/openapi-types/3.2";
4
+ export declare const buildJobsPaths: ({ config, ctx, security }: {
5
+ config: SanitizedConfig;
6
+ ctx: BuildContext;
7
+ security?: SecurityRequirementObject[];
8
+ }) => PathsObject;
9
+ //# sourceMappingURL=jobs.d.ts.map