@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
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { SECURITY_SCHEME_NAME, errorResponses, jsonBody, jsonResponse } from "../components.js";
|
|
2
|
+
import { makeT } from "../../../shared/translations/index.js";
|
|
3
|
+
const buildSystemPaths = ({ ctx, access, uploadSlugs }) => {
|
|
4
|
+
const t = makeT(ctx.i18n);
|
|
5
|
+
const paths = {};
|
|
6
|
+
if (access) paths[`${ctx.apiRoute}/access`] = { get: {
|
|
7
|
+
tags: ["Access"],
|
|
8
|
+
operationId: "access",
|
|
9
|
+
responses: {
|
|
10
|
+
"200": jsonResponse(t("authAccess"), {
|
|
11
|
+
type: "object",
|
|
12
|
+
additionalProperties: true
|
|
13
|
+
}),
|
|
14
|
+
...errorResponses(["500"], t)
|
|
15
|
+
}
|
|
16
|
+
} };
|
|
17
|
+
if (uploadSlugs.length > 0) {
|
|
18
|
+
const staged = {
|
|
19
|
+
"204": { description: t("uploadStageResult") },
|
|
20
|
+
...errorResponses(["400", "500"], t)
|
|
21
|
+
};
|
|
22
|
+
paths[`${ctx.apiRoute}/upload-instructions`] = { post: {
|
|
23
|
+
tags: ["Uploads"],
|
|
24
|
+
operationId: "getUploadInstructions",
|
|
25
|
+
summary: t("uploadInstructionsSummary"),
|
|
26
|
+
requestBody: jsonBody({
|
|
27
|
+
type: "object",
|
|
28
|
+
additionalProperties: false,
|
|
29
|
+
properties: {
|
|
30
|
+
collectionSlug: {
|
|
31
|
+
type: "string",
|
|
32
|
+
enum: uploadSlugs
|
|
33
|
+
},
|
|
34
|
+
docPrefix: { type: "string" },
|
|
35
|
+
filename: { type: "string" },
|
|
36
|
+
filesize: {
|
|
37
|
+
type: "integer",
|
|
38
|
+
minimum: 0
|
|
39
|
+
},
|
|
40
|
+
mimeType: { type: "string" }
|
|
41
|
+
},
|
|
42
|
+
required: [
|
|
43
|
+
"collectionSlug",
|
|
44
|
+
"filename",
|
|
45
|
+
"filesize",
|
|
46
|
+
"mimeType"
|
|
47
|
+
]
|
|
48
|
+
}),
|
|
49
|
+
responses: {
|
|
50
|
+
"200": jsonResponse(t("uploadInstructionsResult"), {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
type: {
|
|
54
|
+
type: "string",
|
|
55
|
+
enum: ["http", "dispatch"]
|
|
56
|
+
},
|
|
57
|
+
file: {
|
|
58
|
+
type: "object",
|
|
59
|
+
properties: {
|
|
60
|
+
filename: { type: "string" },
|
|
61
|
+
mimeType: { type: "string" },
|
|
62
|
+
size: { type: "integer" },
|
|
63
|
+
uploadReference: {
|
|
64
|
+
type: "object",
|
|
65
|
+
additionalProperties: true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
required: [
|
|
69
|
+
"filename",
|
|
70
|
+
"mimeType",
|
|
71
|
+
"size",
|
|
72
|
+
"uploadReference"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
request: {
|
|
76
|
+
type: "object",
|
|
77
|
+
properties: {
|
|
78
|
+
method: {
|
|
79
|
+
type: "string",
|
|
80
|
+
enum: ["POST", "PUT"]
|
|
81
|
+
},
|
|
82
|
+
url: { type: "string" },
|
|
83
|
+
headers: {
|
|
84
|
+
type: "object",
|
|
85
|
+
additionalProperties: { type: "string" }
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
required: ["method", "url"]
|
|
89
|
+
},
|
|
90
|
+
name: { type: "string" },
|
|
91
|
+
data: {}
|
|
92
|
+
},
|
|
93
|
+
required: ["type", "file"]
|
|
94
|
+
}),
|
|
95
|
+
...errorResponses([
|
|
96
|
+
"400",
|
|
97
|
+
"403",
|
|
98
|
+
"500"
|
|
99
|
+
], t)
|
|
100
|
+
},
|
|
101
|
+
security: [{ [SECURITY_SCHEME_NAME]: [] }]
|
|
102
|
+
} };
|
|
103
|
+
paths[`${ctx.apiRoute}/upload-instructions/{uploadId}`] = {
|
|
104
|
+
parameters: [{
|
|
105
|
+
name: "uploadId",
|
|
106
|
+
in: "path",
|
|
107
|
+
required: true,
|
|
108
|
+
schema: { type: "string" }
|
|
109
|
+
}],
|
|
110
|
+
put: {
|
|
111
|
+
tags: ["Uploads"],
|
|
112
|
+
operationId: "uploadStagedFile",
|
|
113
|
+
summary: t("uploadStagePutSummary"),
|
|
114
|
+
requestBody: {
|
|
115
|
+
required: true,
|
|
116
|
+
content: { "*/*": { schema: {
|
|
117
|
+
type: "string",
|
|
118
|
+
format: "binary"
|
|
119
|
+
} } }
|
|
120
|
+
},
|
|
121
|
+
responses: staged,
|
|
122
|
+
security: [{ [SECURITY_SCHEME_NAME]: [] }]
|
|
123
|
+
},
|
|
124
|
+
delete: {
|
|
125
|
+
tags: ["Uploads"],
|
|
126
|
+
operationId: "deleteStagedFile",
|
|
127
|
+
summary: t("uploadStageDeleteSummary"),
|
|
128
|
+
responses: staged,
|
|
129
|
+
security: [{ [SECURITY_SCHEME_NAME]: [] }]
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return paths;
|
|
134
|
+
};
|
|
135
|
+
export { buildSystemPaths };
|
|
136
|
+
|
|
137
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.js","names":[],"sources":["../../../../src/server/spec/paths/system.ts"],"sourcesContent":["import type { PathsObject, ResponsesObject } from '@scalar/openapi-types/3.2'\n\nimport { SECURITY_SCHEME_NAME, errorResponses, jsonBody, jsonResponse } from '@/server/spec/components.js'\nimport { makeT } from '@/shared/translations/index.js'\nimport type { BuildContext } from '@/shared/types/index.js'\n\nexport const buildSystemPaths = ({\n ctx,\n access,\n uploadSlugs,\n}: {\n ctx: BuildContext\n access: boolean\n uploadSlugs: string[]\n}): PathsObject => {\n const t = makeT(ctx.i18n)\n const paths: PathsObject = {}\n\n if (access) {\n paths[`${ctx.apiRoute}/access`] = {\n get: {\n tags: ['Access'],\n operationId: 'access',\n responses: {\n '200': jsonResponse(t('authAccess'), { type: 'object', additionalProperties: true }),\n ...errorResponses(['500'], t),\n },\n },\n }\n }\n\n if (uploadSlugs.length > 0) {\n const staged: ResponsesObject = {\n '204': { description: t('uploadStageResult') },\n ...errorResponses(['400', '500'], t),\n }\n\n paths[`${ctx.apiRoute}/upload-instructions`] = {\n post: {\n tags: ['Uploads'],\n operationId: 'getUploadInstructions',\n summary: t('uploadInstructionsSummary'),\n requestBody: jsonBody({\n type: 'object',\n additionalProperties: false,\n properties: {\n collectionSlug: { type: 'string', enum: uploadSlugs },\n docPrefix: { type: 'string' },\n filename: { type: 'string' },\n filesize: { type: 'integer', minimum: 0 },\n mimeType: { type: 'string' },\n },\n required: ['collectionSlug', 'filename', 'filesize', 'mimeType'],\n }),\n responses: {\n '200': jsonResponse(t('uploadInstructionsResult'), {\n type: 'object',\n properties: {\n type: { type: 'string', enum: ['http', 'dispatch'] },\n file: {\n type: 'object',\n properties: {\n filename: { type: 'string' },\n mimeType: { type: 'string' },\n size: { type: 'integer' },\n uploadReference: { type: 'object', additionalProperties: true },\n },\n required: ['filename', 'mimeType', 'size', 'uploadReference'],\n },\n request: {\n type: 'object',\n properties: {\n method: { type: 'string', enum: ['POST', 'PUT'] },\n url: { type: 'string' },\n headers: { type: 'object', additionalProperties: { type: 'string' } },\n },\n required: ['method', 'url'],\n },\n name: { type: 'string' },\n data: {},\n },\n required: ['type', 'file'],\n }),\n ...errorResponses(['400', '403', '500'], t),\n },\n security: [{ [SECURITY_SCHEME_NAME]: [] }],\n },\n }\n paths[`${ctx.apiRoute}/upload-instructions/{uploadId}`] = {\n parameters: [{ name: 'uploadId', in: 'path', required: true, schema: { type: 'string' } }],\n put: {\n tags: ['Uploads'],\n operationId: 'uploadStagedFile',\n summary: t('uploadStagePutSummary'),\n requestBody: {\n required: true,\n content: { '*/*': { schema: { type: 'string', format: 'binary' } } },\n },\n responses: staged,\n security: [{ [SECURITY_SCHEME_NAME]: [] }],\n },\n delete: {\n tags: ['Uploads'],\n operationId: 'deleteStagedFile',\n summary: t('uploadStageDeleteSummary'),\n responses: staged,\n security: [{ [SECURITY_SCHEME_NAME]: [] }],\n },\n }\n }\n\n return paths\n}\n"],"mappings":";;AAMA,MAAa,oBAAoB,EAC/B,KACA,QACA,kBAKiB;CACjB,MAAM,IAAI,MAAM,IAAI,IAAI;CACxB,MAAM,QAAqB,CAAC;CAE5B,IAAI,QACF,MAAM,GAAG,IAAI,SAAS,YAAY,EAChC,KAAK;EACH,MAAM,CAAC,QAAQ;EACf,aAAa;EACb,WAAW;GACT,OAAO,aAAa,EAAE,YAAY,GAAG;IAAE,MAAM;IAAU,sBAAsB;GAAK,CAAC;GACnF,GAAG,eAAe,CAAC,KAAK,GAAG,CAAC;EAC9B;CACF,EACF;CAGF,IAAI,YAAY,SAAS,GAAG;EAC1B,MAAM,SAA0B;GAC9B,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE;GAC7C,GAAG,eAAe,CAAC,OAAO,KAAK,GAAG,CAAC;EACrC;EAEA,MAAM,GAAG,IAAI,SAAS,yBAAyB,EAC7C,MAAM;GACJ,MAAM,CAAC,SAAS;GAChB,aAAa;GACb,SAAS,EAAE,2BAA2B;GACtC,aAAa,SAAS;IACpB,MAAM;IACN,sBAAsB;IACtB,YAAY;KACV,gBAAgB;MAAE,MAAM;MAAU,MAAM;KAAY;KACpD,WAAW,EAAE,MAAM,SAAS;KAC5B,UAAU,EAAE,MAAM,SAAS;KAC3B,UAAU;MAAE,MAAM;MAAW,SAAS;KAAE;KACxC,UAAU,EAAE,MAAM,SAAS;IAC7B;IACA,UAAU;KAAC;KAAkB;KAAY;KAAY;IAAU;GACjE,CAAC;GACD,WAAW;IACT,OAAO,aAAa,EAAE,0BAA0B,GAAG;KACjD,MAAM;KACN,YAAY;MACV,MAAM;OAAE,MAAM;OAAU,MAAM,CAAC,QAAQ,UAAU;MAAE;MACnD,MAAM;OACJ,MAAM;OACN,YAAY;QACV,UAAU,EAA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IDType } from "../../../shared/types/index.js";
|
|
2
|
+
import { EntitySecurity } from "../security.js";
|
|
3
|
+
import { PathsObject, SchemaObject } from "@scalar/openapi-types/3.2";
|
|
4
|
+
export interface VersionSchemas {
|
|
5
|
+
version: SchemaObject;
|
|
6
|
+
versionList: SchemaObject;
|
|
7
|
+
}
|
|
8
|
+
export declare const versionComponentSchemas: ({ docBase, base, idType }: {
|
|
9
|
+
docBase: string;
|
|
10
|
+
base: string;
|
|
11
|
+
idType: IDType;
|
|
12
|
+
}) => VersionSchemas;
|
|
13
|
+
export declare const buildVersionPaths: ({ entity, pathBase, ctx, schemaBase, nestedTags, security, global }: {
|
|
14
|
+
entity: Entity;
|
|
15
|
+
pathBase: string;
|
|
16
|
+
ctx: BuildContext;
|
|
17
|
+
schemaBase?: string;
|
|
18
|
+
nestedTags: boolean;
|
|
19
|
+
security?: EntitySecurity;
|
|
20
|
+
global?: boolean;
|
|
21
|
+
}) => PathsObject;
|
|
22
|
+
//# sourceMappingURL=versions.d.ts.map
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { refTo, schemaName } from "../names.js";
|
|
2
|
+
import { ERRORS, errorResponses, jsonResponse, nullableType } from "../components.js";
|
|
3
|
+
import { versionsTagName } from "../tags.js";
|
|
4
|
+
import { makeT } from "../../../shared/translations/index.js";
|
|
5
|
+
import { buildParamSchemas, commonReadParams } from "../params.js";
|
|
6
|
+
const buildVersionSchema = (base, idType) => {
|
|
7
|
+
const id = { type: idType === "number" ? "integer" : "string" };
|
|
8
|
+
return {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
id,
|
|
12
|
+
parent: id,
|
|
13
|
+
version: { $ref: refTo(base) },
|
|
14
|
+
createdAt: {
|
|
15
|
+
type: "string",
|
|
16
|
+
format: "date-time"
|
|
17
|
+
},
|
|
18
|
+
updatedAt: {
|
|
19
|
+
type: "string",
|
|
20
|
+
format: "date-time"
|
|
21
|
+
},
|
|
22
|
+
latest: { type: "boolean" },
|
|
23
|
+
autosave: { type: "boolean" },
|
|
24
|
+
snapshot: { type: "boolean" },
|
|
25
|
+
publishedLocale: { type: "string" }
|
|
26
|
+
},
|
|
27
|
+
required: [
|
|
28
|
+
"id",
|
|
29
|
+
"parent",
|
|
30
|
+
"version",
|
|
31
|
+
"createdAt",
|
|
32
|
+
"updatedAt"
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const buildVersionListSchema = (base) => ({
|
|
37
|
+
type: "object",
|
|
38
|
+
properties: {
|
|
39
|
+
docs: {
|
|
40
|
+
type: "array",
|
|
41
|
+
items: { $ref: refTo(`${base}Version`) }
|
|
42
|
+
},
|
|
43
|
+
totalDocs: { type: "integer" },
|
|
44
|
+
limit: { type: "integer" },
|
|
45
|
+
totalPages: { type: "integer" },
|
|
46
|
+
page: { type: "integer" },
|
|
47
|
+
pagingCounter: { type: "integer" },
|
|
48
|
+
hasPrevPage: { type: "boolean" },
|
|
49
|
+
hasNextPage: { type: "boolean" },
|
|
50
|
+
prevPage: nullableType("integer"),
|
|
51
|
+
nextPage: nullableType("integer")
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const versionComponentSchemas = ({ docBase, base, idType }) => ({
|
|
55
|
+
version: buildVersionSchema(docBase, idType),
|
|
56
|
+
versionList: buildVersionListSchema(base)
|
|
57
|
+
});
|
|
58
|
+
const versionRef = (base) => ({ $ref: refTo(`${base}Version`) });
|
|
59
|
+
const versionListRef = (base) => ({ $ref: refTo(`${base}VersionList`) });
|
|
60
|
+
const listVersionParams = ({ base, ctx, refs }) => {
|
|
61
|
+
const t = makeT(ctx.i18n);
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
name: "page",
|
|
65
|
+
in: "query",
|
|
66
|
+
schema: { type: "integer" }
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "limit",
|
|
70
|
+
in: "query",
|
|
71
|
+
schema: { type: "integer" }
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "pagination",
|
|
75
|
+
in: "query",
|
|
76
|
+
schema: { type: "boolean" }
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "sort",
|
|
80
|
+
in: "query",
|
|
81
|
+
description: t("paramSortShort"),
|
|
82
|
+
schema: { type: "string" }
|
|
83
|
+
},
|
|
84
|
+
...commonReadParams({
|
|
85
|
+
base,
|
|
86
|
+
ctx,
|
|
87
|
+
refs
|
|
88
|
+
}),
|
|
89
|
+
{
|
|
90
|
+
name: "where",
|
|
91
|
+
in: "query",
|
|
92
|
+
description: t("versionWhere"),
|
|
93
|
+
content: { "application/json": { schema: {
|
|
94
|
+
type: "object",
|
|
95
|
+
additionalProperties: true
|
|
96
|
+
} } }
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
|
+
};
|
|
100
|
+
const buildVersionPaths = ({ entity, pathBase, ctx, schemaBase, nestedTags, security = {}, global = false }) => {
|
|
101
|
+
if (!entity.versions) return {};
|
|
102
|
+
const t = makeT(ctx.i18n);
|
|
103
|
+
const name = schemaBase ?? schemaName(entity.slug);
|
|
104
|
+
const versionsTag = [nestedTags ? versionsTagName(name) : name];
|
|
105
|
+
const paramSchemas = buildParamSchemas({
|
|
106
|
+
fields: entity.fields,
|
|
107
|
+
ctx
|
|
108
|
+
});
|
|
109
|
+
const refs = {
|
|
110
|
+
select: true,
|
|
111
|
+
populate: Boolean(paramSchemas.populate),
|
|
112
|
+
joins: Boolean(paramSchemas.joins)
|
|
113
|
+
};
|
|
114
|
+
const idParam = {
|
|
115
|
+
name: "id",
|
|
116
|
+
in: "path",
|
|
117
|
+
required: true,
|
|
118
|
+
schema: { type: ctx.defaultIDType === "number" ? "integer" : "string" }
|
|
119
|
+
};
|
|
120
|
+
const message = { type: "string" };
|
|
121
|
+
const restoreResponse = global ? {
|
|
122
|
+
type: "object",
|
|
123
|
+
properties: {
|
|
124
|
+
message,
|
|
125
|
+
doc: { $ref: refTo(name) }
|
|
126
|
+
}
|
|
127
|
+
} : { allOf: [{ $ref: refTo(name) }, {
|
|
128
|
+
type: "object",
|
|
129
|
+
properties: { message }
|
|
130
|
+
}] };
|
|
131
|
+
return {
|
|
132
|
+
[`${pathBase}/versions`]: { get: {
|
|
133
|
+
tags: versionsTag,
|
|
134
|
+
operationId: `find${name}Versions`,
|
|
135
|
+
parameters: listVersionParams({
|
|
136
|
+
base: name,
|
|
137
|
+
ctx,
|
|
138
|
+
refs
|
|
139
|
+
}),
|
|
140
|
+
responses: {
|
|
141
|
+
"200": jsonResponse(t("versionList"), versionListRef(name)),
|
|
142
|
+
...errorResponses(ERRORS.versionList, t)
|
|
143
|
+
},
|
|
144
|
+
security: security.readVersions
|
|
145
|
+
} },
|
|
146
|
+
[`${pathBase}/versions/{id}`]: {
|
|
147
|
+
parameters: [idParam],
|
|
148
|
+
get: {
|
|
149
|
+
tags: versionsTag,
|
|
150
|
+
operationId: `find${name}VersionById`,
|
|
151
|
+
parameters: commonReadParams({
|
|
152
|
+
base: name,
|
|
153
|
+
ctx,
|
|
154
|
+
refs
|
|
155
|
+
}),
|
|
156
|
+
responses: {
|
|
157
|
+
"200": jsonResponse(t("versionSingle"), versionRef(name)),
|
|
158
|
+
...errorResponses(ERRORS.versionRead, t)
|
|
159
|
+
},
|
|
160
|
+
security: security.readVersions
|
|
161
|
+
},
|
|
162
|
+
post: {
|
|
163
|
+
tags: versionsTag,
|
|
164
|
+
operationId: `restore${name}Version`,
|
|
165
|
+
parameters: [{
|
|
166
|
+
name: "depth",
|
|
167
|
+
in: "query",
|
|
168
|
+
schema: { type: "integer" }
|
|
169
|
+
}, {
|
|
170
|
+
name: "draft",
|
|
171
|
+
in: "query",
|
|
172
|
+
schema: { type: "boolean" }
|
|
173
|
+
}],
|
|
174
|
+
responses: {
|
|
175
|
+
"200": jsonResponse(t("versionRestored"), restoreResponse),
|
|
176
|
+
...errorResponses(ERRORS.versionRestore, t)
|
|
177
|
+
},
|
|
178
|
+
security: security.update
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
export { buildVersionPaths, versionComponentSchemas };
|
|
184
|
+
|
|
185
|
+
//# sourceMappingURL=versions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.js","names":[],"sources":["../../../../src/server/spec/paths/versions.ts"],"sourcesContent":["import type { ParameterObject, PathsObject, ReferenceObject, SchemaObject } from '@scalar/openapi-types/3.2'\n\nimport { ERRORS, errorResponses, jsonResponse, nullableType } from '@/server/spec/components.js'\nimport { refTo, schemaName } from '@/server/spec/names.js'\nimport { buildParamSchemas, commonReadParams, type ReadParamRefs } from '@/server/spec/params.js'\nimport type { EntitySecurity } from '@/server/spec/security.js'\nimport { versionsTagName } from '@/server/spec/tags.js'\nimport { makeT } from '@/shared/translations/index.js'\nimport type { BuildContext, Entity, IDType } from '@/shared/types/index.js'\n\nconst buildVersionSchema = (base: string, idType: IDType): SchemaObject => {\n const id: SchemaObject = { type: idType === 'number' ? 'integer' : 'string' }\n return {\n type: 'object',\n properties: {\n id,\n parent: id,\n version: { $ref: refTo(base) },\n createdAt: { type: 'string', format: 'date-time' },\n updatedAt: { type: 'string', format: 'date-time' },\n latest: { type: 'boolean' },\n autosave: { type: 'boolean' },\n snapshot: { type: 'boolean' },\n publishedLocale: { type: 'string' },\n },\n required: ['id', 'parent', 'version', 'createdAt', 'updatedAt'],\n }\n}\n\nconst buildVersionListSchema = (base: string): SchemaObject => ({\n type: 'object',\n properties: {\n docs: { type: 'array', items: { $ref: refTo(`${base}Version`) } },\n totalDocs: { type: 'integer' },\n limit: { type: 'integer' },\n totalPages: { type: 'integer' },\n page: { type: 'integer' },\n pagingCounter: { type: 'integer' },\n hasPrevPage: { type: 'boolean' },\n hasNextPage: { type: 'boolean' },\n prevPage: nullableType('integer'),\n nextPage: nullableType('integer'),\n },\n})\n\nexport interface VersionSchemas {\n version: SchemaObject\n versionList: SchemaObject\n}\n\nexport const versionComponentSchemas = ({\n docBase,\n base,\n idType,\n}: {\n docBase: string\n base: string\n idType: IDType\n}): VersionSchemas => ({\n version: buildVersionSchema(docBase, idType),\n versionList: buildVersionListSchema(base),\n})\n\nconst versionRef = (base: string): ReferenceObject => ({\n $ref: refTo(`${base}Version`),\n})\nconst versionListRef = (base: string): ReferenceObject => ({\n $ref: refTo(`${base}VersionList`),\n})\n\nconst listVersionParams = ({\n base,\n ctx,\n refs,\n}: {\n base: string\n ctx: BuildContext\n refs: ReadParamRefs\n}): ParameterObject[] => {\n const t = makeT(ctx.i18n)\n return [\n { name: 'page', in: 'query', schema: { type: 'integer' } },\n { name: 'limit', in: 'query', schema: { type: 'integer' } },\n { name: 'pagination', in: 'query', schema: { type: 'boolean' } },\n {\n name: 'sort',\n in: 'query',\n description: t('paramSortShort'),\n schema: { type: 'string' },\n },\n ...commonReadParams({ base, ctx, refs }),\n {\n name: 'where',\n in: 'query',\n description: t('versionWhere'),\n content: {\n 'application/json': { schema: { type: 'object', additionalProperties: true } },\n },\n },\n ]\n}\n\nexport const buildVersionPaths = ({\n entity,\n pathBase,\n ctx,\n schemaBase,\n nestedTags,\n security = {},\n global = false,\n}: {\n entity: Entity\n pathBase: string\n ctx: BuildContext\n schemaBase?: string\n nestedTags: boolean\n security?: EntitySecurity\n global?: boolean\n}): PathsObject => {\n if (!entity.versions) return {}\n\n const t = makeT(ctx.i18n)\n const name = schemaBase ?? schemaName(entity.slug)\n const versionsTag = [nestedTags ? versionsTagName(name) : name]\n const paramSchemas = buildParamSchemas({ fields: entity.fields, ctx })\n const refs: ReadParamRefs = {\n select: true,\n populate: Boolean(paramSchemas.populate),\n joins: Boolean(paramSchemas.joins),\n }\n const idParam: ParameterObject = {\n name: 'id',\n in: 'path',\n required: true,\n schema: { type: ctx.defaultIDType === 'number' ? 'integer' : 'string' },\n }\n\n const message: SchemaObject = { type: 'string' }\n const restoreResponse: SchemaObject = global\n ? { type: 'object', properties: { message, doc: { $ref: refTo(name) } } }\n : { allOf: [{ $ref: refTo(name) }, { type: 'object', properties: { message } }] }\n\n return {\n [`${pathBase}/versions`]: {\n get: {\n tags: versionsTag,\n operationId: `find${name}Versions`,\n parameters: listVersionParams({ base: name, ctx, refs }),\n responses: {\n '200': jsonResponse(t('versionList'), versionListRef(name)),\n ...errorResponses(ERRORS.versionList, t),\n },\n security: security.readVersions,\n },\n },\n [`${pathBase}/versions/{id}`]: {\n parameters: [idParam],\n get: {\n tags: versionsTag,\n operationId: `find${name}VersionById`,\n parameters: commonReadParams({ base: name, ctx, refs }),\n responses: {\n '200': jsonResponse(t('versionSingle'), versionRef(name)),\n ...errorResponses(ERRORS.versionRead, t),\n },\n security: security.readVersions,\n },\n post: {\n tags: versionsTag,\n operationId: `restore${name}Version`,\n parameters: [\n { name: 'depth', in: 'query', schema: { type: 'integer' } },\n { name: 'draft', in: 'query', schema: { type: 'boolean' } },\n ],\n responses: {\n '200': jsonResponse(t('versionRestored'), restoreResponse),\n ...errorResponses(ERRORS.versionRestore, t),\n },\n security: security.update,\n },\n },\n }\n}\n"],"mappings":";;;;;AAUA,MAAM,sBAAsB,MAAc,WAAiC;CACzE,MAAM,KAAmB,EAAE,MAAM,WAAW,WAAW,YAAY,SAAS;CAC5E,OAAO;EACL,MAAM;EACN,YAAY;GACV;GACA,QAAQ;GACR,SAAS,EAAE,MAAM,MAAM,IAAI,EAAE;GAC7B,WAAW;IAAE,MAAM;IAAU,QAAQ;GAAY;GACjD,WAAW;IAAE,MAAM;IAAU,QAAQ;GAAY;GACjD,QAAQ,EAAE,MAAM,UAAU;GAC1B,UAAU,EAAE,MAAM,UAAU;GAC5B,UAAU,EAAE,MAAM,UAAU;GAC5B,iBAAiB,EAAE,MAAM,SAAS;EACpC;EACA,UAAU;GAAC;GAAM;GAAU;GAAW;GAAa;EAAW;CAChE;AACF;AAEA,MAAM,0BAA0B,UAAgC;CAC9D,MAAM;CACN,YAAY;EACV,MAAM;GAAE,MAAM;GAAS,OAAO,EAAE,MAAM,MAAM,GAAG,KAAK,QAA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C;IACzC;IACA,UAAU,SAAS;GACrB;GACA,MAAM;IACJ,MAAM;IACN,aAAa,UAAU,KAAK;IAC5B,YAAY,CACV;KAAE,MAAM;KAAS,IAAI;KAAS,QAAQ,EAAE,MAAM,UAAU;IAAE,GAC1D;KAAE,MAAM;KAAS,IAAI;KAAS,QAAQ,EAAE,MAAM,UAAU;IAAE,CAC5D;IACA,WAAW;KACT,OAAO,aAAa,EAAE,iBAAiB,GAAG,eAAe;KACzD,GAAG,eAAe,OAAO,gBAAgB,CAAC;IAC5C;IACA,UAAU,SAAS;GACrB;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Entity, EntityOperation, EntitySecurityOverride, OperationKind, SecurityOption } from "../../shared/types/index.js";
|
|
2
|
+
import { Access, SanitizedConfig } from "payload";
|
|
3
|
+
import { PathsObject, SecurityRequirementObject } from "@scalar/openapi-types/3.2";
|
|
4
|
+
export declare const securedRequirement: (login?: boolean) => SecurityRequirementObject[];
|
|
5
|
+
type ProbedOperation = EntityOperation | 'readVersions';
|
|
6
|
+
export type EntitySecurity = Partial<Record<ProbedOperation, SecurityRequirementObject[] | undefined>>;
|
|
7
|
+
export declare const evaluateAccess: (access: Access | undefined, opts?: {
|
|
8
|
+
locale?: string;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
baseAccess?: SanitizedConfig['baseAccess'];
|
|
11
|
+
}) => Promise<boolean>;
|
|
12
|
+
export declare const readSecurityOverride: (entity: {
|
|
13
|
+
slug: string;
|
|
14
|
+
custom?: {
|
|
15
|
+
openapi?: {
|
|
16
|
+
security?: unknown;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}) => EntitySecurityOverride | undefined;
|
|
20
|
+
export declare const resolveEntitySecurity: ({ entity, operations, locale, baseAccess }: {
|
|
21
|
+
entity: Entity;
|
|
22
|
+
operations: ProbedOperation[];
|
|
23
|
+
locale?: string;
|
|
24
|
+
baseAccess?: SanitizedConfig['baseAccess'];
|
|
25
|
+
}) => Promise<EntitySecurity>;
|
|
26
|
+
export declare const applySecurity: ({ paths, slug, kind, security, login }: {
|
|
27
|
+
paths: PathsObject;
|
|
28
|
+
slug?: string;
|
|
29
|
+
kind: OperationKind;
|
|
30
|
+
security?: SecurityOption;
|
|
31
|
+
login?: boolean;
|
|
32
|
+
}) => Promise<PathsObject>;
|
|
33
|
+
//# sourceMappingURL=security.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { isPlainObject } from "../../shared/utils.js";
|
|
2
|
+
import { INTERACTIVE_SCHEME_NAME, SECURITY_SCHEME_NAME } from "./components.js";
|
|
3
|
+
import { PLUGIN_NAME } from "../../shared/constants.js";
|
|
4
|
+
const HTTP_METHODS = [
|
|
5
|
+
"get",
|
|
6
|
+
"post",
|
|
7
|
+
"patch",
|
|
8
|
+
"put",
|
|
9
|
+
"delete"
|
|
10
|
+
];
|
|
11
|
+
const securedRequirement = (login = false) => login ? [{ [SECURITY_SCHEME_NAME]: [] }, { [INTERACTIVE_SCHEME_NAME]: [] }] : [{ [SECURITY_SCHEME_NAME]: [] }];
|
|
12
|
+
const OVERRIDE_FALLBACK = {
|
|
13
|
+
readVersions: "read",
|
|
14
|
+
validate: "update"
|
|
15
|
+
};
|
|
16
|
+
const withTimeout = async (promise, timeoutMs) => {
|
|
17
|
+
let timer;
|
|
18
|
+
const guard = new Promise((resolve) => {
|
|
19
|
+
timer = setTimeout(() => resolve(false), timeoutMs);
|
|
20
|
+
});
|
|
21
|
+
try {
|
|
22
|
+
return await Promise.race([promise.then((value) => value === true, () => false), guard]);
|
|
23
|
+
} finally {
|
|
24
|
+
if (timer) clearTimeout(timer);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const evaluateAccess = async (access, opts = {}) => {
|
|
28
|
+
if (!access) return false;
|
|
29
|
+
const { locale, timeoutMs = 250, baseAccess } = opts;
|
|
30
|
+
const trap = (allowed, value) => new Proxy({}, { get(_target, key) {
|
|
31
|
+
if (key === allowed) return value;
|
|
32
|
+
throw new Error("req.payload accessed during build");
|
|
33
|
+
} });
|
|
34
|
+
const payloadTrap = trap("config", trap("baseAccess", baseAccess));
|
|
35
|
+
const req = {
|
|
36
|
+
user: null,
|
|
37
|
+
headers: new Headers(),
|
|
38
|
+
context: {},
|
|
39
|
+
locale,
|
|
40
|
+
payload: payloadTrap
|
|
41
|
+
};
|
|
42
|
+
try {
|
|
43
|
+
const result = access({ req });
|
|
44
|
+
if (result && typeof result.then === "function") return await withTimeout(result, timeoutMs);
|
|
45
|
+
return result === true;
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const readSecurityOverride = (entity) => {
|
|
51
|
+
const meta = entity.custom?.openapi?.security;
|
|
52
|
+
if ((isPlainObject(meta) ? Object.values(meta) : [meta]).some((value) => typeof value === "boolean")) throw new Error(`[${PLUGIN_NAME}] custom.openapi.security true/false on "${entity.slug}" was removed, use 'public' or 'secured'`);
|
|
53
|
+
return meta === void 0 ? void 0 : meta;
|
|
54
|
+
};
|
|
55
|
+
const overrideFor = (override, op) => {
|
|
56
|
+
const fallback = OVERRIDE_FALLBACK[op];
|
|
57
|
+
const marking = typeof override === "string" ? override : override?.[op] ?? (fallback ? override?.[fallback] : void 0);
|
|
58
|
+
return marking === void 0 ? void 0 : marking === "public";
|
|
59
|
+
};
|
|
60
|
+
const resolveEntitySecurity = async ({ entity, operations, locale, baseAccess }) => {
|
|
61
|
+
const override = readSecurityOverride(entity);
|
|
62
|
+
const access = entity.access;
|
|
63
|
+
const out = {};
|
|
64
|
+
for (const op of operations) out[op] = overrideFor(override, op) ?? await evaluateAccess(access?.[op], {
|
|
65
|
+
locale,
|
|
66
|
+
baseAccess
|
|
67
|
+
}) ? void 0 : securedRequirement();
|
|
68
|
+
return out;
|
|
69
|
+
};
|
|
70
|
+
const withLogin = (security) => security.some((r) => "PayloadToken" in r) && !security.some((r) => "PayloadLogin" in r) ? [...security, { [INTERACTIVE_SCHEME_NAME]: [] }] : security;
|
|
71
|
+
const applySecurity = async ({ paths, slug, kind, security, login = false }) => {
|
|
72
|
+
if (!security && !login) return paths;
|
|
73
|
+
for (const [path, item] of Object.entries(paths)) {
|
|
74
|
+
if (!item) continue;
|
|
75
|
+
const ops = item;
|
|
76
|
+
for (const method of HTTP_METHODS) {
|
|
77
|
+
const op = ops[method];
|
|
78
|
+
if (!op) continue;
|
|
79
|
+
if (login && op.security) op.security = withLogin(op.security);
|
|
80
|
+
if (!security) continue;
|
|
81
|
+
const decision = await security({
|
|
82
|
+
method,
|
|
83
|
+
path,
|
|
84
|
+
slug,
|
|
85
|
+
kind,
|
|
86
|
+
detected: op.security?.length ? "secured" : "public"
|
|
87
|
+
});
|
|
88
|
+
if (decision === "public") delete op.security;
|
|
89
|
+
else if (decision === "secured") op.security = securedRequirement(login);
|
|
90
|
+
else if (Array.isArray(decision)) op.security = decision;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return paths;
|
|
94
|
+
};
|
|
95
|
+
export { applySecurity, evaluateAccess, readSecurityOverride, resolveEntitySecurity, securedRequirement };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","names":[],"sources":["../../../src/server/spec/security.ts"],"sourcesContent":["import type { PathsObject, SecurityRequirementObject } from '@scalar/openapi-types/3.2'\nimport type { Access, SanitizedConfig } from 'payload'\n\nimport { PLUGIN_NAME } from '@/shared/constants.js'\nimport type {\n Entity,\n EntityOperation,\n EntitySecurityOverride,\n HttpMethod,\n OperationKind,\n SecurityOption,\n} from '@/shared/types/index.js'\nimport { isPlainObject } from '@/shared/utils.js'\n\nimport { INTERACTIVE_SCHEME_NAME, SECURITY_SCHEME_NAME } from './components.js'\n\nconst HTTP_METHODS: HttpMethod[] = ['get', 'post', 'patch', 'put', 'delete']\n\nexport const securedRequirement = (login = false): SecurityRequirementObject[] =>\n login ? [{ [SECURITY_SCHEME_NAME]: [] }, { [INTERACTIVE_SCHEME_NAME]: [] }] : [{ [SECURITY_SCHEME_NAME]: [] }]\n\ntype ProbedOperation = EntityOperation | 'readVersions'\n\nconst OVERRIDE_FALLBACK: Partial<Record<ProbedOperation, EntityOperation>> = {\n readVersions: 'read',\n validate: 'update',\n}\n\nexport type EntitySecurity = Partial<Record<ProbedOperation, SecurityRequirementObject[] | undefined>>\n\nconst withTimeout = async (promise: Promise<unknown>, timeoutMs: number): Promise<boolean> => {\n let timer: ReturnType<typeof setTimeout> | undefined\n const guard = new Promise<false>((resolve) => {\n timer = setTimeout(() => resolve(false), timeoutMs)\n })\n try {\n return await Promise.race([\n promise.then(\n (value) => value === true,\n () => false,\n ),\n guard,\n ])\n } finally {\n if (timer) clearTimeout(timer)\n }\n}\n\nexport const evaluateAccess = async (\n access: Access | undefined,\n opts: { locale?: string; timeoutMs?: number; baseAccess?: SanitizedConfig['baseAccess'] } = {},\n): Promise<boolean> => {\n if (!access) return false\n const { locale, timeoutMs = 250, baseAccess } = opts\n const trap = <T extends object>(allowed: PropertyKey, value: unknown): T =>\n new Proxy({} as T, {\n get(_target, key) {\n if (key === allowed) return value\n throw new Error('req.payload accessed during build')\n },\n })\n const payloadTrap = trap('config', trap('baseAccess', baseAccess))\n const req = { user: null, headers: new Headers(), context: {}, locale, payload: payloadTrap }\n try {\n const result = access({ req } as never)\n if (result && typeof (result as Promise<unknown>).then === 'function') {\n return await withTimeout(result as Promise<unknown>, timeoutMs)\n }\n return result === true\n } catch {\n return false\n }\n}\n\nexport const readSecurityOverride = (entity: {\n slug: string\n custom?: { openapi?: { security?: unknown } }\n}): EntitySecurityOverride | undefined => {\n const meta = entity.custom?.openapi?.security\n const values = isPlainObject(meta) ? Object.values(meta) : [meta]\n if (values.some((value) => typeof value === 'boolean')) {\n throw new Error(\n `[${PLUGIN_NAME}] custom.openapi.security true/false on \"${entity.slug}\" was removed, use 'public' or 'secured'`,\n )\n }\n return meta === undefined ? undefined : (meta as EntitySecurityOverride)\n}\n\nconst overrideFor = (override: EntitySecurityOverride | undefined, op: ProbedOperation): boolean | undefined => {\n const fallback = OVERRIDE_FALLBACK[op]\n const marking =\n typeof override === 'string'\n ? override\n : (override?.[op as EntityOperation] ?? (fallback ? override?.[fallback] : undefined))\n return marking === undefined ? undefined : marking === 'public'\n}\n\nexport const resolveEntitySecurity = async ({\n entity,\n operations,\n locale,\n baseAccess,\n}: {\n entity: Entity\n operations: ProbedOperation[]\n locale?: string\n baseAccess?: SanitizedConfig['baseAccess']\n}): Promise<EntitySecurity> => {\n const override = readSecurityOverride(entity)\n const access = entity.access as Partial<Record<ProbedOperation, Access>> | undefined\n const out: EntitySecurity = {}\n for (const op of operations) {\n const declared = overrideFor(override, op)\n const isPublic = declared ?? (await evaluateAccess(access?.[op], { locale, baseAccess }))\n out[op] = isPublic ? undefined : securedRequirement()\n }\n return out\n}\n\nconst withLogin = (security: SecurityRequirementObject[]): SecurityRequirementObject[] =>\n security.some((r) => SECURITY_SCHEME_NAME in r) && !security.some((r) => INTERACTIVE_SCHEME_NAME in r)\n ? [...security, { [INTERACTIVE_SCHEME_NAME]: [] }]\n : security\n\nexport const applySecurity = async ({\n paths,\n slug,\n kind,\n security,\n login = false,\n}: {\n paths: PathsObject\n slug?: string\n kind: OperationKind\n security?: SecurityOption\n login?: boolean\n}): Promise<PathsObject> => {\n if (!security && !login) return paths\n for (const [path, item] of Object.entries(paths)) {\n if (!item) continue\n const ops = item as Record<HttpMethod, { security?: SecurityRequirementObject[] } | undefined>\n for (const method of HTTP_METHODS) {\n const op = ops[method]\n if (!op) continue\n if (login && op.security) op.security = withLogin(op.security)\n if (!security) continue\n const detected = op.security?.length ? 'secured' : 'public'\n const decision = await security({ method, path, slug, kind, detected })\n if (decision === 'public') delete op.security\n else if (decision === 'secured') op.security = securedRequirement(login)\n else if (Array.isArray(decision)) op.security = decision\n }\n }\n return paths\n}\n"],"mappings":";;;AAgBA,MAAM,eAA6B;CAAC;CAAO;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AAC,UAAU;GAEf,MAAM,WAAW,MAAM,SAAS;IAAE;IAAQ;IAAM;IAAM;IAAM,UAD3C,GAAG,UAAU,SAAS,YAAY;GACkB,CAAC;GACtE,IAAI,aAAa,UAAU,OAAO,GAAG;QAChC,IAAI,aAAa,WAAW,GAAG,WAAW,mBAAmB,KAAK;QAClE,IAAI,MAAM,QAAQ,QAAQ,GAAG,GAAG,WAAW;EAClD;CACF;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Translate } from "../../shared/translations/types.js";
|
|
2
|
+
import { TagObject } from "@scalar/openapi-types/3.2";
|
|
3
|
+
export declare const NAV_COLLECTIONS = "Collections";
|
|
4
|
+
export declare const NAV_GLOBALS = "Globals";
|
|
5
|
+
export declare const NAV_SYSTEM = "System";
|
|
6
|
+
export declare const entityTagName: (base: string) => string;
|
|
7
|
+
export declare const authTagName: (base: string) => string;
|
|
8
|
+
export declare const versionsTagName: (base: string) => string;
|
|
9
|
+
declare const SYSTEM_TAG_SUMMARIES: {
|
|
10
|
+
readonly Jobs: 'tagJobs';
|
|
11
|
+
readonly Uploads: 'tagUploads';
|
|
12
|
+
readonly Access: 'tagAccess';
|
|
13
|
+
};
|
|
14
|
+
export type SystemTag = keyof typeof SYSTEM_TAG_SUMMARIES;
|
|
15
|
+
export interface CollectionTagInfo {
|
|
16
|
+
base: string;
|
|
17
|
+
hasAuth: boolean;
|
|
18
|
+
hasVersions: boolean;
|
|
19
|
+
description?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface GlobalTagInfo {
|
|
22
|
+
base: string;
|
|
23
|
+
hasVersions: boolean;
|
|
24
|
+
description?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface TagHierarchyInput {
|
|
27
|
+
collections: CollectionTagInfo[];
|
|
28
|
+
globals: GlobalTagInfo[];
|
|
29
|
+
systemTags: SystemTag[];
|
|
30
|
+
t: Translate;
|
|
31
|
+
nested: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare const buildTagHierarchy: ({ collections, globals, systemTags, t, nested }: TagHierarchyInput) => TagObject[];
|
|
34
|
+
//# sourceMappingURL=tags.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const NAV_COLLECTIONS = "Collections";
|
|
2
|
+
const NAV_GLOBALS = "Globals";
|
|
3
|
+
const NAV_SYSTEM = "System";
|
|
4
|
+
const entityTagName = (base) => base;
|
|
5
|
+
const authTagName = (base) => `${base} Auth`;
|
|
6
|
+
const versionsTagName = (base) => `${base} Versions`;
|
|
7
|
+
const SYSTEM_TAG_SUMMARIES = {
|
|
8
|
+
Jobs: "tagJobs",
|
|
9
|
+
Uploads: "tagUploads",
|
|
10
|
+
Access: "tagAccess"
|
|
11
|
+
};
|
|
12
|
+
const buildTagHierarchy = ({ collections, globals, systemTags, t, nested }) => {
|
|
13
|
+
if (!nested) return [...collections.map((c) => ({
|
|
14
|
+
name: entityTagName(c.base),
|
|
15
|
+
description: c.description
|
|
16
|
+
})), ...globals.map((g) => ({
|
|
17
|
+
name: entityTagName(g.base),
|
|
18
|
+
description: g.description
|
|
19
|
+
}))];
|
|
20
|
+
const tags = [];
|
|
21
|
+
if (collections.length > 0) {
|
|
22
|
+
tags.push({
|
|
23
|
+
name: NAV_COLLECTIONS,
|
|
24
|
+
summary: t("tagCollections"),
|
|
25
|
+
description: t("tagCollectionsDesc"),
|
|
26
|
+
kind: "nav"
|
|
27
|
+
});
|
|
28
|
+
for (const c of collections) {
|
|
29
|
+
tags.push({
|
|
30
|
+
name: entityTagName(c.base),
|
|
31
|
+
parent: NAV_COLLECTIONS,
|
|
32
|
+
description: c.description
|
|
33
|
+
});
|
|
34
|
+
if (c.hasAuth) tags.push({
|
|
35
|
+
name: authTagName(c.base),
|
|
36
|
+
parent: c.base,
|
|
37
|
+
summary: t("tagAuth")
|
|
38
|
+
});
|
|
39
|
+
if (c.hasVersions) tags.push({
|
|
40
|
+
name: versionsTagName(c.base),
|
|
41
|
+
parent: c.base,
|
|
42
|
+
summary: t("tagVersions")
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (globals.length > 0) {
|
|
47
|
+
tags.push({
|
|
48
|
+
name: NAV_GLOBALS,
|
|
49
|
+
summary: t("tagGlobals"),
|
|
50
|
+
description: t("tagGlobalsDesc"),
|
|
51
|
+
kind: "nav"
|
|
52
|
+
});
|
|
53
|
+
for (const g of globals) {
|
|
54
|
+
tags.push({
|
|
55
|
+
name: entityTagName(g.base),
|
|
56
|
+
parent: NAV_GLOBALS,
|
|
57
|
+
description: g.description
|
|
58
|
+
});
|
|
59
|
+
if (g.hasVersions) tags.push({
|
|
60
|
+
name: versionsTagName(g.base),
|
|
61
|
+
parent: g.base,
|
|
62
|
+
summary: t("tagVersions")
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (systemTags.length > 0) {
|
|
67
|
+
tags.push({
|
|
68
|
+
name: NAV_SYSTEM,
|
|
69
|
+
summary: t("tagSystem"),
|
|
70
|
+
description: t("tagSystemDesc"),
|
|
71
|
+
kind: "nav"
|
|
72
|
+
});
|
|
73
|
+
for (const name of systemTags) tags.push({
|
|
74
|
+
name,
|
|
75
|
+
parent: NAV_SYSTEM,
|
|
76
|
+
summary: t(SYSTEM_TAG_SUMMARIES[name])
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return tags;
|
|
80
|
+
};
|
|
81
|
+
export { NAV_COLLECTIONS, NAV_GLOBALS, NAV_SYSTEM, authTagName, buildTagHierarchy, entityTagName, versionsTagName };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.js","names":[],"sources":["../../../src/server/spec/tags.ts"],"sourcesContent":["import type { TagObject } from '@scalar/openapi-types/3.2'\n\nimport type { Translate } from '@/shared/translations/types.js'\n\nexport const NAV_COLLECTIONS = 'Collections'\nexport const NAV_GLOBALS = 'Globals'\nexport const NAV_SYSTEM = 'System'\n\nexport const entityTagName = (base: string): string => base\nexport const authTagName = (base: string): string => `${base} Auth`\nexport const versionsTagName = (base: string): string => `${base} Versions`\n\nconst SYSTEM_TAG_SUMMARIES = { Jobs: 'tagJobs', Uploads: 'tagUploads', Access: 'tagAccess' } as const\n\nexport type SystemTag = keyof typeof SYSTEM_TAG_SUMMARIES\n\nexport interface CollectionTagInfo {\n base: string\n hasAuth: boolean\n hasVersions: boolean\n description?: string\n}\n\nexport interface GlobalTagInfo {\n base: string\n hasVersions: boolean\n description?: string\n}\n\nexport interface TagHierarchyInput {\n collections: CollectionTagInfo[]\n globals: GlobalTagInfo[]\n systemTags: SystemTag[]\n t: Translate\n nested: boolean\n}\n\nexport const buildTagHierarchy = ({ collections, globals, systemTags, t, nested }: TagHierarchyInput): TagObject[] => {\n if (!nested) {\n return [\n ...collections.map((c) => ({ name: entityTagName(c.base), description: c.description })),\n ...globals.map((g) => ({ name: entityTagName(g.base), description: g.description })),\n ]\n }\n\n const tags: TagObject[] = []\n\n if (collections.length > 0) {\n tags.push({\n name: NAV_COLLECTIONS,\n summary: t('tagCollections'),\n description: t('tagCollectionsDesc'),\n kind: 'nav',\n })\n for (const c of collections) {\n tags.push({ name: entityTagName(c.base), parent: NAV_COLLECTIONS, description: c.description })\n if (c.hasAuth) tags.push({ name: authTagName(c.base), parent: c.base, summary: t('tagAuth') })\n if (c.hasVersions) tags.push({ name: versionsTagName(c.base), parent: c.base, summary: t('tagVersions') })\n }\n }\n\n if (globals.length > 0) {\n tags.push({ name: NAV_GLOBALS, summary: t('tagGlobals'), description: t('tagGlobalsDesc'), kind: 'nav' })\n for (const g of globals) {\n tags.push({ name: entityTagName(g.base), parent: NAV_GLOBALS, description: g.description })\n if (g.hasVersions) tags.push({ name: versionsTagName(g.base), parent: g.base, summary: t('tagVersions') })\n }\n }\n\n if (systemTags.length > 0) {\n tags.push({ name: NAV_SYSTEM, summary: t('tagSystem'), description: t('tagSystemDesc'), kind: 'nav'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