@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
package/dist/spec/paths/auth.js
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import { makeT } from "../../translations/index.js";
|
|
2
|
-
import { ERRORS, errorResponses, jsonBody, jsonResponse, messageResponse } from "../components.js";
|
|
3
|
-
import { refTo, schemaName } from "../names.js";
|
|
4
|
-
import { authTagName } from "../tags.js";
|
|
5
|
-
const identifierBody = (auth, extra = {})=>{
|
|
6
|
-
const email = {
|
|
7
|
-
type: 'string',
|
|
8
|
-
format: 'email'
|
|
9
|
-
};
|
|
10
|
-
const username = {
|
|
11
|
-
type: 'string'
|
|
12
|
-
};
|
|
13
|
-
const extraRequired = Object.keys(extra);
|
|
14
|
-
const loginWithUsername = auth?.loginWithUsername;
|
|
15
|
-
const base = {
|
|
16
|
-
type: 'object',
|
|
17
|
-
additionalProperties: false
|
|
18
|
-
};
|
|
19
|
-
if (!loginWithUsername) return {
|
|
20
|
-
...base,
|
|
21
|
-
properties: {
|
|
22
|
-
email,
|
|
23
|
-
...extra
|
|
24
|
-
},
|
|
25
|
-
required: [
|
|
26
|
-
'email',
|
|
27
|
-
...extraRequired
|
|
28
|
-
]
|
|
29
|
-
};
|
|
30
|
-
if ('object' == typeof loginWithUsername && loginWithUsername.allowEmailLogin) return {
|
|
31
|
-
...base,
|
|
32
|
-
properties: {
|
|
33
|
-
email,
|
|
34
|
-
username,
|
|
35
|
-
...extra
|
|
36
|
-
},
|
|
37
|
-
...extraRequired.length > 0 ? {
|
|
38
|
-
required: extraRequired
|
|
39
|
-
} : {},
|
|
40
|
-
anyOf: [
|
|
41
|
-
{
|
|
42
|
-
required: [
|
|
43
|
-
'email'
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
required: [
|
|
48
|
-
'username'
|
|
49
|
-
]
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
};
|
|
53
|
-
return {
|
|
54
|
-
...base,
|
|
55
|
-
properties: {
|
|
56
|
-
username,
|
|
57
|
-
...extra
|
|
58
|
-
},
|
|
59
|
-
required: [
|
|
60
|
-
'username',
|
|
61
|
-
...extraRequired
|
|
62
|
-
]
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
const buildAuthPaths = ({ collection, ctx, includeAdmin, nestedTags })=>{
|
|
66
|
-
const auth = collection.auth;
|
|
67
|
-
if (!auth || auth.disableLocalStrategy) return {};
|
|
68
|
-
const t = makeT(ctx.i18n);
|
|
69
|
-
const name = schemaName(collection.slug);
|
|
70
|
-
const base = `${ctx.apiRoute}/${collection.slug}`;
|
|
71
|
-
const tag = [
|
|
72
|
-
nestedTags ? authTagName(name) : name
|
|
73
|
-
];
|
|
74
|
-
const userRef = {
|
|
75
|
-
$ref: refTo(name)
|
|
76
|
-
};
|
|
77
|
-
const op = (operationId, codes, extra)=>({
|
|
78
|
-
tags: tag,
|
|
79
|
-
operationId,
|
|
80
|
-
...extra,
|
|
81
|
-
responses: {
|
|
82
|
-
...extra.responses,
|
|
83
|
-
...errorResponses(codes, t)
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
const paths = {
|
|
87
|
-
[`${base}/login`]: {
|
|
88
|
-
post: op(`login${name}`, ERRORS.login, {
|
|
89
|
-
requestBody: jsonBody(identifierBody(auth, {
|
|
90
|
-
password: {
|
|
91
|
-
type: 'string'
|
|
92
|
-
}
|
|
93
|
-
})),
|
|
94
|
-
responses: {
|
|
95
|
-
200: jsonResponse(t('authLogin'), {
|
|
96
|
-
type: 'object',
|
|
97
|
-
properties: {
|
|
98
|
-
message: {
|
|
99
|
-
type: 'string'
|
|
100
|
-
},
|
|
101
|
-
user: userRef,
|
|
102
|
-
token: {
|
|
103
|
-
type: 'string'
|
|
104
|
-
},
|
|
105
|
-
exp: {
|
|
106
|
-
type: 'integer'
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
},
|
|
113
|
-
[`${base}/logout`]: {
|
|
114
|
-
post: op(`logout${name}`, ERRORS.session, {
|
|
115
|
-
responses: messageResponse(t('authLogout'))
|
|
116
|
-
})
|
|
117
|
-
},
|
|
118
|
-
[`${base}/me`]: {
|
|
119
|
-
get: op(`me${name}`, ERRORS.session, {
|
|
120
|
-
responses: {
|
|
121
|
-
200: jsonResponse(t('authMe'), {
|
|
122
|
-
type: 'object',
|
|
123
|
-
properties: {
|
|
124
|
-
user: userRef,
|
|
125
|
-
collection: {
|
|
126
|
-
type: 'string'
|
|
127
|
-
},
|
|
128
|
-
token: {
|
|
129
|
-
type: 'string'
|
|
130
|
-
},
|
|
131
|
-
exp: {
|
|
132
|
-
type: 'integer'
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
},
|
|
139
|
-
[`${base}/refresh-token`]: {
|
|
140
|
-
post: op(`refreshToken${name}`, ERRORS.session, {
|
|
141
|
-
responses: {
|
|
142
|
-
200: jsonResponse(t('authRefreshToken'), {
|
|
143
|
-
type: 'object',
|
|
144
|
-
properties: {
|
|
145
|
-
message: {
|
|
146
|
-
type: 'string'
|
|
147
|
-
},
|
|
148
|
-
refreshedToken: {
|
|
149
|
-
type: 'string'
|
|
150
|
-
},
|
|
151
|
-
exp: {
|
|
152
|
-
type: 'integer'
|
|
153
|
-
},
|
|
154
|
-
user: userRef
|
|
155
|
-
}
|
|
156
|
-
})
|
|
157
|
-
}
|
|
158
|
-
})
|
|
159
|
-
},
|
|
160
|
-
[`${base}/forgot-password`]: {
|
|
161
|
-
post: op(`forgotPassword${name}`, ERRORS.authAction, {
|
|
162
|
-
requestBody: jsonBody(identifierBody(auth)),
|
|
163
|
-
responses: messageResponse(t('authForgotPassword'))
|
|
164
|
-
})
|
|
165
|
-
},
|
|
166
|
-
[`${base}/reset-password`]: {
|
|
167
|
-
post: op(`resetPassword${name}`, ERRORS.authAction, {
|
|
168
|
-
requestBody: jsonBody({
|
|
169
|
-
type: 'object',
|
|
170
|
-
additionalProperties: false,
|
|
171
|
-
properties: {
|
|
172
|
-
token: {
|
|
173
|
-
type: 'string'
|
|
174
|
-
},
|
|
175
|
-
password: {
|
|
176
|
-
type: 'string'
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
required: [
|
|
180
|
-
'token',
|
|
181
|
-
'password'
|
|
182
|
-
]
|
|
183
|
-
}),
|
|
184
|
-
responses: {
|
|
185
|
-
200: jsonResponse(t('authResetPassword'), {
|
|
186
|
-
type: 'object',
|
|
187
|
-
properties: {
|
|
188
|
-
message: {
|
|
189
|
-
type: 'string'
|
|
190
|
-
},
|
|
191
|
-
token: {
|
|
192
|
-
type: 'string'
|
|
193
|
-
},
|
|
194
|
-
user: userRef
|
|
195
|
-
}
|
|
196
|
-
})
|
|
197
|
-
}
|
|
198
|
-
})
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
if (includeAdmin) {
|
|
202
|
-
paths[`${base}/first-register`] = {
|
|
203
|
-
post: op(`firstRegister${name}`, ERRORS.create, {
|
|
204
|
-
requestBody: jsonBody({
|
|
205
|
-
$ref: refTo(`${name}Create`)
|
|
206
|
-
}),
|
|
207
|
-
responses: {
|
|
208
|
-
200: jsonResponse(t('authFirstRegister'), {
|
|
209
|
-
type: 'object',
|
|
210
|
-
properties: {
|
|
211
|
-
message: {
|
|
212
|
-
type: 'string'
|
|
213
|
-
},
|
|
214
|
-
user: userRef,
|
|
215
|
-
token: {
|
|
216
|
-
type: 'string'
|
|
217
|
-
},
|
|
218
|
-
exp: {
|
|
219
|
-
type: 'integer'
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
})
|
|
223
|
-
}
|
|
224
|
-
})
|
|
225
|
-
};
|
|
226
|
-
paths[`${base}/init`] = {
|
|
227
|
-
get: op(`init${name}`, ERRORS.session, {
|
|
228
|
-
responses: {
|
|
229
|
-
200: jsonResponse(t('authInit'), {
|
|
230
|
-
type: 'object',
|
|
231
|
-
properties: {
|
|
232
|
-
initialized: {
|
|
233
|
-
type: 'boolean'
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
})
|
|
237
|
-
}
|
|
238
|
-
})
|
|
239
|
-
};
|
|
240
|
-
paths[`${base}/access`] = {
|
|
241
|
-
get: op(`access${name}`, ERRORS.session, {
|
|
242
|
-
responses: {
|
|
243
|
-
200: jsonResponse(t('authAccess'), {
|
|
244
|
-
type: 'object',
|
|
245
|
-
additionalProperties: true
|
|
246
|
-
})
|
|
247
|
-
}
|
|
248
|
-
})
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
paths[`${base}/unlock`] = {
|
|
252
|
-
post: op(`unlock${name}`, ERRORS.authAction, {
|
|
253
|
-
requestBody: jsonBody(identifierBody(auth)),
|
|
254
|
-
responses: messageResponse(t('authUnlock'))
|
|
255
|
-
})
|
|
256
|
-
};
|
|
257
|
-
if (auth.verify) paths[`${base}/verify/{id}`] = {
|
|
258
|
-
post: op(`verify${name}`, ERRORS.authAction, {
|
|
259
|
-
parameters: [
|
|
260
|
-
{
|
|
261
|
-
name: 'id',
|
|
262
|
-
in: 'path',
|
|
263
|
-
required: true,
|
|
264
|
-
schema: {
|
|
265
|
-
type: 'string'
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
],
|
|
269
|
-
responses: messageResponse(t('authVerify'))
|
|
270
|
-
})
|
|
271
|
-
};
|
|
272
|
-
return paths;
|
|
273
|
-
};
|
|
274
|
-
export { buildAuthPaths };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SanitizedCollectionConfig } from 'payload';
|
|
2
|
-
import type { PathsObject } from '@scalar/openapi-types/3.2';
|
|
3
|
-
import type { BuildContext } from '../../types.js';
|
|
4
|
-
import type { EntitySecurity } from '../security.js';
|
|
5
|
-
export declare const buildCollectionPaths: ({ collection, ctx, security, }: {
|
|
6
|
-
collection: SanitizedCollectionConfig;
|
|
7
|
-
ctx: BuildContext;
|
|
8
|
-
security?: EntitySecurity;
|
|
9
|
-
}) => PathsObject;
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import { makeT } from "../../translations/index.js";
|
|
2
|
-
import { ERRORS, errorResponses, jsonOk, jsonResponse, uploadRequestBody } from "../components.js";
|
|
3
|
-
import { createSchemaName, listSchemaName, refTo, schemaName, updateSchemaName } from "../names.js";
|
|
4
|
-
import { buildListParams, buildParamSchemas, commonReadParams, writeParams } from "../params.js";
|
|
5
|
-
const buildCollectionPaths = ({ collection, ctx, security = {} })=>{
|
|
6
|
-
const t = makeT(ctx.i18n);
|
|
7
|
-
const name = schemaName(collection.slug);
|
|
8
|
-
const base = `${ctx.apiRoute}/${collection.slug}`;
|
|
9
|
-
const docRef = {
|
|
10
|
-
$ref: refTo(name)
|
|
11
|
-
};
|
|
12
|
-
const listRef = {
|
|
13
|
-
$ref: refTo(listSchemaName(name))
|
|
14
|
-
};
|
|
15
|
-
const createRef = {
|
|
16
|
-
$ref: refTo(createSchemaName(name))
|
|
17
|
-
};
|
|
18
|
-
const updateRef = {
|
|
19
|
-
$ref: refTo(updateSchemaName(name))
|
|
20
|
-
};
|
|
21
|
-
const idType = 'number' === ctx.defaultIDType ? 'integer' : 'string';
|
|
22
|
-
const { read: secRead, create: secCreate, update: secUpdate, delete: secDelete } = security;
|
|
23
|
-
const allowBulk = true !== collection.disableBulkEdit;
|
|
24
|
-
const allowDuplicate = true !== collection.disableDuplicate;
|
|
25
|
-
const paramSchemas = buildParamSchemas({
|
|
26
|
-
fields: collection.fields,
|
|
27
|
-
ctx
|
|
28
|
-
});
|
|
29
|
-
const refs = {
|
|
30
|
-
select: true,
|
|
31
|
-
populate: Boolean(paramSchemas.populate),
|
|
32
|
-
joins: Boolean(paramSchemas.joins)
|
|
33
|
-
};
|
|
34
|
-
const isUpload = Boolean(collection.upload);
|
|
35
|
-
const fileRequiredOnCreate = 'object' == typeof collection.upload ? false !== collection.upload.filesRequiredOnCreate : true;
|
|
36
|
-
const requestBody = (ref, fileRequired)=>isUpload ? uploadRequestBody({
|
|
37
|
-
bodyRef: ref,
|
|
38
|
-
fileRequired,
|
|
39
|
-
t
|
|
40
|
-
}) : {
|
|
41
|
-
content: {
|
|
42
|
-
'application/json': {
|
|
43
|
-
schema: ref
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const mutationSchema = {
|
|
48
|
-
type: 'object',
|
|
49
|
-
properties: {
|
|
50
|
-
message: {
|
|
51
|
-
type: 'string'
|
|
52
|
-
},
|
|
53
|
-
doc: docRef
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const listResponse = {
|
|
57
|
-
...jsonOk(t('collectionList'), listRef),
|
|
58
|
-
...errorResponses(ERRORS.list, t)
|
|
59
|
-
};
|
|
60
|
-
const findByIdResponse = {
|
|
61
|
-
...jsonOk(t('collectionDoc'), docRef),
|
|
62
|
-
...errorResponses(ERRORS.read, t)
|
|
63
|
-
};
|
|
64
|
-
const createResponse = {
|
|
65
|
-
201: jsonResponse(t('collectionCreated'), mutationSchema),
|
|
66
|
-
...errorResponses(ERRORS.create, t)
|
|
67
|
-
};
|
|
68
|
-
const updateResponse = {
|
|
69
|
-
...jsonOk(t('collectionUpdated'), mutationSchema),
|
|
70
|
-
...errorResponses(ERRORS.update, t)
|
|
71
|
-
};
|
|
72
|
-
const deleteResponse = {
|
|
73
|
-
...jsonOk(t('collectionDeleted'), mutationSchema),
|
|
74
|
-
...errorResponses(ERRORS["delete"], t)
|
|
75
|
-
};
|
|
76
|
-
const bulkSchema = {
|
|
77
|
-
type: 'object',
|
|
78
|
-
properties: {
|
|
79
|
-
message: {
|
|
80
|
-
type: 'string'
|
|
81
|
-
},
|
|
82
|
-
docs: {
|
|
83
|
-
type: 'array',
|
|
84
|
-
items: docRef
|
|
85
|
-
},
|
|
86
|
-
errors: {
|
|
87
|
-
type: 'array',
|
|
88
|
-
items: {
|
|
89
|
-
type: 'object',
|
|
90
|
-
properties: {
|
|
91
|
-
message: {
|
|
92
|
-
type: 'string'
|
|
93
|
-
},
|
|
94
|
-
id: {
|
|
95
|
-
type: idType
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
const bulkUpdateResponse = {
|
|
103
|
-
...jsonOk(t('collectionBulkUpdate'), bulkSchema),
|
|
104
|
-
...errorResponses(ERRORS.update, t)
|
|
105
|
-
};
|
|
106
|
-
const bulkDeleteResponse = {
|
|
107
|
-
...jsonOk(t('collectionBulkDelete'), bulkSchema),
|
|
108
|
-
...errorResponses(ERRORS["delete"], t)
|
|
109
|
-
};
|
|
110
|
-
const countResponse = {
|
|
111
|
-
...jsonOk(t('collectionCount'), {
|
|
112
|
-
type: 'object',
|
|
113
|
-
properties: {
|
|
114
|
-
totalDocs: {
|
|
115
|
-
type: 'integer'
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}),
|
|
119
|
-
...errorResponses(ERRORS.list, t)
|
|
120
|
-
};
|
|
121
|
-
const listParams = buildListParams({
|
|
122
|
-
base: name,
|
|
123
|
-
fields: collection.fields,
|
|
124
|
-
ctx,
|
|
125
|
-
refs
|
|
126
|
-
});
|
|
127
|
-
const bulkParams = listParams.filter((p)=>'where' === p.name);
|
|
128
|
-
const bulkUpdateParams = listParams.filter((p)=>[
|
|
129
|
-
'limit',
|
|
130
|
-
'sort',
|
|
131
|
-
'where'
|
|
132
|
-
].includes(p.name));
|
|
133
|
-
const write = (operation)=>writeParams({
|
|
134
|
-
base: name,
|
|
135
|
-
entity: collection,
|
|
136
|
-
ctx,
|
|
137
|
-
refs,
|
|
138
|
-
operation
|
|
139
|
-
});
|
|
140
|
-
const deleteParams = write('delete');
|
|
141
|
-
const bulkOps = allowBulk ? {
|
|
142
|
-
patch: {
|
|
143
|
-
tags: [
|
|
144
|
-
name
|
|
145
|
-
],
|
|
146
|
-
operationId: `update${name}`,
|
|
147
|
-
parameters: [
|
|
148
|
-
...bulkUpdateParams,
|
|
149
|
-
...write('update')
|
|
150
|
-
],
|
|
151
|
-
requestBody: requestBody(updateRef, false),
|
|
152
|
-
responses: bulkUpdateResponse,
|
|
153
|
-
security: secUpdate
|
|
154
|
-
},
|
|
155
|
-
delete: {
|
|
156
|
-
tags: [
|
|
157
|
-
name
|
|
158
|
-
],
|
|
159
|
-
operationId: `delete${name}`,
|
|
160
|
-
parameters: [
|
|
161
|
-
...bulkParams,
|
|
162
|
-
...deleteParams
|
|
163
|
-
],
|
|
164
|
-
responses: bulkDeleteResponse,
|
|
165
|
-
security: secDelete
|
|
166
|
-
}
|
|
167
|
-
} : {};
|
|
168
|
-
const paths = {
|
|
169
|
-
[base]: {
|
|
170
|
-
get: {
|
|
171
|
-
tags: [
|
|
172
|
-
name
|
|
173
|
-
],
|
|
174
|
-
operationId: `find${name}`,
|
|
175
|
-
parameters: buildListParams({
|
|
176
|
-
base: name,
|
|
177
|
-
fields: collection.fields,
|
|
178
|
-
ctx,
|
|
179
|
-
refs
|
|
180
|
-
}),
|
|
181
|
-
responses: listResponse,
|
|
182
|
-
security: secRead
|
|
183
|
-
},
|
|
184
|
-
post: {
|
|
185
|
-
tags: [
|
|
186
|
-
name
|
|
187
|
-
],
|
|
188
|
-
operationId: `create${name}`,
|
|
189
|
-
parameters: write('create'),
|
|
190
|
-
requestBody: requestBody(createRef, fileRequiredOnCreate),
|
|
191
|
-
responses: createResponse,
|
|
192
|
-
security: secCreate
|
|
193
|
-
},
|
|
194
|
-
...bulkOps
|
|
195
|
-
},
|
|
196
|
-
[`${base}/count`]: {
|
|
197
|
-
get: {
|
|
198
|
-
tags: [
|
|
199
|
-
name
|
|
200
|
-
],
|
|
201
|
-
operationId: `count${name}`,
|
|
202
|
-
parameters: bulkParams,
|
|
203
|
-
responses: countResponse,
|
|
204
|
-
security: secRead
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
[`${base}/{id}`]: {
|
|
208
|
-
parameters: [
|
|
209
|
-
{
|
|
210
|
-
name: 'id',
|
|
211
|
-
in: 'path',
|
|
212
|
-
required: true,
|
|
213
|
-
schema: {
|
|
214
|
-
type: idType
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
],
|
|
218
|
-
get: {
|
|
219
|
-
tags: [
|
|
220
|
-
name
|
|
221
|
-
],
|
|
222
|
-
operationId: `find${name}ById`,
|
|
223
|
-
parameters: commonReadParams({
|
|
224
|
-
base: name,
|
|
225
|
-
ctx,
|
|
226
|
-
refs
|
|
227
|
-
}),
|
|
228
|
-
responses: findByIdResponse,
|
|
229
|
-
security: secRead
|
|
230
|
-
},
|
|
231
|
-
patch: {
|
|
232
|
-
tags: [
|
|
233
|
-
name
|
|
234
|
-
],
|
|
235
|
-
operationId: `update${name}ById`,
|
|
236
|
-
parameters: write('updateByID'),
|
|
237
|
-
requestBody: requestBody(updateRef, false),
|
|
238
|
-
responses: updateResponse,
|
|
239
|
-
security: secUpdate
|
|
240
|
-
},
|
|
241
|
-
delete: {
|
|
242
|
-
tags: [
|
|
243
|
-
name
|
|
244
|
-
],
|
|
245
|
-
operationId: `delete${name}ById`,
|
|
246
|
-
parameters: deleteParams,
|
|
247
|
-
responses: deleteResponse,
|
|
248
|
-
security: secDelete
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
if (allowDuplicate) paths[`${base}/{id}/duplicate`] = {
|
|
253
|
-
parameters: [
|
|
254
|
-
{
|
|
255
|
-
name: 'id',
|
|
256
|
-
in: 'path',
|
|
257
|
-
required: true,
|
|
258
|
-
schema: {
|
|
259
|
-
type: idType
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
],
|
|
263
|
-
post: {
|
|
264
|
-
tags: [
|
|
265
|
-
name
|
|
266
|
-
],
|
|
267
|
-
operationId: `duplicate${name}`,
|
|
268
|
-
parameters: write('duplicate'),
|
|
269
|
-
responses: {
|
|
270
|
-
...jsonOk(t('collectionDuplicated'), mutationSchema),
|
|
271
|
-
...errorResponses(ERRORS.create, t)
|
|
272
|
-
},
|
|
273
|
-
security: secCreate
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
return paths;
|
|
277
|
-
};
|
|
278
|
-
export { buildCollectionPaths };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SanitizedCollectionConfig, SanitizedConfig, SanitizedGlobalConfig } from 'payload';
|
|
2
|
-
import type { PathsObject } from '@scalar/openapi-types/3.2';
|
|
3
|
-
import type { BuildContext } from '../../types.js';
|
|
4
|
-
export declare const buildCustomEndpointPaths: ({ config, collections, globals, ctx, }: {
|
|
5
|
-
config: SanitizedConfig;
|
|
6
|
-
collections: SanitizedCollectionConfig[];
|
|
7
|
-
globals: SanitizedGlobalConfig[];
|
|
8
|
-
ctx: BuildContext;
|
|
9
|
-
}) => PathsObject;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const getOpenapiMeta = (endpoint)=>{
|
|
2
|
-
const meta = endpoint.custom?.openapi;
|
|
3
|
-
return meta && 'object' == typeof meta ? meta : void 0;
|
|
4
|
-
};
|
|
5
|
-
const normalizePath = (prefix, path)=>{
|
|
6
|
-
const joined = `${prefix}${path.startsWith('/') ? path : `/${path}`}`;
|
|
7
|
-
return joined.replace(/:([A-Za-z0-9_]+)/g, '{$1}');
|
|
8
|
-
};
|
|
9
|
-
const collect = ({ endpoints, prefix, out })=>{
|
|
10
|
-
if (!endpoints) return;
|
|
11
|
-
for (const endpoint of endpoints){
|
|
12
|
-
const meta = getOpenapiMeta(endpoint);
|
|
13
|
-
if (!meta) continue;
|
|
14
|
-
const path = normalizePath(prefix, endpoint.path);
|
|
15
|
-
const method = endpoint.method.toLowerCase();
|
|
16
|
-
out[path] = {
|
|
17
|
-
...out[path],
|
|
18
|
-
[method]: meta
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const buildCustomEndpointPaths = ({ config, collections, globals, ctx })=>{
|
|
23
|
-
const out = {};
|
|
24
|
-
collect({
|
|
25
|
-
endpoints: config.endpoints,
|
|
26
|
-
prefix: '',
|
|
27
|
-
out
|
|
28
|
-
});
|
|
29
|
-
for (const collection of collections)collect({
|
|
30
|
-
endpoints: collection.endpoints,
|
|
31
|
-
prefix: `${ctx.apiRoute}/${collection.slug}`,
|
|
32
|
-
out
|
|
33
|
-
});
|
|
34
|
-
for (const global of globals)collect({
|
|
35
|
-
endpoints: global.endpoints,
|
|
36
|
-
prefix: `${ctx.apiRoute}/globals/${global.slug}`,
|
|
37
|
-
out
|
|
38
|
-
});
|
|
39
|
-
return out;
|
|
40
|
-
};
|
|
41
|
-
export { buildCustomEndpointPaths };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SanitizedGlobalConfig } from 'payload';
|
|
2
|
-
import type { PathsObject } from '@scalar/openapi-types/3.2';
|
|
3
|
-
import type { BuildContext } from '../../types.js';
|
|
4
|
-
import type { EntitySecurity } from '../security.js';
|
|
5
|
-
export declare const buildGlobalPaths: ({ global, ctx, security, }: {
|
|
6
|
-
global: SanitizedGlobalConfig;
|
|
7
|
-
ctx: BuildContext;
|
|
8
|
-
security?: EntitySecurity;
|
|
9
|
-
}) => PathsObject;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { makeT } from "../../translations/index.js";
|
|
2
|
-
import { ERRORS, errorResponses, jsonOk } from "../components.js";
|
|
3
|
-
import { globalSchemaName, refTo, updateSchemaName } from "../names.js";
|
|
4
|
-
import { buildParamSchemas, commonReadParams, writeParams } from "../params.js";
|
|
5
|
-
const buildGlobalPaths = ({ global, ctx, security = {} })=>{
|
|
6
|
-
const t = makeT(ctx.i18n);
|
|
7
|
-
const name = globalSchemaName(global.slug);
|
|
8
|
-
const docRef = {
|
|
9
|
-
$ref: refTo(name)
|
|
10
|
-
};
|
|
11
|
-
const updateRef = {
|
|
12
|
-
$ref: refTo(updateSchemaName(name))
|
|
13
|
-
};
|
|
14
|
-
const { read: secRead, update: secUpdate } = security;
|
|
15
|
-
const paramSchemas = buildParamSchemas({
|
|
16
|
-
fields: global.fields,
|
|
17
|
-
ctx
|
|
18
|
-
});
|
|
19
|
-
const refs = {
|
|
20
|
-
select: true,
|
|
21
|
-
populate: Boolean(paramSchemas.populate),
|
|
22
|
-
joins: Boolean(paramSchemas.joins)
|
|
23
|
-
};
|
|
24
|
-
return {
|
|
25
|
-
[`${ctx.apiRoute}/globals/${global.slug}`]: {
|
|
26
|
-
get: {
|
|
27
|
-
tags: [
|
|
28
|
-
name
|
|
29
|
-
],
|
|
30
|
-
operationId: `find${name}`,
|
|
31
|
-
parameters: commonReadParams({
|
|
32
|
-
base: name,
|
|
33
|
-
ctx,
|
|
34
|
-
refs
|
|
35
|
-
}),
|
|
36
|
-
responses: {
|
|
37
|
-
...jsonOk(t('globalDoc'), docRef),
|
|
38
|
-
...errorResponses(ERRORS.globalRead, t)
|
|
39
|
-
},
|
|
40
|
-
security: secRead
|
|
41
|
-
},
|
|
42
|
-
post: {
|
|
43
|
-
tags: [
|
|
44
|
-
name
|
|
45
|
-
],
|
|
46
|
-
operationId: `update${name}`,
|
|
47
|
-
parameters: writeParams({
|
|
48
|
-
base: name,
|
|
49
|
-
entity: global,
|
|
50
|
-
ctx,
|
|
51
|
-
refs,
|
|
52
|
-
operation: 'globalUpdate'
|
|
53
|
-
}),
|
|
54
|
-
requestBody: {
|
|
55
|
-
content: {
|
|
56
|
-
'application/json': {
|
|
57
|
-
schema: updateRef
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
responses: {
|
|
62
|
-
...jsonOk(t('globalDoc'), {
|
|
63
|
-
type: 'object',
|
|
64
|
-
properties: {
|
|
65
|
-
message: {
|
|
66
|
-
type: 'string'
|
|
67
|
-
},
|
|
68
|
-
result: docRef
|
|
69
|
-
}
|
|
70
|
-
}),
|
|
71
|
-
...errorResponses(ERRORS.globalUpdate, t)
|
|
72
|
-
},
|
|
73
|
-
security: secUpdate
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
export { buildGlobalPaths };
|