@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
@@ -1,265 +0,0 @@
1
- import { refTo } from "./names.js";
2
- const nullableType = (type)=>({
3
- type: [
4
- type,
5
- 'null'
6
- ]
7
- });
8
- const jsonResponse = (description, schema)=>({
9
- description,
10
- content: {
11
- 'application/json': {
12
- schema
13
- }
14
- }
15
- });
16
- const jsonOk = (description, schema)=>({
17
- 200: jsonResponse(description, schema)
18
- });
19
- const jsonBody = (schema)=>({
20
- required: true,
21
- content: {
22
- 'application/json': {
23
- schema
24
- }
25
- }
26
- });
27
- const messageResponse = (description)=>jsonOk(description, {
28
- type: 'object',
29
- properties: {
30
- message: {
31
- type: 'string'
32
- }
33
- }
34
- });
35
- const ERROR_SCHEMA_NAME = 'ErrorResponse';
36
- const ERROR_KEYS = {
37
- 400: 'error400',
38
- 401: 'error401',
39
- 403: 'error403',
40
- 404: 'error404',
41
- 500: 'error500'
42
- };
43
- const ERRORS = {
44
- list: [
45
- '400',
46
- '403',
47
- '500'
48
- ],
49
- read: [
50
- '403',
51
- '404',
52
- '500'
53
- ],
54
- create: [
55
- '400',
56
- '403',
57
- '500'
58
- ],
59
- update: [
60
- '400',
61
- '403',
62
- '404',
63
- '500'
64
- ],
65
- delete: [
66
- '403',
67
- '404',
68
- '500'
69
- ],
70
- globalRead: [
71
- '403',
72
- '500'
73
- ],
74
- globalUpdate: [
75
- '400',
76
- '403',
77
- '500'
78
- ],
79
- login: [
80
- '400',
81
- '401',
82
- '403',
83
- '500'
84
- ],
85
- session: [
86
- '401',
87
- '500'
88
- ],
89
- authAction: [
90
- '400',
91
- '403',
92
- '500'
93
- ],
94
- versionList: [
95
- '400',
96
- '403',
97
- '404',
98
- '500'
99
- ],
100
- versionRead: [
101
- '403',
102
- '404',
103
- '500'
104
- ],
105
- versionRestore: [
106
- '403',
107
- '404',
108
- '500'
109
- ]
110
- };
111
- const buildErrorResponseSchema = ()=>({
112
- type: 'object',
113
- properties: {
114
- errors: {
115
- type: 'array',
116
- items: {
117
- type: 'object',
118
- properties: {
119
- message: {
120
- type: 'string'
121
- },
122
- name: {
123
- type: 'string'
124
- },
125
- field: {
126
- type: 'string'
127
- },
128
- data: {
129
- type: 'object',
130
- additionalProperties: true
131
- }
132
- },
133
- required: [
134
- 'message'
135
- ]
136
- }
137
- }
138
- },
139
- required: [
140
- 'errors'
141
- ]
142
- });
143
- const errorRef = {
144
- $ref: refTo(ERROR_SCHEMA_NAME)
145
- };
146
- const errorContent = (description)=>({
147
- description,
148
- content: {
149
- 'application/json': {
150
- schema: errorRef
151
- }
152
- }
153
- });
154
- const errorResponses = (codes, t)=>{
155
- const responses = {};
156
- for (const code of codes)responses[code] = errorContent(t(ERROR_KEYS[code]));
157
- return responses;
158
- };
159
- const buildListEnvelopeSchema = (base)=>({
160
- type: 'object',
161
- properties: {
162
- docs: {
163
- type: 'array',
164
- items: {
165
- $ref: refTo(base)
166
- }
167
- },
168
- totalDocs: {
169
- type: 'integer'
170
- },
171
- limit: {
172
- type: 'integer'
173
- },
174
- totalPages: {
175
- type: 'integer'
176
- },
177
- page: {
178
- type: 'integer'
179
- },
180
- pagingCounter: {
181
- type: 'integer'
182
- },
183
- hasPrevPage: {
184
- type: 'boolean'
185
- },
186
- hasNextPage: {
187
- type: 'boolean'
188
- },
189
- prevPage: nullableType('integer'),
190
- nextPage: nullableType('integer')
191
- },
192
- required: [
193
- 'docs',
194
- 'totalDocs',
195
- 'limit',
196
- 'totalPages',
197
- 'page'
198
- ]
199
- });
200
- const uploadRequestBody = ({ bodyRef, fileRequired, t })=>{
201
- const fieldsSchemaName = bodyRef.$ref.split('/').pop() ?? 'the document';
202
- return {
203
- required: fileRequired,
204
- description: t('uploadBody'),
205
- content: {
206
- 'multipart/form-data': {
207
- schema: {
208
- type: 'object',
209
- properties: {
210
- file: {
211
- type: 'string',
212
- format: 'binary',
213
- description: t('uploadFile')
214
- },
215
- _payload: {
216
- allOf: [
217
- bodyRef
218
- ],
219
- description: t('uploadPayloadField', {
220
- schema: fieldsSchemaName
221
- })
222
- }
223
- },
224
- ...fileRequired ? {
225
- required: [
226
- 'file'
227
- ]
228
- } : {}
229
- },
230
- encoding: {
231
- file: {
232
- contentType: 'application/octet-stream'
233
- },
234
- _payload: {
235
- contentType: 'application/json'
236
- }
237
- }
238
- },
239
- 'application/json': {
240
- schema: bodyRef
241
- }
242
- }
243
- };
244
- };
245
- const SECURITY_SCHEME_NAME = 'PayloadToken';
246
- const INTERACTIVE_SCHEME_NAME = 'PayloadLogin';
247
- const interactiveSecurityScheme = ({ tokenUrl, t })=>({
248
- type: 'oauth2',
249
- description: t('securityInteractive'),
250
- flows: {
251
- password: {
252
- tokenUrl,
253
- scopes: {}
254
- }
255
- }
256
- });
257
- const securityScheme = ({ cookiePrefix, t })=>({
258
- type: 'http',
259
- scheme: 'bearer',
260
- bearerFormat: 'JWT',
261
- description: t('securityBearer', {
262
- cookiePrefix
263
- })
264
- });
265
- export { ERRORS, ERROR_SCHEMA_NAME, INTERACTIVE_SCHEME_NAME, SECURITY_SCHEME_NAME, buildErrorResponseSchema, buildListEnvelopeSchema, errorResponses, interactiveSecurityScheme, jsonBody, jsonOk, jsonResponse, messageResponse, nullableType, securityScheme, uploadRequestBody };
@@ -1,74 +0,0 @@
1
- const NULL = 'null';
2
- const UNSUPPORTED_KEYWORDS = [
3
- '$schema',
4
- '$id',
5
- '$comment',
6
- 'unevaluatedProperties',
7
- 'patternProperties',
8
- 'propertyNames'
9
- ];
10
- const isStringType = (type)=>'string' === type || Array.isArray(type) && type.includes('string');
11
- const downconvertTo30 = (node)=>{
12
- if (Array.isArray(node)) return node.map(downconvertTo30);
13
- if (!node || 'object' != typeof node) return node;
14
- const out = {};
15
- for (const [key, value] of Object.entries(node))out[key] = downconvertTo30(value);
16
- if (isStringType(out.type) && 'application/octet-stream' === out.contentMediaType) {
17
- if (void 0 === out.format) out.format = 'binary';
18
- delete out.contentMediaType;
19
- }
20
- if (isStringType(out.type) && 'base64' === out.contentEncoding) {
21
- if (void 0 === out.format) out.format = 'byte';
22
- delete out.contentEncoding;
23
- }
24
- if (Array.isArray(out.type)) {
25
- const types = out.type;
26
- const nullable = types.includes(NULL);
27
- const rest = types.filter((t)=>t !== NULL);
28
- if (1 === rest.length) {
29
- out.type = rest[0];
30
- if (nullable) out.nullable = true;
31
- } else if (rest.length > 1) {
32
- delete out.type;
33
- const union = rest.map((type)=>nullable ? {
34
- type,
35
- nullable: true
36
- } : {
37
- type
38
- });
39
- if (out.anyOf) out.allOf = [
40
- ...out.allOf ?? [],
41
- {
42
- anyOf: union
43
- }
44
- ];
45
- else out.anyOf = union;
46
- }
47
- }
48
- if ('const' in out) {
49
- out.enum = [
50
- out.const
51
- ];
52
- delete out.const;
53
- }
54
- if (Array.isArray(out.examples)) {
55
- const examples = out.examples;
56
- if (examples.length > 0) out.example = examples[0];
57
- if (examples.length > 1) out['x-examples'] = examples;
58
- delete out.examples;
59
- }
60
- if (Array.isArray(out.required) && 0 === out.required.length) delete out.required;
61
- for (const keyword of UNSUPPORTED_KEYWORDS)delete out[keyword];
62
- return out;
63
- };
64
- const toOpenApi31 = (doc)=>({
65
- ...doc,
66
- openapi: '3.1.2',
67
- tags: doc.tags?.map(({ kind: _kind, parent: _parent, summary: _summary, ...rest })=>rest)
68
- });
69
- const toOpenApi30 = (doc)=>{
70
- const converted = downconvertTo30(toOpenApi31(doc));
71
- converted.openapi = '3.0.4';
72
- return converted;
73
- };
74
- export { toOpenApi30, toOpenApi31 };
@@ -1,15 +0,0 @@
1
- import type { Block, SanitizedConfig } from 'payload';
2
- import type { SchemaObject } from '@scalar/openapi-types/3.2';
3
- import type { BuildContext, Entity } from '../types.js';
4
- export declare const resolveLocalizedStrings: (value: unknown, ctx: BuildContext) => unknown;
5
- export interface EntitySchemas {
6
- read: SchemaObject;
7
- create: SchemaObject;
8
- update: SchemaObject;
9
- }
10
- export declare const buildEntitySchemas: ({ entity, config, ctx, }: {
11
- entity: Entity;
12
- config: SanitizedConfig;
13
- ctx: BuildContext;
14
- }) => Promise<EntitySchemas>;
15
- export declare const buildBlockSchema: (block: Block, config: SanitizedConfig) => SchemaObject;
@@ -1,250 +0,0 @@
1
- import { entityToJSONSchema } from "payload";
2
- import { getTranslation } from "@payloadcms/translations";
3
- import { deepMerge, isPlainObject } from "../utils.js";
4
- import { makeT } from "../translations/index.js";
5
- import { AUTH_FIELDS, flattenFields } from "./fields.js";
6
- import { refTo, rewriteRefs, schemaName } from "./names.js";
7
- const READ_HIDDEN_FIELDS = new Set([
8
- ...AUTH_FIELDS,
9
- 'collection'
10
- ]);
11
- const SERVER_FIELDS = [
12
- 'id',
13
- 'createdAt',
14
- 'updatedAt'
15
- ];
16
- const stripInterfaceName = (entity)=>{
17
- const { interfaceName: _omit, ...rest } = entity;
18
- return rest;
19
- };
20
- const toComponentSchema = ({ config, source, idType, write = false })=>{
21
- const jsonSchema = entityToJSONSchema(config, source, new Map(), idType, void 0, void 0, {
22
- forceInlineBlocks: write
23
- });
24
- const blockSlugs = new Set((config.blocks ?? []).map((b)=>b.slug));
25
- const schema = rewriteRefs(jsonSchema, blockSlugs);
26
- delete schema.title;
27
- return schema;
28
- };
29
- const fieldOpenapi = (field)=>{
30
- const meta = field.custom?.openapi;
31
- return isPlainObject(meta) ? meta : void 0;
32
- };
33
- const isLocaleKeyed = (value, ctx)=>{
34
- if (!isPlainObject(value)) return false;
35
- const keys = Object.keys(value);
36
- return keys.length > 0 && keys.every((k)=>ctx.locales.includes(k)) && Object.values(value).every((v)=>'string' == typeof v);
37
- };
38
- const LOCALIZABLE_KEYS = new Set([
39
- "description",
40
- 'title',
41
- 'summary'
42
- ]);
43
- const resolveTextValue = (value, ctx)=>{
44
- if ('function' == typeof value) try {
45
- const result = value({
46
- t: ctx.i18n.t,
47
- i18n: ctx.i18n
48
- });
49
- return 'string' == typeof result && result.length > 0 ? result : void 0;
50
- } catch {
51
- return;
52
- }
53
- if (isLocaleKeyed(value, ctx)) return getTranslation(value, ctx.i18n);
54
- };
55
- const resolveLocalizedStrings = (value, ctx)=>{
56
- if (!isPlainObject(value)) return value;
57
- const out = {};
58
- for (const [k, v] of Object.entries(value)){
59
- if (LOCALIZABLE_KEYS.has(k)) {
60
- const resolved = resolveTextValue(v, ctx);
61
- if (void 0 !== resolved) out[k] = resolved;
62
- else if ('function' != typeof v) out[k] = resolveLocalizedStrings(v, ctx);
63
- continue;
64
- }
65
- out[k] = resolveLocalizedStrings(v, ctx);
66
- }
67
- return out;
68
- };
69
- const applyFieldOverrides = ({ schema, fields, ctx })=>{
70
- if (!schema.properties) return;
71
- for (const field of flattenFields(fields)){
72
- const name = 'name' in field ? field.name : void 0;
73
- const override = fieldOpenapi(field);
74
- if (!name || !override) continue;
75
- const current = schema.properties[name];
76
- if (isPlainObject(current)) {
77
- const resolved = resolveLocalizedStrings(override, ctx);
78
- schema.properties[name] = deepMerge(current, resolved);
79
- }
80
- }
81
- };
82
- const isRef = (value)=>isPlainObject(value) && 'string' == typeof value.$ref;
83
- const isBlockBranch = (branch)=>{
84
- if (isRef(branch)) return branch.$ref.startsWith('#/components/schemas/Block');
85
- return isPlainObject(branch) && isPlainObject(branch.properties) && 'blockType' in branch.properties;
86
- };
87
- const addBlockDiscriminators = (node)=>{
88
- if (Array.isArray(node)) {
89
- for (const item of node)addBlockDiscriminators(item);
90
- return;
91
- }
92
- if (!isPlainObject(node)) return;
93
- const oneOf = node.oneOf;
94
- if (Array.isArray(oneOf) && oneOf.length > 0 && oneOf.every(isBlockBranch)) node.discriminator = {
95
- propertyName: 'blockType'
96
- };
97
- for (const value of Object.values(node))addBlockDiscriminators(value);
98
- };
99
- const markLocalizedFields = ({ schema, fields, ctx })=>{
100
- if (!schema.properties || 0 === ctx.locales.length) return;
101
- for (const field of flattenFields(fields)){
102
- if (!('localized' in field) || !field.localized) continue;
103
- const name = 'name' in field ? field.name : void 0;
104
- if (!name || !(name in schema.properties)) continue;
105
- const single = schema.properties[name];
106
- schema.properties[name] = {
107
- oneOf: [
108
- single,
109
- {
110
- type: 'object',
111
- description: makeT(ctx.i18n)('schemaPerLocale'),
112
- properties: Object.fromEntries(ctx.locales.map((l)=>[
113
- l,
114
- single
115
- ]))
116
- }
117
- ]
118
- };
119
- }
120
- };
121
- const removeProps = (schema, names)=>{
122
- if (!schema.properties) return;
123
- for (const name of names)delete schema.properties[name];
124
- if (Array.isArray(schema.required)) {
125
- const drop = new Set(names);
126
- schema.required = schema.required.filter((r)=>!drop.has(r));
127
- }
128
- };
129
- const toIdType = (type)=>Array.isArray(type) ? type.map(toIdType) : 'number' === type ? 'integer' : type;
130
- const writeRelationshipsAsIds = (node, refs)=>{
131
- if (Array.isArray(node)) {
132
- for (const item of node)writeRelationshipsAsIds(item, refs);
133
- return;
134
- }
135
- if (!isPlainObject(node)) return;
136
- const oneOf = node.oneOf;
137
- if (Array.isArray(oneOf) && 2 === oneOf.length && isRef(oneOf[1]) && refs.has(oneOf[1].$ref)) {
138
- delete node.oneOf;
139
- node.type = toIdType(oneOf[0].type);
140
- return;
141
- }
142
- for (const value of Object.values(node))writeRelationshipsAsIds(value, refs);
143
- };
144
- const buildBaseSchema = ({ entity, config, ctx, write = false })=>{
145
- const idType = ctx.defaultIDType;
146
- const schema = toComponentSchema({
147
- config,
148
- source: stripInterfaceName(entity),
149
- idType,
150
- write
151
- });
152
- if (write) {
153
- const refs = new Set((config.collections ?? []).map((c)=>refTo(schemaName(c.slug))));
154
- writeRelationshipsAsIds(schema, refs);
155
- }
156
- const isAuth = 'auth' in entity && Boolean(entity.auth);
157
- if (isAuth) removeProps(schema, READ_HIDDEN_FIELDS);
158
- applyFieldOverrides({
159
- schema,
160
- fields: entity.fields,
161
- ctx
162
- });
163
- addBlockDiscriminators(schema);
164
- return schema;
165
- };
166
- const cloneSchema = (schema)=>({
167
- ...schema,
168
- properties: {
169
- ...schema.properties
170
- },
171
- required: Array.isArray(schema.required) ? [
172
- ...schema.required
173
- ] : schema.required
174
- });
175
- const buildEntitySchemas = async ({ entity, config, ctx })=>{
176
- const read = buildBaseSchema({
177
- entity,
178
- config,
179
- ctx
180
- });
181
- const write = buildBaseSchema({
182
- entity,
183
- config,
184
- ctx,
185
- write: true
186
- });
187
- const isAuth = 'auth' in entity && Boolean(entity.auth);
188
- const create = cloneSchema(write);
189
- if (Array.isArray(create.required)) {
190
- const optional = new Set(SERVER_FIELDS);
191
- create.required = create.required.filter((r)=>!optional.has(r));
192
- }
193
- if (isAuth && create.properties) {
194
- create.properties.password = {
195
- type: 'string'
196
- };
197
- create.required = [
198
- ...new Set([
199
- ...create.required ?? [],
200
- 'password'
201
- ])
202
- ];
203
- }
204
- const update = cloneSchema(write);
205
- delete update.required;
206
- if (update.properties) delete update.properties.id;
207
- if (isAuth && update.properties) update.properties.password = {
208
- type: 'string'
209
- };
210
- markLocalizedFields({
211
- schema: read,
212
- fields: entity.fields,
213
- ctx
214
- });
215
- return {
216
- read,
217
- create,
218
- update
219
- };
220
- };
221
- const buildBlockSchema = (block, config)=>{
222
- const schema = toComponentSchema({
223
- config,
224
- source: stripInterfaceName(block),
225
- idType: 'text'
226
- });
227
- const blockType = {
228
- type: 'string',
229
- enum: [
230
- block.slug
231
- ]
232
- };
233
- const properties = {
234
- ...schema.properties,
235
- blockType
236
- };
237
- const required = [
238
- ...new Set([
239
- 'blockType',
240
- ...schema.required ?? []
241
- ])
242
- ];
243
- return {
244
- ...schema,
245
- type: 'object',
246
- properties,
247
- required
248
- };
249
- };
250
- export { buildBlockSchema, buildEntitySchemas, resolveLocalizedStrings };
@@ -1,44 +0,0 @@
1
- const isHiddenField = (field)=>'hidden' in field && true === field.hidden;
2
- const AUTH_FIELDS = new Set([
3
- 'salt',
4
- 'hash',
5
- 'password',
6
- 'resetPasswordToken',
7
- 'resetPasswordExpiration',
8
- 'loginAttempts',
9
- 'lockUntil',
10
- 'sessions'
11
- ]);
12
- const hasName = (field)=>'name' in field && 'string' == typeof field.name;
13
- const flattenFields = (fields)=>{
14
- const out = [];
15
- for (const field of fields)if ('ui' !== field.type) {
16
- if ('row' === field.type || 'collapsible' === field.type) {
17
- out.push(...flattenFields(field.fields));
18
- continue;
19
- }
20
- if ('tabs' === field.type) {
21
- for (const tab of field.tabs){
22
- const tabName = hasName(tab) ? tab.name : void 0;
23
- if (tabName) out.push({
24
- type: 'group',
25
- name: tabName,
26
- fields: tab.fields
27
- });
28
- else out.push(...flattenFields(tab.fields));
29
- }
30
- continue;
31
- }
32
- if ('group' === field.type && !hasName(field)) {
33
- out.push(...flattenFields(field.fields));
34
- continue;
35
- }
36
- out.push(field);
37
- }
38
- return out;
39
- };
40
- const exposableFields = (fields)=>flattenFields(fields).filter((field)=>{
41
- const name = 'name' in field ? field.name : void 0;
42
- return Boolean(name) && !isHiddenField(field) && !AUTH_FIELDS.has(name);
43
- });
44
- export { AUTH_FIELDS, exposableFields, flattenFields, isHiddenField };
@@ -1,11 +0,0 @@
1
- import type { SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload';
2
- import type { PathsObject } from '@scalar/openapi-types/3.2';
3
- import type { EntityKind, ResolvedFilters } from '../types.js';
4
- export declare const shouldIncludeCollection: (collection: SanitizedCollectionConfig, filters: ResolvedFilters) => boolean;
5
- export declare const shouldIncludeGlobal: (global: SanitizedGlobalConfig, filters: ResolvedFilters) => boolean;
6
- export declare const filterOperations: ({ paths, slug, kind, filters, }: {
7
- paths: PathsObject;
8
- slug: string;
9
- kind: EntityKind;
10
- filters: ResolvedFilters;
11
- }) => PathsObject;