@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,397 @@
1
+ import { BasePayload, PayloadRequest, SanitizedCollectionConfig, SanitizedGlobalConfig } from "payload";
2
+ import { I18n } from "@payloadcms/translations";
3
+ import { ComponentsObject, Document, InfoObject, PathsObject, SecurityRequirementObject, ServerObject, TagObject } from "@scalar/openapi-types/3.2";
4
+ export type OpenApiVersion = '3.0' | '3.1' | '3.2';
5
+ export type EntityKind = 'collection' | 'global';
6
+ export type OperationKind = EntityKind | 'custom' | 'jobs' | 'system';
7
+ export type HttpMethod = 'get' | 'post' | 'patch' | 'put' | 'delete';
8
+ export type IDType = 'text' | 'number';
9
+ export type Entity = SanitizedCollectionConfig | SanitizedGlobalConfig;
10
+ export type EntityOperation = 'read' | 'create' | 'update' | 'delete' | 'validate';
11
+ export type SecurityMarking = 'public' | 'secured';
12
+ /**
13
+ * Marking for a collection or global, set in its `custom.openapi.security`:
14
+ * one marking for every operation, or one per operation. Operations you leave
15
+ * out keep the marking the access probe found. `read` also marks the version
16
+ * reads. `validate` falls back to `update` when you leave it out.
17
+ */
18
+ export type EntitySecurityOverride = SecurityMarking | Partial<Record<EntityOperation, SecurityMarking>>;
19
+ /**
20
+ * Text that follows the request language: a string, a map of language to
21
+ * string (`{ en: '…', de: '…' }`), or a function that gets `{ t, i18n }`.
22
+ */
23
+ export type LocalizedText = string | Record<string, string> | ((args: {
24
+ t: (key: string, vars?: Record<string, unknown>) => string;
25
+ i18n: I18n;
26
+ }) => string);
27
+ /** `custom.openapi` on a collection or global. */
28
+ export interface EntityOpenApiMeta {
29
+ /** Overrides the public or secured marking. See {@link EntitySecurityOverride}. */
30
+ security?: EntitySecurityOverride;
31
+ }
32
+ /**
33
+ * `custom.openapi` on a field: a partial Schema Object deep-merged on top of
34
+ * the inferred one. `description`, `title` and `summary` follow the
35
+ * request language.
36
+ */
37
+ export interface FieldOpenApiMeta {
38
+ description?: LocalizedText;
39
+ title?: LocalizedText;
40
+ summary?: LocalizedText;
41
+ [keyword: string]: unknown;
42
+ }
43
+ declare module 'payload' {
44
+ interface CollectionCustom {
45
+ openapi?: EntityOpenApiMeta;
46
+ }
47
+ interface GlobalCustom {
48
+ openapi?: EntityOpenApiMeta;
49
+ }
50
+ interface FieldCustom {
51
+ openapi?: FieldOpenApiMeta;
52
+ }
53
+ }
54
+ /**
55
+ * The OpenAPI `info` object. `title` and `version` are required. `description`
56
+ * can follow the request language, see {@link LocalizedText}.
57
+ */
58
+ export type OpenApiInfo = Omit<InfoObject, 'description'> & {
59
+ description?: LocalizedText;
60
+ };
61
+ /**
62
+ * Base URLs for the spec's `servers`: a fixed list, or a function that gets
63
+ * the request.
64
+ */
65
+ export type ServersOption = ServerObject[] | ((args: {
66
+ req: PayloadRequest;
67
+ }) => ServerObject[] | Promise<ServerObject[]>);
68
+ /**
69
+ * Interactive "Authorize" login for the docs UI. When on, the plugin adds a
70
+ * token endpoint and a security scheme so Scalar/Swagger can log in with a
71
+ * username and password instead of pasting a token. Off by default.
72
+ * - `true` — on, at the default path, against the first auth collection.
73
+ * - `{ path, collection }` — on, with a custom token endpoint path or auth collection.
74
+ */
75
+ export type InteractiveAuthOption = boolean | {
76
+ /**
77
+ * Token endpoint path, relative to the API route (`/openapi-auth` → `/api/openapi-auth`).
78
+ * @default '/openapi-auth'
79
+ */
80
+ path?: string;
81
+ /**
82
+ * Auth collection the login runs against.
83
+ * @default the first collection with `auth` enabled, or `'users'`
84
+ */
85
+ collection?: string;
86
+ };
87
+ /**
88
+ * Gate for a plugin route. Return `true` to serve the request; anything else
89
+ * answers 403.
90
+ */
91
+ export type AccessOption = (args: {
92
+ req: PayloadRequest;
93
+ }) => boolean | Promise<boolean>;
94
+ /** Match an entity by slug (any kind), a {kind,slug} pair, or a slug pattern. */
95
+ export type EntityMatcher = string | RegExp | {
96
+ kind: EntityKind;
97
+ slug: string;
98
+ };
99
+ /**
100
+ * Drops generated operations. Within one rule, every set field must match (AND);
101
+ * an operation is removed if any rule matches it. Fields:
102
+ * - `method` — HTTP method(s); omit to match any.
103
+ * - `slug` — collection or global slug, exact string or RegExp; omit to match any.
104
+ * A rule with `slug` never matches custom, jobs or system operations.
105
+ * - `kind` — restrict to one operation group; omit to match all.
106
+ * - `path` — RegExp tested against the final route path (e.g. `/api/posts/{id}`).
107
+ */
108
+ export interface OperationRule {
109
+ method?: HttpMethod | HttpMethod[];
110
+ slug?: string | RegExp;
111
+ kind?: OperationKind;
112
+ path?: RegExp;
113
+ }
114
+ /** Context passed to `excludeOperations` functions and `security` for each operation. */
115
+ export interface OperationContext {
116
+ method: HttpMethod;
117
+ path: string;
118
+ /** Collection or global slug. Unset for custom, jobs and system operations. */
119
+ slug?: string;
120
+ kind: OperationKind;
121
+ }
122
+ /** A rule, or a function that drops the operation when it returns (or resolves to) `true`. */
123
+ export type OperationFilter = OperationRule | ((ctx: OperationContext) => boolean | Promise<boolean>);
124
+ type SecurityDecision = SecurityMarking | SecurityRequirementObject[] | undefined;
125
+ /**
126
+ * Decides the security marking of one operation. `'public'` removes it,
127
+ * `'secured'` sets the default requirement, an array sets that exact
128
+ * requirement, and `undefined` keeps `detected`.
129
+ */
130
+ export type SecurityOption = (ctx: OperationContext & {
131
+ detected: SecurityMarking;
132
+ }) => SecurityDecision | Promise<SecurityDecision>;
133
+ /**
134
+ * Controls what appears in the spec, in one flat object: which entities are
135
+ * documented, which Payload-internal collections to show, which extra endpoint
136
+ * groups to generate, and which operations to drop.
137
+ */
138
+ export interface FilterOptions {
139
+ /**
140
+ * Allowlist of entities; when non-empty, only matching entities are documented.
141
+ * @default []
142
+ */
143
+ include?: EntityMatcher[];
144
+ /**
145
+ * Entities to omit entirely (schemas + paths).
146
+ * @default []
147
+ */
148
+ exclude?: EntityMatcher[];
149
+ /**
150
+ * Include collections flagged `hidden`/`admin.hidden`.
151
+ * @default false
152
+ */
153
+ includeHidden?: boolean;
154
+ /**
155
+ * Include Payload-internal collections and globals (payload-jobs, payload-preferences, payload-jobs-stats, ...).
156
+ * @default false
157
+ */
158
+ includeSystem?: boolean;
159
+ /**
160
+ * Document endpoints carrying `custom.openapi` metadata.
161
+ * @default true
162
+ */
163
+ includeCustom?: boolean;
164
+ /**
165
+ * Document auth operation endpoints (login/logout/me/...).
166
+ * @default true
167
+ */
168
+ includeAuth?: boolean;
169
+ /**
170
+ * Document admin/bootstrap auth endpoints (/init, first-register, root /access) and the document access endpoints (/{slug}/access/{id}, /globals/{slug}/access).
171
+ * @default false
172
+ */
173
+ includeAdminAuth?: boolean;
174
+ /**
175
+ * Document version operation endpoints (/versions, /versions/{id}).
176
+ * @default true
177
+ */
178
+ includeVersions?: boolean;
179
+ /**
180
+ * Document jobs endpoints (/payload-jobs/run, /handle-schedules).
181
+ * @default true
182
+ */
183
+ includeJobs?: boolean;
184
+ /**
185
+ * Drops operations from every group: collection, global, custom, jobs and
186
+ * system. An operation is removed when any rule matches it or any function
187
+ * returns `true`.
188
+ * @default []
189
+ */
190
+ excludeOperations?: OperationFilter[];
191
+ }
192
+ export interface OpenApiExtension {
193
+ /** Paths deep-merged into the generated ones. */
194
+ paths?: PathsObject;
195
+ /** Components deep-merged into the generated ones. */
196
+ components?: ComponentsObject;
197
+ /** Tags appended to the list; a tag whose name already exists is skipped. */
198
+ tags?: TagObject[];
199
+ /**
200
+ * Runs on the finished document and returns the document to use. Gets one
201
+ * object: `doc` plus the {@link ExtensionContext}, e.g. `({ doc, payload }) => doc`.
202
+ * It can be `async`. If it throws, the spec request fails: the plugin never
203
+ * serves a document that skipped a transform.
204
+ */
205
+ transform?: (args: ExtensionContext) => Document | Promise<Document>;
206
+ }
207
+ /** What `extensions[].transform` gets: the finished document and the build context. */
208
+ export type ExtensionContext = BuildContext & {
209
+ doc: Document;
210
+ payload: BasePayload;
211
+ options: ResolvedOptions;
212
+ };
213
+ export type OpenApiPluginOptions = {
214
+ /** The document's `info` object. `title` and `version` are required. See {@link OpenApiInfo}. */
215
+ info: OpenApiInfo;
216
+ /**
217
+ * OpenAPI version to serve. The document is always built as 3.2; `3.1` and
218
+ * `3.0` each run a downconversion pass on the result.
219
+ * @default '3.2'
220
+ */
221
+ openapiVersion?: OpenApiVersion;
222
+ /**
223
+ * Where the spec is served, relative to the Payload API route (`routes.api`,
224
+ * `/api` by default). So the `/openapi.json` default is served at
225
+ * `/api/openapi.json`.
226
+ * @default '/openapi.json'
227
+ */
228
+ path?: string;
229
+ /**
230
+ * Set false to turn the plugin off. It then adds no endpoints, no CLI command
231
+ * and no translations. The plugin adds no collections, so the schema stays the same.
232
+ * @default true
233
+ */
234
+ enabled?: boolean;
235
+ /**
236
+ * Mount the runtime spec (and interactive-auth) endpoints. Set false to
237
+ * register only the `openapi:generate` CLI command and skip serving over
238
+ * HTTP — generate the spec to a file and host it however you like (static
239
+ * asset, CDN, committed to the repo). Point the docs UI plugins' `specURL`
240
+ * at wherever the file ends up.
241
+ * @default true
242
+ */
243
+ serve?: boolean;
244
+ /**
245
+ * Who may read the spec endpoint. Runs on every request.
246
+ * @default open to everyone
247
+ */
248
+ access?: AccessOption;
249
+ /**
250
+ * The spec's `servers`. A function runs on every request. See {@link ServersOption}.
251
+ * @default `[{ url: serverURL }]` when the Payload `serverURL` is set, otherwise `[]` (clients use the spec's own origin)
252
+ */
253
+ servers?: ServersOption;
254
+ /**
255
+ * Hosts the spec may echo back as its server URL. When the request `Host`
256
+ * header (`host` or `host:port`) is on this list, `servers` is
257
+ * `https://<host>` (`http` for localhost and 127.*). The `Host` header comes from
258
+ * the client, so the plugin never uses it unless you list it here. A
259
+ * `servers` option wins over this list.
260
+ * @default []
261
+ */
262
+ trustedHosts?: string[];
263
+ /** What appears in the spec. See {@link FilterOptions}. */
264
+ filters?: FilterOptions;
265
+ /**
266
+ * Interactive docs-UI login. See {@link InteractiveAuthOption}.
267
+ * @default false
268
+ */
269
+ interactiveAuth?: InteractiveAuthOption;
270
+ /**
271
+ * Emit an OpenAPI 3.2 nested tag hierarchy (nav groups via `kind`/`parent`,
272
+ * plus per-entity auth/version sub-tags). Off by default: Scalar and Swagger UI
273
+ * don't render 3.2 nested tags yet and would show a confusing flat list of group
274
+ * names. When off, `doc.tags` is a flat list of per-entity tags with their
275
+ * descriptions.
276
+ * @default false
277
+ */
278
+ nestedTags?: boolean;
279
+ /**
280
+ * Override the security marking per operation. Runs last, after
281
+ * `custom.openapi.security` and the access probe, across every operation
282
+ * group. See {@link SecurityOption}.
283
+ */
284
+ security?: SecurityOption;
285
+ /**
286
+ * Cache the built document for the life of the process. The Payload config is
287
+ * static after boot, so the spec is the same every time apart from
288
+ * `servers`, which is set per request. Set false in dev to rebuild on
289
+ * every request, e.g. `cache: process.env.NODE_ENV === 'production'`.
290
+ * @default true
291
+ */
292
+ cache?: boolean;
293
+ /**
294
+ * Extra paths, components and tags merged into the document, plus a final `transform`.
295
+ * @default []
296
+ */
297
+ extensions?: OpenApiExtension[];
298
+ /**
299
+ * Anonymous usage telemetry: plugin, Payload and Node versions and the features in use. On by default.
300
+ * It never sends secrets, IP addresses, keys, URLs, paths, hostnames or collection names.
301
+ * The first run logs a notice.
302
+ *
303
+ * Off when `payload.config.telemetry` is `false`, when `DO_NOT_TRACK` or `OPENAPI_TELEMETRY_DISABLED`
304
+ * is set, in CI or with `NODE_ENV=test`. Set `false` to turn it off. Pass `{ url }` to use your own collector.
305
+ *
306
+ * @see https://payload-plugin-openapi.seshuk.im/v1/configuration/telemetry
307
+ * @default true
308
+ */
309
+ telemetry?: boolean | {
310
+ /**
311
+ * Collector URL that receives the telemetry report.
312
+ * @default the plugin's public collector
313
+ */
314
+ url?: string;
315
+ };
316
+ };
317
+ export interface UiPluginOptions {
318
+ /**
319
+ * Where the docs UI is served, relative to the Payload API route
320
+ * (`routes.api`, `/api` by default). So the `/docs` default is served at
321
+ * `/api/docs`.
322
+ * @default '/docs'
323
+ */
324
+ path?: string;
325
+ /**
326
+ * URL the UI fetches the OpenAPI document from. Any URL reference works:
327
+ * absolute, root-relative, or relative to the docs page.
328
+ * @default the `openapi()` spec route, `<apiRoute>/openapi.json` unless its `path` is set
329
+ */
330
+ specURL?: string;
331
+ /**
332
+ * Where the UI's assets load from: the script URL for Scalar, the folder with
333
+ * `swagger-ui-bundle.js` and `swagger-ui.css` for Swagger UI. Set it to
334
+ * self-host the assets. The default URL is pinned to one version and loads
335
+ * with Subresource Integrity; a custom URL loads without it.
336
+ * @default the pinned jsDelivr URL
337
+ */
338
+ cdnBase?: string;
339
+ /**
340
+ * Extra UI config, merged into the underlying library's init options (Scalar's
341
+ * `createApiReference` config or Swagger UI's `SwaggerUIBundle`). Must be
342
+ * JSON-serializable, functions aren't supported here.
343
+ * @default {}
344
+ */
345
+ configuration?: Record<string, unknown>;
346
+ /**
347
+ * Who may open the docs page. Runs on every request.
348
+ * @default open to everyone
349
+ */
350
+ access?: AccessOption;
351
+ /**
352
+ * Set false to skip mounting the docs UI.
353
+ * @default true
354
+ */
355
+ enabled?: boolean;
356
+ }
357
+ export interface ResolvedFilters {
358
+ include: EntityMatcher[];
359
+ exclude: EntityMatcher[];
360
+ includeHidden: boolean;
361
+ includeSystem: boolean;
362
+ includeCustom: boolean;
363
+ includeAuth: boolean;
364
+ includeAdminAuth: boolean;
365
+ includeVersions: boolean;
366
+ includeJobs: boolean;
367
+ excludeOperations: OperationFilter[];
368
+ }
369
+ export interface ResolvedOptions {
370
+ info: OpenApiInfo;
371
+ openapiVersion: OpenApiVersion;
372
+ path: string;
373
+ serve: boolean;
374
+ access?: AccessOption;
375
+ servers?: ServersOption;
376
+ trustedHosts: string[];
377
+ filters: ResolvedFilters;
378
+ interactiveAuth: {
379
+ enabled: boolean;
380
+ path: string;
381
+ collection?: string;
382
+ };
383
+ nestedTags: boolean;
384
+ security?: SecurityOption;
385
+ cache: boolean;
386
+ extensions: OpenApiExtension[];
387
+ }
388
+ export interface BuildContext {
389
+ defaultIDType: IDType;
390
+ locales: string[];
391
+ apiRoute: string;
392
+ /** Languages the docs are available in (project `i18n.supportedLanguages`). */
393
+ docLanguages: string[];
394
+ /** Request i18n: resolves Payload entity descriptions and, via {@link makeT}, plugin strings. */
395
+ i18n: I18n;
396
+ }
397
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
1
  export declare const upperFirst: (value: string) => string;
