@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.
- package/README.md +72 -26
- package/dist/_tooling/telemetry.js +168 -0
- package/dist/_tooling/telemetry.js.map +1 -0
- package/dist/cli/generateSpec.d.ts +2 -0
- package/dist/cli/generateSpec.js +40 -0
- package/dist/cli/generateSpec.js.map +1 -0
- package/dist/index.d.ts +8 -9
- package/dist/index.js +76 -65
- package/dist/index.js.map +1 -0
- package/dist/{endpoints → server/endpoints}/interactiveAuth.d.ts +2 -2
- package/dist/server/endpoints/interactiveAuth.js +25 -0
- package/dist/server/endpoints/interactiveAuth.js.map +1 -0
- package/dist/server/endpoints/spec.d.ts +5 -0
- package/dist/server/endpoints/spec.js +39 -0
- package/dist/server/endpoints/spec.js.map +1 -0
- package/dist/server/options/resolveOptions.d.ts +4 -0
- package/dist/server/options/resolveOptions.js +65 -0
- package/dist/server/options/resolveOptions.js.map +1 -0
- package/dist/server/spec/build.d.ts +14 -0
- package/dist/server/spec/build.js +40 -0
- package/dist/server/spec/build.js.map +1 -0
- package/dist/server/spec/buildDocument.d.ts +16 -0
- package/dist/server/spec/buildDocument.js +340 -0
- package/dist/server/spec/buildDocument.js.map +1 -0
- package/dist/server/spec/components.d.ts +61 -0
- package/dist/server/spec/components.js +265 -0
- package/dist/server/spec/components.js.map +1 -0
- package/dist/{spec → server/spec}/downconvert.d.ts +2 -1
- package/dist/server/spec/downconvert.js +69 -0
- package/dist/server/spec/downconvert.js.map +1 -0
- package/dist/server/spec/entitySchemas.d.ts +15 -0
- package/dist/server/spec/entitySchemas.js +207 -0
- package/dist/server/spec/entitySchemas.js.map +1 -0
- package/dist/{spec → server/spec}/fields.d.ts +2 -1
- package/dist/server/spec/fields.js +47 -0
- package/dist/server/spec/fields.js.map +1 -0
- package/dist/server/spec/filters.d.ts +16 -0
- package/dist/server/spec/filters.js +102 -0
- package/dist/server/spec/filters.js.map +1 -0
- package/dist/server/spec/hierarchy.d.ts +11 -0
- package/dist/server/spec/hierarchy.js +43 -0
- package/dist/server/spec/hierarchy.js.map +1 -0
- package/dist/{spec → server/spec}/names.d.ts +2 -2
- package/dist/server/spec/names.js +43 -0
- package/dist/server/spec/names.js.map +1 -0
- package/dist/server/spec/params.d.ts +57 -0
- package/dist/server/spec/params.js +394 -0
- package/dist/server/spec/params.js.map +1 -0
- package/dist/server/spec/paths/auth.d.ts +10 -0
- package/dist/server/spec/paths/auth.js +190 -0
- package/dist/server/spec/paths/auth.js.map +1 -0
- package/dist/server/spec/paths/collections.d.ts +11 -0
- package/dist/server/spec/paths/collections.js +418 -0
- package/dist/server/spec/paths/collections.js.map +1 -0
- package/dist/server/spec/paths/custom.d.ts +12 -0
- package/dist/server/spec/paths/custom.js +42 -0
- package/dist/server/spec/paths/custom.js.map +1 -0
- package/dist/server/spec/paths/globals.d.ts +11 -0
- package/dist/server/spec/paths/globals.js +87 -0
- package/dist/server/spec/paths/globals.js.map +1 -0
- package/dist/server/spec/paths/jobs.d.ts +9 -0
- package/dist/server/spec/paths/jobs.js +98 -0
- package/dist/server/spec/paths/jobs.js.map +1 -0
- package/dist/server/spec/paths/system.d.ts +9 -0
- package/dist/server/spec/paths/system.js +203 -0
- package/dist/server/spec/paths/system.js.map +1 -0
- package/dist/server/spec/paths/versions.d.ts +22 -0
- package/dist/server/spec/paths/versions.js +185 -0
- package/dist/server/spec/paths/versions.js.map +1 -0
- package/dist/server/spec/plugins/ecommerce.d.ts +3 -0
- package/dist/server/spec/plugins/ecommerce.js +270 -0
- package/dist/server/spec/plugins/ecommerce.js.map +1 -0
- package/dist/server/spec/plugins/importExport.d.ts +3 -0
- package/dist/server/spec/plugins/importExport.js +202 -0
- package/dist/server/spec/plugins/importExport.js.map +1 -0
- package/dist/server/spec/plugins/index.d.ts +3 -0
- package/dist/server/spec/plugins/index.js +21 -0
- package/dist/server/spec/plugins/index.js.map +1 -0
- package/dist/server/spec/plugins/mcp.d.ts +3 -0
- package/dist/server/spec/plugins/mcp.js +118 -0
- package/dist/server/spec/plugins/mcp.js.map +1 -0
- package/dist/server/spec/plugins/multiTenant.d.ts +3 -0
- package/dist/server/spec/plugins/multiTenant.js +39 -0
- package/dist/server/spec/plugins/multiTenant.js.map +1 -0
- package/dist/server/spec/plugins/search.d.ts +3 -0
- package/dist/server/spec/plugins/search.js +43 -0
- package/dist/server/spec/plugins/search.js.map +1 -0
- package/dist/server/spec/plugins/seo.d.ts +3 -0
- package/dist/server/spec/plugins/seo.js +83 -0
- package/dist/server/spec/plugins/seo.js.map +1 -0
- package/dist/server/spec/plugins/shared.d.ts +35 -0
- package/dist/server/spec/plugins/shared.js +37 -0
- package/dist/server/spec/plugins/shared.js.map +1 -0
- package/dist/server/spec/plugins/storageR2.d.ts +3 -0
- package/dist/server/spec/plugins/storageR2.js +91 -0
- package/dist/server/spec/plugins/storageR2.js.map +1 -0
- package/dist/server/spec/plugins/stripe.d.ts +10 -0
- package/dist/server/spec/plugins/stripe.js +102 -0
- package/dist/server/spec/plugins/stripe.js.map +1 -0
- package/dist/server/spec/security.d.ts +34 -0
- package/dist/server/spec/security.js +100 -0
- package/dist/server/spec/security.js.map +1 -0
- package/dist/server/spec/tags.d.ts +37 -0
- package/dist/server/spec/tags.js +99 -0
- package/dist/server/spec/tags.js.map +1 -0
- package/dist/server/telemetry.d.ts +31 -0
- package/dist/server/telemetry.js +33 -0
- package/dist/server/telemetry.js.map +1 -0
- package/dist/server/ui/createUiPlugin.d.ts +16 -0
- package/dist/server/ui/createUiPlugin.js +33 -0
- package/dist/server/ui/createUiPlugin.js.map +1 -0
- package/dist/{ui → server/ui}/html.d.ts +5 -3
- package/dist/server/ui/html.js +11 -0
- package/dist/server/ui/html.js.map +1 -0
- package/dist/server/ui/scalar.d.ts +4 -0
- package/dist/server/ui/scalar.js +17 -0
- package/dist/server/ui/scalar.js.map +1 -0
- package/dist/server/ui/swagger.d.ts +4 -0
- package/dist/server/ui/swagger.js +18 -0
- package/dist/server/ui/swagger.js.map +1 -0
- package/dist/shared/constants.d.ts +4 -0
- package/dist/shared/constants.js +6 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/translations/index.d.ts +5 -0
- package/dist/{translations → shared/translations}/index.js +49 -47
- package/dist/shared/translations/index.js.map +1 -0
- package/dist/shared/translations/locales/ar.d.ts +3 -0
- package/dist/shared/translations/locales/ar.js +173 -0
- package/dist/shared/translations/locales/ar.js.map +1 -0
- package/dist/shared/translations/locales/az.d.ts +3 -0
- package/dist/shared/translations/locales/az.js +173 -0
- package/dist/shared/translations/locales/az.js.map +1 -0
- package/dist/shared/translations/locales/bg.d.ts +3 -0
- package/dist/shared/translations/locales/bg.js +173 -0
- package/dist/shared/translations/locales/bg.js.map +1 -0
- package/dist/shared/translations/locales/bnBd.d.ts +3 -0
- package/dist/shared/translations/locales/bnBd.js +173 -0
- package/dist/shared/translations/locales/bnBd.js.map +1 -0
- package/dist/shared/translations/locales/bnIn.d.ts +3 -0
- package/dist/shared/translations/locales/bnIn.js +173 -0
- package/dist/shared/translations/locales/bnIn.js.map +1 -0
- package/dist/shared/translations/locales/ca.d.ts +3 -0
- package/dist/shared/translations/locales/ca.js +173 -0
- package/dist/shared/translations/locales/ca.js.map +1 -0
- package/dist/shared/translations/locales/cs.d.ts +3 -0
- package/dist/shared/translations/locales/cs.js +173 -0
- package/dist/shared/translations/locales/cs.js.map +1 -0
- package/dist/shared/translations/locales/da.d.ts +3 -0
- package/dist/shared/translations/locales/da.js +173 -0
- package/dist/shared/translations/locales/da.js.map +1 -0
- package/dist/shared/translations/locales/de.d.ts +3 -0
- package/dist/shared/translations/locales/de.js +173 -0
- package/dist/shared/translations/locales/de.js.map +1 -0
- package/dist/shared/translations/locales/en.d.ts +3 -0
- package/dist/shared/translations/locales/en.js +173 -0
- package/dist/shared/translations/locales/en.js.map +1 -0
- package/dist/shared/translations/locales/es.d.ts +3 -0
- package/dist/shared/translations/locales/es.js +173 -0
- package/dist/shared/translations/locales/es.js.map +1 -0
- package/dist/shared/translations/locales/et.d.ts +3 -0
- package/dist/shared/translations/locales/et.js +173 -0
- package/dist/shared/translations/locales/et.js.map +1 -0
- package/dist/shared/translations/locales/fa.d.ts +3 -0
- package/dist/shared/translations/locales/fa.js +173 -0
- package/dist/shared/translations/locales/fa.js.map +1 -0
- package/dist/shared/translations/locales/fr.d.ts +3 -0
- package/dist/shared/translations/locales/fr.js +173 -0
- package/dist/shared/translations/locales/fr.js.map +1 -0
- package/dist/shared/translations/locales/he.d.ts +3 -0
- package/dist/shared/translations/locales/he.js +173 -0
- package/dist/shared/translations/locales/he.js.map +1 -0
- package/dist/shared/translations/locales/hr.d.ts +3 -0
- package/dist/shared/translations/locales/hr.js +173 -0
- package/dist/shared/translations/locales/hr.js.map +1 -0
- package/dist/shared/translations/locales/hu.d.ts +3 -0
- package/dist/shared/translations/locales/hu.js +173 -0
- package/dist/shared/translations/locales/hu.js.map +1 -0
- package/dist/shared/translations/locales/hy.d.ts +3 -0
- package/dist/shared/translations/locales/hy.js +173 -0
- package/dist/shared/translations/locales/hy.js.map +1 -0
- package/dist/shared/translations/locales/id.d.ts +3 -0
- package/dist/shared/translations/locales/id.js +173 -0
- package/dist/shared/translations/locales/id.js.map +1 -0
- package/dist/shared/translations/locales/is.d.ts +3 -0
- package/dist/shared/translations/locales/is.js +173 -0
- package/dist/shared/translations/locales/is.js.map +1 -0
- package/dist/shared/translations/locales/it.d.ts +3 -0
- package/dist/shared/translations/locales/it.js +173 -0
- package/dist/shared/translations/locales/it.js.map +1 -0
- package/dist/shared/translations/locales/ja.d.ts +3 -0
- package/dist/shared/translations/locales/ja.js +173 -0
- package/dist/shared/translations/locales/ja.js.map +1 -0
- package/dist/shared/translations/locales/ko.d.ts +3 -0
- package/dist/shared/translations/locales/ko.js +173 -0
- package/dist/shared/translations/locales/ko.js.map +1 -0
- package/dist/shared/translations/locales/lt.d.ts +3 -0
- package/dist/shared/translations/locales/lt.js +173 -0
- package/dist/shared/translations/locales/lt.js.map +1 -0
- package/dist/shared/translations/locales/lv.d.ts +3 -0
- package/dist/shared/translations/locales/lv.js +173 -0
- package/dist/shared/translations/locales/lv.js.map +1 -0
- package/dist/shared/translations/locales/my.d.ts +3 -0
- package/dist/shared/translations/locales/my.js +173 -0
- package/dist/shared/translations/locales/my.js.map +1 -0
- package/dist/shared/translations/locales/nb.d.ts +3 -0
- package/dist/shared/translations/locales/nb.js +173 -0
- package/dist/shared/translations/locales/nb.js.map +1 -0
- package/dist/shared/translations/locales/nl.d.ts +3 -0
- package/dist/shared/translations/locales/nl.js +173 -0
- package/dist/shared/translations/locales/nl.js.map +1 -0
- package/dist/shared/translations/locales/pl.d.ts +3 -0
- package/dist/shared/translations/locales/pl.js +173 -0
- package/dist/shared/translations/locales/pl.js.map +1 -0
- package/dist/shared/translations/locales/pt.d.ts +3 -0
- package/dist/shared/translations/locales/pt.js +173 -0
- package/dist/shared/translations/locales/pt.js.map +1 -0
- package/dist/shared/translations/locales/ro.d.ts +3 -0
- package/dist/shared/translations/locales/ro.js +173 -0
- package/dist/shared/translations/locales/ro.js.map +1 -0
- package/dist/shared/translations/locales/rs.d.ts +3 -0
- package/dist/shared/translations/locales/rs.js +173 -0
- package/dist/shared/translations/locales/rs.js.map +1 -0
- package/dist/shared/translations/locales/rsLatin.d.ts +3 -0
- package/dist/shared/translations/locales/rsLatin.js +173 -0
- package/dist/shared/translations/locales/rsLatin.js.map +1 -0
- package/dist/shared/translations/locales/ru.d.ts +3 -0
- package/dist/shared/translations/locales/ru.js +173 -0
- package/dist/shared/translations/locales/ru.js.map +1 -0
- package/dist/shared/translations/locales/sk.d.ts +3 -0
- package/dist/shared/translations/locales/sk.js +173 -0
- package/dist/shared/translations/locales/sk.js.map +1 -0
- package/dist/shared/translations/locales/sl.d.ts +3 -0
- package/dist/shared/translations/locales/sl.js +173 -0
- package/dist/shared/translations/locales/sl.js.map +1 -0
- package/dist/shared/translations/locales/sv.d.ts +3 -0
- package/dist/shared/translations/locales/sv.js +173 -0
- package/dist/shared/translations/locales/sv.js.map +1 -0
- package/dist/shared/translations/locales/ta.d.ts +3 -0
- package/dist/shared/translations/locales/ta.js +173 -0
- package/dist/shared/translations/locales/ta.js.map +1 -0
- package/dist/shared/translations/locales/th.d.ts +3 -0
- package/dist/shared/translations/locales/th.js +173 -0
- package/dist/shared/translations/locales/th.js.map +1 -0
- package/dist/shared/translations/locales/tr.d.ts +3 -0
- package/dist/shared/translations/locales/tr.js +173 -0
- package/dist/shared/translations/locales/tr.js.map +1 -0
- package/dist/shared/translations/locales/uk.d.ts +3 -0
- package/dist/shared/translations/locales/uk.js +173 -0
- package/dist/shared/translations/locales/uk.js.map +1 -0
- package/dist/shared/translations/locales/vi.d.ts +3 -0
- package/dist/shared/translations/locales/vi.js +173 -0
- package/dist/shared/translations/locales/vi.js.map +1 -0
- package/dist/shared/translations/locales/zh.d.ts +3 -0
- package/dist/shared/translations/locales/zh.js +173 -0
- package/dist/shared/translations/locales/zh.js.map +1 -0
- package/dist/shared/translations/locales/zhTw.d.ts +3 -0
- package/dist/shared/translations/locales/zhTw.js +173 -0
- package/dist/shared/translations/locales/zhTw.js.map +1 -0
- package/dist/shared/translations/types.d.ts +180 -0
- package/dist/shared/translations/types.js +1 -0
- package/dist/shared/types/index.d.ts +412 -0
- package/dist/shared/types/index.js +1 -0
- package/dist/{utils.d.ts → shared/utils.d.ts} +1 -0
- package/dist/shared/utils.js +13 -0
- package/dist/shared/utils.js.map +1 -0
- package/package.json +70 -39
- package/dist/bin/generateSpec.d.ts +0 -25
- package/dist/bin/generateSpec.js +0 -61
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -2
- package/dist/endpoints/interactiveAuth.js +0 -27
- package/dist/endpoints/spec.d.ts +0 -5
- package/dist/endpoints/spec.js +0 -39
- package/dist/options.d.ts +0 -2
- package/dist/options.js +0 -45
- package/dist/spec/build.d.ts +0 -14
- package/dist/spec/build.js +0 -36
- package/dist/spec/buildDocument.d.ts +0 -15
- package/dist/spec/buildDocument.js +0 -268
- package/dist/spec/components.d.ts +0 -44
- package/dist/spec/components.js +0 -265
- package/dist/spec/downconvert.js +0 -74
- package/dist/spec/entitySchemas.d.ts +0 -15
- package/dist/spec/entitySchemas.js +0 -250
- package/dist/spec/fields.js +0 -44
- package/dist/spec/filters.d.ts +0 -11
- package/dist/spec/filters.js +0 -83
- package/dist/spec/names.js +0 -37
- package/dist/spec/params.d.ts +0 -55
- package/dist/spec/params.js +0 -436
- package/dist/spec/paths/auth.d.ts +0 -9
- package/dist/spec/paths/auth.js +0 -274
- package/dist/spec/paths/collections.d.ts +0 -9
- package/dist/spec/paths/collections.js +0 -278
- package/dist/spec/paths/custom.d.ts +0 -9
- package/dist/spec/paths/custom.js +0 -41
- package/dist/spec/paths/globals.d.ts +0 -9
- package/dist/spec/paths/globals.js +0 -78
- package/dist/spec/paths/jobs.d.ts +0 -7
- package/dist/spec/paths/jobs.js +0 -130
- package/dist/spec/paths/versions.d.ts +0 -19
- package/dist/spec/paths/versions.js +0 -252
- package/dist/spec/security.d.ts +0 -19
- package/dist/spec/security.js +0 -96
- package/dist/spec/tags.d.ts +0 -27
- package/dist/spec/tags.js +0 -79
- package/dist/translations/index.d.ts +0 -6
- package/dist/translations/locales/ar.d.ts +0 -2
- package/dist/translations/locales/ar.js +0 -81
- package/dist/translations/locales/az.d.ts +0 -2
- package/dist/translations/locales/az.js +0 -81
- package/dist/translations/locales/bg.d.ts +0 -2
- package/dist/translations/locales/bg.js +0 -81
- package/dist/translations/locales/bnBd.d.ts +0 -2
- package/dist/translations/locales/bnBd.js +0 -81
- package/dist/translations/locales/bnIn.d.ts +0 -2
- package/dist/translations/locales/bnIn.js +0 -81
- package/dist/translations/locales/ca.d.ts +0 -2
- package/dist/translations/locales/ca.js +0 -81
- package/dist/translations/locales/cs.d.ts +0 -2
- package/dist/translations/locales/cs.js +0 -81
- package/dist/translations/locales/da.d.ts +0 -2
- package/dist/translations/locales/da.js +0 -81
- package/dist/translations/locales/de.d.ts +0 -2
- package/dist/translations/locales/de.js +0 -81
- package/dist/translations/locales/en.d.ts +0 -2
- package/dist/translations/locales/en.js +0 -81
- package/dist/translations/locales/es.d.ts +0 -2
- package/dist/translations/locales/es.js +0 -81
- package/dist/translations/locales/et.d.ts +0 -2
- package/dist/translations/locales/et.js +0 -81
- package/dist/translations/locales/fa.d.ts +0 -2
- package/dist/translations/locales/fa.js +0 -81
- package/dist/translations/locales/fr.d.ts +0 -2
- package/dist/translations/locales/fr.js +0 -81
- package/dist/translations/locales/he.d.ts +0 -2
- package/dist/translations/locales/he.js +0 -81
- package/dist/translations/locales/hr.d.ts +0 -2
- package/dist/translations/locales/hr.js +0 -81
- package/dist/translations/locales/hu.d.ts +0 -2
- package/dist/translations/locales/hu.js +0 -81
- package/dist/translations/locales/hy.d.ts +0 -2
- package/dist/translations/locales/hy.js +0 -81
- package/dist/translations/locales/id.d.ts +0 -2
- package/dist/translations/locales/id.js +0 -81
- package/dist/translations/locales/is.d.ts +0 -2
- package/dist/translations/locales/is.js +0 -81
- package/dist/translations/locales/it.d.ts +0 -2
- package/dist/translations/locales/it.js +0 -81
- package/dist/translations/locales/ja.d.ts +0 -2
- package/dist/translations/locales/ja.js +0 -81
- package/dist/translations/locales/ko.d.ts +0 -2
- package/dist/translations/locales/ko.js +0 -81
- package/dist/translations/locales/lt.d.ts +0 -2
- package/dist/translations/locales/lt.js +0 -81
- package/dist/translations/locales/lv.d.ts +0 -2
- package/dist/translations/locales/lv.js +0 -81
- package/dist/translations/locales/my.d.ts +0 -2
- package/dist/translations/locales/my.js +0 -81
- package/dist/translations/locales/nb.d.ts +0 -2
- package/dist/translations/locales/nb.js +0 -81
- package/dist/translations/locales/nl.d.ts +0 -2
- package/dist/translations/locales/nl.js +0 -81
- package/dist/translations/locales/pl.d.ts +0 -2
- package/dist/translations/locales/pl.js +0 -81
- package/dist/translations/locales/pt.d.ts +0 -2
- package/dist/translations/locales/pt.js +0 -81
- package/dist/translations/locales/ro.d.ts +0 -2
- package/dist/translations/locales/ro.js +0 -81
- package/dist/translations/locales/rs.d.ts +0 -2
- package/dist/translations/locales/rs.js +0 -81
- package/dist/translations/locales/rsLatin.d.ts +0 -2
- package/dist/translations/locales/rsLatin.js +0 -81
- package/dist/translations/locales/ru.d.ts +0 -2
- package/dist/translations/locales/ru.js +0 -81
- package/dist/translations/locales/sk.d.ts +0 -2
- package/dist/translations/locales/sk.js +0 -81
- package/dist/translations/locales/sl.d.ts +0 -2
- package/dist/translations/locales/sl.js +0 -81
- package/dist/translations/locales/sv.d.ts +0 -2
- package/dist/translations/locales/sv.js +0 -81
- package/dist/translations/locales/ta.d.ts +0 -2
- package/dist/translations/locales/ta.js +0 -81
- package/dist/translations/locales/th.d.ts +0 -2
- package/dist/translations/locales/th.js +0 -81
- package/dist/translations/locales/tr.d.ts +0 -2
- package/dist/translations/locales/tr.js +0 -81
- package/dist/translations/locales/uk.d.ts +0 -2
- package/dist/translations/locales/uk.js +0 -81
- package/dist/translations/locales/vi.d.ts +0 -2
- package/dist/translations/locales/vi.js +0 -81
- package/dist/translations/locales/zh.d.ts +0 -2
- package/dist/translations/locales/zh.js +0 -81
- package/dist/translations/locales/zhTw.d.ts +0 -2
- package/dist/translations/locales/zhTw.js +0 -81
- package/dist/translations/types.d.ts +0 -87
- package/dist/translations/types.js +0 -1
- package/dist/types.d.ts +0 -192
- package/dist/types.js +0 -1
- package/dist/ui/createUiPlugin.d.ts +0 -14
- package/dist/ui/createUiPlugin.js +0 -28
- package/dist/ui/html.js +0 -8
- package/dist/ui/scalar.d.ts +0 -1
- package/dist/ui/scalar.js +0 -12
- package/dist/ui/swagger.d.ts +0 -1
- package/dist/ui/swagger.js +0 -12
- package/dist/utils.js +0 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","names":[],"sources":["../../../../src/server/spec/plugins/mcp.ts"],"sourcesContent":["import type { OperationObject, SchemaObject } from '@scalar/openapi-types/3.2'\n\nimport { ERROR_SCHEMA_NAME, errorResponses, jsonBody, jsonResponse } from '@/server/spec/components.js'\nimport { refTo } from '@/server/spec/names.js'\n\nimport { type OfficialPlugin, mountEndpoints } from './shared.js'\n\nconst TAG = 'MCP'\n\nconst jsonRpcId: SchemaObject = { type: ['string', 'integer', 'null'] }\n\nconst jsonRpc: SchemaObject = {\n type: 'object',\n additionalProperties: true,\n properties: {\n jsonrpc: { type: 'string', enum: ['2.0'] },\n id: jsonRpcId,\n method: { type: 'string' },\n params: { type: 'object', additionalProperties: true },\n result: {},\n error: { type: 'object', additionalProperties: true },\n },\n required: ['jsonrpc'],\n}\n\nconst jsonRpcBatch: SchemaObject = { oneOf: [jsonRpc, { type: 'array', items: jsonRpc }] }\n\nconst jsonRpcError: SchemaObject = {\n type: 'object',\n properties: {\n jsonrpc: { type: 'string', enum: ['2.0'] },\n error: {\n type: 'object',\n properties: { code: { type: 'integer' }, message: { type: 'string' }, data: {} },\n required: ['code', 'message'],\n },\n id: jsonRpcId,\n },\n required: ['jsonrpc', 'error', 'id'],\n}\n\nexport const mcp: OfficialPlugin = {\n slug: '@payloadcms/plugin-mcp',\n tag: TAG,\n build: ({ config, ctx, t }) => {\n const rpcError = (description: string) => jsonResponse(description, jsonRpcError)\n const post: OperationObject = {\n tags: [TAG],\n operationId: 'mcp',\n summary: t('mcp'),\n description: t('mcpDesc'),\n parameters: [\n {\n name: 'overrideAccess',\n in: 'query',\n description: t('mcpOverrideAccess'),\n schema: { type: 'string', enum: ['true', 'false'] },\n },\n {\n name: 'MCP-Protocol-Version',\n in: 'header',\n description: t('mcpProtocolVersion'),\n schema: { type: 'string' },\n },\n ],\n requestBody: jsonBody(jsonRpcBatch),\n responses: {\n '200': jsonResponse(t('mcpResult'), jsonRpcBatch),\n '202': { description: t('mcpResult202') },\n '400': jsonResponse(t('errorPlugin400'), { oneOf: [jsonRpcError, { $ref: refTo(ERROR_SCHEMA_NAME) }] }),\n ...errorResponses(['401'], t),\n '404': rpcError(t('errorPluginMcp404')),\n '406': rpcError(t('errorPluginMcp406')),\n '413': rpcError(t('errorPluginMcp413')),\n '415': rpcError(t('errorPluginMcp415')),\n '500': rpcError(t('errorPlugin500')),\n },\n }\n const get: OperationObject = {\n tags: [TAG],\n operationId: 'mcpStream',\n summary: t('mcpGet'),\n responses: {\n '405': {\n description: t('errorPluginMcpGet405'),\n headers: { Allow: { schema: { type: 'string', enum: ['POST'] } } },\n },\n },\n }\n return [\n {\n paths: mountEndpoints(config.endpoints, ctx.apiRoute, ({ method, path }) => {\n if (path !== '/mcp') return undefined\n if (method === 'post') return post\n return method === 'get' ? get : undefined\n }),\n },\n ]\n },\n}\n"],"mappings":";;;AAOA,MAAM,MAAM;AAEZ,MAAM,YAA0B,EAAE,MAAM;CAAC;CAAU;CAAW;AAAM,EAAE;AAEtE,MAAM,UAAwB;CAC5B,MAAM;CACN,sBAAsB;CACtB,YAAY;EACV,SAAS;GAAE,MAAM;GAAU,MAAM,CAAC,KAAK;EAAE;EACzC,IAAI;EACJ,QAAQ,EAAE,MAAM,SAAS;EACzB,QAAQ;GAAE,MAAM;GAAU,sBAAsB;EAAK;EACrD,QAAQ,CAAC;EACT,OAAO;GAAE,MAAM;GAAU,sBAAsB;EAAK;CACtD;CACA,UAAU,CAAC,SAAS;AACtB;AAEA,MAAM,eAA6B,EAAE,OAAO,CAAC,SAAS;CAAE,MAAM;CAAS,OAAO;AAAQ,CAAC,EAAE;AAEzF,MAAM,eAA6B;CACjC,MAAM;CACN,YAAY;EACV,SAAS;GAAE,MAAM;GAAU,MAAM,CAAC,KAAK;EAAE;EACzC,OAAO;GACL,MAAM;GACN,YAAY;IAAE,MAAM,EAAE,MAAM,UAAU;IAAG,SAAS,EAAE,MAAM,SAAS;IAAG,MAAM,CAAC;GAAE;GAC/E,UAAU,CAAC,QAAQ,SAAS;EAC9B;EACA,IAAI;CACN;CACA,UAAU;EAAC;EAAW;EAAS;CAAI;AACrC;AAEA,MAAa,MAAsB;CACjC,MAAM;CACN,KAAK;CACL,QAAQ,EAAE,QAAQ,KAAK,QAAQ;EAC7B,MAAM,YAAY,gBAAwB,aAAa,aAAa,YAAY;EAChF,MAAM,OAAwB;GAC5B,MAAM,CAAC,GAAG;GACV,aAAa;GACb,SAAS,EAAE,KAAK;GAChB,aAAa,EAAE,SAAS;GACxB,YAAY,CACV;IACE,MAAM;IACN,IAAI;IACJ,aAAa,EAAE,mBAAmB;IAClC,QAAQ;KAAE,MAAM;KAAU,MAAM,CAAC,QAAQ,OAAO;IAAE;GACpD,GACA;IACE,MAAM;IACN,IAAI;IACJ,aAAa,EAAE,oBAAoB;IACnC,QAAQ,EAAE,MAAM,SAAS;GAC3B,CACF;GACA,aAAa,SAAS,YAAY;GAClC,WAAW;IACT,OAAO,aAAa,EAAE,WAAW,GAAG,YAAY;IAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE;IACxC,OAAO,aAAa,EAAE,gBAAgB,GAAG,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,MAAM,iBAAiB,EAAE,CAAC,EAAE,CAAC;IACtG,GAAG,eAAe,CAAC,KAAK,GAAG,CAAC;IAC5B,OAAO,SAAS,EAAE,mBAAmB,CAAC;IACtC,OAAO,SAAS,EAAE,mBAAmB,CAAC;IACtC,OAAO,SAAS,EAAE,mBAAmB,CAAC;IACtC,OAAO,SAAS,EAAE,mBAAmB,CAAC;IACtC,OAAO,SAAS,EAAE,gBAAgB,CAAC;GACrC;EACF;EACA,MAAM,MAAuB;GAC3B,MAAM,CAAC,GAAG;GACV,aAAa;GACb,SAAS,EAAE,QAAQ;GACnB,WAAW,EACT,OAAO;IACL,aAAa,EAAE,sBAAsB;IACrC,SAAS,EAAE,OAAO,EAAE,QAAQ;KAAE,MAAM;KAAU,MAAM,CAAC,MAAM;IAAE,EAAE,EAAE;GACnE,EACF;EACF;EACA,OAAO,CACL,EACE,OAAO,eAAe,OAAO,WAAW,IAAI,WAAW,EAAE,QAAQ,WAAW;GAC1E,IAAI,SAAS,QAAQ,OAAO,KAAA;GAC5B,IAAI,WAAW,QAAQ,OAAO;GAC9B,OAAO,WAAW,QAAQ,MAAM,KAAA;EAClC,CAAC,EACH,CACF;CACF;AACF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { schemaName } from "../names.js";
|
|
2
|
+
import { errorResponses, jsonResponse } from "../components.js";
|
|
3
|
+
import { securedRequirement } from "../security.js";
|
|
4
|
+
import { collectionGroups } from "./shared.js";
|
|
5
|
+
const TAG = "Multi-tenant";
|
|
6
|
+
const multiTenant = {
|
|
7
|
+
slug: "@payloadcms/plugin-multi-tenant",
|
|
8
|
+
tag: TAG,
|
|
9
|
+
build: ({ collections, ctx, options, t }) => {
|
|
10
|
+
const tenantsSlug = options?.tenantsSlug || "tenants";
|
|
11
|
+
return collectionGroups(collections.filter((c) => c.slug === tenantsSlug), ctx, ({ method, path }, collection) => method === "get" && path === "/populate-tenant-options" ? {
|
|
12
|
+
tags: [TAG],
|
|
13
|
+
operationId: `populate${schemaName(collection.slug)}Options`,
|
|
14
|
+
summary: t("tenantOptions"),
|
|
15
|
+
responses: {
|
|
16
|
+
"200": jsonResponse(t("tenantOptionsResult"), {
|
|
17
|
+
type: "object",
|
|
18
|
+
properties: { tenantOptions: {
|
|
19
|
+
type: "array",
|
|
20
|
+
items: {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {
|
|
23
|
+
label: { type: "string" },
|
|
24
|
+
value: { oneOf: [{ type: "string" }, { type: "number" }] }
|
|
25
|
+
},
|
|
26
|
+
required: ["label", "value"]
|
|
27
|
+
}
|
|
28
|
+
} },
|
|
29
|
+
required: ["tenantOptions"]
|
|
30
|
+
}),
|
|
31
|
+
...errorResponses(["401"], t)
|
|
32
|
+
},
|
|
33
|
+
security: securedRequirement()
|
|
34
|
+
} : void 0);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export { multiTenant };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=multiTenant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiTenant.js","names":[],"sources":["../../../../src/server/spec/plugins/multiTenant.ts"],"sourcesContent":["import { errorResponses, 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 } from './shared.js'\n\nconst TAG = 'Multi-tenant'\n\nexport const multiTenant: OfficialPlugin = {\n slug: '@payloadcms/plugin-multi-tenant',\n tag: TAG,\n build: ({ collections, ctx, options, t }) => {\n const tenantsSlug = (options?.tenantsSlug as string | undefined) || 'tenants'\n return collectionGroups(\n collections.filter((c) => c.slug === tenantsSlug),\n ctx,\n ({ method, path }, collection) =>\n method === 'get' && path === '/populate-tenant-options'\n ? {\n tags: [TAG],\n operationId: `populate${schemaName(collection.slug)}Options`,\n summary: t('tenantOptions'),\n responses: {\n '200': jsonResponse(t('tenantOptionsResult'), {\n type: 'object',\n properties: {\n tenantOptions: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n label: { type: 'string' },\n value: { oneOf: [{ type: 'string' }, { type: 'number' }] },\n },\n required: ['label', 'value'],\n },\n },\n },\n required: ['tenantOptions'],\n }),\n ...errorResponses(['401'], t),\n },\n security: securedRequirement(),\n }\n : undefined,\n )\n },\n}\n"],"mappings":";;;;AAMA,MAAM,MAAM;AAEZ,MAAa,cAA8B;CACzC,MAAM;CACN,KAAK;CACL,QAAQ,EAAE,aAAa,KAAK,SAAS,QAAQ;EAC3C,MAAM,cAAe,SAAS,eAAsC;EACpE,OAAO,iBACL,YAAY,QAAQ,MAAM,EAAE,SAAS,WAAW,GAChD,MACC,EAAE,QAAQ,QAAQ,eACjB,WAAW,SAAS,SAAS,6BACzB;GACE,MAAM,CAAC,GAAG;GACV,aAAa,WAAW,WAAW,WAAW,IAAI,EAAE;GACpD,SAAS,EAAE,eAAe;GAC1B,WAAW;IACT,OAAO,aAAa,EAAE,qBAAqB,GAAG;KAC5C,MAAM;KACN,YAAY,EACV,eAAe;MACb,MAAM;MACN,OAAO;OACL,MAAM;OACN,YAAY;QACV,OAAO,EAAE,MAAM,SAAS;QACxB,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,SAAS,GAAG,EAAE,MAAM,SAAS,CAAC,EAAE;OAC3D;OACA,UAAU,CAAC,SAAS,OAAO;MAC7B;KACF,EACF;KACA,UAAU,CAAC,eAAe;IAC5B,CAAC;IACD,GAAG,eAAe,CAAC,KAAK,GAAG,CAAC;GAC9B;GACA,UAAU,mBAAmB;EAC/B,IACA,KAAA,CACR;CACF;AACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { schemaName } from "../names.js";
|
|
2
|
+
import { jsonBody, jsonResponse } from "../components.js";
|
|
3
|
+
import { securedRequirement } from "../security.js";
|
|
4
|
+
import { collectionGroups, messageErrors, messageSchema } from "./shared.js";
|
|
5
|
+
const TAG = "Search";
|
|
6
|
+
const search = {
|
|
7
|
+
slug: "@payloadcms/plugin-search",
|
|
8
|
+
tag: TAG,
|
|
9
|
+
build: ({ collections, ctx, options, t }) => {
|
|
10
|
+
const searchSlug = (options?.searchOverrides)?.slug || "search";
|
|
11
|
+
const visible = new Set(collections.map((c) => c.slug));
|
|
12
|
+
const indexed = Array.isArray(options?.collections) ? options.collections.filter((slug) => visible.has(slug)) : [];
|
|
13
|
+
return collectionGroups(collections.filter((c) => c.slug === searchSlug), ctx, ({ method, path }, collection) => method === "post" && path === "/reindex" ? {
|
|
14
|
+
tags: [TAG],
|
|
15
|
+
operationId: `reindex${schemaName(collection.slug)}`,
|
|
16
|
+
summary: t("searchReindex"),
|
|
17
|
+
requestBody: jsonBody({
|
|
18
|
+
type: "object",
|
|
19
|
+
properties: { collections: {
|
|
20
|
+
type: "array",
|
|
21
|
+
minItems: 1,
|
|
22
|
+
items: {
|
|
23
|
+
type: "string",
|
|
24
|
+
...indexed.length > 0 ? { enum: indexed } : {}
|
|
25
|
+
}
|
|
26
|
+
} },
|
|
27
|
+
required: ["collections"]
|
|
28
|
+
}),
|
|
29
|
+
responses: {
|
|
30
|
+
"200": jsonResponse(t("searchReindexResult"), messageSchema),
|
|
31
|
+
...messageErrors([
|
|
32
|
+
"400",
|
|
33
|
+
"401",
|
|
34
|
+
"500"
|
|
35
|
+
], t)
|
|
36
|
+
},
|
|
37
|
+
security: securedRequirement()
|
|
38
|
+
} : void 0);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export { search };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","names":[],"sources":["../../../../src/server/spec/plugins/search.ts"],"sourcesContent":["import { 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, messageSchema } from './shared.js'\n\nconst TAG = 'Search'\n\nexport const search: OfficialPlugin = {\n slug: '@payloadcms/plugin-search',\n tag: TAG,\n build: ({ collections, ctx, options, t }) => {\n const overrides = options?.searchOverrides as { slug?: string } | undefined\n const searchSlug = overrides?.slug || 'search'\n const visible = new Set(collections.map((c) => c.slug))\n const indexed = Array.isArray(options?.collections)\n ? (options.collections as string[]).filter((slug) => visible.has(slug))\n : []\n return collectionGroups(\n collections.filter((c) => c.slug === searchSlug),\n ctx,\n ({ method, path }, collection) =>\n method === 'post' && path === '/reindex'\n ? {\n tags: [TAG],\n operationId: `reindex${schemaName(collection.slug)}`,\n summary: t('searchReindex'),\n requestBody: jsonBody({\n type: 'object',\n properties: {\n collections: {\n type: 'array',\n minItems: 1,\n items: { type: 'string', ...(indexed.length > 0 ? { enum: indexed } : {}) },\n },\n },\n required: ['collections'],\n }),\n responses: {\n '200': jsonResponse(t('searchReindexResult'), messageSchema),\n ...messageErrors(['400', '401', '500'], t),\n },\n security: securedRequirement(),\n }\n : undefined,\n )\n },\n}\n"],"mappings":";;;;AAMA,MAAM,MAAM;AAEZ,MAAa,SAAyB;CACpC,MAAM;CACN,KAAK;CACL,QAAQ,EAAE,aAAa,KAAK,SAAS,QAAQ;EAE3C,MAAM,cADY,SAAS,gBAAA,EACG,QAAQ;EACtC,MAAM,UAAU,IAAI,IAAI,YAAY,KAAK,MAAM,EAAE,IAAI,CAAC;EACtD,MAAM,UAAU,MAAM,QAAQ,SAAS,WAAW,IAC7C,QAAQ,YAAyB,QAAQ,SAAS,QAAQ,IAAI,IAAI,CAAC,IACpE,CAAC;EACL,OAAO,iBACL,YAAY,QAAQ,MAAM,EAAE,SAAS,UAAU,GAC/C,MACC,EAAE,QAAQ,QAAQ,eACjB,WAAW,UAAU,SAAS,aAC1B;GACE,MAAM,CAAC,GAAG;GACV,aAAa,UAAU,WAAW,WAAW,IAAI;GACjD,SAAS,EAAE,eAAe;GAC1B,aAAa,SAAS;IACpB,MAAM;IACN,YAAY,EACV,aAAa;KACX,MAAM;KACN,UAAU;KACV,OAAO;MAAE,MAAM;MAAU,GAAI,QAAQ,SAAS,IAAI,EAAE,MAAM,QAAQ,IAAI,CAAC;KAAG;IAC5E,EACF;IACA,UAAU,CAAC,aAAa;GAC1B,CAAC;GACD,WAAW;IACT,OAAO,aAAa,EAAE,qBAAqB,GAAG,aAAa;IAC3D,GAAG,cAAc;KAAC;KAAO;KAAO;IAAK,GAAG,CAAC;GAC3C;GACA,UAAU,mBAAmB;EAC/B,IACA,KAAA,CACR;CACF;AACF"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { errorResponses, jsonBody, jsonResponse } from "../components.js";
|
|
2
|
+
import { securedRequirement } from "../security.js";
|
|
3
|
+
import { idSchema, mountEndpoints } from "./shared.js";
|
|
4
|
+
const TAG = "SEO";
|
|
5
|
+
const GENERATORS = {
|
|
6
|
+
"/plugin-seo/generate-title": {
|
|
7
|
+
operationId: "seoGenerateTitle",
|
|
8
|
+
summary: "seoTitle"
|
|
9
|
+
},
|
|
10
|
+
"/plugin-seo/generate-description": {
|
|
11
|
+
operationId: "seoGenerateDescription",
|
|
12
|
+
summary: "seoDescription"
|
|
13
|
+
},
|
|
14
|
+
"/plugin-seo/generate-url": {
|
|
15
|
+
operationId: "seoGenerateUrl",
|
|
16
|
+
summary: "seoUrl"
|
|
17
|
+
},
|
|
18
|
+
"/plugin-seo/generate-image": {
|
|
19
|
+
operationId: "seoGenerateImage",
|
|
20
|
+
summary: "seoImage",
|
|
21
|
+
image: true
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const seo = {
|
|
25
|
+
slug: "@payloadcms/plugin-seo",
|
|
26
|
+
tag: TAG,
|
|
27
|
+
build: ({ config, ctx, t }) => {
|
|
28
|
+
const id = idSchema(ctx);
|
|
29
|
+
const operation = (path) => {
|
|
30
|
+
const generator = GENERATORS[path];
|
|
31
|
+
if (!generator) return void 0;
|
|
32
|
+
const result = generator.image ? { oneOf: [
|
|
33
|
+
{ type: "string" },
|
|
34
|
+
{ type: "number" },
|
|
35
|
+
{
|
|
36
|
+
type: "object",
|
|
37
|
+
additionalProperties: true
|
|
38
|
+
}
|
|
39
|
+
] } : { type: "string" };
|
|
40
|
+
return {
|
|
41
|
+
tags: [TAG],
|
|
42
|
+
operationId: generator.operationId,
|
|
43
|
+
summary: t(generator.summary),
|
|
44
|
+
requestBody: {
|
|
45
|
+
...jsonBody({
|
|
46
|
+
type: "object",
|
|
47
|
+
additionalProperties: true,
|
|
48
|
+
properties: {
|
|
49
|
+
id: { oneOf: [{ type: "string" }, { type: "number" }] },
|
|
50
|
+
collectionSlug: { type: "string" },
|
|
51
|
+
globalSlug: { type: "string" },
|
|
52
|
+
doc: {
|
|
53
|
+
type: "object",
|
|
54
|
+
additionalProperties: true,
|
|
55
|
+
properties: { id }
|
|
56
|
+
},
|
|
57
|
+
locale: { type: "string" },
|
|
58
|
+
title: { type: "string" }
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
description: t("seoBody")
|
|
62
|
+
},
|
|
63
|
+
responses: {
|
|
64
|
+
"200": jsonResponse(t("seoResult"), {
|
|
65
|
+
type: "object",
|
|
66
|
+
properties: { result },
|
|
67
|
+
required: ["result"]
|
|
68
|
+
}),
|
|
69
|
+
...errorResponses([
|
|
70
|
+
"401",
|
|
71
|
+
"403",
|
|
72
|
+
"500"
|
|
73
|
+
], t)
|
|
74
|
+
},
|
|
75
|
+
security: securedRequirement()
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
return [{ paths: mountEndpoints(config.endpoints, ctx.apiRoute, (endpoint) => endpoint.method === "post" ? operation(endpoint.path) : void 0) }];
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
export { seo };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=seo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seo.js","names":[],"sources":["../../../../src/server/spec/plugins/seo.ts"],"sourcesContent":["import type { OperationObject, SchemaObject } from '@scalar/openapi-types/3.2'\n\nimport { errorResponses, jsonBody, jsonResponse } from '@/server/spec/components.js'\nimport { securedRequirement } from '@/server/spec/security.js'\nimport type { MessageKey } from '@/shared/translations/types.js'\n\nimport { type OfficialPlugin, idSchema, mountEndpoints } from './shared.js'\n\nconst TAG = 'SEO'\n\nconst GENERATORS: Record<string, { operationId: string; summary: MessageKey; image?: boolean }> = {\n '/plugin-seo/generate-title': { operationId: 'seoGenerateTitle', summary: 'seoTitle' },\n '/plugin-seo/generate-description': { operationId: 'seoGenerateDescription', summary: 'seoDescription' },\n '/plugin-seo/generate-url': { operationId: 'seoGenerateUrl', summary: 'seoUrl' },\n '/plugin-seo/generate-image': { operationId: 'seoGenerateImage', summary: 'seoImage', image: true },\n}\n\nexport const seo: OfficialPlugin = {\n slug: '@payloadcms/plugin-seo',\n tag: TAG,\n build: ({ config, ctx, t }) => {\n const id = idSchema(ctx)\n const operation = (path: string): OperationObject | undefined => {\n const generator = GENERATORS[path]\n if (!generator) return undefined\n const result: SchemaObject = generator.image\n ? { oneOf: [{ type: 'string' }, { type: 'number' }, { type: 'object', additionalProperties: true }] }\n : { type: 'string' }\n return {\n tags: [TAG],\n operationId: generator.operationId,\n summary: t(generator.summary),\n requestBody: {\n ...jsonBody({\n type: 'object',\n additionalProperties: true,\n properties: {\n id: { oneOf: [{ type: 'string' }, { type: 'number' }] },\n collectionSlug: { type: 'string' },\n globalSlug: { type: 'string' },\n doc: { type: 'object', additionalProperties: true, properties: { id } },\n locale: { type: 'string' },\n title: { type: 'string' },\n },\n }),\n description: t('seoBody'),\n },\n responses: {\n '200': jsonResponse(t('seoResult'), {\n type: 'object',\n properties: { result },\n required: ['result'],\n }),\n ...errorResponses(['401', '403', '500'], t),\n },\n security: securedRequirement(),\n }\n }\n return [\n {\n paths: mountEndpoints(config.endpoints, ctx.apiRoute, (endpoint) =>\n endpoint.method === 'post' ? operation(endpoint.path) : undefined,\n ),\n },\n ]\n },\n}\n"],"mappings":";;;AAQA,MAAM,MAAM;AAEZ,MAAM,aAA4F;CAChG,8BAA8B;EAAE,aAAa;EAAoB,SAAS;CAAW;CACrF,oCAAoC;EAAE,aAAa;EAA0B,SAAS;CAAiB;CACvG,4BAA4B;EAAE,aAAa;EAAkB,SAAS;CAAS;CAC/E,8BAA8B;EAAE,aAAa;EAAoB,SAAS;EAAY,OAAO;CAAK;AACpG;AAEA,MAAa,MAAsB;CACjC,MAAM;CACN,KAAK;CACL,QAAQ,EAAE,QAAQ,KAAK,QAAQ;EAC7B,MAAM,KAAK,SAAS,GAAG;EACvB,MAAM,aAAa,SAA8C;GAC/D,MAAM,YAAY,WAAW;GAC7B,IAAI,CAAC,WAAW,OAAO,KAAA;GACvB,MAAM,SAAuB,UAAU,QACnC,EAAE,OAAO;IAAC,EAAE,MAAM,SAAS;IAAG,EAAE,MAAM,SAAS;IAAG;KAAE,MAAM;KAAU,sBAAsB;IAAK;GAAC,EAAE,IAClG,EAAE,MAAM,SAAS;GACrB,OAAO;IACL,MAAM,CAAC,GAAG;IACV,aAAa,UAAU;IACvB,SAAS,EAAE,UAAU,OAAO;IAC5B,aAAa;KACX,GAAG,SAAS;MACV,MAAM;MACN,sBAAsB;MACtB,YAAY;OACV,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,SAAS,GAAG,EAAE,MAAM,SAAS,CAAC,EAAE;OACtD,gBAAgB,EAAE,MAAM,SAAS;OACjC,YAAY,EAAE,MAAM,SAAS;OAC7B,KAAK;QAAE,MAAM;QAAU,sBAAsB;QAAM,YAAY,EAAE,GAAG;OAAE;OACtE,QAAQ,EAAE,MAAM,SAAS;OACzB,OAAO,EAAE,MAAM,SAAS;MAC1B;KACF,CAAC;KACD,aAAa,EAAE,SAAS;IAC1B;IACA,WAAW;KACT,OAAO,aAAa,EAAE,WAAW,GAAG;MAClC,MAAM;MACN,YAAY,EAAE,OAAO;MACrB,UAAU,CAAC,QAAQ;KACrB,CAAC;KACD,GAAG,eAAe;MAAC;MAAO;MAAO;KAAK,GAAG,CAAC;IAC5C;IACA,UAAU,mBAAmB;GAC/B;EACF;EACA,OAAO,CACL,EACE,OAAO,eAAe,OAAO,WAAW,IAAI,WAAW,aACrD,SAAS,WAAW,SAAS,UAAU,SAAS,IAAI,IAAI,KAAA,CAC1D,EACF,CACF;CACF;AACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BuildContext } from "../../../shared/types/index.js";
|
|
2
|
+
import { Translate } from "../../../shared/translations/types.js";
|
|
3
|
+
import { Endpoint, SanitizedCollectionConfig, SanitizedConfig } from "payload";
|
|
4
|
+
import { OperationObject, PathsObject, ResponsesObject, SchemaObject } from "@scalar/openapi-types/3.2";
|
|
5
|
+
export interface PluginBuildArgs {
|
|
6
|
+
config: SanitizedConfig;
|
|
7
|
+
collections: SanitizedCollectionConfig[];
|
|
8
|
+
ctx: BuildContext;
|
|
9
|
+
options: Record<string, unknown> | undefined;
|
|
10
|
+
schemas: Record<string, SchemaObject>;
|
|
11
|
+
t: Translate;
|
|
12
|
+
}
|
|
13
|
+
export interface PluginGroup {
|
|
14
|
+
paths: PathsObject;
|
|
15
|
+
slug?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface OfficialPlugin {
|
|
18
|
+
slug: string;
|
|
19
|
+
tag: string;
|
|
20
|
+
installed?: (config: SanitizedConfig) => boolean;
|
|
21
|
+
build: (args: PluginBuildArgs) => PluginGroup[];
|
|
22
|
+
}
|
|
23
|
+
export declare const mountEndpoints: (endpoints: Endpoint[] | false | undefined, prefix: string, operation: (endpoint: Endpoint) => OperationObject | undefined) => PathsObject;
|
|
24
|
+
export declare const collectionGroups: (collections: SanitizedCollectionConfig[], ctx: BuildContext, operation: (endpoint: Endpoint, collection: SanitizedCollectionConfig) => OperationObject | undefined) => PluginGroup[];
|
|
25
|
+
export declare const idSchema: (ctx: BuildContext) => SchemaObject;
|
|
26
|
+
export declare const messageSchema: SchemaObject;
|
|
27
|
+
declare const MESSAGE_ERROR_KEYS: {
|
|
28
|
+
readonly '400': 'errorPlugin400';
|
|
29
|
+
readonly '401': 'errorPlugin401';
|
|
30
|
+
readonly '403': 'errorPlugin403';
|
|
31
|
+
readonly '404': 'errorPlugin404';
|
|
32
|
+
readonly '500': 'errorPlugin500';
|
|
33
|
+
};
|
|
34
|
+
export declare const messageErrors: (codes: Array<keyof typeof MESSAGE_ERROR_KEYS>, t: Translate, schema?: SchemaObject) => ResponsesObject;
|
|
35
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsonResponse } from "../components.js";
|
|
2
|
+
import { getOpenapiMeta, normalizePath } from "../paths/custom.js";
|
|
3
|
+
const mountEndpoints = (endpoints, prefix, operation) => {
|
|
4
|
+
const out = {};
|
|
5
|
+
for (const endpoint of endpoints || []) {
|
|
6
|
+
if (getOpenapiMeta(endpoint)) continue;
|
|
7
|
+
const op = operation(endpoint);
|
|
8
|
+
if (!op) continue;
|
|
9
|
+
const path = normalizePath(prefix, endpoint.path);
|
|
10
|
+
out[path] = {
|
|
11
|
+
...out[path],
|
|
12
|
+
[endpoint.method]: op
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return out;
|
|
16
|
+
};
|
|
17
|
+
const collectionGroups = (collections, ctx, operation) => collections.map((collection) => ({
|
|
18
|
+
slug: collection.slug,
|
|
19
|
+
paths: mountEndpoints(collection.endpoints, `${ctx.apiRoute}/${collection.slug}`, (endpoint) => operation(endpoint, collection))
|
|
20
|
+
})).filter((group) => Object.keys(group.paths).length > 0);
|
|
21
|
+
const idSchema = (ctx) => ({ type: ctx.defaultIDType === "number" ? "integer" : "string" });
|
|
22
|
+
const messageSchema = {
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: { message: { type: "string" } },
|
|
25
|
+
required: ["message"]
|
|
26
|
+
};
|
|
27
|
+
const MESSAGE_ERROR_KEYS = {
|
|
28
|
+
"400": "errorPlugin400",
|
|
29
|
+
"401": "errorPlugin401",
|
|
30
|
+
"403": "errorPlugin403",
|
|
31
|
+
"404": "errorPlugin404",
|
|
32
|
+
"500": "errorPlugin500"
|
|
33
|
+
};
|
|
34
|
+
const messageErrors = (codes, t, schema = messageSchema) => Object.fromEntries(codes.map((code) => [code, jsonResponse(t(MESSAGE_ERROR_KEYS[code]), schema)]));
|
|
35
|
+
export { collectionGroups, idSchema, messageErrors, messageSchema, mountEndpoints };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","names":[],"sources":["../../../../src/server/spec/plugins/shared.ts"],"sourcesContent":["import type { OperationObject, PathsObject, ResponsesObject, SchemaObject } from '@scalar/openapi-types/3.2'\nimport type { Endpoint, SanitizedCollectionConfig, SanitizedConfig } from 'payload'\n\nimport { jsonResponse } from '@/server/spec/components.js'\nimport { getOpenapiMeta, normalizePath } from '@/server/spec/paths/custom.js'\nimport type { Translate } from '@/shared/translations/types.js'\nimport type { BuildContext } from '@/shared/types/index.js'\n\nexport interface PluginBuildArgs {\n config: SanitizedConfig\n collections: SanitizedCollectionConfig[]\n ctx: BuildContext\n options: Record<string, unknown> | undefined\n schemas: Record<string, SchemaObject>\n t: Translate\n}\n\nexport interface PluginGroup {\n paths: PathsObject\n slug?: string\n}\n\nexport interface OfficialPlugin {\n slug: string\n tag: string\n installed?: (config: SanitizedConfig) => boolean\n build: (args: PluginBuildArgs) => PluginGroup[]\n}\n\nexport const mountEndpoints = (\n endpoints: Endpoint[] | false | undefined,\n prefix: string,\n operation: (endpoint: Endpoint) => OperationObject | undefined,\n): PathsObject => {\n const out: PathsObject = {}\n for (const endpoint of endpoints || []) {\n if (getOpenapiMeta(endpoint)) continue\n const op = operation(endpoint)\n if (!op) continue\n const path = normalizePath(prefix, endpoint.path)\n out[path] = { ...out[path], [endpoint.method]: op }\n }\n return out\n}\n\nexport const collectionGroups = (\n collections: SanitizedCollectionConfig[],\n ctx: BuildContext,\n operation: (endpoint: Endpoint, collection: SanitizedCollectionConfig) => OperationObject | undefined,\n): PluginGroup[] =>\n collections\n .map((collection) => ({\n slug: collection.slug,\n paths: mountEndpoints(collection.endpoints, `${ctx.apiRoute}/${collection.slug}`, (endpoint) =>\n operation(endpoint, collection),\n ),\n }))\n .filter((group) => Object.keys(group.paths).length > 0)\n\nexport const idSchema = (ctx: BuildContext): SchemaObject => ({\n type: ctx.defaultIDType === 'number' ? 'integer' : 'string',\n})\n\nexport const messageSchema: SchemaObject = {\n type: 'object',\n properties: { message: { type: 'string' } },\n required: ['message'],\n}\n\nconst MESSAGE_ERROR_KEYS = {\n '400': 'errorPlugin400',\n '401': 'errorPlugin401',\n '403': 'errorPlugin403',\n '404': 'errorPlugin404',\n '500': 'errorPlugin500',\n} as const\n\nexport const messageErrors = (\n codes: Array<keyof typeof MESSAGE_ERROR_KEYS>,\n t: Translate,\n schema: SchemaObject = messageSchema,\n): ResponsesObject => Object.fromEntries(codes.map((code) => [code, jsonResponse(t(MESSAGE_ERROR_KEYS[code]), schema)]))\n"],"mappings":";;AA6BA,MAAa,kBACX,WACA,QACA,cACgB;CAChB,MAAM,MAAmB,CAAC;CAC1B,KAAK,MAAM,YAAY,aAAa,CAAC,GAAG;EACtC,IAAI,eAAe,QAAQ,GAAG;EAC9B,MAAM,KAAK,UAAU,QAAQ;EAC7B,IAAI,CAAC,IAAI;EACT,MAAM,OAAO,cAAc,QAAQ,SAAS,IAAI;EAChD,IAAI,QAAQ;GAAE,GAAG,IAAI;IAAQ,SAAS,SAAS;EAAG;CACpD;CACA,OAAO;AACT;AAEA,MAAa,oBACX,aACA,KACA,cAEA,YACG,KAAK,gBAAgB;CACpB,MAAM,WAAW;CACjB,OAAO,eAAe,WAAW,WAAW,GAAG,IAAI,SAAS,GAAG,WAAW,SAAS,aACjF,UAAU,UAAU,UAAU,CAChC;AACF,EAAE,CAAC,CACF,QAAQ,UAAU,OAAO,KAAK,MAAM,KAAK,CAAC,CAAC,SAAS,CAAC;AAE1D,MAAa,YAAY,SAAqC,EAC5D,MAAM,IAAI,kBAAkB,WAAW,YAAY,SACrD;AAEA,MAAa,gBAA8B;CACzC,MAAM;CACN,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,EAAE;CAC1C,UAAU,CAAC,SAAS;AACtB;AAEA,MAAM,qBAAqB;CACzB,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;AACT;AAEA,MAAa,iBACX,OACA,GACA,SAAuB,kBACH,OAAO,YAAY,MAAM,KAAK,SAAS,CAAC,MAAM,aAAa,EAAE,mBAAmB,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { errorResponses } from "../components.js";
|
|
2
|
+
import { securedRequirement } from "../security.js";
|
|
3
|
+
import { mountEndpoints } from "./shared.js";
|
|
4
|
+
const TAG = "Storage R2";
|
|
5
|
+
const UPLOAD_PATH = /^\/storage-r2-multi-part-upload(?:-(\d+))?$/;
|
|
6
|
+
const query = (name, required, type = "string") => ({
|
|
7
|
+
name,
|
|
8
|
+
in: "query",
|
|
9
|
+
required,
|
|
10
|
+
schema: { type }
|
|
11
|
+
});
|
|
12
|
+
const storageR2 = {
|
|
13
|
+
slug: "@payloadcms/storage-r2",
|
|
14
|
+
tag: TAG,
|
|
15
|
+
installed: (config) => (config.storage ?? []).some((adapter) => adapter?.name === "r2"),
|
|
16
|
+
build: ({ config, ctx, t }) => {
|
|
17
|
+
const upload = (suffix) => ({
|
|
18
|
+
tags: [TAG],
|
|
19
|
+
operationId: `r2MultipartUpload${suffix}`,
|
|
20
|
+
summary: t("r2Upload"),
|
|
21
|
+
description: t("r2UploadDesc"),
|
|
22
|
+
parameters: [
|
|
23
|
+
query("collection", true),
|
|
24
|
+
query("fileName", true),
|
|
25
|
+
query("fileType", true),
|
|
26
|
+
query("docPrefix", false),
|
|
27
|
+
query("multipartId", false),
|
|
28
|
+
query("multipartKey", false),
|
|
29
|
+
query("multipartNumber", false, "integer"),
|
|
30
|
+
query("signedReceipt", false)
|
|
31
|
+
],
|
|
32
|
+
requestBody: { content: {
|
|
33
|
+
"application/octet-stream": { schema: {
|
|
34
|
+
type: "string",
|
|
35
|
+
format: "binary"
|
|
36
|
+
} },
|
|
37
|
+
"application/json": { schema: {
|
|
38
|
+
type: "array",
|
|
39
|
+
items: {
|
|
40
|
+
type: "object",
|
|
41
|
+
properties: {
|
|
42
|
+
partNumber: { type: "integer" },
|
|
43
|
+
etag: { type: "string" }
|
|
44
|
+
},
|
|
45
|
+
required: ["partNumber", "etag"]
|
|
46
|
+
}
|
|
47
|
+
} }
|
|
48
|
+
} },
|
|
49
|
+
responses: {
|
|
50
|
+
"200": {
|
|
51
|
+
description: t("r2UploadResult"),
|
|
52
|
+
content: {
|
|
53
|
+
"application/json": { schema: {
|
|
54
|
+
type: "object",
|
|
55
|
+
additionalProperties: true,
|
|
56
|
+
properties: {
|
|
57
|
+
filename: { type: "string" },
|
|
58
|
+
key: { type: "string" },
|
|
59
|
+
uploadId: { type: "string" },
|
|
60
|
+
uploadReference: {
|
|
61
|
+
type: "object",
|
|
62
|
+
additionalProperties: true
|
|
63
|
+
},
|
|
64
|
+
partNumber: { type: "integer" },
|
|
65
|
+
etag: { type: "string" }
|
|
66
|
+
}
|
|
67
|
+
} },
|
|
68
|
+
"text/plain": { schema: { type: "string" } }
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
...errorResponses([
|
|
72
|
+
"400",
|
|
73
|
+
"403",
|
|
74
|
+
"500"
|
|
75
|
+
], t),
|
|
76
|
+
"412": {
|
|
77
|
+
description: t("errorStorageR2412"),
|
|
78
|
+
content: { "text/plain": { schema: { type: "string" } } }
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
security: securedRequirement()
|
|
82
|
+
});
|
|
83
|
+
return [{ paths: mountEndpoints(config.endpoints, ctx.apiRoute, ({ method, path }) => {
|
|
84
|
+
const match = UPLOAD_PATH.exec(path);
|
|
85
|
+
return method === "post" && match ? upload(match[1] ?? "") : void 0;
|
|
86
|
+
}) }];
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
export { storageR2 };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=storageR2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storageR2.js","names":[],"sources":["../../../../src/server/spec/plugins/storageR2.ts"],"sourcesContent":["import type { OperationObject, ParameterObject } from '@scalar/openapi-types/3.2'\n\nimport { errorResponses } from '@/server/spec/components.js'\nimport { securedRequirement } from '@/server/spec/security.js'\n\nimport { type OfficialPlugin, mountEndpoints } from './shared.js'\n\nconst TAG = 'Storage R2'\n\nconst UPLOAD_PATH = /^\\/storage-r2-multi-part-upload(?:-(\\d+))?$/\n\nconst query = (name: string, required: boolean, type: 'string' | 'integer' = 'string'): ParameterObject => ({\n name,\n in: 'query',\n required,\n schema: { type },\n})\n\nexport const storageR2: OfficialPlugin = {\n slug: '@payloadcms/storage-r2',\n tag: TAG,\n installed: (config) => (config.storage ?? []).some((adapter) => adapter?.name === 'r2'),\n build: ({ config, ctx, t }) => {\n const upload = (suffix: string): OperationObject => ({\n tags: [TAG],\n operationId: `r2MultipartUpload${suffix}`,\n summary: t('r2Upload'),\n description: t('r2UploadDesc'),\n parameters: [\n query('collection', true),\n query('fileName', true),\n query('fileType', true),\n query('docPrefix', false),\n query('multipartId', false),\n query('multipartKey', false),\n query('multipartNumber', false, 'integer'),\n query('signedReceipt', false),\n ],\n requestBody: {\n content: {\n 'application/octet-stream': { schema: { type: 'string', format: 'binary' } },\n 'application/json': {\n schema: {\n type: 'array',\n items: {\n type: 'object',\n properties: { partNumber: { type: 'integer' }, etag: { type: 'string' } },\n required: ['partNumber', 'etag'],\n },\n },\n },\n },\n },\n responses: {\n '200': {\n description: t('r2UploadResult'),\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n additionalProperties: true,\n properties: {\n filename: { type: 'string' },\n key: { type: 'string' },\n uploadId: { type: 'string' },\n uploadReference: { type: 'object', additionalProperties: true },\n partNumber: { type: 'integer' },\n etag: { type: 'string' },\n },\n },\n },\n 'text/plain': { schema: { type: 'string' } },\n },\n },\n ...errorResponses(['400', '403', '500'], t),\n '412': { description: t('errorStorageR2412'), content: { 'text/plain': { schema: { type: 'string' } } } },\n },\n security: securedRequirement(),\n })\n return [\n {\n paths: mountEndpoints(config.endpoints, ctx.apiRoute, ({ method, path }) => {\n const match = UPLOAD_PATH.exec(path)\n return method === 'post' && match ? upload(match[1] ?? '') : undefined\n }),\n },\n ]\n },\n}\n"],"mappings":";;;AAOA,MAAM,MAAM;AAEZ,MAAM,cAAc;AAEpB,MAAM,SAAS,MAAc,UAAmB,OAA6B,cAA+B;CAC1G;CACA,IAAI;CACJ;CACA,QAAQ,EAAE,KAAK;AACjB;AAEA,MAAa,YAA4B;CACvC,MAAM;CACN,KAAK;CACL,YAAY,YAAY,OAAO,WAAW,CAAC,EAAA,CAAG,MAAM,YAAY,SAAS,SAAS,IAAI;CACtF,QAAQ,EAAE,QAAQ,KAAK,QAAQ;EAC7B,MAAM,UAAU,YAAqC;GACnD,MAAM,CAAC,GAAG;GACV,aAAa,oBAAoB;GACjC,SAAS,EAAE,UAAU;GACrB,aAAa,EAAE,cAAc;GAC7B,YAAY;IACV,MAAM,cAAc,IAAI;IACxB,MAAM,YAAY,IAAI;IACtB,MAAM,YAAY,IAAI;IACtB,MAAM,aAAa,KAAK;IACxB,MAAM,eAAe,KAAK;IAC1B,MAAM,gBAAgB,KAAK;IAC3B,MAAM,mBAAmB,OAAO,SAAS;IACzC,MAAM,iBAAiB,KAAK;GAC9B;GACA,aAAa,EACX,SAAS;IACP,4BAA4B,EAAE,QAAQ;KAAE,MAAM;KAAU,QAAQ;IAAS,EAAE;IAC3E,oBAAoB,EAClB,QAAQ;KACN,MAAM;KACN,OAAO;MACL,MAAM;MACN,YAAY;OAAE,YAAY,EAAE,MAAM,UAAU;OAAG,MAAM,EAAE,MAAM,SAAS;MAAE;MACxE,UAAU,CAAC,cAAc,MAAM;KACjC;IACF,EACF;GACF,EACF;GACA,WAAW;IACT,OAAO;KACL,aAAa,EAAE,gBAAgB;KAC/B,SAAS;MACP,oBAAoB,EAClB,QAAQ;OACN,MAAM;OACN,sBAAsB;OACtB,YAAY;QACV,UAAU,EAAE,MAAM,SAAS;QAC3B,KAAK,EAAE,MAAM,SAAS;QACtB,UAAU,EAAE,MAAM,SAAS;QAC3B,iBAAiB;SAAE,MAAM;SAAU,sBAAsB;QAAK;QAC9D,YAAY,EAAE,MAAM,UAAU;QAC9B,MAAM,EAAE,MAAM,SAAS;OACzB;MACF,EACF;MACA,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,EAAE;KAC7C;IACF;IACA,GAAG,eAAe;KAAC;KAAO;KAAO;IAAK,GAAG,CAAC;IAC1C,OAAO;KAAE,aAAa,EAAE,mBAAmB;KAAG,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,EAAE,EAAE;IAAE;GAC1G;GACA,UAAU,mBAAmB;EAC/B;EACA,OAAO,CACL,EACE,OAAO,eAAe,OAAO,WAAW,IAAI,WAAW,EAAE,QAAQ,WAAW;GAC1E,MAAM,QAAQ,YAAY,KAAK,IAAI;GACnC,OAAO,WAAW,UAAU,QAAQ,OAAO,MAAM,MAAM,EAAE,IAAI,KAAA;EAC/D,CAAC,EACH,CACF;CACF;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Translate } from "../../../shared/translations/types.js";
|
|
2
|
+
import { OfficialPlugin } from "./shared.js";
|
|
3
|
+
import { OperationObject } from "@scalar/openapi-types/3.2";
|
|
4
|
+
export declare const stripeWebhookOperation: ({ tag, operationId, t }: {
|
|
5
|
+
tag: string;
|
|
6
|
+
operationId: string;
|
|
7
|
+
t: Translate;
|
|
8
|
+
}) => OperationObject;
|
|
9
|
+
export declare const stripe: OfficialPlugin;
|
|
10
|
+
//# sourceMappingURL=stripe.d.ts.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsonBody, jsonResponse } from "../components.js";
|
|
2
|
+
import { securedRequirement } from "../security.js";
|
|
3
|
+
import { messageErrors, mountEndpoints } from "./shared.js";
|
|
4
|
+
const TAG = "Stripe";
|
|
5
|
+
const stripeWebhookOperation = ({ tag, operationId, t }) => {
|
|
6
|
+
const received = {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: { received: { type: "boolean" } },
|
|
9
|
+
required: ["received"]
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
tags: [tag],
|
|
13
|
+
operationId,
|
|
14
|
+
summary: t("stripeWebhook"),
|
|
15
|
+
parameters: [{
|
|
16
|
+
name: "stripe-signature",
|
|
17
|
+
in: "header",
|
|
18
|
+
schema: { type: "string" }
|
|
19
|
+
}],
|
|
20
|
+
requestBody: {
|
|
21
|
+
...jsonBody({
|
|
22
|
+
type: "object",
|
|
23
|
+
additionalProperties: true
|
|
24
|
+
}),
|
|
25
|
+
description: t("stripeWebhookBody")
|
|
26
|
+
},
|
|
27
|
+
responses: {
|
|
28
|
+
"200": jsonResponse(t("stripeWebhookResult"), received),
|
|
29
|
+
"400": jsonResponse(t("errorPluginStripeWebhook400"), received)
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const stripe = {
|
|
34
|
+
slug: "@payloadcms/plugin-stripe",
|
|
35
|
+
tag: TAG,
|
|
36
|
+
build: ({ config, ctx, options, t }) => {
|
|
37
|
+
const rest = options?.rest;
|
|
38
|
+
const allowed = Array.isArray(rest?.allowedMethods) ? rest.allowedMethods : void 0;
|
|
39
|
+
const restOperation = {
|
|
40
|
+
tags: [TAG],
|
|
41
|
+
operationId: "stripeRest",
|
|
42
|
+
summary: t("stripeRest"),
|
|
43
|
+
requestBody: jsonBody({
|
|
44
|
+
type: "object",
|
|
45
|
+
properties: {
|
|
46
|
+
stripeMethod: {
|
|
47
|
+
type: "string",
|
|
48
|
+
...allowed ? { enum: [...new Set(allowed)] } : {}
|
|
49
|
+
},
|
|
50
|
+
stripeArgs: {
|
|
51
|
+
type: "array",
|
|
52
|
+
items: {}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
required: ["stripeMethod", "stripeArgs"]
|
|
56
|
+
}),
|
|
57
|
+
responses: {
|
|
58
|
+
"200": jsonResponse(t("stripeRestResult"), {
|
|
59
|
+
type: "object",
|
|
60
|
+
properties: {
|
|
61
|
+
data: {},
|
|
62
|
+
status: {
|
|
63
|
+
type: "integer",
|
|
64
|
+
enum: [200]
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
required: ["data", "status"]
|
|
68
|
+
}),
|
|
69
|
+
...messageErrors([
|
|
70
|
+
"400",
|
|
71
|
+
"401",
|
|
72
|
+
"403"
|
|
73
|
+
], t),
|
|
74
|
+
"404": jsonResponse(t("errorPluginStripeRest404"), {
|
|
75
|
+
type: "object",
|
|
76
|
+
properties: {
|
|
77
|
+
message: { type: "string" },
|
|
78
|
+
status: {
|
|
79
|
+
type: "integer",
|
|
80
|
+
enum: [404]
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
required: ["message", "status"]
|
|
84
|
+
}),
|
|
85
|
+
...messageErrors(["500"], t)
|
|
86
|
+
},
|
|
87
|
+
security: securedRequirement()
|
|
88
|
+
};
|
|
89
|
+
return [{ paths: mountEndpoints(config.endpoints, ctx.apiRoute, ({ method, path }) => {
|
|
90
|
+
if (method !== "post") return void 0;
|
|
91
|
+
if (path === "/stripe/webhooks") return stripeWebhookOperation({
|
|
92
|
+
tag: TAG,
|
|
93
|
+
operationId: "stripeWebhooks",
|
|
94
|
+
t
|
|
95
|
+
});
|
|
96
|
+
return path === "/stripe/rest" ? restOperation : void 0;
|
|
97
|
+
}) }];
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
export { stripe, stripeWebhookOperation };
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=stripe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.js","names":[],"sources":["../../../../src/server/spec/plugins/stripe.ts"],"sourcesContent":["import type { OperationObject, SchemaObject } from '@scalar/openapi-types/3.2'\n\nimport { jsonBody, jsonResponse } from '@/server/spec/components.js'\nimport { securedRequirement } from '@/server/spec/security.js'\nimport type { Translate } from '@/shared/translations/types.js'\n\nimport { type OfficialPlugin, messageErrors, mountEndpoints } from './shared.js'\n\nconst TAG = 'Stripe'\n\nexport const stripeWebhookOperation = ({\n tag,\n operationId,\n t,\n}: {\n tag: string\n operationId: string\n t: Translate\n}): OperationObject => {\n const received: SchemaObject = {\n type: 'object',\n properties: { received: { type: 'boolean' } },\n required: ['received'],\n }\n return {\n tags: [tag],\n operationId,\n summary: t('stripeWebhook'),\n parameters: [{ name: 'stripe-signature', in: 'header', schema: { type: 'string' } }],\n requestBody: {\n ...jsonBody({ type: 'object', additionalProperties: true }),\n description: t('stripeWebhookBody'),\n },\n responses: {\n '200': jsonResponse(t('stripeWebhookResult'), received),\n '400': jsonResponse(t('errorPluginStripeWebhook400'), received),\n },\n }\n}\n\nexport const stripe: OfficialPlugin = {\n slug: '@payloadcms/plugin-stripe',\n tag: TAG,\n build: ({ config, ctx, options, t }) => {\n const rest = options?.rest as { allowedMethods?: unknown } | undefined\n const allowed = Array.isArray(rest?.allowedMethods) ? (rest.allowedMethods as string[]) : undefined\n const restOperation: OperationObject = {\n tags: [TAG],\n operationId: 'stripeRest',\n summary: t('stripeRest'),\n requestBody: jsonBody({\n type: 'object',\n properties: {\n stripeMethod: { type: 'string', ...(allowed ? { enum: [...new Set(allowed)] } : {}) },\n stripeArgs: { type: 'array', items: {} },\n },\n required: ['stripeMethod', 'stripeArgs'],\n }),\n responses: {\n '200': jsonResponse(t('stripeRestResult'), {\n type: 'object',\n properties: { data: {}, status: { type: 'integer', enum: [200] } },\n required: ['data', 'status'],\n }),\n ...messageErrors(['400', '401', '403'], t),\n '404': jsonResponse(t('errorPluginStripeRest404'), {\n type: 'object',\n properties: { message: { type: 'string' }, status: { type: 'integer', enum: [404] } },\n required: ['message', 'status'],\n }),\n ...messageErrors(['500'], t),\n },\n security: securedRequirement(),\n }\n return [\n {\n paths: mountEndpoints(config.endpoints, ctx.apiRoute, ({ method, path }) => {\n if (method !== 'post') return undefined\n if (path === '/stripe/webhooks') return stripeWebhookOperation({ tag: TAG, operationId: 'stripeWebhooks', t })\n return path === '/stripe/rest' ? restOperation : undefined\n }),\n },\n ]\n },\n}\n"],"mappings":";;;AAQA,MAAM,MAAM;AAEZ,MAAa,0BAA0B,EACrC,KACA,aACA,QAKqB;CACrB,MAAM,WAAyB;EAC7B,MAAM;EACN,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,EAAE;EAC5C,UAAU,CAAC,UAAU;CACvB;CACA,OAAO;EACL,MAAM,CAAC,GAAG;EACV;EACA,SAAS,EAAE,eAAe;EAC1B,YAAY,CAAC;GAAE,MAAM;GAAoB,IAAI;GAAU,QAAQ,EAAE,MAAM,SAAS;EAAE,CAAC;EACnF,aAAa;GACX,GAAG,SAAS;IAAE,MAAM;IAAU,sBAAsB;GAAK,CAAC;GAC1D,aAAa,EAAE,mBAAmB;EACpC;EACA,WAAW;GACT,OAAO,aAAa,EAAE,qBAAqB,GAAG,QAAQ;GACtD,OAAO,aAAa,EAAE,6BAA6B,GAAG,QAAQ;EAChE;CACF;AACF;AAEA,MAAa,SAAyB;CACpC,MAAM;CACN,KAAK;CACL,QAAQ,EAAE,QAAQ,KAAK,SAAS,QAAQ;EACtC,MAAM,OAAO,SAAS;EACtB,MAAM,UAAU,MAAM,QAAQ,MAAM,cAAc,IAAK,KAAK,iBAA8B,KAAA;EAC1F,MAAM,gBAAiC;GACrC,MAAM,CAAC,GAAG;GACV,aAAa;GACb,SAAS,EAAE,YAAY;GACvB,aAAa,SAAS;IACpB,MAAM;IACN,YAAY;KACV,cAAc;MAAE,MAAM;MAAU,GAAI,UAAU,EAAE,MAAM,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC,EAAE,IAAI,CAAC;KAAG;KACpF,YAAY;MAAE,MAAM;MAAS,OAAO,CAAC;KAAE;IACzC;IACA,UAAU,CAAC,gBAAgB,YAAY;GACzC,CAAC;GACD,WAAW;IACT,OAAO,aAAa,EAAE,kBAAkB,GAAG;KACzC,MAAM;KACN,YAAY;MAAE,MAAM,CAAC;MAAG,QAAQ;OAAE,MAAM;OAAW,MAAM,CAAC,GAAG;MAAE;KAAE;KACjE,UAAU,CAAC,QAAQ,QAAQ;IAC7B,CAAC;IACD,GAAG,cAAc;KAAC;KAAO;KAAO;IAAK,GAAG,CAAC;IACzC,OAAO,aAAa,EAAE,0BAA0B,GAAG;KACjD,MAAM;KACN,YAAY;MAAE,SAAS,EAAE,MAAM,SAAS;MAAG,QAAQ;OAAE,MAAM;OAAW,MAAM,CAAC,GAAG;MAAE;KAAE;KACpF,UAAU,CAAC,WAAW,QAAQ;IAChC,CAAC;IACD,GAAG,cAAc,CAAC,KAAK,GAAG,CAAC;GAC7B;GACA,UAAU,mBAAmB;EAC/B;EACA,OAAO,CACL,EACE,OAAO,eAAe,OAAO,WAAW,IAAI,WAAW,EAAE,QAAQ,WAAW;GAC1E,IAAI,WAAW,QAAQ,OAAO,KAAA;GAC9B,IAAI,SAAS,oBAAoB,OAAO,uBAAuB;IAAE,KAAK;IAAK,aAAa;IAAkB;GAAE,CAAC;GAC7G,OAAO,SAAS,iBAAiB,gBAAgB,KAAA;EACnD,CAAC,EACH,CACF;CACF;AACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Entity, EntityOperation, EntitySecurityOverride, OperationKind, SecurityOption } from "../../shared/types/index.js";
|
|
2
|
+
import { Access, SanitizedConfig } from "payload";
|
|
3
|
+
import { PathsObject, SecurityRequirementObject } from "@scalar/openapi-types/3.2";
|
|
4
|
+
export declare const securedRequirement: (login?: boolean) => SecurityRequirementObject[];
|
|
5
|
+
type ProbedOperation = EntityOperation | 'readVersions';
|
|
6
|
+
export type EntitySecurity = Partial<Record<ProbedOperation, SecurityRequirementObject[] | undefined>>;
|
|
7
|
+
export declare const evaluateAccess: (access: Access | undefined, opts?: {
|
|
8
|
+
locale?: string;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
baseAccess?: SanitizedConfig['baseAccess'];
|
|
11
|
+
}) => Promise<boolean>;
|
|
12
|
+
export declare const readSecurityOverride: (entity: {
|
|
13
|
+
slug: string;
|
|
14
|
+
custom?: {
|
|
15
|
+
openapi?: {
|
|
16
|
+
security?: unknown;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}) => EntitySecurityOverride | undefined;
|
|
20
|
+
export declare const resolveEntitySecurity: ({ entity, operations, locale, baseAccess }: {
|
|
21
|
+
entity: Entity;
|
|
22
|
+
operations: ProbedOperation[];
|
|
23
|
+
locale?: string;
|
|
24
|
+
baseAccess?: SanitizedConfig['baseAccess'];
|
|
25
|
+
}) => Promise<EntitySecurity>;
|
|
26
|
+
export declare const applySecurity: ({ paths, slug, kind, plugin, security, login }: {
|
|
27
|
+
paths: PathsObject;
|
|
28
|
+
slug?: string;
|
|
29
|
+
kind: OperationKind;
|
|
30
|
+
plugin?: string;
|
|
31
|
+
security?: SecurityOption;
|
|
32
|
+
login?: boolean;
|
|
33
|
+
}) => Promise<PathsObject>;
|
|
34
|
+
//# sourceMappingURL=security.d.ts.map
|