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