2
2
  export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
3
3
  export declare const deepMerge: (a: Record<string, unknown>, b: Record<string, unknown>) => Record<string, unknown>;
4
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,13 @@
1
+ const upperFirst = (value) => value.length === 0 ? value : value[0].toUpperCase() + value.slice(1);
2
+ const isPlainObject = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
3
+ const deepMerge = (a, b) => {
4
+ const out = { ...a };
5
+ for (const [key, value] of Object.entries(b)) {
6
+ const prev = out[key];
7
+ out[key] = isPlainObject(prev) && isPlainObject(value) ? deepMerge(prev, value) : value;
8
+ }
9
+ return out;
10
+ };
11
+ export { deepMerge, isPlainObject, upperFirst };
12
+
13
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../src/shared/utils.ts"],"sourcesContent":["export const upperFirst = (value: string): string =>\n value.length === 0 ? value : value[0]!.toUpperCase() + value.slice(1)\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n\nexport const deepMerge = (a: Record<string, unknown>, b: Record<string, unknown>): Record<string, unknown> => {\n const out = { ...a }\n for (const [key, value] of Object.entries(b)) {\n const prev = out[key]\n out[key] = isPlainObject(prev) && isPlainObject(value) ? deepMerge(prev, value) : value\n }\n return out\n}\n"],"mappings":"AAAA,MAAa,cAAc,UACzB,MAAM,WAAW,IAAI,QAAQ,MAAM,EAAE,CAAE,YAAY,IAAI,MAAM,MAAM,CAAC;AAEtE,MAAa,iBAAiB,UAC5B,QAAQ,KAAK,KAAK,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAa,aAAa,GAA4B,MAAwD;CAC5G,MAAM,MAAM,EAAE,GAAG,EAAE;CACnB,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,CAAC,GAAG;EAC5C,MAAM,OAAO,IAAI;EACjB,IAAI,OAAO,cAAc,IAAI,KAAK,cAAc,KAAK,IAAI,UAAU,MAAM,KAAK,IAAI;CACpF;CACA,OAAO;AACT"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@seshuk/payload-plugin-openapi",
3
- "version": "0.2.1",
4
- "description": "OpenAPI 3.0/3.1/3.2 spec generator for Payload CMS, with Scalar/Swagger UI.",
3
+ "version": "1.0.0-beta.1",
4
+ "description": "OpenAPI 3.0/3.1/3.2 spec generator for Payload, with Scalar/Swagger UI.",
5
5
  "keywords": [
6
6
  "api-docs",
7
7
  "cms",
@@ -23,77 +23,88 @@
23
23
  "type": "git",
24
24
  "url": "git+https://github.com/maximseshuk/payload-plugin-openapi.git"
25
25
  },
