moonflower 1.2.0 → 1.3.0
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/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/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 +9 -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/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
|
@@ -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;AA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AA,QACA,WAAWN;AAAA,QACX,aAAa;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,IAC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ACX,aAAa;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;"}
|
|
@@ -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":""}
|
|
@@ -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,cAAc,CAAC,CAAA;CAClE,WASJ,CAAA;AAED,eAAO,MAAM,0BAA0B,WAEnC;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,cAAc,CAAC,CAAA;CAClE,
|
|
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,cAAc,CAAC,CAAA;CAClE,WASJ,CAAA;AAED,eAAO,MAAM,0BAA0B,WAEnC;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,cAAc,CAAC,CAAA;CAClE,cACQ,MAAM,GAAG,IAAI,WAezB,CAAA;AAED,eAAO,MAAM,wBAAwB,cAAe,SAAS,CAAC,OAAO,CAAC,WAOrE,CAAA;AAED,eAAO,MAAM,iCAAiC,cAAe,SAAS,CAAC,OAAO,CAAC,WAU9E,CAAA"}
|
|
@@ -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,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACzC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACrB,CAAC,CAAC,CA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C,GAClC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC7B,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACrB,CAAA;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAElE,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IAC1B,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAA;IAC3C,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,CAAC,CAAA;IAC9B,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO,CAAA;IAMzC,QAAQ,EAAE,OAAO,CAAA;IAKjB,WAAW,CAAC,EAAE,MAAM,CAAA;IAIpB,YAAY,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,YAAY,SAAS,MAAM,EAAE,aAAa,SAAS,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG;IAC3G,WAAW,EAAE,YAAY,CAAA;IACzB,YAAY,EAAE,aAAa,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,CAAA;AACzE,MAAM,MAAM,2BAA2B,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateMissingParams.mjs","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":";;;AAMO,SAASA,EACfC,GACAC,GACAC,GACAC,GACC;AACD,QAAMC,IAAgBJ,EAAO,OAAO,CAACK,MAAU;AAC9C,QAAIC,IAAaJ,EAAWG,EAAM,IAAI,EAAE;AACxC,WAAIH,EAAWG,EAAM,IAAI,aAAaE,EAAE,YACvCD,IAAcJ,EAAWG,EAAM,IAAI,EAAgB,UAAU,MAAS,EAAE,UAGlEJ,EAAeI,EAAM,IAAI,MAAM,UAAa,CAACC;AAAA,EAAA,CACpD;AAEG,MAAAF,EAAc,SAAS;AAC1B,UAAM,IAAII;AAAA,MACT,WAAWL,CAAM,YAAYC,EAAc,IAAI,CAACC,MAAUI,EAAuBJ,CAAK,CAAC,EAAE,KAAK,IAAI,CAAC;AAAA,IACpG;AAEF;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../node_modules/zod/v4/classic/external.cjs"),a=require("../utils/getValueAsNullableString.cjs"),c=require("../node_modules/zod/v4/classic/errors.cjs");function o(e,r){try{const t=s(e,r),n=l(e,r),u=f(e,n);return{validated:t&&u,parsedValue:n,exception:null}}catch(t){return{validated:!1,parsedValue:null,exception:p(t)}}}function s(e,r){return"prevalidate"in e&&typeof e.prevalidate=="function"?e.prevalidate(a.getValueAsNullableString(r)):!0}function l(e,r){if(e instanceof i.ZodType){const t=(()=>{try{return typeof r=="string"?JSON.parse(r):r}catch{return r}})();return e.parse(t)}return e.parse(a.getValueAsNullableString(r))}function f(e,r){return"validate"in e&&typeof e.validate=="function"?e.validate(r):!0}function p(e){return e instanceof c.ZodError?i.treeifyError(e).errors.join("; ").replace("Invalid input: ",""):"Validation failed"}exports.validateParam=o;
|
|
2
|
+
//# sourceMappingURL=validateParam.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateParam.cjs","sources":["../../src/validators/validateParam.ts"],"sourcesContent":["import z, { ZodError } from 'zod'\n\nimport { getValueAsNullableString } from '../utils/getValueAsNullableString'\nimport { ValidatorUnion } from './types'\n\nexport function validateParam(\n\tvalidator: ValidatorUnion,\n\tvalue: string | number | boolean | object | null,\n): {\n\tvalidated: boolean\n\tparsedValue: unknown\n\texception: string | null\n} {\n\ttry {\n\t\tconst prevalidatorSuccess = runPrevalidator(validator, value)\n\t\tconst parsedValue = runParser(validator, value)\n\t\tconst validatorSuccess = runValidator(validator, parsedValue)\n\n\t\treturn {\n\t\t\tvalidated: prevalidatorSuccess && validatorSuccess,\n\t\t\tparsedValue,\n\t\t\texception: null,\n\t\t}\n\t} catch (error) {\n\t\tconst exception = getErrorMessage(error)\n\t\treturn { validated: false, parsedValue: null, exception }\n\t}\n}\n\nfunction runPrevalidator(validator: ValidatorUnion, value: string | number | boolean | object | null) {\n\t// Legacy validator\n\tif ('prevalidate' in validator && typeof validator.prevalidate === 'function') {\n\t\treturn validator.prevalidate(getValueAsNullableString(value))\n\t}\n\t// Zod (skip)\n\treturn true\n}\n\nfunction runParser(validator: ValidatorUnion, value: string | number | boolean | object | null) {\n\t// Zod validator\n\tif (validator instanceof z.ZodType) {\n\t\tconst coercedValue = (() => {\n\t\t\ttry {\n\t\t\t\treturn typeof value === 'string' ? JSON.parse(value) : value\n\t\t\t} catch {\n\t\t\t\treturn value\n\t\t\t}\n\t\t})()\n\t\treturn validator.parse(coercedValue)\n\t}\n\t// Legacy validator\n\treturn validator.parse(getValueAsNullableString(value))\n}\n\nfunction runValidator(validator: ValidatorUnion, parsedValue: unknown) {\n\t// Legacy validator\n\tif ('validate' in validator && typeof validator.validate === 'function') {\n\t\treturn validator.validate(parsedValue)\n\t}\n\t// Zod (skip)\n\treturn true\n}\n\nfunction getErrorMessage(error: unknown) {\n\tif (error instanceof ZodError) {\n\t\treturn z.treeifyError(error).errors.join('; ').replace('Invalid input: ', '')\n\t}\n\treturn 'Validation failed'\n}\n"],"names":["validateParam","validator","value","prevalidatorSuccess","runPrevalidator","parsedValue","runParser","validatorSuccess","runValidator","error","getErrorMessage","getValueAsNullableString","z","coercedValue","ZodError"],"mappings":"yPAKgB,SAAAA,EACfC,EACAC,EAKC,CACG,GAAA,CACG,MAAAC,EAAsBC,EAAgBH,EAAWC,CAAK,EACtDG,EAAcC,EAAUL,EAAWC,CAAK,EACxCK,EAAmBC,EAAaP,EAAWI,CAAW,EAErD,MAAA,CACN,UAAWF,GAAuBI,EAClC,YAAAF,EACA,UAAW,IACZ,QACQI,EAAO,CAEf,MAAO,CAAE,UAAW,GAAO,YAAa,KAAM,UAD5BC,EAAgBD,CAAK,CACiB,CAAA,CAE1D,CAEA,SAASL,EAAgBH,EAA2BC,EAAkD,CAErG,MAAI,gBAAiBD,GAAa,OAAOA,EAAU,aAAgB,WAC3DA,EAAU,YAAYU,EAAyB,yBAAAT,CAAK,CAAC,EAGtD,EACR,CAEA,SAASI,EAAUL,EAA2BC,EAAkD,CAE3F,GAAAD,aAAqBW,EAAE,QAAS,CACnC,MAAMC,GAAgB,IAAM,CACvB,GAAA,CACH,OAAO,OAAOX,GAAU,SAAW,KAAK,MAAMA,CAAK,EAAIA,CAAA,MAChD,CACA,OAAAA,CAAA,CACR,GACE,EACI,OAAAD,EAAU,MAAMY,CAAY,CAAA,CAGpC,OAAOZ,EAAU,MAAMU,EAAyB,yBAAAT,CAAK,CAAC,CACvD,CAEA,SAASM,EAAaP,EAA2BI,EAAsB,CAEtE,MAAI,aAAcJ,GAAa,OAAOA,EAAU,UAAa,WACrDA,EAAU,SAASI,CAAW,EAG/B,EACR,CAEA,SAASK,EAAgBD,EAAgB,CACxC,OAAIA,aAAiBK,EAAAA,SACbF,EAAE,aAAaH,CAAK,EAAE,OAAO,KAAK,IAAI,EAAE,QAAQ,kBAAmB,EAAE,EAEtE,mBACR"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ValidatorUnion } from './types';
|
|
2
|
+
|
|
3
|
+
export declare function validateParam(validator: ValidatorUnion, value: string | number | boolean | object | null): {
|
|
4
|
+
validated: boolean;
|
|
5
|
+
parsedValue: unknown;
|
|
6
|
+
exception: string | null;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=validateParam.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateParam.d.ts","sourceRoot":"","sources":["../../src/validators/validateParam.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExC,wBAAgB,aAAa,CAC5B,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,GAC9C;IACF,SAAS,EAAE,OAAO,CAAA;IAClB,WAAW,EAAE,OAAO,CAAA;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB,CAeA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as i from "../node_modules/zod/v4/classic/external.mjs";
|
|
2
|
+
import { getValueAsNullableString as o } from "../utils/getValueAsNullableString.mjs";
|
|
3
|
+
import { ZodError as u } from "../node_modules/zod/v4/classic/errors.mjs";
|
|
4
|
+
function m(r, e) {
|
|
5
|
+
try {
|
|
6
|
+
const t = c(r, e), n = s(r, e), a = f(r, n);
|
|
7
|
+
return {
|
|
8
|
+
validated: t && a,
|
|
9
|
+
parsedValue: n,
|
|
10
|
+
exception: null
|
|
11
|
+
};
|
|
12
|
+
} catch (t) {
|
|
13
|
+
return { validated: !1, parsedValue: null, exception: p(t) };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function c(r, e) {
|
|
17
|
+
return "prevalidate" in r && typeof r.prevalidate == "function" ? r.prevalidate(o(e)) : !0;
|
|
18
|
+
}
|
|
19
|
+
function s(r, e) {
|
|
20
|
+
if (r instanceof i.ZodType) {
|
|
21
|
+
const t = (() => {
|
|
22
|
+
try {
|
|
23
|
+
return typeof e == "string" ? JSON.parse(e) : e;
|
|
24
|
+
} catch {
|
|
25
|
+
return e;
|
|
26
|
+
}
|
|
27
|
+
})();
|
|
28
|
+
return r.parse(t);
|
|
29
|
+
}
|
|
30
|
+
return r.parse(o(e));
|
|
31
|
+
}
|
|
32
|
+
function f(r, e) {
|
|
33
|
+
return "validate" in r && typeof r.validate == "function" ? r.validate(e) : !0;
|
|
34
|
+
}
|
|
35
|
+
function p(r) {
|
|
36
|
+
return r instanceof u ? i.treeifyError(r).errors.join("; ").replace("Invalid input: ", "") : "Validation failed";
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
m as validateParam
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=validateParam.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateParam.mjs","sources":["../../src/validators/validateParam.ts"],"sourcesContent":["import z, { ZodError } from 'zod'\n\nimport { getValueAsNullableString } from '../utils/getValueAsNullableString'\nimport { ValidatorUnion } from './types'\n\nexport function validateParam(\n\tvalidator: ValidatorUnion,\n\tvalue: string | number | boolean | object | null,\n): {\n\tvalidated: boolean\n\tparsedValue: unknown\n\texception: string | null\n} {\n\ttry {\n\t\tconst prevalidatorSuccess = runPrevalidator(validator, value)\n\t\tconst parsedValue = runParser(validator, value)\n\t\tconst validatorSuccess = runValidator(validator, parsedValue)\n\n\t\treturn {\n\t\t\tvalidated: prevalidatorSuccess && validatorSuccess,\n\t\t\tparsedValue,\n\t\t\texception: null,\n\t\t}\n\t} catch (error) {\n\t\tconst exception = getErrorMessage(error)\n\t\treturn { validated: false, parsedValue: null, exception }\n\t}\n}\n\nfunction runPrevalidator(validator: ValidatorUnion, value: string | number | boolean | object | null) {\n\t// Legacy validator\n\tif ('prevalidate' in validator && typeof validator.prevalidate === 'function') {\n\t\treturn validator.prevalidate(getValueAsNullableString(value))\n\t}\n\t// Zod (skip)\n\treturn true\n}\n\nfunction runParser(validator: ValidatorUnion, value: string | number | boolean | object | null) {\n\t// Zod validator\n\tif (validator instanceof z.ZodType) {\n\t\tconst coercedValue = (() => {\n\t\t\ttry {\n\t\t\t\treturn typeof value === 'string' ? JSON.parse(value) : value\n\t\t\t} catch {\n\t\t\t\treturn value\n\t\t\t}\n\t\t})()\n\t\treturn validator.parse(coercedValue)\n\t}\n\t// Legacy validator\n\treturn validator.parse(getValueAsNullableString(value))\n}\n\nfunction runValidator(validator: ValidatorUnion, parsedValue: unknown) {\n\t// Legacy validator\n\tif ('validate' in validator && typeof validator.validate === 'function') {\n\t\treturn validator.validate(parsedValue)\n\t}\n\t// Zod (skip)\n\treturn true\n}\n\nfunction getErrorMessage(error: unknown) {\n\tif (error instanceof ZodError) {\n\t\treturn z.treeifyError(error).errors.join('; ').replace('Invalid input: ', '')\n\t}\n\treturn 'Validation failed'\n}\n"],"names":["validateParam","validator","value","prevalidatorSuccess","runPrevalidator","parsedValue","runParser","validatorSuccess","runValidator","error","getErrorMessage","getValueAsNullableString","z","coercedValue","ZodError"],"mappings":";;;AAKgB,SAAAA,EACfC,GACAC,GAKC;AACG,MAAA;AACG,UAAAC,IAAsBC,EAAgBH,GAAWC,CAAK,GACtDG,IAAcC,EAAUL,GAAWC,CAAK,GACxCK,IAAmBC,EAAaP,GAAWI,CAAW;AAErD,WAAA;AAAA,MACN,WAAWF,KAAuBI;AAAA,MAClC,aAAAF;AAAA,MACA,WAAW;AAAA,IACZ;AAAA,WACQI,GAAO;AAEf,WAAO,EAAE,WAAW,IAAO,aAAa,MAAM,WAD5BC,EAAgBD,CAAK,EACiB;AAAA,EAAA;AAE1D;AAEA,SAASL,EAAgBH,GAA2BC,GAAkD;AAErG,SAAI,iBAAiBD,KAAa,OAAOA,EAAU,eAAgB,aAC3DA,EAAU,YAAYU,EAAyBT,CAAK,CAAC,IAGtD;AACR;AAEA,SAASI,EAAUL,GAA2BC,GAAkD;AAE3F,MAAAD,aAAqBW,EAAE,SAAS;AACnC,UAAMC,KAAgB,MAAM;AACvB,UAAA;AACH,eAAO,OAAOX,KAAU,WAAW,KAAK,MAAMA,CAAK,IAAIA;AAAA,MAAA,QAChD;AACA,eAAAA;AAAA,MAAA;AAAA,IACR,GACE;AACI,WAAAD,EAAU,MAAMY,CAAY;AAAA,EAAA;AAGpC,SAAOZ,EAAU,MAAMU,EAAyBT,CAAK,CAAC;AACvD;AAEA,SAASM,EAAaP,GAA2BI,GAAsB;AAEtE,SAAI,cAAcJ,KAAa,OAAOA,EAAU,YAAa,aACrDA,EAAU,SAASI,CAAW,IAG/B;AACR;AAEA,SAASK,EAAgBD,GAAgB;AACxC,SAAIA,aAAiBK,IACbF,EAAE,aAAaH,CAAK,EAAE,OAAO,KAAK,IAAI,EAAE,QAAQ,mBAAmB,EAAE,IAEtE;AACR;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moonflower",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "tenebrie",
|
|
6
6
|
"license": "MIT",
|
|
@@ -129,7 +129,13 @@
|
|
|
129
129
|
"peerDependencies": {
|
|
130
130
|
"@koa/router": "^13.1.0",
|
|
131
131
|
"koa": "^2.15.3",
|
|
132
|
-
"koa-bodyparser": "^4.4.1"
|
|
132
|
+
"koa-bodyparser": "^4.4.1",
|
|
133
|
+
"zod": "4.3.6"
|
|
134
|
+
},
|
|
135
|
+
"peerDependenciesMeta": {
|
|
136
|
+
"zod": {
|
|
137
|
+
"optional": true
|
|
138
|
+
}
|
|
133
139
|
},
|
|
134
140
|
"devDependencies": {
|
|
135
141
|
"@koa/router": "^13.1.0",
|
|
@@ -148,6 +154,7 @@
|
|
|
148
154
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
149
155
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
150
156
|
"jest": "29.7.0",
|
|
157
|
+
"zod": "4.3.6",
|
|
151
158
|
"koa": "^2.15.3",
|
|
152
159
|
"koa-bodyparser": "^4.4.1",
|
|
153
160
|
"node-mocks-http": "^1.16.2",
|
|
@@ -34,12 +34,66 @@ export class InternalServerError extends BaseHttpError {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
export class ForbiddenError extends BaseHttpError {
|
|
38
|
+
constructor(message: string) {
|
|
39
|
+
super(StatusCodes.FORBIDDEN, message)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class MethodNotAllowedError extends BaseHttpError {
|
|
44
|
+
constructor(message: string) {
|
|
45
|
+
super(StatusCodes.METHOD_NOT_ALLOWED, message)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class ConflictError extends BaseHttpError {
|
|
50
|
+
constructor(message: string) {
|
|
51
|
+
super(StatusCodes.CONFLICT, message)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export class GoneError extends BaseHttpError {
|
|
56
|
+
constructor(message: string) {
|
|
57
|
+
super(StatusCodes.GONE, message)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class UnprocessableEntityError extends BaseHttpError {
|
|
62
|
+
constructor(message: string) {
|
|
63
|
+
super(StatusCodes.UNPROCESSABLE_ENTITY, message)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class TooManyRequestsError extends BaseHttpError {
|
|
68
|
+
constructor(message: string) {
|
|
69
|
+
super(StatusCodes.TOO_MANY_REQUESTS, message)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export class NotImplementedError extends BaseHttpError {
|
|
74
|
+
constructor(message: string) {
|
|
75
|
+
super(StatusCodes.NOT_IMPLEMENTED, message)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export class BadGatewayError extends BaseHttpError {
|
|
80
|
+
constructor(message: string) {
|
|
81
|
+
super(StatusCodes.BAD_GATEWAY, message)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
37
85
|
export class ServiceUnavailableError extends BaseHttpError {
|
|
38
86
|
constructor(message: string) {
|
|
39
87
|
super(StatusCodes.SERVICE_UNAVAILABLE, message)
|
|
40
88
|
}
|
|
41
89
|
}
|
|
42
90
|
|
|
91
|
+
export class GatewayTimeoutError extends BaseHttpError {
|
|
92
|
+
constructor(message: string) {
|
|
93
|
+
super(StatusCodes.GATEWAY_TIMEOUT, message)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
43
97
|
// To be used later
|
|
44
98
|
// export const errorNameToStatusCode = (name: string): number => {
|
|
45
99
|
// switch (name) {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { expectTypeOf } from 'vitest'
|
|
2
|
+
import z from 'zod'
|
|
3
|
+
|
|
1
4
|
import {
|
|
2
5
|
BooleanValidator,
|
|
3
6
|
NumberValidator,
|
|
@@ -158,4 +161,28 @@ describe('usePathParams', () => {
|
|
|
158
161
|
expect(test).toThrow(ValidationError)
|
|
159
162
|
expect(test).toThrow("Failed route param validation: 'testParam' (Description)")
|
|
160
163
|
})
|
|
164
|
+
|
|
165
|
+
describe('zod validators', () => {
|
|
166
|
+
it('parses required params when present', () => {
|
|
167
|
+
const ctx = mockContextPath(mockContext(), '/test/:stringParam/:numberParam/:booleanParam', {
|
|
168
|
+
stringParam: 'test_string',
|
|
169
|
+
numberParam: '12',
|
|
170
|
+
booleanParam: 'true',
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
const params = usePathParams(ctx, {
|
|
174
|
+
stringParam: z.string(),
|
|
175
|
+
numberParam: z.number(),
|
|
176
|
+
booleanParam: z.boolean(),
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
expect(params.stringParam).toEqual('test_string')
|
|
180
|
+
expect(params.numberParam).toEqual(12)
|
|
181
|
+
expect(params.booleanParam).toEqual(true)
|
|
182
|
+
|
|
183
|
+
expectTypeOf(params.stringParam).toEqualTypeOf<string>()
|
|
184
|
+
expectTypeOf(params.numberParam).toEqualTypeOf<number>()
|
|
185
|
+
expectTypeOf(params.booleanParam).toEqualTypeOf<boolean>()
|
|
186
|
+
})
|
|
187
|
+
})
|
|
161
188
|
})
|
|
@@ -5,6 +5,7 @@ import { keysOf } from '../utils/object'
|
|
|
5
5
|
import { CleanUpPathParam } from '../utils/TypeUtils'
|
|
6
6
|
import { getValidationResultMessage } from '../utils/validationMessages'
|
|
7
7
|
import { Validator } from '../validators/types'
|
|
8
|
+
import { validateParam } from '../validators/validateParam'
|
|
8
9
|
|
|
9
10
|
type CheckIfOptional<T, B> = B extends string ? (B extends `${string}?` ? T | undefined : T) : never
|
|
10
11
|
|
|
@@ -50,21 +51,12 @@ export const usePathParams = <
|
|
|
50
51
|
|
|
51
52
|
// Param is optional and is not provided - skip validation
|
|
52
53
|
if (paramValue === undefined) {
|
|
53
|
-
return { param, validated: true }
|
|
54
|
+
return { param, validated: true, parsedValue: undefined, exception: null }
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const parsedValue = validatorObject.parse(paramValue)
|
|
60
|
-
const validatorSuccess = !validatorObject.validate || validatorObject.validate(parsedValue)
|
|
61
|
-
return {
|
|
62
|
-
param,
|
|
63
|
-
validated: prevalidatorSuccess && validatorSuccess,
|
|
64
|
-
parsedValue,
|
|
65
|
-
}
|
|
66
|
-
} catch {
|
|
67
|
-
return { param, validated: false }
|
|
57
|
+
return {
|
|
58
|
+
...validateParam(param.validator, paramValue),
|
|
59
|
+
param,
|
|
68
60
|
}
|
|
69
61
|
})
|
|
70
62
|
|