@seshuk/payload-plugin-openapi 0.2.1 → 1.0.0-beta.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 (377) hide show
  1. package/README.md +67 -25
  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 +287 -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 +16 -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 +12 -0
  38. package/dist/server/spec/filters.js +91 -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 +38 -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 +314 -0
  54. package/dist/server/spec/paths/collections.js.map +1 -0
  55. package/dist/server/spec/paths/custom.d.ts +10 -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 +8 -0
  65. package/dist/server/spec/paths/system.js +137 -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/security.d.ts +33 -0
  71. package/dist/server/spec/security.js +97 -0
  72. package/dist/server/spec/security.js.map +1 -0
  73. package/dist/server/spec/tags.d.ts +34 -0
  74. package/dist/server/spec/tags.js +83 -0
  75. package/dist/server/spec/tags.js.map +1 -0
  76. package/dist/server/telemetry.d.ts +31 -0
  77. package/dist/server/telemetry.js +33 -0
  78. package/dist/server/telemetry.js.map +1 -0
  79. package/dist/server/ui/createUiPlugin.d.ts +16 -0
  80. package/dist/server/ui/createUiPlugin.js +33 -0
  81. package/dist/server/ui/createUiPlugin.js.map +1 -0
  82. package/dist/{ui → server/ui}/html.d.ts +5 -3
  83. package/dist/server/ui/html.js +11 -0
  84. package/dist/server/ui/html.js.map +1 -0
  85. package/dist/server/ui/scalar.d.ts +4 -0
  86. package/dist/server/ui/scalar.js +17 -0
  87. package/dist/server/ui/scalar.js.map +1 -0
  88. package/dist/server/ui/swagger.d.ts +4 -0
  89. package/dist/server/ui/swagger.js +18 -0
  90. package/dist/server/ui/swagger.js.map +1 -0
  91. package/dist/shared/constants.d.ts +4 -0
  92. package/dist/shared/constants.js +6 -0
  93. package/dist/shared/constants.js.map +1 -0
  94. package/dist/shared/translations/index.d.ts +5 -0
  95. package/dist/{translations → shared/translations}/index.js +49 -47
  96. package/dist/shared/translations/index.js.map +1 -0
  97. package/dist/shared/translations/locales/ar.d.ts +3 -0
  98. package/dist/shared/translations/locales/ar.js +99 -0
  99. package/dist/shared/translations/locales/ar.js.map +1 -0
  100. package/dist/shared/translations/locales/az.d.ts +3 -0
  101. package/dist/shared/translations/locales/az.js +99 -0
  102. package/dist/shared/translations/locales/az.js.map +1 -0
  103. package/dist/shared/translations/locales/bg.d.ts +3 -0
  104. package/dist/shared/translations/locales/bg.js +99 -0
  105. package/dist/shared/translations/locales/bg.js.map +1 -0
  106. package/dist/shared/translations/locales/bnBd.d.ts +3 -0
  107. package/dist/shared/translations/locales/bnBd.js +99 -0
  108. package/dist/shared/translations/locales/bnBd.js.map +1 -0
  109. package/dist/shared/translations/locales/bnIn.d.ts +3 -0
  110. package/dist/shared/translations/locales/bnIn.js +99 -0
  111. package/dist/shared/translations/locales/bnIn.js.map +1 -0
  112. package/dist/shared/translations/locales/ca.d.ts +3 -0
  113. package/dist/shared/translations/locales/ca.js +99 -0
  114. package/dist/shared/translations/locales/ca.js.map +1 -0
  115. package/dist/shared/translations/locales/cs.d.ts +3 -0
  116. package/dist/shared/translations/locales/cs.js +99 -0
  117. package/dist/shared/translations/locales/cs.js.map +1 -0
  118. package/dist/shared/translations/locales/da.d.ts +3 -0
  119. package/dist/shared/translations/locales/da.js +99 -0
  120. package/dist/shared/translations/locales/da.js.map +1 -0
  121. package/dist/shared/translations/locales/de.d.ts +3 -0
  122. package/dist/shared/translations/locales/de.js +99 -0
  123. package/dist/shared/translations/locales/de.js.map +1 -0
  124. package/dist/shared/translations/locales/en.d.ts +3 -0
  125. package/dist/shared/translations/locales/en.js +99 -0
  126. package/dist/shared/translations/locales/en.js.map +1 -0
  127. package/dist/shared/translations/locales/es.d.ts +3 -0
  128. package/dist/shared/translations/locales/es.js +99 -0
  129. package/dist/shared/translations/locales/es.js.map +1 -0
  130. package/dist/shared/translations/locales/et.d.ts +3 -0
  131. package/dist/shared/translations/locales/et.js +99 -0
  132. package/dist/shared/translations/locales/et.js.map +1 -0
  133. package/dist/shared/translations/locales/fa.d.ts +3 -0
  134. package/dist/shared/translations/locales/fa.js +99 -0
  135. package/dist/shared/translations/locales/fa.js.map +1 -0
  136. package/dist/shared/translations/locales/fr.d.ts +3 -0
  137. package/dist/shared/translations/locales/fr.js +99 -0
  138. package/dist/shared/translations/locales/fr.js.map +1 -0
  139. package/dist/shared/translations/locales/he.d.ts +3 -0
  140. package/dist/shared/translations/locales/he.js +99 -0
  141. package/dist/shared/translations/locales/he.js.map +1 -0
  142. package/dist/shared/translations/locales/hr.d.ts +3 -0
  143. package/dist/shared/translations/locales/hr.js +99 -0
  144. package/dist/shared/translations/locales/hr.js.map +1 -0
  145. package/dist/shared/translations/locales/hu.d.ts +3 -0
  146. package/dist/shared/translations/locales/hu.js +99 -0
  147. package/dist/shared/translations/locales/hu.js.map +1 -0
  148. package/dist/shared/translations/locales/hy.d.ts +3 -0
  149. package/dist/shared/translations/locales/hy.js +99 -0
  150. package/dist/shared/translations/locales/hy.js.map +1 -0
  151. package/dist/shared/translations/locales/id.d.ts +3 -0
  152. package/dist/shared/translations/locales/id.js +99 -0
  153. package/dist/shared/translations/locales/id.js.map +1 -0
  154. package/dist/shared/translations/locales/is.d.ts +3 -0
  155. package/dist/shared/translations/locales/is.js +99 -0
  156. package/dist/shared/translations/locales/is.js.map +1 -0
  157. package/dist/shared/translations/locales/it.d.ts +3 -0
  158. package/dist/shared/translations/locales/it.js +99 -0
  159. package/dist/shared/translations/locales/it.js.map +1 -0
  160. package/dist/shared/translations/locales/ja.d.ts +3 -0
  161. package/dist/shared/translations/locales/ja.js +99 -0
  162. package/dist/shared/translations/locales/ja.js.map +1 -0
  163. package/dist/shared/translations/locales/ko.d.ts +3 -0
  164. package/dist/shared/translations/locales/ko.js +99 -0
  165. package/dist/shared/translations/locales/ko.js.map +1 -0
  166. package/dist/shared/translations/locales/lt.d.ts +3 -0
  167. package/dist/shared/translations/locales/lt.js +99 -0
  168. package/dist/shared/translations/locales/lt.js.map +1 -0
  169. package/dist/shared/translations/locales/lv.d.ts +3 -0
  170. package/dist/shared/translations/locales/lv.js +99 -0
  171. package/dist/shared/translations/locales/lv.js.map +1 -0
  172. package/dist/shared/translations/locales/my.d.ts +3 -0
  173. package/dist/shared/translations/locales/my.js +99 -0
  174. package/dist/shared/translations/locales/my.js.map +1 -0
  175. package/dist/shared/translations/locales/nb.d.ts +3 -0
  176. package/dist/shared/translations/locales/nb.js +99 -0
  177. package/dist/shared/translations/locales/nb.js.map +1 -0
  178. package/dist/shared/translations/locales/nl.d.ts +3 -0
  179. package/dist/shared/translations/locales/nl.js +99 -0
  180. package/dist/shared/translations/locales/nl.js.map +1 -0
  181. package/dist/shared/translations/locales/pl.d.ts +3 -0
  182. package/dist/shared/translations/locales/pl.js +99 -0
  183. package/dist/shared/translations/locales/pl.js.map +1 -0
  184. package/dist/shared/translations/locales/pt.d.ts +3 -0
  185. package/dist/shared/translations/locales/pt.js +99 -0
  186. package/dist/shared/translations/locales/pt.js.map +1 -0
  187. package/dist/shared/translations/locales/ro.d.ts +3 -0
  188. package/dist/shared/translations/locales/ro.js +99 -0
  189. package/dist/shared/translations/locales/ro.js.map +1 -0
  190. package/dist/shared/translations/locales/rs.d.ts +3 -0
  191. package/dist/shared/translations/locales/rs.js +99 -0
  192. package/dist/shared/translations/locales/rs.js.map +1 -0
  193. package/dist/shared/translations/locales/rsLatin.d.ts +3 -0
  194. package/dist/shared/translations/locales/rsLatin.js +99 -0
  195. package/dist/shared/translations/locales/rsLatin.js.map +1 -0
  196. package/dist/shared/translations/locales/ru.d.ts +3 -0
  197. package/dist/shared/translations/locales/ru.js +99 -0
  198. package/dist/shared/translations/locales/ru.js.map +1 -0
  199. package/dist/shared/translations/locales/sk.d.ts +3 -0
  200. package/dist/shared/translations/locales/sk.js +99 -0
  201. package/dist/shared/translations/locales/sk.js.map +1 -0
  202. package/dist/shared/translations/locales/sl.d.ts +3 -0
  203. package/dist/shared/translations/locales/sl.js +99 -0
  204. package/dist/shared/translations/locales/sl.js.map +1 -0
  205. package/dist/shared/translations/locales/sv.d.ts +3 -0
  206. package/dist/shared/translations/locales/sv.js +99 -0
  207. package/dist/shared/translations/locales/sv.js.map +1 -0
  208. package/dist/shared/translations/locales/ta.d.ts +3 -0
  209. package/dist/shared/translations/locales/ta.js +99 -0
  210. package/dist/shared/translations/locales/ta.js.map +1 -0
  211. package/dist/shared/translations/locales/th.d.ts +3 -0
  212. package/dist/shared/translations/locales/th.js +99 -0
  213. package/dist/shared/translations/locales/th.js.map +1 -0
  214. package/dist/shared/translations/locales/tr.d.ts +3 -0
  215. package/dist/shared/translations/locales/tr.js +99 -0
  216. package/dist/shared/translations/locales/tr.js.map +1 -0
  217. package/dist/shared/translations/locales/uk.d.ts +3 -0
  218. package/dist/shared/translations/locales/uk.js +99 -0
  219. package/dist/shared/translations/locales/uk.js.map +1 -0
  220. package/dist/shared/translations/locales/vi.d.ts +3 -0
  221. package/dist/shared/translations/locales/vi.js +99 -0
  222. package/dist/shared/translations/locales/vi.js.map +1 -0
  223. package/dist/shared/translations/locales/zh.d.ts +3 -0
  224. package/dist/shared/translations/locales/zh.js +99 -0
  225. package/dist/shared/translations/locales/zh.js.map +1 -0
  226. package/dist/shared/translations/locales/zhTw.d.ts +3 -0
  227. package/dist/shared/translations/locales/zhTw.js +99 -0
  228. package/dist/shared/translations/locales/zhTw.js.map +1 -0
  229. package/dist/shared/translations/types.d.ts +106 -0
  230. package/dist/shared/translations/types.js +1 -0
  231. package/dist/shared/types/index.d.ts +397 -0
  232. package/dist/shared/types/index.js +1 -0
  233. package/dist/{utils.d.ts → shared/utils.d.ts} +1 -0
  234. package/dist/shared/utils.js +13 -0
  235. package/dist/shared/utils.js.map +1 -0
  236. package/package.json +67 -56
  237. package/dist/bin/generateSpec.d.ts +0 -25
  238. package/dist/bin/generateSpec.js +0 -61
  239. package/dist/constants.d.ts +0 -1
  240. package/dist/constants.js +0 -2
  241. package/dist/endpoints/interactiveAuth.js +0 -27
  242. package/dist/endpoints/spec.d.ts +0 -5
  243. package/dist/endpoints/spec.js +0 -39
  244. package/dist/options.d.ts +0 -2
  245. package/dist/options.js +0 -45
  246. package/dist/spec/build.d.ts +0 -14
  247. package/dist/spec/build.js +0 -36
  248. package/dist/spec/buildDocument.d.ts +0 -15
  249. package/dist/spec/buildDocument.js +0 -268
  250. package/dist/spec/components.d.ts +0 -44
  251. package/dist/spec/components.js +0 -265
  252. package/dist/spec/downconvert.js +0 -74
  253. package/dist/spec/entitySchemas.d.ts +0 -15
  254. package/dist/spec/entitySchemas.js +0 -250
  255. package/dist/spec/fields.js +0 -44
  256. package/dist/spec/filters.d.ts +0 -11
  257. package/dist/spec/filters.js +0 -83
  258. package/dist/spec/names.js +0 -37
  259. package/dist/spec/params.d.ts +0 -55
  260. package/dist/spec/params.js +0 -436
  261. package/dist/spec/paths/auth.d.ts +0 -9
  262. package/dist/spec/paths/auth.js +0 -274
  263. package/dist/spec/paths/collections.d.ts +0 -9
  264. package/dist/spec/paths/collections.js +0 -278
  265. package/dist/spec/paths/custom.d.ts +0 -9
  266. package/dist/spec/paths/custom.js +0 -41
  267. package/dist/spec/paths/globals.d.ts +0 -9
  268. package/dist/spec/paths/globals.js +0 -78
  269. package/dist/spec/paths/jobs.d.ts +0 -7
  270. package/dist/spec/paths/jobs.js +0 -130
  271. package/dist/spec/paths/versions.d.ts +0 -19
  272. package/dist/spec/paths/versions.js +0 -252
  273. package/dist/spec/security.d.ts +0 -19
  274. package/dist/spec/security.js +0 -96
  275. package/dist/spec/tags.d.ts +0 -27
  276. package/dist/spec/tags.js +0 -79
  277. package/dist/translations/index.d.ts +0 -6
  278. package/dist/translations/locales/ar.d.ts +0 -2
  279. package/dist/translations/locales/ar.js +0 -81
  280. package/dist/translations/locales/az.d.ts +0 -2
  281. package/dist/translations/locales/az.js +0 -81
  282. package/dist/translations/locales/bg.d.ts +0 -2
  283. package/dist/translations/locales/bg.js +0 -81
  284. package/dist/translations/locales/bnBd.d.ts +0 -2
  285. package/dist/translations/locales/bnBd.js +0 -81
  286. package/dist/translations/locales/bnIn.d.ts +0 -2
  287. package/dist/translations/locales/bnIn.js +0 -81
  288. package/dist/translations/locales/ca.d.ts +0 -2
  289. package/dist/translations/locales/ca.js +0 -81
  290. package/dist/translations/locales/cs.d.ts +0 -2
  291. package/dist/translations/locales/cs.js +0 -81
  292. package/dist/translations/locales/da.d.ts +0 -2
  293. package/dist/translations/locales/da.js +0 -81
  294. package/dist/translations/locales/de.d.ts +0 -2
  295. package/dist/translations/locales/de.js +0 -81
  296. package/dist/translations/locales/en.d.ts +0 -2
  297. package/dist/translations/locales/en.js +0 -81
  298. package/dist/translations/locales/es.d.ts +0 -2
  299. package/dist/translations/locales/es.js +0 -81
  300. package/dist/translations/locales/et.d.ts +0 -2
  301. package/dist/translations/locales/et.js +0 -81
  302. package/dist/translations/locales/fa.d.ts +0 -2
  303. package/dist/translations/locales/fa.js +0 -81
  304. package/dist/translations/locales/fr.d.ts +0 -2
  305. package/dist/translations/locales/fr.js +0 -81
  306. package/dist/translations/locales/he.d.ts +0 -2
  307. package/dist/translations/locales/he.js +0 -81
  308. package/dist/translations/locales/hr.d.ts +0 -2
  309. package/dist/translations/locales/hr.js +0 -81
  310. package/dist/translations/locales/hu.d.ts +0 -2
  311. package/dist/translations/locales/hu.js +0 -81
  312. package/dist/translations/locales/hy.d.ts +0 -2
  313. package/dist/translations/locales/hy.js +0 -81
  314. package/dist/translations/locales/id.d.ts +0 -2
  315. package/dist/translations/locales/id.js +0 -81
  316. package/dist/translations/locales/is.d.ts +0 -2
  317. package/dist/translations/locales/is.js +0 -81
  318. package/dist/translations/locales/it.d.ts +0 -2
  319. package/dist/translations/locales/it.js +0 -81
  320. package/dist/translations/locales/ja.d.ts +0 -2
  321. package/dist/translations/locales/ja.js +0 -81
  322. package/dist/translations/locales/ko.d.ts +0 -2
  323. package/dist/translations/locales/ko.js +0 -81
  324. package/dist/translations/locales/lt.d.ts +0 -2
  325. package/dist/translations/locales/lt.js +0 -81
  326. package/dist/translations/locales/lv.d.ts +0 -2
  327. package/dist/translations/locales/lv.js +0 -81
  328. package/dist/translations/locales/my.d.ts +0 -2
  329. package/dist/translations/locales/my.js +0 -81
  330. package/dist/translations/locales/nb.d.ts +0 -2
  331. package/dist/translations/locales/nb.js +0 -81
  332. package/dist/translations/locales/nl.d.ts +0 -2
  333. package/dist/translations/locales/nl.js +0 -81
  334. package/dist/translations/locales/pl.d.ts +0 -2
  335. package/dist/translations/locales/pl.js +0 -81
  336. package/dist/translations/locales/pt.d.ts +0 -2
  337. package/dist/translations/locales/pt.js +0 -81
  338. package/dist/translations/locales/ro.d.ts +0 -2
  339. package/dist/translations/locales/ro.js +0 -81
  340. package/dist/translations/locales/rs.d.ts +0 -2
  341. package/dist/translations/locales/rs.js +0 -81
  342. package/dist/translations/locales/rsLatin.d.ts +0 -2
  343. package/dist/translations/locales/rsLatin.js +0 -81
  344. package/dist/translations/locales/ru.d.ts +0 -2
  345. package/dist/translations/locales/ru.js +0 -81
  346. package/dist/translations/locales/sk.d.ts +0 -2
  347. package/dist/translations/locales/sk.js +0 -81
  348. package/dist/translations/locales/sl.d.ts +0 -2
  349. package/dist/translations/locales/sl.js +0 -81
  350. package/dist/translations/locales/sv.d.ts +0 -2
  351. package/dist/translations/locales/sv.js +0 -81
  352. package/dist/translations/locales/ta.d.ts +0 -2
  353. package/dist/translations/locales/ta.js +0 -81
  354. package/dist/translations/locales/th.d.ts +0 -2
  355. package/dist/translations/locales/th.js +0 -81
  356. package/dist/translations/locales/tr.d.ts +0 -2
  357. package/dist/translations/locales/tr.js +0 -81
  358. package/dist/translations/locales/uk.d.ts +0 -2
  359. package/dist/translations/locales/uk.js +0 -81
  360. package/dist/translations/locales/vi.d.ts +0 -2
  361. package/dist/translations/locales/vi.js +0 -81
  362. package/dist/translations/locales/zh.d.ts +0 -2
  363. package/dist/translations/locales/zh.js +0 -81
  364. package/dist/translations/locales/zhTw.d.ts +0 -2
  365. package/dist/translations/locales/zhTw.js +0 -81
  366. package/dist/translations/types.d.ts +0 -87
  367. package/dist/translations/types.js +0 -1
  368. package/dist/types.d.ts +0 -192
  369. package/dist/types.js +0 -1
  370. package/dist/ui/createUiPlugin.d.ts +0 -14
  371. package/dist/ui/createUiPlugin.js +0 -28
  372. package/dist/ui/html.js +0 -8
  373. package/dist/ui/scalar.d.ts +0 -1
  374. package/dist/ui/scalar.js +0 -12
  375. package/dist/ui/swagger.d.ts +0 -1
  376. package/dist/ui/swagger.js +0 -12
  377. package/dist/utils.js +0 -13
