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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (407) hide show
  1. package/README.md +72 -26
  2. package/dist/_tooling/telemetry.js +168 -0
  3. package/dist/_tooling/telemetry.js.map +1 -0
  4. package/dist/cli/generateSpec.d.ts +2 -0
  5. package/dist/cli/generateSpec.js +40 -0
  6. package/dist/cli/generateSpec.js.map +1 -0
  7. package/dist/index.d.ts +8 -9
  8. package/dist/index.js +76 -65
  9. package/dist/index.js.map +1 -0
  10. package/dist/{endpoints → server/endpoints}/interactiveAuth.d.ts +2 -2
  11. package/dist/server/endpoints/interactiveAuth.js +25 -0
  12. package/dist/server/endpoints/interactiveAuth.js.map +1 -0
  13. package/dist/server/endpoints/spec.d.ts +5 -0
  14. package/dist/server/endpoints/spec.js +39 -0
  15. package/dist/server/endpoints/spec.js.map +1 -0
  16. package/dist/server/options/resolveOptions.d.ts +4 -0
  17. package/dist/server/options/resolveOptions.js +65 -0
  18. package/dist/server/options/resolveOptions.js.map +1 -0
  19. package/dist/server/spec/build.d.ts +14 -0
  20. package/dist/server/spec/build.js +40 -0
  21. package/dist/server/spec/build.js.map +1 -0
  22. package/dist/server/spec/buildDocument.d.ts +16 -0
  23. package/dist/server/spec/buildDocument.js +340 -0
  24. package/dist/server/spec/buildDocument.js.map +1 -0
  25. package/dist/server/spec/components.d.ts +61 -0
  26. package/dist/server/spec/components.js +265 -0
  27. package/dist/server/spec/components.js.map +1 -0
  28. package/dist/{spec → server/spec}/downconvert.d.ts +2 -1
  29. package/dist/server/spec/downconvert.js +69 -0
  30. package/dist/server/spec/downconvert.js.map +1 -0
  31. package/dist/server/spec/entitySchemas.d.ts +15 -0
  32. package/dist/server/spec/entitySchemas.js +207 -0
  33. package/dist/server/spec/entitySchemas.js.map +1 -0
  34. package/dist/{spec → server/spec}/fields.d.ts +2 -1
  35. package/dist/server/spec/fields.js +47 -0
  36. package/dist/server/spec/fields.js.map +1 -0
  37. package/dist/server/spec/filters.d.ts +16 -0
  38. package/dist/server/spec/filters.js +102 -0
  39. package/dist/server/spec/filters.js.map +1 -0
  40. package/dist/server/spec/hierarchy.d.ts +11 -0
  41. package/dist/server/spec/hierarchy.js +43 -0
  42. package/dist/server/spec/hierarchy.js.map +1 -0
  43. package/dist/{spec → server/spec}/names.d.ts +2 -2
  44. package/dist/server/spec/names.js +43 -0
  45. package/dist/server/spec/names.js.map +1 -0
  46. package/dist/server/spec/params.d.ts +57 -0
  47. package/dist/server/spec/params.js +394 -0
  48. package/dist/server/spec/params.js.map +1 -0
  49. package/dist/server/spec/paths/auth.d.ts +10 -0
  50. package/dist/server/spec/paths/auth.js +190 -0
  51. package/dist/server/spec/paths/auth.js.map +1 -0
  52. package/dist/server/spec/paths/collections.d.ts +11 -0
  53. package/dist/server/spec/paths/collections.js +418 -0
  54. package/dist/server/spec/paths/collections.js.map +1 -0
  55. package/dist/server/spec/paths/custom.d.ts +12 -0
  56. package/dist/server/spec/paths/custom.js +42 -0
  57. package/dist/server/spec/paths/custom.js.map +1 -0
  58. package/dist/server/spec/paths/globals.d.ts +11 -0
  59. package/dist/server/spec/paths/globals.js +87 -0
  60. package/dist/server/spec/paths/globals.js.map +1 -0
  61. package/dist/server/spec/paths/jobs.d.ts +9 -0
  62. package/dist/server/spec/paths/jobs.js +98 -0
  63. package/dist/server/spec/paths/jobs.js.map +1 -0
  64. package/dist/server/spec/paths/system.d.ts +9 -0
  65. package/dist/server/spec/paths/system.js +203 -0
  66. package/dist/server/spec/paths/system.js.map +1 -0
  67. package/dist/server/spec/paths/versions.d.ts +22 -0
  68. package/dist/server/spec/paths/versions.js +185 -0
  69. package/dist/server/spec/paths/versions.js.map +1 -0
  70. package/dist/server/spec/plugins/ecommerce.d.ts +3 -0
  71. package/dist/server/spec/plugins/ecommerce.js +270 -0
  72. package/dist/server/spec/plugins/ecommerce.js.map +1 -0
  73. package/dist/server/spec/plugins/importExport.d.ts +3 -0
  74. package/dist/server/spec/plugins/importExport.js +202 -0
  75. package/dist/server/spec/plugins/importExport.js.map +1 -0
  76. package/dist/server/spec/plugins/index.d.ts +3 -0
  77. package/dist/server/spec/plugins/index.js +21 -0
  78. package/dist/server/spec/plugins/index.js.map +1 -0
  79. package/dist/server/spec/plugins/mcp.d.ts +3 -0
  80. package/dist/server/spec/plugins/mcp.js +118 -0
  81. package/dist/server/spec/plugins/mcp.js.map +1 -0
  82. package/dist/server/spec/plugins/multiTenant.d.ts +3 -0
  83. package/dist/server/spec/plugins/multiTenant.js +39 -0
  84. package/dist/server/spec/plugins/multiTenant.js.map +1 -0
  85. package/dist/server/spec/plugins/search.d.ts +3 -0
  86. package/dist/server/spec/plugins/search.js +43 -0
  87. package/dist/server/spec/plugins/search.js.map +1 -0
  88. package/dist/server/spec/plugins/seo.d.ts +3 -0
  89. package/dist/server/spec/plugins/seo.js +83 -0
  90. package/dist/server/spec/plugins/seo.js.map +1 -0
  91. package/dist/server/spec/plugins/shared.d.ts +35 -0
  92. package/dist/server/spec/plugins/shared.js +37 -0
  93. package/dist/server/spec/plugins/shared.js.map +1 -0
  94. package/dist/server/spec/plugins/storageR2.d.ts +3 -0
  95. package/dist/server/spec/plugins/storageR2.js +91 -0
  96. package/dist/server/spec/plugins/storageR2.js.map +1 -0
  97. package/dist/server/spec/plugins/stripe.d.ts +10 -0
  98. package/dist/server/spec/plugins/stripe.js +102 -0
  99. package/dist/server/spec/plugins/stripe.js.map +1 -0
  100. package/dist/server/spec/security.d.ts +34 -0
  101. package/dist/server/spec/security.js +100 -0
  102. package/dist/server/spec/security.js.map +1 -0
  103. package/dist/server/spec/tags.d.ts +37 -0
  104. package/dist/server/spec/tags.js +99 -0
  105. package/dist/server/spec/tags.js.map +1 -0
  106. package/dist/server/telemetry.d.ts +31 -0
  107. package/dist/server/telemetry.js +33 -0
  108. package/dist/server/telemetry.js.map +1 -0
  109. package/dist/server/ui/createUiPlugin.d.ts +16 -0
  110. package/dist/server/ui/createUiPlugin.js +33 -0
  111. package/dist/server/ui/createUiPlugin.js.map +1 -0
  112. package/dist/{ui → server/ui}/html.d.ts +5 -3
  113. package/dist/server/ui/html.js +11 -0
  114. package/dist/server/ui/html.js.map +1 -0
  115. package/dist/server/ui/scalar.d.ts +4 -0
  116. package/dist/server/ui/scalar.js +17 -0
  117. package/dist/server/ui/scalar.js.map +1 -0
  118. package/dist/server/ui/swagger.d.ts +4 -0
  119. package/dist/server/ui/swagger.js +18 -0
  120. package/dist/server/ui/swagger.js.map +1 -0
  121. package/dist/shared/constants.d.ts +4 -0
  122. package/dist/shared/constants.js +6 -0
  123. package/dist/shared/constants.js.map +1 -0
  124. package/dist/shared/translations/index.d.ts +5 -0
  125. package/dist/{translations → shared/translations}/index.js +49 -47
  126. package/dist/shared/translations/index.js.map +1 -0
  127. package/dist/shared/translations/locales/ar.d.ts +3 -0
  128. package/dist/shared/translations/locales/ar.js +173 -0
  129. package/dist/shared/translations/locales/ar.js.map +1 -0
  130. package/dist/shared/translations/locales/az.d.ts +3 -0
  131. package/dist/shared/translations/locales/az.js +173 -0
  132. package/dist/shared/translations/locales/az.js.map +1 -0
  133. package/dist/shared/translations/locales/bg.d.ts +3 -0
  134. package/dist/shared/translations/locales/bg.js +173 -0
  135. package/dist/shared/translations/locales/bg.js.map +1 -0
  136. package/dist/shared/translations/locales/bnBd.d.ts +3 -0
  137. package/dist/shared/translations/locales/bnBd.js +173 -0
  138. package/dist/shared/translations/locales/bnBd.js.map +1 -0
  139. package/dist/shared/translations/locales/bnIn.d.ts +3 -0
  140. package/dist/shared/translations/locales/bnIn.js +173 -0
  141. package/dist/shared/translations/locales/bnIn.js.map +1 -0
  142. package/dist/shared/translations/locales/ca.d.ts +3 -0
  143. package/dist/shared/translations/locales/ca.js +173 -0
  144. package/dist/shared/translations/locales/ca.js.map +1 -0
  145. package/dist/shared/translations/locales/cs.d.ts +3 -0
  146. package/dist/shared/translations/locales/cs.js +173 -0
  147. package/dist/shared/translations/locales/cs.js.map +1 -0
  148. package/dist/shared/translations/locales/da.d.ts +3 -0
  149. package/dist/shared/translations/locales/da.js +173 -0
  150. package/dist/shared/translations/locales/da.js.map +1 -0
  151. package/dist/shared/translations/locales/de.d.ts +3 -0
  152. package/dist/shared/translations/locales/de.js +173 -0
  153. package/dist/shared/translations/locales/de.js.map +1 -0
  154. package/dist/shared/translations/locales/en.d.ts +3 -0
  155. package/dist/shared/translations/locales/en.js +173 -0
  156. package/dist/shared/translations/locales/en.js.map +1 -0
  157. package/dist/shared/translations/locales/es.d.ts +3 -0
  158. package/dist/shared/translations/locales/es.js +173 -0
  159. package/dist/shared/translations/locales/es.js.map +1 -0
  160. package/dist/shared/translations/locales/et.d.ts +3 -0
  161. package/dist/shared/translations/locales/et.js +173 -0
  162. package/dist/shared/translations/locales/et.js.map +1 -0
  163. package/dist/shared/translations/locales/fa.d.ts +3 -0
  164. package/dist/shared/translations/locales/fa.js +173 -0
  165. package/dist/shared/translations/locales/fa.js.map +1 -0
  166. package/dist/shared/translations/locales/fr.d.ts +3 -0
  167. package/dist/shared/translations/locales/fr.js +173 -0
  168. package/dist/shared/translations/locales/fr.js.map +1 -0
  169. package/dist/shared/translations/locales/he.d.ts +3 -0
  170. package/dist/shared/translations/locales/he.js +173 -0
  171. package/dist/shared/translations/locales/he.js.map +1 -0
  172. package/dist/shared/translations/locales/hr.d.ts +3 -0
  173. package/dist/shared/translations/locales/hr.js +173 -0
  174. package/dist/shared/translations/locales/hr.js.map +1 -0
  175. package/dist/shared/translations/locales/hu.d.ts +3 -0
  176. package/dist/shared/translations/locales/hu.js +173 -0
  177. package/dist/shared/translations/locales/hu.js.map +1 -0
  178. package/dist/shared/translations/locales/hy.d.ts +3 -0
  179. package/dist/shared/translations/locales/hy.js +173 -0
  180. package/dist/shared/translations/locales/hy.js.map +1 -0
  181. package/dist/shared/translations/locales/id.d.ts +3 -0
  182. package/dist/shared/translations/locales/id.js +173 -0
  183. package/dist/shared/translations/locales/id.js.map +1 -0
  184. package/dist/shared/translations/locales/is.d.ts +3 -0
  185. package/dist/shared/translations/locales/is.js +173 -0
  186. package/dist/shared/translations/locales/is.js.map +1 -0
  187. package/dist/shared/translations/locales/it.d.ts +3 -0
  188. package/dist/shared/translations/locales/it.js +173 -0
  189. package/dist/shared/translations/locales/it.js.map +1 -0
  190. package/dist/shared/translations/locales/ja.d.ts +3 -0
  191. package/dist/shared/translations/locales/ja.js +173 -0
  192. package/dist/shared/translations/locales/ja.js.map +1 -0
  193. package/dist/shared/translations/locales/ko.d.ts +3 -0
  194. package/dist/shared/translations/locales/ko.js +173 -0
  195. package/dist/shared/translations/locales/ko.js.map +1 -0
  196. package/dist/shared/translations/locales/lt.d.ts +3 -0
  197. package/dist/shared/translations/locales/lt.js +173 -0
  198. package/dist/shared/translations/locales/lt.js.map +1 -0
  199. package/dist/shared/translations/locales/lv.d.ts +3 -0
  200. package/dist/shared/translations/locales/lv.js +173 -0
  201. package/dist/shared/translations/locales/lv.js.map +1 -0
  202. package/dist/shared/translations/locales/my.d.ts +3 -0
  203. package/dist/shared/translations/locales/my.js +173 -0
  204. package/dist/shared/translations/locales/my.js.map +1 -0
  205. package/dist/shared/translations/locales/nb.d.ts +3 -0
  206. package/dist/shared/translations/locales/nb.js +173 -0
  207. package/dist/shared/translations/locales/nb.js.map +1 -0
  208. package/dist/shared/translations/locales/nl.d.ts +3 -0
  209. package/dist/shared/translations/locales/nl.js +173 -0
  210. package/dist/shared/translations/locales/nl.js.map +1 -0
  211. package/dist/shared/translations/locales/pl.d.ts +3 -0
  212. package/dist/shared/translations/locales/pl.js +173 -0
  213. package/dist/shared/translations/locales/pl.js.map +1 -0
  214. package/dist/shared/translations/locales/pt.d.ts +3 -0
  215. package/dist/shared/translations/locales/pt.js +173 -0
  216. package/dist/shared/translations/locales/pt.js.map +1 -0
  217. package/dist/shared/translations/locales/ro.d.ts +3 -0
  218. package/dist/shared/translations/locales/ro.js +173 -0
  219. package/dist/shared/translations/locales/ro.js.map +1 -0
  220. package/dist/shared/translations/locales/rs.d.ts +3 -0
  221. package/dist/shared/translations/locales/rs.js +173 -0
  222. package/dist/shared/translations/locales/rs.js.map +1 -0
  223. package/dist/shared/translations/locales/rsLatin.d.ts +3 -0
  224. package/dist/shared/translations/locales/rsLatin.js +173 -0
  225. package/dist/shared/translations/locales/rsLatin.js.map +1 -0
  226. package/dist/shared/translations/locales/ru.d.ts +3 -0
  227. package/dist/shared/translations/locales/ru.js +173 -0
  228. package/dist/shared/translations/locales/ru.js.map +1 -0
  229. package/dist/shared/translations/locales/sk.d.ts +3 -0
  230. package/dist/shared/translations/locales/sk.js +173 -0
  231. package/dist/shared/translations/locales/sk.js.map +1 -0
  232. package/dist/shared/translations/locales/sl.d.ts +3 -0
  233. package/dist/shared/translations/locales/sl.js +173 -0
  234. package/dist/shared/translations/locales/sl.js.map +1 -0
  235. package/dist/shared/translations/locales/sv.d.ts +3 -0
  236. package/dist/shared/translations/locales/sv.js +173 -0
  237. package/dist/shared/translations/locales/sv.js.map +1 -0
  238. package/dist/shared/translations/locales/ta.d.ts +3 -0
  239. package/dist/shared/translations/locales/ta.js +173 -0
  240. package/dist/shared/translations/locales/ta.js.map +1 -0
  241. package/dist/shared/translations/locales/th.d.ts +3 -0
  242. package/dist/shared/translations/locales/th.js +173 -0
  243. package/dist/shared/translations/locales/th.js.map +1 -0
  244. package/dist/shared/translations/locales/tr.d.ts +3 -0
  245. package/dist/shared/translations/locales/tr.js +173 -0
  246. package/dist/shared/translations/locales/tr.js.map +1 -0
  247. package/dist/shared/translations/locales/uk.d.ts +3 -0
  248. package/dist/shared/translations/locales/uk.js +173 -0
  249. package/dist/shared/translations/locales/uk.js.map +1 -0
  250. package/dist/shared/translations/locales/vi.d.ts +3 -0
  251. package/dist/shared/translations/locales/vi.js +173 -0
  252. package/dist/shared/translations/locales/vi.js.map +1 -0
  253. package/dist/shared/translations/locales/zh.d.ts +3 -0
  254. package/dist/shared/translations/locales/zh.js +173 -0
  255. package/dist/shared/translations/locales/zh.js.map +1 -0
  256. package/dist/shared/translations/locales/zhTw.d.ts +3 -0
  257. package/dist/shared/translations/locales/zhTw.js +173 -0
  258. package/dist/shared/translations/locales/zhTw.js.map +1 -0
  259. package/dist/shared/translations/types.d.ts +180 -0
  260. package/dist/shared/translations/types.js +1 -0
  261. package/dist/shared/types/index.d.ts +412 -0
  262. package/dist/shared/types/index.js +1 -0
  263. package/dist/{utils.d.ts → shared/utils.d.ts} +1 -0
  264. package/dist/shared/utils.js +13 -0
  265. package/dist/shared/utils.js.map +1 -0
  266. package/package.json +70 -39
  267. package/dist/bin/generateSpec.d.ts +0 -25
  268. package/dist/bin/generateSpec.js +0 -61
  269. package/dist/constants.d.ts +0 -1
  270. package/dist/constants.js +0 -2
  271. package/dist/endpoints/interactiveAuth.js +0 -27
  272. package/dist/endpoints/spec.d.ts +0 -5
  273. package/dist/endpoints/spec.js +0 -39
  274. package/dist/options.d.ts +0 -2
  275. package/dist/options.js +0 -45
  276. package/dist/spec/build.d.ts +0 -14
  277. package/dist/spec/build.js +0 -36
  278. package/dist/spec/buildDocument.d.ts +0 -15
  279. package/dist/spec/buildDocument.js +0 -268
  280. package/dist/spec/components.d.ts +0 -44
  281. package/dist/spec/components.js +0 -265
  282. package/dist/spec/downconvert.js +0 -74
  283. package/dist/spec/entitySchemas.d.ts +0 -15
  284. package/dist/spec/entitySchemas.js +0 -250
  285. package/dist/spec/fields.js +0 -44
  286. package/dist/spec/filters.d.ts +0 -11
  287. package/dist/spec/filters.js +0 -83
  288. package/dist/spec/names.js +0 -37
  289. package/dist/spec/params.d.ts +0 -55
  290. package/dist/spec/params.js +0 -436
  291. package/dist/spec/paths/auth.d.ts +0 -9
  292. package/dist/spec/paths/auth.js +0 -274
  293. package/dist/spec/paths/collections.d.ts +0 -9
  294. package/dist/spec/paths/collections.js +0 -278
  295. package/dist/spec/paths/custom.d.ts +0 -9
  296. package/dist/spec/paths/custom.js +0 -41
  297. package/dist/spec/paths/globals.d.ts +0 -9
  298. package/dist/spec/paths/globals.js +0 -78
  299. package/dist/spec/paths/jobs.d.ts +0 -7
  300. package/dist/spec/paths/jobs.js +0 -130
  301. package/dist/spec/paths/versions.d.ts +0 -19
  302. package/dist/spec/paths/versions.js +0 -252
  303. package/dist/spec/security.d.ts +0 -19
  304. package/dist/spec/security.js +0 -96
  305. package/dist/spec/tags.d.ts +0 -27
  306. package/dist/spec/tags.js +0 -79
  307. package/dist/translations/index.d.ts +0 -6
  308. package/dist/translations/locales/ar.d.ts +0 -2
  309. package/dist/translations/locales/ar.js +0 -81
  310. package/dist/translations/locales/az.d.ts +0 -2
  311. package/dist/translations/locales/az.js +0 -81
  312. package/dist/translations/locales/bg.d.ts +0 -2
  313. package/dist/translations/locales/bg.js +0 -81
  314. package/dist/translations/locales/bnBd.d.ts +0 -2
  315. package/dist/translations/locales/bnBd.js +0 -81
  316. package/dist/translations/locales/bnIn.d.ts +0 -2
  317. package/dist/translations/locales/bnIn.js +0 -81
  318. package/dist/translations/locales/ca.d.ts +0 -2
  319. package/dist/translations/locales/ca.js +0 -81
  320. package/dist/translations/locales/cs.d.ts +0 -2
  321. package/dist/translations/locales/cs.js +0 -81
  322. package/dist/translations/locales/da.d.ts +0 -2
  323. package/dist/translations/locales/da.js +0 -81
  324. package/dist/translations/locales/de.d.ts +0 -2
  325. package/dist/translations/locales/de.js +0 -81
  326. package/dist/translations/locales/en.d.ts +0 -2
  327. package/dist/translations/locales/en.js +0 -81
  328. package/dist/translations/locales/es.d.ts +0 -2
  329. package/dist/translations/locales/es.js +0 -81
  330. package/dist/translations/locales/et.d.ts +0 -2
  331. package/dist/translations/locales/et.js +0 -81
  332. package/dist/translations/locales/fa.d.ts +0 -2
  333. package/dist/translations/locales/fa.js +0 -81
  334. package/dist/translations/locales/fr.d.ts +0 -2
  335. package/dist/translations/locales/fr.js +0 -81
  336. package/dist/translations/locales/he.d.ts +0 -2
  337. package/dist/translations/locales/he.js +0 -81
  338. package/dist/translations/locales/hr.d.ts +0 -2
  339. package/dist/translations/locales/hr.js +0 -81
  340. package/dist/translations/locales/hu.d.ts +0 -2
  341. package/dist/translations/locales/hu.js +0 -81
  342. package/dist/translations/locales/hy.d.ts +0 -2
  343. package/dist/translations/locales/hy.js +0 -81
  344. package/dist/translations/locales/id.d.ts +0 -2
  345. package/dist/translations/locales/id.js +0 -81
  346. package/dist/translations/locales/is.d.ts +0 -2
  347. package/dist/translations/locales/is.js +0 -81
  348. package/dist/translations/locales/it.d.ts +0 -2
  349. package/dist/translations/locales/it.js +0 -81
  350. package/dist/translations/locales/ja.d.ts +0 -2
  351. package/dist/translations/locales/ja.js +0 -81
  352. package/dist/translations/locales/ko.d.ts +0 -2
  353. package/dist/translations/locales/ko.js +0 -81
  354. package/dist/translations/locales/lt.d.ts +0 -2
  355. package/dist/translations/locales/lt.js +0 -81
  356. package/dist/translations/locales/lv.d.ts +0 -2
  357. package/dist/translations/locales/lv.js +0 -81
  358. package/dist/translations/locales/my.d.ts +0 -2
  359. package/dist/translations/locales/my.js +0 -81
  360. package/dist/translations/locales/nb.d.ts +0 -2
  361. package/dist/translations/locales/nb.js +0 -81
  362. package/dist/translations/locales/nl.d.ts +0 -2
  363. package/dist/translations/locales/nl.js +0 -81
  364. package/dist/translations/locales/pl.d.ts +0 -2
  365. package/dist/translations/locales/pl.js +0 -81
  366. package/dist/translations/locales/pt.d.ts +0 -2
  367. package/dist/translations/locales/pt.js +0 -81
  368. package/dist/translations/locales/ro.d.ts +0 -2
  369. package/dist/translations/locales/ro.js +0 -81
  370. package/dist/translations/locales/rs.d.ts +0 -2
  371. package/dist/translations/locales/rs.js +0 -81
  372. package/dist/translations/locales/rsLatin.d.ts +0 -2
  373. package/dist/translations/locales/rsLatin.js +0 -81
  374. package/dist/translations/locales/ru.d.ts +0 -2
  375. package/dist/translations/locales/ru.js +0 -81
  376. package/dist/translations/locales/sk.d.ts +0 -2
  377. package/dist/translations/locales/sk.js +0 -81
  378. package/dist/translations/locales/sl.d.ts +0 -2
  379. package/dist/translations/locales/sl.js +0 -81
  380. package/dist/translations/locales/sv.d.ts +0 -2
  381. package/dist/translations/locales/sv.js +0 -81
  382. package/dist/translations/locales/ta.d.ts +0 -2
  383. package/dist/translations/locales/ta.js +0 -81
  384. package/dist/translations/locales/th.d.ts +0 -2
  385. package/dist/translations/locales/th.js +0 -81
  386. package/dist/translations/locales/tr.d.ts +0 -2
  387. package/dist/translations/locales/tr.js +0 -81
  388. package/dist/translations/locales/uk.d.ts +0 -2
  389. package/dist/translations/locales/uk.js +0 -81
  390. package/dist/translations/locales/vi.d.ts +0 -2
  391. package/dist/translations/locales/vi.js +0 -81
  392. package/dist/translations/locales/zh.d.ts +0 -2
  393. package/dist/translations/locales/zh.js +0 -81
  394. package/dist/translations/locales/zhTw.d.ts +0 -2
  395. package/dist/translations/locales/zhTw.js +0 -81
  396. package/dist/translations/types.d.ts +0 -87
  397. package/dist/translations/types.js +0 -1
  398. package/dist/types.d.ts +0 -192
  399. package/dist/types.js +0 -1
  400. package/dist/ui/createUiPlugin.d.ts +0 -14
  401. package/dist/ui/createUiPlugin.js +0 -28
  402. package/dist/ui/html.js +0 -8
  403. package/dist/ui/scalar.d.ts +0 -1
  404. package/dist/ui/scalar.js +0 -12
  405. package/dist/ui/swagger.d.ts +0 -1
  406. package/dist/ui/swagger.js +0 -12
  407. package/dist/utils.js +0 -13
