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":"nodeParsers.mjs","sources":["../../../src/openapi/analyzerModule/nodeParsers.ts"],"sourcesContent":["import {\n\tNode,\n\tPropertyAccessExpression,\n\tPropertyAssignment,\n\tPropertySignature,\n\tShorthandPropertyAssignment,\n\tSyntaxKind,\n\tts,\n\tType,\n\tTypeReferenceNode,\n} from 'ts-morph'\n\nimport { Logger } from '../../utils/logger'\nimport { OpenApiManager } from '../manager/OpenApiManager'\nimport { ShapeOfProperty, ShapeOfType, ShapeOfUnionEntry } from './types'\n\nconst implementationCache = new WeakMap<Node, Node>()\n\nexport const findNodeImplementation = (node: Node): Node => {\n\tconst cached = implementationCache.get(node)\n\tif (cached) {\n\t\treturn cached\n\t}\n\n\tif (node.getKind() === SyntaxKind.Identifier) {\n\t\tconst implementationNode = node.asKind(SyntaxKind.Identifier)!.getImplementations()[0]?.getNode()\n\t\tif (implementationNode) {\n\t\t\tconst implementationParentNode = implementationNode.getParent()!\n\t\t\tconst assignmentValueNode = implementationParentNode.getLastChild()!\n\t\t\tif (assignmentValueNode === node) {\n\t\t\t\tthrow new Error('Recursive implementation found')\n\t\t\t}\n\t\t\tconst result = findNodeImplementation(assignmentValueNode)\n\t\t\timplementationCache.set(node, result)\n\t\t\treturn result\n\t\t}\n\n\t\tconst definitionNode = node.asKind(SyntaxKind.Identifier)!.getDefinitions()[0]?.getNode()\n\t\tif (definitionNode) {\n\t\t\tconst definitionParentNode = definitionNode.getParent()!\n\t\t\tconst assignmentValueNode = definitionParentNode.getLastChild()!\n\t\t\tif (assignmentValueNode === node) {\n\t\t\t\tthrow new Error('Recursive implementation found')\n\t\t\t}\n\t\t\tconst result = findNodeImplementation(assignmentValueNode)\n\t\t\timplementationCache.set(node, result)\n\t\t\treturn result\n\t\t}\n\t\tthrow new Error('No implementation nor definition available')\n\t}\n\n\timplementationCache.set(node, node)\n\treturn node\n}\n\nexport const findPropertyAssignmentValueNode = (\n\tnode:\n\t\t| PropertyAssignment\n\t\t| TypeReferenceNode\n\t\t| PropertySignature\n\t\t| PropertyAccessExpression\n\t\t| ShorthandPropertyAssignment,\n): Node => {\n\tconst identifierChildren = node.getChildrenOfKind(SyntaxKind.Identifier)\n\tif (identifierChildren.length === 2) {\n\t\treturn findNodeImplementation(identifierChildren[1])\n\t}\n\tconst lastMatchingChild = node.getChildren().reverse()\n\treturn lastMatchingChild.find(\n\t\t(child) =>\n\t\t\tchild.getKind() !== SyntaxKind.GreaterThanToken &&\n\t\t\tchild.getKind() !== SyntaxKind.CommaToken &&\n\t\t\tchild.getKind() !== SyntaxKind.SemicolonToken,\n\t)!\n}\n\nexport const getTypeReferenceShape = (node: TypeReferenceNode): ShapeOfType['shape'] => {\n\tconst firstChild = node.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\tif (firstChild.isKind(SyntaxKind.SyntaxList)) {\n\t\treturn getRecursiveNodeShape(firstChild.getFirstChild()!)\n\t} else {\n\t\treturn getRecursiveNodeShape(firstChild)\n\t}\n}\n\nexport const getRecursiveNodeShape = (nodeOrReference: Node): ShapeOfType['shape'] => {\n\tconst typeName = nodeOrReference.getSymbol()?.getName()\n\tif (typeName && OpenApiManager.getInstance().hasExposedModel(typeName)) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'ref',\n\t\t\t\tshape: typeName,\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tconst node = findNodeImplementation(nodeOrReference)\n\n\t// Undefined\n\tconst undefinedNode = node.asKind(SyntaxKind.UndefinedKeyword)\n\tif (undefinedNode) {\n\t\treturn 'undefined'\n\t}\n\n\t// Literal type\n\tconst literalNode = node.asKind(SyntaxKind.LiteralType)\n\tif (literalNode) {\n\t\tif (literalNode.getFirstChildByKind(SyntaxKind.TrueKeyword)) {\n\t\t\treturn 'true'\n\t\t}\n\t\tif (literalNode.getFirstChildByKind(SyntaxKind.FalseKeyword)) {\n\t\t\treturn 'false'\n\t\t}\n\t}\n\n\t// Boolean literal\n\tconst booleanLiteralNode =\n\t\tnode.asKind(SyntaxKind.BooleanKeyword) ||\n\t\tnode.asKind(SyntaxKind.TrueKeyword) ||\n\t\tnode.asKind(SyntaxKind.FalseKeyword)\n\tif (booleanLiteralNode) {\n\t\treturn 'boolean'\n\t}\n\n\t// String literal\n\tconst stringLiteralNode = node.asKind(SyntaxKind.StringKeyword) || node.asKind(SyntaxKind.StringLiteral)\n\tif (stringLiteralNode) {\n\t\treturn 'string'\n\t}\n\n\t// Number literal\n\tconst numberLiteralNode = node.asKind(SyntaxKind.NumberKeyword) || node.asKind(SyntaxKind.NumericLiteral)\n\tif (numberLiteralNode) {\n\t\treturn 'number'\n\t}\n\n\t// BigInt literal\n\tconst bigIntNode = node.asKind(SyntaxKind.BigIntKeyword) || node.asKind(SyntaxKind.BigIntLiteral)\n\tif (bigIntNode) {\n\t\treturn 'bigint'\n\t}\n\n\t// Type literal\n\tconst typeLiteralNode = node.asKind(SyntaxKind.TypeLiteral)\n\tif (typeLiteralNode) {\n\t\tconst properties = typeLiteralNode\n\t\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t\t.getChildrenOfKind(SyntaxKind.PropertySignature)\n\n\t\tconst propertyShapes = properties.map((propNode) => {\n\t\t\tconst identifier = propNode.getFirstChildByKind(SyntaxKind.Identifier)!\n\t\t\tconst valueNode = findPropertyAssignmentValueNode(propNode)\n\t\t\tconst questionMarkToken = identifier.getNextSiblingIfKind(SyntaxKind.QuestionToken)\n\t\t\treturn {\n\t\t\t\trole: 'property' as const,\n\t\t\t\tidentifier: identifier.getText(),\n\t\t\t\tshape: getRecursiveNodeShape(valueNode),\n\t\t\t\toptional: valueNode.getType().isNullable() || !!questionMarkToken,\n\t\t\t}\n\t\t})\n\t\treturn propertyShapes\n\t}\n\n\t// Type reference\n\tconst typeReferenceNode = node.asKind(SyntaxKind.TypeReference)\n\tif (typeReferenceNode) {\n\t\treturn getRecursiveNodeShape(typeReferenceNode.getFirstChild()!)\n\t}\n\n\t// Property access expression\n\tconst propertyAccessNode = node.asKind(SyntaxKind.PropertyAccessExpression)\n\tif (propertyAccessNode) {\n\t\tconst lastChild = findNodeImplementation(node.getLastChild()!)\n\t\treturn getProperTypeShape(lastChild.asKind(SyntaxKind.CallExpression)!.getReturnType(), lastChild)\n\t}\n\n\t// Union type\n\tconst unionTypeNode = node.asKind(SyntaxKind.UnionType)\n\tif (unionTypeNode) {\n\t\treturn getProperTypeShape(unionTypeNode.getType(), node)\n\t}\n\n\t// Typeof query\n\tconst typeQueryNode = node.asKind(SyntaxKind.TypeQuery)\n\tif (typeQueryNode) {\n\t\treturn getRecursiveNodeShape(typeQueryNode.getLastChild()!)\n\t}\n\n\t// Qualified name\n\tconst qualifiedNameNode = node.asKind(SyntaxKind.QualifiedName)\n\tif (qualifiedNameNode) {\n\t\treturn getRecursiveNodeShape(qualifiedNameNode.getLastChild()!)\n\t}\n\n\t// Call expression\n\tconst callExpressionNode = node.asKind(SyntaxKind.CallExpression)\n\tif (callExpressionNode) {\n\t\treturn getProperTypeShape(callExpressionNode.getReturnType(), callExpressionNode)\n\t}\n\n\t// Await expression\n\tconst awaitExpressionNode = node.asKind(SyntaxKind.AwaitExpression)\n\tif (awaitExpressionNode) {\n\t\treturn getRecursiveNodeShape(awaitExpressionNode.getChildAtIndex(1)!)\n\t}\n\n\t// 'As' Expression\n\tconst asExpressionNode = node.asKind(SyntaxKind.AsExpression)\n\tif (asExpressionNode) {\n\t\treturn getRecursiveNodeShape(asExpressionNode.getChildAtIndex(2)!)\n\t}\n\n\t// TODO\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown node type: ${node.getKindName()}`)\n\treturn 'unknown_1'\n}\n\nexport const getShapeOfValidatorLiteral = (\n\tobjectLiteralNode: Node<ts.ObjectLiteralExpression>,\n): (ShapeOfProperty & { description: string; errorMessage: string })[] => {\n\tconst syntaxListNode = objectLiteralNode.getFirstDescendantByKind(SyntaxKind.SyntaxList)!\n\tconst assignmentNodes = syntaxListNode.getChildrenOfKind(SyntaxKind.PropertyAssignment)!\n\n\tconst properties = assignmentNodes.map((node) => {\n\t\tconst identifierNode = node.getFirstChild()!\n\t\tconst identifierName = (() => {\n\t\t\tif (identifierNode.isKind(SyntaxKind.Identifier)) {\n\t\t\t\treturn identifierNode.getText()\n\t\t\t}\n\t\t\tif (identifierNode.isKind(SyntaxKind.StringLiteral)) {\n\t\t\t\treturn identifierNode.getLiteralText()\n\t\t\t}\n\t\t\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\t\t\tLogger.warn(`[${fileName}] Unknown identifier name: ${identifierNode.getText()}`)\n\t\t\treturn 'unknown_30'\n\t\t})()\n\n\t\tconst assignmentValueNode = node.getLastChild()!\n\t\tconst innerLiteralNode = findNodeImplementation(assignmentValueNode)\n\n\t\treturn {\n\t\t\trole: 'property' as const,\n\t\t\tidentifier: identifierName,\n\t\t\tshape: getValidatorPropertyShape(innerLiteralNode),\n\t\t\toptional: getValidatorPropertyOptionality(innerLiteralNode),\n\t\t\tdescription: getValidatorPropertyStringValue(innerLiteralNode, 'description'),\n\t\t\terrorMessage: getValidatorPropertyStringValue(innerLiteralNode, 'errorMessage'),\n\t\t}\n\t})\n\n\treturn properties || []\n}\n\nexport const getValidatorPropertyShape = (innerLiteralNode: Node): ShapeOfType['shape'] => {\n\t// Inline definition with `as Validator<...>` clause\n\tconst inlineValidatorAsExpression = innerLiteralNode\n\t\t.getParent()!\n\t\t.getFirstChildByKind(SyntaxKind.AsExpression)\n\tif (inlineValidatorAsExpression) {\n\t\tconst typeReference = inlineValidatorAsExpression.getLastChildByKind(SyntaxKind.TypeReference)!\n\t\treturn getTypeReferenceShape(typeReference)\n\t}\n\n\t// Variable with `: Validator<...>` clause\n\tconst childTypeReferenceNode = innerLiteralNode.getParent()!.getFirstChildByKind(SyntaxKind.TypeReference)\n\tif (childTypeReferenceNode) {\n\t\treturn getTypeReferenceShape(childTypeReferenceNode)\n\t}\n\n\t// `RequiredParam<...>` inline call expression\n\tif (innerLiteralNode.getParent()!.getChildrenOfKind(SyntaxKind.SyntaxList).length >= 2) {\n\t\tconst typeNode = innerLiteralNode\n\t\t\t.getParent()!\n\t\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t\t.getFirstChild()!\n\t\treturn getRecursiveNodeShape(typeNode)\n\t}\n\n\t// `RequestParam | RequiredParam | OptionalParam` call expression\n\tconst childCallExpressionNode = innerLiteralNode.getParent()!.getFirstChildByKind(SyntaxKind.CallExpression)\n\tif (childCallExpressionNode) {\n\t\tconst callExpressionArgument = findNodeImplementation(\n\t\t\tchildCallExpressionNode.getFirstChildByKind(SyntaxKind.SyntaxList)!.getFirstChild()!,\n\t\t)\n\n\t\t// Param is a type reference\n\t\tconst typeReferenceNode = callExpressionArgument\n\t\t\t.getParent()!\n\t\t\t.getFirstChildByKind(SyntaxKind.TypeReference)!\n\t\tif (typeReferenceNode) {\n\t\t\treturn getProperTypeShape(typeReferenceNode.getType(), typeReferenceNode, [])\n\t\t}\n\n\t\tconst thingyNode = callExpressionArgument\n\t\t\t.getParent()!\n\t\t\t.getFirstChildByKind(SyntaxKind.ObjectLiteralExpression)!\n\t\tif (thingyNode) {\n\t\t\treturn getValidatorPropertyShape(thingyNode)\n\t\t}\n\n\t\tif (callExpressionArgument.getKind() === SyntaxKind.CallExpression) {\n\t\t\treturn getValidatorPropertyShape(callExpressionArgument)\n\t\t}\n\n\t\tif (callExpressionArgument.getKind() === SyntaxKind.IntersectionType) {\n\t\t\treturn getValidatorPropertyShape(callExpressionArgument)\n\t\t}\n\n\t\tconst fileName = innerLiteralNode.getSourceFile().getFilePath().split('/').pop()\n\t\tLogger.warn(`[${fileName}] Unknown call expression argument: ${callExpressionArgument.getKindName()}`)\n\t\treturn 'unknown_3'\n\t}\n\n\t// Attempting to infer type from `parse` function\n\tconst innerNodePropertyAssignments = innerLiteralNode\n\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t.getChildrenOfKind(SyntaxKind.PropertyAssignment)\n\tconst parsePropertyAssignment = innerNodePropertyAssignments.find((prop) => {\n\t\treturn prop.getFirstChildByKind(SyntaxKind.Identifier)?.getText() === 'parse'\n\t})\n\tif (parsePropertyAssignment) {\n\t\tconst returnType = findPropertyAssignmentValueNode(parsePropertyAssignment)\n\t\t\t.asKind(SyntaxKind.ArrowFunction)!\n\t\t\t.getReturnType()\n\t\treturn getProperTypeShape(returnType, parsePropertyAssignment)\n\t}\n\n\t// Import statement\n\tconst importTypeNode = innerLiteralNode\n\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)\n\t\t?.getFirstChildByKind(SyntaxKind.ImportType)\n\tif (importTypeNode) {\n\t\tconst indexOfGreaterThanToken = importTypeNode\n\t\t\t.getLastChildByKind(SyntaxKind.GreaterThanToken)!\n\t\t\t.getChildIndex()\n\t\tconst targetSyntaxList = importTypeNode.getChildAtIndex(indexOfGreaterThanToken - 1)\n\t\treturn getRecursiveNodeShape(targetSyntaxList.getFirstChild()!)\n\t}\n\n\t// Intersection type with Validator\n\tconst intersectionType = innerLiteralNode.isKind(SyntaxKind.IntersectionType)\n\t\t? innerLiteralNode\n\t\t: innerLiteralNode.getParent()?.isKind(SyntaxKind.VariableDeclaration)\n\t\t\t? innerLiteralNode.getParent()?.getFirstChildByKind(SyntaxKind.IntersectionType)\n\t\t\t: null\n\n\tif (intersectionType) {\n\t\tconst validatorType = intersectionType.getFirstChildByKind(SyntaxKind.TypeReference)\n\t\tif (validatorType) {\n\t\t\treturn getTypeReferenceShape(validatorType)\n\t\t}\n\t}\n\n\tconst fileName = innerLiteralNode.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown import type node`)\n\n\treturn 'unknown_2'\n}\n\nexport const getValidatorPropertyOptionality = (node: Node): boolean => {\n\tconst callExpressionNode = node.asKind(SyntaxKind.CallExpression)\n\tif (callExpressionNode) {\n\t\tconst identifierNode = callExpressionNode.getFirstChildByKind(SyntaxKind.Identifier)\n\t\tif (identifierNode?.getText() === 'OptionalParam') {\n\t\t\treturn true\n\t\t} else if (identifierNode?.getText() === 'RequiredParam') {\n\t\t\treturn false\n\t\t}\n\n\t\tconst syntaxListNode = callExpressionNode.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\tconst literalExpression = findNodeImplementation(syntaxListNode.getFirstChild()!)\n\t\treturn getValidatorPropertyOptionality(literalExpression)\n\t}\n\n\tconst syntaxListNode = node.getFirstDescendantByKind(SyntaxKind.SyntaxList)!\n\tconst assignmentNodes = syntaxListNode.getChildrenOfKind(SyntaxKind.PropertyAssignment)!\n\n\treturn assignmentNodes.some((node) => {\n\t\tconst identifierNode = node.getFirstDescendantByKind(SyntaxKind.Identifier)!\n\t\tconst identifierName = identifierNode.getText()\n\n\t\tif (identifierName === 'optional') {\n\t\t\tconst value = findPropertyAssignmentValueNode(node)\n\t\t\treturn value.getKind() === SyntaxKind.TrueKeyword\n\t\t}\n\t\treturn false\n\t})\n}\n\nexport const getValidatorPropertyStringValue = (\n\tnodeOrReference: Node,\n\tname: 'description' | 'errorMessage',\n): string => {\n\tconst node = findNodeImplementation(nodeOrReference)\n\n\tconst callExpressionNode = node.asKind(SyntaxKind.CallExpression)\n\tif (callExpressionNode) {\n\t\tconst targetChild = callExpressionNode.getLastChildByKind(SyntaxKind.SyntaxList)!\n\t\treturn getValidatorPropertyStringValue(targetChild, name)\n\t}\n\n\tconst syntaxListNode = node.asKind(SyntaxKind.SyntaxList)\n\tif (syntaxListNode) {\n\t\tconst children = syntaxListNode.getChildren().map((c) => getValidatorPropertyStringValue(c, name))\n\t\treturn children.find((value) => !!value && value !== 'unknown_25') || ''\n\t}\n\n\tconst objectLiteralNode = node.asKind(SyntaxKind.ObjectLiteralExpression)\n\tif (objectLiteralNode) {\n\t\tconst values = getValuesOfObjectLiteral(objectLiteralNode)\n\t\tconst targetValue = values.find((value) => value.identifier === name)\n\t\tif (!targetValue) {\n\t\t\treturn ''\n\t\t}\n\t\tif (Array.isArray(targetValue.value)) {\n\t\t\treturn 'array'\n\t\t}\n\t\treturn targetValue.value || ''\n\t}\n\n\tconst intersectionTypeNode = node.asKind(SyntaxKind.IntersectionType)\n\tif (intersectionTypeNode) {\n\t\treturn (\n\t\t\tintersectionTypeNode\n\t\t\t\t.getTypeNodes()\n\t\t\t\t.flatMap((t) => getValidatorPropertyStringValue(t, name))\n\t\t\t\t.filter((v) => !!v && v !== 'unknown_25')[0] || 'unknown_27'\n\t\t)\n\t}\n\n\tconst typeLiteralNode = node.asKind(SyntaxKind.TypeLiteral)\n\tif (typeLiteralNode) {\n\t\treturn getValidatorPropertyStringValue(typeLiteralNode.getFirstChildByKind(SyntaxKind.SyntaxList)!, name)\n\t}\n\n\tconst propertySignatureNode = node.asKind(SyntaxKind.PropertySignature)\n\tif (propertySignatureNode) {\n\t\tconst identifier = node.getFirstDescendantByKind(SyntaxKind.Identifier)!\n\t\tif (identifier.getText() === name) {\n\t\t\tconst targetNode = findPropertyAssignmentValueNode(propertySignatureNode).getFirstDescendantByKind(\n\t\t\t\tSyntaxKind.StringLiteral,\n\t\t\t)!\n\t\t\treturn targetNode.getLiteralText()\n\t\t}\n\t}\n\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.dev(`[${fileName}] Unknown property string value node ${node.getKindName()}`)\n\treturn 'unknown_25'\n}\n\nconst isPromise = (type: Type) => {\n\tconst symbol = type.getSymbol()\n\tif (!type.isObject() || !symbol) {\n\t\treturn false\n\t}\n\tconst args = type.getTypeArguments()\n\treturn symbol.getName() === 'Promise' && args.length === 1\n}\n\nexport const getProperTypeShape = (\n\ttypeOrPromise: Type,\n\tatLocation: Node,\n\tstack: Type[] = [],\n): ShapeOfType['shape'] => {\n\tconst typeName = typeOrPromise.getAliasSymbol()?.getName()\n\tif (typeName && OpenApiManager.getInstance().hasExposedModel(typeName)) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'ref',\n\t\t\t\tshape: typeName,\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tconst type = isPromise(typeOrPromise) ? typeOrPromise.getTypeArguments()[0] : typeOrPromise\n\n\tif (stack.some((previousType) => previousType === type)) {\n\t\treturn 'circular'\n\t}\n\n\tconst nextStack = stack.concat(type)\n\n\tif (type.getText() === 'void') {\n\t\treturn 'void'\n\t}\n\n\tif (type.isAny()) {\n\t\treturn 'any'\n\t}\n\n\tif (type.isNull()) {\n\t\treturn 'null'\n\t}\n\n\tif (type.isUndefined()) {\n\t\treturn 'undefined'\n\t}\n\n\tif (type.isBoolean() || type.isBooleanLiteral()) {\n\t\treturn 'boolean'\n\t}\n\n\tif (type.isStringLiteral()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'literal_string' as const,\n\t\t\t\tshape: String(type.getLiteralValue()!),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isNumberLiteral()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'literal_number' as const,\n\t\t\t\tshape: String(type.getLiteralValue()!),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isString() || type.isTemplateLiteral()) {\n\t\treturn 'string'\n\t}\n\n\tif (type.isNumber()) {\n\t\treturn 'number'\n\t}\n\n\tif (type.getText() === 'bigint') {\n\t\treturn 'bigint'\n\t}\n\n\tif (type.isTuple()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'tuple' as const,\n\t\t\t\tshape: type.getTupleElements().map((t) => ({\n\t\t\t\t\trole: 'tuple_entry' as const,\n\t\t\t\t\tshape: getProperTypeShape(t, atLocation, nextStack),\n\t\t\t\t\toptional: false,\n\t\t\t\t})),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isArray()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'array' as const,\n\t\t\t\tshape: getProperTypeShape(type.getArrayElementType()!, atLocation, nextStack),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isObject() && type.getText() === 'Buffer') {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'buffer' as const,\n\t\t\t\tshape: 'buffer',\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isObject() && type.getProperties().length === 0) {\n\t\tconst targetType = type.getAliasTypeArguments()[1]\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'record' as const,\n\t\t\t\tshape: getProperTypeShape(targetType, atLocation, nextStack),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isObject()) {\n\t\tif (type.getText() === 'Date') {\n\t\t\treturn 'Date'\n\t\t}\n\t\treturn type\n\t\t\t.getProperties()\n\t\t\t.map((prop) => {\n\t\t\t\tconst valueDeclaration = prop.getValueDeclaration() || prop.getDeclarations()[0]!\n\t\t\t\tif (!valueDeclaration) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: 'property' as const,\n\t\t\t\t\t\tidentifier: prop.getName(),\n\t\t\t\t\t\tshape: getProperTypeShape(prop.getTypeAtLocation(atLocation), atLocation, nextStack),\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst valueDeclarationNode =\n\t\t\t\t\tvalueDeclaration.asKind(SyntaxKind.PropertySignature) ||\n\t\t\t\t\tvalueDeclaration.asKind(SyntaxKind.PropertyAssignment) ||\n\t\t\t\t\tvalueDeclaration.asKind(SyntaxKind.ShorthandPropertyAssignment)\n\n\t\t\t\tif (!valueDeclarationNode) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: 'property' as const,\n\t\t\t\t\t\tidentifier: prop.getName(),\n\t\t\t\t\t\tshape: getProperTypeShape(prop.getTypeAtLocation(atLocation), atLocation, nextStack),\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst isOptional = prop.getTypeAtLocation(atLocation).isNullable()\n\n\t\t\t\tconst shape = getProperTypeShape(prop.getTypeAtLocation(atLocation), atLocation, nextStack)\n\t\t\t\treturn {\n\t\t\t\t\trole: 'property' as const,\n\t\t\t\t\tidentifier: prop.getName(),\n\t\t\t\t\tshape: shape,\n\t\t\t\t\toptional: isOptional,\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter((val) => val.shape !== 'undefined')\n\t}\n\n\tif (type.isUnion()) {\n\t\tconst unfilteredShapes: ShapeOfUnionEntry[] = type.getUnionTypes().map((type) => ({\n\t\t\trole: 'union_entry',\n\t\t\tshape: getProperTypeShape(type, atLocation, nextStack),\n\t\t\toptional: false,\n\t\t}))\n\n\t\tconst dedupedShapes = unfilteredShapes.filter(\n\t\t\t(type, index, arr) => !arr.find((dup, dupIndex) => dup.shape === type.shape && dupIndex > index),\n\t\t)\n\t\tconst isNullable = dedupedShapes.some((shape) => shape.shape === 'undefined')\n\t\tconst shapes = dedupedShapes.filter((shape) => shape.shape !== 'undefined')\n\t\tif (shapes.length === 1) {\n\t\t\treturn shapes[0].shape\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'union',\n\t\t\t\tshape: shapes,\n\t\t\t\toptional: isNullable,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isIntersection()) {\n\t\tconst children = type.getIntersectionTypes()\n\t\tconst shapesOfChildren = children\n\t\t\t.map((child) => getProperTypeShape(child, atLocation, nextStack))\n\t\t\t.filter((shape) => typeof shape !== 'string') as ShapeOfProperty[][]\n\t\treturn shapesOfChildren.reduce<ShapeOfType[]>((total, current) => [...total, ...current], [])\n\t}\n\n\tconst fileName = atLocation.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown type shape node ${typeOrPromise.getText()}`)\n\treturn 'unknown_5'\n}\n\nconst getLiteralValueOfNode = (node: Node): string | string[] | unknown[] => {\n\tif (node.isKind(SyntaxKind.Identifier)) {\n\t\treturn getLiteralValueOfNode(findNodeImplementation(node))\n\t} else if (node.isKind(SyntaxKind.StringLiteral)) {\n\t\treturn node.getLiteralValue()\n\t} else if (node.isKind(SyntaxKind.ArrayLiteralExpression)) {\n\t\treturn node.forEachChildAsArray().map((child) => getLiteralValueOfNode(child)) as string[]\n\t} else if (node.isKind(SyntaxKind.PropertyAccessExpression)) {\n\t\treturn getLiteralValueOfNode(findPropertyAssignmentValueNode(node))\n\t} else if (node.isKind(SyntaxKind.ObjectLiteralExpression)) {\n\t\treturn getValuesOfObjectLiteral(node)\n\t}\n\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.dev(`[${fileName}] Unknown literal value node ${node.getKindName()}`)\n\n\treturn 'unknown_6'\n}\n\nexport const getValuesOfObjectLiteral = (objectLiteralNode: Node<ts.ObjectLiteralExpression>) => {\n\tconst syntaxListNode = objectLiteralNode.getFirstDescendantByKind(SyntaxKind.SyntaxList)!\n\tconst assignmentNodes = syntaxListNode.getChildrenOfKind(SyntaxKind.PropertyAssignment)!\n\n\tconst properties = assignmentNodes.map((node) => {\n\t\tconst identifierNode = node.getFirstDescendantByKind(SyntaxKind.Identifier)!\n\t\tconst identifierName = identifierNode.getText()\n\n\t\tconst assignmentValueNode = node.getLastChild()!\n\t\tconst targetNode = findNodeImplementation(assignmentValueNode)\n\t\tconst value = getLiteralValueOfNode(targetNode)\n\n\t\treturn {\n\t\t\tidentifier: identifierName,\n\t\t\tvalue,\n\t\t}\n\t})\n\n\treturn properties || []\n}\n"],"names":["implementationCache","findNodeImplementation","node","cached","SyntaxKind","implementationNode","assignmentValueNode","result","definitionNode","findPropertyAssignmentValueNode","identifierChildren","child","getTypeReferenceShape","firstChild","getRecursiveNodeShape","nodeOrReference","typeName","OpenApiManager","literalNode","typeLiteralNode","propNode","identifier","valueNode","questionMarkToken","typeReferenceNode","lastChild","getProperTypeShape","unionTypeNode","typeQueryNode","qualifiedNameNode","callExpressionNode","awaitExpressionNode","asExpressionNode","fileName","Logger","getShapeOfValidatorLiteral","objectLiteralNode","identifierNode","identifierName","innerLiteralNode","getValidatorPropertyShape","getValidatorPropertyOptionality","getValidatorPropertyStringValue","inlineValidatorAsExpression","typeReference","childTypeReferenceNode","typeNode","childCallExpressionNode","callExpressionArgument","thingyNode","parsePropertyAssignment","prop","returnType","importTypeNode","indexOfGreaterThanToken","targetSyntaxList","intersectionType","validatorType","syntaxListNode","literalExpression","name","targetChild","c","value","targetValue","getValuesOfObjectLiteral","intersectionTypeNode","t","v","propertySignatureNode","isPromise","type","symbol","args","typeOrPromise","atLocation","stack","previousType","nextStack","targetType","valueDeclaration","isOptional","shape","val","dedupedShapes","index","arr","dup","dupIndex","isNullable","shapes","total","current","getLiteralValueOfNode","targetNode"],"mappings":";;;AAgBA,MAAMA,wBAA0B,QAAoB,GAEvCC,IAAyB,CAACC,MAAqB;AACrD,QAAAC,IAASH,EAAoB,IAAIE,CAAI;AAC3C,MAAIC;AACI,WAAAA;AAGR,MAAID,EAAK,cAAcE,EAAW,YAAY;AAC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|
|
1
|
+
{"version":3,"file":"nodeParsers.mjs","sources":["../../../src/openapi/analyzerModule/nodeParsers.ts"],"sourcesContent":["import {\n\tNode,\n\tPropertyAccessExpression,\n\tPropertyAssignment,\n\tPropertySignature,\n\tShorthandPropertyAssignment,\n\tSyntaxKind,\n\tts,\n\tType,\n\tTypeReferenceNode,\n} from 'ts-morph'\n\nimport { Logger } from '../../utils/logger'\nimport { OpenApiManager } from '../manager/OpenApiManager'\nimport { ShapeOfProperty, ShapeOfType, ShapeOfUnionEntry } from './types'\n\nconst implementationCache = new WeakMap<Node, Node>()\n\nexport const findNodeImplementation = (node: Node): Node => {\n\tconst cached = implementationCache.get(node)\n\tif (cached) {\n\t\treturn cached\n\t}\n\n\tif (node.getKind() === SyntaxKind.Identifier) {\n\t\tconst implementationNode = node.asKind(SyntaxKind.Identifier)!.getImplementations()[0]?.getNode()\n\t\tif (implementationNode) {\n\t\t\tconst implementationParentNode = implementationNode.getParent()!\n\t\t\tconst assignmentValueNode = implementationParentNode.getLastChild()!\n\t\t\tif (assignmentValueNode === node) {\n\t\t\t\tthrow new Error('Recursive implementation found')\n\t\t\t}\n\t\t\tconst result = findNodeImplementation(assignmentValueNode)\n\t\t\timplementationCache.set(node, result)\n\t\t\treturn result\n\t\t}\n\n\t\tconst definitionNode = node.asKind(SyntaxKind.Identifier)!.getDefinitions()[0]?.getNode()\n\t\tif (definitionNode) {\n\t\t\tconst definitionParentNode = definitionNode.getParent()!\n\t\t\tconst assignmentValueNode = definitionParentNode.getLastChild()!\n\t\t\tif (assignmentValueNode === node) {\n\t\t\t\tthrow new Error('Recursive implementation found')\n\t\t\t}\n\t\t\tconst result = findNodeImplementation(assignmentValueNode)\n\t\t\timplementationCache.set(node, result)\n\t\t\treturn result\n\t\t}\n\t\tthrow new Error('No implementation nor definition available')\n\t}\n\n\timplementationCache.set(node, node)\n\treturn node\n}\n\nexport const findPropertyAssignmentValueNode = (\n\tnode:\n\t\t| PropertyAssignment\n\t\t| TypeReferenceNode\n\t\t| PropertySignature\n\t\t| PropertyAccessExpression\n\t\t| ShorthandPropertyAssignment,\n): Node => {\n\tconst identifierChildren = node.getChildrenOfKind(SyntaxKind.Identifier)\n\tif (identifierChildren.length === 2) {\n\t\treturn findNodeImplementation(identifierChildren[1])\n\t}\n\tconst lastMatchingChild = node.getChildren().reverse()\n\treturn lastMatchingChild.find(\n\t\t(child) =>\n\t\t\tchild.getKind() !== SyntaxKind.GreaterThanToken &&\n\t\t\tchild.getKind() !== SyntaxKind.CommaToken &&\n\t\t\tchild.getKind() !== SyntaxKind.SemicolonToken,\n\t)!\n}\n\nexport const getTypeReferenceShape = (node: TypeReferenceNode): ShapeOfType['shape'] => {\n\tconst firstChild = node.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\tif (firstChild.isKind(SyntaxKind.SyntaxList)) {\n\t\treturn getRecursiveNodeShape(firstChild.getFirstChild()!)\n\t} else {\n\t\treturn getRecursiveNodeShape(firstChild)\n\t}\n}\n\nexport const getRecursiveNodeShape = (nodeOrReference: Node): ShapeOfType['shape'] => {\n\tconst typeName = nodeOrReference.getSymbol()?.getName()\n\tif (typeName && OpenApiManager.getInstance().hasExposedModel(typeName)) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'ref',\n\t\t\t\tshape: typeName,\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tconst node = findNodeImplementation(nodeOrReference)\n\n\t// Undefined\n\tconst undefinedNode = node.asKind(SyntaxKind.UndefinedKeyword)\n\tif (undefinedNode) {\n\t\treturn 'undefined'\n\t}\n\n\t// Literal type\n\tconst literalNode = node.asKind(SyntaxKind.LiteralType)\n\tif (literalNode) {\n\t\tif (literalNode.getFirstChildByKind(SyntaxKind.TrueKeyword)) {\n\t\t\treturn 'true'\n\t\t}\n\t\tif (literalNode.getFirstChildByKind(SyntaxKind.FalseKeyword)) {\n\t\t\treturn 'false'\n\t\t}\n\t}\n\n\t// Boolean literal\n\tconst booleanLiteralNode =\n\t\tnode.asKind(SyntaxKind.BooleanKeyword) ||\n\t\tnode.asKind(SyntaxKind.TrueKeyword) ||\n\t\tnode.asKind(SyntaxKind.FalseKeyword)\n\tif (booleanLiteralNode) {\n\t\treturn 'boolean'\n\t}\n\n\t// String literal\n\tconst stringLiteralNode = node.asKind(SyntaxKind.StringKeyword) || node.asKind(SyntaxKind.StringLiteral)\n\tif (stringLiteralNode) {\n\t\treturn 'string'\n\t}\n\n\t// Number literal\n\tconst numberLiteralNode = node.asKind(SyntaxKind.NumberKeyword) || node.asKind(SyntaxKind.NumericLiteral)\n\tif (numberLiteralNode) {\n\t\treturn 'number'\n\t}\n\n\t// BigInt literal\n\tconst bigIntNode = node.asKind(SyntaxKind.BigIntKeyword) || node.asKind(SyntaxKind.BigIntLiteral)\n\tif (bigIntNode) {\n\t\treturn 'bigint'\n\t}\n\n\t// Type literal\n\tconst typeLiteralNode = node.asKind(SyntaxKind.TypeLiteral)\n\tif (typeLiteralNode) {\n\t\tconst properties = typeLiteralNode\n\t\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t\t.getChildrenOfKind(SyntaxKind.PropertySignature)\n\n\t\tconst propertyShapes = properties.map((propNode) => {\n\t\t\tconst identifier = propNode.getFirstChildByKind(SyntaxKind.Identifier)!\n\t\t\tconst valueNode = findPropertyAssignmentValueNode(propNode)\n\t\t\tconst questionMarkToken = identifier.getNextSiblingIfKind(SyntaxKind.QuestionToken)\n\t\t\treturn {\n\t\t\t\trole: 'property' as const,\n\t\t\t\tidentifier: identifier.getText(),\n\t\t\t\tshape: getRecursiveNodeShape(valueNode),\n\t\t\t\toptional: valueNode.getType().isNullable() || !!questionMarkToken,\n\t\t\t}\n\t\t})\n\t\treturn propertyShapes\n\t}\n\n\t// Type reference\n\tconst typeReferenceNode = node.asKind(SyntaxKind.TypeReference)\n\tif (typeReferenceNode) {\n\t\treturn getRecursiveNodeShape(typeReferenceNode.getFirstChild()!)\n\t}\n\n\t// Property access expression\n\tconst propertyAccessNode = node.asKind(SyntaxKind.PropertyAccessExpression)\n\tif (propertyAccessNode) {\n\t\tconst lastChild = findNodeImplementation(node.getLastChild()!)\n\t\treturn getProperTypeShape(lastChild.asKind(SyntaxKind.CallExpression)!.getReturnType(), lastChild)\n\t}\n\n\t// Union type\n\tconst unionTypeNode = node.asKind(SyntaxKind.UnionType)\n\tif (unionTypeNode) {\n\t\treturn getProperTypeShape(unionTypeNode.getType(), node)\n\t}\n\n\t// Typeof query\n\tconst typeQueryNode = node.asKind(SyntaxKind.TypeQuery)\n\tif (typeQueryNode) {\n\t\treturn getRecursiveNodeShape(typeQueryNode.getLastChild()!)\n\t}\n\n\t// Qualified name\n\tconst qualifiedNameNode = node.asKind(SyntaxKind.QualifiedName)\n\tif (qualifiedNameNode) {\n\t\treturn getRecursiveNodeShape(qualifiedNameNode.getLastChild()!)\n\t}\n\n\t// Call expression\n\tconst callExpressionNode = node.asKind(SyntaxKind.CallExpression)\n\tif (callExpressionNode) {\n\t\treturn getProperTypeShape(callExpressionNode.getReturnType(), callExpressionNode)\n\t}\n\n\t// Await expression\n\tconst awaitExpressionNode = node.asKind(SyntaxKind.AwaitExpression)\n\tif (awaitExpressionNode) {\n\t\treturn getRecursiveNodeShape(awaitExpressionNode.getChildAtIndex(1)!)\n\t}\n\n\t// 'As' Expression\n\tconst asExpressionNode = node.asKind(SyntaxKind.AsExpression)\n\tif (asExpressionNode) {\n\t\treturn getRecursiveNodeShape(asExpressionNode.getChildAtIndex(2)!)\n\t}\n\n\t// TODO\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown node type: ${node.getKindName()}`)\n\treturn 'unknown_1'\n}\n\nexport const getShapeOfValidatorLiteral = (\n\tobjectLiteralNode: Node<ts.ObjectLiteralExpression>,\n): (ShapeOfProperty & { description: string; errorMessage: string })[] => {\n\tconst syntaxListNode = objectLiteralNode.getFirstDescendantByKind(SyntaxKind.SyntaxList)!\n\tconst assignmentNodes = syntaxListNode.getChildrenOfKind(SyntaxKind.PropertyAssignment)!\n\n\tconst properties = assignmentNodes.map((node) => {\n\t\tconst identifierNode = node.getFirstChild()!\n\t\tconst identifierName = (() => {\n\t\t\tif (identifierNode.isKind(SyntaxKind.Identifier)) {\n\t\t\t\treturn identifierNode.getText()\n\t\t\t}\n\t\t\tif (identifierNode.isKind(SyntaxKind.StringLiteral)) {\n\t\t\t\treturn identifierNode.getLiteralText()\n\t\t\t}\n\t\t\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\t\t\tLogger.warn(`[${fileName}] Unknown identifier name: ${identifierNode.getText()}`)\n\t\t\treturn 'unknown_30'\n\t\t})()\n\n\t\tconst assignmentValueNode = node.getLastChild()!\n\t\tconst innerLiteralNode = findNodeImplementation(assignmentValueNode)\n\n\t\treturn {\n\t\t\trole: 'property' as const,\n\t\t\tidentifier: identifierName,\n\t\t\tshape: getValidatorPropertyShape(innerLiteralNode),\n\t\t\toptional: getValidatorPropertyOptionality(innerLiteralNode),\n\t\t\tdescription: getValidatorPropertyStringValue(innerLiteralNode, 'description'),\n\t\t\terrorMessage: getValidatorPropertyStringValue(innerLiteralNode, 'errorMessage'),\n\t\t}\n\t})\n\n\treturn properties || []\n}\n\nconst isZodCallExpression = (node: Node): boolean => {\n\tconst callExpression = node.asKind(SyntaxKind.CallExpression)\n\tif (!callExpression) {\n\t\treturn false\n\t}\n\tconst returnType = callExpression.getReturnType()\n\tconst typeName = returnType.getSymbol()?.getName() ?? ''\n\treturn typeName.startsWith('Zod')\n}\n\nconst getZodCallShape = (node: Node): ShapeOfType['shape'] => {\n\tconst callExpression = node.asKind(SyntaxKind.CallExpression)!\n\tconst returnType = callExpression.getReturnType()\n\tconst typeName = returnType.getSymbol()?.getName() ?? ''\n\n\tif (typeName === 'ZodNumber') {\n\t\treturn 'number'\n\t}\n\tif (typeName === 'ZodString') {\n\t\treturn 'string'\n\t}\n\tif (typeName === 'ZodBoolean') {\n\t\treturn 'boolean'\n\t}\n\tif (typeName === 'ZodBigInt') {\n\t\treturn 'bigint'\n\t}\n\n\tif (typeName === 'ZodObject') {\n\t\tconst argNode = callExpression.getFirstChildByKind(SyntaxKind.SyntaxList)?.getFirstChild()\n\t\tconst objectLiteral = argNode?.asKind(SyntaxKind.ObjectLiteralExpression)\n\t\tif (!objectLiteral) {\n\t\t\treturn 'unknown_zod_object'\n\t\t}\n\t\tconst syntaxList = objectLiteral.getFirstChildByKind(SyntaxKind.SyntaxList)\n\t\tif (!syntaxList) {\n\t\t\treturn []\n\t\t}\n\t\tconst properties = syntaxList.getChildrenOfKind(SyntaxKind.PropertyAssignment)\n\t\treturn properties.map((prop) => {\n\t\t\tconst identifier = prop.getFirstChildByKind(SyntaxKind.Identifier)!.getText()\n\t\t\tconst valueNode = prop.getLastChild()!\n\t\t\treturn {\n\t\t\t\trole: 'property' as const,\n\t\t\t\tidentifier,\n\t\t\t\tshape: isZodCallExpression(valueNode)\n\t\t\t\t\t? getZodCallShape(valueNode)\n\t\t\t\t\t: getValidatorPropertyShape(valueNode),\n\t\t\t\toptional: false,\n\t\t\t}\n\t\t})\n\t}\n\n\tif (typeName === 'ZodArray') {\n\t\tconst argNode = callExpression.getFirstChildByKind(SyntaxKind.SyntaxList)?.getFirstChild()\n\t\tif (!argNode) {\n\t\t\treturn 'unknown_zod_array'\n\t\t}\n\t\tconst elementShape = isZodCallExpression(argNode)\n\t\t\t? getZodCallShape(argNode)\n\t\t\t: getValidatorPropertyShape(argNode)\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'array' as const,\n\t\t\t\tshape: elementShape,\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown zod type: ${typeName}`)\n\treturn 'unknown_zod'\n}\n\nexport const getValidatorPropertyShape = (innerLiteralNode: Node): ShapeOfType['shape'] => {\n\t// Zod validator (e.g. z.number(), z.string(), z.object({...}), z.array(...))\n\tif (isZodCallExpression(innerLiteralNode)) {\n\t\treturn getZodCallShape(innerLiteralNode)\n\t}\n\n\t// Inline definition with `as Validator<...>` clause\n\tconst inlineValidatorAsExpression = innerLiteralNode\n\t\t.getParent()!\n\t\t.getFirstChildByKind(SyntaxKind.AsExpression)\n\tif (inlineValidatorAsExpression) {\n\t\tconst typeReference = inlineValidatorAsExpression.getLastChildByKind(SyntaxKind.TypeReference)!\n\t\treturn getTypeReferenceShape(typeReference)\n\t}\n\n\t// Variable with `: Validator<...>` clause\n\tconst childTypeReferenceNode = innerLiteralNode.getParent()!.getFirstChildByKind(SyntaxKind.TypeReference)\n\tif (childTypeReferenceNode) {\n\t\treturn getTypeReferenceShape(childTypeReferenceNode)\n\t}\n\n\t// `RequiredParam<...>` inline call expression\n\tif (innerLiteralNode.getParent()!.getChildrenOfKind(SyntaxKind.SyntaxList).length >= 2) {\n\t\tconst typeNode = innerLiteralNode\n\t\t\t.getParent()!\n\t\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t\t.getFirstChild()!\n\t\treturn getRecursiveNodeShape(typeNode)\n\t}\n\n\t// `RequestParam | RequiredParam | OptionalParam` call expression\n\tconst childCallExpressionNode = innerLiteralNode.getParent()!.getFirstChildByKind(SyntaxKind.CallExpression)\n\tif (childCallExpressionNode) {\n\t\tconst callExpressionArgument = findNodeImplementation(\n\t\t\tchildCallExpressionNode.getFirstChildByKind(SyntaxKind.SyntaxList)!.getFirstChild()!,\n\t\t)\n\n\t\t// Param is a type reference\n\t\tconst typeReferenceNode = callExpressionArgument\n\t\t\t.getParent()!\n\t\t\t.getFirstChildByKind(SyntaxKind.TypeReference)!\n\t\tif (typeReferenceNode) {\n\t\t\treturn getProperTypeShape(typeReferenceNode.getType(), typeReferenceNode, [])\n\t\t}\n\n\t\tconst thingyNode = callExpressionArgument\n\t\t\t.getParent()!\n\t\t\t.getFirstChildByKind(SyntaxKind.ObjectLiteralExpression)!\n\t\tif (thingyNode) {\n\t\t\treturn getValidatorPropertyShape(thingyNode)\n\t\t}\n\n\t\tif (callExpressionArgument.getKind() === SyntaxKind.CallExpression) {\n\t\t\treturn getValidatorPropertyShape(callExpressionArgument)\n\t\t}\n\n\t\tif (callExpressionArgument.getKind() === SyntaxKind.IntersectionType) {\n\t\t\treturn getValidatorPropertyShape(callExpressionArgument)\n\t\t}\n\n\t\tconst fileName = innerLiteralNode.getSourceFile().getFilePath().split('/').pop()\n\t\tLogger.warn(`[${fileName}] Unknown call expression argument: ${callExpressionArgument.getKindName()}`)\n\t\treturn 'unknown_3'\n\t}\n\n\t// Attempting to infer type from `parse` function\n\tconst innerNodePropertyAssignments = innerLiteralNode\n\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t.getChildrenOfKind(SyntaxKind.PropertyAssignment)\n\tconst parsePropertyAssignment = innerNodePropertyAssignments.find((prop) => {\n\t\treturn prop.getFirstChildByKind(SyntaxKind.Identifier)?.getText() === 'parse'\n\t})\n\tif (parsePropertyAssignment) {\n\t\tconst returnType = findPropertyAssignmentValueNode(parsePropertyAssignment)\n\t\t\t.asKind(SyntaxKind.ArrowFunction)!\n\t\t\t.getReturnType()\n\t\treturn getProperTypeShape(returnType, parsePropertyAssignment)\n\t}\n\n\t// Import statement\n\tconst importTypeNode = innerLiteralNode\n\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)\n\t\t?.getFirstChildByKind(SyntaxKind.ImportType)\n\tif (importTypeNode) {\n\t\tconst indexOfGreaterThanToken = importTypeNode\n\t\t\t.getLastChildByKind(SyntaxKind.GreaterThanToken)!\n\t\t\t.getChildIndex()\n\t\tconst targetSyntaxList = importTypeNode.getChildAtIndex(indexOfGreaterThanToken - 1)\n\t\treturn getRecursiveNodeShape(targetSyntaxList.getFirstChild()!)\n\t}\n\n\t// Intersection type with Validator\n\tconst intersectionType = innerLiteralNode.isKind(SyntaxKind.IntersectionType)\n\t\t? innerLiteralNode\n\t\t: innerLiteralNode.getParent()?.isKind(SyntaxKind.VariableDeclaration)\n\t\t\t? innerLiteralNode.getParent()?.getFirstChildByKind(SyntaxKind.IntersectionType)\n\t\t\t: null\n\n\tif (intersectionType) {\n\t\tconst validatorType = intersectionType.getFirstChildByKind(SyntaxKind.TypeReference)\n\t\tif (validatorType) {\n\t\t\treturn getTypeReferenceShape(validatorType)\n\t\t}\n\t}\n\n\tconst fileName = innerLiteralNode.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown import type node`)\n\n\treturn 'unknown_2'\n}\n\nexport const getValidatorPropertyOptionality = (node: Node): boolean => {\n\tif (isZodCallExpression(node)) {\n\t\treturn false\n\t}\n\n\tconst callExpressionNode = node.asKind(SyntaxKind.CallExpression)\n\tif (callExpressionNode) {\n\t\tconst identifierNode = callExpressionNode.getFirstChildByKind(SyntaxKind.Identifier)\n\t\tif (identifierNode?.getText() === 'OptionalParam') {\n\t\t\treturn true\n\t\t} else if (identifierNode?.getText() === 'RequiredParam') {\n\t\t\treturn false\n\t\t}\n\n\t\tconst syntaxListNode = callExpressionNode.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\tconst literalExpression = findNodeImplementation(syntaxListNode.getFirstChild()!)\n\t\treturn getValidatorPropertyOptionality(literalExpression)\n\t}\n\n\tconst syntaxListNode = node.getFirstDescendantByKind(SyntaxKind.SyntaxList)!\n\tconst assignmentNodes = syntaxListNode.getChildrenOfKind(SyntaxKind.PropertyAssignment)!\n\n\treturn assignmentNodes.some((node) => {\n\t\tconst identifierNode = node.getFirstDescendantByKind(SyntaxKind.Identifier)!\n\t\tconst identifierName = identifierNode.getText()\n\n\t\tif (identifierName === 'optional') {\n\t\t\tconst value = findPropertyAssignmentValueNode(node)\n\t\t\treturn value.getKind() === SyntaxKind.TrueKeyword\n\t\t}\n\t\treturn false\n\t})\n}\n\nexport const getValidatorPropertyStringValue = (\n\tnodeOrReference: Node,\n\tname: 'description' | 'errorMessage',\n): string => {\n\tif (isZodCallExpression(nodeOrReference)) {\n\t\treturn ''\n\t}\n\n\tconst node = findNodeImplementation(nodeOrReference)\n\n\tconst callExpressionNode = node.asKind(SyntaxKind.CallExpression)\n\tif (callExpressionNode) {\n\t\tconst targetChild = callExpressionNode.getLastChildByKind(SyntaxKind.SyntaxList)!\n\t\treturn getValidatorPropertyStringValue(targetChild, name)\n\t}\n\n\tconst syntaxListNode = node.asKind(SyntaxKind.SyntaxList)\n\tif (syntaxListNode) {\n\t\tconst children = syntaxListNode.getChildren().map((c) => getValidatorPropertyStringValue(c, name))\n\t\treturn children.find((value) => !!value && value !== 'unknown_25') || ''\n\t}\n\n\tconst objectLiteralNode = node.asKind(SyntaxKind.ObjectLiteralExpression)\n\tif (objectLiteralNode) {\n\t\tconst values = getValuesOfObjectLiteral(objectLiteralNode)\n\t\tconst targetValue = values.find((value) => value.identifier === name)\n\t\tif (!targetValue) {\n\t\t\treturn ''\n\t\t}\n\t\tif (Array.isArray(targetValue.value)) {\n\t\t\treturn 'array'\n\t\t}\n\t\treturn targetValue.value || ''\n\t}\n\n\tconst intersectionTypeNode = node.asKind(SyntaxKind.IntersectionType)\n\tif (intersectionTypeNode) {\n\t\treturn (\n\t\t\tintersectionTypeNode\n\t\t\t\t.getTypeNodes()\n\t\t\t\t.flatMap((t) => getValidatorPropertyStringValue(t, name))\n\t\t\t\t.filter((v) => !!v && v !== 'unknown_25')[0] || 'unknown_27'\n\t\t)\n\t}\n\n\tconst typeLiteralNode = node.asKind(SyntaxKind.TypeLiteral)\n\tif (typeLiteralNode) {\n\t\treturn getValidatorPropertyStringValue(typeLiteralNode.getFirstChildByKind(SyntaxKind.SyntaxList)!, name)\n\t}\n\n\tconst propertySignatureNode = node.asKind(SyntaxKind.PropertySignature)\n\tif (propertySignatureNode) {\n\t\tconst identifier = node.getFirstDescendantByKind(SyntaxKind.Identifier)!\n\t\tif (identifier.getText() === name) {\n\t\t\tconst targetNode = findPropertyAssignmentValueNode(propertySignatureNode).getFirstDescendantByKind(\n\t\t\t\tSyntaxKind.StringLiteral,\n\t\t\t)!\n\t\t\treturn targetNode.getLiteralText()\n\t\t}\n\t}\n\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.dev(`[${fileName}] Unknown property string value node ${node.getKindName()}`)\n\treturn 'unknown_25'\n}\n\nconst isPromise = (type: Type) => {\n\tconst symbol = type.getSymbol()\n\tif (!type.isObject() || !symbol) {\n\t\treturn false\n\t}\n\tconst args = type.getTypeArguments()\n\treturn symbol.getName() === 'Promise' && args.length === 1\n}\n\nexport const getProperTypeShape = (\n\ttypeOrPromise: Type,\n\tatLocation: Node,\n\tstack: Type[] = [],\n): ShapeOfType['shape'] => {\n\tconst typeName = typeOrPromise.getAliasSymbol()?.getName()\n\tif (typeName && OpenApiManager.getInstance().hasExposedModel(typeName)) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'ref',\n\t\t\t\tshape: typeName,\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tconst type = isPromise(typeOrPromise) ? typeOrPromise.getTypeArguments()[0] : typeOrPromise\n\n\tif (stack.some((previousType) => previousType === type)) {\n\t\treturn 'circular'\n\t}\n\n\tconst nextStack = stack.concat(type)\n\n\tif (type.getText() === 'void') {\n\t\treturn 'void'\n\t}\n\n\tif (type.isAny()) {\n\t\treturn 'any'\n\t}\n\n\tif (type.isNull()) {\n\t\treturn 'null'\n\t}\n\n\tif (type.isUndefined()) {\n\t\treturn 'undefined'\n\t}\n\n\tif (type.isBoolean() || type.isBooleanLiteral()) {\n\t\treturn 'boolean'\n\t}\n\n\tif (type.isStringLiteral()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'literal_string' as const,\n\t\t\t\tshape: String(type.getLiteralValue()!),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isNumberLiteral()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'literal_number' as const,\n\t\t\t\tshape: String(type.getLiteralValue()!),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isString() || type.isTemplateLiteral()) {\n\t\treturn 'string'\n\t}\n\n\tif (type.isNumber()) {\n\t\treturn 'number'\n\t}\n\n\tif (type.getText() === 'bigint') {\n\t\treturn 'bigint'\n\t}\n\n\tif (type.isTuple()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'tuple' as const,\n\t\t\t\tshape: type.getTupleElements().map((t) => ({\n\t\t\t\t\trole: 'tuple_entry' as const,\n\t\t\t\t\tshape: getProperTypeShape(t, atLocation, nextStack),\n\t\t\t\t\toptional: false,\n\t\t\t\t})),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isArray()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'array' as const,\n\t\t\t\tshape: getProperTypeShape(type.getArrayElementType()!, atLocation, nextStack),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isObject() && type.getText() === 'Buffer') {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'buffer' as const,\n\t\t\t\tshape: 'buffer',\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isObject() && type.getProperties().length === 0) {\n\t\tconst targetType = type.getAliasTypeArguments()[1] ?? type.getStringIndexType()\n\t\tif (targetType) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\trole: 'record' as const,\n\t\t\t\t\tshape: getProperTypeShape(targetType, atLocation, nextStack),\n\t\t\t\t\toptional: false,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t}\n\n\tif (type.isObject()) {\n\t\tif (type.getText() === 'Date') {\n\t\t\treturn 'Date'\n\t\t}\n\t\treturn type\n\t\t\t.getProperties()\n\t\t\t.map((prop) => {\n\t\t\t\tconst valueDeclaration = prop.getValueDeclaration() || prop.getDeclarations()[0]!\n\t\t\t\tif (!valueDeclaration) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: 'property' as const,\n\t\t\t\t\t\tidentifier: prop.getName(),\n\t\t\t\t\t\tshape: getProperTypeShape(prop.getTypeAtLocation(atLocation), atLocation, nextStack),\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst valueDeclarationNode =\n\t\t\t\t\tvalueDeclaration.asKind(SyntaxKind.PropertySignature) ||\n\t\t\t\t\tvalueDeclaration.asKind(SyntaxKind.PropertyAssignment) ||\n\t\t\t\t\tvalueDeclaration.asKind(SyntaxKind.ShorthandPropertyAssignment)\n\n\t\t\t\tif (!valueDeclarationNode) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: 'property' as const,\n\t\t\t\t\t\tidentifier: prop.getName(),\n\t\t\t\t\t\tshape: getProperTypeShape(prop.getTypeAtLocation(atLocation), atLocation, nextStack),\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst isOptional = prop.getTypeAtLocation(atLocation).isNullable()\n\n\t\t\t\tconst shape = getProperTypeShape(prop.getTypeAtLocation(atLocation), atLocation, nextStack)\n\t\t\t\treturn {\n\t\t\t\t\trole: 'property' as const,\n\t\t\t\t\tidentifier: prop.getName(),\n\t\t\t\t\tshape: shape,\n\t\t\t\t\toptional: isOptional,\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter((val) => val.shape !== 'undefined')\n\t}\n\n\tif (type.isUnion()) {\n\t\tconst unfilteredShapes: ShapeOfUnionEntry[] = type.getUnionTypes().map((type) => ({\n\t\t\trole: 'union_entry',\n\t\t\tshape: getProperTypeShape(type, atLocation, nextStack),\n\t\t\toptional: false,\n\t\t}))\n\n\t\tconst dedupedShapes = unfilteredShapes.filter(\n\t\t\t(type, index, arr) => !arr.find((dup, dupIndex) => dup.shape === type.shape && dupIndex > index),\n\t\t)\n\t\tconst isNullable = dedupedShapes.some((shape) => shape.shape === 'undefined')\n\t\tconst shapes = dedupedShapes.filter((shape) => shape.shape !== 'undefined')\n\t\tif (shapes.length === 1) {\n\t\t\treturn shapes[0].shape\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'union',\n\t\t\t\tshape: shapes,\n\t\t\t\toptional: isNullable,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isIntersection()) {\n\t\tconst children = type.getIntersectionTypes()\n\t\tconst shapesOfChildren = children\n\t\t\t.map((child) => getProperTypeShape(child, atLocation, nextStack))\n\t\t\t.filter((shape) => typeof shape !== 'string') as ShapeOfProperty[][]\n\t\treturn shapesOfChildren.reduce<ShapeOfType[]>((total, current) => [...total, ...current], [])\n\t}\n\n\tconst fileName = atLocation.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown type shape node ${typeOrPromise.getText()}`)\n\treturn 'unknown_5'\n}\n\nconst getLiteralValueOfNode = (node: Node): string | string[] | unknown[] => {\n\tif (node.isKind(SyntaxKind.Identifier)) {\n\t\treturn getLiteralValueOfNode(findNodeImplementation(node))\n\t} else if (node.isKind(SyntaxKind.StringLiteral)) {\n\t\treturn node.getLiteralValue()\n\t} else if (node.isKind(SyntaxKind.ArrayLiteralExpression)) {\n\t\treturn node.forEachChildAsArray().map((child) => getLiteralValueOfNode(child)) as string[]\n\t} else if (node.isKind(SyntaxKind.PropertyAccessExpression)) {\n\t\treturn getLiteralValueOfNode(findPropertyAssignmentValueNode(node))\n\t} else if (node.isKind(SyntaxKind.ObjectLiteralExpression)) {\n\t\treturn getValuesOfObjectLiteral(node)\n\t}\n\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.dev(`[${fileName}] Unknown literal value node ${node.getKindName()}`)\n\n\treturn 'unknown_6'\n}\n\nexport const resolveEndpointPath = (node: Node): string | null => {\n\tconst callExpression = node.getFirstDescendantByKind(SyntaxKind.CallExpression)\n\tif (!callExpression) return null\n\n\tconst firstArg = callExpression.getArguments()[0]\n\tif (!firstArg) return null\n\n\tconst argType = firstArg.getType()\n\tif (argType.isStringLiteral()) {\n\t\treturn argType.getLiteralValue() as string\n\t}\n\n\treturn null\n}\n\nexport const getValuesOfObjectLiteral = (objectLiteralNode: Node<ts.ObjectLiteralExpression>) => {\n\tconst syntaxListNode = objectLiteralNode.getFirstDescendantByKind(SyntaxKind.SyntaxList)!\n\tconst assignmentNodes = syntaxListNode.getChildrenOfKind(SyntaxKind.PropertyAssignment)!\n\n\tconst properties = assignmentNodes.map((node) => {\n\t\tconst identifierNode = node.getFirstDescendantByKind(SyntaxKind.Identifier)!\n\t\tconst identifierName = identifierNode.getText()\n\n\t\tconst assignmentValueNode = node.getLastChild()!\n\t\tconst targetNode = findNodeImplementation(assignmentValueNode)\n\t\tconst value = getLiteralValueOfNode(targetNode)\n\n\t\treturn {\n\t\t\tidentifier: identifierName,\n\t\t\tvalue,\n\t\t}\n\t})\n\n\treturn properties || []\n}\n"],"names":["implementationCache","findNodeImplementation","node","cached","SyntaxKind","implementationNode","assignmentValueNode","result","definitionNode","findPropertyAssignmentValueNode","identifierChildren","child","getTypeReferenceShape","firstChild","getRecursiveNodeShape","nodeOrReference","typeName","OpenApiManager","literalNode","typeLiteralNode","propNode","identifier","valueNode","questionMarkToken","typeReferenceNode","lastChild","getProperTypeShape","unionTypeNode","typeQueryNode","qualifiedNameNode","callExpressionNode","awaitExpressionNode","asExpressionNode","fileName","Logger","getShapeOfValidatorLiteral","objectLiteralNode","identifierNode","identifierName","innerLiteralNode","getValidatorPropertyShape","getValidatorPropertyOptionality","getValidatorPropertyStringValue","isZodCallExpression","callExpression","getZodCallShape","objectLiteral","syntaxList","prop","argNode","inlineValidatorAsExpression","typeReference","childTypeReferenceNode","typeNode","childCallExpressionNode","callExpressionArgument","thingyNode","parsePropertyAssignment","returnType","importTypeNode","indexOfGreaterThanToken","targetSyntaxList","intersectionType","validatorType","syntaxListNode","literalExpression","name","targetChild","c","value","targetValue","getValuesOfObjectLiteral","intersectionTypeNode","t","v","propertySignatureNode","isPromise","type","symbol","args","typeOrPromise","atLocation","stack","previousType","nextStack","targetType","valueDeclaration","isOptional","shape","val","dedupedShapes","index","arr","dup","dupIndex","isNullable","shapes","total","current","getLiteralValueOfNode","resolveEndpointPath","firstArg","argType","targetNode"],"mappings":";;;AAgBA,MAAMA,wBAA0B,QAAoB,GAEvCC,IAAyB,CAACC,MAAqB;AACrD,QAAAC,IAASH,EAAoB,IAAIE,CAAI;AAC3C,MAAIC;AACI,WAAAA;AAGR,MAAID,EAAK,cAAcE,EAAW,YAAY;AACvC,UAAAC,IAAqBH,EAAK,OAAOE,EAAW,UAAU,EAAG,mBAAmB,EAAE,CAAC,GAAG,QAAQ;AAChG,QAAIC,GAAoB;AAEjB,YAAAC,IAD2BD,EAAmB,UAAU,EACT,aAAa;AAClE,UAAIC,MAAwBJ;AACrB,cAAA,IAAI,MAAM,gCAAgC;AAE3C,YAAAK,IAASN,EAAuBK,CAAmB;AACrC,aAAAN,EAAA,IAAIE,GAAMK,CAAM,GAC7BA;AAAA,IAAA;AAGF,UAAAC,IAAiBN,EAAK,OAAOE,EAAW,UAAU,EAAG,eAAe,EAAE,CAAC,GAAG,QAAQ;AACxF,QAAII,GAAgB;AAEb,YAAAF,IADuBE,EAAe,UAAU,EACL,aAAa;AAC9D,UAAIF,MAAwBJ;AACrB,cAAA,IAAI,MAAM,gCAAgC;AAE3C,YAAAK,IAASN,EAAuBK,CAAmB;AACrC,aAAAN,EAAA,IAAIE,GAAMK,CAAM,GAC7BA;AAAA,IAAA;AAEF,UAAA,IAAI,MAAM,4CAA4C;AAAA,EAAA;AAGzC,SAAAP,EAAA,IAAIE,GAAMA,CAAI,GAC3BA;AACR,GAEaO,IAAkC,CAC9CP,MAMU;AACV,QAAMQ,IAAqBR,EAAK,kBAAkBE,EAAW,UAAU;AACnE,SAAAM,EAAmB,WAAW,IAC1BT,EAAuBS,EAAmB,CAAC,CAAC,IAE1BR,EAAK,YAAY,EAAE,QAAQ,EAC5B;AAAA,IACxB,CAACS,MACAA,EAAM,QAAA,MAAcP,EAAW,oBAC/BO,EAAM,cAAcP,EAAW,cAC/BO,EA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wB;AAClD,WAAA+F,EAAsB1F,EAAgCP,CAAI,CAAC;AACxD,MAAAA,EAAK,OAAOE,EAAW,uBAAuB;AACxD,WAAOmE,EAAyBrE,CAAI;AAG/B,QAAA+B,IAAW/B,EAAK,cAAc,EAAE,cAAc,MAAM,GAAG,EAAE,IAAI;AACnE,SAAAgC,EAAO,IAAI,IAAID,CAAQ,gCAAgC/B,EAAK,YAAa,CAAA,EAAE,GAEpE;AACR,GAEakG,IAAsB,CAAClG,MAA8B;AACjE,QAAM0C,IAAiB1C,EAAK,yBAAyBE,EAAW,cAAc;AAC1E,MAAA,CAACwC,EAAuB,QAAA;AAE5B,QAAMyD,IAAWzD,EAAe,aAAa,EAAE,CAAC;AAC5C,MAAA,CAACyD,EAAiB,QAAA;AAEhB,QAAAC,IAAUD,EAAS,QAAQ;AAC7B,SAAAC,EAAQ,oBACJA,EAAQ,gBAAgB,IAGzB;AACR,GAEa/B,IAA2B,CAACnC,MACjBA,EAAkB,yBAAyBhC,EAAW,UAAU,EAChD,kBAAkBA,EAAW,kBAAkB,EAEnD,IAAI,CAACF,MAAS;AAE1C,QAAAoC,IADiBpC,EAAK,yBAAyBE,EAAW,UAAU,EACpC,QAAQ,GAExCE,IAAsBJ,EAAK,aAAa,GACxCqG,IAAatG,EAAuBK,CAAmB,GACvD+D,IAAQ8B,EAAsBI,CAAU;AAEvC,SAAA;AAAA,IACN,YAAYjE;AAAA,IACZ,OAAA+B;AAAA,EACD;AAAA,CACA,KAEoB,CAAC;"}
|
|
@@ -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 s=require("ts-morph"),c=require("../../utils/logger.cjs"),l=require("./nodeParsers.cjs"),y=(t,n)=>{const o=t.getFirstDescendantByKind(s.SyntaxKind.PropertyAccessExpression).getText().split(".")[1].toUpperCase(),r=o==="DEL"?"DELETE":o,i=l.resolveEndpointPath(t)??"",d={method:r,path:i,sourceFilePath:n,requestPathParams:[],requestQuery:[],requestHeaders:[],rawBody:void 0,objectBody:[],responses:[],name:void 0,summary:void 0,description:void 0,tags:void 0};try{f(t).forEach(a=>{d[a.identifier]=a.value})}catch(e){c.Logger.error("Error",e)}try{d.requestPathParams=x(t,i)}catch(e){c.Logger.error("Error",e)}try{d.requestQuery=p(t,"useQueryParams")}catch(e){c.Logger.error("Error",e)}try{d.requestHeaders=p(t,"useHeaderParams")}catch(e){c.Logger.error("Error",e)}try{const e=E(t);e&&(d.rawBody=e)}catch(e){c.Logger.error("Error",e)}try{d.objectBody=p(t,"useRequestBody")}catch(e){c.Logger.error("Error",e)}try{d.responses=K(t)}catch(e){c.Logger.error("Error",e)}return d},u=(t,n)=>t.getDescendantsOfKind(s.SyntaxKind.CallExpression).filter(i=>i.getFirstChildByKind(s.SyntaxKind.Identifier)?.getText()===n)[0]??null,f=t=>{const n=u(t,"useApiEndpoint");if(!n)return[];const o=n.getFirstChildByKind(s.SyntaxKind.SyntaxList),r=l.findNodeImplementation(o.getLastChild());if(!r.isKind(s.SyntaxKind.ObjectLiteralExpression))throw new Error("Non-literal type used in useApiEndpoint");const i=r.asKind(s.SyntaxKind.ObjectLiteralExpression);return l.getValuesOfObjectLiteral(i).filter(e=>e.value!==null)},x=(t,n)=>{const o=u(t,"usePathParams");if(!o)return[];const r=o.getFirstChildByKind(s.SyntaxKind.SyntaxList),i=l.findNodeImplementation(r.getLastChild());if(!i.isKind(s.SyntaxKind.ObjectLiteralExpression))throw new Error("Non-literal type used in usePathParams");const d=n.split("/").filter(a=>a.startsWith(":")).map(a=>({name:a.substring(1).replace(/\?/,""),optional:a.includes("?")})),e=i.asKind(s.SyntaxKind.ObjectLiteralExpression);return l.getShapeOfValidatorLiteral(e).filter(a=>a.shape!==null).map(a=>({identifier:a.identifier,signature:a.shape,optional:d.some(h=>h.name===a.identifier&&h.optional),description:a.description,errorMessage:a.errorMessage}))},E=t=>{const n=u(t,"useRequestRawBody");if(!n)return null;const o=n.getFirstChildByKind(s.SyntaxKind.SyntaxList),r=l.findNodeImplementation(o.getLastChild(i=>!i.isKind(s.SyntaxKind.CommaToken)));return{signature:l.getValidatorPropertyShape(r),optional:l.getValidatorPropertyOptionality(r),description:l.getValidatorPropertyStringValue(r,"description"),errorMessage:l.getValidatorPropertyStringValue(r,"errorMessage")}},p=(t,n)=>{const o=u(t,n);if(!o)return[];const r=o.getFirstChildByKind(s.SyntaxKind.SyntaxList),i=l.findNodeImplementation(r.getLastChild());if(!i.isKind(s.SyntaxKind.ObjectLiteralExpression))throw new Error(`Non-literal type used in ${n}`);const d=i.asKind(s.SyntaxKind.ObjectLiteralExpression);return l.getShapeOfValidatorLiteral(d).filter(e=>e.shape!==null).map(e=>({identifier:e.identifier,signature:e.shape,optional:e.optional,description:e.description,errorMessage:e.errorMessage}))},K=t=>{const o=t.getFirstChildByKind(s.SyntaxKind.CallExpression).getFirstChildByKind(s.SyntaxKind.SyntaxList).getFirstChildByKind(s.SyntaxKind.ArrowFunction).getReturnType(),r=o.getText().startsWith("Promise")?o.getTypeArguments()[0]:o,i=l.getProperTypeShape(r,t);return g(i)},g=t=>{if(typeof t=="string")return[{status:t==="void"||t==="null"?204:200,contentType:"text/plain",signature:t,description:"",errorMessage:""}];if(t[0].role==="union_entry"||t[0].role==="literal_string")return g(t[0].shape);if(t[0].role==="property"&&t[0].identifier==="_isUseReturnValue"){const n=(()=>{const r=t.find(i=>i.role==="property"&&i.identifier==="status")?.shape;if(!r||typeof r=="string"||typeof r[0].shape!="string")throw new Error("Invalid useReturnValue hook");return parseInt(r[0].shape)})(),o=(()=>{const r=t.find(i=>i.role==="property"&&i.identifier==="contentType")?.shape;if(!r||typeof r=="string"||typeof r[0].shape!="string")throw new Error("Invalid useReturnValue hook");return r[0].shape})();return[{status:n,contentType:o,signature:t,description:"",errorMessage:""}]}return t[0].role==="union"?typeof t[0].shape=="string"?[{status:t[0].shape==="void"||t[0].shape==="null"?204:200,contentType:"application/json",signature:t[0].shape,description:"",errorMessage:""}]:t[0].shape.flatMap(n=>g([n])):t[0].role==="buffer"?[{status:200,contentType:"application/octet-stream",signature:t,description:"",errorMessage:""}]:[{status:200,contentType:"application/json",signature:t,description:"",errorMessage:""}]};exports.parseEndpoint=y;
|
|
2
2
|
//# sourceMappingURL=parseEndpoint.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseEndpoint.cjs","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":"+KAeaA,EAAgB,CAACC,EAAqBC,IAA2B,CAC7E,MAAMC,EAAuBF,EAC3B,yBAAyBG,EAAAA,WAAW,wBAAwB,EAC5D,QAAQ,EACR,MAAM,GAAG,EAAE,CAAC,EACZ,YAAY,EAERC,EAAiBF,IAAyB,MAAQ,SAAWA,EAE7DG,EAAeL,EAAK,yBAAyBG,aAAW,aAAa,EAAG,WAAa,GACrFG,EAAeD,EAAa,UAAU,EAAGA,EAAa,OAAS,CAAC,EAEhEE,EAA6B,CAClC,OAAQH,EACR,KAAME,EACN,eAAAL,EACA,kBAAmB,CAAC,EACpB,aAAc,CAAC,EACf,eAAgB,CAAC,EACjB,QAAS,OACT,WAAY,CAAC,EACb,UAAW,CAAC,EACZ,KAAM,OACN,QAAS,OACT,YAAa,OACb,KAAM,MACP,EAQI,GAAA,CACaO,EAAsBR,CAAI,EAClC,QAASS,GAAU,CACbF,EAAAE,EAAM,UAAU,EAAIA,EAAM,KAAA,CACvC,QACOC,EAAK,CAKNC,SAAA,MAAM,QAASD,CAAG,CAAA,CAItB,GAAA,CACUH,EAAA,kBAAoBK,EAAmBZ,EAAMM,CAAY,QAC9DI,EAAK,CAKNC,SAAA,MAAM,QAASD,CAAG,CAAA,CAItB,GAAA,CACUH,EAAA,aAAeM,EAAwBb,EAAM,gBAAgB,QAClEU,EAAK,CAKNC,SAAA,MAAM,QAASD,CAAG,CAAA,CAItB,GAAA,CACUH,EAAA,eAAiBM,EAAwBb,EAAM,iBAAiB,QACrEU,EAAK,CAKNC,SAAA,MAAM,Q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,SACvE,MAAA,IAAI,MAAM,6BAA6B,EAE9C,OAAO,SAASA,EAAS,CAAC,EAAE,KAAK,CAAA,GAC/B,EACGE,GAAe,IAAM,CAC1B,MAAMF,EAAWJ,EAAa,KAC5BK,GAAaA,EAAS,OAAS,YAAcA,EAAS,aAAe,aAAA,GACpE,MACC,GAAA,CAACD,GAAY,OAAOA,GAAa,UAAY,OAAOA,EAAS,CAAC,EAAE,OAAU,SACvE,MAAA,IAAI,MAAM,6BAA6B,EAEvC,OAAAA,EAAS,CAAC,EAAE,KAAA,GACjB,EACI,MAAA,CACN,CACC,OAAAD,EACA,YAAAG,EACA,UAAWN,EACX,YAAa,GACb,aAAc,EAAA,CAEhB,CAAA,CAGD,OAAIA,EAAa,CAAC,EAAE,OAAS,QACxB,OAAOA,EAAa,CAAC,EAAE,OAAU,SAC7B,CACN,CACC,OAAQA,EAAa,CAAC,EAAE,QAAU,QAAUA,EAAa,CAAC,EAAE,QAAU,OAAS,IAAM,IACrF,YAAa,mBACb,UAAWA,EAAa,CAAC,EAAE,MAC3B,YAAa,GACb,aAAc,EAAA,CAEhB,EAGMA,EAAa,CAAC,EAAE,MAAM,QAASO,GAC9BL,EAAmB,CAACK,CAAU,CAAC,CACtC,EAGEP,EAAa,CAAC,EAAE,OAAS,SACrB,CACN,CACC,OAAQ,IACR,YAAa,2BACb,UAAWA,EACX,YAAa,GACb,aAAc,EAAA,CAEhB,EAGM,CACN,CACC,OAAQ,IACR,YAAa,mBACb,UAAWA,EACX,YAAa,GACb,aAAc,EAAA,CAEhB,CACD"}
|
|
1
|
+
{"version":3,"file":"parseEndpoint.cjs","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":"+KAgBaA,EAAgB,CAACC,EAAqBC,IAA2B,CAC7E,MAAMC,EAAuBF,EAC3B,yBAAyBG,EAAAA,WAAW,wBAAwB,EAC5D,QAAQ,EACR,MAAM,GAAG,EAAE,CAAC,EACZ,YAAY,EAERC,EAAiBF,IAAyB,MAAQ,SAAWA,EAE7DG,EAAeC,EAAAA,oBAAoBN,CAAI,GAAK,GAE5CO,EAA6B,CAClC,OAAQH,EACR,KAAMC,EAC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BACb,UAAWA,EAAa,CAAC,EAAE,MAC3B,YAAa,GACb,aAAc,EAAA,CAEhB,EAGMA,EAAa,CAAC,EAAE,MAAM,QAASO,GAC9BL,EAAmB,CAACK,CAAU,CAAC,CACtC,EAGEP,EAAa,CAAC,EAAE,OAAS,SACrB,CACN,CACC,OAAQ,IACR,YAAa,2BACb,UAAWA,EACX,YAAa,GACb,aAAc,EAAA,CAEhB,EAGM,CACN,CACC,OAAQ,IACR,YAAa,mBACb,UAAWA,EACX,YAAa,GACb,aAAc,EAAA,CAEhB,CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseEndpoint.d.ts","sourceRoot":"","sources":["../../../src/openapi/analyzerModule/parseEndpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,EAAE,EAAE,MAAM,UAAU,CAAA;AAI/C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"parseEndpoint.d.ts","sourceRoot":"","sources":["../../../src/openapi/analyzerModule/parseEndpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,EAAE,EAAE,MAAM,UAAU,CAAA;AAI/C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAYvC,eAAO,MAAM,aAAa,SAAU,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,kBAAkB,MAAM,iBAoHxE,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { SyntaxKind as
|
|
1
|
+
import { SyntaxKind as n } from "ts-morph";
|
|
2
2
|
import { Logger as c } from "../../utils/logger.mjs";
|
|
3
|
-
import { findNodeImplementation as
|
|
4
|
-
const
|
|
5
|
-
const o = t.getFirstDescendantByKind(
|
|
3
|
+
import { resolveEndpointPath as E, findNodeImplementation as d, getValuesOfObjectLiteral as m, getShapeOfValidatorLiteral as y, getValidatorPropertyStringValue as f, getValidatorPropertyOptionality as x, getValidatorPropertyShape as L, getProperTypeShape as P } from "./nodeParsers.mjs";
|
|
4
|
+
const w = (t, s) => {
|
|
5
|
+
const o = t.getFirstDescendantByKind(n.PropertyAccessExpression).getText().split(".")[1].toUpperCase(), r = o === "DEL" ? "DELETE" : o, i = E(t) ?? "", l = {
|
|
6
6
|
method: r,
|
|
7
|
-
path:
|
|
8
|
-
sourceFilePath:
|
|
7
|
+
path: i,
|
|
8
|
+
sourceFilePath: s,
|
|
9
9
|
requestPathParams: [],
|
|
10
10
|
requestQuery: [],
|
|
11
11
|
requestHeaders: [],
|
|
@@ -18,101 +18,101 @@ const j = (t, n) => {
|
|
|
18
18
|
tags: void 0
|
|
19
19
|
};
|
|
20
20
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
v(t).forEach((a) => {
|
|
22
|
+
l[a.identifier] = a.value;
|
|
23
23
|
});
|
|
24
24
|
} catch (e) {
|
|
25
25
|
c.error("Error", e);
|
|
26
26
|
}
|
|
27
27
|
try {
|
|
28
|
-
|
|
28
|
+
l.requestPathParams = C(t, i);
|
|
29
29
|
} catch (e) {
|
|
30
30
|
c.error("Error", e);
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
|
-
|
|
33
|
+
l.requestQuery = p(t, "useQueryParams");
|
|
34
34
|
} catch (e) {
|
|
35
35
|
c.error("Error", e);
|
|
36
36
|
}
|
|
37
37
|
try {
|
|
38
|
-
|
|
38
|
+
l.requestHeaders = p(t, "useHeaderParams");
|
|
39
39
|
} catch (e) {
|
|
40
40
|
c.error("Error", e);
|
|
41
41
|
}
|
|
42
42
|
try {
|
|
43
|
-
const e =
|
|
44
|
-
e && (
|
|
43
|
+
const e = K(t);
|
|
44
|
+
e && (l.rawBody = e);
|
|
45
45
|
} catch (e) {
|
|
46
46
|
c.error("Error", e);
|
|
47
47
|
}
|
|
48
48
|
try {
|
|
49
|
-
|
|
49
|
+
l.objectBody = p(t, "useRequestBody");
|
|
50
50
|
} catch (e) {
|
|
51
51
|
c.error("Error", e);
|
|
52
52
|
}
|
|
53
53
|
try {
|
|
54
|
-
|
|
54
|
+
l.responses = N(t);
|
|
55
55
|
} catch (e) {
|
|
56
56
|
c.error("Error", e);
|
|
57
57
|
}
|
|
58
|
-
return
|
|
59
|
-
},
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
58
|
+
return l;
|
|
59
|
+
}, u = (t, s) => t.getDescendantsOfKind(n.CallExpression).filter((i) => i.getFirstChildByKind(n.Identifier)?.getText() === s)[0] ?? null, v = (t) => {
|
|
60
|
+
const s = u(t, "useApiEndpoint");
|
|
61
|
+
if (!s)
|
|
62
62
|
return [];
|
|
63
|
-
const o =
|
|
64
|
-
if (!r.isKind(
|
|
63
|
+
const o = s.getFirstChildByKind(n.SyntaxList), r = d(o.getLastChild());
|
|
64
|
+
if (!r.isKind(n.ObjectLiteralExpression))
|
|
65
65
|
throw new Error("Non-literal type used in useApiEndpoint");
|
|
66
|
-
const i = r.asKind(
|
|
67
|
-
return
|
|
68
|
-
},
|
|
69
|
-
const o =
|
|
66
|
+
const i = r.asKind(n.ObjectLiteralExpression);
|
|
67
|
+
return m(i).filter((e) => e.value !== null);
|
|
68
|
+
}, C = (t, s) => {
|
|
69
|
+
const o = u(t, "usePathParams");
|
|
70
70
|
if (!o)
|
|
71
71
|
return [];
|
|
72
|
-
const r = o.getFirstChildByKind(
|
|
73
|
-
if (!i.isKind(
|
|
72
|
+
const r = o.getFirstChildByKind(n.SyntaxList), i = d(r.getLastChild());
|
|
73
|
+
if (!i.isKind(n.ObjectLiteralExpression))
|
|
74
74
|
throw new Error("Non-literal type used in usePathParams");
|
|
75
|
-
const l =
|
|
76
|
-
name:
|
|
77
|
-
optional:
|
|
78
|
-
})),
|
|
79
|
-
return y(
|
|
80
|
-
identifier:
|
|
81
|
-
signature:
|
|
82
|
-
optional: l.some((
|
|
83
|
-
description:
|
|
84
|
-
errorMessage:
|
|
75
|
+
const l = s.split("/").filter((a) => a.startsWith(":")).map((a) => ({
|
|
76
|
+
name: a.substring(1).replace(/\?/, ""),
|
|
77
|
+
optional: a.includes("?")
|
|
78
|
+
})), e = i.asKind(n.ObjectLiteralExpression);
|
|
79
|
+
return y(e).filter((a) => a.shape !== null).map((a) => ({
|
|
80
|
+
identifier: a.identifier,
|
|
81
|
+
signature: a.shape,
|
|
82
|
+
optional: l.some((g) => g.name === a.identifier && g.optional),
|
|
83
|
+
description: a.description,
|
|
84
|
+
errorMessage: a.errorMessage
|
|
85
85
|
}));
|
|
86
|
-
},
|
|
87
|
-
const
|
|
88
|
-
if (!
|
|
86
|
+
}, K = (t) => {
|
|
87
|
+
const s = u(t, "useRequestRawBody");
|
|
88
|
+
if (!s)
|
|
89
89
|
return null;
|
|
90
|
-
const o =
|
|
91
|
-
o.getLastChild((i) => !i.isKind(
|
|
90
|
+
const o = s.getFirstChildByKind(n.SyntaxList), r = d(
|
|
91
|
+
o.getLastChild((i) => !i.isKind(n.CommaToken))
|
|
92
92
|
);
|
|
93
93
|
return {
|
|
94
|
-
signature:
|
|
95
|
-
optional:
|
|
94
|
+
signature: L(r),
|
|
95
|
+
optional: x(r),
|
|
96
96
|
description: f(r, "description"),
|
|
97
97
|
errorMessage: f(r, "errorMessage")
|
|
98
98
|
};
|
|
99
|
-
},
|
|
100
|
-
const o =
|
|
99
|
+
}, p = (t, s) => {
|
|
100
|
+
const o = u(t, s);
|
|
101
101
|
if (!o)
|
|
102
102
|
return [];
|
|
103
|
-
const r = o.getFirstChildByKind(
|
|
104
|
-
if (!i.isKind(
|
|
105
|
-
throw new Error(`Non-literal type used in ${
|
|
106
|
-
const l = i.asKind(
|
|
107
|
-
return y(l).filter((
|
|
108
|
-
identifier:
|
|
109
|
-
signature:
|
|
110
|
-
optional:
|
|
111
|
-
description:
|
|
112
|
-
errorMessage:
|
|
103
|
+
const r = o.getFirstChildByKind(n.SyntaxList), i = d(r.getLastChild());
|
|
104
|
+
if (!i.isKind(n.ObjectLiteralExpression))
|
|
105
|
+
throw new Error(`Non-literal type used in ${s}`);
|
|
106
|
+
const l = i.asKind(n.ObjectLiteralExpression);
|
|
107
|
+
return y(l).filter((e) => e.shape !== null).map((e) => ({
|
|
108
|
+
identifier: e.identifier,
|
|
109
|
+
signature: e.shape,
|
|
110
|
+
optional: e.optional,
|
|
111
|
+
description: e.description,
|
|
112
|
+
errorMessage: e.errorMessage
|
|
113
113
|
}));
|
|
114
|
-
},
|
|
115
|
-
const o = t.getFirstChildByKind(
|
|
114
|
+
}, N = (t) => {
|
|
115
|
+
const o = t.getFirstChildByKind(n.CallExpression).getFirstChildByKind(n.SyntaxList).getFirstChildByKind(n.ArrowFunction).getReturnType(), r = o.getText().startsWith("Promise") ? o.getTypeArguments()[0] : o, i = P(r, t);
|
|
116
116
|
return h(i);
|
|
117
117
|
}, h = (t) => {
|
|
118
118
|
if (typeof t == "string")
|
|
@@ -128,7 +128,7 @@ const j = (t, n) => {
|
|
|
128
128
|
if (t[0].role === "union_entry" || t[0].role === "literal_string")
|
|
129
129
|
return h(t[0].shape);
|
|
130
130
|
if (t[0].role === "property" && t[0].identifier === "_isUseReturnValue") {
|
|
131
|
-
const
|
|
131
|
+
const s = (() => {
|
|
132
132
|
const r = t.find(
|
|
133
133
|
(i) => i.role === "property" && i.identifier === "status"
|
|
134
134
|
)?.shape;
|
|
@@ -145,7 +145,7 @@ const j = (t, n) => {
|
|
|
145
145
|
})();
|
|
146
146
|
return [
|
|
147
147
|
{
|
|
148
|
-
status:
|
|
148
|
+
status: s,
|
|
149
149
|
contentType: o,
|
|
150
150
|
signature: t,
|
|
151
151
|
description: "",
|
|
@@ -161,7 +161,7 @@ const j = (t, n) => {
|
|
|
161
161
|
description: "",
|
|
162
162
|
errorMessage: ""
|
|
163
163
|
}
|
|
164
|
-
] : t[0].shape.flatMap((
|
|
164
|
+
] : t[0].shape.flatMap((s) => h([s])) : t[0].role === "buffer" ? [
|
|
165
165
|
{
|
|
166
166
|
status: 200,
|
|
167
167
|
contentType: "application/octet-stream",
|
|
@@ -180,6 +180,6 @@ const j = (t, n) => {
|
|
|
180
180
|
];
|
|
181
181
|
};
|
|
182
182
|
export {
|
|
183
|
-
|
|
183
|
+
w as parseEndpoint
|
|
184
184
|
};
|
|
185
185
|
//# sourceMappingURL=parseEndpoint.mjs.map
|