moonflower 1.2.0 → 1.3.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/cli/entry.cjs +1 -1
- package/dist/cli/cli.cjs +2 -0
- package/dist/cli/cli.cjs.map +1 -0
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/cli/cli.mjs +62 -0
- package/dist/cli/cli.mjs.map +1 -0
- package/dist/cli/prettyprint.cjs +2 -0
- package/dist/cli/prettyprint.cjs.map +1 -0
- package/dist/cli/prettyprint.d.ts +5 -0
- package/dist/cli/prettyprint.d.ts.map +1 -0
- package/dist/cli/prettyprint.mjs +15 -0
- package/dist/cli/prettyprint.mjs.map +1 -0
- package/dist/errors/UserFacingErrors.cjs +1 -1
- package/dist/errors/UserFacingErrors.cjs.map +1 -1
- package/dist/errors/UserFacingErrors.d.ts +27 -0
- package/dist/errors/UserFacingErrors.d.ts.map +1 -1
- package/dist/errors/UserFacingErrors.mjs +67 -13
- package/dist/errors/UserFacingErrors.mjs.map +1 -1
- package/dist/hooks/usePathParams.cjs +1 -1
- package/dist/hooks/usePathParams.cjs.map +1 -1
- package/dist/hooks/usePathParams.d.ts.map +1 -1
- package/dist/hooks/usePathParams.mjs +20 -27
- package/dist/hooks/usePathParams.mjs.map +1 -1
- package/dist/hooks/useQueryParams.cjs +1 -1
- package/dist/hooks/useQueryParams.cjs.map +1 -1
- package/dist/hooks/useQueryParams.d.ts +4 -3
- package/dist/hooks/useQueryParams.d.ts.map +1 -1
- package/dist/hooks/useQueryParams.mjs +24 -33
- package/dist/hooks/useQueryParams.mjs.map +1 -1
- package/dist/hooks/useRequestBody.cjs +1 -1
- package/dist/hooks/useRequestBody.cjs.map +1 -1
- package/dist/hooks/useRequestBody.d.ts +4 -3
- package/dist/hooks/useRequestBody.d.ts.map +1 -1
- package/dist/hooks/useRequestBody.mjs +23 -34
- package/dist/hooks/useRequestBody.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +64 -55
- package/dist/node_modules/zod/index.cjs +2 -0
- package/dist/node_modules/zod/index.cjs.map +1 -0
- package/dist/node_modules/zod/index.mjs +6 -0
- package/dist/node_modules/zod/index.mjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/checks.cjs +2 -0
- package/dist/node_modules/zod/v4/classic/checks.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/checks.mjs +34 -0
- package/dist/node_modules/zod/v4/classic/checks.mjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/coerce.cjs +2 -0
- package/dist/node_modules/zod/v4/classic/coerce.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/coerce.mjs +26 -0
- package/dist/node_modules/zod/v4/classic/coerce.mjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/compat.cjs +2 -0
- package/dist/node_modules/zod/v4/classic/compat.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/compat.mjs +35 -0
- package/dist/node_modules/zod/v4/classic/compat.mjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/errors.cjs +2 -0
- package/dist/node_modules/zod/v4/classic/errors.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/errors.mjs +41 -0
- package/dist/node_modules/zod/v4/classic/errors.mjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/external.cjs +2 -0
- package/dist/node_modules/zod/v4/classic/external.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/external.mjs +260 -0
- package/dist/node_modules/zod/v4/classic/external.mjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/from-json-schema.cjs +2 -0
- package/dist/node_modules/zod/v4/classic/from-json-schema.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/from-json-schema.mjs +287 -0
- package/dist/node_modules/zod/v4/classic/from-json-schema.mjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/iso.cjs +2 -0
- package/dist/node_modules/zod/v4/classic/iso.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/iso.mjs +40 -0
- package/dist/node_modules/zod/v4/classic/iso.mjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/parse.cjs +2 -0
- package/dist/node_modules/zod/v4/classic/parse.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/parse.mjs +19 -0
- package/dist/node_modules/zod/v4/classic/parse.mjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/schemas.cjs +2 -0
- package/dist/node_modules/zod/v4/classic/schemas.cjs.map +1 -0
- package/dist/node_modules/zod/v4/classic/schemas.mjs +912 -0
- package/dist/node_modules/zod/v4/classic/schemas.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/api.cjs +2 -0
- package/dist/node_modules/zod/v4/core/api.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/api.mjs +1110 -0
- package/dist/node_modules/zod/v4/core/api.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/checks.cjs +2 -0
- package/dist/node_modules/zod/v4/core/checks.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/checks.mjs +421 -0
- package/dist/node_modules/zod/v4/core/checks.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/core.cjs +2 -0
- package/dist/node_modules/zod/v4/core/core.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/core.mjs +62 -0
- package/dist/node_modules/zod/v4/core/core.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/doc.cjs +4 -0
- package/dist/node_modules/zod/v4/core/doc.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/doc.mjs +27 -0
- package/dist/node_modules/zod/v4/core/doc.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/errors.cjs +3 -0
- package/dist/node_modules/zod/v4/core/errors.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/errors.mjs +89 -0
- package/dist/node_modules/zod/v4/core/errors.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/index.cjs +2 -0
- package/dist/node_modules/zod/v4/core/index.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/index.mjs +293 -0
- package/dist/node_modules/zod/v4/core/index.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema-generator.cjs +2 -0
- package/dist/node_modules/zod/v4/core/json-schema-generator.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema-generator.mjs +66 -0
- package/dist/node_modules/zod/v4/core/json-schema-generator.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.cjs +2 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.mjs +346 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema.cjs +2 -0
- package/dist/node_modules/zod/v4/core/json-schema.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema.mjs +2 -0
- package/dist/node_modules/zod/v4/core/json-schema.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/parse.cjs +2 -0
- package/dist/node_modules/zod/v4/core/parse.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/parse.mjs +75 -0
- package/dist/node_modules/zod/v4/core/parse.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/regexes.cjs +2 -0
- package/dist/node_modules/zod/v4/core/regexes.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/regexes.mjs +94 -0
- package/dist/node_modules/zod/v4/core/regexes.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/registries.cjs +2 -0
- package/dist/node_modules/zod/v4/core/registries.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/registries.mjs +44 -0
- package/dist/node_modules/zod/v4/core/registries.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/schemas.cjs +36 -0
- package/dist/node_modules/zod/v4/core/schemas.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/schemas.mjs +1319 -0
- package/dist/node_modules/zod/v4/core/schemas.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs +4 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.mjs +244 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/util.cjs +2 -0
- package/dist/node_modules/zod/v4/core/util.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/util.mjs +523 -0
- package/dist/node_modules/zod/v4/core/util.mjs.map +1 -0
- package/dist/node_modules/zod/v4/core/versions.cjs +2 -0
- package/dist/node_modules/zod/v4/core/versions.cjs.map +1 -0
- package/dist/node_modules/zod/v4/core/versions.mjs +9 -0
- package/dist/node_modules/zod/v4/core/versions.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ar.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/ar.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ar.mjs +87 -0
- package/dist/node_modules/zod/v4/locales/ar.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/az.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/az.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/az.mjs +87 -0
- package/dist/node_modules/zod/v4/locales/az.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/be.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/be.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/be.mjs +129 -0
- package/dist/node_modules/zod/v4/locales/be.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/bg.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/bg.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/bg.mjs +98 -0
- package/dist/node_modules/zod/v4/locales/bg.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ca.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/ca.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ca.mjs +88 -0
- package/dist/node_modules/zod/v4/locales/ca.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/cs.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/cs.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/cs.mjs +91 -0
- package/dist/node_modules/zod/v4/locales/cs.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/da.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/da.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/da.mjs +94 -0
- package/dist/node_modules/zod/v4/locales/da.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/de.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/de.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/de.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/de.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/en.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/en.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/en.mjs +91 -0
- package/dist/node_modules/zod/v4/locales/en.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/eo.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/eo.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/eo.mjs +90 -0
- package/dist/node_modules/zod/v4/locales/eo.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/es.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/es.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/es.mjs +111 -0
- package/dist/node_modules/zod/v4/locales/es.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/fa.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/fa.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/fa.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/fa.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/fi.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/fi.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/fi.mjs +91 -0
- package/dist/node_modules/zod/v4/locales/fi.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/fr-CA.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/fr-CA.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/fr-CA.mjs +87 -0
- package/dist/node_modules/zod/v4/locales/fr-CA.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/fr.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/fr.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/fr.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/fr.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/he.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/he.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/he.mjs +152 -0
- package/dist/node_modules/zod/v4/locales/he.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/hu.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/hu.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/hu.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/hu.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/hy.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/hy.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/hy.mjs +130 -0
- package/dist/node_modules/zod/v4/locales/hy.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/id.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/id.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/id.mjs +87 -0
- package/dist/node_modules/zod/v4/locales/id.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/index.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/index.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/index.mjs +101 -0
- package/dist/node_modules/zod/v4/locales/index.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/is.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/is.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/is.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/is.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/it.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/it.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/it.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/it.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ja.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/ja.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ja.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/ja.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ka.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/ka.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ka.mjs +92 -0
- package/dist/node_modules/zod/v4/locales/ka.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/kh.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/kh.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/kh.mjs +8 -0
- package/dist/node_modules/zod/v4/locales/kh.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/km.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/km.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/km.mjs +90 -0
- package/dist/node_modules/zod/v4/locales/km.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ko.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/ko.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ko.mjs +87 -0
- package/dist/node_modules/zod/v4/locales/ko.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/lt.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/lt.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/lt.mjs +178 -0
- package/dist/node_modules/zod/v4/locales/lt.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/mk.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/mk.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/mk.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/mk.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ms.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/ms.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ms.mjs +88 -0
- package/dist/node_modules/zod/v4/locales/ms.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/nl.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/nl.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/nl.mjs +88 -0
- package/dist/node_modules/zod/v4/locales/nl.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/no.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/no.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/no.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/no.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ota.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/ota.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ota.mjs +90 -0
- package/dist/node_modules/zod/v4/locales/ota.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/pl.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/pl.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/pl.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/pl.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ps.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/ps.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ps.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/ps.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/pt.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/pt.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/pt.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/pt.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ru.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/ru.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ru.mjs +129 -0
- package/dist/node_modules/zod/v4/locales/ru.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/sl.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/sl.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/sl.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/sl.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/sv.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/sv.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/sv.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/sv.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ta.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/ta.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ta.mjs +90 -0
- package/dist/node_modules/zod/v4/locales/ta.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/th.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/th.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/th.mjs +90 -0
- package/dist/node_modules/zod/v4/locales/th.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/tr.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/tr.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/tr.mjs +87 -0
- package/dist/node_modules/zod/v4/locales/tr.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ua.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/ua.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ua.mjs +8 -0
- package/dist/node_modules/zod/v4/locales/ua.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/uk.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/uk.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/uk.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/uk.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ur.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/ur.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/ur.mjs +90 -0
- package/dist/node_modules/zod/v4/locales/ur.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/uz.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/uz.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/uz.mjs +90 -0
- package/dist/node_modules/zod/v4/locales/uz.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/vi.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/vi.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/vi.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/vi.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/yo.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/yo.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/yo.mjs +89 -0
- package/dist/node_modules/zod/v4/locales/yo.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/zh-CN.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/zh-CN.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/zh-CN.mjs +90 -0
- package/dist/node_modules/zod/v4/locales/zh-CN.mjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/zh-TW.cjs +2 -0
- package/dist/node_modules/zod/v4/locales/zh-TW.cjs.map +1 -0
- package/dist/node_modules/zod/v4/locales/zh-TW.mjs +87 -0
- package/dist/node_modules/zod/v4/locales/zh-TW.mjs.map +1 -0
- package/dist/openapi/analyzerModule/analyzerModule.cjs +1 -1
- package/dist/openapi/analyzerModule/analyzerModule.cjs.map +1 -1
- package/dist/openapi/analyzerModule/analyzerModule.d.ts.map +1 -1
- package/dist/openapi/analyzerModule/analyzerModule.mjs +42 -42
- package/dist/openapi/analyzerModule/analyzerModule.mjs.map +1 -1
- package/dist/openapi/analyzerModule/nodeParsers.cjs +1 -1
- package/dist/openapi/analyzerModule/nodeParsers.cjs.map +1 -1
- package/dist/openapi/analyzerModule/nodeParsers.d.ts +1 -0
- package/dist/openapi/analyzerModule/nodeParsers.d.ts.map +1 -1
- package/dist/openapi/analyzerModule/nodeParsers.mjs +261 -206
- package/dist/openapi/analyzerModule/nodeParsers.mjs.map +1 -1
- package/dist/openapi/analyzerModule/parseEndpoint.cjs +1 -1
- package/dist/openapi/analyzerModule/parseEndpoint.cjs.map +1 -1
- package/dist/openapi/analyzerModule/parseEndpoint.d.ts.map +1 -1
- package/dist/openapi/analyzerModule/parseEndpoint.mjs +62 -62
- package/dist/openapi/analyzerModule/parseEndpoint.mjs.map +1 -1
- package/dist/openapi/analyzerModule/test/TestCase.d.ts +9 -0
- package/dist/openapi/analyzerModule/test/TestCase.d.ts.map +1 -0
- package/dist/openapi/analyzerModule/test/openApiAnalyzer.zod.spec.d.ts +2 -0
- package/dist/openapi/analyzerModule/test/openApiAnalyzer.zod.spec.d.ts.map +1 -0
- package/dist/openapi/analyzerModule/test/openApiAnalyzer.zod.spec.data.d.ts +2 -0
- package/dist/openapi/analyzerModule/test/openApiAnalyzer.zod.spec.data.d.ts.map +1 -0
- package/dist/openapi/initOpenApiEngine.cjs +1 -1
- package/dist/openapi/initOpenApiEngine.cjs.map +1 -1
- package/dist/openapi/initOpenApiEngine.d.ts +7 -2
- package/dist/openapi/initOpenApiEngine.d.ts.map +1 -1
- package/dist/openapi/initOpenApiEngine.mjs +13 -7
- package/dist/openapi/initOpenApiEngine.mjs.map +1 -1
- package/dist/openapi/manager/OpenApiManager.cjs +1 -1
- package/dist/openapi/manager/OpenApiManager.cjs.map +1 -1
- package/dist/openapi/manager/OpenApiManager.d.ts +4 -0
- package/dist/openapi/manager/OpenApiManager.d.ts.map +1 -1
- package/dist/openapi/manager/OpenApiManager.mjs +11 -2
- package/dist/openapi/manager/OpenApiManager.mjs.map +1 -1
- package/dist/openapi/router/OpenApiRouter.cjs +1 -1
- package/dist/openapi/router/OpenApiRouter.cjs.map +1 -1
- package/dist/openapi/router/OpenApiRouter.d.ts.map +1 -1
- package/dist/openapi/router/OpenApiRouter.mjs +9 -6
- package/dist/openapi/router/OpenApiRouter.mjs.map +1 -1
- package/dist/utils/getValueAsNullableString.cjs +2 -0
- package/dist/utils/getValueAsNullableString.cjs.map +1 -0
- package/dist/utils/getValueAsNullableString.d.ts +2 -0
- package/dist/utils/getValueAsNullableString.d.ts.map +1 -0
- package/dist/utils/getValueAsNullableString.mjs +7 -0
- package/dist/utils/getValueAsNullableString.mjs.map +1 -0
- package/dist/utils/validationMessages.cjs +1 -1
- package/dist/utils/validationMessages.cjs.map +1 -1
- package/dist/utils/validationMessages.d.ts +1 -1
- package/dist/utils/validationMessages.d.ts.map +1 -1
- package/dist/utils/validationMessages.mjs +8 -8
- package/dist/utils/validationMessages.mjs.map +1 -1
- package/dist/validators/types.d.ts +4 -0
- package/dist/validators/types.d.ts.map +1 -1
- package/dist/validators/validateMissingParams.cjs +2 -0
- package/dist/validators/validateMissingParams.cjs.map +1 -0
- package/dist/validators/validateMissingParams.d.ts +7 -0
- package/dist/validators/validateMissingParams.d.ts.map +1 -0
- package/dist/validators/validateMissingParams.mjs +17 -0
- package/dist/validators/validateMissingParams.mjs.map +1 -0
- package/dist/validators/validateParam.cjs +2 -0
- package/dist/validators/validateParam.cjs.map +1 -0
- package/dist/validators/validateParam.d.ts +8 -0
- package/dist/validators/validateParam.d.ts.map +1 -0
- package/dist/validators/validateParam.mjs +41 -0
- package/dist/validators/validateParam.mjs.map +1 -0
- package/package.json +12 -5
- package/{cli → src/cli}/cli.ts +26 -6
- package/{cli → src/cli}/prettyprint.ts +2 -2
- package/src/errors/UserFacingErrors.ts +54 -0
- package/src/hooks/usePathParams.spec.ts +27 -0
- package/src/hooks/usePathParams.ts +5 -13
- package/src/hooks/useQueryParams.spec.ts +99 -0
- package/src/hooks/useQueryParams.ts +16 -25
- package/src/hooks/useRequestBody.spec.ts +99 -0
- package/src/hooks/useRequestBody.ts +16 -35
- package/src/openapi/analyzerModule/analyzerModule.ts +2 -3
- package/src/openapi/analyzerModule/nodeParsers.ts +113 -8
- package/src/openapi/analyzerModule/parseEndpoint.ts +2 -2
- package/src/openapi/analyzerModule/test/TestCase.ts +8 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.ts +9 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.ts +21 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.zod.spec.data.ts +87 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.zod.spec.ts +178 -0
- package/src/openapi/initOpenApiEngine.ts +48 -6
- package/src/openapi/manager/OpenApiManager.ts +16 -0
- package/src/openapi/router/OpenApiRouter.ts +6 -1
- package/src/test/app.spec.ts +27 -0
- package/src/utils/getValueAsNullableString.ts +8 -0
- package/src/utils/validationMessages.ts +4 -0
- package/src/validators/types.ts +5 -0
- package/src/validators/validateMissingParams.ts +27 -0
- package/src/validators/validateParam.ts +69 -0
- package/vite.config.ts +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseEndpoint.mjs","sources":["../../../src/openapi/analyzerModule/parseEndpoint.ts"],"sourcesContent":["import { Node, SyntaxKind, ts } from 'ts-morph'\n\nimport { ApiEndpointDocs } from '../../hooks/useApiEndpoint'\nimport { Logger } from '../../utils/logger'\nimport { EndpointData } from '../types'\nimport {\n\tfindNodeImplementation,\n\tgetProperTypeShape,\n\tgetShapeOfValidatorLiteral,\n\tgetValidatorPropertyOptionality,\n\tgetValidatorPropertyShape,\n\tgetValidatorPropertyStringValue,\n\tgetValuesOfObjectLiteral,\n} from './nodeParsers'\n\nexport const parseEndpoint = (node: Node<ts.Node>, sourceFilePath: string) => {\n\tconst parsedEndpointMethod = node\n\t\t.getFirstDescendantByKind(SyntaxKind.PropertyAccessExpression)!\n\t\t.getText()\n\t\t.split('.')[1]\n\t\t.toUpperCase()\n\n\tconst endpointMethod = parsedEndpointMethod === 'DEL' ? 'DELETE' : parsedEndpointMethod\n\n\tconst endpointText = node.getFirstDescendantByKind(SyntaxKind.StringLiteral)!.getText() ?? ''\n\tconst endpointPath = endpointText.substring(1, endpointText.length - 1)\n\n\tconst endpointData: EndpointData = {\n\t\tmethod: endpointMethod as 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',\n\t\tpath: endpointPath,\n\t\tsourceFilePath,\n\t\trequestPathParams: [],\n\t\trequestQuery: [],\n\t\trequestHeaders: [],\n\t\trawBody: undefined,\n\t\tobjectBody: [],\n\t\tresponses: [],\n\t\tname: undefined,\n\t\tsummary: undefined,\n\t\tdescription: undefined,\n\t\ttags: undefined,\n\t}\n\n\tconst warningData: {\n\t\tsegment: string\n\t\terror: Error\n\t}[] = []\n\n\t// API documentation\n\ttry {\n\t\tconst entries = parseApiDocumentation(node)\n\t\tentries.forEach((param) => {\n\t\t\tendpointData[param.identifier] = param.value as string & string[]\n\t\t})\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'api',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\t// Request params\n\ttry {\n\t\tendpointData.requestPathParams = parseRequestParams(node, endpointPath)\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'path',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\t// Request query\n\ttry {\n\t\tendpointData.requestQuery = parseRequestObjectInput(node, 'useQueryParams')\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'query',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\t// Request headers\n\ttry {\n\t\tendpointData.requestHeaders = parseRequestObjectInput(node, 'useHeaderParams')\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'headers',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\t// Raw request body\n\ttry {\n\t\tconst parsedBody = parseRequestRawBody(node)\n\t\tif (parsedBody) {\n\t\t\tendpointData.rawBody = parsedBody\n\t\t}\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'rawBody',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\t// Object request body\n\ttry {\n\t\tendpointData.objectBody = parseRequestObjectInput(node, 'useRequestBody')\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'objectBody',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\t// Request response\n\ttry {\n\t\tendpointData.responses = parseRequestResponse(node)\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'response',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\treturn endpointData\n}\n\nconst getHookNode = (\n\tendpointNode: Node<ts.Node>,\n\thookName:\n\t\t| 'useApiEndpoint'\n\t\t| 'usePathParams'\n\t\t| 'useQueryParams'\n\t\t| 'useHeaderParams'\n\t\t| 'useRequestBody'\n\t\t| 'useRequestRawBody',\n) => {\n\tconst callExpressions = endpointNode.getDescendantsOfKind(SyntaxKind.CallExpression)\n\tconst matchingCallExpressions = callExpressions.filter((node) => {\n\t\treturn node.getFirstChildByKind(SyntaxKind.Identifier)?.getText() === hookName\n\t})\n\treturn matchingCallExpressions[0] ?? null\n}\n\nconst parseApiDocumentation = (node: Node<ts.Node>) => {\n\tconst hookNode = getHookNode(node, 'useApiEndpoint')\n\tif (!hookNode) {\n\t\treturn []\n\t}\n\tconst paramNode = hookNode.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\tconst valueNode = findNodeImplementation(paramNode.getLastChild()!)\n\n\tif (!valueNode.isKind(SyntaxKind.ObjectLiteralExpression)) {\n\t\tthrow new Error('Non-literal type used in useApiEndpoint')\n\t}\n\n\tconst objectLiteral = valueNode.asKind(SyntaxKind.ObjectLiteralExpression)!\n\n\tconst values = getValuesOfObjectLiteral(objectLiteral).filter((param) => param.value !== null)\n\treturn values as {\n\t\tidentifier: keyof ApiEndpointDocs\n\t\tvalue: (typeof values)[number]['value']\n\t}[]\n}\n\nconst parseRequestParams = (node: Node<ts.Node>, endpointPath: string): EndpointData['requestPathParams'] => {\n\tconst hookNode = getHookNode(node, 'usePathParams')\n\tif (!hookNode) {\n\t\treturn []\n\t}\n\n\tconst paramNode = hookNode.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\tconst valueNode = findNodeImplementation(paramNode.getLastChild()!)\n\n\tif (!valueNode.isKind(SyntaxKind.ObjectLiteralExpression)) {\n\t\tthrow new Error('Non-literal type used in usePathParams')\n\t}\n\n\tconst declaredParams = endpointPath\n\t\t.split('/')\n\t\t.filter((segment) => segment.startsWith(':'))\n\t\t.map((segment) => ({\n\t\t\tname: segment.substring(1).replace(/\\?/, ''),\n\t\t\toptional: segment.includes('?'),\n\t\t}))\n\n\tconst objectLiteral = valueNode.asKind(SyntaxKind.ObjectLiteralExpression)!\n\treturn getShapeOfValidatorLiteral(objectLiteral)\n\t\t.filter((param) => param.shape !== null)\n\t\t.map((param) => ({\n\t\t\tidentifier: param.identifier,\n\t\t\tsignature: param.shape as string,\n\t\t\toptional: declaredParams.some((declared) => declared.name === param.identifier && declared.optional),\n\t\t\tdescription: param.description,\n\t\t\terrorMessage: param.errorMessage,\n\t\t}))\n}\n\nconst parseRequestRawBody = (node: Node<ts.Node>): NonNullable<EndpointData['rawBody']> | null => {\n\tconst hookNode = getHookNode(node, 'useRequestRawBody')\n\tif (!hookNode) {\n\t\treturn null\n\t}\n\tconst paramNode = hookNode.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\tconst valueNode = findNodeImplementation(\n\t\tparamNode.getLastChild((node) => !node.isKind(SyntaxKind.CommaToken))!,\n\t)\n\n\treturn {\n\t\tsignature: getValidatorPropertyShape(valueNode),\n\t\toptional: getValidatorPropertyOptionality(valueNode),\n\t\tdescription: getValidatorPropertyStringValue(valueNode, 'description'),\n\t\terrorMessage: getValidatorPropertyStringValue(valueNode, 'errorMessage'),\n\t}\n}\n\nconst parseRequestObjectInput = (\n\tnode: Node<ts.Node>,\n\tnodeName: 'useQueryParams' | 'useHeaderParams' | 'useRequestBody',\n): EndpointData['requestQuery'] | EndpointData['objectBody'] => {\n\tconst hookNode = getHookNode(node, nodeName)\n\tif (!hookNode) {\n\t\treturn []\n\t}\n\tconst paramNode = hookNode.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\tconst valueNode = findNodeImplementation(paramNode.getLastChild()!)\n\n\tif (!valueNode.isKind(SyntaxKind.ObjectLiteralExpression)) {\n\t\tthrow new Error(`Non-literal type used in ${nodeName}`)\n\t}\n\n\tconst objectLiteral = valueNode.asKind(SyntaxKind.ObjectLiteralExpression)!\n\treturn getShapeOfValidatorLiteral(objectLiteral)\n\t\t.filter((param) => param.shape !== null)\n\t\t.map((param) => ({\n\t\t\tidentifier: param.identifier,\n\t\t\tsignature: param.shape as string,\n\t\t\toptional: param.optional,\n\t\t\tdescription: param.description,\n\t\t\terrorMessage: param.errorMessage,\n\t\t}))\n}\n\nconst parseRequestResponse = (node: Node<ts.Node>): EndpointData['responses'] => {\n\tconst implementationNode = node\n\t\t.getFirstChildByKind(SyntaxKind.CallExpression)!\n\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t.getFirstChildByKind(SyntaxKind.ArrowFunction)!\n\tconst returnType = implementationNode.getReturnType()\n\n\tconst actualType = (() => {\n\t\tif (returnType.getText().startsWith('Promise')) {\n\t\t\treturn returnType.getTypeArguments()[0]\n\t\t}\n\t\treturn returnType\n\t})()\n\n\tconst responseType = getProperTypeShape(actualType, node)\n\n\treturn parseResponseTypes(responseType)\n}\n\nconst parseResponseTypes = (\n\tresponseType: ReturnType<typeof getProperTypeShape>,\n): EndpointData['responses'] => {\n\t// TODO: Add support for response descriptions and errors\n\tif (typeof responseType === 'string') {\n\t\treturn [\n\t\t\t{\n\t\t\t\tstatus: responseType === 'void' || responseType === 'null' ? 204 : 200,\n\t\t\t\tcontentType: 'text/plain',\n\t\t\t\tsignature: responseType,\n\t\t\t\tdescription: '',\n\t\t\t\terrorMessage: '',\n\t\t\t},\n\t\t]\n\t}\n\n\tif (responseType[0].role === 'union_entry' || responseType[0].role === 'literal_string') {\n\t\treturn parseResponseTypes(responseType[0].shape)\n\t}\n\n\t// Response type is a useReturnValue hook\n\tif (responseType[0].role === 'property' && responseType[0].identifier === '_isUseReturnValue') {\n\t\tconst status = (() => {\n\t\t\tconst property = responseType.find(\n\t\t\t\t(response) => response.role === 'property' && response.identifier === 'status',\n\t\t\t)?.shape\n\t\t\tif (!property || typeof property === 'string' || typeof property[0].shape !== 'string') {\n\t\t\t\tthrow new Error('Invalid useReturnValue hook')\n\t\t\t}\n\t\t\treturn parseInt(property[0].shape)\n\t\t})()\n\t\tconst contentType = (() => {\n\t\t\tconst property = responseType.find(\n\t\t\t\t(response) => response.role === 'property' && response.identifier === 'contentType',\n\t\t\t)?.shape\n\t\t\tif (!property || typeof property === 'string' || typeof property[0].shape !== 'string') {\n\t\t\t\tthrow new Error('Invalid useReturnValue hook')\n\t\t\t}\n\t\t\treturn property[0].shape\n\t\t})()\n\t\treturn [\n\t\t\t{\n\t\t\t\tstatus,\n\t\t\t\tcontentType,\n\t\t\t\tsignature: responseType,\n\t\t\t\tdescription: '',\n\t\t\t\terrorMessage: '',\n\t\t\t},\n\t\t]\n\t}\n\n\tif (responseType[0].role === 'union') {\n\t\tif (typeof responseType[0].shape === 'string') {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tstatus: responseType[0].shape === 'void' || responseType[0].shape === 'null' ? 204 : 200,\n\t\t\t\t\tcontentType: 'application/json',\n\t\t\t\t\tsignature: responseType[0].shape,\n\t\t\t\t\tdescription: '',\n\t\t\t\t\terrorMessage: '',\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\n\t\treturn responseType[0].shape.flatMap((unionEntry) => {\n\t\t\treturn parseResponseTypes([unionEntry])\n\t\t})\n\t}\n\n\tif (responseType[0].role === 'buffer') {\n\t\treturn [\n\t\t\t{\n\t\t\t\tstatus: 200,\n\t\t\t\tcontentType: 'application/octet-stream',\n\t\t\t\tsignature: responseType,\n\t\t\t\tdescription: '',\n\t\t\t\terrorMessage: '',\n\t\t\t},\n\t\t]\n\t}\n\n\treturn [\n\t\t{\n\t\t\tstatus: 200,\n\t\t\tcontentType: 'application/json',\n\t\t\tsignature: responseType,\n\t\t\tdescription: '',\n\t\t\terrorMessage: '',\n\t\t},\n\t]\n}\n"],"names":["parseEndpoint","node","sourceFilePath","parsedEndpointMethod","SyntaxKind","endpointMethod","endpointText","endpointPath","endpointData","parseApiDocumentation","param","err","Logger","parseRequestParams","parseRequestObjectInput","parsedBody","parseRequestRawBody","parseRequestResponse","getHookNode","endpointNode","hookName","hookNode","paramNode","valueNode","findNodeImplementation","objectLiteral","getValuesOfObjectLiteral","declaredParams","segment","getShapeOfValidatorLiteral","declared","getValidatorPropertyShape","getValidatorPropertyOptionality","getValidatorPropertyStringValue","nodeName","returnType","actualType","responseType","getProperTypeShape","parseResponseTypes","status","property","response","contentType","unionEntry"],"mappings":";;;AAea,MAAAA,IAAgB,CAACC,GAAqBC,MAA2B;AAC7E,QAAMC,IAAuBF,EAC3B,yBAAyBG,EAAW,wBAAwB,EAC5D,QAAQ,EACR,MAAM,GAAG,EAAE,CAAC,EACZ,YAAY,GAERC,IAAiBF,MAAyB,QAAQ,WAAWA,GAE7DG,IAAeL,EAAK,yBAAyBG,EAAW,aAAa,EAAG,aAAa,IACrFG,IAAeD,EAAa,UAAU,GAAGA,EAAa,SAAS,CAAC,GAEhEE,IAA6B;AAAA,IAClC,QAAQH;AAAA,IACR,MAAME;AAAA,IACN,gBAAAL;AAAA,IACA,mBAAmB,CAAC;AAAA,IACpB,cAAc,CAAC;AAAA,IACf,gBAAgB,CAAC;AAAA,IACjB,SAAS;AAAA,IACT,YAAY,CAAC;AAAA,IACb,WAAW,CAAC;AAAA,IACZ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aA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AAa;AAAA,QACb,cAAc;AAAA,MAAA;AAAA,IAEhB;AAAA,EAAA;AAGD,SAAIA,EAAa,CAAC,EAAE,SAAS,UACxB,OAAOA,EAAa,CAAC,EAAE,SAAU,WAC7B;AAAA,IACN;AAAA,MACC,QAAQA,EAAa,CAAC,EAAE,UAAU,UAAUA,EAAa,CAAC,EAAE,UAAU,SAAS,MAAM;AAAA,MACrF,aAAa;AAAA,MACb,WAAWA,EAAa,CAAC,EAAE;AAAA,MAC3B,aAAa;AAAA,MACb,cAAc;AAAA,IAAA;AAAA,EAEhB,IAGMA,EAAa,CAAC,EAAE,MAAM,QAAQ,CAACO,MAC9BL,EAAmB,CAACK,CAAU,CAAC,CACtC,IAGEP,EAAa,CAAC,EAAE,SAAS,WACrB;AAAA,IACN;AAAA,MACC,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,WAAWA;AAAA,MACX,aAAa;AAAA,MACb,cAAc;AAAA,IAAA;AAAA,EAEhB,IAGM;AAAA,IACN;AAAA,MACC,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,WAAWA;AAAA,MACX,aAAa;AAAA,MACb,cAAc;AAAA,IAAA;AAAA,EAEhB;AACD;"}
|
|
1
|
+
{"version":3,"file":"parseEndpoint.mjs","sources":["../../../src/openapi/analyzerModule/parseEndpoint.ts"],"sourcesContent":["import { Node, SyntaxKind, ts } from 'ts-morph'\n\nimport { ApiEndpointDocs } from '../../hooks/useApiEndpoint'\nimport { Logger } from '../../utils/logger'\nimport { EndpointData } from '../types'\nimport {\n\tfindNodeImplementation,\n\tgetProperTypeShape,\n\tgetShapeOfValidatorLiteral,\n\tgetValidatorPropertyOptionality,\n\tgetValidatorPropertyShape,\n\tgetValidatorPropertyStringValue,\n\tgetValuesOfObjectLiteral,\n\tresolveEndpointPath,\n} from './nodeParsers'\n\nexport const parseEndpoint = (node: Node<ts.Node>, sourceFilePath: string) => {\n\tconst parsedEndpointMethod = node\n\t\t.getFirstDescendantByKind(SyntaxKind.PropertyAccessExpression)!\n\t\t.getText()\n\t\t.split('.')[1]\n\t\t.toUpperCase()\n\n\tconst endpointMethod = parsedEndpointMethod === 'DEL' ? 'DELETE' : parsedEndpointMethod\n\n\tconst endpointPath = resolveEndpointPath(node) ?? ''\n\n\tconst endpointData: EndpointData = {\n\t\tmethod: endpointMethod as 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',\n\t\tpath: endpointPath,\n\t\tsourceFilePath,\n\t\trequestPathParams: [],\n\t\trequestQuery: [],\n\t\trequestHeaders: [],\n\t\trawBody: undefined,\n\t\tobjectBody: [],\n\t\tresponses: [],\n\t\tname: undefined,\n\t\tsummary: undefined,\n\t\tdescription: undefined,\n\t\ttags: undefined,\n\t}\n\n\tconst warningData: {\n\t\tsegment: string\n\t\terror: Error\n\t}[] = []\n\n\t// API documentation\n\ttry {\n\t\tconst entries = parseApiDocumentation(node)\n\t\tentries.forEach((param) => {\n\t\t\tendpointData[param.identifier] = param.value as string & string[]\n\t\t})\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'api',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\t// Request params\n\ttry {\n\t\tendpointData.requestPathParams = parseRequestParams(node, endpointPath)\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'path',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\t// Request query\n\ttry {\n\t\tendpointData.requestQuery = parseRequestObjectInput(node, 'useQueryParams')\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'query',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\t// Request headers\n\ttry {\n\t\tendpointData.requestHeaders = parseRequestObjectInput(node, 'useHeaderParams')\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'headers',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\t// Raw request body\n\ttry {\n\t\tconst parsedBody = parseRequestRawBody(node)\n\t\tif (parsedBody) {\n\t\t\tendpointData.rawBody = parsedBody\n\t\t}\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'rawBody',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\t// Object request body\n\ttry {\n\t\tendpointData.objectBody = parseRequestObjectInput(node, 'useRequestBody')\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'objectBody',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\t// Request response\n\ttry {\n\t\tendpointData.responses = parseRequestResponse(node)\n\t} catch (err) {\n\t\twarningData.push({\n\t\t\tsegment: 'response',\n\t\t\terror: err as Error,\n\t\t})\n\t\tLogger.error('Error', err)\n\t}\n\n\treturn endpointData\n}\n\nconst getHookNode = (\n\tendpointNode: Node<ts.Node>,\n\thookName:\n\t\t| 'useApiEndpoint'\n\t\t| 'usePathParams'\n\t\t| 'useQueryParams'\n\t\t| 'useHeaderParams'\n\t\t| 'useRequestBody'\n\t\t| 'useRequestRawBody',\n) => {\n\tconst callExpressions = endpointNode.getDescendantsOfKind(SyntaxKind.CallExpression)\n\tconst matchingCallExpressions = callExpressions.filter((node) => {\n\t\treturn node.getFirstChildByKind(SyntaxKind.Identifier)?.getText() === hookName\n\t})\n\treturn matchingCallExpressions[0] ?? null\n}\n\nconst parseApiDocumentation = (node: Node<ts.Node>) => {\n\tconst hookNode = getHookNode(node, 'useApiEndpoint')\n\tif (!hookNode) {\n\t\treturn []\n\t}\n\tconst paramNode = hookNode.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\tconst valueNode = findNodeImplementation(paramNode.getLastChild()!)\n\n\tif (!valueNode.isKind(SyntaxKind.ObjectLiteralExpression)) {\n\t\tthrow new Error('Non-literal type used in useApiEndpoint')\n\t}\n\n\tconst objectLiteral = valueNode.asKind(SyntaxKind.ObjectLiteralExpression)!\n\n\tconst values = getValuesOfObjectLiteral(objectLiteral).filter((param) => param.value !== null)\n\treturn values as {\n\t\tidentifier: keyof ApiEndpointDocs\n\t\tvalue: (typeof values)[number]['value']\n\t}[]\n}\n\nconst parseRequestParams = (node: Node<ts.Node>, endpointPath: string): EndpointData['requestPathParams'] => {\n\tconst hookNode = getHookNode(node, 'usePathParams')\n\tif (!hookNode) {\n\t\treturn []\n\t}\n\n\tconst paramNode = hookNode.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\tconst valueNode = findNodeImplementation(paramNode.getLastChild()!)\n\n\tif (!valueNode.isKind(SyntaxKind.ObjectLiteralExpression)) {\n\t\tthrow new Error('Non-literal type used in usePathParams')\n\t}\n\n\tconst declaredParams = endpointPath\n\t\t.split('/')\n\t\t.filter((segment) => segment.startsWith(':'))\n\t\t.map((segment) => ({\n\t\t\tname: segment.substring(1).replace(/\\?/, ''),\n\t\t\toptional: segment.includes('?'),\n\t\t}))\n\n\tconst objectLiteral = valueNode.asKind(SyntaxKind.ObjectLiteralExpression)!\n\treturn getShapeOfValidatorLiteral(objectLiteral)\n\t\t.filter((param) => param.shape !== null)\n\t\t.map((param) => ({\n\t\t\tidentifier: param.identifier,\n\t\t\tsignature: param.shape as string,\n\t\t\toptional: declaredParams.some((declared) => declared.name === param.identifier && declared.optional),\n\t\t\tdescription: param.description,\n\t\t\terrorMessage: param.errorMessage,\n\t\t}))\n}\n\nconst parseRequestRawBody = (node: Node<ts.Node>): NonNullable<EndpointData['rawBody']> | null => {\n\tconst hookNode = getHookNode(node, 'useRequestRawBody')\n\tif (!hookNode) {\n\t\treturn null\n\t}\n\tconst paramNode = hookNode.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\tconst valueNode = findNodeImplementation(\n\t\tparamNode.getLastChild((node) => !node.isKind(SyntaxKind.CommaToken))!,\n\t)\n\n\treturn {\n\t\tsignature: getValidatorPropertyShape(valueNode),\n\t\toptional: getValidatorPropertyOptionality(valueNode),\n\t\tdescription: getValidatorPropertyStringValue(valueNode, 'description'),\n\t\terrorMessage: getValidatorPropertyStringValue(valueNode, 'errorMessage'),\n\t}\n}\n\nconst parseRequestObjectInput = (\n\tnode: Node<ts.Node>,\n\tnodeName: 'useQueryParams' | 'useHeaderParams' | 'useRequestBody',\n): EndpointData['requestQuery'] | EndpointData['objectBody'] => {\n\tconst hookNode = getHookNode(node, nodeName)\n\tif (!hookNode) {\n\t\treturn []\n\t}\n\tconst paramNode = hookNode.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\tconst valueNode = findNodeImplementation(paramNode.getLastChild()!)\n\n\tif (!valueNode.isKind(SyntaxKind.ObjectLiteralExpression)) {\n\t\tthrow new Error(`Non-literal type used in ${nodeName}`)\n\t}\n\n\tconst objectLiteral = valueNode.asKind(SyntaxKind.ObjectLiteralExpression)!\n\treturn getShapeOfValidatorLiteral(objectLiteral)\n\t\t.filter((param) => param.shape !== null)\n\t\t.map((param) => ({\n\t\t\tidentifier: param.identifier,\n\t\t\tsignature: param.shape as string,\n\t\t\toptional: param.optional,\n\t\t\tdescription: param.description,\n\t\t\terrorMessage: param.errorMessage,\n\t\t}))\n}\n\nconst parseRequestResponse = (node: Node<ts.Node>): EndpointData['responses'] => {\n\tconst implementationNode = node\n\t\t.getFirstChildByKind(SyntaxKind.CallExpression)!\n\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t.getFirstChildByKind(SyntaxKind.ArrowFunction)!\n\tconst returnType = implementationNode.getReturnType()\n\n\tconst actualType = (() => {\n\t\tif (returnType.getText().startsWith('Promise')) {\n\t\t\treturn returnType.getTypeArguments()[0]\n\t\t}\n\t\treturn returnType\n\t})()\n\n\tconst responseType = getProperTypeShape(actualType, node)\n\n\treturn parseResponseTypes(responseType)\n}\n\nconst parseResponseTypes = (\n\tresponseType: ReturnType<typeof getProperTypeShape>,\n): EndpointData['responses'] => {\n\t// TODO: Add support for response descriptions and errors\n\tif (typeof responseType === 'string') {\n\t\treturn [\n\t\t\t{\n\t\t\t\tstatus: responseType === 'void' || responseType === 'null' ? 204 : 200,\n\t\t\t\tcontentType: 'text/plain',\n\t\t\t\tsignature: responseType,\n\t\t\t\tdescription: '',\n\t\t\t\terrorMessage: '',\n\t\t\t},\n\t\t]\n\t}\n\n\tif (responseType[0].role === 'union_entry' || responseType[0].role === 'literal_string') {\n\t\treturn parseResponseTypes(responseType[0].shape)\n\t}\n\n\t// Response type is a useReturnValue hook\n\tif (responseType[0].role === 'property' && responseType[0].identifier === '_isUseReturnValue') {\n\t\tconst status = (() => {\n\t\t\tconst property = responseType.find(\n\t\t\t\t(response) => response.role === 'property' && response.identifier === 'status',\n\t\t\t)?.shape\n\t\t\tif (!property || typeof property === 'string' || typeof property[0].shape !== 'string') {\n\t\t\t\tthrow new Error('Invalid useReturnValue hook')\n\t\t\t}\n\t\t\treturn parseInt(property[0].shape)\n\t\t})()\n\t\tconst contentType = (() => {\n\t\t\tconst property = responseType.find(\n\t\t\t\t(response) => response.role === 'property' && response.identifier === 'contentType',\n\t\t\t)?.shape\n\t\t\tif (!property || typeof property === 'string' || typeof property[0].shape !== 'string') {\n\t\t\t\tthrow new Error('Invalid useReturnValue hook')\n\t\t\t}\n\t\t\treturn property[0].shape\n\t\t})()\n\t\treturn [\n\t\t\t{\n\t\t\t\tstatus,\n\t\t\t\tcontentType,\n\t\t\t\tsignature: responseType,\n\t\t\t\tdescription: '',\n\t\t\t\terrorMessage: '',\n\t\t\t},\n\t\t]\n\t}\n\n\tif (responseType[0].role === 'union') {\n\t\tif (typeof responseType[0].shape === 'string') {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tstatus: responseType[0].shape === 'void' || responseType[0].shape === 'null' ? 204 : 200,\n\t\t\t\t\tcontentType: 'application/json',\n\t\t\t\t\tsignature: responseType[0].shape,\n\t\t\t\t\tdescription: '',\n\t\t\t\t\terrorMessage: '',\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\n\t\treturn responseType[0].shape.flatMap((unionEntry) => {\n\t\t\treturn parseResponseTypes([unionEntry])\n\t\t})\n\t}\n\n\tif (responseType[0].role === 'buffer') {\n\t\treturn [\n\t\t\t{\n\t\t\t\tstatus: 200,\n\t\t\t\tcontentType: 'application/octet-stream',\n\t\t\t\tsignature: responseType,\n\t\t\t\tdescription: '',\n\t\t\t\terrorMessage: '',\n\t\t\t},\n\t\t]\n\t}\n\n\treturn [\n\t\t{\n\t\t\tstatus: 200,\n\t\t\tcontentType: 'application/json',\n\t\t\tsignature: responseType,\n\t\t\tdescription: '',\n\t\t\terrorMessage: '',\n\t\t},\n\t]\n}\n"],"names":["parseEndpoint","node","sourceFilePath","parsedEndpointMethod","SyntaxKind","endpointMethod","endpointPath","resolveEndpointPath","endpointData","parseApiDocumentation","param","err","Logger","parseRequestParams","parseRequestObjectInput","parsedBody","parseRequestRawBody","parseRequestResponse","getHookNode","endpointNode","hookName","hookNode","paramNode","valueNode","findNodeImplementation","objectLiteral","getValuesOfObjectLiteral","declaredParams","segment","getShapeOfValidatorLiteral","declared","getValidatorPropertyShape","getValidatorPropertyOptionality","getValidatorPropertyStringValue","nodeName","returnType","actualType","responseType","getProperTypeShape","parseResponseTypes","status","property","response","contentType","unionEntry"],"mappings":";;;AAgBa,MAAAA,IAAgB,CAACC,GAAqBC,MAA2B;AAC7E,QAAMC,IAAuBF,EAC3B,yBAAyBG,EAAW,wBAAwB,EAC5D,QAAQ,EACR,MAAM,GAAG,EAAE,CAAC,EACZ,YAAY,GAERC,IAAiBF,MAAyB,QAAQ,WAAWA,GAE7DG,IAAeC,EAAoBN,CAAI,KAAK,IAE5CO,IAA6B;AAAA,IAClC,QAAQH;AAAA,IACR,MAAMC;AAAA,IACN,gBAAAJ;AAAA,IACA,mBAAmB,CAAC;AAAA,IACpB,cAAc,CAAC;AAAA,IACf,gBAAgB,CAAC;AAAA,IACjB,SAAS;AAAA,IACT,YAAY,CAAC;AAAA,IACb,WAAW,CAAC;AAAA,IACZ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM;AA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AAA,MAAA;AAAA,IAEhB;AAAA,EAAA;AAGD,SAAIA,EAAa,CAAC,EAAE,SAAS,UACxB,OAAOA,EAAa,CAAC,EAAE,SAAU,WAC7B;AAAA,IACN;AAAA,MACC,QAAQA,EAAa,CAAC,EAAE,UAAU,UAAUA,EAAa,CAAC,EAAE,UAAU,SAAS,MAAM;AAAA,MACrF,aAAa;AAAA,MACb,WAAWA,EAAa,CAAC,EAAE;AAAA,MAC3B,aAAa;AAAA,MACb,cAAc;AAAA,IAAA;AAAA,EAEhB,IAGMA,EAAa,CAAC,EAAE,MAAM,QAAQ,CAACO,MAC9BL,EAAmB,CAACK,CAAU,CAAC,CACtC,IAGEP,EAAa,CAAC,EAAE,SAAS,WACrB;AAAA,IACN;AAAA,MACC,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,WAAWA;AAAA,MACX,aAAa;AAAA,MACb,cAAc;AAAA,IAAA;AAAA,EAEhB,IAGM;AAAA,IACN;AAAA,MACC,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,WAAWA;AAAA,MACX,aAAa;AAAA,MACb,cAAc;AAAA,IAAA;AAAA,EAEhB;AACD;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const TestCase: {
|
|
2
|
+
readonly parsesInlineZodNumber: "parses-inline-zod-number";
|
|
3
|
+
readonly parsesInlineZodString: "parses-inline-zod-string";
|
|
4
|
+
readonly parsesInlineZodObject: "parses-inline-zod-object";
|
|
5
|
+
readonly parsesInlineZodNumberArray: "parses-inline-zod-number-array";
|
|
6
|
+
readonly parsesInlineZodObjectArray: "parses-inline-zod-object-array";
|
|
7
|
+
readonly parsedAliasedZodSchema: "parses-aliased-zod-schema";
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=TestCase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestCase.d.ts","sourceRoot":"","sources":["../../../../src/openapi/analyzerModule/test/TestCase.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;;;;;CAOX,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openApiAnalyzer.zod.spec.d.ts","sourceRoot":"","sources":["../../../../src/openapi/analyzerModule/test/openApiAnalyzer.zod.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openApiAnalyzer.zod.spec.data.d.ts","sourceRoot":"","sources":["../../../../src/openapi/analyzerModule/test/openApiAnalyzer.zod.spec.data.ts"],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("fs"),a=require("./manager/OpenApiManager.cjs"),i=require("./router/OpenApiRouter.cjs");function u(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const l=u(c),p=e=>{const t="specPath"in e?d(e.specPath):Promise.resolve().then(()=>require("./analyzerModule/analyzerModule.cjs")).then(({prepareOpenApiSpec:o})=>o(e)),n=i.OpenApiRouter.routes(),r=i.OpenApiRouter.allowedMethods();return async(o,s)=>(await t,n(o,()=>r(o,s)))},d=e=>{const t=a.OpenApiManager.getInstance();if(t.isReady())return;const n=l.readFileSync(e,"utf-8"),r=JSON.parse(n);t.setPrebuiltSpec(r),t.markAsReady()};exports.initOpenApiEngine=p;
|
|
2
2
|
//# sourceMappingURL=initOpenApiEngine.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initOpenApiEngine.cjs","sources":["../../src/openapi/initOpenApiEngine.ts"],"sourcesContent":["import Koa from 'koa'\n\nimport
|
|
1
|
+
{"version":3,"file":"initOpenApiEngine.cjs","sources":["../../src/openapi/initOpenApiEngine.ts"],"sourcesContent":["import * as fs from 'fs'\nimport Koa from 'koa'\n\nimport type * as AnalyzerModule from './analyzerModule/analyzerModule'\nimport { OpenApiManager } from './manager/OpenApiManager'\nimport { OpenApiRouter } from './router/OpenApiRouter'\n\ntype AnalyzerProps = Parameters<typeof AnalyzerModule.prepareOpenApiSpec>[0]\n\ntype PrebuiltSpecProps = {\n\t/**\n\t * Path to a pre-built OpenAPI spec JSON file.\n\t * When provided, the analyzer is skipped entirely and the spec is served from this file.\n\t * Use this in production to avoid running the TypeScript analyzer on startup.\n\t *\n\t * Generate the spec file at build time using the CLI:\n\t * ```\n\t * moonflower openapi ./openapi-spec.json\n\t * ```\n\t */\n\tspecPath: string\n}\n\n/**\n * Middleware to initialize the openApi engine.\n * Can be at any position in the middleware execution order.\n *\n * In development, pass analyzer options to generate the spec on startup:\n * ```\n * initOpenApiEngine({ tsconfigPath: 'tsconfig.json', sourceFileDiscovery: true })\n * ```\n *\n * In production, pass a pre-built spec file to skip analysis:\n * ```\n * initOpenApiEngine({ specPath: './openapi-spec.json' })\n * ```\n */\nexport const initOpenApiEngine = (props: AnalyzerProps | PrebuiltSpecProps) => {\n\tconst ready =\n\t\t'specPath' in props\n\t\t\t? loadPrebuiltSpec(props.specPath)\n\t\t\t: import('./analyzerModule/analyzerModule').then(({ prepareOpenApiSpec }) => prepareOpenApiSpec(props))\n\n\tconst builtInRoutes = OpenApiRouter.routes()\n\tconst builtInAllowedMethods = OpenApiRouter.allowedMethods()\n\treturn async (ctx: Koa.ParameterizedContext<any, any>, next: Koa.Next) => {\n\t\tawait ready\n\t\treturn builtInRoutes(ctx, () => builtInAllowedMethods(ctx, next))\n\t}\n}\n\nconst loadPrebuiltSpec = (specPath: string) => {\n\tconst manager = OpenApiManager.getInstance()\n\tif (manager.isReady()) {\n\t\treturn\n\t}\n\n\tconst content = fs.readFileSync(specPath, 'utf-8')\n\tconst spec = JSON.parse(content)\n\tmanager.setPrebuiltSpec(spec)\n\tmanager.markAsReady()\n}\n"],"names":["initOpenApiEngine","props","ready","loadPrebuiltSpec","prepareOpenApiSpec","builtInRoutes","OpenApiRouter","builtInAllowedMethods","ctx","next","specPath","manager","OpenApiManager","content","fs","spec"],"mappings":"kdAqCaA,EAAqBC,GAA6C,CAC9E,MAAMC,EACL,aAAcD,EACXE,EAAiBF,EAAM,QAAQ,EAC/B,QAAO,QAAA,EAAA,KAAA,IAAA,QAAA,qCAAiC,CAAA,EAAE,KAAK,CAAC,CAAE,mBAAAG,KAAyBA,EAAmBH,CAAK,CAAC,EAElGI,EAAgBC,gBAAc,OAAO,EACrCC,EAAwBD,gBAAc,eAAe,EACpD,MAAA,OAAOE,EAAyCC,KAChD,MAAAP,EACCG,EAAcG,EAAK,IAAMD,EAAsBC,EAAKC,CAAI,CAAC,EAElE,EAEMN,EAAoBO,GAAqB,CACxC,MAAAC,EAAUC,iBAAe,YAAY,EACvC,GAAAD,EAAQ,UACX,OAGD,MAAME,EAAUC,EAAG,aAAaJ,EAAU,OAAO,EAC3CK,EAAO,KAAK,MAAMF,CAAO,EAC/BF,EAAQ,gBAAgBI,CAAI,EAC5BJ,EAAQ,YAAY,CACrB"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { default as Koa } from 'koa';
|
|
2
|
-
import { prepareOpenApiSpec } from './analyzerModule/analyzerModule';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import type * as AnalyzerModule from './analyzerModule/analyzerModule';
|
|
4
|
+
type AnalyzerProps = Parameters<typeof AnalyzerModule.prepareOpenApiSpec>[0];
|
|
5
|
+
type PrebuiltSpecProps = {
|
|
6
|
+
specPath: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const initOpenApiEngine: (props: AnalyzerProps | PrebuiltSpecProps) => (ctx: Koa.ParameterizedContext<any, any>, next: Koa.Next) => Promise<any>;
|
|
9
|
+
export {};
|
|
5
10
|
//# sourceMappingURL=initOpenApiEngine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initOpenApiEngine.d.ts","sourceRoot":"","sources":["../../src/openapi/initOpenApiEngine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initOpenApiEngine.d.ts","sourceRoot":"","sources":["../../src/openapi/initOpenApiEngine.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,OAAO,KAAK,KAAK,cAAc,MAAM,iCAAiC,CAAA;AAItE,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAA;AAE5E,KAAK,iBAAiB,GAAG;IAWxB,QAAQ,EAAE,MAAM,CAAA;CAChB,CAAA;AAgBD,eAAO,MAAM,iBAAiB,UAAW,aAAa,GAAG,iBAAiB,WAQtD,GAAG,CAAC,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,GAAG,CAAC,IAAI,iBAIrE,CAAA"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const n =
|
|
6
|
-
return (
|
|
1
|
+
import * as i from "fs";
|
|
2
|
+
import { OpenApiManager as c } from "./manager/OpenApiManager.mjs";
|
|
3
|
+
import { OpenApiRouter as s } from "./router/OpenApiRouter.mjs";
|
|
4
|
+
const d = (e) => {
|
|
5
|
+
const t = "specPath" in e ? p(e.specPath) : import("./analyzerModule/analyzerModule.mjs").then(({ prepareOpenApiSpec: n }) => n(e)), o = s.routes(), r = s.allowedMethods();
|
|
6
|
+
return async (n, a) => (await t, o(n, () => r(n, a)));
|
|
7
|
+
}, p = (e) => {
|
|
8
|
+
const t = c.getInstance();
|
|
9
|
+
if (t.isReady())
|
|
10
|
+
return;
|
|
11
|
+
const o = i.readFileSync(e, "utf-8"), r = JSON.parse(o);
|
|
12
|
+
t.setPrebuiltSpec(r), t.markAsReady();
|
|
7
13
|
};
|
|
8
14
|
export {
|
|
9
|
-
|
|
15
|
+
d as initOpenApiEngine
|
|
10
16
|
};
|
|
11
17
|
//# sourceMappingURL=initOpenApiEngine.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initOpenApiEngine.mjs","sources":["../../src/openapi/initOpenApiEngine.ts"],"sourcesContent":["import Koa from 'koa'\n\nimport
|
|
1
|
+
{"version":3,"file":"initOpenApiEngine.mjs","sources":["../../src/openapi/initOpenApiEngine.ts"],"sourcesContent":["import * as fs from 'fs'\nimport Koa from 'koa'\n\nimport type * as AnalyzerModule from './analyzerModule/analyzerModule'\nimport { OpenApiManager } from './manager/OpenApiManager'\nimport { OpenApiRouter } from './router/OpenApiRouter'\n\ntype AnalyzerProps = Parameters<typeof AnalyzerModule.prepareOpenApiSpec>[0]\n\ntype PrebuiltSpecProps = {\n\t/**\n\t * Path to a pre-built OpenAPI spec JSON file.\n\t * When provided, the analyzer is skipped entirely and the spec is served from this file.\n\t * Use this in production to avoid running the TypeScript analyzer on startup.\n\t *\n\t * Generate the spec file at build time using the CLI:\n\t * ```\n\t * moonflower openapi ./openapi-spec.json\n\t * ```\n\t */\n\tspecPath: string\n}\n\n/**\n * Middleware to initialize the openApi engine.\n * Can be at any position in the middleware execution order.\n *\n * In development, pass analyzer options to generate the spec on startup:\n * ```\n * initOpenApiEngine({ tsconfigPath: 'tsconfig.json', sourceFileDiscovery: true })\n * ```\n *\n * In production, pass a pre-built spec file to skip analysis:\n * ```\n * initOpenApiEngine({ specPath: './openapi-spec.json' })\n * ```\n */\nexport const initOpenApiEngine = (props: AnalyzerProps | PrebuiltSpecProps) => {\n\tconst ready =\n\t\t'specPath' in props\n\t\t\t? loadPrebuiltSpec(props.specPath)\n\t\t\t: import('./analyzerModule/analyzerModule').then(({ prepareOpenApiSpec }) => prepareOpenApiSpec(props))\n\n\tconst builtInRoutes = OpenApiRouter.routes()\n\tconst builtInAllowedMethods = OpenApiRouter.allowedMethods()\n\treturn async (ctx: Koa.ParameterizedContext<any, any>, next: Koa.Next) => {\n\t\tawait ready\n\t\treturn builtInRoutes(ctx, () => builtInAllowedMethods(ctx, next))\n\t}\n}\n\nconst loadPrebuiltSpec = (specPath: string) => {\n\tconst manager = OpenApiManager.getInstance()\n\tif (manager.isReady()) {\n\t\treturn\n\t}\n\n\tconst content = fs.readFileSync(specPath, 'utf-8')\n\tconst spec = JSON.parse(content)\n\tmanager.setPrebuiltSpec(spec)\n\tmanager.markAsReady()\n}\n"],"names":["initOpenApiEngine","props","ready","loadPrebuiltSpec","prepareOpenApiSpec","builtInRoutes","OpenApiRouter","builtInAllowedMethods","ctx","next","specPath","manager","OpenApiManager","content","fs","spec"],"mappings":";;;AAqCa,MAAAA,IAAoB,CAACC,MAA6C;AAC9E,QAAMC,IACL,cAAcD,IACXE,EAAiBF,EAAM,QAAQ,IAC/B,OAAO,qCAAiC,EAAE,KAAK,CAAC,EAAE,oBAAAG,QAAyBA,EAAmBH,CAAK,CAAC,GAElGI,IAAgBC,EAAc,OAAO,GACrCC,IAAwBD,EAAc,eAAe;AACpD,SAAA,OAAOE,GAAyCC,OAChD,MAAAP,GACCG,EAAcG,GAAK,MAAMD,EAAsBC,GAAKC,CAAI,CAAC;AAElE,GAEMN,IAAmB,CAACO,MAAqB;AACxC,QAAAC,IAAUC,EAAe,YAAY;AACvC,MAAAD,EAAQ;AACX;AAGD,QAAME,IAAUC,EAAG,aAAaJ,GAAU,OAAO,GAC3CK,IAAO,KAAK,MAAMF,CAAO;AAC/B,EAAAF,EAAQ,gBAAgBI,CAAI,GAC5BJ,EAAQ,YAAY;AACrB;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class t{constructor(e,s,i,r,n){this.apiDocsHeader=e,this.exposedModels=s,this.endpoints=i,this.preferences=r,this.stats=n,this.isInitialized=!1,this.registeredRouters=[]}static{this.instance=null}isReady(){return this.isInitialized}hasExposedModel(e){return this.exposedModels.some(s=>s.name===e)}getExposedModels(){return this.exposedModels}setExposedModels(e){return this.exposedModels=e,this}setEndpoints(e){return this.endpoints=e,this}markAsReady(){return this.isInitialized=!0,this}getHeader(){return this.apiDocsHeader}setHeader(e){return this.apiDocsHeader=e,this}getEndpoints(){return this.endpoints}getPreferences(){return this.preferences}setPreferences(e){return this.preferences={...e},this}getStats(){return this.stats}setStats(e){return this.stats={...e},this}getRouters(){return this.registeredRouters}registerRouters(e){return e.forEach(s=>this.registeredRouters.push(s)),this}reset(){this.exposedModels=[],this.endpoints=[]}static getInstance(){return t.instance||(t.instance=new t({title:"Default title",version:"1.0.0"},[],[],{allowOptionalPathParams:!1},{discoveredRouterFiles:[],explicitRouterFiles:[]})),t.instance}}exports.OpenApiManager=t;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class t{constructor(e,s,i,r,n){this.apiDocsHeader=e,this.exposedModels=s,this.endpoints=i,this.preferences=r,this.stats=n,this.isInitialized=!1,this.registeredRouters=[],this.prebuiltSpec=null}static{this.instance=null}isReady(){return this.isInitialized}hasExposedModel(e){return this.exposedModels.some(s=>s.name===e)}getExposedModels(){return this.exposedModels}setExposedModels(e){return this.exposedModels=e,this}setEndpoints(e){return this.endpoints=e,this}markAsReady(){return this.isInitialized=!0,this}getHeader(){return this.apiDocsHeader}setHeader(e){return this.apiDocsHeader=e,this}getEndpoints(){return this.endpoints}getPreferences(){return this.preferences}setPreferences(e){return this.preferences={...e},this}getStats(){return this.stats}setStats(e){return this.stats={...e},this}getRouters(){return this.registeredRouters}registerRouters(e){return e.forEach(s=>this.registeredRouters.push(s)),this}getPrebuiltSpec(){return this.prebuiltSpec}setPrebuiltSpec(e){return this.prebuiltSpec=e,this}clearPrebuiltSpec(){return this.prebuiltSpec=null,this}reset(){this.exposedModels=[],this.endpoints=[],this.prebuiltSpec=null}static getInstance(){return t.instance||(t.instance=new t({title:"Default title",version:"1.0.0"},[],[],{allowOptionalPathParams:!1},{discoveredRouterFiles:[],explicitRouterFiles:[]})),t.instance}}exports.OpenApiManager=t;
|
|
2
2
|
//# sourceMappingURL=OpenApiManager.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiManager.cjs","sources":["../../../src/openapi/manager/OpenApiManager.ts"],"sourcesContent":["import { Router } from '../../router/Router'\nimport { EndpointData, ExposedModelData } from '../types'\n\ntype UrlType = `${'http' | 'https'}://${string}.${string}`\n\nexport type ApiDocsHeader = {\n\ttitle: string\n\tversion: string\n\tdescription?: string\n\ttermsOfService?: UrlType\n\tcontact?: {\n\t\tname?: string\n\t\turl?: UrlType\n\t\temail?: string\n\t}\n\tlicense?: {\n\t\tname?: string\n\t\turl?: UrlType\n\t}\n}\n\nexport type ApiDocsPreferences = {\n\tallowOptionalPathParams: boolean\n}\n\nexport type ApiAnalysisStats = {\n\texplicitRouterFiles: {\n\t\tpath: string\n\t\trouters: {\n\t\t\tname: string\n\t\t\tendpoints: string[]\n\t\t}[]\n\t}[]\n\tdiscoveredRouterFiles: {\n\t\tpath: string\n\t\trouters: {\n\t\t\tname: string\n\t\t\tendpoints: string[]\n\t\t}[]\n\t}[]\n}\n\nexport class OpenApiManager {\n\tprivate static instance: OpenApiManager | null = null\n\n\tprivate isInitialized = false\n\tprivate registeredRouters: Router[] = []\n\n\tconstructor(\n\t\tprivate apiDocsHeader: ApiDocsHeader,\n\t\tprivate exposedModels: ExposedModelData[],\n\t\tprivate endpoints: EndpointData[],\n\t\tprivate preferences: ApiDocsPreferences,\n\t\tprivate stats: ApiAnalysisStats,\n\t) {}\n\n\tpublic isReady(): boolean {\n\t\treturn this.isInitialized\n\t}\n\n\tpublic hasExposedModel(name: string) {\n\t\treturn this.exposedModels.some((model) => model.name === name)\n\t}\n\n\tpublic getExposedModels() {\n\t\treturn this.exposedModels\n\t}\n\n\tpublic setExposedModels(models: ExposedModelData[]) {\n\t\tthis.exposedModels = models\n\t\treturn this\n\t}\n\n\tpublic setEndpoints(endpoints: EndpointData[]) {\n\t\tthis.endpoints = endpoints\n\t\treturn this\n\t}\n\n\tpublic markAsReady() {\n\t\tthis.isInitialized = true\n\t\treturn this\n\t}\n\n\tpublic getHeader(): ApiDocsHeader {\n\t\treturn this.apiDocsHeader\n\t}\n\n\tpublic setHeader(docs: ApiDocsHeader) {\n\t\tthis.apiDocsHeader = docs\n\t\treturn this\n\t}\n\n\tpublic getEndpoints() {\n\t\treturn this.endpoints\n\t}\n\n\tpublic getPreferences() {\n\t\treturn this.preferences\n\t}\n\n\tpublic setPreferences(preferences: ApiDocsPreferences) {\n\t\tthis.preferences = {\n\t\t\t...preferences,\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getStats() {\n\t\treturn this.stats\n\t}\n\n\tpublic setStats(stats: ApiAnalysisStats) {\n\t\tthis.stats = {\n\t\t\t...stats,\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getRouters(): readonly Router[] {\n\t\treturn this.registeredRouters\n\t}\n\n\tpublic registerRouters(routers: Router<any, any>[]) {\n\t\trouters.forEach((r) => this.registeredRouters.push(r))\n\t\treturn this\n\t}\n\n\tpublic reset() {\n\t\tthis.exposedModels = []\n\t\tthis.endpoints = []\n\t}\n\n\tpublic static getInstance() {\n\t\tif (!OpenApiManager.instance) {\n\t\t\tOpenApiManager.instance = new OpenApiManager(\n\t\t\t\t{\n\t\t\t\t\ttitle: 'Default title',\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t\t[],\n\t\t\t\t{\n\t\t\t\t\tallowOptionalPathParams: false,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdiscoveredRouterFiles: [],\n\t\t\t\t\texplicitRouterFiles: [],\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn OpenApiManager.instance\n\t}\n}\n"],"names":["OpenApiManager","apiDocsHeader","exposedModels","endpoints","preferences","stats","name","model","models","docs","routers","r"],"mappings":"gFA0CO,MAAMA,CAAe,
|
|
1
|
+
{"version":3,"file":"OpenApiManager.cjs","sources":["../../../src/openapi/manager/OpenApiManager.ts"],"sourcesContent":["import { Router } from '../../router/Router'\nimport { EndpointData, ExposedModelData } from '../types'\n\ntype UrlType = `${'http' | 'https'}://${string}.${string}`\n\nexport type ApiDocsHeader = {\n\ttitle: string\n\tversion: string\n\tdescription?: string\n\ttermsOfService?: UrlType\n\tcontact?: {\n\t\tname?: string\n\t\turl?: UrlType\n\t\temail?: string\n\t}\n\tlicense?: {\n\t\tname?: string\n\t\turl?: UrlType\n\t}\n}\n\nexport type ApiDocsPreferences = {\n\tallowOptionalPathParams: boolean\n}\n\nexport type ApiAnalysisStats = {\n\texplicitRouterFiles: {\n\t\tpath: string\n\t\trouters: {\n\t\t\tname: string\n\t\t\tendpoints: string[]\n\t\t}[]\n\t}[]\n\tdiscoveredRouterFiles: {\n\t\tpath: string\n\t\trouters: {\n\t\t\tname: string\n\t\t\tendpoints: string[]\n\t\t}[]\n\t}[]\n}\n\nexport class OpenApiManager {\n\tprivate static instance: OpenApiManager | null = null\n\n\tprivate isInitialized = false\n\tprivate registeredRouters: Router[] = []\n\tprivate prebuiltSpec: Record<string, unknown> | null = null\n\n\tconstructor(\n\t\tprivate apiDocsHeader: ApiDocsHeader,\n\t\tprivate exposedModels: ExposedModelData[],\n\t\tprivate endpoints: EndpointData[],\n\t\tprivate preferences: ApiDocsPreferences,\n\t\tprivate stats: ApiAnalysisStats,\n\t) {}\n\n\tpublic isReady(): boolean {\n\t\treturn this.isInitialized\n\t}\n\n\tpublic hasExposedModel(name: string) {\n\t\treturn this.exposedModels.some((model) => model.name === name)\n\t}\n\n\tpublic getExposedModels() {\n\t\treturn this.exposedModels\n\t}\n\n\tpublic setExposedModels(models: ExposedModelData[]) {\n\t\tthis.exposedModels = models\n\t\treturn this\n\t}\n\n\tpublic setEndpoints(endpoints: EndpointData[]) {\n\t\tthis.endpoints = endpoints\n\t\treturn this\n\t}\n\n\tpublic markAsReady() {\n\t\tthis.isInitialized = true\n\t\treturn this\n\t}\n\n\tpublic getHeader(): ApiDocsHeader {\n\t\treturn this.apiDocsHeader\n\t}\n\n\tpublic setHeader(docs: ApiDocsHeader) {\n\t\tthis.apiDocsHeader = docs\n\t\treturn this\n\t}\n\n\tpublic getEndpoints() {\n\t\treturn this.endpoints\n\t}\n\n\tpublic getPreferences() {\n\t\treturn this.preferences\n\t}\n\n\tpublic setPreferences(preferences: ApiDocsPreferences) {\n\t\tthis.preferences = {\n\t\t\t...preferences,\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getStats() {\n\t\treturn this.stats\n\t}\n\n\tpublic setStats(stats: ApiAnalysisStats) {\n\t\tthis.stats = {\n\t\t\t...stats,\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getRouters(): readonly Router[] {\n\t\treturn this.registeredRouters\n\t}\n\n\tpublic registerRouters(routers: Router<any, any>[]) {\n\t\trouters.forEach((r) => this.registeredRouters.push(r))\n\t\treturn this\n\t}\n\n\tpublic getPrebuiltSpec(): Record<string, unknown> | null {\n\t\treturn this.prebuiltSpec\n\t}\n\n\tpublic setPrebuiltSpec(spec: Record<string, unknown>) {\n\t\tthis.prebuiltSpec = spec\n\t\treturn this\n\t}\n\n\tpublic clearPrebuiltSpec() {\n\t\tthis.prebuiltSpec = null\n\t\treturn this\n\t}\n\n\tpublic reset() {\n\t\tthis.exposedModels = []\n\t\tthis.endpoints = []\n\t\tthis.prebuiltSpec = null\n\t}\n\n\tpublic static getInstance() {\n\t\tif (!OpenApiManager.instance) {\n\t\t\tOpenApiManager.instance = new OpenApiManager(\n\t\t\t\t{\n\t\t\t\t\ttitle: 'Default title',\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t\t[],\n\t\t\t\t{\n\t\t\t\t\tallowOptionalPathParams: false,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdiscoveredRouterFiles: [],\n\t\t\t\t\texplicitRouterFiles: [],\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn OpenApiManager.instance\n\t}\n}\n"],"names":["OpenApiManager","apiDocsHeader","exposedModels","endpoints","preferences","stats","name","model","models","docs","routers","r","spec"],"mappings":"gFA0CO,MAAMA,CAAe,CAO3B,YACSC,EACAC,EACAC,EACAC,EACAC,EACP,CALO,KAAA,cAAAJ,EACA,KAAA,cAAAC,EACA,KAAA,UAAAC,EACA,KAAA,YAAAC,EACA,KAAA,MAAAC,EATT,KAAQ,cAAgB,GACxB,KAAQ,kBAA8B,CAAC,EACvC,KAAQ,aAA+C,IAAA,CAJvD,MAAA,CAAA,KAAe,SAAkC,IAAA,CAc1C,SAAmB,CACzB,OAAO,KAAK,aAAA,CAGN,gBAAgBC,EAAc,CACpC,OAAO,KAAK,cAAc,KAAMC,GAAUA,EAAM,OAASD,CAAI,CAAA,CAGvD,kBAAmB,CACzB,OAAO,KAAK,aAAA,CAGN,iBAAiBE,EAA4B,CACnD,YAAK,cAAgBA,EACd,IAAA,CAGD,aAAaL,EAA2B,CAC9C,YAAK,UAAYA,EACV,IAAA,CAGD,aAAc,CACpB,YAAK,cAAgB,GACd,IAAA,CAGD,WAA2B,CACjC,OAAO,KAAK,aAAA,CAGN,UAAUM,EAAqB,CACrC,YAAK,cAAgBA,EACd,IAAA,CAGD,cAAe,CACrB,OAAO,KAAK,SAAA,CAGN,gBAAiB,CACvB,OAAO,KAAK,WAAA,CAGN,eAAeL,EAAiC,CACtD,YAAK,YAAc,CAClB,GAAGA,CACJ,EACO,IAAA,CAGD,UAAW,CACjB,OAAO,KAAK,KAAA,CAGN,SAASC,EAAyB,CACxC,YAAK,MAAQ,CACZ,GAAGA,CACJ,EACO,IAAA,CAGD,YAAgC,CACtC,OAAO,KAAK,iBAAA,CAGN,gBAAgBK,EAA6B,CACnD,OAAAA,EAAQ,QAASC,GAAM,KAAK,kBAAkB,KAAKA,CAAC,CAAC,EAC9C,IAAA,CAGD,iBAAkD,CACxD,OAAO,KAAK,YAAA,CAGN,gBAAgBC,EAA+B,CACrD,YAAK,aAAeA,EACb,IAAA,CAGD,mBAAoB,CAC1B,YAAK,aAAe,KACb,IAAA,CAGD,OAAQ,CACd,KAAK,cAAgB,CAAC,EACtB,KAAK,UAAY,CAAC,EAClB,KAAK,aAAe,IAAA,CAGrB,OAAc,aAAc,CACvB,OAACZ,EAAe,WACnBA,EAAe,SAAW,IAAIA,EAC7B,CACC,MAAO,gBACP,QAAS,OACV,EACA,CAAC,EACD,CAAC,EACD,CACC,wBAAyB,EAC1B,EACA,CACC,sBAAuB,CAAC,EACxB,oBAAqB,CAAA,CAAC,CAExB,GAEMA,EAAe,QAAA,CAExB"}
|
|
@@ -45,6 +45,7 @@ export declare class OpenApiManager {
|
|
|
45
45
|
private static instance;
|
|
46
46
|
private isInitialized;
|
|
47
47
|
private registeredRouters;
|
|
48
|
+
private prebuiltSpec;
|
|
48
49
|
constructor(apiDocsHeader: ApiDocsHeader, exposedModels: ExposedModelData[], endpoints: EndpointData[], preferences: ApiDocsPreferences, stats: ApiAnalysisStats);
|
|
49
50
|
isReady(): boolean;
|
|
50
51
|
hasExposedModel(name: string): boolean;
|
|
@@ -61,6 +62,9 @@ export declare class OpenApiManager {
|
|
|
61
62
|
setStats(stats: ApiAnalysisStats): this;
|
|
62
63
|
getRouters(): readonly Router[];
|
|
63
64
|
registerRouters(routers: Router<any, any>[]): this;
|
|
65
|
+
getPrebuiltSpec(): Record<string, unknown> | null;
|
|
66
|
+
setPrebuiltSpec(spec: Record<string, unknown>): this;
|
|
67
|
+
clearPrebuiltSpec(): this;
|
|
64
68
|
reset(): void;
|
|
65
69
|
static getInstance(): OpenApiManager;
|
|
66
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiManager.d.ts","sourceRoot":"","sources":["../../../src/openapi/manager/OpenApiManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,gBAAgB,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AAE,aAAa,EAC5B,aAAa,EAAE,gBAAgB,EAAE,EACjC,SAAS,EAAE,YAAY,EAAE,EACzB,WAAW,EAAE,kBAAkB,EAC/B,KAAK,EAAE,gBAAgB;IAGzB,OAAO,IAAI,OAAO;IAIlB,eAAe,CAAC,IAAI,EAAE,MAAM;IAI5B,gBAAgB;IAIhB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,EAAE;IAK3C,YAAY,CAAC,SAAS,EAAE,YAAY,EAAE;IAKtC,WAAW;IAKX,SAAS,IAAI,aAAa;IAI1B,SAAS,CAAC,IAAI,EAAE,aAAa;IAK7B,YAAY;IAIZ,cAAc;IAId,cAAc,CAAC,WAAW,EAAE,kBAAkB;IAO9C,QAAQ;IAIR,QAAQ,CAAC,KAAK,EAAE,gBAAgB;IAOhC,UAAU,IAAI,SAAS,MAAM,EAAE;IAI/B,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE;IAK3C,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIjD,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAK7C,iBAAiB;IAKjB,KAAK;WAME,WAAW;CAoBzB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class s {
|
|
2
2
|
constructor(e, t, i, r, n) {
|
|
3
|
-
this.apiDocsHeader = e, this.exposedModels = t, this.endpoints = i, this.preferences = r, this.stats = n, this.isInitialized = !1, this.registeredRouters = [];
|
|
3
|
+
this.apiDocsHeader = e, this.exposedModels = t, this.endpoints = i, this.preferences = r, this.stats = n, this.isInitialized = !1, this.registeredRouters = [], this.prebuiltSpec = null;
|
|
4
4
|
}
|
|
5
5
|
static {
|
|
6
6
|
this.instance = null;
|
|
@@ -54,8 +54,17 @@ class s {
|
|
|
54
54
|
registerRouters(e) {
|
|
55
55
|
return e.forEach((t) => this.registeredRouters.push(t)), this;
|
|
56
56
|
}
|
|
57
|
+
getPrebuiltSpec() {
|
|
58
|
+
return this.prebuiltSpec;
|
|
59
|
+
}
|
|
60
|
+
setPrebuiltSpec(e) {
|
|
61
|
+
return this.prebuiltSpec = e, this;
|
|
62
|
+
}
|
|
63
|
+
clearPrebuiltSpec() {
|
|
64
|
+
return this.prebuiltSpec = null, this;
|
|
65
|
+
}
|
|
57
66
|
reset() {
|
|
58
|
-
this.exposedModels = [], this.endpoints = [];
|
|
67
|
+
this.exposedModels = [], this.endpoints = [], this.prebuiltSpec = null;
|
|
59
68
|
}
|
|
60
69
|
static getInstance() {
|
|
61
70
|
return s.instance || (s.instance = new s(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiManager.mjs","sources":["../../../src/openapi/manager/OpenApiManager.ts"],"sourcesContent":["import { Router } from '../../router/Router'\nimport { EndpointData, ExposedModelData } from '../types'\n\ntype UrlType = `${'http' | 'https'}://${string}.${string}`\n\nexport type ApiDocsHeader = {\n\ttitle: string\n\tversion: string\n\tdescription?: string\n\ttermsOfService?: UrlType\n\tcontact?: {\n\t\tname?: string\n\t\turl?: UrlType\n\t\temail?: string\n\t}\n\tlicense?: {\n\t\tname?: string\n\t\turl?: UrlType\n\t}\n}\n\nexport type ApiDocsPreferences = {\n\tallowOptionalPathParams: boolean\n}\n\nexport type ApiAnalysisStats = {\n\texplicitRouterFiles: {\n\t\tpath: string\n\t\trouters: {\n\t\t\tname: string\n\t\t\tendpoints: string[]\n\t\t}[]\n\t}[]\n\tdiscoveredRouterFiles: {\n\t\tpath: string\n\t\trouters: {\n\t\t\tname: string\n\t\t\tendpoints: string[]\n\t\t}[]\n\t}[]\n}\n\nexport class OpenApiManager {\n\tprivate static instance: OpenApiManager | null = null\n\n\tprivate isInitialized = false\n\tprivate registeredRouters: Router[] = []\n\n\tconstructor(\n\t\tprivate apiDocsHeader: ApiDocsHeader,\n\t\tprivate exposedModels: ExposedModelData[],\n\t\tprivate endpoints: EndpointData[],\n\t\tprivate preferences: ApiDocsPreferences,\n\t\tprivate stats: ApiAnalysisStats,\n\t) {}\n\n\tpublic isReady(): boolean {\n\t\treturn this.isInitialized\n\t}\n\n\tpublic hasExposedModel(name: string) {\n\t\treturn this.exposedModels.some((model) => model.name === name)\n\t}\n\n\tpublic getExposedModels() {\n\t\treturn this.exposedModels\n\t}\n\n\tpublic setExposedModels(models: ExposedModelData[]) {\n\t\tthis.exposedModels = models\n\t\treturn this\n\t}\n\n\tpublic setEndpoints(endpoints: EndpointData[]) {\n\t\tthis.endpoints = endpoints\n\t\treturn this\n\t}\n\n\tpublic markAsReady() {\n\t\tthis.isInitialized = true\n\t\treturn this\n\t}\n\n\tpublic getHeader(): ApiDocsHeader {\n\t\treturn this.apiDocsHeader\n\t}\n\n\tpublic setHeader(docs: ApiDocsHeader) {\n\t\tthis.apiDocsHeader = docs\n\t\treturn this\n\t}\n\n\tpublic getEndpoints() {\n\t\treturn this.endpoints\n\t}\n\n\tpublic getPreferences() {\n\t\treturn this.preferences\n\t}\n\n\tpublic setPreferences(preferences: ApiDocsPreferences) {\n\t\tthis.preferences = {\n\t\t\t...preferences,\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getStats() {\n\t\treturn this.stats\n\t}\n\n\tpublic setStats(stats: ApiAnalysisStats) {\n\t\tthis.stats = {\n\t\t\t...stats,\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getRouters(): readonly Router[] {\n\t\treturn this.registeredRouters\n\t}\n\n\tpublic registerRouters(routers: Router<any, any>[]) {\n\t\trouters.forEach((r) => this.registeredRouters.push(r))\n\t\treturn this\n\t}\n\n\tpublic reset() {\n\t\tthis.exposedModels = []\n\t\tthis.endpoints = []\n\t}\n\n\tpublic static getInstance() {\n\t\tif (!OpenApiManager.instance) {\n\t\t\tOpenApiManager.instance = new OpenApiManager(\n\t\t\t\t{\n\t\t\t\t\ttitle: 'Default title',\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t\t[],\n\t\t\t\t{\n\t\t\t\t\tallowOptionalPathParams: false,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdiscoveredRouterFiles: [],\n\t\t\t\t\texplicitRouterFiles: [],\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn OpenApiManager.instance\n\t}\n}\n"],"names":["OpenApiManager","apiDocsHeader","exposedModels","endpoints","preferences","stats","name","model","models","docs","routers","r"],"mappings":"AA0CO,MAAMA,EAAe;AAAA,
|
|
1
|
+
{"version":3,"file":"OpenApiManager.mjs","sources":["../../../src/openapi/manager/OpenApiManager.ts"],"sourcesContent":["import { Router } from '../../router/Router'\nimport { EndpointData, ExposedModelData } from '../types'\n\ntype UrlType = `${'http' | 'https'}://${string}.${string}`\n\nexport type ApiDocsHeader = {\n\ttitle: string\n\tversion: string\n\tdescription?: string\n\ttermsOfService?: UrlType\n\tcontact?: {\n\t\tname?: string\n\t\turl?: UrlType\n\t\temail?: string\n\t}\n\tlicense?: {\n\t\tname?: string\n\t\turl?: UrlType\n\t}\n}\n\nexport type ApiDocsPreferences = {\n\tallowOptionalPathParams: boolean\n}\n\nexport type ApiAnalysisStats = {\n\texplicitRouterFiles: {\n\t\tpath: string\n\t\trouters: {\n\t\t\tname: string\n\t\t\tendpoints: string[]\n\t\t}[]\n\t}[]\n\tdiscoveredRouterFiles: {\n\t\tpath: string\n\t\trouters: {\n\t\t\tname: string\n\t\t\tendpoints: string[]\n\t\t}[]\n\t}[]\n}\n\nexport class OpenApiManager {\n\tprivate static instance: OpenApiManager | null = null\n\n\tprivate isInitialized = false\n\tprivate registeredRouters: Router[] = []\n\tprivate prebuiltSpec: Record<string, unknown> | null = null\n\n\tconstructor(\n\t\tprivate apiDocsHeader: ApiDocsHeader,\n\t\tprivate exposedModels: ExposedModelData[],\n\t\tprivate endpoints: EndpointData[],\n\t\tprivate preferences: ApiDocsPreferences,\n\t\tprivate stats: ApiAnalysisStats,\n\t) {}\n\n\tpublic isReady(): boolean {\n\t\treturn this.isInitialized\n\t}\n\n\tpublic hasExposedModel(name: string) {\n\t\treturn this.exposedModels.some((model) => model.name === name)\n\t}\n\n\tpublic getExposedModels() {\n\t\treturn this.exposedModels\n\t}\n\n\tpublic setExposedModels(models: ExposedModelData[]) {\n\t\tthis.exposedModels = models\n\t\treturn this\n\t}\n\n\tpublic setEndpoints(endpoints: EndpointData[]) {\n\t\tthis.endpoints = endpoints\n\t\treturn this\n\t}\n\n\tpublic markAsReady() {\n\t\tthis.isInitialized = true\n\t\treturn this\n\t}\n\n\tpublic getHeader(): ApiDocsHeader {\n\t\treturn this.apiDocsHeader\n\t}\n\n\tpublic setHeader(docs: ApiDocsHeader) {\n\t\tthis.apiDocsHeader = docs\n\t\treturn this\n\t}\n\n\tpublic getEndpoints() {\n\t\treturn this.endpoints\n\t}\n\n\tpublic getPreferences() {\n\t\treturn this.preferences\n\t}\n\n\tpublic setPreferences(preferences: ApiDocsPreferences) {\n\t\tthis.preferences = {\n\t\t\t...preferences,\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getStats() {\n\t\treturn this.stats\n\t}\n\n\tpublic setStats(stats: ApiAnalysisStats) {\n\t\tthis.stats = {\n\t\t\t...stats,\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getRouters(): readonly Router[] {\n\t\treturn this.registeredRouters\n\t}\n\n\tpublic registerRouters(routers: Router<any, any>[]) {\n\t\trouters.forEach((r) => this.registeredRouters.push(r))\n\t\treturn this\n\t}\n\n\tpublic getPrebuiltSpec(): Record<string, unknown> | null {\n\t\treturn this.prebuiltSpec\n\t}\n\n\tpublic setPrebuiltSpec(spec: Record<string, unknown>) {\n\t\tthis.prebuiltSpec = spec\n\t\treturn this\n\t}\n\n\tpublic clearPrebuiltSpec() {\n\t\tthis.prebuiltSpec = null\n\t\treturn this\n\t}\n\n\tpublic reset() {\n\t\tthis.exposedModels = []\n\t\tthis.endpoints = []\n\t\tthis.prebuiltSpec = null\n\t}\n\n\tpublic static getInstance() {\n\t\tif (!OpenApiManager.instance) {\n\t\t\tOpenApiManager.instance = new OpenApiManager(\n\t\t\t\t{\n\t\t\t\t\ttitle: 'Default title',\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t\t[],\n\t\t\t\t{\n\t\t\t\t\tallowOptionalPathParams: false,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdiscoveredRouterFiles: [],\n\t\t\t\t\texplicitRouterFiles: [],\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn OpenApiManager.instance\n\t}\n}\n"],"names":["OpenApiManager","apiDocsHeader","exposedModels","endpoints","preferences","stats","name","model","models","docs","routers","r","spec"],"mappings":"AA0CO,MAAMA,EAAe;AAAA,EAO3B,YACSC,GACAC,GACAC,GACAC,GACAC,GACP;AALO,SAAA,gBAAAJ,GACA,KAAA,gBAAAC,GACA,KAAA,YAAAC,GACA,KAAA,cAAAC,GACA,KAAA,QAAAC,GATT,KAAQ,gBAAgB,IACxB,KAAQ,oBAA8B,CAAC,GACvC,KAAQ,eAA+C;AAAA,EAAA;AAAA,EAJvD,OAAA;AAAA,SAAe,WAAkC;AAAA,EAAA;AAAA,EAc1C,UAAmB;AACzB,WAAO,KAAK;AAAA,EAAA;AAAA,EAGN,gBAAgBC,GAAc;AACpC,WAAO,KAAK,cAAc,KAAK,CAACC,MAAUA,EAAM,SAASD,CAAI;AAAA,EAAA;AAAA,EAGvD,mBAAmB;AACzB,WAAO,KAAK;AAAA,EAAA;AAAA,EAGN,iBAAiBE,GAA4B;AACnD,gBAAK,gBAAgBA,GACd;AAAA,EAAA;AAAA,EAGD,aAAaL,GAA2B;AAC9C,gBAAK,YAAYA,GACV;AAAA,EAAA;AAAA,EAGD,cAAc;AACpB,gBAAK,gBAAgB,IACd;AAAA,EAAA;AAAA,EAGD,YAA2B;AACjC,WAAO,KAAK;AAAA,EAAA;AAAA,EAGN,UAAUM,GAAqB;AACrC,gBAAK,gBAAgBA,GACd;AAAA,EAAA;AAAA,EAGD,eAAe;AACrB,WAAO,KAAK;AAAA,EAAA;AAAA,EAGN,iBAAiB;AACvB,WAAO,KAAK;AAAA,EAAA;AAAA,EAGN,eAAeL,GAAiC;AACtD,gBAAK,cAAc;AAAA,MAClB,GAAGA;AAAA,IACJ,GACO;AAAA,EAAA;AAAA,EAGD,WAAW;AACjB,WAAO,KAAK;AAAA,EAAA;AAAA,EAGN,SAASC,GAAyB;AACxC,gBAAK,QAAQ;AAAA,MACZ,GAAGA;AAAA,IACJ,GACO;AAAA,EAAA;AAAA,EAGD,aAAgC;AACtC,WAAO,KAAK;AAAA,EAAA;AAAA,EAGN,gBAAgBK,GAA6B;AACnD,WAAAA,EAAQ,QAAQ,CAACC,MAAM,KAAK,kBAAkB,KAAKA,CAAC,CAAC,GAC9C;AAAA,EAAA;AAAA,EAGD,kBAAkD;AACxD,WAAO,KAAK;AAAA,EAAA;AAAA,EAGN,gBAAgBC,GAA+B;AACrD,gBAAK,eAAeA,GACb;AAAA,EAAA;AAAA,EAGD,oBAAoB;AAC1B,gBAAK,eAAe,MACb;AAAA,EAAA;AAAA,EAGD,QAAQ;AACd,SAAK,gBAAgB,CAAC,GACtB,KAAK,YAAY,CAAC,GAClB,KAAK,eAAe;AAAA,EAAA;AAAA,EAGrB,OAAc,cAAc;AACvB,WAACZ,EAAe,aACnBA,EAAe,WAAW,IAAIA;AAAA,MAC7B;AAAA,QACC,OAAO;AAAA,QACP,SAAS;AAAA,MACV;AAAA,MACA,CAAC;AAAA,MACD,CAAC;AAAA,MACD;AAAA,QACC,yBAAyB;AAAA,MAC1B;AAAA,MACA;AAAA,QACC,uBAAuB,CAAC;AAAA,QACxB,qBAAqB,CAAA;AAAA,MAAC;AAAA,IAExB,IAEMA,EAAe;AAAA,EAAA;AAExB;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../router/Router.cjs"),o=require("../generatorModule/generatorModule.cjs"),i=require("../manager/OpenApiManager.cjs"),t=new n.Router({skipOpenApiAnalysis:!0});t.get("/api-json",()=>{const e=i.OpenApiManager.getInstance(),r=e.getPrebuiltSpec();return r||o.generateOpenApiSpec(e)});const p=t;exports.OpenApiRouter=p;
|
|
2
2
|
//# sourceMappingURL=OpenApiRouter.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiRouter.cjs","sources":["../../../src/openapi/router/OpenApiRouter.ts"],"sourcesContent":["import { Router } from '../../router/Router'\nimport { generateOpenApiSpec } from '../generatorModule/generatorModule'\nimport { OpenApiManager } from '../manager/OpenApiManager'\n\nconst router = new Router({ skipOpenApiAnalysis: true })\n\nrouter.get('/api-json', () => {\n\
|
|
1
|
+
{"version":3,"file":"OpenApiRouter.cjs","sources":["../../../src/openapi/router/OpenApiRouter.ts"],"sourcesContent":["import { Router } from '../../router/Router'\nimport { generateOpenApiSpec } from '../generatorModule/generatorModule'\nimport { OpenApiManager } from '../manager/OpenApiManager'\n\nconst router = new Router({ skipOpenApiAnalysis: true })\n\nrouter.get('/api-json', () => {\n\tconst manager = OpenApiManager.getInstance()\n\tconst prebuilt = manager.getPrebuiltSpec()\n\tif (prebuilt) {\n\t\treturn prebuilt\n\t}\n\treturn generateOpenApiSpec(manager)\n})\n\nexport const OpenApiRouter = router\n"],"names":["router","Router","manager","OpenApiManager","prebuilt","generateOpenApiSpec","OpenApiRouter"],"mappings":"0NAIMA,EAAS,IAAIC,EAAA,OAAO,CAAE,oBAAqB,GAAM,EAEvDD,EAAO,IAAI,YAAa,IAAM,CACvB,MAAAE,EAAUC,iBAAe,YAAY,EACrCC,EAAWF,EAAQ,gBAAgB,EACzC,OAAIE,GAGGC,EAAAA,oBAAoBH,CAAO,CACnC,CAAC,EAEM,MAAMI,EAAgBN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiRouter.d.ts","sourceRoot":"","sources":["../../../src/openapi/router/OpenApiRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"OpenApiRouter.d.ts","sourceRoot":"","sources":["../../../src/openapi/router/OpenApiRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAe5C,eAAO,MAAM,aAAa,kEAAS,CAAA"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { Router as
|
|
1
|
+
import { Router as n } from "../../router/Router.mjs";
|
|
2
2
|
import { generateOpenApiSpec as p } from "../generatorModule/generatorModule.mjs";
|
|
3
|
-
import { OpenApiManager as
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const
|
|
3
|
+
import { OpenApiManager as o } from "../manager/OpenApiManager.mjs";
|
|
4
|
+
const t = new n({ skipOpenApiAnalysis: !0 });
|
|
5
|
+
t.get("/api-json", () => {
|
|
6
|
+
const e = o.getInstance(), r = e.getPrebuiltSpec();
|
|
7
|
+
return r || p(e);
|
|
8
|
+
});
|
|
9
|
+
const u = t;
|
|
7
10
|
export {
|
|
8
|
-
|
|
11
|
+
u as OpenApiRouter
|
|
9
12
|
};
|
|
10
13
|
//# sourceMappingURL=OpenApiRouter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiRouter.mjs","sources":["../../../src/openapi/router/OpenApiRouter.ts"],"sourcesContent":["import { Router } from '../../router/Router'\nimport { generateOpenApiSpec } from '../generatorModule/generatorModule'\nimport { OpenApiManager } from '../manager/OpenApiManager'\n\nconst router = new Router({ skipOpenApiAnalysis: true })\n\nrouter.get('/api-json', () => {\n\
|
|
1
|
+
{"version":3,"file":"OpenApiRouter.mjs","sources":["../../../src/openapi/router/OpenApiRouter.ts"],"sourcesContent":["import { Router } from '../../router/Router'\nimport { generateOpenApiSpec } from '../generatorModule/generatorModule'\nimport { OpenApiManager } from '../manager/OpenApiManager'\n\nconst router = new Router({ skipOpenApiAnalysis: true })\n\nrouter.get('/api-json', () => {\n\tconst manager = OpenApiManager.getInstance()\n\tconst prebuilt = manager.getPrebuiltSpec()\n\tif (prebuilt) {\n\t\treturn prebuilt\n\t}\n\treturn generateOpenApiSpec(manager)\n})\n\nexport const OpenApiRouter = router\n"],"names":["router","Router","manager","OpenApiManager","prebuilt","generateOpenApiSpec","OpenApiRouter"],"mappings":";;;AAIA,MAAMA,IAAS,IAAIC,EAAO,EAAE,qBAAqB,IAAM;AAEvDD,EAAO,IAAI,aAAa,MAAM;AACvB,QAAAE,IAAUC,EAAe,YAAY,GACrCC,IAAWF,EAAQ,gBAAgB;AACzC,SAAIE,KAGGC,EAAoBH,CAAO;AACnC,CAAC;AAEM,MAAMI,IAAgBN;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getValueAsNullableString.cjs","sources":["../../src/utils/getValueAsNullableString.ts"],"sourcesContent":["export function getValueAsNullableString(value: unknown) {\n\tif (value === null) {\n\t\treturn null\n\t} else if (typeof value === 'object') {\n\t\treturn JSON.stringify(value)\n\t}\n\treturn String(value)\n}\n"],"names":["getValueAsNullableString","value"],"mappings":"gFAAO,SAASA,EAAyBC,EAAgB,CACxD,OAAIA,IAAU,KACN,KACG,OAAOA,GAAU,SACpB,KAAK,UAAUA,CAAK,EAErB,OAAOA,CAAK,CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getValueAsNullableString.d.ts","sourceRoot":"","sources":["../../src/utils/getValueAsNullableString.ts"],"names":[],"mappings":"AAAA,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,iBAOtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getValueAsNullableString.mjs","sources":["../../src/utils/getValueAsNullableString.ts"],"sourcesContent":["export function getValueAsNullableString(value: unknown) {\n\tif (value === null) {\n\t\treturn null\n\t} else if (typeof value === 'object') {\n\t\treturn JSON.stringify(value)\n\t}\n\treturn String(value)\n}\n"],"names":["getValueAsNullableString","value"],"mappings":"AAAO,SAASA,EAAyBC,GAAgB;AACxD,SAAIA,MAAU,OACN,OACG,OAAOA,KAAU,WACpB,KAAK,UAAUA,CAAK,IAErB,OAAOA,CAAK;AACpB;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=e=>{const i="name"in e?e.name:e.originalName,{description:a}=e.validator;return a?`'${i}' (${a})`:`'${i}'`},r=(e,i)=>{const a="name"in e?e.name:e.originalName,{description:n,errorMessage:s}=e.validator;return i?`'${a}' (${i})`:s?`'${a}' (${s})`:n?`'${a}' (${n})`:`'${a}'`},o=e=>{const{description:i}=e;return i?`Missing request body (${i}).`:"Missing request body."},d=e=>{const{description:i,errorMessage:a}=e;return a?`Failed request body validation (${a}).`:i?`Failed request body validation (${i}).`:"Failed request body validation."};exports.getFailedRawBodyValidationMessage=d;exports.getMissingParamMessage=t;exports.getMissingRawBodyMessage=o;exports.getValidationResultMessage=r;
|
|
2
2
|
//# sourceMappingURL=validationMessages.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationMessages.cjs","sources":["../../src/utils/validationMessages.ts"],"sourcesContent":["import { Validator } from '../validators/types'\n\nexport const getMissingParamMessage = (\n\tresult:\n\t\t| {\n\t\t\t\tname: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t }\n\t\t| {\n\t\t\t\toriginalName: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t },\n) => {\n\tconst name = 'name' in result ? result.name : result.originalName\n\tconst { description } = result.validator\n\n\tif (description) {\n\t\treturn `'${name}' (${description})`\n\t}\n\treturn `'${name}'`\n}\n\nexport const getValidationResultMessage = (\n\tresult:\n\t\t| {\n\t\t\t\tname: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t }\n\t\t| {\n\t\t\t\toriginalName: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t },\n) => {\n\tconst name = 'name' in result ? result.name : result.originalName\n\tconst { description, errorMessage } = result.validator\n\n\tif (errorMessage) {\n\t\treturn `'${name}' (${errorMessage})`\n\t}\n\tif (description) {\n\t\treturn `'${name}' (${description})`\n\t}\n\treturn `'${name}'`\n}\n\nexport const getMissingRawBodyMessage = (validator: Validator<unknown>) => {\n\tconst { description } = validator\n\n\tif (description) {\n\t\treturn `Missing request body (${description}).`\n\t}\n\treturn 'Missing request body.'\n}\n\nexport const getFailedRawBodyValidationMessage = (validator: Validator<unknown>) => {\n\tconst { description, errorMessage } = validator\n\n\tif (errorMessage) {\n\t\treturn `Failed request body validation (${errorMessage}).`\n\t}\n\tif (description) {\n\t\treturn `Failed request body validation (${description}).`\n\t}\n\treturn 'Failed request body validation.'\n}\n"],"names":["getMissingParamMessage","result","name","description","getValidationResultMessage","errorMessage","getMissingRawBodyMessage","validator","getFailedRawBodyValidationMessage"],"mappings":"gFAEa,MAAAA,EACZC,GASI,CACJ,MAAMC,EAAO,SAAUD,EAASA,EAAO,KAAOA,EAAO,aAC/C,CAAE,YAAAE,GAAgBF,EAAO,UAE/B,OAAIE,EACI,IAAID,CAAI,MAAMC,CAAW,IAE1B,IAAID,CAAI,GAChB,EAEaE,
|
|
1
|
+
{"version":3,"file":"validationMessages.cjs","sources":["../../src/utils/validationMessages.ts"],"sourcesContent":["import { Validator } from '../validators/types'\n\nexport const getMissingParamMessage = (\n\tresult:\n\t\t| {\n\t\t\t\tname: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t }\n\t\t| {\n\t\t\t\toriginalName: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t },\n) => {\n\tconst name = 'name' in result ? result.name : result.originalName\n\tconst { description } = result.validator\n\n\tif (description) {\n\t\treturn `'${name}' (${description})`\n\t}\n\treturn `'${name}'`\n}\n\nexport const getValidationResultMessage = (\n\tresult:\n\t\t| {\n\t\t\t\tname: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t }\n\t\t| {\n\t\t\t\toriginalName: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t },\n\texception?: string | null,\n) => {\n\tconst name = 'name' in result ? result.name : result.originalName\n\tconst { description, errorMessage } = result.validator\n\n\tif (exception) {\n\t\treturn `'${name}' (${exception})`\n\t}\n\tif (errorMessage) {\n\t\treturn `'${name}' (${errorMessage})`\n\t}\n\tif (description) {\n\t\treturn `'${name}' (${description})`\n\t}\n\treturn `'${name}'`\n}\n\nexport const getMissingRawBodyMessage = (validator: Validator<unknown>) => {\n\tconst { description } = validator\n\n\tif (description) {\n\t\treturn `Missing request body (${description}).`\n\t}\n\treturn 'Missing request body.'\n}\n\nexport const getFailedRawBodyValidationMessage = (validator: Validator<unknown>) => {\n\tconst { description, errorMessage } = validator\n\n\tif (errorMessage) {\n\t\treturn `Failed request body validation (${errorMessage}).`\n\t}\n\tif (description) {\n\t\treturn `Failed request body validation (${description}).`\n\t}\n\treturn 'Failed request body validation.'\n}\n"],"names":["getMissingParamMessage","result","name","description","getValidationResultMessage","exception","errorMessage","getMissingRawBodyMessage","validator","getFailedRawBodyValidationMessage"],"mappings":"gFAEa,MAAAA,EACZC,GASI,CACJ,MAAMC,EAAO,SAAUD,EAASA,EAAO,KAAOA,EAAO,aAC/C,CAAE,YAAAE,GAAgBF,EAAO,UAE/B,OAAIE,EACI,IAAID,CAAI,MAAMC,CAAW,IAE1B,IAAID,CAAI,GAChB,EAEaE,EAA6B,CACzCH,EASAI,IACI,CACJ,MAAMH,EAAO,SAAUD,EAASA,EAAO,KAAOA,EAAO,aAC/C,CAAE,YAAAE,EAAa,aAAAG,CAAa,EAAIL,EAAO,UAE7C,OAAII,EACI,IAAIH,CAAI,MAAMG,CAAS,IAE3BC,EACI,IAAIJ,CAAI,MAAMI,CAAY,IAE9BH,EACI,IAAID,CAAI,MAAMC,CAAW,IAE1B,IAAID,CAAI,GAChB,EAEaK,EAA4BC,GAAkC,CACpE,KAAA,CAAE,YAAAL,GAAgBK,EAExB,OAAIL,EACI,yBAAyBA,CAAW,KAErC,uBACR,EAEaM,EAAqCD,GAAkC,CAC7E,KAAA,CAAE,YAAAL,EAAa,aAAAG,CAAA,EAAiBE,EAEtC,OAAIF,EACI,mCAAmCA,CAAY,KAEnDH,EACI,mCAAmCA,CAAW,KAE/C,iCACR"}
|
|
@@ -13,7 +13,7 @@ export declare const getValidationResultMessage: (result: {
|
|
|
13
13
|
} | {
|
|
14
14
|
originalName: string;
|
|
15
15
|
validator: Pick<Validator<unknown>, "description" | "errorMessage">;
|
|
16
|
-
}) => string;
|
|
16
|
+
}, exception?: string | null) => string;
|
|
17
17
|
export declare const getMissingRawBodyMessage: (validator: Validator<unknown>) => string;
|
|
18
18
|
export declare const getFailedRawBodyValidationMessage: (validator: Validator<unknown>) => string;
|
|
19
19
|
//# sourceMappingURL=validationMessages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationMessages.d.ts","sourceRoot":"","sources":["../../src/utils/validationMessages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,eAAO,MAAM,sBAAsB,WAE/B;IACA,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,cAAc,CAAC,CAAA;CAClE,GACD;IACA,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,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@@ -1,20 +1,20 @@
|
|
|
1
1
|
const t = (e) => {
|
|
2
2
|
const i = "name" in e ? e.name : e.originalName, { description: n } = e.validator;
|
|
3
3
|
return n ? `'${i}' (${n})` : `'${i}'`;
|
|
4
|
-
},
|
|
5
|
-
const
|
|
6
|
-
return
|
|
7
|
-
},
|
|
4
|
+
}, s = (e, i) => {
|
|
5
|
+
const n = "name" in e ? e.name : e.originalName, { description: a, errorMessage: r } = e.validator;
|
|
6
|
+
return i ? `'${n}' (${i})` : r ? `'${n}' (${r})` : a ? `'${n}' (${a})` : `'${n}'`;
|
|
7
|
+
}, o = (e) => {
|
|
8
8
|
const { description: i } = e;
|
|
9
9
|
return i ? `Missing request body (${i}).` : "Missing request body.";
|
|
10
|
-
},
|
|
10
|
+
}, d = (e) => {
|
|
11
11
|
const { description: i, errorMessage: n } = e;
|
|
12
12
|
return n ? `Failed request body validation (${n}).` : i ? `Failed request body validation (${i}).` : "Failed request body validation.";
|
|
13
13
|
};
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
d as getFailedRawBodyValidationMessage,
|
|
16
16
|
t as getMissingParamMessage,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
o as getMissingRawBodyMessage,
|
|
18
|
+
s as getValidationResultMessage
|
|
19
19
|
};
|
|
20
20
|
//# sourceMappingURL=validationMessages.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationMessages.mjs","sources":["../../src/utils/validationMessages.ts"],"sourcesContent":["import { Validator } from '../validators/types'\n\nexport const getMissingParamMessage = (\n\tresult:\n\t\t| {\n\t\t\t\tname: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t }\n\t\t| {\n\t\t\t\toriginalName: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t },\n) => {\n\tconst name = 'name' in result ? result.name : result.originalName\n\tconst { description } = result.validator\n\n\tif (description) {\n\t\treturn `'${name}' (${description})`\n\t}\n\treturn `'${name}'`\n}\n\nexport const getValidationResultMessage = (\n\tresult:\n\t\t| {\n\t\t\t\tname: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t }\n\t\t| {\n\t\t\t\toriginalName: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t },\n) => {\n\tconst name = 'name' in result ? result.name : result.originalName\n\tconst { description, errorMessage } = result.validator\n\n\tif (errorMessage) {\n\t\treturn `'${name}' (${errorMessage})`\n\t}\n\tif (description) {\n\t\treturn `'${name}' (${description})`\n\t}\n\treturn `'${name}'`\n}\n\nexport const getMissingRawBodyMessage = (validator: Validator<unknown>) => {\n\tconst { description } = validator\n\n\tif (description) {\n\t\treturn `Missing request body (${description}).`\n\t}\n\treturn 'Missing request body.'\n}\n\nexport const getFailedRawBodyValidationMessage = (validator: Validator<unknown>) => {\n\tconst { description, errorMessage } = validator\n\n\tif (errorMessage) {\n\t\treturn `Failed request body validation (${errorMessage}).`\n\t}\n\tif (description) {\n\t\treturn `Failed request body validation (${description}).`\n\t}\n\treturn 'Failed request body validation.'\n}\n"],"names":["getMissingParamMessage","result","name","description","getValidationResultMessage","errorMessage","getMissingRawBodyMessage","validator","getFailedRawBodyValidationMessage"],"mappings":"AAEa,MAAAA,IAAyB,CACrCC,MASI;AACJ,QAAMC,IAAO,UAAUD,IAASA,EAAO,OAAOA,EAAO,cAC/C,EAAE,aAAAE,MAAgBF,EAAO;AAE/B,SAAIE,IACI,IAAID,CAAI,MAAMC,CAAW,MAE1B,IAAID,CAAI;AAChB,GAEaE,IAA6B,CACzCH,
|
|
1
|
+
{"version":3,"file":"validationMessages.mjs","sources":["../../src/utils/validationMessages.ts"],"sourcesContent":["import { Validator } from '../validators/types'\n\nexport const getMissingParamMessage = (\n\tresult:\n\t\t| {\n\t\t\t\tname: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t }\n\t\t| {\n\t\t\t\toriginalName: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t },\n) => {\n\tconst name = 'name' in result ? result.name : result.originalName\n\tconst { description } = result.validator\n\n\tif (description) {\n\t\treturn `'${name}' (${description})`\n\t}\n\treturn `'${name}'`\n}\n\nexport const getValidationResultMessage = (\n\tresult:\n\t\t| {\n\t\t\t\tname: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t }\n\t\t| {\n\t\t\t\toriginalName: string\n\t\t\t\tvalidator: Pick<Validator<unknown>, 'description' | 'errorMessage'>\n\t\t },\n\texception?: string | null,\n) => {\n\tconst name = 'name' in result ? result.name : result.originalName\n\tconst { description, errorMessage } = result.validator\n\n\tif (exception) {\n\t\treturn `'${name}' (${exception})`\n\t}\n\tif (errorMessage) {\n\t\treturn `'${name}' (${errorMessage})`\n\t}\n\tif (description) {\n\t\treturn `'${name}' (${description})`\n\t}\n\treturn `'${name}'`\n}\n\nexport const getMissingRawBodyMessage = (validator: Validator<unknown>) => {\n\tconst { description } = validator\n\n\tif (description) {\n\t\treturn `Missing request body (${description}).`\n\t}\n\treturn 'Missing request body.'\n}\n\nexport const getFailedRawBodyValidationMessage = (validator: Validator<unknown>) => {\n\tconst { description, errorMessage } = validator\n\n\tif (errorMessage) {\n\t\treturn `Failed request body validation (${errorMessage}).`\n\t}\n\tif (description) {\n\t\treturn `Failed request body validation (${description}).`\n\t}\n\treturn 'Failed request body validation.'\n}\n"],"names":["getMissingParamMessage","result","name","description","getValidationResultMessage","exception","errorMessage","getMissingRawBodyMessage","validator","getFailedRawBodyValidationMessage"],"mappings":"AAEa,MAAAA,IAAyB,CACrCC,MASI;AACJ,QAAMC,IAAO,UAAUD,IAASA,EAAO,OAAOA,EAAO,cAC/C,EAAE,aAAAE,MAAgBF,EAAO;AAE/B,SAAIE,IACI,IAAID,CAAI,MAAMC,CAAW,MAE1B,IAAID,CAAI;AAChB,GAEaE,IAA6B,CACzCH,GASAI,MACI;AACJ,QAAMH,IAAO,UAAUD,IAASA,EAAO,OAAOA,EAAO,cAC/C,EAAE,aAAAE,GAAa,cAAAG,EAAa,IAAIL,EAAO;AAE7C,SAAII,IACI,IAAIH,CAAI,MAAMG,CAAS,MAE3BC,IACI,IAAIJ,CAAI,MAAMI,CAAY,MAE9BH,IACI,IAAID,CAAI,MAAMC,CAAW,MAE1B,IAAID,CAAI;AAChB,GAEaK,IAA2B,CAACC,MAAkC;AACpE,QAAA,EAAE,aAAAL,MAAgBK;AAExB,SAAIL,IACI,yBAAyBA,CAAW,OAErC;AACR,GAEaM,IAAoC,CAACD,MAAkC;AAC7E,QAAA,EAAE,aAAAL,GAAa,cAAAG,EAAA,IAAiBE;AAEtC,SAAIF,IACI,mCAAmCA,CAAY,OAEnDH,IACI,mCAAmCA,CAAW,OAE/C;AACR;"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { default as z } from 'zod';
|
|
2
|
+
|
|
1
3
|
type DeepPartial<T> = {
|
|
2
4
|
[P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]>;
|
|
3
5
|
};
|
|
@@ -14,5 +16,7 @@ export type BuiltInValidator<T, DescriptionT extends string, ErrorMessageT exten
|
|
|
14
16
|
description: DescriptionT;
|
|
15
17
|
errorMessage: ErrorMessageT;
|
|
16
18
|
};
|
|
19
|
+
export type ValidatorUnion = Omit<Validator<any>, 'optional'> | z.ZodType;
|
|
20
|
+
export type MaybeOptionalValidatorUnion = Validator<any> | z.ZodType;
|
|
17
21
|
export {};
|
|
18
22
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/validators/types.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,CAAC,CAAC,IAAI;KACpB,CAAC,IAAI,MAAM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symbol.toStringTag,{value:"Module"});const o=require("../node_modules/zod/v4/classic/external.cjs"),g=require("../errors/UserFacingErrors.cjs"),c=require("../utils/validationMessages.cjs");function l(r,a,s,t){const i=r.filter(e=>{let n=s[e.name].optional;return s[e.name]instanceof o.ZodType&&(n=s[e.name].safeParse(void 0).success),a[e.name]===void 0&&!n});if(i.length>0)throw new g.ValidationError(`Missing ${t} params: ${i.map(e=>c.getMissingParamMessage(e)).join(", ")}`)}exports.validateMissingParams=l;
|
|
2
|
+
//# sourceMappingURL=validateMissingParams.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateMissingParams.cjs","sources":["../../src/validators/validateMissingParams.ts"],"sourcesContent":["import z from 'zod'\n\nimport { ValidationError } from '../errors/UserFacingErrors'\nimport { getMissingParamMessage } from '../utils/validationMessages'\nimport { MaybeOptionalValidatorUnion, Validator } from './types'\n\nexport function validateMissingParams<ValidatorsT extends Record<string, MaybeOptionalValidatorUnion>>(\n\tparams: { name: string; validator: Pick<Validator<unknown>, 'description' | 'errorMessage'> }[],\n\tprovidedParams: Record<string, unknown>,\n\tvalidators: ValidatorsT,\n\tsuffix: 'body' | 'query' | 'path',\n) {\n\tconst missingParams = params.filter((param) => {\n\t\tlet isOptional = validators[param.name].optional\n\t\tif (validators[param.name] instanceof z.ZodType) {\n\t\t\tisOptional = (validators[param.name] as z.ZodType).safeParse(undefined).success\n\t\t}\n\n\t\treturn providedParams[param.name] === undefined && !isOptional\n\t})\n\n\tif (missingParams.length > 0) {\n\t\tthrow new ValidationError(\n\t\t\t`Missing ${suffix} params: ${missingParams.map((param) => getMissingParamMessage(param)).join(', ')}`,\n\t\t)\n\t}\n}\n"],"names":["validateMissingParams","params","providedParams","validators","suffix","missingParams","param","isOptional","z","ValidationError","getMissingParamMessage"],"mappings":"wOAMO,SAASA,EACfC,EACAC,EACAC,EACAC,EACC,CACD,MAAMC,EAAgBJ,EAAO,OAAQK,GAAU,CAC9C,IAAIC,EAAaJ,EAAWG,EAAM,IAAI,EAAE,SACxC,OAAIH,EAAWG,EAAM,IAAI,YAAaE,EAAE,UACvCD,EAAcJ,EAAWG,EAAM,IAAI,EAAgB,UAAU,MAAS,EAAE,SAGlEJ,EAAeI,EAAM,IAAI,IAAM,QAAa,CAACC,CAAA,CACpD,EAEG,GAAAF,EAAc,OAAS,EAC1B,MAAM,IAAII,EAAA,gBACT,WAAWL,CAAM,YAAYC,EAAc,IAAKC,GAAUI,EAAAA,uBAAuBJ,CAAK,CAAC,EAAE,KAAK,IAAI,CAAC,EACpG,CAEF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MaybeOptionalValidatorUnion, Validator } from './types';
|
|
2
|
+
|
|
3
|
+
export declare function validateMissingParams<ValidatorsT extends Record<string, MaybeOptionalValidatorUnion>>(params: {
|
|
4
|
+
name: string;
|
|
5
|
+
validator: Pick<Validator<unknown>, 'description' | 'errorMessage'>;
|
|
6
|
+
}[], providedParams: Record<string, unknown>, validators: ValidatorsT, suffix: 'body' | 'query' | 'path'): void;
|
|
7
|
+
//# sourceMappingURL=validateMissingParams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateMissingParams.d.ts","sourceRoot":"","sources":["../../src/validators/validateMissingParams.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,2BAA2B,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEhE,wBAAgB,qBAAqB,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,EACpG,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,cAAc,CAAC,CAAA;CAAE,EAAE,EAC/F,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,UAAU,EAAE,WAAW,EACvB,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,QAgBjC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as r from "../node_modules/zod/v4/classic/external.mjs";
|
|
2
|
+
import { ValidationError as m } from "../errors/UserFacingErrors.mjs";
|
|
3
|
+
import { getMissingParamMessage as f } from "../utils/validationMessages.mjs";
|
|
4
|
+
function p(o, t, e, a) {
|
|
5
|
+
const n = o.filter((i) => {
|
|
6
|
+
let s = e[i.name].optional;
|
|
7
|
+
return e[i.name] instanceof r.ZodType && (s = e[i.name].safeParse(void 0).success), t[i.name] === void 0 && !s;
|
|
8
|
+
});
|
|
9
|
+
if (n.length > 0)
|
|
10
|
+
throw new m(
|
|
11
|
+
`Missing ${a} params: ${n.map((i) => f(i)).join(", ")}`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
p as validateMissingParams
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=validateMissingParams.mjs.map
|