@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,98 @@
|
|
|
1
|
+
import { errorResponses, jsonResponse } from "../components.js";
|
|
2
|
+
import { makeT } from "../../../shared/translations/index.js";
|
|
3
|
+
const boolParam = (name, description) => ({
|
|
4
|
+
name,
|
|
5
|
+
in: "query",
|
|
6
|
+
description,
|
|
7
|
+
schema: { type: "boolean" }
|
|
8
|
+
});
|
|
9
|
+
const collectQueues = (jobs) => {
|
|
10
|
+
const queues = /* @__PURE__ */ new Set(["default"]);
|
|
11
|
+
const add = (q) => {
|
|
12
|
+
if (typeof q === "string" && q) queues.add(q);
|
|
13
|
+
};
|
|
14
|
+
const fromSchedules = (items) => {
|
|
15
|
+
if (!Array.isArray(items)) return;
|
|
16
|
+
for (const item of items) for (const s of item.schedule ?? []) add(s.queue);
|
|
17
|
+
};
|
|
18
|
+
fromSchedules(jobs?.tasks);
|
|
19
|
+
fromSchedules(jobs?.workflows);
|
|
20
|
+
const autoRun = jobs?.autoRun;
|
|
21
|
+
if (Array.isArray(autoRun)) for (const cron of autoRun) add(cron.queue);
|
|
22
|
+
const processingOrder = jobs?.processingOrder;
|
|
23
|
+
if (processingOrder?.queues) for (const name of Object.keys(processingOrder.queues)) add(name);
|
|
24
|
+
return [...queues].toSorted();
|
|
25
|
+
};
|
|
26
|
+
const queueParam = (queues, ctx) => ({
|
|
27
|
+
name: "queue",
|
|
28
|
+
in: "query",
|
|
29
|
+
description: makeT(ctx.i18n)("jobsQueue", { queues: queues.map((q) => `\`${q}\``).join(", ") }),
|
|
30
|
+
schema: {
|
|
31
|
+
type: "string",
|
|
32
|
+
enum: queues
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const buildJobsPaths = ({ config, ctx, security }) => {
|
|
36
|
+
const jobs = config.jobs;
|
|
37
|
+
if (!Boolean((jobs?.tasks)?.length || (jobs?.workflows)?.length)) return {};
|
|
38
|
+
const t = makeT(ctx.i18n);
|
|
39
|
+
const queue = queueParam(collectQueues(jobs), ctx);
|
|
40
|
+
const errors = errorResponses([
|
|
41
|
+
"401",
|
|
42
|
+
"403",
|
|
43
|
+
"500"
|
|
44
|
+
], t);
|
|
45
|
+
return {
|
|
46
|
+
[`${ctx.apiRoute}/payload-jobs/run`]: { get: {
|
|
47
|
+
tags: ["Jobs"],
|
|
48
|
+
operationId: "runJobs",
|
|
49
|
+
summary: t("jobsRunSummary"),
|
|
50
|
+
parameters: [
|
|
51
|
+
queue,
|
|
52
|
+
boolParam("allQueues", t("jobsRunAllQueues")),
|
|
53
|
+
{
|
|
54
|
+
name: "limit",
|
|
55
|
+
in: "query",
|
|
56
|
+
description: t("jobsLimit"),
|
|
57
|
+
schema: { type: "integer" }
|
|
58
|
+
},
|
|
59
|
+
boolParam("disableScheduling", t("jobsDisableScheduling")),
|
|
60
|
+
boolParam("silent", t("jobsSilent"))
|
|
61
|
+
],
|
|
62
|
+
responses: {
|
|
63
|
+
"200": jsonResponse(t("jobsRunResult"), {
|
|
64
|
+
type: "object",
|
|
65
|
+
properties: {
|
|
66
|
+
message: { type: "string" },
|
|
67
|
+
noJobsRemaining: { type: "boolean" },
|
|
68
|
+
remainingJobsFromQueried: { type: "integer" }
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
...errors
|
|
72
|
+
},
|
|
73
|
+
security
|
|
74
|
+
} },
|
|
75
|
+
[`${ctx.apiRoute}/payload-jobs/handle-schedules`]: { get: {
|
|
76
|
+
tags: ["Jobs"],
|
|
77
|
+
operationId: "handleJobSchedules",
|
|
78
|
+
summary: t("jobsSchedulesSummary"),
|
|
79
|
+
parameters: [queue, boolParam("allQueues", t("jobsSchedulesAllQueues"))],
|
|
80
|
+
responses: {
|
|
81
|
+
"200": jsonResponse(t("jobsSchedulesResult"), {
|
|
82
|
+
type: "object",
|
|
83
|
+
properties: {
|
|
84
|
+
message: { type: "string" },
|
|
85
|
+
queued: { type: "integer" },
|
|
86
|
+
errored: { type: "integer" },
|
|
87
|
+
skipped: { type: "integer" }
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
...errors
|
|
91
|
+
},
|
|
92
|
+
security
|
|
93
|
+
} }
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
export { buildJobsPaths };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=jobs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.js","names":[],"sources":["../../../../src/server/spec/paths/jobs.ts"],"sourcesContent":["import type { ParameterObject, PathsObject, SecurityRequirementObject } from '@scalar/openapi-types/3.2'\nimport type { SanitizedConfig } from 'payload'\n\nimport { errorResponses, jsonResponse } from '@/server/spec/components.js'\nimport { makeT } from '@/shared/translations/index.js'\nimport type { BuildContext } from '@/shared/types/index.js'\n\nconst boolParam = (name: string, description: string): ParameterObject => ({\n name,\n in: 'query',\n description,\n schema: { type: 'boolean' },\n})\n\nconst collectQueues = (jobs: Record<string, unknown> | undefined): string[] => {\n const queues = new Set<string>(['default'])\n\n const add = (q: unknown) => {\n if (typeof q === 'string' && q) queues.add(q)\n }\n const fromSchedules = (items: unknown) => {\n if (!Array.isArray(items)) return\n for (const item of items as Array<{ schedule?: Array<{ queue?: unknown }> }>) {\n for (const s of item.schedule ?? []) add(s.queue)\n }\n }\n\n fromSchedules(jobs?.tasks)\n fromSchedules(jobs?.workflows)\n\n const autoRun = jobs?.autoRun\n if (Array.isArray(autoRun)) {\n for (const cron of autoRun as Array<{ queue?: unknown }>) add(cron.queue)\n }\n\n const processingOrder = jobs?.processingOrder as { queues?: Record<string, unknown> } | undefined\n if (processingOrder?.queues) {\n for (const name of Object.keys(processingOrder.queues)) add(name)\n }\n\n return [...queues].toSorted()\n}\n\nconst queueParam = (queues: string[], ctx: BuildContext): ParameterObject => ({\n name: 'queue',\n in: 'query',\n description: makeT(ctx.i18n)('jobsQueue', { queues: queues.map((q) => `\\`${q}\\``).join(', ') }),\n schema: { type: 'string', enum: queues },\n})\n\nexport const buildJobsPaths = ({\n config,\n ctx,\n security,\n}: {\n config: SanitizedConfig\n ctx: BuildContext\n security?: SecurityRequirementObject[]\n}): PathsObject => {\n const jobs = config.jobs as Record<string, unknown> | undefined\n const hasJobs = Boolean((jobs?.tasks as unknown[])?.length || (jobs?.workflows as unknown[])?.length)\n if (!hasJobs) return {}\n\n const t = makeT(ctx.i18n)\n const queue = queueParam(collectQueues(jobs), ctx)\n const errors = errorResponses(['401', '403', '500'], t)\n\n return {\n [`${ctx.apiRoute}/payload-jobs/run`]: {\n get: {\n tags: ['Jobs'],\n operationId: 'runJobs',\n summary: t('jobsRunSummary'),\n parameters: [\n queue,\n boolParam('allQueues', t('jobsRunAllQueues')),\n { name: 'limit', in: 'query', description: t('jobsLimit'), schema: { type: 'integer' } },\n boolParam('disableScheduling', t('jobsDisableScheduling')),\n boolParam('silent', t('jobsSilent')),\n ],\n responses: {\n '200': jsonResponse(t('jobsRunResult'), {\n type: 'object',\n properties: {\n message: { type: 'string' },\n noJobsRemaining: { type: 'boolean' },\n remainingJobsFromQueried: { type: 'integer' },\n },\n }),\n ...errors,\n },\n security,\n },\n },\n [`${ctx.apiRoute}/payload-jobs/handle-schedules`]: {\n get: {\n tags: ['Jobs'],\n operationId: 'handleJobSchedules',\n summary: t('jobsSchedulesSummary'),\n parameters: [queue, boolParam('allQueues', t('jobsSchedulesAllQueues'))],\n responses: {\n '200': jsonResponse(t('jobsSchedulesResult'), {\n type: 'object',\n properties: {\n message: { type: 'string' },\n queued: { type: 'integer' },\n errored: { type: 'integer' },\n skipped: { type: 'integer' },\n },\n }),\n ...errors,\n },\n security,\n },\n },\n }\n}\n"],"mappings":";;AAOA,MAAM,aAAa,MAAc,iBAA0C;CACzE;CACA,IAAI;CACJ;CACA,QAAQ,EAAE,MAAM,UAAU;AAC5B;AAEA,MAAM,iBAAiB,SAAwD;CAC7E,MAAM,yBAAS,IAAI,IAAY,CAAC,SAAS,CAAC;CAE1C,MAAM,OAAO,MAAe;EAC1B,IAAI,OAAO,MAAM,YAAY,GAAG,OAAO,IAAI,CAAC;CAC9C;CACA,MAAM,iBAAiB,UAAmB;EACxC,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;EAC3B,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,KAAK,KAAK,YAAY,CAAC,GAAG,I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,YAAY,CAAC;GACrC;GACA,WAAW;IACT,OAAO,aAAa,EAAE,eAAe,GAAG;KACtC,MAAM;KACN,YAAY;MACV,SAAS,EAAE,MAAM,SAAS;MAC1B,iBAAiB,EAAE,MAAM,UAAU;MACnC,0BAA0B,EAAE,MAAM,UAAU;KAC9C;IACF,CAAC;IACD,GAAG;GACL;GACA;EACF,EACF;GACC,GAAG,IAAI,SAAS,kCAAkC,EACjD,KAAK;GACH,MAAM,CAAC,MAAM;GACb,aAAa;GACb,SAAS,EAAE,sBAAsB;GACjC,YAAY,CAAC,OAAO,UAAU,aAAa,EAAE,wBAAwB,CAAC,CAAC;GACvE,WAAW;IACT,OAAO,aAAa,EAAE,qBAAqB,GAAG;KAC5C,MAAM;KACN,YAAY;MACV,SAAS,EAAE,MAAM,SAAS;MAC1B,QAAQ,EAAE,MAAM,UAAU;MAC1B,SAAS,EAAE,MAAM,UAAU;MAC3B,SAAS,EAAE,MAAM,UAAU;KAC7B;IACF,CAAC;IACD,GAAG;GACL;GACA;EACF,EACF;CACF;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BuildContext } from "../../../shared/types/index.js";
|
|
2
|
+
import { PathsObject } from "@scalar/openapi-types/3.2";
|
|
3
|
+
export declare const buildSystemPaths: ({ ctx, access, uploadSlugs, reorderSlugs }: {
|
|
4
|
+
ctx: BuildContext;
|
|
5
|
+
access: boolean;
|
|
6
|
+
uploadSlugs: string[];
|
|
7
|
+
reorderSlugs?: string[];
|
|
8
|
+
}) => PathsObject;
|
|
9
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { SECURITY_SCHEME_NAME, errorResponses, jsonBody, jsonResponse } from "../components.js";
|
|
2
|
+
import { makeT } from "../../../shared/translations/index.js";
|
|
3
|
+
const buildSystemPaths = ({ ctx, access, uploadSlugs, reorderSlugs = [] }) => {
|
|
4
|
+
const t = makeT(ctx.i18n);
|
|
5
|
+
const paths = {};
|
|
6
|
+
if (access) paths[`${ctx.apiRoute}/access`] = { get: {
|
|
7
|
+
tags: ["Access"],
|
|
8
|
+
operationId: "access",
|
|
9
|
+
responses: {
|
|
10
|
+
"200": jsonResponse(t("authAccess"), {
|
|
11
|
+
type: "object",
|
|
12
|
+
additionalProperties: true
|
|
13
|
+
}),
|
|
14
|
+
...errorResponses(["500"], t)
|
|
15
|
+
}
|
|
16
|
+
} };
|
|
17
|
+
if (uploadSlugs.length > 0) {
|
|
18
|
+
const staged = {
|
|
19
|
+
"204": { description: t("uploadStageResult") },
|
|
20
|
+
...errorResponses(["400", "500"], t)
|
|
21
|
+
};
|
|
22
|
+
paths[`${ctx.apiRoute}/upload-instructions`] = { post: {
|
|
23
|
+
tags: ["Uploads"],
|
|
24
|
+
operationId: "getUploadInstructions",
|
|
25
|
+
summary: t("uploadInstructionsSummary"),
|
|
26
|
+
requestBody: jsonBody({
|
|
27
|
+
type: "object",
|
|
28
|
+
additionalProperties: false,
|
|
29
|
+
properties: {
|
|
30
|
+
collectionSlug: {
|
|
31
|
+
type: "string",
|
|
32
|
+
enum: uploadSlugs
|
|
33
|
+
},
|
|
34
|
+
docPrefix: { type: "string" },
|
|
35
|
+
filename: { type: "string" },
|
|
36
|
+
filesize: {
|
|
37
|
+
type: "integer",
|
|
38
|
+
minimum: 0
|
|
39
|
+
},
|
|
40
|
+
mimeType: { type: "string" }
|
|
41
|
+
},
|
|
42
|
+
required: [
|
|
43
|
+
"collectionSlug",
|
|
44
|
+
"filename",
|
|
45
|
+
"filesize",
|
|
46
|
+
"mimeType"
|
|
47
|
+
]
|
|
48
|
+
}),
|
|
49
|
+
responses: {
|
|
50
|
+
"200": jsonResponse(t("uploadInstructionsResult"), {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
type: {
|
|
54
|
+
type: "string",
|
|
55
|
+
enum: ["http", "dispatch"]
|
|
56
|
+
},
|
|
57
|
+
file: {
|
|
58
|
+
type: "object",
|
|
59
|
+
properties: {
|
|
60
|
+
filename: { type: "string" },
|
|
61
|
+
mimeType: { type: "string" },
|
|
62
|
+
size: { type: "integer" },
|
|
63
|
+
uploadReference: {
|
|
64
|
+
type: "object",
|
|
65
|
+
additionalProperties: true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
required: [
|
|
69
|
+
"filename",
|
|
70
|
+
"mimeType",
|
|
71
|
+
"size",
|
|
72
|
+
"uploadReference"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
request: {
|
|
76
|
+
type: "object",
|
|
77
|
+
properties: {
|
|
78
|
+
method: {
|
|
79
|
+
type: "string",
|
|
80
|
+
enum: ["POST", "PUT"]
|
|
81
|
+
},
|
|
82
|
+
url: { type: "string" },
|
|
83
|
+
headers: {
|
|
84
|
+
type: "object",
|
|
85
|
+
additionalProperties: { type: "string" }
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
required: ["method", "url"]
|
|
89
|
+
},
|
|
90
|
+
name: { type: "string" },
|
|
91
|
+
data: {}
|
|
92
|
+
},
|
|
93
|
+
required: ["type", "file"]
|
|
94
|
+
}),
|
|
95
|
+
...errorResponses([
|
|
96
|
+
"400",
|
|
97
|
+
"403",
|
|
98
|
+
"500"
|
|
99
|
+
], t)
|
|
100
|
+
},
|
|
101
|
+
security: [{ [SECURITY_SCHEME_NAME]: [] }]
|
|
102
|
+
} };
|
|
103
|
+
paths[`${ctx.apiRoute}/upload-instructions/{uploadId}`] = {
|
|
104
|
+
parameters: [{
|
|
105
|
+
name: "uploadId",
|
|
106
|
+
in: "path",
|
|
107
|
+
required: true,
|
|
108
|
+
schema: { type: "string" }
|
|
109
|
+
}],
|
|
110
|
+
put: {
|
|
111
|
+
tags: ["Uploads"],
|
|
112
|
+
operationId: "uploadStagedFile",
|
|
113
|
+
summary: t("uploadStagePutSummary"),
|
|
114
|
+
requestBody: {
|
|
115
|
+
required: true,
|
|
116
|
+
content: { "*/*": { schema: {
|
|
117
|
+
type: "string",
|
|
118
|
+
format: "binary"
|
|
119
|
+
} } }
|
|
120
|
+
},
|
|
121
|
+
responses: staged,
|
|
122
|
+
security: [{ [SECURITY_SCHEME_NAME]: [] }]
|
|
123
|
+
},
|
|
124
|
+
delete: {
|
|
125
|
+
tags: ["Uploads"],
|
|
126
|
+
operationId: "deleteStagedFile",
|
|
127
|
+
summary: t("uploadStageDeleteSummary"),
|
|
128
|
+
responses: staged,
|
|
129
|
+
security: [{ [SECURITY_SCHEME_NAME]: [] }]
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (reorderSlugs.length > 0) {
|
|
134
|
+
const idType = ctx.defaultIDType === "number" ? "integer" : "string";
|
|
135
|
+
paths[`${ctx.apiRoute}/reorder`] = { post: {
|
|
136
|
+
tags: ["Reorder"],
|
|
137
|
+
operationId: "reorder",
|
|
138
|
+
summary: t("reorder"),
|
|
139
|
+
requestBody: {
|
|
140
|
+
...jsonBody({
|
|
141
|
+
type: "object",
|
|
142
|
+
properties: {
|
|
143
|
+
collectionSlug: {
|
|
144
|
+
type: "string",
|
|
145
|
+
enum: reorderSlugs
|
|
146
|
+
},
|
|
147
|
+
docsToMove: {
|
|
148
|
+
type: "array",
|
|
149
|
+
minItems: 1,
|
|
150
|
+
items: { type: idType }
|
|
151
|
+
},
|
|
152
|
+
newKeyWillBe: {
|
|
153
|
+
type: "string",
|
|
154
|
+
enum: ["greater", "less"]
|
|
155
|
+
},
|
|
156
|
+
orderableFieldName: { type: "string" },
|
|
157
|
+
target: {
|
|
158
|
+
type: "object",
|
|
159
|
+
properties: {
|
|
160
|
+
id: { type: idType },
|
|
161
|
+
key: { type: "string" }
|
|
162
|
+
},
|
|
163
|
+
required: ["id"]
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
required: [
|
|
167
|
+
"collectionSlug",
|
|
168
|
+
"docsToMove",
|
|
169
|
+
"newKeyWillBe",
|
|
170
|
+
"orderableFieldName",
|
|
171
|
+
"target"
|
|
172
|
+
]
|
|
173
|
+
}),
|
|
174
|
+
description: t("reorderBody")
|
|
175
|
+
},
|
|
176
|
+
responses: {
|
|
177
|
+
"200": jsonResponse(t("reorderResult"), {
|
|
178
|
+
type: "object",
|
|
179
|
+
properties: {
|
|
180
|
+
success: { type: "boolean" },
|
|
181
|
+
orderValues: {
|
|
182
|
+
type: "array",
|
|
183
|
+
items: { type: "string" }
|
|
184
|
+
},
|
|
185
|
+
message: { type: "string" }
|
|
186
|
+
},
|
|
187
|
+
required: ["success"]
|
|
188
|
+
}),
|
|
189
|
+
"400": jsonResponse(t("errorReorder400"), {
|
|
190
|
+
type: "object",
|
|
191
|
+
properties: { error: { type: "string" } },
|
|
192
|
+
required: ["error"]
|
|
193
|
+
}),
|
|
194
|
+
...errorResponses(["403", "500"], t)
|
|
195
|
+
},
|
|
196
|
+
security: [{ [SECURITY_SCHEME_NAME]: [] }]
|
|
197
|
+
} };
|
|
198
|
+
}
|
|
199
|
+
return paths;
|
|
200
|
+
};
|
|
201
|
+
export { buildSystemPaths };
|
|
202
|
+
|
|
203
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.js","names":[],"sources":["../../../../src/server/spec/paths/system.ts"],"sourcesContent":["import type { PathsObject, ResponsesObject } from '@scalar/openapi-types/3.2'\n\nimport { SECURITY_SCHEME_NAME, errorResponses, jsonBody, jsonResponse } from '@/server/spec/components.js'\nimport { makeT } from '@/shared/translations/index.js'\nimport type { BuildContext } from '@/shared/types/index.js'\n\nexport const buildSystemPaths = ({\n ctx,\n access,\n uploadSlugs,\n reorderSlugs = [],\n}: {\n ctx: BuildContext\n access: boolean\n uploadSlugs: string[]\n reorderSlugs?: string[]\n}): PathsObject => {\n const t = makeT(ctx.i18n)\n const paths: PathsObject = {}\n\n if (access) {\n paths[`${ctx.apiRoute}/access`] = {\n get: {\n tags: ['Access'],\n operationId: 'access',\n responses: {\n '200': jsonResponse(t('authAccess'), { type: 'object', additionalProperties: true }),\n ...errorResponses(['500'], t),\n },\n },\n }\n }\n\n if (uploadSlugs.length > 0) {\n const staged: ResponsesObject = {\n '204': { description: t('uploadStageResult') },\n ...errorResponses(['400', '500'], t),\n }\n\n paths[`${ctx.apiRoute}/upload-instructions`] = {\n post: {\n tags: ['Uploads'],\n operationId: 'getUploadInstructions',\n summary: t('uploadInstructionsSummary'),\n requestBody: jsonBody({\n type: 'object',\n additionalProperties: false,\n properties: {\n collectionSlug: { type: 'string', enum: uploadSlugs },\n docPrefix: { type: 'string' },\n filename: { type: 'string' },\n filesize: { type: 'integer', minimum: 0 },\n mimeType: { type: 'string' },\n },\n required: ['collectionSlug', 'filename', 'filesize', 'mimeType'],\n }),\n responses: {\n '200': jsonResponse(t('uploadInstructionsResult'), {\n type: 'object',\n properties: {\n type: { type: 'string', enum: ['http', 'dispatch'] },\n file: {\n type: 'object',\n properties: {\n filename: { type: 'string' },\n mimeType: { type: 'string' },\n size: { type: 'integer' },\n uploadReference: { type: 'object', additionalProperties: true },\n },\n required: ['filename', 'mimeType', 'size', 'uploadReference'],\n },\n request: {\n type: 'object',\n properties: {\n method: { type: 'string', enum: ['POST', 'PUT'] },\n url: { type: 'string' },\n headers: { type: 'object', additionalProperties: { type: 'string' } },\n },\n required: ['method', 'url'],\n },\n name: { type: 'string' },\n data: {},\n },\n required: ['type', 'file'],\n }),\n ...errorResponses(['400', '403', '500'], t),\n },\n security: [{ [SECURITY_SCHEME_NAME]: [] }],\n },\n }\n paths[`${ctx.apiRoute}/upload-instructions/{uploadId}`] = {\n parameters: [{ name: 'uploadId', in: 'path', required: true, schema: { type: 'string' } }],\n put: {\n tags: ['Uploads'],\n operationId: 'uploadStagedFile',\n summary: t('uploadStagePutSummary'),\n requestBody: {\n required: true,\n content: { '*/*': { schema: { type: 'string', format: 'binary' } } },\n },\n responses: staged,\n security: [{ [SECURITY_SCHEME_NAME]: [] }],\n },\n delete: {\n tags: ['Uploads'],\n operationId: 'deleteStagedFile',\n summary: t('uploadStageDeleteSummary'),\n responses: staged,\n security: [{ [SECURITY_SCHEME_NAME]: [] }],\n },\n }\n }\n\n if (reorderSlugs.length > 0) {\n const idType = ctx.defaultIDType === 'number' ? 'integer' : 'string'\n paths[`${ctx.apiRoute}/reorder`] = {\n post: {\n tags: ['Reorder'],\n operationId: 'reorder',\n summary: t('reorder'),\n requestBody: {\n ...jsonBody({\n type: 'object',\n properties: {\n collectionSlug: { type: 'string', enum: reorderSlugs },\n docsToMove: { type: 'array', minItems: 1, items: { type: idType } },\n newKeyWillBe: { type: 'string', enum: ['greater', 'less'] },\n orderableFieldName: { type: 'string' },\n target: {\n type: 'object',\n properties: { id: { type: idType }, key: { type: 'string' } },\n required: ['id'],\n },\n },\n required: ['collectionSlug', 'docsToMove', 'newKeyWillBe', 'orderableFieldName', 'target'],\n }),\n description: t('reorderBody'),\n },\n responses: {\n '200': jsonResponse(t('reorderResult'), {\n type: 'object',\n properties: {\n success: { type: 'boolean' },\n orderValues: { type: 'array', items: { type: 'string' } },\n message: { type: 'string' },\n },\n required: ['success'],\n }),\n '400': jsonResponse(t('errorReorder400'), {\n type: 'object',\n properties: { error: { type: 'string' } },\n required: ['error'],\n }),\n ...errorResponses(['403', '500'], t),\n },\n security: [{ [SECURITY_SCHEME_NAME]: [] }],\n },\n }\n }\n\n return paths\n}\n"],"mappings":";;AAMA,MAAa,oBAAoB,EAC/B,KACA,QACA,aACA,eAAe,CAAC,QAMC;CACjB,MAAM,IAAI,MAAM,IAAI,IAAI;CACxB,MAAM,QAAqB,CAAC;CAE5B,IAAI,QACF,MAAM,GAAG,IAAI,SAAS,YAAY,EAChC,KAAK;EACH,MAAM,CAAC,QAAQ;EACf,aAAa;EACb,WAAW;GACT,OAAO,aAAa,EAAE,YAAY,GAAG;IAAE,MAAM;IAAU,sBAAsB;GAAK,CAAC;GACnF,GAAG,eAAe,CAAC,KAAK,GAAG,CAAC;EAC9B;CACF,EACF;CAGF,IAAI,YAAY,SAAS,GAAG;EAC1B,MAAM,SAA0B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AgB;MAAsB;KAAQ;IAC3F,CAAC;IACD,aAAa,EAAE,aAAa;GAC9B;GACA,WAAW;IACT,OAAO,aAAa,EAAE,eAAe,GAAG;KACtC,MAAM;KACN,YAAY;MACV,SAAS,EAAE,MAAM,UAAU;MAC3B,aAAa;OAAE,MAAM;OAAS,OAAO,EAAE,MAAM,SAAS;MAAE;MACxD,SAAS,EAAE,MAAM,SAAS;KAC5B;KACA,UAAU,CAAC,SAAS;IACtB,CAAC;IACD,OAAO,aAAa,EAAE,iBAAiB,GAAG;KACxC,MAAM;KACN,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,EAAE;KACxC,UAAU,CAAC,OAAO;IACpB,CAAC;IACD,GAAG,eAAe,CAAC,OAAO,KAAK,GAAG,CAAC;GACrC;GACA,UAAU,CAAC,GAAG,uBAAuB,CAAC,EAAE,CAAC;EAC3C,EACF;CACF;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BuildContext, Entity, IDType } from "../../../shared/types/index.js";
|
|
2
|
+
import { EntitySecurity } from "../security.js";
|
|
3
|
+
import { PathsObject, SchemaObject } from "@scalar/openapi-types/3.2";
|
|
4
|
+
export interface VersionSchemas {
|
|
5
|
+
version: SchemaObject;
|
|
6
|
+
versionList: SchemaObject;
|
|
7
|
+
}
|
|
8
|
+
export declare const versionComponentSchemas: ({ docBase, base, idType }: {
|
|
9
|
+
docBase: string;
|
|
10
|
+
base: string;
|
|
11
|
+
idType: IDType;
|
|
12
|
+
}) => VersionSchemas;
|
|
13
|
+
export declare const buildVersionPaths: ({ entity, pathBase, ctx, schemaBase, nestedTags, security, global }: {
|
|
14
|
+
entity: Entity;
|
|
15
|
+
pathBase: string;
|
|
16
|
+
ctx: BuildContext;
|
|
17
|
+
schemaBase?: string;
|
|
18
|
+
nestedTags: boolean;
|
|
19
|
+
security?: EntitySecurity;
|
|
20
|
+
global?: boolean;
|
|
21
|
+
}) => PathsObject;
|
|
22
|
+
//# sourceMappingURL=versions.d.ts.map
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { refTo, schemaName } from "../names.js";
|
|
2
|
+
import { ERRORS, errorResponses, jsonResponse, nullableType } from "../components.js";
|
|
3
|
+
import { versionsTagName } from "../tags.js";
|
|
4
|
+
import { makeT } from "../../../shared/translations/index.js";
|
|
5
|
+
import { buildParamSchemas, commonReadParams } from "../params.js";
|
|
6
|
+
const buildVersionSchema = (base, idType) => {
|
|
7
|
+
const id = { type: idType === "number" ? "integer" : "string" };
|
|
8
|
+
return {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
id,
|
|
12
|
+
parent: id,
|
|
13
|
+
version: { $ref: refTo(base) },
|
|
14
|
+
createdAt: {
|
|
15
|
+
type: "string",
|
|
16
|
+
format: "date-time"
|
|
17
|
+
},
|
|
18
|
+
updatedAt: {
|
|
19
|
+
type: "string",
|
|
20
|
+
format: "date-time"
|
|
21
|
+
},
|
|
22
|
+
latest: { type: "boolean" },
|
|
23
|
+
autosave: { type: "boolean" },
|
|
24
|
+
snapshot: { type: "boolean" },
|
|
25
|
+
publishedLocale: { type: "string" }
|
|
26
|
+
},
|
|
27
|
+
required: [
|
|
28
|
+
"id",
|
|
29
|
+
"parent",
|
|
30
|
+
"version",
|
|
31
|
+
"createdAt",
|
|
32
|
+
"updatedAt"
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const buildVersionListSchema = (base) => ({
|
|
37
|
+
type: "object",
|
|
38
|
+
properties: {
|
|
39
|
+
docs: {
|
|
40
|
+
type: "array",
|
|
41
|
+
items: { $ref: refTo(`${base}Version`) }
|
|
42
|
+
},
|
|
43
|
+
totalDocs: { type: "integer" },
|
|
44
|
+
limit: { type: "integer" },
|
|
45
|
+
totalPages: { type: "integer" },
|
|
46
|
+
page: { type: "integer" },
|
|
47
|
+
pagingCounter: { type: "integer" },
|
|
48
|
+
hasPrevPage: { type: "boolean" },
|
|
49
|
+
hasNextPage: { type: "boolean" },
|
|
50
|
+
prevPage: nullableType("integer"),
|
|
51
|
+
nextPage: nullableType("integer")
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const versionComponentSchemas = ({ docBase, base, idType }) => ({
|
|
55
|
+
version: buildVersionSchema(docBase, idType),
|
|
56
|
+
versionList: buildVersionListSchema(base)
|
|
57
|
+
});
|
|
58
|
+
const versionRef = (base) => ({ $ref: refTo(`${base}Version`) });
|
|
59
|
+
const versionListRef = (base) => ({ $ref: refTo(`${base}VersionList`) });
|
|
60
|
+
const listVersionParams = ({ base, ctx, refs }) => {
|
|
61
|
+
const t = makeT(ctx.i18n);
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
name: "page",
|
|
65
|
+
in: "query",
|
|
66
|
+
schema: { type: "integer" }
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "limit",
|
|
70
|
+
in: "query",
|
|
71
|
+
schema: { type: "integer" }
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "pagination",
|
|
75
|
+
in: "query",
|
|
76
|
+
schema: { type: "boolean" }
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "sort",
|
|
80
|
+
in: "query",
|
|
81
|
+
description: t("paramSortShort"),
|
|
82
|
+
schema: { type: "string" }
|
|
83
|
+
},
|
|
84
|
+
...commonReadParams({
|
|
85
|
+
base,
|
|
86
|
+
ctx,
|
|
87
|
+
refs
|
|
88
|
+
}),
|
|
89
|
+
{
|
|
90
|
+
name: "where",
|
|
91
|
+
in: "query",
|
|
92
|
+
description: t("versionWhere"),
|
|
93
|
+
content: { "application/json": { schema: {
|
|
94
|
+
type: "object",
|
|
95
|
+
additionalProperties: true
|
|
96
|
+
} } }
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
|
+
};
|
|
100
|
+
const buildVersionPaths = ({ entity, pathBase, ctx, schemaBase, nestedTags, security = {}, global = false }) => {
|
|
101
|
+
if (!entity.versions) return {};
|
|
102
|
+
const t = makeT(ctx.i18n);
|
|
103
|
+
const name = schemaBase ?? schemaName(entity.slug);
|
|
104
|
+
const versionsTag = [nestedTags ? versionsTagName(name) : name];
|
|
105
|
+
const paramSchemas = buildParamSchemas({
|
|
106
|
+
fields: entity.fields,
|
|
107
|
+
ctx
|
|
108
|
+
});
|
|
109
|
+
const refs = {
|
|
110
|
+
select: true,
|
|
111
|
+
populate: Boolean(paramSchemas.populate),
|
|
112
|
+
joins: Boolean(paramSchemas.joins)
|
|
113
|
+
};
|
|
114
|
+
const idParam = {
|
|
115
|
+
name: "id",
|
|
116
|
+
in: "path",
|
|
117
|
+
required: true,
|
|
118
|
+
schema: { type: ctx.defaultIDType === "number" ? "integer" : "string" }
|
|
119
|
+
};
|
|
120
|
+
const message = { type: "string" };
|
|
121
|
+
const restoreResponse = global ? {
|
|
122
|
+
type: "object",
|
|
123
|
+
properties: {
|
|
124
|
+
message,
|
|
125
|
+
doc: { $ref: refTo(name) }
|
|
126
|
+
}
|
|
127
|
+
} : { allOf: [{ $ref: refTo(name) }, {
|
|
128
|
+
type: "object",
|
|
129
|
+
properties: { message }
|
|
130
|
+
}] };
|
|
131
|
+
return {
|
|
132
|
+
[`${pathBase}/versions`]: { get: {
|
|
133
|
+
tags: versionsTag,
|
|
134
|
+
operationId: `find${name}Versions`,
|
|
135
|
+
parameters: listVersionParams({
|
|
136
|
+
base: name,
|
|
137
|
+
ctx,
|
|
138
|
+
refs
|
|
139
|
+
}),
|
|
140
|
+
responses: {
|
|
141
|
+
"200": jsonResponse(t("versionList"), versionListRef(name)),
|
|
142
|
+
...errorResponses(ERRORS.versionList, t)
|
|
143
|
+
},
|
|
144
|
+
security: security.readVersions
|
|
145
|
+
} },
|
|
146
|
+
[`${pathBase}/versions/{id}`]: {
|
|
147
|
+
parameters: [idParam],
|
|
148
|
+
get: {
|
|
149
|
+
tags: versionsTag,
|
|
150
|
+
operationId: `find${name}VersionById`,
|
|
151
|
+
parameters: commonReadParams({
|
|
152
|
+
base: name,
|
|
153
|
+
ctx,
|
|
154
|
+
refs
|
|
155
|
+
}),
|
|
156
|
+
responses: {
|
|
157
|
+
"200": jsonResponse(t("versionSingle"), versionRef(name)),
|
|
158
|
+
...errorResponses(ERRORS.versionRead, t)
|
|
159
|
+
},
|
|
160
|
+
security: security.readVersions
|
|
161
|
+
},
|
|
162
|
+
post: {
|
|
163
|
+
tags: versionsTag,
|
|
164
|
+
operationId: `restore${name}Version`,
|
|
165
|
+
parameters: [{
|
|
166
|
+
name: "depth",
|
|
167
|
+
in: "query",
|
|
168
|
+
schema: { type: "integer" }
|
|
169
|
+
}, {
|
|
170
|
+
name: "draft",
|
|
171
|
+
in: "query",
|
|
172
|
+
schema: { type: "boolean" }
|
|
173
|
+
}],
|
|
174
|
+
responses: {
|
|
175
|
+
"200": jsonResponse(t("versionRestored"), restoreResponse),
|
|
176
|
+
...errorResponses(ERRORS.versionRestore, t)
|
|
177
|
+
},
|
|
178
|
+
security: security.update
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
export { buildVersionPaths, versionComponentSchemas };
|
|
184
|
+
|
|
185
|
+
//# sourceMappingURL=versions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.js","names":[],"sources":["../../../../src/server/spec/paths/versions.ts"],"sourcesContent":["import type { ParameterObject, PathsObject, ReferenceObject, SchemaObject } from '@scalar/openapi-types/3.2'\n\nimport { ERRORS, errorResponses, jsonResponse, nullableType } from '@/server/spec/components.js'\nimport { refTo, schemaName } from '@/server/spec/names.js'\nimport { buildParamSchemas, commonReadParams, type ReadParamRefs } from '@/server/spec/params.js'\nimport type { EntitySecurity } from '@/server/spec/security.js'\nimport { versionsTagName } from '@/server/spec/tags.js'\nimport { makeT } from '@/shared/translations/index.js'\nimport type { BuildContext, Entity, IDType } from '@/shared/types/index.js'\n\nconst buildVersionSchema = (base: string, idType: IDType): SchemaObject => {\n const id: SchemaObject = { type: idType === 'number' ? 'integer' : 'string' }\n return {\n type: 'object',\n properties: {\n id,\n parent: id,\n version: { $ref: refTo(base) },\n createdAt: { type: 'string', format: 'date-time' },\n updatedAt: { type: 'string', format: 'date-time' },\n latest: { type: 'boolean' },\n autosave: { type: 'boolean' },\n snapshot: { type: 'boolean' },\n publishedLocale: { type: 'string' },\n },\n required: ['id', 'parent', 'version', 'createdAt', 'updatedAt'],\n }\n}\n\nconst buildVersionListSchema = (base: string): SchemaObject => ({\n type: 'object',\n properties: {\n docs: { type: 'array', items: { $ref: refTo(`${base}Version`) } },\n totalDocs: { type: 'integer' },\n limit: { type: 'integer' },\n totalPages: { type: 'integer' },\n page: { type: 'integer' },\n pagingCounter: { type: 'integer' },\n hasPrevPage: { type: 'boolean' },\n hasNextPage: { type: 'boolean' },\n prevPage: nullableType('integer'),\n nextPage: nullableType('integer'),\n },\n})\n\nexport interface VersionSchemas {\n version: SchemaObject\n versionList: SchemaObject\n}\n\nexport const versionComponentSchemas = ({\n docBase,\n base,\n idType,\n}: {\n docBase: string\n base: string\n idType: IDType\n}): VersionSchemas => ({\n version: buildVersionSchema(docBase, idType),\n versionList: buildVersionListSchema(base),\n})\n\nconst versionRef = (base: string): ReferenceObject => ({\n $ref: refTo(`${base}Version`),\n})\nconst versionListRef = (base: string): ReferenceObject => ({\n $ref: refTo(`${base}VersionList`),\n})\n\nconst listVersionParams = ({\n base,\n ctx,\n refs,\n}: {\n base: string\n ctx: BuildContext\n refs: ReadParamRefs\n}): ParameterObject[] => {\n const t = makeT(ctx.i18n)\n return [\n { name: 'page', in: 'query', schema: { type: 'integer' } },\n { name: 'limit', in: 'query', schema: { type: 'integer' } },\n { name: 'pagination', in: 'query', schema: { type: 'boolean' } },\n {\n name: 'sort',\n in: 'query',\n description: t('paramSortShort'),\n schema: { type: 'string' },\n },\n ...commonReadParams({ base, ctx, refs }),\n {\n name: 'where',\n in: 'query',\n description: t('versionWhere'),\n content: {\n 'application/json': { schema: { type: 'object', additionalProperties: true } },\n },\n },\n ]\n}\n\nexport const buildVersionPaths = ({\n entity,\n pathBase,\n ctx,\n schemaBase,\n nestedTags,\n security = {},\n global = false,\n}: {\n entity: Entity\n pathBase: string\n ctx: BuildContext\n schemaBase?: string\n nestedTags: boolean\n security?: EntitySecurity\n global?: boolean\n}): PathsObject => {\n if (!entity.versions) return {}\n\n const t = makeT(ctx.i18n)\n const name = schemaBase ?? schemaName(entity.slug)\n const versionsTag = [nestedTags ? versionsTagName(name) : name]\n const paramSchemas = buildParamSchemas({ fields: entity.fields, ctx })\n const refs: ReadParamRefs = {\n select: true,\n populate: Boolean(paramSchemas.populate),\n joins: Boolean(paramSchemas.joins),\n }\n const idParam: ParameterObject = {\n name: 'id',\n in: 'path',\n required: true,\n schema: { type: ctx.defaultIDType === 'number' ? 'integer' : 'string' },\n }\n\n const message: SchemaObject = { type: 'string' }\n const restoreResponse: SchemaObject = global\n ? { type: 'object', properties: { message, doc: { $ref: refTo(name) } } }\n : { allOf: [{ $ref: refTo(name) }, { type: 'object', properties: { message } }] }\n\n return {\n [`${pathBase}/versions`]: {\n get: {\n tags: versionsTag,\n operationId: `find${name}Versions`,\n parameters: listVersionParams({ base: name, ctx, refs }),\n responses: {\n '200': jsonResponse(t('versionList'), versionListRef(name)),\n ...errorResponses(ERRORS.versionList, t),\n },\n security: security.readVersions,\n },\n },\n [`${pathBase}/versions/{id}`]: {\n parameters: [idParam],\n get: {\n tags: versionsTag,\n operationId: `find${name}VersionById`,\n parameters: commonReadParams({ base: name, ctx, refs }),\n responses: {\n '200': jsonResponse(t('versionSingle'), versionRef(name)),\n ...errorResponses(ERRORS.versionRead, t),\n },\n security: security.readVersions,\n },\n post: {\n tags: versionsTag,\n operationId: `restore${name}Version`,\n parameters: [\n { name: 'depth', in: 'query', schema: { type: 'integer' } },\n { name: 'draft', in: 'query', schema: { type: 'boolean' } },\n ],\n responses: {\n '200': jsonResponse(t('versionRestored'), restoreResponse),\n ...errorResponses(ERRORS.versionRestore, t),\n },\n security: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