@@ -0,0 +1,394 @@
1
+ import { joinsSchemaName, populateSchemaName, querySchemaName, refTo, selectSchemaName } from "./names.js";
2
+ import { makeT } from "../../shared/translations/index.js";
3
+ import { exposableFields } from "./fields.js";
4
+ const fieldName = (field) => "name" in field && typeof field.name === "string" ? field.name : void 0;
5
+ const relationTargets = (field) => {
6
+ if (field.type !== "relationship" && field.type !== "upload") return [];
7
+ const relTo = field.relationTo;
8
+ return Array.isArray(relTo) ? relTo : [relTo];
9
+ };
10
+ const buildSelectSchema = ({ fields, ctx }) => {
11
+ const properties = {};
12
+ for (const field of exposableFields(fields)) {
13
+ const name = fieldName(field);
14
+ if (name) properties[name] = { type: "boolean" };
15
+ }
16
+ return {
17
+ type: "object",
18
+ additionalProperties: false,
19
+ description: makeT(ctx.i18n)("schemaSelect"),
20
+ properties
21
+ };
22
+ };
23
+ const buildPopulateSchema = ({ fields, ctx }) => {
24
+ const targets = /* @__PURE__ */ new Set();
25
+ for (const field of exposableFields(fields)) for (const target of relationTargets(field)) targets.add(target);
26
+ if (targets.size === 0) return void 0;
27
+ const properties = {};
28
+ for (const target of targets) properties[target] = {
29
+ type: "object",
30
+ additionalProperties: { type: "boolean" }
31
+ };
32
+ return {
33
+ type: "object",
34
+ additionalProperties: false,
35
+ description: makeT(ctx.i18n)("schemaPopulate"),
36
+ properties
37
+ };
38
+ };
39
+ const buildJoinsSchema = ({ fields, ctx }) => {
40
+ const joinControls = {
41
+ type: "object",
42
+ additionalProperties: false,
43
+ properties: {
44
+ limit: { type: "integer" },
45
+ page: { type: "integer" },
46
+ sort: { type: "string" },
47
+ count: { type: "boolean" },
48
+ where: {
49
+ type: "object",
50
+ additionalProperties: true
51
+ }
52
+ }
53
+ };
54
+ const properties = {};
55
+ for (const field of exposableFields(fields)) {
56
+ if (field.type !== "join") continue;
57
+ const name = fieldName(field);
58
+ if (name) properties[name] = joinControls;
59
+ }
60
+ if (Object.keys(properties).length === 0) return void 0;
61
+ return {
62
+ type: "object",
63
+ additionalProperties: false,
64
+ description: makeT(ctx.i18n)("schemaJoins"),
65
+ properties
66
+ };
67
+ };
68
+ const buildParamSchemas = ({ fields, ctx }) => ({
69
+ select: buildSelectSchema({
70
+ fields,
71
+ ctx
72
+ }),
73
+ populate: buildPopulateSchema({
74
+ fields,
75
+ ctx
76
+ }),
77
+ joins: buildJoinsSchema({
78
+ fields,
79
+ ctx
80
+ })
81
+ });
82
+ const OPERATORS_BY_TYPE = {
83
+ text: [
84
+ "equals",
85
+ "not_equals",
86
+ "like",
87
+ "contains",
88
+ "in",
89
+ "not_in",
90
+ "exists"
91
+ ],
92
+ textarea: [
93
+ "equals",
94
+ "not_equals",
95
+ "like",
96
+ "contains",
97
+ "in",
98
+ "not_in",
99
+ "exists"
100
+ ],
101
+ email: [
102
+ "equals",
103
+ "not_equals",
104
+ "like",
105
+ "contains",
106
+ "in",
107
+ "not_in",
108
+ "exists"
109
+ ],
110
+ code: [
111
+ "equals",
112
+ "not_equals",
113
+ "like",
114
+ "contains",
115
+ "exists"
116
+ ],
117
+ number: [
118
+ "equals",
119
+ "not_equals",
120
+ "greater_than",
121
+ "greater_than_equal",
122
+ "less_than",
123
+ "less_than_equal",
124
+ "in",
125
+ "not_in",
126
+ "exists"
127
+ ],
128
+ date: [
129
+ "equals",
130
+ "not_equals",
131
+ "greater_than",
132
+ "greater_than_equal",
133
+ "less_than",
134
+ "less_than_equal",
135
+ "exists"
136
+ ],
137
+ checkbox: [
138
+ "equals",
139
+ "not_equals",
140
+ "exists"
141
+ ],
142
+ radio: [
143
+ "equals",
144
+ "not_equals",
145
+ "in",
146
+ "not_in",
147
+ "exists"
148
+ ],
149
+ select: [
150
+ "equals",
151
+ "not_equals",
152
+ "in",
153
+ "not_in",
154
+ "exists"
155
+ ],
156
+ relationship: [
157
+ "equals",
158
+ "not_equals",
159
+ "in",
160
+ "not_in",
161
+ "exists"
162
+ ],
163
+ upload: [
164
+ "equals",
165
+ "not_equals",
166
+ "in",
167
+ "not_in",
168
+ "exists"
169
+ ]
170
+ };
171
+ const fieldHasQueryOperators = (field) => Boolean(OPERATORS_BY_TYPE[field.type]);
172
+ const collectionHasFilters = (fields) => exposableFields(fields).some((f) => fieldName(f) && fieldHasQueryOperators(f));
173
+ const buildQueryOperationsSchema = ({ base, fields, ctx }) => {
174
+ const properties = {};
175
+ for (const field of exposableFields(fields)) {
176
+ const name = fieldName(field);
177
+ const operators = OPERATORS_BY_TYPE[field.type];
178
+ if (!name || !operators) continue;
179
+ properties[name] = {
180
+ type: "object",
181
+ additionalProperties: false,
182
+ properties: Object.fromEntries(operators.map((op) => [op, {}]))
183
+ };
184
+ }
185
+ const selfRef = { $ref: refTo(querySchemaName(base)) };
186
+ properties.and = {
187
+ type: "array",
188
+ items: selfRef
189
+ };
190
+ properties.or = {
191
+ type: "array",
192
+ items: selfRef
193
+ };
194
+ return {
195
+ type: "object",
196
+ additionalProperties: false,
197
+ description: makeT(ctx.i18n)("schemaWhere"),
198
+ properties
199
+ };
200
+ };
201
+ const objectParam = (name, ref) => ({
202
+ name,
203
+ in: "query",
204
+ content: { "application/json": { schema: ref ? { $ref: ref } : {
205
+ type: "object",
206
+ additionalProperties: true
207
+ } } }
208
+ });
209
+ const localeParam = (ctx) => ({
210
+ name: "locale",
211
+ in: "query",
212
+ description: makeT(ctx.i18n)("paramLocale"),
213
+ schema: ctx.locales.length > 0 ? {
214
+ type: "string",
215
+ enum: [...ctx.locales, "all"]
216
+ } : { type: "string" }
217
+ });
218
+ const fallbackLocaleParam = (ctx) => ({
219
+ name: "fallback-locale",
220
+ in: "query",
221
+ description: makeT(ctx.i18n)("paramFallbackLocale"),
222
+ schema: ctx.locales.length > 0 ? {
223
+ type: "string",
224
+ enum: [...ctx.locales, "none"]
225
+ } : { type: "string" }
226
+ });
227
+ const commonReadParams = ({ base, ctx, refs }) => {
228
+ const params = [
229
+ {
230
+ name: "depth",
231
+ in: "query",
232
+ description: makeT(ctx.i18n)("paramDepth"),
233
+ schema: { type: "integer" }
234
+ },
235
+ localeParam(ctx),
236
+ fallbackLocaleParam(ctx),
237
+ objectParam("select", refs.select ? refTo(selectSchemaName(base)) : void 0),
238
+ {
239
+ name: "flattenLocales",
240
+ in: "query",
241
+ description: makeT(ctx.i18n)("paramFlattenLocales"),
242
+ schema: { type: "boolean" }
243
+ },
244
+ {
245
+ name: "draft",
246
+ in: "query",
247
+ description: makeT(ctx.i18n)("paramDraft"),
248
+ schema: { type: "boolean" }
249
+ },
250
+ {
251
+ name: "trash",
252
+ in: "query",
253
+ description: makeT(ctx.i18n)("paramTrash"),
254
+ schema: { type: "boolean" }
255
+ }
256
+ ];
257
+ if (refs.populate) params.push(objectParam("populate", refTo(populateSchemaName(base))));
258
+ if (refs.joins) params.push(objectParam("joins", refTo(joinsSchemaName(base))));
259
+ return params;
260
+ };
261
+ const SHARED = [
262
+ "depth",
263
+ "locale",
264
+ "fallback-locale",
265
+ "select",
266
+ "populate"
267
+ ];
268
+ const ALL_LOCALES = ["publishAllLocales", "unpublishAllLocales"];
269
+ const WRITE_PARAMS = {
270
+ create: /* @__PURE__ */ new Set([
271
+ ...SHARED,
272
+ "draft",
273
+ "autosave",
274
+ "publishAllLocales"
275
+ ]),
276
+ update: /* @__PURE__ */ new Set([
277
+ ...SHARED,
278
+ "draft",
279
+ "trash",
280
+ "overrideLock",
281
+ ...ALL_LOCALES
282
+ ]),
283
+ updateByID: /* @__PURE__ */ new Set([
284
+ ...SHARED,
285
+ "draft",
286
+ "trash",
287
+ "autosave",
288
+ "overrideLock",
289
+ ...ALL_LOCALES
290
+ ]),
291
+ delete: /* @__PURE__ */ new Set([
292
+ ...SHARED,
293
+ "trash",
294
+ "overrideLock"
295
+ ]),
296
+ duplicate: /* @__PURE__ */ new Set([
297
+ ...SHARED,
298
+ "draft",
299
+ "selectedLocales[]"
300
+ ]),
301
+ globalUpdate: /* @__PURE__ */ new Set([
302
+ ...SHARED,
303
+ "draft",
304
+ "autosave",
305
+ ...ALL_LOCALES
306
+ ])
307
+ };
308
+ const entityWriteParams = (entity, ctx) => {
309
+ const t = makeT(ctx.i18n);
310
+ const flag = (name, key) => ({
311
+ name,
312
+ in: "query",
313
+ description: t(key),
314
+ schema: { type: "boolean" }
315
+ });
316
+ const drafts = entity.versions ? entity.versions.drafts : false;
317
+ const params = [];
318
+ if (drafts && drafts.autosave) params.push(flag("autosave", "paramAutosave"));
319
+ if (drafts && drafts.localizeStatus) {
320
+ params.push(flag("publishAllLocales", "paramPublishAllLocales"));
321
+ params.push(flag("unpublishAllLocales", "paramUnpublishAllLocales"));
322
+ }
323
+ if (entity.lockDocuments !== false) params.push(flag("overrideLock", "paramOverrideLock"));
324
+ if (ctx.locales.length > 0) params.push({
325
+ name: "selectedLocales[]",
326
+ in: "query",
327
+ description: t("paramSelectedLocales"),
328
+ style: "form",
329
+ explode: true,
330
+ schema: {
331
+ type: "array",
332
+ items: {
333
+ type: "string",
334
+ enum: ctx.locales
335
+ }
336
+ }
337
+ });
338
+ return params;
339
+ };
340
+ const writeParams = ({ base, entity, ctx, refs, operation }) => [...commonReadParams({
341
+ base,
342
+ ctx,
343
+ refs
344
+ }), ...entityWriteParams(entity, ctx)].filter((p) => WRITE_PARAMS[operation].has(p.name));
345
+ const validateParams = (ctx) => ctx.locales.length > 0 ? [{
346
+ name: "locale",
347
+ in: "query",
348
+ description: makeT(ctx.i18n)("paramValidateLocale"),
349
+ style: "form",
350
+ explode: true,
351
+ schema: {
352
+ type: "array",
353
+ items: {
354
+ type: "string",
355
+ enum: [...ctx.locales, "all"]
356
+ }
357
+ }
358
+ }] : [];
359
+ const whereParam = (base) => objectParam("where", refTo(querySchemaName(base)));
360
+ const buildListParams = ({ base, fields, ctx, refs }) => {
361
+ const params = [
362
+ {
363
+ name: "page",
364
+ in: "query",
365
+ schema: { type: "integer" }
366
+ },
367
+ {
368
+ name: "limit",
369
+ in: "query",
370
+ schema: { type: "integer" }
371
+ },
372
+ {
373
+ name: "pagination",
374
+ in: "query",
375
+ schema: { type: "boolean" }
376
+ },
377
+ {
378
+ name: "sort",
379
+ in: "query",
380
+ description: makeT(ctx.i18n)("paramSort"),
381
+ schema: { type: "string" }
382
+ },
383
+ ...commonReadParams({
384
+ base,
385
+ ctx,
386
+ refs
387
+ })
388
+ ];
389
+ if (collectionHasFilters(fields)) params.push(whereParam(base));
390
+ return params;
391
+ };
392
+ export { buildJoinsSchema, buildListParams, buildParamSchemas, buildPopulateSchema, buildQueryOperationsSchema, buildSelectSchema, collectionHasFilters, commonReadParams, validateParams, whereParam, writeParams };
393
+
394
+ //# sourceMappingURL=params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.js","names":[],"sources":["../../../src/server/spec/params.ts"],"sourcesContent":["import type { ParameterObject, ReferenceObject, SchemaObject } from '@scalar/openapi-types/3.2'\nimport type { Field } from 'payload'\n\nimport { makeT } from '@/shared/translations/index.js'\nimport type { BuildContext, Entity } from '@/shared/types/index.js'\n\nimport { exposableFields } from './fields.js'\nimport { joinsSchemaName, populateSchemaName, querySchemaName, refTo, selectSchemaName } from './names.js'\n\nconst fieldName = (field: Field): string | undefined =>\n 'name' in field && typeof field.name === 'string' ? field.name : undefined\n\nconst relationTargets = (field: Field): string[] => {\n if (field.type !== 'relationship' && field.type !== 'upload') return []\n const relTo = (field as { relationTo: string | string[] }).relationTo\n return Array.isArray(relTo) ? relTo : [relTo]\n}\n\nexport const buildSelectSchema = ({ fields, ctx }: { fields: Field[]; ctx: BuildContext }): SchemaObject => {\n const properties: Record<string, SchemaObject> = {}\n for (const field of exposableFields(fields)) {\n const name = fieldName(field)\n if (name) properties[name] = { type: 'boolean' }\n }\n return {\n type: 'object',\n additionalProperties: false,\n description: makeT(ctx.i18n)('schemaSelect'),\n properties,\n }\n}\n\nexport const buildPopulateSchema = ({\n fields,\n ctx,\n}: {\n fields: Field[]\n ctx: BuildContext\n}): SchemaObject | undefined => {\n const targets = new Set<string>()\n for (const field of exposableFields(fields)) {\n for (const target of relationTargets(field)) targets.add(target)\n }\n if (targets.size === 0) return undefined\n\n const properties: Record<string, SchemaObject> = {}\n for (const target of targets) {\n properties[target] = { type: 'object', additionalProperties: { type: 'boolean' } }\n }\n return {\n type: 'object',\n additionalProperties: false,\n description: makeT(ctx.i18n)('schemaPopulate'),\n properties,\n }\n}\n\nexport const buildJoinsSchema = ({ fields, ctx }: { fields: Field[]; ctx: BuildContext }): SchemaObject | undefined => {\n const joinControls: SchemaObject = {\n type: 'object',\n additionalProperties: false,\n properties: {\n limit: { type: 'integer' },\n page: { type: 'integer' },\n sort: { type: 'string' },\n count: { type: 'boolean' },\n where: { type: 'object', additionalProperties: true },\n },\n }\n\n const properties: Record<string, SchemaObject> = {}\n for (const field of exposableFields(fields)) {\n if (field.type !== 'join') continue\n const name = fieldName(field)\n if (name) properties[name] = joinControls\n }\n if (Object.keys(properties).length === 0) return undefined\n return {\n type: 'object',\n additionalProperties: false,\n description: makeT(ctx.i18n)('schemaJoins'),\n properties,\n }\n}\n\nexport interface ParamSchemas {\n select: SchemaObject\n populate?: SchemaObject\n joins?: SchemaObject\n}\n\nexport const buildParamSchemas = ({ fields, ctx }: { fields: Field[]; ctx: BuildContext }): ParamSchemas => ({\n select: buildSelectSchema({ fields, ctx }),\n populate: buildPopulateSchema({ fields, ctx }),\n joins: buildJoinsSchema({ fields, ctx }),\n})\n\nconst OPERATORS_BY_TYPE: Record<string, string[]> = {\n text: ['equals', 'not_equals', 'like', 'contains', 'in', 'not_in', 'exists'],\n textarea: ['equals', 'not_equals', 'like', 'contains', 'in', 'not_in', 'exists'],\n email: ['equals', 'not_equals', 'like', 'contains', 'in', 'not_in', 'exists'],\n code: ['equals', 'not_equals', 'like', 'contains', 'exists'],\n number: [\n 'equals',\n 'not_equals',\n 'greater_than',\n 'greater_than_equal',\n 'less_than',\n 'less_than_equal',\n 'in',\n 'not_in',\n 'exists',\n ],\n date: ['equals', 'not_equals', 'greater_than', 'greater_than_equal', 'less_than', 'less_than_equal', 'exists'],\n checkbox: ['equals', 'not_equals', 'exists'],\n radio: ['equals', 'not_equals', 'in', 'not_in', 'exists'],\n select: ['equals', 'not_equals', 'in', 'not_in', 'exists'],\n relationship: ['equals', 'not_equals', 'in', 'not_in', 'exists'],\n upload: ['equals', 'not_equals', 'in', 'not_in', 'exists'],\n}\n\nconst fieldHasQueryOperators = (field: Field): boolean => Boolean(OPERATORS_BY_TYPE[field.type])\n\nexport const collectionHasFilters = (fields: Field[]): boolean =>\n exposableFields(fields).some((f) => fieldName(f) && fieldHasQueryOperators(f))\n\nexport const buildQueryOperationsSchema = ({\n base,\n fields,\n ctx,\n}: {\n base: string\n fields: Field[]\n ctx: BuildContext\n}): SchemaObject => {\n const properties: Record<string, SchemaObject> = {}\n\n for (const field of exposableFields(fields)) {\n const name = fieldName(field)\n const operators = OPERATORS_BY_TYPE[field.type]\n if (!name || !operators) continue\n properties[name] = {\n type: 'object',\n additionalProperties: false,\n properties: Object.fromEntries(operators.map((op) => [op, {}])),\n }\n }\n\n const selfRef: ReferenceObject = { $ref: refTo(querySchemaName(base)) }\n properties.and = { type: 'array', items: selfRef }\n properties.or = { type: 'array', items: selfRef }\n\n return {\n type: 'object',\n additionalProperties: false,\n description: makeT(ctx.i18n)('schemaWhere'),\n properties,\n }\n}\n\nexport interface ReadParamRefs {\n select: boolean\n populate: boolean\n joins: boolean\n}\n\nconst objectParam = (name: string, ref?: string): ParameterObject => ({\n name,\n in: 'query',\n content: {\n 'application/json': {\n schema: ref ? { $ref: ref } : { type: 'object', additionalProperties: true },\n },\n },\n})\n\nconst localeParam = (ctx: BuildContext): ParameterObject => ({\n name: 'locale',\n in: 'query',\n description: makeT(ctx.i18n)('paramLocale'),\n schema: ctx.locales.length > 0 ? { type: 'string', enum: [...ctx.locales, 'all'] } : { type: 'string' },\n})\n\nconst fallbackLocaleParam = (ctx: BuildContext): ParameterObject => ({\n name: 'fallback-locale',\n in: 'query',\n description: makeT(ctx.i18n)('paramFallbackLocale'),\n schema: ctx.locales.length > 0 ? { type: 'string', enum: [...ctx.locales, 'none'] } : { type: 'string' },\n})\n\nexport const commonReadParams = ({\n base,\n ctx,\n refs,\n}: {\n base: string\n ctx: BuildContext\n refs: ReadParamRefs\n}): ParameterObject[] => {\n const params: ParameterObject[] = [\n {\n name: 'depth',\n in: 'query',\n description: makeT(ctx.i18n)('paramDepth'),\n schema: { type: 'integer' },\n },\n localeParam(ctx),\n fallbackLocaleParam(ctx),\n objectParam('select', refs.select ? refTo(selectSchemaName(base)) : undefined),\n {\n name: 'flattenLocales',\n in: 'query',\n description: makeT(ctx.i18n)('paramFlattenLocales'),\n schema: { type: 'boolean' },\n },\n { name: 'draft', in: 'query', description: makeT(ctx.i18n)('paramDraft'), schema: { type: 'boolean' } },\n { name: 'trash', in: 'query', description: makeT(ctx.i18n)('paramTrash'), schema: { type: 'boolean' } },\n ]\n\n if (refs.populate) {\n params.push(objectParam('populate', refTo(populateSchemaName(base))))\n }\n if (refs.joins) {\n params.push(objectParam('joins', refTo(joinsSchemaName(base))))\n }\n\n return params\n}\n\nexport type WriteOperation = 'create' | 'update' | 'updateByID' | 'delete' | 'duplicate' | 'globalUpdate'\n\nconst SHARED = ['depth', 'locale', 'fallback-locale', 'select', 'populate']\nconst ALL_LOCALES = ['publishAllLocales', 'unpublishAllLocales']\n\nconst WRITE_PARAMS: Record<WriteOperation, Set<string>> = {\n create: new Set([...SHARED, 'draft', 'autosave', 'publishAllLocales']),\n update: new Set([...SHARED, 'draft', 'trash', 'overrideLock', ...ALL_LOCALES]),\n updateByID: new Set([...SHARED, 'draft', 'trash', 'autosave', 'overrideLock', ...ALL_LOCALES]),\n delete: new Set([...SHARED, 'trash', 'overrideLock']),\n duplicate: new Set([...SHARED, 'draft', 'selectedLocales[]']),\n globalUpdate: new Set([...SHARED, 'draft', 'autosave', ...ALL_LOCALES]),\n}\n\nconst entityWriteParams = (entity: Entity, ctx: BuildContext): ParameterObject[] => {\n const t = makeT(ctx.i18n)\n const flag = (name: string, key: Parameters<typeof t>[0]): ParameterObject => ({\n name,\n in: 'query',\n description: t(key),\n schema: { type: 'boolean' },\n })\n const drafts = entity.versions ? entity.versions.drafts : false\n const params: ParameterObject[] = []\n if (drafts && drafts.autosave) params.push(flag('autosave', 'paramAutosave'))\n if (drafts && drafts.localizeStatus) {\n params.push(flag('publishAllLocales', 'paramPublishAllLocales'))\n params.push(flag('unpublishAllLocales', 'paramUnpublishAllLocales'))\n }\n if (entity.lockDocuments !== false) params.push(flag('overrideLock', 'paramOverrideLock'))\n if (ctx.locales.length > 0) {\n params.push({\n name: 'selectedLocales[]',\n in: 'query',\n description: t('paramSelectedLocales'),\n style: 'form',\n explode: true,\n schema: { type: 'array', items: { type: 'string', enum: ctx.locales } },\n })\n }\n return params\n}\n\nexport const writeParams = ({\n base,\n entity,\n ctx,\n refs,\n operation,\n}: {\n base: string\n entity: Entity\n ctx: BuildContext\n refs: ReadParamRefs\n operation: WriteOperation\n}): ParameterObject[] =>\n [...commonReadParams({ base, ctx, refs }), ...entityWriteParams(entity, ctx)].filter((p) =>\n WRITE_PARAMS[operation].has(p.name),\n )\n\nexport const validateParams = (ctx: BuildContext): ParameterObject[] =>\n ctx.locales.length > 0\n ? [\n {\n name: 'locale',\n in: 'query',\n description: makeT(ctx.i18n)('paramValidateLocale'),\n style: 'form',\n explode: true,\n schema: { type: 'array', items: { type: 'string', enum: [...ctx.locales, 'all'] } },\n },\n ]\n : []\n\nexport const whereParam = (base: string): ParameterObject => objectParam('where', refTo(querySchemaName(base)))\n\nexport const buildListParams = ({\n base,\n fields,\n ctx,\n refs,\n}: {\n base: string\n fields: Field[]\n ctx: BuildContext\n refs: ReadParamRefs\n}): ParameterObject[] => {\n const params: ParameterObject[] = [\n { name: 'page', in: 'query', schema: { type: 'integer' } },\n { name: 'limit', in: 'query', schema: { type: 'integer' } },\n { name: 'pagination', in: 'query', schema: { type: 'boolean' } },\n {\n name: 'sort',\n in: 'query',\n description: makeT(ctx.i18n)('paramSort'),\n schema: { type: 'string' },\n },\n ...commonReadParams({ base, ctx, refs }),\n ]\n\n if (collectionHasFilters(fields)) {\n params.push(whereParam(base))\n }\n\n return params\n}\n"],"mappings":";;;AASA,MAAM,aAAa,UACjB,UAAU,SAAS,OAAO,MAAM,SAAS,WAAW,MAAM,OAAO,KAAA;AAEnE,MAAM,mBAAmB,UAA2B;CAClD,IAAI,MAAM,SAAS,kBAAkB,MAAM,SAAS,UAAU,OAAO,CA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AC,qBAAqB;CAClD,OAAO;CACP,SAAS;CACT,QAAQ;EAAE,MAAM;EAAS,OAAO;GAAE,MAAM;GAAU,MAAM,CAAC,GAAG,IAAI,SAAS,KAAK;EAAE;CAAE;AACpF,CACF,IACA,CAAC;AAEP,MAAa,cAAc,SAAkC,YAAY,SAAS,MAAM,gBAAgB,IAAI,CAAC,CAAC;AAE9G,MAAa,mBAAmB,EAC9B,MACA,QACA,KACA,WAMuB;CACvB,MAAM,SAA4B;EAChC;GAAE,MAAM;GAAQ,IAAI;GAAS,QAAQ,EAAE,MAAM,UAAU;EAAE;EACzD;GAAE,MAAM;GAAS,IAAI;GAAS,QAAQ,EAAE,MAAM,UAAU;EAAE;EAC1D;GAAE,MAAM;GAAc,IAAI;GAAS,QAAQ,EAAE,MAAM,UAAU;EAAE;EAC/D;GACE,MAAM;GACN,IAAI;GACJ,aAAa,MAAM,IAAI,IAAI,CAAC,CAAC,WAAW;GACxC,QAAQ,EAAE,MAAM,SAAS;EAC3B;EACA,GAAG,iBAAiB;GAAE;GAAM;GAAK;EAAK,CAAC;CACzC;CAEA,IAAI,qBAAqB,MAAM,GAC7B,OAAO,KAAK,WAAW,IAAI,CAAC;CAG9B,OAAO;AACT"}
@@ -0,0 +1,10 @@
1
+ import { BuildContext } from "../../../shared/types/index.js";
2
+ import { SanitizedCollectionConfig } from "payload";
3
+ import { PathsObject } from "@scalar/openapi-types/3.2";
4
+ export declare const buildAuthPaths: ({ collection, ctx, includeAdmin, nestedTags }: {
5
+ collection: SanitizedCollectionConfig;
6
+ ctx: BuildContext;
7
+ includeAdmin: boolean;
8
+ nestedTags: boolean;
9
+ }) => PathsObject;
10
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1,190 @@
1
+ import { refTo, schemaName } from "../names.js";
2
+ import { ERRORS, SECURITY_SCHEME_NAME, errorResponses, jsonBody, jsonResponse, messageResponse } from "../components.js";
3
+ import { authTagName } from "../tags.js";
4
+ import { makeT } from "../../../shared/translations/index.js";
5
+ const LOCAL_STRATEGY_ROUTES = [
6
+ "login",
7
+ "forgot-password",
8
+ "reset-password",
9
+ "first-register",
10
+ "unlock",
11
+ "verify/{id}"
12
+ ];
13
+ const identifierBody = (auth, extra = {}) => {
14
+ const email = {
15
+ type: "string",
16
+ format: "email"
17
+ };
18
+ const username = { type: "string" };
19
+ const extraRequired = Object.keys(extra);
20
+ const loginWithUsername = auth?.loginWithUsername;
21
+ const base = {
22
+ type: "object",
23
+ additionalProperties: false
24
+ };
25
+ if (!loginWithUsername) return {
26
+ ...base,
27
+ properties: {
28
+ email,
29
+ ...extra
30
+ },
31
+ required: ["email", ...extraRequired]
32
+ };
33
+ if (typeof loginWithUsername === "object" && loginWithUsername.allowEmailLogin) return {
34
+ ...base,
35
+ properties: {
36
+ email,
37
+ username,
38
+ ...extra
39
+ },
40
+ ...extraRequired.length > 0 ? { required: extraRequired } : {},
41
+ anyOf: [{ required: ["email"] }, { required: ["username"] }]
42
+ };
43
+ return {
44
+ ...base,
45
+ properties: {
46
+ username,
47
+ ...extra
48
+ },
49
+ required: ["username", ...extraRequired]
50
+ };
51
+ };
52
+ const buildAuthPaths = ({ collection, ctx, includeAdmin, nestedTags }) => {
53
+ const auth = collection.auth;
54
+ if (!auth) return {};
55
+ const t = makeT(ctx.i18n);
56
+ const name = schemaName(collection.slug);
57
+ const base = `${ctx.apiRoute}/${collection.slug}`;
58
+ const tag = [nestedTags ? authTagName(name) : name];
59
+ const userRef = { $ref: refTo(name) };
60
+ const op = (operationId, codes, extra) => ({
61
+ tags: tag,
62
+ operationId,
63
+ ...extra,
64
+ responses: {
65
+ ...extra.responses,
66
+ ...errorResponses(codes, t)
67
+ }
68
+ });
69
+ const paths = {
70
+ [`${base}/login`]: { post: op(`login${name}`, ERRORS.login, {
71
+ requestBody: jsonBody(identifierBody(auth, { password: { type: "string" } })),
72
+ responses: { "200": jsonResponse(t("authLogin"), {
73
+ type: "object",
74
+ properties: {
75
+ message: { type: "string" },
76
+ user: userRef,
77
+ token: { type: "string" },
78
+ exp: { type: "integer" }
79
+ }
80
+ }) }
81
+ }) },
82
+ [`${base}/logout`]: { post: op(`logout${name}`, ERRORS.session, { responses: messageResponse(t("authLogout")) }) },
83
+ [`${base}/me`]: { get: op(`me${name}`, ERRORS.session, { responses: { "200": jsonResponse(t("authMe"), {
84
+ type: "object",
85
+ properties: {
86
+ user: userRef,
87
+ collection: { type: "string" },
88
+ token: { type: "string" },
89
+ exp: { type: "integer" }
90
+ }
91
+ }) } }) },
92
+ [`${base}/refresh-token`]: { post: op(`refreshToken${name}`, ERRORS.session, { responses: { "200": jsonResponse(t("authRefreshToken"), {
93
+ type: "object",
94
+ properties: {
95
+ message: { type: "string" },
96
+ refreshedToken: { type: "string" },
97
+ exp: { type: "integer" },
98
+ user: userRef
99
+ }
100
+ }) } }) },
101
+ [`${base}/forgot-password`]: { post: op(`forgotPassword${name}`, ERRORS.authAction, {
102
+ requestBody: jsonBody(identifierBody(auth)),
103
+ responses: messageResponse(t("authForgotPassword"))
104
+ }) },
105
+ [`${base}/reset-password`]: { post: op(`resetPassword${name}`, ERRORS.authAction, {
106
+ requestBody: jsonBody({
107
+ type: "object",
108
+ additionalProperties: false,
109
+ properties: {
110
+ token: { type: "string" },
111
+ password: { type: "string" }
112
+ },
113
+ required: ["token", "password"]
114
+ }),
115
+ responses: { "200": jsonResponse(t("authResetPassword"), {
116
+ type: "object",
117
+ properties: {
118
+ message: { type: "string" },
119
+ token: { type: "string" },
120
+ user: userRef
121
+ }
122
+ }) }
123
+ }) }
124
+ };
125
+ if (includeAdmin) {
126
+ paths[`${base}/first-register`] = { post: op(`firstRegister${name}`, ERRORS.create, {
127
+ requestBody: jsonBody({ $ref: refTo(`${name}Create`) }),
128
+ responses: { "200": jsonResponse(t("authFirstRegister"), {
129
+ type: "object",
130
+ properties: {
131
+ message: { type: "string" },
132
+ user: userRef,
133
+ token: { type: "string" },
134
+ exp: { type: "integer" }
135
+ }
136
+ }) }
137
+ }) };
138
+ paths[`${base}/init`] = { get: op(`init${name}`, ERRORS.session, { responses: { "200": jsonResponse(t("authInit"), {
139
+ type: "object",
140
+ properties: { initialized: { type: "boolean" } }
141
+ }) } }) };
142
+ }
143
+ paths[`${base}/unlock`] = { post: op(`unlock${name}`, ERRORS.authAction, {
144
+ requestBody: jsonBody(identifierBody(auth)),
145
+ responses: messageResponse(t("authUnlock"))
146
+ }) };
147
+ if (auth.verify) paths[`${base}/verify/{id}`] = { post: op(`verify${name}`, ERRORS.authAction, {
148
+ parameters: [{
149
+ name: "id",
150
+ in: "path",
151
+ required: true,
152
+ schema: { type: "string" }
153
+ }],
154
+ responses: messageResponse(t("authVerify"))
155
+ }) };
156
+ if (auth.disableLocalStrategy) for (const route of LOCAL_STRATEGY_ROUTES) delete paths[`${base}/${route}`];
157
+ if (typeof auth.useAPIKey === "object" && auth.useAPIKey.reveal === true) {
158
+ const errorBody = (description) => jsonResponse(description, {
159
+ type: "object",
160
+ properties: { error: { type: "string" } }
161
+ });
162
+ paths[`${base}/{id}/api-key/reveal`] = {
163
+ parameters: [{
164
+ name: "id",
165
+ in: "path",
166
+ required: true,
167
+ schema: { type: ctx.defaultIDType === "number" ? "integer" : "string" }
168
+ }],
169
+ post: {
170
+ tags: tag,
171
+ operationId: `revealApiKey${name}`,
172
+ responses: {
173
+ "200": jsonResponse(t("apiKeyReveal"), {
174
+ type: "object",
175
+ properties: { apiKey: { type: "string" } },
176
+ required: ["apiKey"]
177
+ }),
178
+ "403": errorBody(t("error403")),
179
+ "404": errorBody(t("error404")),
180
+ ...errorResponses(["500"], t)
181
+ },
182
+ security: [{ [SECURITY_SCHEME_NAME]: [] }]
183
+ }
184
+ };
185
+ }
186
+ return paths;
187
+ };
188
+ export { buildAuthPaths };
189
+
190
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","names":[],"sources":["../../../../src/server/spec/paths/auth.ts"],"sourcesContent":["import type {\n OperationObject,\n PathsObject,\n ReferenceObject,\n ResponsesObject,\n SchemaObject,\n} from '@scalar/openapi-types/3.2'\nimport type { SanitizedCollectionConfig } from 'payload'\n\nimport {\n ERRORS,\n type ErrorCode,\n SECURITY_SCHEME_NAME,\n errorResponses,\n jsonBody,\n jsonResponse,\n messageResponse,\n} from '@/server/spec/components.js'\nimport { refTo, schemaName } from '@/server/spec/names.js'\nimport { authTagName } from '@/server/spec/tags.js'\nimport { makeT } from '@/shared/translations/index.js'\nimport type { BuildContext } from '@/shared/types/index.js'\n\nconst LOCAL_STRATEGY_ROUTES = ['login', 'forgot-password', 'reset-password', 'first-register', 'unlock', 'verify/{id}']\n\nconst identifierBody = (\n auth: SanitizedCollectionConfig['auth'],\n extra: Record<string, SchemaObject> = {},\n): SchemaObject => {\n const email: SchemaObject = { type: 'string', format: 'email' }\n const username: SchemaObject = { type: 'string' }\n const extraRequired = Object.keys(extra)\n const loginWithUsername = auth?.loginWithUsername\n const base = { type: 'object', additionalProperties: false } as const\n\n if (!loginWithUsername) {\n return { ...base, properties: { email, ...extra }, required: ['email', ...extraRequired] }\n }\n if (typeof loginWithUsername === 'object' && loginWithUsername.allowEmailLogin) {\n return {\n ...base,\n properties: { email, username, ...extra },\n ...(extraRequired.length > 0 ? { required: extraRequired } : {}),\n anyOf: [{ required: ['email'] }, { required: ['username'] }],\n }\n }\n return { ...base, properties: { username, ...extra }, required: ['username', ...extraRequired] }\n}\n\nexport const buildAuthPaths = ({\n collection,\n ctx,\n includeAdmin,\n nestedTags,\n}: {\n collection: SanitizedCollectionConfig\n ctx: BuildContext\n includeAdmin: boolean\n nestedTags: boolean\n}): PathsObject => {\n const auth = collection.auth\n if (!auth) return {}\n\n const t = makeT(ctx.i18n)\n const name = schemaName(collection.slug)\n const base = `${ctx.apiRoute}/${collection.slug}`\n const tag = [nestedTags ? authTagName(name) : name]\n const userRef: ReferenceObject = { $ref: refTo(name) }\n\n const op = (\n operationId: string,\n codes: ErrorCode[],\n extra: Omit<OperationObject, 'tags' | 'operationId'> & { responses: ResponsesObject },\n ): OperationObject => ({\n tags: tag,\n operationId,\n ...extra,\n responses: { ...extra.responses, ...errorResponses(codes, t) },\n })\n\n const paths: PathsObject = {\n [`${base}/login`]: {\n post: op(`login${name}`, ERRORS.login, {\n requestBody: jsonBody(identifierBody(auth, { password: { type: 'string' } })),\n responses: {\n '200': jsonResponse(t('authLogin'), {\n type: 'object',\n properties: {\n message: { type: 'string' },\n user: userRef,\n token: { type: 'string' },\n exp: { type: 'integer' },\n },\n }),\n },\n }),\n },\n [`${base}/logout`]: {\n post: op(`logout${name}`, ERRORS.session, { responses: messageResponse(t('authLogout')) }),\n },\n [`${base}/me`]: {\n get: op(`me${name}`, ERRORS.session, {\n responses: {\n '200': jsonResponse(t('authMe'), {\n type: 'object',\n properties: {\n user: userRef,\n collection: { type: 'string' },\n token: { type: 'string' },\n exp: { type: 'integer' },\n },\n }),\n },\n }),\n },\n [`${base}/refresh-token`]: {\n post: op(`refreshToken${name}`, ERRORS.session, {\n responses: {\n '200': jsonResponse(t('authRefreshToken'), {\n type: 'object',\n properties: {\n message: { type: 'string' },\n refreshedToken: { type: 'string' },\n exp: { type: 'integer' },\n user: userRef,\n },\n }),\n },\n }),\n },\n [`${base}/forgot-password`]: {\n post: op(`forgotPassword${name}`, ERRORS.authAction, {\n requestBody: jsonBody(identifierBody(auth)),\n responses: messageResponse(t('authForgotPassword')),\n }),\n },\n [`${base}/reset-password`]: {\n post: op(`resetPassword${name}`, ERRORS.authAction, {\n requestBody: jsonBody({\n type: 'object',\n additionalProperties: false,\n properties: { token: { type: 'string' }, password: { type: 'string' } },\n required: ['token', 'password'],\n }),\n responses: {\n '200': jsonResponse(t('authResetPassword'), {\n type: 'object',\n properties: {\n message: { type: 'string' },\n token: { type: 'string' },\n user: userRef,\n },\n }),\n },\n }),\n },\n }\n\n if (includeAdmin) {\n paths[`${base}/first-register`] = {\n post: op(`firstRegister${name}`, ERRORS.create, {\n requestBody: jsonBody({ $ref: refTo(`${name}Create`) } as SchemaObject),\n responses: {\n '200': jsonResponse(t('authFirstRegister'), {\n type: 'object',\n properties: {\n message: { type: 'string' },\n user: userRef,\n token: { type: 'string' },\n exp: { type: 'integer' },\n },\n }),\n },\n }),\n }\n paths[`${base}/init`] = {\n get: op(`init${name}`, ERRORS.session, {\n responses: {\n '200': jsonResponse(t('authInit'), {\n type: 'object',\n properties: { initialized: { type: 'boolean' } },\n }),\n },\n }),\n }\n }\n\n paths[`${base}/unlock`] = {\n post: op(`unlock${name}`, ERRORS.authAction, {\n requestBody: jsonBody(identifierBody(auth)),\n responses: messageResponse(t('authUnlock')),\n }),\n }\n\n if (auth.verify) {\n paths[`${base}/verify/{id}`] = {\n post: op(`verify${name}`, ERRORS.authAction, {\n parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],\n responses: messageResponse(t('authVerify')),\n }),\n }\n }\n\n if (auth.disableLocalStrategy) {\n for (const route of LOCAL_STRATEGY_ROUTES) delete paths[`${base}/${route}`]\n }\n\n if (typeof auth.useAPIKey === 'object' && auth.useAPIKey.reveal === true) {\n const errorBody = (description: string) =>\n jsonResponse(description, { type: 'object', properties: { error: { type: 'string' } } })\n paths[`${base}/{id}/api-key/reveal`] = {\n parameters: [\n {\n name: 'id',\n in: 'path',\n required: true,\n schema: { type: ctx.defaultIDType === 'number' ? 'integer' : 'string' },\n },\n ],\n post: {\n tags: tag,\n operationId: `revealApiKey${name}`,\n responses: {\n '200': jsonResponse(t('apiKeyReveal'), {\n type: 'object',\n properties: { apiKey: { type: 'string' } },\n required: ['apiKey'],\n }),\n '403': errorBody(t('error403')),\n '404': errorBody(t('error404')),\n ...errorResponses(['500'], t),\n },\n security: [{ [SECURITY_SCHEME_NAME]: [] }],\n },\n }\n }\n\n return paths\n}\n"],"mappings":";;;;AAuBA,MAAM,wBAAwB;CAAC;CAAS;CAAmB;CAAkB;CAAkB;CAAU;AAAa;AAEtH,MAAM,kBACJ,MACA,QAAsC,CAAC,MACtB;CACjB,MAAM,QAAsB;EAAE,MAAM;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AU;GAAM,QAAQ,EAAE,MAAM,SAAS;EAAE,CAAC;EACnF,WAAW,gBAAgB,EAAE,YAAY,CAAC;CAC5C,CAAC,EACH;CAGF,IAAI,KAAK,sBACP,KAAK,MAAM,SAAS,uBAAuB,OAAO,MAAM,GAAG,KAAK,GAAG;CAGrE,IAAI,OAAO,KAAK,cAAc,YAAY,KAAK,UAAU,WAAW,MAAM;EACxE,MAAM,aAAa,gBACjB,aAAa,aAAa;GAAE,MAAM;GAAU,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,EAAE;EAAE,CAAC;EACzF,MAAM,GAAG,KAAK,yBAAyB;GACrC,YAAY,CACV;IACE,MAAM;IACN,IAAI;IACJ,UAAU;IACV,QAAQ,EAAE,MAAM,IAAI,kBAAkB,WAAW,YAAY,SAAS;GACxE,CACF;GACA,MAAM;IACJ,MAAM;IACN,aAAa,eAAe;IAC5B,WAAW;KACT,OAAO,aAAa,EAAE,cAAc,GAAG;MACrC,MAAM;MACN,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,EAAE;MACzC,UAAU,CAAC,QAAQ;KACrB,CAAC;KACD,OAAO,UAAU,EAAE,UAAU,CAAC;KAC9B,OAAO,UAAU,EAAE,UAAU,CAAC;KAC9B,GAAG,eAAe,CAAC,KAAK,GAAG,CAAC;IAC9B;IACA,UAAU,CAAC,GAAG,uBAAuB,CAAC,EAAE,CAAC;GAC3C;EACF;CACF;CAEA,OAAO;AACT"}
@@ -0,0 +1,11 @@
1
+ import { BuildContext } from "../../../shared/types/index.js";
2
+ import { EntitySecurity } from "../security.js";
3
+ import { SanitizedCollectionConfig } from "payload";
4
+ import { PathsObject } from "@scalar/openapi-types/3.2";
5
+ export declare const buildCollectionPaths: ({ collection, ctx, security, access }: {
6
+ collection: SanitizedCollectionConfig;
7
+ ctx: BuildContext;
8
+ security?: EntitySecurity;
9
+ access?: boolean;
10
+ }) => PathsObject;
11
+ //# sourceMappingURL=collections.d.ts.map