@@ -0,0 +1,270 @@
1
+ import { upperFirst } from "../../../shared/utils.js";
2
+ import { refTo, schemaName } from "../names.js";
3
+ import { ERROR_SCHEMA_NAME, errorResponses, jsonBody, jsonResponse } from "../components.js";
4
+ import { securedRequirement } from "../security.js";
5
+ import { collectionGroups, idSchema, messageErrors, mountEndpoints } from "./shared.js";
6
+ import { stripeWebhookOperation } from "./stripe.js";
7
+ const TAG = "Ecommerce";
8
+ const PAYMENT_PATH = /^\/payments\/([^/]+)\/(initiate|confirm-order)$/;
9
+ const CART_OPERATIONS = {
10
+ "/:id/add-item": {
11
+ operationId: "addItem",
12
+ summary: "ecommerceAddItem"
13
+ },
14
+ "/:id/remove-item": {
15
+ operationId: "removeItem",
16
+ summary: "ecommerceRemoveItem"
17
+ },
18
+ "/:id/update-item": {
19
+ operationId: "updateItem",
20
+ summary: "ecommerceUpdateItem"
21
+ },
22
+ "/:id/clear": {
23
+ operationId: "clear",
24
+ summary: "ecommerceClearCart"
25
+ },
26
+ "/:id/merge": {
27
+ operationId: "merge",
28
+ summary: "ecommerceMergeCart"
29
+ }
30
+ };
31
+ const ecommerce = {
32
+ slug: "@payloadcms/plugin-ecommerce",
33
+ tag: TAG,
34
+ build: ({ config, collections, ctx, schemas, t }) => {
35
+ const id = idSchema(ctx);
36
+ const secret = { type: "string" };
37
+ const failure = {
38
+ type: "object",
39
+ properties: {
40
+ message: { type: "string" },
41
+ success: {
42
+ type: "boolean",
43
+ enum: [false]
44
+ }
45
+ },
46
+ required: ["message", "success"]
47
+ };
48
+ const cartBodies = {
49
+ "/:id/add-item": {
50
+ type: "object",
51
+ properties: {
52
+ item: {
53
+ type: "object",
54
+ additionalProperties: true,
55
+ properties: {
56
+ product: id,
57
+ variant: id
58
+ },
59
+ required: ["product"]
60
+ },
61
+ quantity: {
62
+ type: "number",
63
+ default: 1
64
+ },
65
+ secret
66
+ },
67
+ required: ["item"]
68
+ },
69
+ "/:id/remove-item": {
70
+ type: "object",
71
+ properties: {
72
+ itemID: { type: "string" },
73
+ secret
74
+ },
75
+ required: ["itemID"]
76
+ },
77
+ "/:id/update-item": {
78
+ type: "object",
79
+ properties: {
80
+ itemID: { type: "string" },
81
+ quantity: {
82
+ description: t("ecommerceQuantity"),
83
+ oneOf: [{ type: "number" }, {
84
+ type: "object",
85
+ properties: { $inc: { type: "number" } },
86
+ required: ["$inc"]
87
+ }]
88
+ },
89
+ removeOnZero: {
90
+ type: "boolean",
91
+ default: true
92
+ },
93
+ secret
94
+ },
95
+ required: ["itemID", "quantity"]
96
+ },
97
+ "/:id/clear": {
98
+ type: "object",
99
+ properties: { secret }
100
+ },
101
+ "/:id/merge": {
102
+ type: "object",
103
+ properties: {
104
+ sourceCartID: id,
105
+ sourceSecret: { type: "string" }
106
+ },
107
+ required: ["sourceCartID", "sourceSecret"]
108
+ }
109
+ };
110
+ const cartGroups = collectionGroups(collections.filter((c) => (c.endpoints || []).some((endpoint) => endpoint.method === "post" && endpoint.path === "/:id/add-item")), ctx, ({ method, path }, collection) => {
111
+ const meta = CART_OPERATIONS[path];
112
+ if (!meta || method !== "post") return void 0;
113
+ const name = schemaName(collection.slug);
114
+ const merge = path === "/:id/merge";
115
+ const cart = schemas[name] ? { $ref: refTo(name) } : {
116
+ type: "object",
117
+ additionalProperties: true
118
+ };
119
+ const param = {
120
+ name: "id",
121
+ in: "path",
122
+ required: true,
123
+ schema: id
124
+ };
125
+ return {
126
+ tags: [TAG],
127
+ operationId: `${meta.operationId}${name}`,
128
+ summary: t(meta.summary),
129
+ description: merge ? void 0 : t("ecommerceCartAccess"),
130
+ parameters: [param],
131
+ requestBody: {
132
+ ...jsonBody(cartBodies[path]),
133
+ required: path !== "/:id/clear"
134
+ },
135
+ responses: {
136
+ "200": jsonResponse(t("ecommerceCartResult"), {
137
+ type: "object",
138
+ properties: {
139
+ cart,
140
+ message: { type: "string" },
141
+ success: {
142
+ type: "boolean",
143
+ enum: [true]
144
+ }
145
+ },
146
+ required: [
147
+ "cart",
148
+ "message",
149
+ "success"
150
+ ]
151
+ }),
152
+ ...messageErrors(merge ? ["400", "401"] : ["400"], t, failure),
153
+ ...errorResponses(["403"], t),
154
+ "404": jsonResponse(t("errorPluginEcommerce404"), { oneOf: [{
155
+ type: "object",
156
+ properties: {
157
+ cart: { type: ["object", "null"] },
158
+ ...failure.properties
159
+ },
160
+ required: [
161
+ "cart",
162
+ "message",
163
+ "success"
164
+ ]
165
+ }, { $ref: refTo(ERROR_SCHEMA_NAME) }] })
166
+ },
167
+ ...merge ? { security: securedRequirement() } : {}
168
+ };
169
+ });
170
+ const address = {
171
+ type: "object",
172
+ additionalProperties: true
173
+ };
174
+ const paymentBody = (extra) => ({
175
+ ...jsonBody({
176
+ type: "object",
177
+ additionalProperties: true,
178
+ properties: {
179
+ cartID: id,
180
+ secret,
181
+ customerEmail: {
182
+ type: "string",
183
+ format: "email"
184
+ },
185
+ billingAddress: address,
186
+ shippingAddress: address,
187
+ ...extra
188
+ },
189
+ ...Object.keys(extra).length > 0 ? { required: Object.keys(extra) } : {}
190
+ }),
191
+ description: t("ecommercePaymentBody")
192
+ });
193
+ const usedIds = /* @__PURE__ */ new Set();
194
+ const uniqueId = (base) => {
195
+ let operationId = base;
196
+ for (let n = 2; usedIds.has(operationId); n++) operationId = `${base}${n}`;
197
+ usedIds.add(operationId);
198
+ return operationId;
199
+ };
200
+ return [{ paths: mountEndpoints(config.endpoints, ctx.apiRoute, ({ method, path }) => {
201
+ if (method !== "post") return void 0;
202
+ if (path === "/payments/stripe/webhooks") return stripeWebhookOperation({
203
+ tag: TAG,
204
+ operationId: "ecommerceStripeWebhooks",
205
+ t
206
+ });
207
+ const match = PAYMENT_PATH.exec(path);
208
+ if (!match) return void 0;
209
+ const [, methodName = "", step] = match;
210
+ const stripe = methodName === "stripe";
211
+ const suffix = upperFirst(methodName.replace(/[^A-Za-z0-9]+(.)?/g, (_, c = "") => c.toUpperCase()));
212
+ if (step === "initiate") return {
213
+ tags: [TAG],
214
+ operationId: uniqueId(`initiatePayment${suffix}`),
215
+ summary: t("ecommerceInitiatePayment", { method: methodName }),
216
+ requestBody: paymentBody({}),
217
+ responses: {
218
+ "200": jsonResponse(t("ecommerceInitiateResult"), {
219
+ type: "object",
220
+ additionalProperties: true,
221
+ properties: {
222
+ message: { type: "string" },
223
+ ...stripe ? {
224
+ clientSecret: { type: "string" },
225
+ paymentIntentID: { type: "string" }
226
+ } : {}
227
+ },
228
+ required: ["message"]
229
+ }),
230
+ ...messageErrors([
231
+ "400",
232
+ "404",
233
+ "500"
234
+ ], t)
235
+ }
236
+ };
237
+ return {
238
+ tags: [TAG],
239
+ operationId: uniqueId(`confirmOrder${suffix}`),
240
+ summary: t("ecommerceConfirmOrder", { method: methodName }),
241
+ requestBody: paymentBody(stripe ? { paymentIntentID: { type: "string" } } : {}),
242
+ responses: {
243
+ "200": jsonResponse(t("ecommerceConfirmResult"), {
244
+ type: "object",
245
+ additionalProperties: true,
246
+ properties: {
247
+ message: { type: "string" },
248
+ orderID: id,
249
+ transactionID: id,
250
+ ...stripe ? { accessToken: { type: "string" } } : {}
251
+ },
252
+ required: [
253
+ "message",
254
+ "orderID",
255
+ "transactionID"
256
+ ]
257
+ }),
258
+ ...messageErrors([
259
+ "400",
260
+ "404",
261
+ "500"
262
+ ], t)
263
+ }
264
+ };
265
+ }) }, ...cartGroups];
266
+ }
267
+ };
268
+ export { ecommerce };
269
+
270
+ //# sourceMappingURL=ecommerce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecommerce.js","names":[],"sources":["../../../../src/server/spec/plugins/ecommerce.ts"],"sourcesContent":["import type { OperationObject, ParameterObject, SchemaObject } from '@scalar/openapi-types/3.2'\n\nimport { ERROR_SCHEMA_NAME, errorResponses, jsonBody, jsonResponse } from '@/server/spec/components.js'\nimport { refTo, schemaName } from '@/server/spec/names.js'\nimport { securedRequirement } from '@/server/spec/security.js'\nimport type { MessageKey } from '@/shared/translations/types.js'\nimport { upperFirst } from '@/shared/utils.js'\n\nimport { type OfficialPlugin, collectionGroups, idSchema, messageErrors, mountEndpoints } from './shared.js'\nimport { stripeWebhookOperation } from './stripe.js'\n\nconst TAG = 'Ecommerce'\n\nconst PAYMENT_PATH = /^\\/payments\\/([^/]+)\\/(initiate|confirm-order)$/\n\nconst CART_OPERATIONS: Record<string, { operationId: string; summary: MessageKey }> = {\n '/:id/add-item': { operationId: 'addItem', summary: 'ecommerceAddItem' },\n '/:id/remove-item': { operationId: 'removeItem', summary: 'ecommerceRemoveItem' },\n '/:id/update-item': { operationId: 'updateItem', summary: 'ecommerceUpdateItem' },\n '/:id/clear': { operationId: 'clear', summary: 'ecommerceClearCart' },\n '/:id/merge': { operationId: 'merge', summary: 'ecommerceMergeCart' },\n}\n\nexport const ecommerce: OfficialPlugin = {\n slug: '@payloadcms/plugin-ecommerce',\n tag: TAG,\n build: ({ config, collections, ctx, schemas, t }) => {\n const id = idSchema(ctx)\n const secret: SchemaObject = { type: 'string' }\n const failure: SchemaObject = {\n type: 'object',\n properties: { message: { type: 'string' }, success: { type: 'boolean', enum: [false] } },\n required: ['message', 'success'],\n }\n\n const cartBodies: Record<string, SchemaObject> = {\n '/:id/add-item': {\n type: 'object',\n properties: {\n item: {\n type: 'object',\n additionalProperties: true,\n properties: { product: id, variant: id },\n required: ['product'],\n },\n quantity: { type: 'number', default: 1 },\n secret,\n },\n required: ['item'],\n },\n '/:id/remove-item': {\n type: 'object',\n properties: { itemID: { type: 'string' }, secret },\n required: ['itemID'],\n },\n '/:id/update-item': {\n type: 'object',\n properties: {\n itemID: { type: 'string' },\n quantity: {\n description: t('ecommerceQuantity'),\n oneOf: [\n { type: 'number' },\n { type: 'object', properties: { $inc: { type: 'number' } }, required: ['$inc'] },\n ],\n },\n removeOnZero: { type: 'boolean', default: true },\n secret,\n },\n required: ['itemID', 'quantity'],\n },\n '/:id/clear': { type: 'object', properties: { secret } },\n '/:id/merge': {\n type: 'object',\n properties: { sourceCartID: id, sourceSecret: { type: 'string' } },\n required: ['sourceCartID', 'sourceSecret'],\n },\n }\n\n const cartGroups = collectionGroups(\n collections.filter((c) =>\n (c.endpoints || []).some((endpoint) => endpoint.method === 'post' && endpoint.path === '/:id/add-item'),\n ),\n ctx,\n ({ method, path }, collection): OperationObject | undefined => {\n const meta = CART_OPERATIONS[path]\n if (!meta || method !== 'post') return undefined\n const name = schemaName(collection.slug)\n const merge = path === '/:id/merge'\n const cart: SchemaObject = schemas[name]\n ? { $ref: refTo(name) }\n : { type: 'object', additionalProperties: true }\n const param: ParameterObject = { name: 'id', in: 'path', required: true, schema: id }\n return {\n tags: [TAG],\n operationId: `${meta.operationId}${name}`,\n summary: t(meta.summary),\n description: merge ? undefined : t('ecommerceCartAccess'),\n parameters: [param],\n requestBody: { ...jsonBody(cartBodies[path]!), required: path !== '/:id/clear' },\n responses: {\n '200': jsonResponse(t('ecommerceCartResult'), {\n type: 'object',\n properties: { cart, message: { type: 'string' }, success: { type: 'boolean', enum: [true] } },\n required: ['cart', 'message', 'success'],\n }),\n ...messageErrors(merge ? ['400', '401'] : ['400'], t, failure),\n ...errorResponses(['403'], t),\n '404': jsonResponse(t('errorPluginEcommerce404'), {\n oneOf: [\n {\n type: 'object',\n properties: { cart: { type: ['object', 'null'] }, ...failure.properties },\n required: ['cart', 'message', 'success'],\n },\n { $ref: refTo(ERROR_SCHEMA_NAME) },\n ],\n }),\n },\n ...(merge ? { security: securedRequirement() } : {}),\n }\n },\n )\n\n const address: SchemaObject = { type: 'object', additionalProperties: true }\n const paymentBody = (extra: Record<string, SchemaObject>) => ({\n ...jsonBody({\n type: 'object',\n additionalProperties: true,\n properties: {\n cartID: id,\n secret,\n customerEmail: { type: 'string', format: 'email' },\n billingAddress: address,\n shippingAddress: address,\n ...extra,\n },\n ...(Object.keys(extra).length > 0 ? { required: Object.keys(extra) } : {}),\n }),\n description: t('ecommercePaymentBody'),\n })\n\n const usedIds = new Set<string>()\n const uniqueId = (base: string) => {\n let operationId = base\n for (let n = 2; usedIds.has(operationId); n++) operationId = `${base}${n}`\n usedIds.add(operationId)\n return operationId\n }\n\n const payments = mountEndpoints(config.endpoints, ctx.apiRoute, ({ method, path }) => {\n if (method !== 'post') return undefined\n if (path === '/payments/stripe/webhooks') {\n return stripeWebhookOperation({ tag: TAG, operationId: 'ecommerceStripeWebhooks', t })\n }\n const match = PAYMENT_PATH.exec(path)\n if (!match) return undefined\n const [, methodName = '', step] = match\n const stripe = methodName === 'stripe'\n const suffix = upperFirst(methodName.replace(/[^A-Za-z0-9]+(.)?/g, (_, c: string = '') => c.toUpperCase()))\n if (step === 'initiate') {\n return {\n tags: [TAG],\n operationId: uniqueId(`initiatePayment${suffix}`),\n summary: t('ecommerceInitiatePayment', { method: methodName }),\n requestBody: paymentBody({}),\n responses: {\n '200': jsonResponse(t('ecommerceInitiateResult'), {\n type: 'object',\n additionalProperties: true,\n properties: {\n message: { type: 'string' },\n ...(stripe ? { clientSecret: { type: 'string' }, paymentIntentID: { type: 'string' } } : {}),\n },\n required: ['message'],\n }),\n ...messageErrors(['400', '404', '500'], t),\n },\n }\n }\n return {\n tags: [TAG],\n operationId: uniqueId(`confirmOrder${suffix}`),\n summary: t('ecommerceConfirmOrder', { method: methodName }),\n requestBody: paymentBody(stripe ? { paymentIntentID: { type: 'string' } } : {}),\n responses: {\n '200': jsonResponse(t('ecommerceConfirmResult'), {\n type: 'object',\n additionalProperties: true,\n properties: {\n message: { type: 'string' },\n orderID: id,\n transactionID: id,\n ...(stripe ? { accessToken: { type: 'string' } } : {}),\n },\n required: ['message', 'orderID', 'transactionID'],\n }),\n ...messageErrors(['400', '404', '500'], t),\n },\n }\n })\n\n return [{ paths: payments }, ...cartGroups]\n },\n}\n"],"mappings":";;;;;;AAWA,MAAM,MAAM;AAEZ,MAAM,eAAe;AAErB,MAAM,kBAAgF;CACpF,iBAAiB;EAAE,aAAa;EAAW,SAAS;CAAmB;CACvE,oBAAoB;EAAE,aAAa;EAAc,SAAS;CAAsB;CAChF,oBAAoB;EAAE,aAAa;EAAc,SAAS;CAAsB;CAChF,cAAc;EAAE,aAAa;EAAS,SAAS;CAAqB;CACpE,cAAc;EAAE,aAAa;EAAS,SAAS;CAAqB;AACtE;AAEA,MAAa,YAA4B;CACvC,MAAM;CACN,KAAK;CACL,QAAQ,EAAE,QAAQ,aAAa,KAAK,SAAS,QAAQ;EACnD,MAAM,KAAK,SAAS,GAAG;EACvB,MAAM,SAAuB,EAAE,MAAM,SAAS;EAC9C,MAAM,UAAwB;GAC5B,MAAM;GACN,YAAY;IAAE,SAAS,EAAE,MAAM,SAAS;IAAG,SAAS;KAAE,MAAM;KAAW,MAAM,CAAC,KAAK;IAAE;GAAE;GAC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,CAAC,SAAS;KACtB,CAAC;KACD,GAAG,cAAc;MAAC;MAAO;MAAO;KAAK,GAAG,CAAC;IAC3C;GACF;GAEF,OAAO;IACL,MAAM,CAAC,GAAG;IACV,aAAa,SAAS,eAAe,QAAQ;IAC7C,SAAS,EAAE,yBAAyB,EAAE,QAAQ,WAAW,CAAC;IAC1D,aAAa,YAAY,SAAS,EAAE,iBAAiB,EAAE,MAAM,SAAS,EAAE,IAAI,CAAC,CAAC;IAC9E,WAAW;KACT,OAAO,aAAa,EAAE,wBAAwB,GAAG;MAC/C,MAAM;MACN,sBAAsB;MACtB,YAAY;OACV,SAAS,EAAE,MAAM,SAAS;OAC1B,SAAS;OACT,eAAe;OACf,GAAI,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,EAAE,IAAI,CAAC;MACtD;MACA,UAAU;OAAC;OAAW;OAAW;MAAe;KAClD,CAAC;KACD,GAAG,cAAc;MAAC;MAAO;MAAO;KAAK,GAAG,CAAC;IAC3C;GACF;EACF,CAEwB,EAAE,GAAG,GAAG,UAAU;CAC5C;AACF"}
@@ -0,0 +1,3 @@
1
+ import { OfficialPlugin } from "./shared.js";
2
+ export declare const importExport: OfficialPlugin;
3
+ //# sourceMappingURL=importExport.d.ts.map
@@ -0,0 +1,202 @@
1
+ import { schemaName } from "../names.js";
2
+ import { errorResponses, jsonBody, jsonResponse } from "../components.js";
3
+ import { securedRequirement } from "../security.js";
4
+ import { collectionGroups, messageErrors } from "./shared.js";
5
+ const TAG = "Import/Export";
6
+ const targetSlugs = (collection) => {
7
+ const meta = (collection.admin?.custom)?.["plugin-import-export"];
8
+ return Array.isArray(meta?.collectionSlugs) ? meta.collectionSlugs : void 0;
9
+ };
10
+ const errorSchema = {
11
+ type: "object",
12
+ properties: { error: { type: "string" } },
13
+ required: ["error"]
14
+ };
15
+ const pageProperties = {
16
+ docs: {
17
+ type: "array",
18
+ items: {
19
+ type: "object",
20
+ additionalProperties: true
21
+ }
22
+ },
23
+ hasNextPage: { type: "boolean" },
24
+ hasPrevPage: { type: "boolean" },
25
+ limit: { type: "integer" },
26
+ maxLimit: { type: "integer" },
27
+ page: { type: "integer" },
28
+ totalDocs: { type: "integer" },
29
+ totalPages: { type: "integer" }
30
+ };
31
+ const previewPaging = {
32
+ previewLimit: {
33
+ type: "integer",
34
+ minimum: 1,
35
+ maximum: 100,
36
+ default: 10
37
+ },
38
+ previewPage: {
39
+ type: "integer",
40
+ minimum: 1,
41
+ default: 1
42
+ }
43
+ };
44
+ const format = {
45
+ type: "string",
46
+ enum: ["csv", "json"]
47
+ };
48
+ const drafts = {
49
+ type: "string",
50
+ enum: ["yes", "no"]
51
+ };
52
+ const query = {
53
+ fields: {
54
+ type: "array",
55
+ items: { type: "string" }
56
+ },
57
+ limit: {
58
+ type: "integer",
59
+ minimum: 0
60
+ },
61
+ locale: { type: "string" },
62
+ sort: { type: "string" },
63
+ where: {
64
+ type: "object",
65
+ additionalProperties: true
66
+ }
67
+ };
68
+ const importExport = {
69
+ slug: "@payloadcms/plugin-import-export",
70
+ tag: TAG,
71
+ build: ({ collections, ctx, t }) => {
72
+ const visible = new Set(collections.map((c) => c.slug));
73
+ return collectionGroups(collections, ctx, ({ method, path }, collection) => {
74
+ const slugs = targetSlugs(collection)?.filter((slug) => visible.has(slug));
75
+ if (!slugs || method !== "post") return void 0;
76
+ const name = schemaName(collection.slug);
77
+ const collectionSlug = {
78
+ type: "string",
79
+ ...slugs.length > 0 ? { enum: slugs } : {}
80
+ };
81
+ if (path === "/download") return {
82
+ tags: [TAG],
83
+ operationId: `download${name}`,
84
+ summary: t("exportDownload"),
85
+ requestBody: jsonBody({
86
+ type: "object",
87
+ properties: { data: {
88
+ type: "object",
89
+ additionalProperties: true,
90
+ properties: {
91
+ collectionSlug,
92
+ format,
93
+ name: { type: "string" },
94
+ ...query,
95
+ page: { type: "integer" },
96
+ drafts
97
+ },
98
+ required: ["collectionSlug", "format"]
99
+ } },
100
+ required: ["data"]
101
+ }),
102
+ responses: {
103
+ "200": {
104
+ description: t("exportDownloadResult"),
105
+ headers: { "Content-Disposition": { schema: { type: "string" } } },
106
+ content: {
107
+ "text/csv": { schema: { type: "string" } },
108
+ "application/json": { schema: {
109
+ type: "array",
110
+ items: {
111
+ type: "object",
112
+ additionalProperties: true
113
+ }
114
+ } }
115
+ }
116
+ },
117
+ ...errorResponses(["400"], t)
118
+ },
119
+ security: securedRequirement()
120
+ };
121
+ if (path === "/export-preview") return {
122
+ tags: [TAG],
123
+ operationId: `preview${name}`,
124
+ summary: t("exportPreview"),
125
+ requestBody: jsonBody({
126
+ type: "object",
127
+ additionalProperties: true,
128
+ properties: {
129
+ collectionSlug,
130
+ format,
131
+ ...query,
132
+ ...previewPaging,
133
+ draft: drafts
134
+ },
135
+ required: ["collectionSlug"]
136
+ }),
137
+ responses: {
138
+ "200": jsonResponse(t("previewResult"), {
139
+ type: "object",
140
+ properties: {
141
+ columns: {
142
+ type: "array",
143
+ items: { type: "string" }
144
+ },
145
+ exportTotalDocs: { type: "integer" },
146
+ ...pageProperties
147
+ },
148
+ required: [
149
+ "docs",
150
+ "page",
151
+ "limit",
152
+ "totalDocs",
153
+ "totalPages"
154
+ ]
155
+ }),
156
+ ...messageErrors(["400"], t, errorSchema)
157
+ }
158
+ };
159
+ if (path === "/preview-data") return {
160
+ tags: [TAG],
161
+ operationId: `preview${name}Data`,
162
+ summary: t("importPreview"),
163
+ requestBody: jsonBody({
164
+ type: "object",
165
+ additionalProperties: true,
166
+ properties: {
167
+ collectionSlug,
168
+ fileData: {
169
+ type: "string",
170
+ contentEncoding: "base64",
171
+ description: t("importFileData")
172
+ },
173
+ format,
174
+ ...previewPaging
175
+ },
176
+ required: ["collectionSlug", "fileData"]
177
+ }),
178
+ responses: {
179
+ "200": jsonResponse(t("previewResult"), {
180
+ type: "object",
181
+ properties: {
182
+ ...pageProperties,
183
+ limitExceeded: { type: "boolean" }
184
+ },
185
+ required: [
186
+ "docs",
187
+ "page",
188
+ "limit",
189
+ "totalDocs",
190
+ "totalPages",
191
+ "limitExceeded"
192
+ ]
193
+ }),
194
+ ...messageErrors(["400", "500"], t, errorSchema)
195
+ }
196
+ };
197
+ });
198
+ }
199
+ };
200
+ export { importExport };
201
+
202
+ //# sourceMappingURL=importExport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importExport.js","names":[],"sources":["../../../../src/server/spec/plugins/importExport.ts"],"sourcesContent":["import type { OperationObject, SchemaObject } from '@scalar/openapi-types/3.2'\nimport type { SanitizedCollectionConfig } from 'payload'\n\nimport { errorResponses, jsonBody, jsonResponse } from '@/server/spec/components.js'\nimport { schemaName } from '@/server/spec/names.js'\nimport { securedRequirement } from '@/server/spec/security.js'\n\nimport { type OfficialPlugin, collectionGroups, messageErrors } from './shared.js'\n\nconst TAG = 'Import/Export'\n\nconst targetSlugs = (collection: SanitizedCollectionConfig): string[] | undefined => {\n const meta = (collection.admin?.custom as Record<string, { collectionSlugs?: unknown } | undefined> | undefined)?.[\n 'plugin-import-export'\n ]\n return Array.isArray(meta?.collectionSlugs) ? (meta.collectionSlugs as string[]) : undefined\n}\n\nconst errorSchema: SchemaObject = { type: 'object', properties: { error: { type: 'string' } }, required: ['error'] }\n\nconst pageProperties: Record<string, SchemaObject> = {\n docs: { type: 'array', items: { type: 'object', additionalProperties: true } },\n hasNextPage: { type: 'boolean' },\n hasPrevPage: { type: 'boolean' },\n limit: { type: 'integer' },\n maxLimit: { type: 'integer' },\n page: { type: 'integer' },\n totalDocs: { type: 'integer' },\n totalPages: { type: 'integer' },\n}\n\nconst previewPaging: Record<string, SchemaObject> = {\n previewLimit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },\n previewPage: { type: 'integer', minimum: 1, default: 1 },\n}\n\nconst format: SchemaObject = { type: 'string', enum: ['csv', 'json'] }\nconst drafts: SchemaObject = { type: 'string', enum: ['yes', 'no'] }\n\nconst query: Record<string, SchemaObject> = {\n fields: { type: 'array', items: { type: 'string' } },\n limit: { type: 'integer', minimum: 0 },\n locale: { type: 'string' },\n sort: { type: 'string' },\n where: { type: 'object', additionalProperties: true },\n}\n\nexport const importExport: OfficialPlugin = {\n slug: '@payloadcms/plugin-import-export',\n tag: TAG,\n build: ({ collections, ctx, t }) => {\n const visible = new Set(collections.map((c) => c.slug))\n return collectionGroups(collections, ctx, ({ method, path }, collection): OperationObject | undefined => {\n const slugs = targetSlugs(collection)?.filter((slug) => visible.has(slug))\n if (!slugs || method !== 'post') return undefined\n const name = schemaName(collection.slug)\n const collectionSlug: SchemaObject = { type: 'string', ...(slugs.length > 0 ? { enum: slugs } : {}) }\n if (path === '/download') {\n return {\n tags: [TAG],\n operationId: `download${name}`,\n summary: t('exportDownload'),\n requestBody: jsonBody({\n type: 'object',\n properties: {\n data: {\n type: 'object',\n additionalProperties: true,\n properties: {\n collectionSlug,\n format,\n name: { type: 'string' },\n ...query,\n page: { type: 'integer' },\n drafts,\n },\n required: ['collectionSlug', 'format'],\n },\n },\n required: ['data'],\n }),\n responses: {\n '200': {\n description: t('exportDownloadResult'),\n headers: { 'Content-Disposition': { schema: { type: 'string' } } },\n content: {\n 'text/csv': { schema: { type: 'string' } },\n 'application/json': {\n schema: { type: 'array', items: { type: 'object', additionalProperties: true } },\n },\n },\n },\n ...errorResponses(['400'], t),\n },\n security: securedRequirement(),\n }\n }\n if (path === '/export-preview') {\n return {\n tags: [TAG],\n operationId: `preview${name}`,\n summary: t('exportPreview'),\n requestBody: jsonBody({\n type: 'object',\n additionalProperties: true,\n properties: { collectionSlug, format, ...query, ...previewPaging, draft: drafts },\n required: ['collectionSlug'],\n }),\n responses: {\n '200': jsonResponse(t('previewResult'), {\n type: 'object',\n properties: {\n columns: { type: 'array', items: { type: 'string' } },\n exportTotalDocs: { type: 'integer' },\n ...pageProperties,\n },\n required: ['docs', 'page', 'limit', 'totalDocs', 'totalPages'],\n }),\n ...messageErrors(['400'], t, errorSchema),\n },\n }\n }\n if (path === '/preview-data') {\n return {\n tags: [TAG],\n operationId: `preview${name}Data`,\n summary: t('importPreview'),\n requestBody: jsonBody({\n type: 'object',\n additionalProperties: true,\n properties: {\n collectionSlug,\n fileData: { type: 'string', contentEncoding: 'base64', description: t('importFileData') },\n format,\n ...previewPaging,\n },\n required: ['collectionSlug', 'fileData'],\n }),\n responses: {\n '200': jsonResponse(t('previewResult'), {\n type: 'object',\n properties: { ...pageProperties, limitExceeded: { type: 'boolean' } },\n required: ['docs', 'page', 'limit', 'totalDocs', 'totalPages', 'limitExceeded'],\n }),\n ...messageErrors(['400', '500'], t, errorSchema),\n },\n }\n }\n return undefined\n })\n },\n}\n"],"mappings":";;;;AASA,MAAM,MAAM;AAEZ,MAAM,eAAe,eAAgE;CACnF,MAAM,QAAQ,WAAW,OAAO,OAAA,GAC9B;CAEF,OAAO,MAAM,QAAQ,MAAM,eAAe,IAAK,KAAK,kBAA+B,KAAA;AACrF;AAEA,MAAM,cAA4B;CAAE,MAAM;CAAU,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,EAAE;CAAG,UAAU,CAAC,OAAO;AAAE;AAEnH,MAAM,iBAA+C;CACnD,MAAM;EAAE,MAAM;EAAS,OAAO;GAAE,MAAM;GAAU,sBAAsB;EAAK;CAAE;CAC7E,aAAa,EAAE,MAAM,UAAU;CAC/B,aAAa,EAAE,MAAM,UAAU;CAC/B,OAAO,EAAE,MAAM,UAAU;CACzB,UAAU,EAAE,MAAM,UAAU;CAC5B,MAAM,EAAE,MAAM,UAAU;CACxB,WAAW,EAAE,MAAM,UAAU;CAC7B,YAAY,EAAE,MAAM,UAAU;AAChC;AAEA,MAAM,gBAA8C;CAClD,cAAc;EAAE,MAAM;EAAW,SAAS;EAAG,SAAS;EAAK,SAAS;CAAG;CACvE,aAAa;EAAE,MAAM;EAAW,SAAS;EAAG,SAAS;CAAE;AACzD;AAEA,MAAM,SAAuB;CAAE,MAAM;CAAU,MAAM,CAAC,OAAO,MAAM;AAAE;AACrE,MAAM,SAAuB;CAAE,MAAM;CAAU,MAAM,CAAC,OAAO,IAAI;AAAE;AAE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AAC,OAAO,KAAK,GAAG,GAAG,WAAW;IACjD;GACF;EAGJ,CAAC;CACH;AACF"}
@@ -0,0 +1,3 @@
1
+ import { OfficialPlugin } from "./shared.js";
2
+ export declare const OFFICIAL_PLUGINS: OfficialPlugin[];
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { stripe } from "./stripe.js";
2
+ import { ecommerce } from "./ecommerce.js";
3
+ import { importExport } from "./importExport.js";
4
+ import { mcp } from "./mcp.js";
5
+ import { multiTenant } from "./multiTenant.js";
6
+ import { search } from "./search.js";
7
+ import { seo } from "./seo.js";
8
+ import { storageR2 } from "./storageR2.js";
9
+ const OFFICIAL_PLUGINS = [
10
+ ecommerce,
11
+ stripe,
12
+ mcp,
13
+ seo,
14
+ search,
15
+ multiTenant,
16
+ importExport,
17
+ storageR2
18
+ ];
19
+ export { OFFICIAL_PLUGINS };
20
+
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/server/spec/plugins/index.ts"],"sourcesContent":["import { ecommerce } from './ecommerce.js'\nimport { importExport } from './importExport.js'\nimport { mcp } from './mcp.js'\nimport { multiTenant } from './multiTenant.js'\nimport { search } from './search.js'\nimport { seo } from './seo.js'\nimport type { OfficialPlugin } from './shared.js'\nimport { storageR2 } from './storageR2.js'\nimport { stripe } from './stripe.js'\n\nexport const OFFICIAL_PLUGINS: OfficialPlugin[] = [\n ecommerce,\n stripe,\n mcp,\n seo,\n search,\n multiTenant,\n importExport,\n storageR2,\n]\n"],"mappings":";;;;;;;;AAUA,MAAa,mBAAqC;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -0,0 +1,3 @@
1
+ import { OfficialPlugin } from "./shared.js";
2
+ export declare const mcp: OfficialPlugin;
3
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1,118 @@
1
+ import { refTo } from "../names.js";
2
+ import { ERROR_SCHEMA_NAME, errorResponses, jsonBody, jsonResponse } from "../components.js";
3
+ import { mountEndpoints } from "./shared.js";
4
+ const TAG = "MCP";
5
+ const jsonRpcId = { type: [
6
+ "string",
7
+ "integer",
8
+ "null"
9
+ ] };
10
+ const jsonRpc = {
11
+ type: "object",
12
+ additionalProperties: true,
13
+ properties: {
14
+ jsonrpc: {
15
+ type: "string",
16
+ enum: ["2.0"]
17
+ },
18
+ id: jsonRpcId,
19
+ method: { type: "string" },
20
+ params: {
21
+ type: "object",
22
+ additionalProperties: true
23
+ },
24
+ result: {},
25
+ error: {
26
+ type: "object",
27
+ additionalProperties: true
28
+ }
29
+ },
30
+ required: ["jsonrpc"]
31
+ };
32
+ const jsonRpcBatch = { oneOf: [jsonRpc, {
33
+ type: "array",
34
+ items: jsonRpc
35
+ }] };
36
+ const jsonRpcError = {
37
+ type: "object",
38
+ properties: {
39
+ jsonrpc: {
40
+ type: "string",
41
+ enum: ["2.0"]
42
+ },
43
+ error: {
44
+ type: "object",
45
+ properties: {
46
+ code: { type: "integer" },
47
+ message: { type: "string" },
48
+ data: {}
49
+ },
50
+ required: ["code", "message"]
51
+ },
52
+ id: jsonRpcId
53
+ },
54
+ required: [
55
+ "jsonrpc",
56
+ "error",
57
+ "id"
58
+ ]
59
+ };
60
+ const mcp = {
61
+ slug: "@payloadcms/plugin-mcp",
62
+ tag: TAG,
63
+ build: ({ config, ctx, t }) => {
64
+ const rpcError = (description) => jsonResponse(description, jsonRpcError);
65
+ const post = {
66
+ tags: [TAG],
67
+ operationId: "mcp",
68
+ summary: t("mcp"),
69
+ description: t("mcpDesc"),
70
+ parameters: [{
71
+ name: "overrideAccess",
72
+ in: "query",
73
+ description: t("mcpOverrideAccess"),
74
+ schema: {
75
+ type: "string",
76
+ enum: ["true", "false"]
77
+ }
78
+ }, {
79
+ name: "MCP-Protocol-Version",
80
+ in: "header",
81
+ description: t("mcpProtocolVersion"),
82
+ schema: { type: "string" }
83
+ }],
84
+ requestBody: jsonBody(jsonRpcBatch),
85
+ responses: {
86
+ "200": jsonResponse(t("mcpResult"), jsonRpcBatch),
87
+ "202": { description: t("mcpResult202") },
88
+ "400": jsonResponse(t("errorPlugin400"), { oneOf: [jsonRpcError, { $ref: refTo(ERROR_SCHEMA_NAME) }] }),
89
+ ...errorResponses(["401"], t),
90
+ "404": rpcError(t("errorPluginMcp404")),
91
+ "406": rpcError(t("errorPluginMcp406")),
92
+ "413": rpcError(t("errorPluginMcp413")),
93
+ "415": rpcError(t("errorPluginMcp415")),
94
+ "500": rpcError(t("errorPlugin500"))
95
+ }
96
+ };
97
+ const get = {
98
+ tags: [TAG],
99
+ operationId: "mcpStream",
100
+ summary: t("mcpGet"),
101
+ responses: { "405": {
102
+ description: t("errorPluginMcpGet405"),
103
+ headers: { Allow: { schema: {
104
+ type: "string",
105
+ enum: ["POST"]
106
+ } } }
107
+ } }
108
+ };
109
+ return [{ paths: mountEndpoints(config.endpoints, ctx.apiRoute, ({ method, path }) => {
110
+ if (path !== "/mcp") return void 0;
111
+ if (method === "post") return post;
112
+ return method === "get" ? get : void 0;
113
+ }) }];
114
+ }
115
+ };
116
+ export { mcp };
117
+
118
+ //# sourceMappingURL=mcp.js.map