26
- "funding": "https://ko-fi.com/V7V61UCT39",
26
+ "funding": {
27
+ "type": "ko-fi",
28
+ "url": "https://ko-fi.com/seshuk"
29
+ },
27
30
  "files": [
28
31
  "dist"
29
32
  ],
30
33
  "type": "module",
31
- "main": "./src/index.ts",
32
- "types": "./src/index.ts",
34
+ "main": "./dist/index.js",
35
+ "module": "./dist/index.js",
36
+ "types": "./dist/index.d.ts",
33
37
  "exports": {
34
38
  ".": {
35
- "import": "./src/index.ts",
36
- "types": "./src/index.ts",
37
- "default": "./src/index.ts"
38
- },
39
- "./*": "./*"
40
- },
41
- "publishConfig": {
42
- "main": "./dist/index.js",
43
- "types": "./dist/index.d.ts",
44
- "exports": {
45
- ".": {
46
- "import": "./dist/index.js",
47
- "types": "./dist/index.d.ts",
48
- "default": "./dist/index.js"
49
- }
39
+ "types": "./dist/index.d.ts",
40
+ "import": "./dist/index.js",
41
+ "default": "./dist/index.js"
50
42
  }
51
43
  },
52
- "scripts": {
53
- "build": "rslib build",
54
- "build:watch": "rslib build --watch",
55
- "dev": "cross-env PAYLOAD_CONFIG_PATH=./tests/payload.config.ts next dev tests --turbo",
56
- "dev:safe": "rm -rf .next && cross-env PAYLOAD_CONFIG_PATH=./tests/payload.config.ts next dev tests --turbo --port 3001",
57
- "dev:generate-importmap": "cd tests && cross-env PAYLOAD_CONFIG_PATH=./payload.config.ts payload generate:importmap",
58
- "docs:check-links": "pnpm --dir docs check-links",
59
- "docs:dev": "pnpm --dir docs dev",
60
- "docs:validate": "pnpm --dir docs validate",
61
- "lint": "oxlint src tests",
62
- "lint:fix": "oxlint src tests --fix",
63
- "format": "oxfmt .",
64
- "format:check": "oxfmt --check .",
65
- "test": "vitest run",
66
- "test:watch": "vitest",
67
- "typecheck": "tsc --noEmit",
68
- "release:patch": "pnpm version patch -m \"chore(release): v%s\"",
69
- "release:minor": "pnpm version minor -m \"chore(release): v%s\"",
70
- "release:major": "pnpm version major -m \"chore(release): v%s\""
44
+ "publishConfig": {
45
+ "access": "public",
46
+ "registry": "https://registry.npmjs.org/"
71
47
  },
72
48
  "dependencies": {
73
49
  "@scalar/openapi-types": "^0.9.1"
74
50
  },
75
51
  "devDependencies": {
76
- "@payloadcms/db-sqlite": "^3.85.1",
77
- "@payloadcms/next": "^3.85.1",
78
- "@payloadcms/translations": "^3.85.1",
79
- "@rslib/core": "^0.22.1",
52
+ "@payloadcms/db-sqlite": "4.0.0-canary.38",
53
+ "@payloadcms/next": "4.0.0-canary.38",
54
+ "@payloadcms/translations": "4.0.0-canary.38",
55
+ "@payloadcms/ui": "4.0.0-canary.38",
80
56
  "@seriousme/openapi-schema-validator": "^2.9.0",
57
+ "@seshuk/payload-plugin-tooling": "0.2.3",
58
+ "@types/node": "^26.1.2",
59
+ "@vitest/coverage-v8": "^5.0.3",
81
60
  "cross-env": "^10.1.0",
82
- "next": "^16.2.9",
83
- "oxfmt": "^0.54.0",
84
- "oxlint": "^1.69.0",
85
- "payload": "^3.85.1",
86
- "react": "^19.2.7",
87
- "react-dom": "^19.2.7",
88
- "typescript": "^6.0.3",
89
- "vite-tsconfig-paths": "7.0.0-alpha.1",
90
- "vitest": "^4.1.8"
61
+ "next": "16.4.0",
62
+ "oxfmt": "^0.71.0",
63
+ "oxlint": "^1.86.0",
64
+ "payload": "4.0.0-canary.38",
65
+ "react": "19.3.0",
66
+ "react-dom": "19.3.0",
67
+ "tsdown": "^0.23.0",
68
+ "typescript": "7.0.2",
69
+ "vitest": "^5.0.3"
91
70
  },
92
71
  "peerDependencies": {
93
- "@payloadcms/translations": "^3.53.0",
94
- "payload": "^3.53.0"
72
+ "@payloadcms/translations": "4.0.0-canary.38",
73
+ "payload": "4.0.0-canary.38"
74
+ },
75
+ "devEngines": {
76
+ "packageManager": {
77
+ "name": "pnpm",
78
+ "version": "^12.0.0",
79
+ "onFail": "warn"
80
+ },
81
+ "runtime": {
82
+ "name": "node",
83
+ "version": ">=24.15.0",
84
+ "onFail": "warn"
85
+ }
95
86
  },
96
87
  "engines": {
97
- "node": ">=20.9.0"
88
+ "node": ">=24.15.0"
89
+ },
90
+ "scripts": {
91
+ "build": "tsdown",
92
+ "build:watch": "tsdown --watch",
93
+ "dev": "cross-env PAYLOAD_CONFIG_PATH=./tests/payload.config.ts DATABASE_URL=file:./tests/payload.db next dev tests",
94
+ "dev:generate-importmap": "cd tests && cross-env PAYLOAD_CONFIG_PATH=./payload.config.ts payload generate:importmap",
95
+ "dev:safe": "rm -rf tests/.next && cross-env PAYLOAD_CONFIG_PATH=./tests/payload.config.ts DATABASE_URL=file:./tests/payload.db next dev tests --port 3001",
96
+ "docs:check-links": "pnpm --dir docs check-links",
97
+ "docs:dev": "pnpm --dir docs dev",
98
+ "docs:validate": "pnpm --dir docs validate",
99
+ "format": "oxfmt",
100
+ "format:check": "oxfmt --check",
101
+ "lint": "oxlint",
102
+ "lint:fix": "oxlint --fix",
103
+ "test": "vitest run -c tests/vitest.config.ts",
104
+ "test:coverage": "vitest run -c tests/vitest.config.ts --coverage",
105
+ "test:int": "vitest run -c tests/vitest.config.ts --project int",
106
+ "test:unit": "vitest run -c tests/vitest.config.ts --project unit",
107
+ "test:watch": "vitest -c tests/vitest.config.ts",
108
+ "typecheck": "tsc --noEmit"
98
109
  }
99
- }
110
+ }
@@ -1,25 +0,0 @@
1
- import type { SanitizedConfig } from 'payload';
2
- interface CliArgs {
3
- lang?: string;
4
- out?: string;
5
- server?: string;
6
- }
7
- export declare const parseArgs: (argv: string[]) => CliArgs;
8
- /**
9
- * Bin entrypoint registered automatically by the OpenAPI plugin. Reads resolved
10
- * plugin options from `config.custom[PLUGIN_NAME]` (stashed during config build),
11
- * then writes the OpenAPI document(s) to disk — no HTTP request required.
12
- *
13
- * Flags:
14
- * --lang <code|all> locale for translated descriptions; `all` writes one file
15
- * per supported language. Defaults to the i18n fallback.
16
- * --out <path> output file for a single-language run (default openapi.json).
17
- * --server <url> base URL written to the document's `servers`. The HTTP
18
- * endpoint derives this per request; on disk there's no
19
- * request, so pass it here or leave `servers` empty.
20
- *
21
- * Note: the spec reflects public-access marking only (no per-user access),
22
- * identical to the HTTP endpoint.
23
- */
24
- export declare const script: (config: SanitizedConfig) => Promise<void>;
25
- export {};
@@ -1,61 +0,0 @@
1
- import { writeFile } from "node:fs/promises";
2
- import node_path from "node:path";
3
- import { getPayload } from "payload";
4
- import { PLUGIN_NAME } from "../constants.js";
5
- import { buildOpenApiDocument } from "../spec/build.js";
6
- const parseArgs = (argv)=>{
7
- const args = {};
8
- for(let i = 0; i < argv.length; i++){
9
- const arg = argv[i];
10
- if (void 0 === arg) continue;
11
- const read = (key, flag)=>{
12
- if (arg === flag) {
13
- args[key] = argv[++i];
14
- return true;
15
- }
16
- if (arg.startsWith(`${flag}=`)) {
17
- args[key] = arg.slice(flag.length + 1);
18
- return true;
19
- }
20
- return false;
21
- };
22
- if (!read('lang', '--lang')) {
23
- if (!read('out', '--out')) read('server', '--server');
24
- }
25
- }
26
- return args;
27
- };
28
- const script = async (config)=>{
29
- const resolved = config.custom?.[PLUGIN_NAME];
30
- if (!resolved) throw new Error(`${PLUGIN_NAME}: plugin is not registered in payload.config — no resolved options found on config.custom['${PLUGIN_NAME}'].`);
31
- const payload = await getPayload({
32
- config
33
- });
34
- const { lang, out, server } = parseArgs(process.argv);
35
- const servers = server ? [
36
- {
37
- url: server
38
- }
39
- ] : void 0;
40
- const fallback = config.i18n?.fallbackLanguage ?? 'en';
41
- const supported = config.i18n?.supportedLanguages ? Object.keys(config.i18n.supportedLanguages) : [
42
- fallback
43
- ];
44
- const langs = 'all' === lang ? supported : [
45
- lang ?? fallback
46
- ];
47
- for (const language of langs){
48
- const doc = await buildOpenApiDocument({
49
- payload,
50
- options: resolved,
51
- language,
52
- servers
53
- });
54
- const file = langs.length > 1 ? `openapi.${language}.json` : out ?? 'openapi.json';
55
- await writeFile(node_path.resolve(file), `${JSON.stringify(doc, null, 2)}\n`);
56
- payload.logger.info(`Wrote ${file}`);
57
- }
58
- await payload.destroy();
59
- process.exit(0);
60
- };
61
- export { parseArgs, script };
@@ -1 +0,0 @@
1
- export declare const PLUGIN_NAME = "@seshuk/payload-plugin-openapi";
package/dist/constants.js DELETED
@@ -1,2 +0,0 @@
1
- const PLUGIN_NAME = '@seshuk/payload-plugin-openapi';
2
- export { PLUGIN_NAME };