@seshuk/payload-plugin-openapi 0.2.2 → 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 +57 -34
- 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/components.js
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { refTo } from "./names.js";
|
|
2
|
-
const nullableType = (type)=>({
|
|
3
|
-
type: [
|
|
4
|
-
type,
|
|
5
|
-
'null'
|
|
6
|
-
]
|
|
7
|
-
});
|
|
8
|
-
const jsonResponse = (description, schema)=>({
|
|
9
|
-
description,
|
|
10
|
-
content: {
|
|
11
|
-
'application/json': {
|
|
12
|
-
schema
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
const jsonOk = (description, schema)=>({
|
|
17
|
-
200: jsonResponse(description, schema)
|
|
18
|
-
});
|
|
19
|
-
const jsonBody = (schema)=>({
|
|
20
|
-
required: true,
|
|
21
|
-
content: {
|
|
22
|
-
'application/json': {
|
|
23
|
-
schema
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
const messageResponse = (description)=>jsonOk(description, {
|
|
28
|
-
type: 'object',
|
|
29
|
-
properties: {
|
|
30
|
-
message: {
|
|
31
|
-
type: 'string'
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
const ERROR_SCHEMA_NAME = 'ErrorResponse';
|
|
36
|
-
const ERROR_KEYS = {
|
|
37
|
-
400: 'error400',
|
|
38
|
-
401: 'error401',
|
|
39
|
-
403: 'error403',
|
|
40
|
-
404: 'error404',
|
|
41
|
-
500: 'error500'
|
|
42
|
-
};
|
|
43
|
-
const ERRORS = {
|
|
44
|
-
list: [
|
|
45
|
-
'400',
|
|
46
|
-
'403',
|
|
47
|
-
'500'
|
|
48
|
-
],
|
|
49
|
-
read: [
|
|
50
|
-
'403',
|
|
51
|
-
'404',
|
|
52
|
-
'500'
|
|
53
|
-
],
|
|
54
|
-
create: [
|
|
55
|
-
'400',
|
|
56
|
-
'403',
|
|
57
|
-
'500'
|
|
58
|
-
],
|
|
59
|
-
update: [
|
|
60
|
-
'400',
|
|
61
|
-
'403',
|
|
62
|
-
'404',
|
|
63
|
-
'500'
|
|
64
|
-
],
|
|
65
|
-
delete: [
|
|
66
|
-
'403',
|
|
67
|
-
'404',
|
|
68
|
-
'500'
|
|
69
|
-
],
|
|
70
|
-
globalRead: [
|
|
71
|
-
'403',
|
|
72
|
-
'500'
|
|
73
|
-
],
|
|
74
|
-
globalUpdate: [
|
|
75
|
-
'400',
|
|
76
|
-
'403',
|
|
77
|
-
'500'
|
|
78
|
-
],
|
|
79
|
-
login: [
|
|
80
|
-
'400',
|
|
81
|
-
'401',
|
|
82
|
-
'403',
|
|
83
|
-
'500'
|
|
84
|
-
],
|
|
85
|
-
session: [
|
|
86
|
-
'401',
|
|
87
|
-
'500'
|
|
88
|
-
],
|
|
89
|
-
authAction: [
|
|
90
|
-
'400',
|
|
91
|
-
'403',
|
|
92
|
-
'500'
|
|
93
|
-
],
|
|
94
|
-
versionList: [
|
|
95
|
-
'400',
|
|
96
|
-
'403',
|
|
97
|
-
'404',
|
|
98
|
-
'500'
|
|
99
|
-
],
|
|
100
|
-
versionRead: [
|
|
101
|
-
'403',
|
|
102
|
-
'404',
|
|
103
|
-
'500'
|
|
104
|
-
],
|
|
105
|
-
versionRestore: [
|
|
106
|
-
'403',
|
|
107
|
-
'404',
|
|
108
|
-
'500'
|
|
109
|
-
]
|
|
110
|
-
};
|
|
111
|
-
const buildErrorResponseSchema = ()=>({
|
|
112
|
-
type: 'object',
|
|
113
|
-
properties: {
|
|
114
|
-
errors: {
|
|
115
|
-
type: 'array',
|
|
116
|
-
items: {
|
|
117
|
-
type: 'object',
|
|
118
|
-
properties: {
|
|
119
|
-
message: {
|
|
120
|
-
type: 'string'
|
|
121
|
-
},
|
|
122
|
-
name: {
|
|
123
|
-
type: 'string'
|
|
124
|
-
},
|
|
125
|
-
field: {
|
|
126
|
-
type: 'string'
|
|
127
|
-
},
|
|
128
|
-
data: {
|
|
129
|
-
type: 'object',
|
|
130
|
-
additionalProperties: true
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
required: [
|
|
134
|
-
'message'
|
|
135
|
-
]
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
required: [
|
|
140
|
-
'errors'
|
|
141
|
-
]
|
|
142
|
-
});
|
|
143
|
-
const errorRef = {
|
|
144
|
-
$ref: refTo(ERROR_SCHEMA_NAME)
|
|
145
|
-
};
|
|
146
|
-
const errorContent = (description)=>({
|
|
147
|
-
description,
|
|
148
|
-
content: {
|
|
149
|
-
'application/json': {
|
|
150
|
-
schema: errorRef
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
const errorResponses = (codes, t)=>{
|
|
155
|
-
const responses = {};
|
|
156
|
-
for (const code of codes)responses[code] = errorContent(t(ERROR_KEYS[code]));
|
|
157
|
-
return responses;
|
|
158
|
-
};
|
|
159
|
-
const buildListEnvelopeSchema = (base)=>({
|
|
160
|
-
type: 'object',
|
|
161
|
-
properties: {
|
|
162
|
-
docs: {
|
|
163
|
-
type: 'array',
|
|
164
|
-
items: {
|
|
165
|
-
$ref: refTo(base)
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
totalDocs: {
|
|
169
|
-
type: 'integer'
|
|
170
|
-
},
|
|
171
|
-
limit: {
|
|
172
|
-
type: 'integer'
|
|
173
|
-
},
|
|
174
|
-
totalPages: {
|
|
175
|
-
type: 'integer'
|
|
176
|
-
},
|
|
177
|
-
page: {
|
|
178
|
-
type: 'integer'
|
|
179
|
-
},
|
|
180
|
-
pagingCounter: {
|
|
181
|
-
type: 'integer'
|
|
182
|
-
},
|
|
183
|
-
hasPrevPage: {
|
|
184
|
-
type: 'boolean'
|
|
185
|
-
},
|
|
186
|
-
hasNextPage: {
|
|
187
|
-
type: 'boolean'
|
|
188
|
-
},
|
|
189
|
-
prevPage: nullableType('integer'),
|
|
190
|
-
nextPage: nullableType('integer')
|
|
191
|
-
},
|
|
192
|
-
required: [
|
|
193
|
-
'docs',
|
|
194
|
-
'totalDocs',
|
|
195
|
-
'limit',
|
|
196
|
-
'totalPages',
|
|
197
|
-
'page'
|
|
198
|
-
]
|
|
199
|
-
});
|
|
200
|
-
const uploadRequestBody = ({ bodyRef, fileRequired, t })=>{
|
|
201
|
-
const fieldsSchemaName = bodyRef.$ref.split('/').pop() ?? 'the document';
|
|
202
|
-
return {
|
|
203
|
-
required: fileRequired,
|
|
204
|
-
description: t('uploadBody'),
|
|
205
|
-
content: {
|
|
206
|
-
'multipart/form-data': {
|
|
207
|
-
schema: {
|
|
208
|
-
type: 'object',
|
|
209
|
-
properties: {
|
|
210
|
-
file: {
|
|
211
|
-
type: 'string',
|
|
212
|
-
format: 'binary',
|
|
213
|
-
description: t('uploadFile')
|
|
214
|
-
},
|
|
215
|
-
_payload: {
|
|
216
|
-
allOf: [
|
|
217
|
-
bodyRef
|
|
218
|
-
],
|
|
219
|
-
description: t('uploadPayloadField', {
|
|
220
|
-
schema: fieldsSchemaName
|
|
221
|
-
})
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
...fileRequired ? {
|
|
225
|
-
required: [
|
|
226
|
-
'file'
|
|
227
|
-
]
|
|
228
|
-
} : {}
|
|
229
|
-
},
|
|
230
|
-
encoding: {
|
|
231
|
-
file: {
|
|
232
|
-
contentType: 'application/octet-stream'
|
|
233
|
-
},
|
|
234
|
-
_payload: {
|
|
235
|
-
contentType: 'application/json'
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
'application/json': {
|
|
240
|
-
schema: bodyRef
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
};
|
|
245
|
-
const SECURITY_SCHEME_NAME = 'PayloadToken';
|
|
246
|
-
const INTERACTIVE_SCHEME_NAME = 'PayloadLogin';
|
|
247
|
-
const interactiveSecurityScheme = ({ tokenUrl, t })=>({
|
|
248
|
-
type: 'oauth2',
|
|
249
|
-
description: t('securityInteractive'),
|
|
250
|
-
flows: {
|
|
251
|
-
password: {
|
|
252
|
-
tokenUrl,
|
|
253
|
-
scopes: {}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
const securityScheme = ({ cookiePrefix, t })=>({
|
|
258
|
-
type: 'http',
|
|
259
|
-
scheme: 'bearer',
|
|
260
|
-
bearerFormat: 'JWT',
|
|
261
|
-
description: t('securityBearer', {
|
|
262
|
-
cookiePrefix
|
|
263
|
-
})
|
|
264
|
-
});
|
|
265
|
-
export { ERRORS, ERROR_SCHEMA_NAME, INTERACTIVE_SCHEME_NAME, SECURITY_SCHEME_NAME, buildErrorResponseSchema, buildListEnvelopeSchema, errorResponses, interactiveSecurityScheme, jsonBody, jsonOk, jsonResponse, messageResponse, nullableType, securityScheme, uploadRequestBody };
|
package/dist/spec/downconvert.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
const NULL = 'null';
|
|
2
|
-
const UNSUPPORTED_KEYWORDS = [
|
|
3
|
-
'$schema',
|
|
4
|
-
'$id',
|
|
5
|
-
'$comment',
|
|
6
|
-
'unevaluatedProperties',
|
|
7
|
-
'patternProperties',
|
|
8
|
-
'propertyNames'
|
|
9
|
-
];
|
|
10
|
-
const isStringType = (type)=>'string' === type || Array.isArray(type) && type.includes('string');
|
|
11
|
-
const downconvertTo30 = (node)=>{
|
|
12
|
-
if (Array.isArray(node)) return node.map(downconvertTo30);
|
|
13
|
-
if (!node || 'object' != typeof node) return node;
|
|
14
|
-
const out = {};
|
|
15
|
-
for (const [key, value] of Object.entries(node))out[key] = downconvertTo30(value);
|
|
16
|
-
if (isStringType(out.type) && 'application/octet-stream' === out.contentMediaType) {
|
|
17
|
-
if (void 0 === out.format) out.format = 'binary';
|
|
18
|
-
delete out.contentMediaType;
|
|
19
|
-
}
|
|
20
|
-
if (isStringType(out.type) && 'base64' === out.contentEncoding) {
|
|
21
|
-
if (void 0 === out.format) out.format = 'byte';
|
|
22
|
-
delete out.contentEncoding;
|
|
23
|
-
}
|
|
24
|
-
if (Array.isArray(out.type)) {
|
|
25
|
-
const types = out.type;
|
|
26
|
-
const nullable = types.includes(NULL);
|
|
27
|
-
const rest = types.filter((t)=>t !== NULL);
|
|
28
|
-
if (1 === rest.length) {
|
|
29
|
-
out.type = rest[0];
|
|
30
|
-
if (nullable) out.nullable = true;
|
|
31
|
-
} else if (rest.length > 1) {
|
|
32
|
-
delete out.type;
|
|
33
|
-
const union = rest.map((type)=>nullable ? {
|
|
34
|
-
type,
|
|
35
|
-
nullable: true
|
|
36
|
-
} : {
|
|
37
|
-
type
|
|
38
|
-
});
|
|
39
|
-
if (out.anyOf) out.allOf = [
|
|
40
|
-
...out.allOf ?? [],
|
|
41
|
-
{
|
|
42
|
-
anyOf: union
|
|
43
|
-
}
|
|
44
|
-
];
|
|
45
|
-
else out.anyOf = union;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if ('const' in out) {
|
|
49
|
-
out.enum = [
|
|
50
|
-
out.const
|
|
51
|
-
];
|
|
52
|
-
delete out.const;
|
|
53
|
-
}
|
|
54
|
-
if (Array.isArray(out.examples)) {
|
|
55
|
-
const examples = out.examples;
|
|
56
|
-
if (examples.length > 0) out.example = examples[0];
|
|
57
|
-
if (examples.length > 1) out['x-examples'] = examples;
|
|
58
|
-
delete out.examples;
|
|
59
|
-
}
|
|
60
|
-
if (Array.isArray(out.required) && 0 === out.required.length) delete out.required;
|
|
61
|
-
for (const keyword of UNSUPPORTED_KEYWORDS)delete out[keyword];
|
|
62
|
-
return out;
|
|
63
|
-
};
|
|
64
|
-
const toOpenApi31 = (doc)=>({
|
|
65
|
-
...doc,
|
|
66
|
-
openapi: '3.1.2',
|
|
67
|
-
tags: doc.tags?.map(({ kind: _kind, parent: _parent, summary: _summary, ...rest })=>rest)
|
|
68
|
-
});
|
|
69
|
-
const toOpenApi30 = (doc)=>{
|
|
70
|
-
const converted = downconvertTo30(toOpenApi31(doc));
|
|
71
|
-
converted.openapi = '3.0.4';
|
|
72
|
-
return converted;
|
|
73
|
-
};
|
|
74
|
-
export { toOpenApi30, toOpenApi31 };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Block, SanitizedConfig } from 'payload';
|
|
2
|
-
import type { SchemaObject } from '@scalar/openapi-types/3.2';
|
|
3
|
-
import type { BuildContext, Entity } from '../types.js';
|
|
4
|
-
export declare const resolveLocalizedStrings: (value: unknown, ctx: BuildContext) => unknown;
|
|
5
|
-
export interface EntitySchemas {
|
|
6
|
-
read: SchemaObject;
|
|
7
|
-
create: SchemaObject;
|
|
8
|
-
update: SchemaObject;
|
|
9
|
-
}
|
|
10
|
-
export declare const buildEntitySchemas: ({ entity, config, ctx, }: {
|
|
11
|
-
entity: Entity;
|
|
12
|
-
config: SanitizedConfig;
|
|
13
|
-
ctx: BuildContext;
|
|
14
|
-
}) => Promise<EntitySchemas>;
|
|
15
|
-
export declare const buildBlockSchema: (block: Block, config: SanitizedConfig) => SchemaObject;
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { entityToJSONSchema } from "payload";
|
|
2
|
-
import { getTranslation } from "@payloadcms/translations";
|
|
3
|
-
import { deepMerge, isPlainObject } from "../utils.js";
|
|
4
|
-
import { makeT } from "../translations/index.js";
|
|
5
|
-
import { AUTH_FIELDS, flattenFields } from "./fields.js";
|
|
6
|
-
import { refTo, rewriteRefs, schemaName } from "./names.js";
|
|
7
|
-
const READ_HIDDEN_FIELDS = new Set([
|
|
8
|
-
...AUTH_FIELDS,
|
|
9
|
-
'collection'
|
|
10
|
-
]);
|
|
11
|
-
const SERVER_FIELDS = [
|
|
12
|
-
'id',
|
|
13
|
-
'createdAt',
|
|
14
|
-
'updatedAt'
|
|
15
|
-
];
|
|
16
|
-
const stripInterfaceName = (entity)=>{
|
|
17
|
-
const { interfaceName: _omit, ...rest } = entity;
|
|
18
|
-
return rest;
|
|
19
|
-
};
|
|
20
|
-
const toComponentSchema = ({ config, source, idType, write = false })=>{
|
|
21
|
-
const jsonSchema = entityToJSONSchema(config, source, new Map(), idType, void 0, void 0, {
|
|
22
|
-
forceInlineBlocks: write
|
|
23
|
-
});
|
|
24
|
-
const blockSlugs = new Set((config.blocks ?? []).map((b)=>b.slug));
|
|
25
|
-
const schema = rewriteRefs(jsonSchema, blockSlugs);
|
|
26
|
-
delete schema.title;
|
|
27
|
-
return schema;
|
|
28
|
-
};
|
|
29
|
-
const fieldOpenapi = (field)=>{
|
|
30
|
-
const meta = field.custom?.openapi;
|
|
31
|
-
return isPlainObject(meta) ? meta : void 0;
|
|
32
|
-
};
|
|
33
|
-
const isLocaleKeyed = (value, ctx)=>{
|
|
34
|
-
if (!isPlainObject(value)) return false;
|
|
35
|
-
const keys = Object.keys(value);
|
|
36
|
-
return keys.length > 0 && keys.every((k)=>ctx.locales.includes(k)) && Object.values(value).every((v)=>'string' == typeof v);
|
|
37
|
-
};
|
|
38
|
-
const LOCALIZABLE_KEYS = new Set([
|
|
39
|
-
"description",
|
|
40
|
-
'title',
|
|
41
|
-
'summary'
|
|
42
|
-
]);
|
|
43
|
-
const resolveTextValue = (value, ctx)=>{
|
|
44
|
-
if ('function' == typeof value) try {
|
|
45
|
-
const result = value({
|
|
46
|
-
t: ctx.i18n.t,
|
|
47
|
-
i18n: ctx.i18n
|
|
48
|
-
});
|
|
49
|
-
return 'string' == typeof result && result.length > 0 ? result : void 0;
|
|
50
|
-
} catch {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (isLocaleKeyed(value, ctx)) return getTranslation(value, ctx.i18n);
|
|
54
|
-
};
|
|
55
|
-
const resolveLocalizedStrings = (value, ctx)=>{
|
|
56
|
-
if (!isPlainObject(value)) return value;
|
|
57
|
-
const out = {};
|
|
58
|
-
for (const [k, v] of Object.entries(value)){
|
|
59
|
-
if (LOCALIZABLE_KEYS.has(k)) {
|
|
60
|
-
const resolved = resolveTextValue(v, ctx);
|
|
61
|
-
if (void 0 !== resolved) out[k] = resolved;
|
|
62
|
-
else if ('function' != typeof v) out[k] = resolveLocalizedStrings(v, ctx);
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
out[k] = resolveLocalizedStrings(v, ctx);
|
|
66
|
-
}
|
|
67
|
-
return out;
|
|
68
|
-
};
|
|
69
|
-
const applyFieldOverrides = ({ schema, fields, ctx })=>{
|
|
70
|
-
if (!schema.properties) return;
|
|
71
|
-
for (const field of flattenFields(fields)){
|
|
72
|
-
const name = 'name' in field ? field.name : void 0;
|
|
73
|
-
const override = fieldOpenapi(field);
|
|
74
|
-
if (!name || !override) continue;
|
|
75
|
-
const current = schema.properties[name];
|
|
76
|
-
if (isPlainObject(current)) {
|
|
77
|
-
const resolved = resolveLocalizedStrings(override, ctx);
|
|
78
|
-
schema.properties[name] = deepMerge(current, resolved);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
const isRef = (value)=>isPlainObject(value) && 'string' == typeof value.$ref;
|
|
83
|
-
const isBlockBranch = (branch)=>{
|
|
84
|
-
if (isRef(branch)) return branch.$ref.startsWith('#/components/schemas/Block');
|
|
85
|
-
return isPlainObject(branch) && isPlainObject(branch.properties) && 'blockType' in branch.properties;
|
|
86
|
-
};
|
|
87
|
-
const addBlockDiscriminators = (node)=>{
|
|
88
|
-
if (Array.isArray(node)) {
|
|
89
|
-
for (const item of node)addBlockDiscriminators(item);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (!isPlainObject(node)) return;
|
|
93
|
-
const oneOf = node.oneOf;
|
|
94
|
-
if (Array.isArray(oneOf) && oneOf.length > 0 && oneOf.every(isBlockBranch)) node.discriminator = {
|
|
95
|
-
propertyName: 'blockType'
|
|
96
|
-
};
|
|
97
|
-
for (const value of Object.values(node))addBlockDiscriminators(value);
|
|
98
|
-
};
|
|
99
|
-
const markLocalizedFields = ({ schema, fields, ctx })=>{
|
|
100
|
-
if (!schema.properties || 0 === ctx.locales.length) return;
|
|
101
|
-
for (const field of flattenFields(fields)){
|
|
102
|
-
if (!('localized' in field) || !field.localized) continue;
|
|
103
|
-
const name = 'name' in field ? field.name : void 0;
|
|
104
|
-
if (!name || !(name in schema.properties)) continue;
|
|
105
|
-
const single = schema.properties[name];
|
|
106
|
-
schema.properties[name] = {
|
|
107
|
-
oneOf: [
|
|
108
|
-
single,
|
|
109
|
-
{
|
|
110
|
-
type: 'object',
|
|
111
|
-
description: makeT(ctx.i18n)('schemaPerLocale'),
|
|
112
|
-
properties: Object.fromEntries(ctx.locales.map((l)=>[
|
|
113
|
-
l,
|
|
114
|
-
single
|
|
115
|
-
]))
|
|
116
|
-
}
|
|
117
|
-
]
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
const removeProps = (schema, names)=>{
|
|
122
|
-
if (!schema.properties) return;
|
|
123
|
-
for (const name of names)delete schema.properties[name];
|
|
124
|
-
if (Array.isArray(schema.required)) {
|
|
125
|
-
const drop = new Set(names);
|
|
126
|
-
schema.required = schema.required.filter((r)=>!drop.has(r));
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
const toIdType = (type)=>Array.isArray(type) ? type.map(toIdType) : 'number' === type ? 'integer' : type;
|
|
130
|
-
const writeRelationshipsAsIds = (node, refs)=>{
|
|
131
|
-
if (Array.isArray(node)) {
|
|
132
|
-
for (const item of node)writeRelationshipsAsIds(item, refs);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
if (!isPlainObject(node)) return;
|
|
136
|
-
const oneOf = node.oneOf;
|
|
137
|
-
if (Array.isArray(oneOf) && 2 === oneOf.length && isRef(oneOf[1]) && refs.has(oneOf[1].$ref)) {
|
|
138
|
-
delete node.oneOf;
|
|
139
|
-
node.type = toIdType(oneOf[0].type);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
for (const value of Object.values(node))writeRelationshipsAsIds(value, refs);
|
|
143
|
-
};
|
|
144
|
-
const buildBaseSchema = ({ entity, config, ctx, write = false })=>{
|
|
145
|
-
const idType = ctx.defaultIDType;
|
|
146
|
-
const schema = toComponentSchema({
|
|
147
|
-
config,
|
|
148
|
-
source: stripInterfaceName(entity),
|
|
149
|
-
idType,
|
|
150
|
-
write
|
|
151
|
-
});
|
|
152
|
-
if (write) {
|
|
153
|
-
const refs = new Set((config.collections ?? []).map((c)=>refTo(schemaName(c.slug))));
|
|
154
|
-
writeRelationshipsAsIds(schema, refs);
|
|
155
|
-
}
|
|
156
|
-
const isAuth = 'auth' in entity && Boolean(entity.auth);
|
|
157
|
-
if (isAuth) removeProps(schema, READ_HIDDEN_FIELDS);
|
|
158
|
-
applyFieldOverrides({
|
|
159
|
-
schema,
|
|
160
|
-
fields: entity.fields,
|
|
161
|
-
ctx
|
|
162
|
-
});
|
|
163
|
-
addBlockDiscriminators(schema);
|
|
164
|
-
return schema;
|
|
165
|
-
};
|
|
166
|
-
const cloneSchema = (schema)=>({
|
|
167
|
-
...schema,
|
|
168
|
-
properties: {
|
|
169
|
-
...schema.properties
|
|
170
|
-
},
|
|
171
|
-
required: Array.isArray(schema.required) ? [
|
|
172
|
-
...schema.required
|
|
173
|
-
] : schema.required
|
|
174
|
-
});
|
|
175
|
-
const buildEntitySchemas = async ({ entity, config, ctx })=>{
|
|
176
|
-
const read = buildBaseSchema({
|
|
177
|
-
entity,
|
|
178
|
-
config,
|
|
179
|
-
ctx
|
|
180
|
-
});
|
|
181
|
-
const write = buildBaseSchema({
|
|
182
|
-
entity,
|
|
183
|
-
config,
|
|
184
|
-
ctx,
|
|
185
|
-
write: true
|
|
186
|
-
});
|
|
187
|
-
const isAuth = 'auth' in entity && Boolean(entity.auth);
|
|
188
|
-
const create = cloneSchema(write);
|
|
189
|
-
if (Array.isArray(create.required)) {
|
|
190
|
-
const optional = new Set(SERVER_FIELDS);
|
|
191
|
-
create.required = create.required.filter((r)=>!optional.has(r));
|
|
192
|
-
}
|
|
193
|
-
if (isAuth && create.properties) {
|
|
194
|
-
create.properties.password = {
|
|
195
|
-
type: 'string'
|
|
196
|
-
};
|
|
197
|
-
create.required = [
|
|
198
|
-
...new Set([
|
|
199
|
-
...create.required ?? [],
|
|
200
|
-
'password'
|
|
201
|
-
])
|
|
202
|
-
];
|
|
203
|
-
}
|
|
204
|
-
const update = cloneSchema(write);
|
|
205
|
-
delete update.required;
|
|
206
|
-
if (update.properties) delete update.properties.id;
|
|
207
|
-
if (isAuth && update.properties) update.properties.password = {
|
|
208
|
-
type: 'string'
|
|
209
|
-
};
|
|
210
|
-
markLocalizedFields({
|
|
211
|
-
schema: read,
|
|
212
|
-
fields: entity.fields,
|
|
213
|
-
ctx
|
|
214
|
-
});
|
|
215
|
-
return {
|
|
216
|
-
read,
|
|
217
|
-
create,
|
|
218
|
-
update
|
|
219
|
-
};
|
|
220
|
-
};
|
|
221
|
-
const buildBlockSchema = (block, config)=>{
|
|
222
|
-
const schema = toComponentSchema({
|
|
223
|
-
config,
|
|
224
|
-
source: stripInterfaceName(block),
|
|
225
|
-
idType: 'text'
|
|
226
|
-
});
|
|
227
|
-
const blockType = {
|
|
228
|
-
type: 'string',
|
|
229
|
-
enum: [
|
|
230
|
-
block.slug
|
|
231
|
-
]
|
|
232
|
-
};
|
|
233
|
-
const properties = {
|
|
234
|
-
...schema.properties,
|
|
235
|
-
blockType
|
|
236
|
-
};
|
|
237
|
-
const required = [
|
|
238
|
-
...new Set([
|
|
239
|
-
'blockType',
|
|
240
|
-
...schema.required ?? []
|
|
241
|
-
])
|
|
242
|
-
];
|
|
243
|
-
return {
|
|
244
|
-
...schema,
|
|
245
|
-
type: 'object',
|
|
246
|
-
properties,
|
|
247
|
-
required
|
|
248
|
-
};
|
|
249
|
-
};
|
|
250
|
-
export { buildBlockSchema, buildEntitySchemas, resolveLocalizedStrings };
|
package/dist/spec/fields.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const isHiddenField = (field)=>'hidden' in field && true === field.hidden;
|
|
2
|
-
const AUTH_FIELDS = new Set([
|
|
3
|
-
'salt',
|
|
4
|
-
'hash',
|
|
5
|
-
'password',
|
|
6
|
-
'resetPasswordToken',
|
|
7
|
-
'resetPasswordExpiration',
|
|
8
|
-
'loginAttempts',
|
|
9
|
-
'lockUntil',
|
|
10
|
-
'sessions'
|
|
11
|
-
]);
|
|
12
|
-
const hasName = (field)=>'name' in field && 'string' == typeof field.name;
|
|
13
|
-
const flattenFields = (fields)=>{
|
|
14
|
-
const out = [];
|
|
15
|
-
for (const field of fields)if ('ui' !== field.type) {
|
|
16
|
-
if ('row' === field.type || 'collapsible' === field.type) {
|
|
17
|
-
out.push(...flattenFields(field.fields));
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
if ('tabs' === field.type) {
|
|
21
|
-
for (const tab of field.tabs){
|
|
22
|
-
const tabName = hasName(tab) ? tab.name : void 0;
|
|
23
|
-
if (tabName) out.push({
|
|
24
|
-
type: 'group',
|
|
25
|
-
name: tabName,
|
|
26
|
-
fields: tab.fields
|
|
27
|
-
});
|
|
28
|
-
else out.push(...flattenFields(tab.fields));
|
|
29
|
-
}
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if ('group' === field.type && !hasName(field)) {
|
|
33
|
-
out.push(...flattenFields(field.fields));
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
out.push(field);
|
|
37
|
-
}
|
|
38
|
-
return out;
|
|
39
|
-
};
|
|
40
|
-
const exposableFields = (fields)=>flattenFields(fields).filter((field)=>{
|
|
41
|
-
const name = 'name' in field ? field.name : void 0;
|
|
42
|
-
return Boolean(name) && !isHiddenField(field) && !AUTH_FIELDS.has(name);
|
|
43
|
-
});
|
|
44
|
-
export { AUTH_FIELDS, exposableFields, flattenFields, isHiddenField };
|
package/dist/spec/filters.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload';
|
|
2
|
-
import type { PathsObject } from '@scalar/openapi-types/3.2';
|
|
3
|
-
import type { EntityKind, ResolvedFilters } from '../types.js';
|
|
4
|
-
export declare const shouldIncludeCollection: (collection: SanitizedCollectionConfig, filters: ResolvedFilters) => boolean;
|
|
5
|
-
export declare const shouldIncludeGlobal: (global: SanitizedGlobalConfig, filters: ResolvedFilters) => boolean;
|
|
6
|
-
export declare const filterOperations: ({ paths, slug, kind, filters, }: {
|
|
7
|
-
paths: PathsObject;
|
|
8
|
-
slug: string;
|
|
9
|
-
kind: EntityKind;
|
|
10
|
-
filters: ResolvedFilters;
|
|
11
|
-
}) => PathsObject;
|