keq 2.8.14 → 2.9.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/.claude/settings.local.json +26 -0
- package/CHANGELOG.md +7 -0
- package/dist/esm/src/create-request.js +2 -0
- package/dist/esm/src/middlewares/mutex-flow-control-middleware.d.ts +2 -0
- package/dist/esm/src/middlewares/mutex-flow-control-middleware.js +22 -0
- package/dist/esm/src/types/keq-flow-control.d.ts +1 -1
- package/dist/esm/src/types/keq-global.d.ts +1 -0
- package/dist/umd/src/create-request.js +3 -1
- package/dist/umd/src/middlewares/mutex-flow-control-middleware.d.ts +2 -0
- package/dist/umd/src/middlewares/mutex-flow-control-middleware.js +36 -0
- package/dist/umd/src/types/keq-flow-control.d.ts +1 -1
- package/dist/umd/src/types/keq-global.d.ts +1 -0
- package/package.json +1 -1
- package/packages/cache/.turbo/turbo-build.log +26 -11
- package/packages/cache/dist/index.d.mts +354 -0
- package/packages/cache/dist/index.d.mts.map +1 -0
- package/packages/cache/dist/index.d.ts +352 -5
- package/packages/cache/dist/index.d.ts.map +1 -1
- package/packages/cache/dist/index.js +1211 -1276
- package/packages/cache/dist/index.js.map +1 -1
- package/packages/cache/dist/index.mjs +1183 -1251
- package/packages/cache/dist/index.mjs.map +1 -1
- package/packages/cli/.turbo/turbo-build.log +89 -9
- package/packages/cli/dist/cli.cjs +1333 -2937
- package/packages/cli/dist/cli.cjs.map +1 -1
- package/packages/cli/dist/cli.d.cts +1 -0
- package/packages/cli/dist/cli.d.mts +1 -0
- package/packages/cli/dist/cli.mjs +1359 -0
- package/packages/cli/dist/cli.mjs.map +1 -0
- package/packages/cli/dist/compiler-0Kli6UCr.cjs +738 -0
- package/packages/cli/dist/compiler-0Kli6UCr.cjs.map +1 -0
- package/packages/cli/dist/compiler-C3AE8j54.mjs +715 -0
- package/packages/cli/dist/compiler-C3AE8j54.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +17 -2896
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.d.cts +17 -0
- package/packages/cli/dist/index.d.cts.map +1 -0
- package/packages/cli/dist/index.d.mts +17 -0
- package/packages/cli/dist/index.d.mts.map +1 -0
- package/packages/cli/dist/index.mjs +10 -0
- package/packages/cli/dist/index.mjs.map +1 -0
- package/packages/cli/dist/init-BNhD2oCI.mjs +168 -0
- package/packages/cli/dist/init-BNhD2oCI.mjs.map +1 -0
- package/packages/cli/dist/init-DqxLcRSQ.cjs +170 -0
- package/packages/cli/dist/init-DqxLcRSQ.cjs.map +1 -0
- package/packages/cli/dist/logger-D7PyVZo3.cjs +46 -0
- package/packages/cli/dist/logger-D7PyVZo3.cjs.map +1 -0
- package/packages/cli/dist/logger-QLBHySQ3.mjs +12 -0
- package/packages/cli/dist/logger-QLBHySQ3.mjs.map +1 -0
- package/packages/cli/dist/micro-function.translator-BmJZzkKh.cjs +16 -0
- package/packages/cli/dist/micro-function.translator-BmJZzkKh.cjs.map +1 -0
- package/packages/cli/dist/micro-function.translator-CDfkj4Tt.mjs +11 -0
- package/packages/cli/dist/micro-function.translator-CDfkj4Tt.mjs.map +1 -0
- package/packages/cli/dist/mock-command-Bp1LxSls.mjs +350 -0
- package/packages/cli/dist/mock-command-Bp1LxSls.mjs.map +1 -0
- package/packages/cli/dist/mock-command-WZcfy5Iq.cjs +353 -0
- package/packages/cli/dist/mock-command-WZcfy5Iq.cjs.map +1 -0
- package/packages/cli/dist/plugins-CgMhaNZq.cjs +3558 -0
- package/packages/cli/dist/plugins-CgMhaNZq.cjs.map +1 -0
- package/packages/cli/dist/plugins-DCvJ8iHR.mjs +3280 -0
- package/packages/cli/dist/plugins-DCvJ8iHR.mjs.map +1 -0
- package/packages/cli/dist/plugins.cjs +36 -2438
- package/packages/cli/dist/plugins.d.cts +2 -0
- package/packages/cli/dist/plugins.d.mts +2 -0
- package/packages/cli/dist/plugins.mjs +2 -0
- package/packages/cli/dist/runtime-config-BWQlPhiB.d.cts +780 -0
- package/packages/cli/dist/runtime-config-BWQlPhiB.d.cts.map +1 -0
- package/packages/cli/dist/runtime-config-CrzK-Ucf.d.mts +780 -0
- package/packages/cli/dist/runtime-config-CrzK-Ucf.d.mts.map +1 -0
- package/packages/cli/dist/translators.cjs +14 -0
- package/packages/cli/dist/translators.cjs.map +1 -0
- package/packages/cli/dist/translators.d.cts +14 -0
- package/packages/cli/dist/translators.d.cts.map +1 -0
- package/packages/cli/dist/translators.d.mts +14 -0
- package/packages/cli/dist/translators.d.mts.map +1 -0
- package/packages/cli/dist/translators.mjs +12 -0
- package/packages/cli/dist/translators.mjs.map +1 -0
- package/packages/cli/node_modules/.bin/eslint +2 -2
- package/packages/cli/node_modules/.bin/jiti +2 -2
- package/packages/cli/node_modules/.bin/js-yaml +2 -2
- package/packages/cli/node_modules/.bin/jsf +21 -0
- package/packages/cli/node_modules/.bin/jsonpath +2 -2
- package/packages/cli/node_modules/.bin/jsonpath-plus +2 -2
- package/packages/cli/node_modules/.bin/semver +2 -2
- package/packages/cli/node_modules/.bin/tsc +4 -4
- package/packages/cli/node_modules/.bin/tsserver +4 -4
- package/packages/exception/.turbo/turbo-build.log +26 -31
- package/packages/exception/dist/index.d.mts +21 -0
- package/packages/exception/dist/index.d.mts.map +1 -0
- package/packages/exception/dist/index.d.ts +20 -3
- package/packages/exception/dist/index.d.ts.map +1 -1
- package/packages/exception/dist/index.js +97 -105
- package/packages/exception/dist/index.js.map +1 -1
- package/packages/exception/dist/index.mjs +92 -104
- package/packages/exception/dist/index.mjs.map +1 -1
- package/packages/headers/.turbo/turbo-build.log +26 -18
- package/packages/headers/dist/index.d.mts +46 -0
- package/packages/headers/dist/index.d.mts.map +1 -0
- package/packages/headers/dist/index.d.ts +11 -7
- package/packages/headers/dist/index.d.ts.map +1 -1
- package/packages/headers/dist/index.js +68 -64
- package/packages/headers/dist/index.js.map +1 -1
- package/packages/headers/dist/index.mjs +62 -43
- package/packages/headers/dist/index.mjs.map +1 -1
- package/packages/keq/.turbo/turbo-build.log +26 -16
- package/packages/keq/dist/index.d.mts +962 -0
- package/packages/keq/dist/index.d.mts.map +1 -0
- package/packages/keq/dist/index.d.ts +961 -7
- package/packages/keq/dist/index.d.ts.map +1 -1
- package/packages/keq/dist/index.js +1727 -1842
- package/packages/keq/dist/index.js.map +1 -1
- package/packages/keq/dist/index.mjs +1671 -1817
- package/packages/keq/dist/index.mjs.map +1 -1
- package/packages/nestjs/.turbo/turbo-build.log +26 -11
- package/packages/nestjs/dist/index.d.mts +52 -0
- package/packages/nestjs/dist/index.d.mts.map +1 -0
- package/packages/nestjs/dist/index.d.ts +51 -2
- package/packages/nestjs/dist/index.d.ts.map +1 -1
- package/packages/nestjs/dist/index.js +156 -60
- package/packages/nestjs/dist/index.js.map +1 -1
- package/packages/nestjs/dist/index.mjs +133 -42
- package/packages/nestjs/dist/index.mjs.map +1 -1
- package/packages/test/.turbo/turbo-build.log +1 -1
- package/packages/url/.turbo/turbo-build.log +26 -18
- package/packages/url/dist/index.d.mts +9 -0
- package/packages/url/dist/index.d.mts.map +1 -0
- package/packages/url/dist/index.d.ts +8 -4
- package/packages/url/dist/index.d.ts.map +1 -1
- package/packages/url/dist/index.js +36 -60
- package/packages/url/dist/index.js.map +1 -1
- package/packages/url/dist/index.mjs +33 -39
- package/packages/url/dist/index.mjs.map +1 -1
- package/packages/cache/dist/cache-entry/cache-entry.d.ts +0 -17
- package/packages/cache/dist/cache-entry/cache-entry.d.ts.map +0 -1
- package/packages/cache/dist/cache-entry/index.d.ts +0 -4
- package/packages/cache/dist/cache-entry/index.d.ts.map +0 -1
- package/packages/cache/dist/cache-entry/types/cache-entry-build-options.d.ts +0 -8
- package/packages/cache/dist/cache-entry/types/cache-entry-build-options.d.ts.map +0 -1
- package/packages/cache/dist/cache-entry/types/cache-entry-options.d.ts +0 -7
- package/packages/cache/dist/cache-entry/types/cache-entry-options.d.ts.map +0 -1
- package/packages/cache/dist/cache.d.ts +0 -44
- package/packages/cache/dist/cache.d.ts.map +0 -1
- package/packages/cache/dist/constants/eviction.enum.d.ts +0 -7
- package/packages/cache/dist/constants/eviction.enum.d.ts.map +0 -1
- package/packages/cache/dist/constants/index.d.ts +0 -5
- package/packages/cache/dist/constants/index.d.ts.map +0 -1
- package/packages/cache/dist/constants/max-expired-at.d.ts +0 -2
- package/packages/cache/dist/constants/max-expired-at.d.ts.map +0 -1
- package/packages/cache/dist/constants/size.enum.d.ts +0 -7
- package/packages/cache/dist/constants/size.enum.d.ts.map +0 -1
- package/packages/cache/dist/constants/strategy.enum.d.ts +0 -7
- package/packages/cache/dist/constants/strategy.enum.d.ts.map +0 -1
- package/packages/cache/dist/exceptions/cache-exception.d.ts +0 -5
- package/packages/cache/dist/exceptions/cache-exception.d.ts.map +0 -1
- package/packages/cache/dist/exceptions/index.d.ts +0 -2
- package/packages/cache/dist/exceptions/index.d.ts.map +0 -1
- package/packages/cache/dist/request-cache-handler/index.d.ts +0 -2
- package/packages/cache/dist/request-cache-handler/index.d.ts.map +0 -1
- package/packages/cache/dist/request-cache-handler/request-cache-handler.d.ts +0 -23
- package/packages/cache/dist/request-cache-handler/request-cache-handler.d.ts.map +0 -1
- package/packages/cache/dist/storage/index.d.ts +0 -6
- package/packages/cache/dist/storage/index.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/base-indexed-db-storage.d.ts +0 -22
- package/packages/cache/dist/storage/indexed-db-storage/base-indexed-db-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/constants/default-table-name.d.ts +0 -2
- package/packages/cache/dist/storage/indexed-db-storage/constants/default-table-name.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/index.d.ts +0 -3
- package/packages/cache/dist/storage/indexed-db-storage/index.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/indexed-db-storage.d.ts +0 -12
- package/packages/cache/dist/storage/indexed-db-storage/indexed-db-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/lfu-indexed-db-storage.d.ts +0 -11
- package/packages/cache/dist/storage/indexed-db-storage/lfu-indexed-db-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/lru-indexed-db-storage.d.ts +0 -11
- package/packages/cache/dist/storage/indexed-db-storage/lru-indexed-db-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/random-indexed-db-storage.d.ts +0 -11
- package/packages/cache/dist/storage/indexed-db-storage/random-indexed-db-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/ttl-indexed-db-storage.d.ts +0 -11
- package/packages/cache/dist/storage/indexed-db-storage/ttl-indexed-db-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/types/index.d.ts +0 -7
- package/packages/cache/dist/storage/indexed-db-storage/types/index.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-metadata.d.ts +0 -12
- package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-metadata.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-response.d.ts +0 -8
- package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-response.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-visits.d.ts +0 -14
- package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-entry-visits.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-schema.d.ts +0 -29
- package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-schema.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-storage-options.d.ts +0 -14
- package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-storage-options.d.ts.map +0 -1
- package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-storage-size.d.ts +0 -13
- package/packages/cache/dist/storage/indexed-db-storage/types/indexed-db-storage-size.d.ts.map +0 -1
- package/packages/cache/dist/storage/internal-storage/internal-storage.d.ts +0 -16
- package/packages/cache/dist/storage/internal-storage/internal-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/internal-storage/types/events.d.ts +0 -16
- package/packages/cache/dist/storage/internal-storage/types/events.d.ts.map +0 -1
- package/packages/cache/dist/storage/internal-storage/types/storage-options.d.ts +0 -20
- package/packages/cache/dist/storage/internal-storage/types/storage-options.d.ts.map +0 -1
- package/packages/cache/dist/storage/keq-cache-storage.d.ts +0 -20
- package/packages/cache/dist/storage/keq-cache-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/base-memory-storage.d.ts +0 -31
- package/packages/cache/dist/storage/memory-storage/base-memory-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/index.d.ts +0 -3
- package/packages/cache/dist/storage/memory-storage/index.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/lfu-memory-storage.d.ts +0 -11
- package/packages/cache/dist/storage/memory-storage/lfu-memory-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/lru-memory-storage.d.ts +0 -11
- package/packages/cache/dist/storage/memory-storage/lru-memory-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/memory-storage.d.ts +0 -13
- package/packages/cache/dist/storage/memory-storage/memory-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/random-memory-storage.d.ts +0 -11
- package/packages/cache/dist/storage/memory-storage/random-memory-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/ttl-memory-storage.d.ts +0 -11
- package/packages/cache/dist/storage/memory-storage/ttl-memory-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/types/index.d.ts +0 -3
- package/packages/cache/dist/storage/memory-storage/types/index.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/types/memory-storage-options.d.ts +0 -9
- package/packages/cache/dist/storage/memory-storage/types/memory-storage-options.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/types/memory-storage-size.d.ts +0 -13
- package/packages/cache/dist/storage/memory-storage/types/memory-storage-size.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/utils/humanize-size.d.ts +0 -6
- package/packages/cache/dist/storage/memory-storage/utils/humanize-size.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/utils/index.d.ts +0 -3
- package/packages/cache/dist/storage/memory-storage/utils/index.d.ts.map +0 -1
- package/packages/cache/dist/storage/memory-storage/utils/serialize-response-body.d.ts +0 -6
- package/packages/cache/dist/storage/memory-storage/utils/serialize-response-body.d.ts.map +0 -1
- package/packages/cache/dist/storage/multi-tier-storage/index.d.ts +0 -3
- package/packages/cache/dist/storage/multi-tier-storage/index.d.ts.map +0 -1
- package/packages/cache/dist/storage/multi-tier-storage/multi-tier-storage.d.ts +0 -36
- package/packages/cache/dist/storage/multi-tier-storage/multi-tier-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/multi-tier-storage/types/index.d.ts +0 -2
- package/packages/cache/dist/storage/multi-tier-storage/types/index.d.ts.map +0 -1
- package/packages/cache/dist/storage/multi-tier-storage/types/multi-tier-storage-options.d.ts +0 -5
- package/packages/cache/dist/storage/multi-tier-storage/types/multi-tier-storage-options.d.ts.map +0 -1
- package/packages/cache/dist/storage/tier-storage/index.d.ts +0 -3
- package/packages/cache/dist/storage/tier-storage/index.d.ts.map +0 -1
- package/packages/cache/dist/storage/tier-storage/tier-storage.d.ts +0 -15
- package/packages/cache/dist/storage/tier-storage/tier-storage.d.ts.map +0 -1
- package/packages/cache/dist/storage/tier-storage/types/index.d.ts +0 -2
- package/packages/cache/dist/storage/tier-storage/types/index.d.ts.map +0 -1
- package/packages/cache/dist/storage/tier-storage/types/tier-storage-options.d.ts +0 -21
- package/packages/cache/dist/storage/tier-storage/types/tier-storage-options.d.ts.map +0 -1
- package/packages/cache/dist/strategies/cache-first.d.ts +0 -3
- package/packages/cache/dist/strategies/cache-first.d.ts.map +0 -1
- package/packages/cache/dist/strategies/index.d.ts +0 -5
- package/packages/cache/dist/strategies/index.d.ts.map +0 -1
- package/packages/cache/dist/strategies/network-first.d.ts +0 -3
- package/packages/cache/dist/strategies/network-first.d.ts.map +0 -1
- package/packages/cache/dist/strategies/network-only.d.ts +0 -3
- package/packages/cache/dist/strategies/network-only.d.ts.map +0 -1
- package/packages/cache/dist/strategies/stale-while-revalidate.d.ts +0 -3
- package/packages/cache/dist/strategies/stale-while-revalidate.d.ts.map +0 -1
- package/packages/cache/dist/types/index.d.ts +0 -6
- package/packages/cache/dist/types/index.d.ts.map +0 -1
- package/packages/cache/dist/types/keq-cache-key.d.ts +0 -4
- package/packages/cache/dist/types/keq-cache-key.d.ts.map +0 -1
- package/packages/cache/dist/types/keq-cache-pattern.d.ts +0 -3
- package/packages/cache/dist/types/keq-cache-pattern.d.ts.map +0 -1
- package/packages/cache/dist/types/keq-cache-rule.d.ts +0 -6
- package/packages/cache/dist/types/keq-cache-rule.d.ts.map +0 -1
- package/packages/cache/dist/types/keq-cache-strategy.d.ts +0 -6
- package/packages/cache/dist/types/keq-cache-strategy.d.ts.map +0 -1
- package/packages/cache/dist/types/request-cache-options.d.ts +0 -45
- package/packages/cache/dist/types/request-cache-options.d.ts.map +0 -1
- package/packages/cache/dist/utils/get-response-bytes.d.ts +0 -2
- package/packages/cache/dist/utils/get-response-bytes.d.ts.map +0 -1
- package/packages/cache/dist/utils/index.d.ts +0 -4
- package/packages/cache/dist/utils/index.d.ts.map +0 -1
- package/packages/cache/dist/utils/logger.d.ts +0 -5
- package/packages/cache/dist/utils/logger.d.ts.map +0 -1
- package/packages/cache/dist/utils/random.d.ts +0 -2
- package/packages/cache/dist/utils/random.d.ts.map +0 -1
- package/packages/cli/dist/cli.d.ts +0 -3
- package/packages/cli/dist/cli.d.ts.map +0 -1
- package/packages/cli/dist/cli.js +0 -2945
- package/packages/cli/dist/cli.js.map +0 -1
- package/packages/cli/dist/compiler/compiler.d.ts +0 -17
- package/packages/cli/dist/compiler/compiler.d.ts.map +0 -1
- package/packages/cli/dist/compiler/index.d.ts +0 -4
- package/packages/cli/dist/compiler/index.d.ts.map +0 -1
- package/packages/cli/dist/compiler/intercepter/index.d.ts +0 -3
- package/packages/cli/dist/compiler/intercepter/index.d.ts.map +0 -1
- package/packages/cli/dist/compiler/intercepter/perfect-error-message.d.ts +0 -3
- package/packages/cli/dist/compiler/intercepter/perfect-error-message.d.ts.map +0 -1
- package/packages/cli/dist/compiler/intercepter/print-information.d.ts +0 -5
- package/packages/cli/dist/compiler/intercepter/print-information.d.ts.map +0 -1
- package/packages/cli/dist/compiler/tasks/compile/index.d.ts +0 -6
- package/packages/cli/dist/compiler/tasks/compile/index.d.ts.map +0 -1
- package/packages/cli/dist/compiler/tasks/download/index.d.ts +0 -10
- package/packages/cli/dist/compiler/tasks/download/index.d.ts.map +0 -1
- package/packages/cli/dist/compiler/tasks/index.d.ts +0 -6
- package/packages/cli/dist/compiler/tasks/index.d.ts.map +0 -1
- package/packages/cli/dist/compiler/tasks/persist/index.d.ts +0 -5
- package/packages/cli/dist/compiler/tasks/persist/index.d.ts.map +0 -1
- package/packages/cli/dist/compiler/tasks/setup/index.d.ts +0 -15
- package/packages/cli/dist/compiler/tasks/setup/index.d.ts.map +0 -1
- package/packages/cli/dist/compiler/tasks/setup/utils/find-nearest-package-json.d.ts +0 -6
- package/packages/cli/dist/compiler/tasks/setup/utils/find-nearest-package-json.d.ts.map +0 -1
- package/packages/cli/dist/compiler/tasks/setup/utils/get-project-module-system.d.ts +0 -5
- package/packages/cli/dist/compiler/tasks/setup/utils/get-project-module-system.d.ts.map +0 -1
- package/packages/cli/dist/compiler/tasks/setup/utils/index.d.ts +0 -3
- package/packages/cli/dist/compiler/tasks/setup/utils/index.d.ts.map +0 -1
- package/packages/cli/dist/compiler/tasks/setup/utils/parse-runtime-config.d.ts +0 -3
- package/packages/cli/dist/compiler/tasks/setup/utils/parse-runtime-config.d.ts.map +0 -1
- package/packages/cli/dist/compiler/tasks/types/base-task-options.d.ts +0 -6
- package/packages/cli/dist/compiler/tasks/types/base-task-options.d.ts.map +0 -1
- package/packages/cli/dist/compiler/tasks/types/index.d.ts +0 -3
- package/packages/cli/dist/compiler/tasks/types/index.d.ts.map +0 -1
- package/packages/cli/dist/compiler/tasks/types/task-wrapper.d.ts +0 -4
- package/packages/cli/dist/compiler/tasks/types/task-wrapper.d.ts.map +0 -1
- package/packages/cli/dist/compiler/types/compiler-context.d.ts +0 -11
- package/packages/cli/dist/compiler/types/compiler-context.d.ts.map +0 -1
- package/packages/cli/dist/compiler/types/compiler-hooks.d.ts +0 -19
- package/packages/cli/dist/compiler/types/compiler-hooks.d.ts.map +0 -1
- package/packages/cli/dist/compiler/types/index.d.ts +0 -3
- package/packages/cli/dist/compiler/types/index.d.ts.map +0 -1
- package/packages/cli/dist/constants/file-naming-style.d.ts +0 -14
- package/packages/cli/dist/constants/file-naming-style.d.ts.map +0 -1
- package/packages/cli/dist/constants/index.d.ts +0 -4
- package/packages/cli/dist/constants/index.d.ts.map +0 -1
- package/packages/cli/dist/constants/qs-array-format.d.ts +0 -9
- package/packages/cli/dist/constants/qs-array-format.d.ts.map +0 -1
- package/packages/cli/dist/constants/supported-methods.d.ts +0 -2
- package/packages/cli/dist/constants/supported-methods.d.ts.map +0 -1
- package/packages/cli/dist/define-config.d.ts +0 -3
- package/packages/cli/dist/define-config.d.ts.map +0 -1
- package/packages/cli/dist/exception.d.ts +0 -6
- package/packages/cli/dist/exception.d.ts.map +0 -1
- package/packages/cli/dist/generators/index.d.ts +0 -2
- package/packages/cli/dist/generators/index.d.ts.map +0 -1
- package/packages/cli/dist/index.d.ts +0 -6
- package/packages/cli/dist/index.d.ts.map +0 -1
- package/packages/cli/dist/index.js +0 -2853
- package/packages/cli/dist/index.js.map +0 -1
- package/packages/cli/dist/models/anchor.d.ts +0 -20
- package/packages/cli/dist/models/anchor.d.ts.map +0 -1
- package/packages/cli/dist/models/api-document_v3_1.d.ts +0 -16
- package/packages/cli/dist/models/api-document_v3_1.d.ts.map +0 -1
- package/packages/cli/dist/models/artifact.d.ts +0 -17
- package/packages/cli/dist/models/artifact.d.ts.map +0 -1
- package/packages/cli/dist/models/asset.d.ts +0 -5
- package/packages/cli/dist/models/asset.d.ts.map +0 -1
- package/packages/cli/dist/models/index.d.ts +0 -8
- package/packages/cli/dist/models/index.d.ts.map +0 -1
- package/packages/cli/dist/models/module-definition.d.ts +0 -8
- package/packages/cli/dist/models/module-definition.d.ts.map +0 -1
- package/packages/cli/dist/models/operation-definition.d.ts +0 -23
- package/packages/cli/dist/models/operation-definition.d.ts.map +0 -1
- package/packages/cli/dist/models/schema-definition.d.ts +0 -20
- package/packages/cli/dist/models/schema-definition.d.ts.map +0 -1
- package/packages/cli/dist/models/utils/to-comment.d.ts +0 -2
- package/packages/cli/dist/models/utils/to-comment.d.ts.map +0 -1
- package/packages/cli/dist/plugins/body-fallback/index.d.ts +0 -6
- package/packages/cli/dist/plugins/body-fallback/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.d.ts +0 -5
- package/packages/cli/dist/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.d.ts.map +0 -1
- package/packages/cli/dist/plugins/chinese-to-pinyin/index.d.ts +0 -2
- package/packages/cli/dist/plugins/chinese-to-pinyin/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/download-http-file/download-http-file.plugin.d.ts +0 -8
- package/packages/cli/dist/plugins/download-http-file/download-http-file.plugin.d.ts.map +0 -1
- package/packages/cli/dist/plugins/download-http-file/index.d.ts +0 -2
- package/packages/cli/dist/plugins/download-http-file/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/download-local-file/download-local-file.plugin.d.ts +0 -6
- package/packages/cli/dist/plugins/download-local-file/download-local-file.plugin.d.ts.map +0 -1
- package/packages/cli/dist/plugins/download-local-file/index.d.ts +0 -2
- package/packages/cli/dist/plugins/download-local-file/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/eslint/index.d.ts +0 -15
- package/packages/cli/dist/plugins/eslint/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-declaration/constants/index.d.ts +0 -2
- package/packages/cli/dist/plugins/generate-declaration/constants/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-declaration/constants/metadata-storage.d.ts +0 -12
- package/packages/cli/dist/plugins/generate-declaration/constants/metadata-storage.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-declaration/generate-declaration.plugin.d.ts +0 -15
- package/packages/cli/dist/plugins/generate-declaration/generate-declaration.plugin.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-declaration/generators/index.d.ts +0 -3
- package/packages/cli/dist/plugins/generate-declaration/generators/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-declaration/generators/operation-declaration/index.d.ts +0 -2
- package/packages/cli/dist/plugins/generate-declaration/generators/operation-declaration/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-declaration/generators/operation-declaration/operation.generator.d.ts +0 -15
- package/packages/cli/dist/plugins/generate-declaration/generators/operation-declaration/operation.generator.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-declaration/generators/schema-declaration/index.d.ts +0 -2
- package/packages/cli/dist/plugins/generate-declaration/generators/schema-declaration/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-declaration/generators/schema-declaration/schema.generator.d.ts +0 -15
- package/packages/cli/dist/plugins/generate-declaration/generators/schema-declaration/schema.generator.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-declaration/index.d.ts +0 -3
- package/packages/cli/dist/plugins/generate-declaration/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-micro-function/constants/index.d.ts +0 -2
- package/packages/cli/dist/plugins/generate-micro-function/constants/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-micro-function/constants/metadata-storage.d.ts +0 -11
- package/packages/cli/dist/plugins/generate-micro-function/constants/metadata-storage.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-micro-function/generate-micro-function.plugin.d.ts +0 -11
- package/packages/cli/dist/plugins/generate-micro-function/generate-micro-function.plugin.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-micro-function/generators/index.d.ts +0 -3
- package/packages/cli/dist/plugins/generate-micro-function/generators/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-micro-function/generators/micro_function/index.d.ts +0 -2
- package/packages/cli/dist/plugins/generate-micro-function/generators/micro_function/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-micro-function/generators/micro_function/micro-function.generator.d.ts +0 -15
- package/packages/cli/dist/plugins/generate-micro-function/generators/micro_function/micro-function.generator.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-micro-function/generators/request/index.d.ts +0 -2
- package/packages/cli/dist/plugins/generate-micro-function/generators/request/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-micro-function/generators/request/request.generator.d.ts +0 -11
- package/packages/cli/dist/plugins/generate-micro-function/generators/request/request.generator.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-micro-function/index.d.ts +0 -3
- package/packages/cli/dist/plugins/generate-micro-function/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-nestjs-module/constants/index.d.ts +0 -2
- package/packages/cli/dist/plugins/generate-nestjs-module/constants/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-nestjs-module/constants/metadata-storage.d.ts +0 -10
- package/packages/cli/dist/plugins/generate-nestjs-module/constants/metadata-storage.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-nestjs-module/generate-nestjs-module.d.ts +0 -10
- package/packages/cli/dist/plugins/generate-nestjs-module/generate-nestjs-module.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-nestjs-module/generators/index.d.ts +0 -2
- package/packages/cli/dist/plugins/generate-nestjs-module/generators/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-nestjs-module/generators/nestjs-module.generator.d.ts +0 -14
- package/packages/cli/dist/plugins/generate-nestjs-module/generators/nestjs-module.generator.d.ts.map +0 -1
- package/packages/cli/dist/plugins/generate-nestjs-module/index.d.ts +0 -3
- package/packages/cli/dist/plugins/generate-nestjs-module/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/index.d.ts +0 -15
- package/packages/cli/dist/plugins/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/initialize/index.d.ts +0 -2
- package/packages/cli/dist/plugins/initialize/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/initialize/initialize.plugin.d.ts +0 -15
- package/packages/cli/dist/plugins/initialize/initialize.plugin.d.ts.map +0 -1
- package/packages/cli/dist/plugins/overwrite-operation-id/index.d.ts +0 -2
- package/packages/cli/dist/plugins/overwrite-operation-id/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/overwrite-operation-id/overwrite-operation-id.plugin.d.ts +0 -20
- package/packages/cli/dist/plugins/overwrite-operation-id/overwrite-operation-id.plugin.d.ts.map +0 -1
- package/packages/cli/dist/plugins/overwrite-query-options/index.d.ts +0 -2
- package/packages/cli/dist/plugins/overwrite-query-options/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/overwrite-query-options/overwrite-query-options.plugin.d.ts +0 -18
- package/packages/cli/dist/plugins/overwrite-query-options/overwrite-query-options.plugin.d.ts.map +0 -1
- package/packages/cli/dist/plugins/prettier/index.d.ts +0 -2
- package/packages/cli/dist/plugins/prettier/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/prettier/prettier.plugin.d.ts +0 -6
- package/packages/cli/dist/plugins/prettier/prettier.plugin.d.ts.map +0 -1
- package/packages/cli/dist/plugins/shaking/index.d.ts +0 -2
- package/packages/cli/dist/plugins/shaking/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/shaking/shaking.plugin.d.ts +0 -8
- package/packages/cli/dist/plugins/shaking/shaking.plugin.d.ts.map +0 -1
- package/packages/cli/dist/plugins/terminal-select/index.d.ts +0 -2
- package/packages/cli/dist/plugins/terminal-select/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/terminal-select/terminal-select.plugin.d.ts +0 -18
- package/packages/cli/dist/plugins/terminal-select/terminal-select.plugin.d.ts.map +0 -1
- package/packages/cli/dist/plugins/terminal-select/types/ignore-mode.d.ts +0 -2
- package/packages/cli/dist/plugins/terminal-select/types/ignore-mode.d.ts.map +0 -1
- package/packages/cli/dist/plugins/terminal-select/types/index.d.ts +0 -2
- package/packages/cli/dist/plugins/terminal-select/types/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/terminal-select/utils/index.d.ts +0 -2
- package/packages/cli/dist/plugins/terminal-select/utils/index.d.ts.map +0 -1
- package/packages/cli/dist/plugins/terminal-select/utils/select-operation-definitions.d.ts +0 -5
- package/packages/cli/dist/plugins/terminal-select/utils/select-operation-definitions.d.ts.map +0 -1
- package/packages/cli/dist/plugins.cjs.map +0 -1
- package/packages/cli/dist/plugins.js +0 -2378
- package/packages/cli/dist/plugins.js.map +0 -1
- package/packages/cli/dist/transformers/api-document/api-document.transformer.d.ts +0 -8
- package/packages/cli/dist/transformers/api-document/api-document.transformer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/api-document/index.d.ts +0 -2
- package/packages/cli/dist/transformers/api-document/index.d.ts.map +0 -1
- package/packages/cli/dist/transformers/api-document/nestjs-client.renderer.d.ts +0 -14
- package/packages/cli/dist/transformers/api-document/nestjs-client.renderer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/api-document/nestjs-module.renderer.d.ts +0 -12
- package/packages/cli/dist/transformers/api-document/nestjs-module.renderer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/entrypoint/entrypoint.transformer.d.ts +0 -10
- package/packages/cli/dist/transformers/entrypoint/entrypoint.transformer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/entrypoint/index.d.ts +0 -2
- package/packages/cli/dist/transformers/entrypoint/index.d.ts.map +0 -1
- package/packages/cli/dist/transformers/index.d.ts +0 -6
- package/packages/cli/dist/transformers/index.d.ts.map +0 -1
- package/packages/cli/dist/transformers/json-schema/comment.renderer.d.ts +0 -8
- package/packages/cli/dist/transformers/json-schema/comment.renderer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/json-schema/declaration.renderer.d.ts +0 -26
- package/packages/cli/dist/transformers/json-schema/declaration.renderer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/json-schema/index.d.ts +0 -4
- package/packages/cli/dist/transformers/json-schema/index.d.ts.map +0 -1
- package/packages/cli/dist/transformers/json-schema/json-schema.transformer.d.ts +0 -7
- package/packages/cli/dist/transformers/json-schema/json-schema.transformer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/json-schema/reference.transformer.d.ts +0 -5
- package/packages/cli/dist/transformers/json-schema/reference.transformer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/json-schema/types/any-other-attribute.d.ts +0 -5
- package/packages/cli/dist/transformers/json-schema/types/any-other-attribute.d.ts.map +0 -1
- package/packages/cli/dist/transformers/json-schema/types/index.d.ts +0 -3
- package/packages/cli/dist/transformers/json-schema/types/index.d.ts.map +0 -1
- package/packages/cli/dist/transformers/json-schema/types/mixed-schema-object.d.ts +0 -7
- package/packages/cli/dist/transformers/json-schema/types/mixed-schema-object.d.ts.map +0 -1
- package/packages/cli/dist/transformers/operation-definition/comment.renderer.d.ts +0 -8
- package/packages/cli/dist/transformers/operation-definition/comment.renderer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/operation-definition/declaration.renderer.d.ts +0 -20
- package/packages/cli/dist/transformers/operation-definition/declaration.renderer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/operation-definition/index.d.ts +0 -3
- package/packages/cli/dist/transformers/operation-definition/index.d.ts.map +0 -1
- package/packages/cli/dist/transformers/operation-definition/micro-function.renderer.d.ts +0 -19
- package/packages/cli/dist/transformers/operation-definition/micro-function.renderer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/operation-definition/nestjs-method.renderer.d.ts +0 -15
- package/packages/cli/dist/transformers/operation-definition/nestjs-method.renderer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/operation-definition/operation-definition.transformer.d.ts +0 -11
- package/packages/cli/dist/transformers/operation-definition/operation-definition.transformer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/operation-definition/typescript-snippet.d.ts +0 -22
- package/packages/cli/dist/transformers/operation-definition/typescript-snippet.d.ts.map +0 -1
- package/packages/cli/dist/transformers/operation-definition/utils/index.d.ts +0 -2
- package/packages/cli/dist/transformers/operation-definition/utils/index.d.ts.map +0 -1
- package/packages/cli/dist/transformers/operation-definition/utils/type-name-factory.d.ts +0 -4
- package/packages/cli/dist/transformers/operation-definition/utils/type-name-factory.d.ts.map +0 -1
- package/packages/cli/dist/transformers/schema-definition/index.d.ts +0 -2
- package/packages/cli/dist/transformers/schema-definition/index.d.ts.map +0 -1
- package/packages/cli/dist/transformers/schema-definition/schema-definition.transformer.d.ts +0 -10
- package/packages/cli/dist/transformers/schema-definition/schema-definition.transformer.d.ts.map +0 -1
- package/packages/cli/dist/transformers/types/renderer.d.ts +0 -4
- package/packages/cli/dist/transformers/types/renderer.d.ts.map +0 -1
- package/packages/cli/dist/types/address.d.ts +0 -8
- package/packages/cli/dist/types/address.d.ts.map +0 -1
- package/packages/cli/dist/types/build-cli-options.d.ts +0 -19
- package/packages/cli/dist/types/build-cli-options.d.ts.map +0 -1
- package/packages/cli/dist/types/generator.d.ts +0 -7
- package/packages/cli/dist/types/generator.d.ts.map +0 -1
- package/packages/cli/dist/types/index.d.ts +0 -7
- package/packages/cli/dist/types/index.d.ts.map +0 -1
- package/packages/cli/dist/types/plugin.d.ts +0 -5
- package/packages/cli/dist/types/plugin.d.ts.map +0 -1
- package/packages/cli/dist/types/runtime-config.d.ts +0 -41
- package/packages/cli/dist/types/runtime-config.d.ts.map +0 -1
- package/packages/cli/dist/types/to-code-options.d.ts +0 -4
- package/packages/cli/dist/types/to-code-options.d.ts.map +0 -1
- package/packages/cli/dist/utils/debugger.d.ts +0 -7
- package/packages/cli/dist/utils/debugger.d.ts.map +0 -1
- package/packages/cli/dist/utils/ignore-matcher.d.ts +0 -18
- package/packages/cli/dist/utils/ignore-matcher.d.ts.map +0 -1
- package/packages/cli/dist/utils/indent.d.ts +0 -2
- package/packages/cli/dist/utils/indent.d.ts.map +0 -1
- package/packages/cli/dist/utils/is-keywords.d.ts +0 -2
- package/packages/cli/dist/utils/is-keywords.d.ts.map +0 -1
- package/packages/cli/dist/utils/is-reserved-word.d.ts +0 -2
- package/packages/cli/dist/utils/is-reserved-word.d.ts.map +0 -1
- package/packages/cli/dist/utils/is-valid-url.d.ts +0 -16
- package/packages/cli/dist/utils/is-valid-url.d.ts.map +0 -1
- package/packages/cli/dist/utils/json-schema-utils/index.d.ts +0 -11
- package/packages/cli/dist/utils/json-schema-utils/index.d.ts.map +0 -1
- package/packages/cli/dist/utils/json-schema-utils/is-array.d.ts +0 -3
- package/packages/cli/dist/utils/json-schema-utils/is-array.d.ts.map +0 -1
- package/packages/cli/dist/utils/json-schema-utils/is-mixed.d.ts +0 -4
- package/packages/cli/dist/utils/json-schema-utils/is-mixed.d.ts.map +0 -1
- package/packages/cli/dist/utils/json-schema-utils/is-non-array.d.ts +0 -3
- package/packages/cli/dist/utils/json-schema-utils/is-non-array.d.ts.map +0 -1
- package/packages/cli/dist/utils/json-schema-utils/is-ref.d.ts +0 -3
- package/packages/cli/dist/utils/json-schema-utils/is-ref.d.ts.map +0 -1
- package/packages/cli/dist/utils/json-schema-utils/types/any-other-attribute.d.ts +0 -5
- package/packages/cli/dist/utils/json-schema-utils/types/any-other-attribute.d.ts.map +0 -1
- package/packages/cli/dist/utils/json-schema-utils/types/mixed-schema-object.d.ts +0 -7
- package/packages/cli/dist/utils/json-schema-utils/types/mixed-schema-object.d.ts.map +0 -1
- package/packages/cli/dist/utils/logger.d.ts +0 -6
- package/packages/cli/dist/utils/logger.d.ts.map +0 -1
- package/packages/cli/dist/utils/openapi-utils/dereference-deep.d.ts +0 -3
- package/packages/cli/dist/utils/openapi-utils/dereference-deep.d.ts.map +0 -1
- package/packages/cli/dist/utils/openapi-utils/dereference-operation.d.ts +0 -4
- package/packages/cli/dist/utils/openapi-utils/dereference-operation.d.ts.map +0 -1
- package/packages/cli/dist/utils/openapi-utils/dereference.d.ts +0 -3
- package/packages/cli/dist/utils/openapi-utils/dereference.d.ts.map +0 -1
- package/packages/cli/dist/utils/openapi-utils/index.d.ts +0 -19
- package/packages/cli/dist/utils/openapi-utils/index.d.ts.map +0 -1
- package/packages/cli/dist/utils/openapi-utils/is-ref-defined.d.ts +0 -3
- package/packages/cli/dist/utils/openapi-utils/is-ref-defined.d.ts.map +0 -1
- package/packages/cli/dist/utils/openapi-utils/map-operation.d.ts +0 -4
- package/packages/cli/dist/utils/openapi-utils/map-operation.d.ts.map +0 -1
- package/packages/cli/dist/utils/openapi-utils/map-parameter.d.ts +0 -4
- package/packages/cli/dist/utils/openapi-utils/map-parameter.d.ts.map +0 -1
- package/packages/cli/dist/utils/openapi-utils/remove-undefined-ref.d.ts +0 -3
- package/packages/cli/dist/utils/openapi-utils/remove-undefined-ref.d.ts.map +0 -1
- package/packages/cli/dist/utils/openapi-utils/to-3_1.d.ts +0 -3
- package/packages/cli/dist/utils/openapi-utils/to-3_1.d.ts.map +0 -1
- package/packages/exception/dist/catch-exception.d.ts +0 -4
- package/packages/exception/dist/catch-exception.d.ts.map +0 -1
- package/packages/exception/dist/plugins/index.d.mts +0 -12
- package/packages/exception/dist/plugins/index.d.ts +0 -12
- package/packages/exception/dist/plugins/index.js +0 -95
- package/packages/exception/dist/plugins/index.mjs +0 -68
- package/packages/exception/dist/throw-exception.d.ts +0 -5
- package/packages/exception/dist/throw-exception.d.ts.map +0 -1
- package/packages/exception/dist/validate-status-code.d.ts +0 -3
- package/packages/exception/dist/validate-status-code.d.ts.map +0 -1
- package/packages/exception/node_modules/.bin/keq +0 -21
- package/packages/keq/dist/context/execution-context.d.ts +0 -26
- package/packages/keq/dist/context/execution-context.d.ts.map +0 -1
- package/packages/keq/dist/context/index.d.ts +0 -5
- package/packages/keq/dist/context/index.d.ts.map +0 -1
- package/packages/keq/dist/context/middleware-context.d.ts +0 -11
- package/packages/keq/dist/context/middleware-context.d.ts.map +0 -1
- package/packages/keq/dist/context/orchestrator-context.d.ts +0 -18
- package/packages/keq/dist/context/orchestrator-context.d.ts.map +0 -1
- package/packages/keq/dist/context/shared-context.d.ts +0 -43
- package/packages/keq/dist/context/shared-context.d.ts.map +0 -1
- package/packages/keq/dist/context/types/index.d.ts +0 -6
- package/packages/keq/dist/context/types/index.d.ts.map +0 -1
- package/packages/keq/dist/context/types/keq-context-data.d.ts +0 -7
- package/packages/keq/dist/context/types/keq-context-data.d.ts.map +0 -1
- package/packages/keq/dist/context/types/keq-context-emitter.d.ts +0 -35
- package/packages/keq/dist/context/types/keq-context-emitter.d.ts.map +0 -1
- package/packages/keq/dist/context/types/keq-context-options/index.d.ts +0 -6
- package/packages/keq/dist/context/types/keq-context-options/index.d.ts.map +0 -1
- package/packages/keq/dist/context/types/keq-context-options/keq-context-options.d.ts +0 -5
- package/packages/keq/dist/context/types/keq-context-options/keq-context-options.d.ts.map +0 -1
- package/packages/keq/dist/context/types/keq-context-options/keq-middleware-options.d.ts +0 -33
- package/packages/keq/dist/context/types/keq-context-options/keq-middleware-options.d.ts.map +0 -1
- package/packages/keq/dist/context/types/keq-context-options/keq-module-options.d.ts +0 -5
- package/packages/keq/dist/context/types/keq-context-options/keq-module-options.d.ts.map +0 -1
- package/packages/keq/dist/context/types/keq-context-options/keq-resolve-with-mode.d.ts +0 -2
- package/packages/keq/dist/context/types/keq-context-options/keq-resolve-with-mode.d.ts.map +0 -1
- package/packages/keq/dist/context/types/keq-context-options/keq-retry-options.d.ts +0 -9
- package/packages/keq/dist/context/types/keq-context-options/keq-retry-options.d.ts.map +0 -1
- package/packages/keq/dist/context/types/keq-context.d.ts +0 -17
- package/packages/keq/dist/context/types/keq-context.d.ts.map +0 -1
- package/packages/keq/dist/context/types/keq-global.d.ts +0 -12
- package/packages/keq/dist/context/types/keq-global.d.ts.map +0 -1
- package/packages/keq/dist/context/utils/assign-shared-context.d.ts +0 -3
- package/packages/keq/dist/context/utils/assign-shared-context.d.ts.map +0 -1
- package/packages/keq/dist/context/utils/clone-shared-context.d.ts +0 -3
- package/packages/keq/dist/context/utils/clone-shared-context.d.ts.map +0 -1
- package/packages/keq/dist/context/utils/create-proxy-response.d.ts +0 -2
- package/packages/keq/dist/context/utils/create-proxy-response.d.ts.map +0 -1
- package/packages/keq/dist/context/utils/fork.d.ts +0 -6
- package/packages/keq/dist/context/utils/fork.d.ts.map +0 -1
- package/packages/keq/dist/context/utils/index.d.ts +0 -5
- package/packages/keq/dist/context/utils/index.d.ts.map +0 -1
- package/packages/keq/dist/context/utils/watch-object.d.ts +0 -5
- package/packages/keq/dist/context/utils/watch-object.d.ts.map +0 -1
- package/packages/keq/dist/exception/abort.exception.d.ts +0 -4
- package/packages/keq/dist/exception/abort.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/exception.d.ts +0 -5
- package/packages/keq/dist/exception/exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/bad-gateway.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/bad-gateway.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/bad-request.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/bad-request.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/conflict.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/conflict.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/content-too-large.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/content-too-large.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/forbidden.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/forbidden.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/gateway-timeout.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/gateway-timeout.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/http-version-not-supported.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/http-version-not-supported.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/im-a-teapot.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/im-a-teapot.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/index.d.ts +0 -22
- package/packages/keq/dist/exception/http-exceptions/index.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/internal-server-error.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/internal-server-error.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/method-not-allowed.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/method-not-allowed.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/not-acceptable.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/not-acceptable.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/not-founded.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/not-founded.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/not-implemented.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/not-implemented.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/precondition-failed.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/precondition-failed.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/proxy-authentication-required.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/proxy-authentication-required.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/request-timeout.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/request-timeout.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/request.exception.d.ts +0 -12
- package/packages/keq/dist/exception/http-exceptions/request.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/service-unavailable.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/service-unavailable.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/too-many-requests.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/too-many-requests.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/unauthorized.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/unauthorized.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/unsupported-media-type.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/unsupported-media-type.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/http-exceptions/uri-too-long.exception.d.ts +0 -5
- package/packages/keq/dist/exception/http-exceptions/uri-too-long.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/index.d.ts +0 -6
- package/packages/keq/dist/exception/index.d.ts.map +0 -1
- package/packages/keq/dist/exception/timeout.exception.d.ts +0 -5
- package/packages/keq/dist/exception/timeout.exception.d.ts.map +0 -1
- package/packages/keq/dist/exception/type.exception.d.ts +0 -5
- package/packages/keq/dist/exception/type.exception.d.ts.map +0 -1
- package/packages/keq/dist/middleware/index.d.ts +0 -3
- package/packages/keq/dist/middleware/index.d.ts.map +0 -1
- package/packages/keq/dist/middleware/types/index.d.ts +0 -3
- package/packages/keq/dist/middleware/types/index.d.ts.map +0 -1
- package/packages/keq/dist/middleware/types/keq-middleware.d.ts +0 -8
- package/packages/keq/dist/middleware/types/keq-middleware.d.ts.map +0 -1
- package/packages/keq/dist/middleware/types/keq-next.d.ts +0 -2
- package/packages/keq/dist/middleware/types/keq-next.d.ts.map +0 -1
- package/packages/keq/dist/middleware/utils/compose-middleware.d.ts +0 -7
- package/packages/keq/dist/middleware/utils/compose-middleware.d.ts.map +0 -1
- package/packages/keq/dist/middleware/utils/get-middleware-name.d.ts +0 -3
- package/packages/keq/dist/middleware/utils/get-middleware-name.d.ts.map +0 -1
- package/packages/keq/dist/middleware/utils/index.d.ts +0 -3
- package/packages/keq/dist/middleware/utils/index.d.ts.map +0 -1
- package/packages/keq/dist/middlewares/fetch-middleware/index.d.ts +0 -6
- package/packages/keq/dist/middlewares/fetch-middleware/index.d.ts.map +0 -1
- package/packages/keq/dist/middlewares/flow-control-middleware/abort-flow-control-middleware.d.ts +0 -3
- package/packages/keq/dist/middlewares/flow-control-middleware/abort-flow-control-middleware.d.ts.map +0 -1
- package/packages/keq/dist/middlewares/flow-control-middleware/index.d.ts +0 -4
- package/packages/keq/dist/middlewares/flow-control-middleware/index.d.ts.map +0 -1
- package/packages/keq/dist/middlewares/flow-control-middleware/serial-flow-control-middleware.d.ts +0 -3
- package/packages/keq/dist/middlewares/flow-control-middleware/serial-flow-control-middleware.d.ts.map +0 -1
- package/packages/keq/dist/middlewares/flow-control-middleware/types/keq-flow-control.d.ts +0 -9
- package/packages/keq/dist/middlewares/flow-control-middleware/types/keq-flow-control.d.ts.map +0 -1
- package/packages/keq/dist/middlewares/index.d.ts +0 -4
- package/packages/keq/dist/middlewares/index.d.ts.map +0 -1
- package/packages/keq/dist/middlewares/timeout-middleware/index.d.ts +0 -6
- package/packages/keq/dist/middlewares/timeout-middleware/index.d.ts.map +0 -1
- package/packages/keq/dist/orchestrator/executor.d.ts +0 -13
- package/packages/keq/dist/orchestrator/executor.d.ts.map +0 -1
- package/packages/keq/dist/orchestrator/index.d.ts +0 -3
- package/packages/keq/dist/orchestrator/index.d.ts.map +0 -1
- package/packages/keq/dist/orchestrator/orchestrator.d.ts +0 -25
- package/packages/keq/dist/orchestrator/orchestrator.d.ts.map +0 -1
- package/packages/keq/dist/request/core.d.ts +0 -48
- package/packages/keq/dist/request/core.d.ts.map +0 -1
- package/packages/keq/dist/request/create-request.d.ts +0 -7
- package/packages/keq/dist/request/create-request.d.ts.map +0 -1
- package/packages/keq/dist/request/index.d.ts +0 -6
- package/packages/keq/dist/request/index.d.ts.map +0 -1
- package/packages/keq/dist/request/keq.d.ts +0 -120
- package/packages/keq/dist/request/keq.d.ts.map +0 -1
- package/packages/keq/dist/request/request.d.ts +0 -79
- package/packages/keq/dist/request/request.d.ts.map +0 -1
- package/packages/keq/dist/request/types/api-schema/api-schema-select.d.ts +0 -42
- package/packages/keq/dist/request/types/api-schema/api-schema-select.d.ts.map +0 -1
- package/packages/keq/dist/request/types/api-schema/api-schema.d.ts +0 -8
- package/packages/keq/dist/request/types/api-schema/api-schema.d.ts.map +0 -1
- package/packages/keq/dist/request/types/api-schema/default-operation.d.ts +0 -18
- package/packages/keq/dist/request/types/api-schema/default-operation.d.ts.map +0 -1
- package/packages/keq/dist/request/types/api-schema/extract-method-operations.d.ts +0 -31
- package/packages/keq/dist/request/types/api-schema/extract-method-operations.d.ts.map +0 -1
- package/packages/keq/dist/request/types/api-schema/index.d.ts +0 -6
- package/packages/keq/dist/request/types/api-schema/index.d.ts.map +0 -1
- package/packages/keq/dist/request/types/api-schema/operation.d.ts +0 -17
- package/packages/keq/dist/request/types/api-schema/operation.d.ts.map +0 -1
- package/packages/keq/dist/request/types/content-type.d.ts +0 -3
- package/packages/keq/dist/request/types/content-type.d.ts.map +0 -1
- package/packages/keq/dist/request/types/index.d.ts +0 -8
- package/packages/keq/dist/request/types/index.d.ts.map +0 -1
- package/packages/keq/dist/request/types/keq-attachable-file.d.ts +0 -2
- package/packages/keq/dist/request/types/keq-attachable-file.d.ts.map +0 -1
- package/packages/keq/dist/request/types/keq-param-value.d.ts +0 -3
- package/packages/keq/dist/request/types/keq-param-value.d.ts.map +0 -1
- package/packages/keq/dist/request/types/keq-query-options.d.ts +0 -7
- package/packages/keq/dist/request/types/keq-query-options.d.ts.map +0 -1
- package/packages/keq/dist/request/types/keq-query-value.d.ts +0 -8
- package/packages/keq/dist/request/types/keq-query-value.d.ts.map +0 -1
- package/packages/keq/dist/request/types/server-sent-event.d.ts +0 -3
- package/packages/keq/dist/request/types/server-sent-event.d.ts.map +0 -1
- package/packages/keq/dist/request/utils/fix-content-type.d.ts +0 -4
- package/packages/keq/dist/request/utils/fix-content-type.d.ts.map +0 -1
- package/packages/keq/dist/request/utils/get-location-id.d.ts +0 -2
- package/packages/keq/dist/request/utils/get-location-id.d.ts.map +0 -1
- package/packages/keq/dist/request/utils/index.d.ts +0 -7
- package/packages/keq/dist/request/utils/index.d.ts.map +0 -1
- package/packages/keq/dist/request/utils/intelligent-parse-response.d.ts +0 -2
- package/packages/keq/dist/request/utils/intelligent-parse-response.d.ts.map +0 -1
- package/packages/keq/dist/request/utils/merge-keq-request-body.d.ts +0 -3
- package/packages/keq/dist/request/utils/merge-keq-request-body.d.ts.map +0 -1
- package/packages/keq/dist/request/utils/query-stringify.d.ts +0 -3
- package/packages/keq/dist/request/utils/query-stringify.d.ts.map +0 -1
- package/packages/keq/dist/request/utils/resolve-with.d.ts +0 -3
- package/packages/keq/dist/request/utils/resolve-with.d.ts.map +0 -1
- package/packages/keq/dist/request-init/index.d.ts +0 -4
- package/packages/keq/dist/request-init/index.d.ts.map +0 -1
- package/packages/keq/dist/request-init/request-init.d.ts +0 -42
- package/packages/keq/dist/request-init/request-init.d.ts.map +0 -1
- package/packages/keq/dist/request-init/types/index.d.ts +0 -3
- package/packages/keq/dist/request-init/types/index.d.ts.map +0 -1
- package/packages/keq/dist/request-init/types/keq-body-init.d.ts +0 -2
- package/packages/keq/dist/request-init/types/keq-body-init.d.ts.map +0 -1
- package/packages/keq/dist/request-init/types/keq-request-method.d.ts +0 -2
- package/packages/keq/dist/request-init/types/keq-request-method.d.ts.map +0 -1
- package/packages/keq/dist/request-init/utils/assign-request-init.d.ts +0 -3
- package/packages/keq/dist/request-init/utils/assign-request-init.d.ts.map +0 -1
- package/packages/keq/dist/request-init/utils/clone-body.d.ts +0 -2
- package/packages/keq/dist/request-init/utils/clone-body.d.ts.map +0 -1
- package/packages/keq/dist/request-init/utils/clone-headers.d.ts +0 -2
- package/packages/keq/dist/request-init/utils/clone-headers.d.ts.map +0 -1
- package/packages/keq/dist/request-init/utils/clone-request-init.d.ts +0 -3
- package/packages/keq/dist/request-init/utils/clone-request-init.d.ts.map +0 -1
- package/packages/keq/dist/request-init/utils/compile-url.d.ts +0 -3
- package/packages/keq/dist/request-init/utils/compile-url.d.ts.map +0 -1
- package/packages/keq/dist/request-init/utils/index.d.ts +0 -7
- package/packages/keq/dist/request-init/utils/index.d.ts.map +0 -1
- package/packages/keq/dist/request-init/utils/to-form-data.d.ts +0 -2
- package/packages/keq/dist/request-init/utils/to-form-data.d.ts.map +0 -1
- package/packages/keq/dist/request-init/utils/to-url-search-params.d.ts +0 -2
- package/packages/keq/dist/request-init/utils/to-url-search-params.d.ts.map +0 -1
- package/packages/keq/dist/router/index.d.ts +0 -4
- package/packages/keq/dist/router/index.d.ts.map +0 -1
- package/packages/keq/dist/router/keq-host-route.d.ts +0 -3
- package/packages/keq/dist/router/keq-host-route.d.ts.map +0 -1
- package/packages/keq/dist/router/keq-location-route.d.ts +0 -3
- package/packages/keq/dist/router/keq-location-route.d.ts.map +0 -1
- package/packages/keq/dist/router/keq-method-route.d.ts +0 -3
- package/packages/keq/dist/router/keq-method-route.d.ts.map +0 -1
- package/packages/keq/dist/router/keq-module-route.d.ts +0 -3
- package/packages/keq/dist/router/keq-module-route.d.ts.map +0 -1
- package/packages/keq/dist/router/keq-pathname-route.d.ts +0 -3
- package/packages/keq/dist/router/keq-pathname-route.d.ts.map +0 -1
- package/packages/keq/dist/router/keq-router.d.ts +0 -32
- package/packages/keq/dist/router/keq-router.d.ts.map +0 -1
- package/packages/keq/dist/router/types/index.d.ts +0 -2
- package/packages/keq/dist/router/types/index.d.ts.map +0 -1
- package/packages/keq/dist/router/types/keq-route.d.ts +0 -7
- package/packages/keq/dist/router/types/keq-route.d.ts.map +0 -1
- package/packages/keq/dist/router/utils/compose-route.d.ts +0 -3
- package/packages/keq/dist/router/utils/compose-route.d.ts.map +0 -1
- package/packages/keq/dist/router/utils/index.d.ts +0 -2
- package/packages/keq/dist/router/utils/index.d.ts.map +0 -1
- package/packages/keq/dist/types/enabled-if-string-index.d.ts +0 -24
- package/packages/keq/dist/types/enabled-if-string-index.d.ts.map +0 -1
- package/packages/keq/dist/types/exclude-unknown-properties.d.ts +0 -19
- package/packages/keq/dist/types/exclude-unknown-properties.d.ts.map +0 -1
- package/packages/keq/dist/types/index-keys.d.ts +0 -18
- package/packages/keq/dist/types/index-keys.d.ts.map +0 -1
- package/packages/keq/dist/types/index.d.ts +0 -7
- package/packages/keq/dist/types/index.d.ts.map +0 -1
- package/packages/keq/dist/types/literal-keys.d.ts +0 -18
- package/packages/keq/dist/types/literal-keys.d.ts.map +0 -1
- package/packages/keq/dist/types/loose-nested-like.d.ts +0 -11
- package/packages/keq/dist/types/loose-nested-like.d.ts.map +0 -1
- package/packages/keq/dist/types/string-index-value-of.d.ts +0 -18
- package/packages/keq/dist/types/string-index-value-of.d.ts.map +0 -1
- package/packages/keq/dist/utils/base64.d.ts +0 -3
- package/packages/keq/dist/utils/base64.d.ts.map +0 -1
- package/packages/keq/dist/utils/index.d.ts +0 -4
- package/packages/keq/dist/utils/index.d.ts.map +0 -1
- package/packages/keq/dist/utils/shallow-clone.d.ts +0 -5
- package/packages/keq/dist/utils/shallow-clone.d.ts.map +0 -1
- package/packages/keq/dist/utils/sleep.d.ts +0 -2
- package/packages/keq/dist/utils/sleep.d.ts.map +0 -1
- package/packages/keq/dist/validator/index.d.ts +0 -2
- package/packages/keq/dist/validator/index.d.ts.map +0 -1
- package/packages/keq/dist/validator/validator.d.ts +0 -65
- package/packages/keq/dist/validator/validator.d.ts.map +0 -1
- package/packages/nestjs/dist/keq.module-definition.d.ts +0 -3
- package/packages/nestjs/dist/keq.module-definition.d.ts.map +0 -1
- package/packages/nestjs/dist/keq.module.d.ts +0 -7
- package/packages/nestjs/dist/keq.module.d.ts.map +0 -1
- package/packages/nestjs/dist/types/index.d.ts +0 -2
- package/packages/nestjs/dist/types/index.d.ts.map +0 -1
- package/packages/nestjs/dist/types/keq-module-options.d.ts +0 -5
- package/packages/nestjs/dist/types/keq-module-options.d.ts.map +0 -1
|
@@ -1,2968 +1,1364 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"delete",
|
|
36
|
-
"patch",
|
|
37
|
-
"head",
|
|
38
|
-
"options"
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
// src/utils/logger.ts
|
|
42
|
-
var import_chalk = __toESM(require("chalk"), 1);
|
|
43
|
-
var logger = {
|
|
44
|
-
log: (str) => console.log(import_chalk.default.green(str)),
|
|
45
|
-
warn: (str) => console.warn(import_chalk.default.yellow(str)),
|
|
46
|
-
error: (str) => console.error(import_chalk.default.red(str))
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// src/compiler/compiler.ts
|
|
50
|
-
var import_listr22 = require("listr2");
|
|
51
|
-
var import_tapable4 = require("tapable");
|
|
52
|
-
|
|
53
|
-
// src/compiler/tasks/setup/index.ts
|
|
54
|
-
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
55
|
-
var import_path = __toESM(require("path"), 1);
|
|
56
|
-
var import_cosmiconfig = require("cosmiconfig");
|
|
57
|
-
|
|
58
|
-
// src/utils/ignore-matcher.ts
|
|
59
|
-
var R = __toESM(require("ramda"), 1);
|
|
60
|
-
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
61
|
-
var IgnoreMatcher = class _IgnoreMatcher {
|
|
62
|
-
rules;
|
|
63
|
-
constructor(rules) {
|
|
64
|
-
this.rules = rules;
|
|
65
|
-
}
|
|
66
|
-
static async read(filepath) {
|
|
67
|
-
let content = await import_fs_extra.default.readFile(filepath, "utf-8");
|
|
68
|
-
content = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/#.*$/gm, "").replace(/\n+/g, "\n").trim();
|
|
69
|
-
let rules = content.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => {
|
|
70
|
-
const matched = line.match(/^(!)?\s*([^\s/]+)\s+([^\s/]+)\s+([^\s]+)$/);
|
|
71
|
-
if (!matched) throw new Error(`Invalid ignore rule: "${line}"`);
|
|
72
|
-
const [, flag, moduleName, operationMethod, operationPathname] = matched;
|
|
73
|
-
return {
|
|
74
|
-
persist: true,
|
|
75
|
-
ignore: !flag,
|
|
76
|
-
moduleName,
|
|
77
|
-
operationMethod: operationMethod.toLowerCase(),
|
|
78
|
-
operationPathname
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
rules = R.sortBy(
|
|
82
|
-
R.prop("ignore"),
|
|
83
|
-
rules
|
|
84
|
-
);
|
|
85
|
-
rules = R.uniqWith(
|
|
86
|
-
(a, b) => a.moduleName === b.moduleName && a.operationMethod === b.operationMethod && a.operationPathname === b.operationPathname,
|
|
87
|
-
rules
|
|
88
|
-
);
|
|
89
|
-
return new _IgnoreMatcher(rules);
|
|
90
|
-
}
|
|
91
|
-
async write(filepath) {
|
|
92
|
-
const ruleGroups = R.compose(
|
|
93
|
-
R.groupBy((rule) => rule.moduleName),
|
|
94
|
-
R.reverse,
|
|
95
|
-
R.uniqWith(
|
|
96
|
-
(a, b) => a.moduleName === b.moduleName && a.operationMethod === b.operationMethod && a.operationPathname === b.operationPathname
|
|
97
|
-
),
|
|
98
|
-
R.filter((rule) => rule.persist)
|
|
99
|
-
)(this.rules);
|
|
100
|
-
const content = Object.entries(ruleGroups).sort((a, b) => {
|
|
101
|
-
const aModuleName = a[0];
|
|
102
|
-
const bModuleName = b[0];
|
|
103
|
-
if (aModuleName === "*") return -1;
|
|
104
|
-
if (bModuleName === "*") return 1;
|
|
105
|
-
return aModuleName.localeCompare(bModuleName);
|
|
106
|
-
}).map(([, rules]) => (rules || []).sort((a, b) => {
|
|
107
|
-
if (a.ignore !== b.ignore) return a.ignore ? -1 : 1;
|
|
108
|
-
if (a.operationMethod === "*") return -1;
|
|
109
|
-
if (b.operationMethod === "*") return 1;
|
|
110
|
-
if (a.operationPathname === "*") return -1;
|
|
111
|
-
if (b.operationPathname === "*") return 1;
|
|
112
|
-
if (a.operationMethod !== b.operationMethod) return a.operationMethod.localeCompare(b.operationMethod);
|
|
113
|
-
if (a.operationPathname !== b.operationPathname) return a.operationPathname.localeCompare(b.operationPathname);
|
|
114
|
-
return 0;
|
|
115
|
-
}).map((rule) => `${rule.ignore ? "" : "! "}${rule.moduleName} ${rule.operationMethod.toUpperCase()} ${rule.operationPathname}`).join("\n")).join("\n\n");
|
|
116
|
-
await import_fs_extra.default.writeFile(filepath, content, "utf-8");
|
|
117
|
-
}
|
|
118
|
-
append(rule) {
|
|
119
|
-
this.rules.unshift(rule);
|
|
120
|
-
}
|
|
121
|
-
// if operation is ignored, return true
|
|
122
|
-
isOperationIgnored(operationDefinition) {
|
|
123
|
-
const moduleName = operationDefinition.module.name;
|
|
124
|
-
const operationMethod = operationDefinition.method.toLowerCase();
|
|
125
|
-
const operationPathname = operationDefinition.pathname;
|
|
126
|
-
for (const rule of this.rules) {
|
|
127
|
-
if (rule.moduleName !== "*" && rule.moduleName !== moduleName) continue;
|
|
128
|
-
if (rule.operationMethod !== "*" && rule.operationMethod !== operationMethod) continue;
|
|
129
|
-
if (rule.operationPathname !== "*" && rule.operationPathname !== operationPathname) continue;
|
|
130
|
-
return rule.ignore;
|
|
131
|
-
}
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
isModuleIgnored(moduleDefinition) {
|
|
135
|
-
const moduleName = moduleDefinition.name;
|
|
136
|
-
for (const rule of this.rules) {
|
|
137
|
-
if (!rule.ignore) {
|
|
138
|
-
if (rule.moduleName === "*" || rule.moduleName === moduleName) return false;
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
if (rule.operationMethod !== "*") continue;
|
|
142
|
-
if (rule.operationPathname !== "*") continue;
|
|
143
|
-
if (rule.moduleName === "*" || rule.moduleName === moduleName) return true;
|
|
144
|
-
}
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// src/compiler/tasks/setup/utils/find-nearest-package-json.ts
|
|
150
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
151
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
152
|
-
function findNearestPackageJson(startDir = process.cwd()) {
|
|
153
|
-
let dir = startDir;
|
|
154
|
-
while (true) {
|
|
155
|
-
const pkgPath = import_node_path.default.join(dir, "package.json");
|
|
156
|
-
if (import_node_fs.default.existsSync(pkgPath)) {
|
|
157
|
-
const json = JSON.parse(import_node_fs.default.readFileSync(pkgPath, "utf8"));
|
|
158
|
-
return { json, path: pkgPath };
|
|
159
|
-
}
|
|
160
|
-
const parent = import_node_path.default.dirname(dir);
|
|
161
|
-
if (parent === dir) break;
|
|
162
|
-
dir = parent;
|
|
163
|
-
}
|
|
164
|
-
return null;
|
|
2
|
+
const require_logger = require("./logger-D7PyVZo3.cjs");
|
|
3
|
+
const require_compiler = require("./compiler-0Kli6UCr.cjs");
|
|
4
|
+
const require_plugins = require("./plugins-CgMhaNZq.cjs");
|
|
5
|
+
let fs_extra = require("fs-extra");
|
|
6
|
+
fs_extra = require_logger.__toESM(fs_extra, 1);
|
|
7
|
+
let path = require("path");
|
|
8
|
+
path = require_logger.__toESM(path, 1);
|
|
9
|
+
let cosmiconfig = require("cosmiconfig");
|
|
10
|
+
let ramda = require("ramda");
|
|
11
|
+
ramda = require_logger.__toESM(ramda, 1);
|
|
12
|
+
let picomatch = require("picomatch");
|
|
13
|
+
picomatch = require_logger.__toESM(picomatch, 1);
|
|
14
|
+
let js_yaml = require("js-yaml");
|
|
15
|
+
js_yaml = require_logger.__toESM(js_yaml, 1);
|
|
16
|
+
let semver = require("semver");
|
|
17
|
+
semver = require_logger.__toESM(semver, 1);
|
|
18
|
+
let commander = require("commander");
|
|
19
|
+
let os = require("os");
|
|
20
|
+
os = require_logger.__toESM(os, 1);
|
|
21
|
+
let _modelcontextprotocol_sdk_server_mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
22
|
+
let _modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
23
|
+
let zod = require("zod");
|
|
24
|
+
//#region src/utils/xprod-merge.ts
|
|
25
|
+
/**
|
|
26
|
+
* 对多个对象数组执行笛卡尔积合并
|
|
27
|
+
* @example
|
|
28
|
+
* xprodMerge([{ a: 1 }, { a: 2 }], [{b: 1}], [{ c: 1 }])
|
|
29
|
+
* // => [{ a: 1, b: 1, c: 1}, { a: 2, b:1, c: 1 }]
|
|
30
|
+
*/
|
|
31
|
+
function xprodMerge(...lists) {
|
|
32
|
+
if (lists.length === 0) return [];
|
|
33
|
+
if (lists.length === 1) return lists[0];
|
|
34
|
+
return lists.reduce((acc, curr) => ramda.chain((item1) => ramda.map((item2) => ramda.mergeAll([item1, item2]), curr), acc));
|
|
165
35
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
function
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// src/compiler/tasks/setup/utils/parse-runtime-config.ts
|
|
176
|
-
var import_value = require("@sinclair/typebox/value");
|
|
177
|
-
|
|
178
|
-
// src/types/address.ts
|
|
179
|
-
var import_typebox = require("@sinclair/typebox");
|
|
180
|
-
var Address = import_typebox.Type.Object({
|
|
181
|
-
url: import_typebox.Type.String(),
|
|
182
|
-
headers: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.String(), { default: {} })),
|
|
183
|
-
encoding: import_typebox.Type.Optional(
|
|
184
|
-
import_typebox.Type.Union([
|
|
185
|
-
import_typebox.Type.Literal("utf8"),
|
|
186
|
-
import_typebox.Type.Literal("ascii")
|
|
187
|
-
], { default: "utf8" })
|
|
188
|
-
)
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// src/types/runtime-config.ts
|
|
192
|
-
var R2 = __toESM(require("ramda"), 1);
|
|
193
|
-
var import_typebox2 = require("@sinclair/typebox");
|
|
194
|
-
|
|
195
|
-
// src/constants/file-naming-style.ts
|
|
196
|
-
var FileNamingStyle = /* @__PURE__ */ ((FileNamingStyle2) => {
|
|
197
|
-
FileNamingStyle2["camelCase"] = "camelCase";
|
|
198
|
-
FileNamingStyle2["capitalCase"] = "capitalCase";
|
|
199
|
-
FileNamingStyle2["constantCase"] = "constantCase";
|
|
200
|
-
FileNamingStyle2["dotCase"] = "dotCase";
|
|
201
|
-
FileNamingStyle2["headerCase"] = "headerCase";
|
|
202
|
-
FileNamingStyle2["noCase"] = "noCase";
|
|
203
|
-
FileNamingStyle2["paramCase"] = "paramCase";
|
|
204
|
-
FileNamingStyle2["pascalCase"] = "pascalCase";
|
|
205
|
-
FileNamingStyle2["pathCase"] = "pathCase";
|
|
206
|
-
FileNamingStyle2["sentenceCase"] = "sentenceCase";
|
|
207
|
-
FileNamingStyle2["snakeCase"] = "snakeCase";
|
|
208
|
-
return FileNamingStyle2;
|
|
209
|
-
})(FileNamingStyle || {});
|
|
210
|
-
|
|
211
|
-
// src/utils/is-valid-url.ts
|
|
212
|
-
var URL_REGEX = /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/(?:[^\s@]+@)?[^\s/:?#]*(?::\d+)?(?:\/[^\s?#]*)?(?:\?[^\s#]*)?(?:#[^\s]*)?$/;
|
|
213
|
-
function isValidURL(url) {
|
|
214
|
-
return URL_REGEX.test(url);
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/commands/utils/xprod-filter-rules.ts
|
|
38
|
+
function xprodFilterRules(options) {
|
|
39
|
+
return xprodMerge((options.module || ["*"]).map((moduleName) => ({
|
|
40
|
+
deny: false,
|
|
41
|
+
persist: options.persist,
|
|
42
|
+
moduleName
|
|
43
|
+
})), options.method ? [{ operationMethod: options.method.toLowerCase() }] : [{ operationMethod: "*" }], options.pathname ? [{ operationPathname: options.pathname }] : [{ operationPathname: "/**" }]);
|
|
215
44
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
import_typebox2.Type.Literal("nestjs-module"),
|
|
252
|
-
import_typebox2.Type.Literal("none")
|
|
253
|
-
], { default: "micro-function" })
|
|
254
|
-
),
|
|
255
|
-
/**
|
|
256
|
-
* Whether to generate ES Module code
|
|
257
|
-
*
|
|
258
|
-
* If not specified, the module system will be inferred from the nearest package.json "type" field
|
|
259
|
-
* or defaults to "cjs" if no package.json is found.
|
|
260
|
-
*/
|
|
261
|
-
esm: import_typebox2.Type.Optional(import_typebox2.Type.Boolean({ default: false })),
|
|
262
|
-
/**
|
|
263
|
-
* Output directory for generated files
|
|
264
|
-
*/
|
|
265
|
-
outdir: import_typebox2.Type.String({ default: `${process.cwd()}/api` }),
|
|
266
|
-
/**
|
|
267
|
-
* File naming style for generated files
|
|
268
|
-
*/
|
|
269
|
-
fileNamingStyle: import_typebox2.Type.Enum(FileNamingStyle, { default: "snakeCase" /* snakeCase */ }),
|
|
270
|
-
modules: Modules,
|
|
271
|
-
debug: import_typebox2.Type.Optional(import_typebox2.Type.Boolean({ default: false })),
|
|
272
|
-
/**
|
|
273
|
-
* Whether to tolerate wrong openapi/swagger structure
|
|
274
|
-
*/
|
|
275
|
-
tolerant: import_typebox2.Type.Optional(import_typebox2.Type.Boolean({ default: false })),
|
|
276
|
-
plugins: import_typebox2.Type.Optional(import_typebox2.Type.Array(import_typebox2.Type.Unsafe(import_typebox2.Type.Any()), { default: [] }))
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
// src/compiler/tasks/setup/utils/parse-runtime-config.ts
|
|
280
|
-
function parseRuntimeConfig(data) {
|
|
281
|
-
try {
|
|
282
|
-
const originalPlugins = typeof data === "object" && data !== null && "plugins" in data ? data.plugins : void 0;
|
|
283
|
-
const parsed = import_value.Value.Parse(RawConfig, data);
|
|
284
|
-
if (originalPlugins !== void 0) {
|
|
285
|
-
parsed.plugins = originalPlugins;
|
|
286
|
-
}
|
|
287
|
-
return parsed;
|
|
288
|
-
} catch (error) {
|
|
289
|
-
if (error instanceof Error) {
|
|
290
|
-
error.message = `Invalid Config: ${error.message}`;
|
|
291
|
-
}
|
|
292
|
-
throw error;
|
|
293
|
-
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/commands/build.ts
|
|
47
|
+
function registerBuildCommand(program) {
|
|
48
|
+
program.command("build").description("Build and generate API client code from OpenAPI/Swagger specifications").option("-c --config <config>", "The keq-cli config file").option("--module <modules...>", "Filter module(s) to generate").option("--debug", "Print debug information").option("--tolerant", "Tolerate wrong swagger/openapi structure").option("--fresh", "Clean the output directory before building").option("-i --interactive", "Interactive select the scope of generation").addOption(new commander.Option("--method <method>", "Only generate files of the specified operation method").choices([...require_plugins.SupportedMethods, ...require_plugins.SupportedMethods.map((method) => method.toUpperCase())])).option("--pathname <pathname>", "Only generate files of the specified operation pathname").action(async (options) => {
|
|
49
|
+
const filterRules = [];
|
|
50
|
+
if (options.module || options.method || options.pathname) filterRules.push({
|
|
51
|
+
deny: true,
|
|
52
|
+
persist: false,
|
|
53
|
+
moduleName: "*",
|
|
54
|
+
operationMethod: "*",
|
|
55
|
+
operationPathname: "/**"
|
|
56
|
+
}, ...xprodFilterRules({
|
|
57
|
+
module: options.module,
|
|
58
|
+
method: options.method,
|
|
59
|
+
pathname: options.pathname,
|
|
60
|
+
persist: false
|
|
61
|
+
}));
|
|
62
|
+
else if (options.interactive) filterRules.push({
|
|
63
|
+
deny: true,
|
|
64
|
+
persist: false,
|
|
65
|
+
moduleName: "*",
|
|
66
|
+
operationMethod: "*",
|
|
67
|
+
operationPathname: "/**"
|
|
68
|
+
});
|
|
69
|
+
await new require_compiler.Compiler({
|
|
70
|
+
build: true,
|
|
71
|
+
persist: true,
|
|
72
|
+
fresh: !!options.fresh,
|
|
73
|
+
config: options.config,
|
|
74
|
+
debug: !!options.debug,
|
|
75
|
+
tolerant: !!options.tolerant,
|
|
76
|
+
interactive: !!options.interactive && { mode: "allow" },
|
|
77
|
+
filter: filterRules.length > 0 ? { rules: filterRules } : void 0
|
|
78
|
+
}).run();
|
|
79
|
+
});
|
|
294
80
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/commands/filter.ts
|
|
83
|
+
function registerFilterCommand(program) {
|
|
84
|
+
program.command("filter").description("Manage filter rules for API generation using .keqfilter file").addArgument(new commander.Argument("<mode>", "The filter mode").choices([
|
|
85
|
+
"all",
|
|
86
|
+
"deny",
|
|
87
|
+
"allow"
|
|
88
|
+
]).argRequired()).option("-c --config <config>", "The keq-cli config file").option("--debug", "Print debug information").option("--tolerant", "Tolerate wrong swagger/openapi structure").option("--module <modules...>").option("--build", "Build after updating .keqfilter file").addOption(new commander.Option("--method <method>", "Only generate files of the specified operation method").choices([...require_plugins.SupportedMethods, ...require_plugins.SupportedMethods.map((method) => method.toUpperCase())])).option("--pathname <pathnames>", "Only generate files of the specified operation pathname").option("-i --interactive", "Interactive select the scope of generation").action(async (mode, options) => {
|
|
89
|
+
let compiler;
|
|
90
|
+
if (mode === "all") {
|
|
91
|
+
if (options.build) throw new Error("'--build' cannot be used with 'all' mode");
|
|
92
|
+
if (options.interactive) throw new Error("'--interactive' cannot be used with 'all' mode");
|
|
93
|
+
if (options.module) throw new Error("'--module' cannot be used with 'all' mode");
|
|
94
|
+
if (options.method) throw new Error("'--method' cannot be used with 'all' mode");
|
|
95
|
+
if (options.pathname) throw new Error("'--pathname' cannot be used with 'all' mode");
|
|
96
|
+
compiler = new require_compiler.Compiler({
|
|
97
|
+
build: false,
|
|
98
|
+
persist: true,
|
|
99
|
+
config: options.config,
|
|
100
|
+
debug: !!options.debug,
|
|
101
|
+
tolerant: !!options.tolerant,
|
|
102
|
+
interactive: false,
|
|
103
|
+
filter: { rules: [{
|
|
104
|
+
persist: true,
|
|
105
|
+
deny: true,
|
|
106
|
+
moduleName: "*",
|
|
107
|
+
operationMethod: "*",
|
|
108
|
+
operationPathname: "/**"
|
|
109
|
+
}] }
|
|
110
|
+
});
|
|
111
|
+
} else if (options.interactive) {
|
|
112
|
+
if (options.interactive) {
|
|
113
|
+
if (options.method) throw new Error("'--method' cannot be used with '--interactive'");
|
|
114
|
+
if (options.pathname) throw new Error("'--pathname' cannot be used with '--interactive'");
|
|
115
|
+
}
|
|
116
|
+
compiler = new require_compiler.Compiler({
|
|
117
|
+
build: !!options.build,
|
|
118
|
+
persist: true,
|
|
119
|
+
config: options.config,
|
|
120
|
+
debug: !!options.debug,
|
|
121
|
+
tolerant: !!options.tolerant,
|
|
122
|
+
interactive: {
|
|
123
|
+
mode,
|
|
124
|
+
persist: true
|
|
125
|
+
},
|
|
126
|
+
filter: { rules: [{
|
|
127
|
+
persist: false,
|
|
128
|
+
deny: true,
|
|
129
|
+
moduleName: "*",
|
|
130
|
+
operationMethod: "*",
|
|
131
|
+
operationPathname: "/**"
|
|
132
|
+
}] }
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
if (!options.method && !options.pathname) throw new Error("at least one of '-i --interactive', '--method' or '--pathname' must be specified");
|
|
136
|
+
const moduleNames = options.module || ["*"];
|
|
137
|
+
compiler = new require_compiler.Compiler({
|
|
138
|
+
build: !!options.build,
|
|
139
|
+
persist: true,
|
|
140
|
+
config: options.config,
|
|
141
|
+
debug: !!options.debug,
|
|
142
|
+
tolerant: !!options.tolerant,
|
|
143
|
+
filter: { rules: moduleNames.map((moduleNames) => ({
|
|
144
|
+
persist: true,
|
|
145
|
+
deny: mode === "deny",
|
|
146
|
+
moduleName: moduleNames,
|
|
147
|
+
operationMethod: options.method,
|
|
148
|
+
operationPathname: options.pathname
|
|
149
|
+
})) },
|
|
150
|
+
interactive: false
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
await compiler.run();
|
|
154
|
+
});
|
|
338
155
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
*/
|
|
373
|
-
append(anchorName, content) {
|
|
374
|
-
const lines = this.artifact.content.split("\n");
|
|
375
|
-
const anchor = `@anchor:${anchorName}:end`;
|
|
376
|
-
const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`));
|
|
377
|
-
if (anchorIndex === -1) {
|
|
378
|
-
throw new Error(`"${anchor}" not found in artifact "${this.artifact.filepath}".`);
|
|
379
|
-
}
|
|
380
|
-
lines.splice(anchorIndex, 0, content);
|
|
381
|
-
this.artifact.content = lines.join("\n");
|
|
382
|
-
}
|
|
383
|
-
prepend(anchorName, content) {
|
|
384
|
-
const lines = this.artifact.content.split("\n");
|
|
385
|
-
const anchor = `@anchor:${anchorName}:start`;
|
|
386
|
-
const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`));
|
|
387
|
-
if (anchorIndex === -1) {
|
|
388
|
-
throw new Error(`"${anchor}" not found in artifact "${this.artifact.filepath}".`);
|
|
389
|
-
}
|
|
390
|
-
lines.splice(anchorIndex + 1, 0, content);
|
|
391
|
-
this.artifact.content = lines.join("\n");
|
|
392
|
-
}
|
|
393
|
-
replace(anchorName, content) {
|
|
394
|
-
const lines = this.artifact.content.split("\n");
|
|
395
|
-
const startIndex = lines.findIndex((line) => line.includes(`/* @anchor:${anchorName}:start */`));
|
|
396
|
-
const endIndex = lines.findIndex((line) => line.includes(`/* @anchor:${anchorName}:end */`));
|
|
397
|
-
if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex) {
|
|
398
|
-
throw new Error(`"@anchor:${anchorName}:start" or "@anchor:${anchorName}:end" not found in artifact "${this.artifact.filepath}".`);
|
|
399
|
-
}
|
|
400
|
-
lines.splice(startIndex + 1, endIndex - startIndex - 1, content);
|
|
401
|
-
this.artifact.content = lines.join("\n");
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
var Anchor = class {
|
|
405
|
-
constructor(artifact) {
|
|
406
|
-
this.artifact = artifact;
|
|
407
|
-
this.block = new AnchorBlock(artifact);
|
|
408
|
-
}
|
|
409
|
-
block;
|
|
410
|
-
append(anchorName, content) {
|
|
411
|
-
const lines = this.artifact.content.split("\n");
|
|
412
|
-
const anchor = `@anchor:${anchorName}`;
|
|
413
|
-
const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`));
|
|
414
|
-
if (anchorIndex === -1) {
|
|
415
|
-
throw new Error(`"${anchor}" not found in artifact "${this.artifact.filepath}".`);
|
|
416
|
-
}
|
|
417
|
-
lines.splice(anchorIndex + 1, 0, content);
|
|
418
|
-
this.artifact.content = lines.join("\n");
|
|
419
|
-
}
|
|
420
|
-
prepend(anchorName, content) {
|
|
421
|
-
const lines = this.artifact.content.split("\n");
|
|
422
|
-
const anchor = `@anchor:${anchorName}`;
|
|
423
|
-
const anchorIndex = lines.findIndex((line) => line.includes(`/* ${anchor} */`));
|
|
424
|
-
if (anchorIndex === -1) {
|
|
425
|
-
throw new Error(`"${anchor}" not found in artifact "${this.artifact.filepath}".`);
|
|
426
|
-
}
|
|
427
|
-
lines.splice(anchorIndex, 0, content);
|
|
428
|
-
this.artifact.content = lines.join("\n");
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
// src/models/artifact.ts
|
|
433
|
-
var HeaderComment = [
|
|
434
|
-
"// Code generated by keq-cli. DO NOT EDIT.",
|
|
435
|
-
"// Code generated by keq-cli. DO NOT EDIT.",
|
|
436
|
-
"// Code generated by keq-cli. DO NOT EDIT.",
|
|
437
|
-
"",
|
|
438
|
-
""
|
|
439
|
-
].join("\n");
|
|
440
|
-
var Artifact = class {
|
|
441
|
-
id;
|
|
442
|
-
filepath;
|
|
443
|
-
content;
|
|
444
|
-
extensionName;
|
|
445
|
-
anchor = new Anchor(this);
|
|
446
|
-
constructor(options) {
|
|
447
|
-
this.id = options.id;
|
|
448
|
-
this.filepath = options.filepath;
|
|
449
|
-
this.extensionName = options.extensionName || path3.extname(options.filepath);
|
|
450
|
-
this.content = options.content;
|
|
451
|
-
}
|
|
452
|
-
get dirname() {
|
|
453
|
-
return path3.dirname(this.filepath);
|
|
454
|
-
}
|
|
455
|
-
renderer() {
|
|
456
|
-
return `${HeaderComment}${this.content}`;
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
// src/models/api-document_v3_1.ts
|
|
461
|
-
var R5 = __toESM(require("ramda"), 1);
|
|
462
|
-
|
|
463
|
-
// src/models/module-definition.ts
|
|
464
|
-
var ModuleDefinition = class _ModuleDefinition {
|
|
465
|
-
name;
|
|
466
|
-
address;
|
|
467
|
-
constructor(name, address) {
|
|
468
|
-
this.name = name;
|
|
469
|
-
if (typeof address === "string") {
|
|
470
|
-
this.address = { url: address, headers: {}, encoding: "utf8" };
|
|
471
|
-
} else {
|
|
472
|
-
this.address = address;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
static unknown() {
|
|
476
|
-
return new _ModuleDefinition("", { url: "", headers: {}, encoding: "utf8" });
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
// src/models/operation-definition.ts
|
|
481
|
-
var R4 = __toESM(require("ramda"), 1);
|
|
482
|
-
|
|
483
|
-
// src/utils/is-keywords.ts
|
|
484
|
-
var keywords = [
|
|
485
|
-
"break",
|
|
486
|
-
"case",
|
|
487
|
-
"catch",
|
|
488
|
-
"continue",
|
|
489
|
-
"default",
|
|
490
|
-
"delete",
|
|
491
|
-
"do",
|
|
492
|
-
"else",
|
|
493
|
-
"finally",
|
|
494
|
-
"for",
|
|
495
|
-
"function",
|
|
496
|
-
"if",
|
|
497
|
-
"in",
|
|
498
|
-
"instanceof",
|
|
499
|
-
"new",
|
|
500
|
-
"return",
|
|
501
|
-
"switch",
|
|
502
|
-
"this",
|
|
503
|
-
"throw",
|
|
504
|
-
"try",
|
|
505
|
-
"typeof",
|
|
506
|
-
"var",
|
|
507
|
-
"void",
|
|
508
|
-
"while",
|
|
509
|
-
"with"
|
|
510
|
-
];
|
|
511
|
-
function isKeywords(str) {
|
|
512
|
-
return keywords.includes(str);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
// src/utils/is-reserved-word.ts
|
|
516
|
-
var reservedWords = [
|
|
517
|
-
"abstract",
|
|
518
|
-
"boolean",
|
|
519
|
-
"byte",
|
|
520
|
-
"char",
|
|
521
|
-
"class",
|
|
522
|
-
"const",
|
|
523
|
-
"debugger",
|
|
524
|
-
"double",
|
|
525
|
-
"enum",
|
|
526
|
-
"export",
|
|
527
|
-
"extends",
|
|
528
|
-
"final",
|
|
529
|
-
"float",
|
|
530
|
-
"goto",
|
|
531
|
-
"implements",
|
|
532
|
-
"import",
|
|
533
|
-
"int",
|
|
534
|
-
"interface",
|
|
535
|
-
"long",
|
|
536
|
-
"native",
|
|
537
|
-
"package",
|
|
538
|
-
"private",
|
|
539
|
-
"protected",
|
|
540
|
-
"public",
|
|
541
|
-
"short",
|
|
542
|
-
"static",
|
|
543
|
-
"super",
|
|
544
|
-
"synchronized",
|
|
545
|
-
"throws",
|
|
546
|
-
"transient",
|
|
547
|
-
"volatile"
|
|
548
|
-
];
|
|
549
|
-
function isReservedWord(str) {
|
|
550
|
-
return reservedWords.includes(str);
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
// src/models/operation-definition.ts
|
|
554
|
-
var import_jsonpath_plus2 = require("jsonpath-plus");
|
|
555
|
-
|
|
556
|
-
// src/models/schema-definition.ts
|
|
557
|
-
var R3 = __toESM(require("ramda"), 1);
|
|
558
|
-
var import_jsonpath_plus = require("jsonpath-plus");
|
|
559
|
-
var SchemaDefinition = class _SchemaDefinition {
|
|
560
|
-
name;
|
|
561
|
-
schema;
|
|
562
|
-
module;
|
|
563
|
-
document;
|
|
564
|
-
get id() {
|
|
565
|
-
return `${this.module.address}#/components/schemas/${this.name}`;
|
|
566
|
-
}
|
|
567
|
-
constructor(args) {
|
|
568
|
-
this.module = args.module;
|
|
569
|
-
this.name = args.name;
|
|
570
|
-
this.schema = args.schema;
|
|
571
|
-
this.document = args.document;
|
|
572
|
-
}
|
|
573
|
-
getDependencies() {
|
|
574
|
-
const refs = R3.uniq((0, import_jsonpath_plus.JSONPath)({
|
|
575
|
-
path: "$..*['$ref']",
|
|
576
|
-
json: this.schema
|
|
577
|
-
}));
|
|
578
|
-
return refs.filter((ref) => typeof ref === "string" && !!ref.trim()).map((ref) => {
|
|
579
|
-
const definition = this.document.dereference(ref);
|
|
580
|
-
if (definition) return definition;
|
|
581
|
-
return _SchemaDefinition.unknown();
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
static unknown() {
|
|
585
|
-
return new _SchemaDefinition({
|
|
586
|
-
name: "",
|
|
587
|
-
schema: {},
|
|
588
|
-
module: ModuleDefinition.unknown(),
|
|
589
|
-
document: ApiDocumentV3_1.unknown()
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
static isUnknown(definition) {
|
|
593
|
-
return definition.name === "";
|
|
594
|
-
}
|
|
595
|
-
};
|
|
596
|
-
|
|
597
|
-
// src/models/operation-definition.ts
|
|
598
|
-
var OperationDefinition = class {
|
|
599
|
-
module;
|
|
600
|
-
operationId;
|
|
601
|
-
method;
|
|
602
|
-
pathname;
|
|
603
|
-
operation;
|
|
604
|
-
document;
|
|
605
|
-
get id() {
|
|
606
|
-
return `${this.module.address}#/paths/${this.pathname}/${this.method}`;
|
|
607
|
-
}
|
|
608
|
-
constructor(args) {
|
|
609
|
-
this.module = args.module;
|
|
610
|
-
this.method = args.method.toLowerCase();
|
|
611
|
-
this.pathname = args.pathname;
|
|
612
|
-
this.document = args.document;
|
|
613
|
-
this.operationId = this.formatOperationId(args.method, args.pathname, args.operation);
|
|
614
|
-
this.operation = {
|
|
615
|
-
...args.operation,
|
|
616
|
-
operationId: this.operationId
|
|
617
|
-
};
|
|
618
|
-
}
|
|
619
|
-
formatOperationId(method, pathname, operation) {
|
|
620
|
-
const operationId = operation.operationId;
|
|
621
|
-
if (operationId && operationId !== "index" && !isKeywords(operationId) && !isReservedWord(operationId)) {
|
|
622
|
-
return operationId;
|
|
623
|
-
}
|
|
624
|
-
return `${method}_${pathname}`.replace(/\//g, "_").replace(/-/g, "_").replace(/:/g, "$$").replace(/{(.+)}/, "$$$1");
|
|
625
|
-
}
|
|
626
|
-
getDependencies() {
|
|
627
|
-
const refs = R4.uniq([
|
|
628
|
-
...(0, import_jsonpath_plus2.JSONPath)({
|
|
629
|
-
path: "$.requestBody.content..schema..$ref",
|
|
630
|
-
json: this.operation
|
|
631
|
-
}),
|
|
632
|
-
...(0, import_jsonpath_plus2.JSONPath)({
|
|
633
|
-
path: "$.responses..content..schema..$ref",
|
|
634
|
-
json: this.operation
|
|
635
|
-
}),
|
|
636
|
-
...(0, import_jsonpath_plus2.JSONPath)({
|
|
637
|
-
path: "$.parameters..schema..$ref",
|
|
638
|
-
json: this.operation
|
|
639
|
-
})
|
|
640
|
-
]);
|
|
641
|
-
const dependencies = refs.filter((ref) => typeof ref === "string" && ref).map((ref) => {
|
|
642
|
-
const schemaDefinition = this.document.dereference(ref);
|
|
643
|
-
if (schemaDefinition) return schemaDefinition;
|
|
644
|
-
return SchemaDefinition.unknown();
|
|
645
|
-
});
|
|
646
|
-
return dependencies;
|
|
647
|
-
}
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
// src/models/api-document_v3_1.ts
|
|
651
|
-
var ApiDocumentV3_1 = class _ApiDocumentV3_1 {
|
|
652
|
-
module;
|
|
653
|
-
specification;
|
|
654
|
-
constructor(specification, module2) {
|
|
655
|
-
this.module = module2;
|
|
656
|
-
this.specification = specification;
|
|
657
|
-
}
|
|
658
|
-
get schemas() {
|
|
659
|
-
const module2 = this.module;
|
|
660
|
-
return Object.entries(this.specification.components?.schemas || {}).map(([name, schema]) => new SchemaDefinition({
|
|
661
|
-
name,
|
|
662
|
-
schema,
|
|
663
|
-
module: module2,
|
|
664
|
-
document: this
|
|
665
|
-
}));
|
|
666
|
-
}
|
|
667
|
-
get operations() {
|
|
668
|
-
const module2 = this.module;
|
|
669
|
-
return Object.entries(this.specification.paths || {}).flatMap(([pathname, pathItem]) => Object.entries(pathItem || {}).filter(([method]) => SupportedMethods.includes(method.toLowerCase())).map(([method, operation]) => new OperationDefinition({
|
|
670
|
-
method,
|
|
671
|
-
pathname,
|
|
672
|
-
operation,
|
|
673
|
-
module: module2,
|
|
674
|
-
document: this
|
|
675
|
-
})));
|
|
676
|
-
}
|
|
677
|
-
isEmpty() {
|
|
678
|
-
return R5.isEmpty(this.specification.paths);
|
|
679
|
-
}
|
|
680
|
-
dereference($ref) {
|
|
681
|
-
if ($ref.startsWith("#/")) {
|
|
682
|
-
return this.schemas.find((schema) => schema.id.endsWith($ref));
|
|
683
|
-
}
|
|
684
|
-
logger.warn(`The $ref(${$ref}) is not defined in ${this.module.name} openapi/swagger.`);
|
|
685
|
-
}
|
|
686
|
-
isRefDefined($ref) {
|
|
687
|
-
if ($ref.startsWith("#/")) {
|
|
688
|
-
const path13 = $ref.replace("#/", "").split("/");
|
|
689
|
-
return R5.path(path13, this.specification) !== void 0;
|
|
690
|
-
}
|
|
691
|
-
return false;
|
|
692
|
-
}
|
|
693
|
-
static unknown() {
|
|
694
|
-
return new _ApiDocumentV3_1({}, ModuleDefinition.unknown());
|
|
695
|
-
}
|
|
696
|
-
};
|
|
697
|
-
|
|
698
|
-
// src/models/asset.ts
|
|
699
|
-
var Asset = class {
|
|
700
|
-
path;
|
|
701
|
-
constructor(path13) {
|
|
702
|
-
this.path = path13;
|
|
703
|
-
}
|
|
704
|
-
};
|
|
705
|
-
|
|
706
|
-
// src/exception.ts
|
|
707
|
-
var import_ts_custom_error = require("ts-custom-error");
|
|
708
|
-
var import_word_wrap = __toESM(require("word-wrap"), 1);
|
|
709
|
-
var Exception = class extends import_ts_custom_error.CustomError {
|
|
710
|
-
constructor(module2, message) {
|
|
711
|
-
const moduleName = typeof module2 === "string" ? module2 : module2.name;
|
|
712
|
-
const msg = (0, import_word_wrap.default)(message, { width: 60, indent: " " });
|
|
713
|
-
super(`${moduleName} module failed to compile:
|
|
714
|
-
${msg}`);
|
|
715
|
-
Object.defineProperty(this, "name", { value: "KeqCLI_Exception" });
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
|
-
|
|
719
|
-
// src/utils/openapi-utils/dereference.ts
|
|
720
|
-
function dereference($ref, swagger) {
|
|
721
|
-
let value;
|
|
722
|
-
for (const key of $ref.split("/")) {
|
|
723
|
-
if (key === "#") {
|
|
724
|
-
value = swagger;
|
|
725
|
-
} else {
|
|
726
|
-
value = value[key];
|
|
727
|
-
}
|
|
728
|
-
if (!value) break;
|
|
729
|
-
}
|
|
730
|
-
return value;
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/utils/scan-generated-files.ts
|
|
158
|
+
/**
|
|
159
|
+
* Recursively find all files in a directory
|
|
160
|
+
*/
|
|
161
|
+
async function findAllFiles(dir, extensions) {
|
|
162
|
+
const results = [];
|
|
163
|
+
async function scan(currentDir) {
|
|
164
|
+
let entries;
|
|
165
|
+
try {
|
|
166
|
+
entries = await fs_extra.default.readdir(currentDir);
|
|
167
|
+
} catch (err) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
for (const entry of entries) {
|
|
171
|
+
if (entry === "node_modules" || entry === ".git") continue;
|
|
172
|
+
const fullPath = path.join(currentDir, entry);
|
|
173
|
+
let stat;
|
|
174
|
+
try {
|
|
175
|
+
stat = await fs_extra.default.stat(fullPath);
|
|
176
|
+
} catch (err) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (stat.isDirectory()) await scan(fullPath);
|
|
180
|
+
else if (stat.isFile()) if (!extensions) results.push(fullPath);
|
|
181
|
+
else {
|
|
182
|
+
const ext = path.extname(fullPath);
|
|
183
|
+
if (extensions.includes(ext)) results.push(fullPath);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
await scan(dir);
|
|
188
|
+
return results;
|
|
731
189
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
var R6 = __toESM(require("ramda"), 1);
|
|
745
|
-
function isRefDefined($ref, swagger) {
|
|
746
|
-
if ($ref.startsWith("#/")) {
|
|
747
|
-
const path13 = $ref.replace("#/", "").split("/");
|
|
748
|
-
return R6.path(path13, swagger) !== void 0;
|
|
749
|
-
}
|
|
750
|
-
return false;
|
|
190
|
+
/**
|
|
191
|
+
* Scan all files in the output directory
|
|
192
|
+
* @param outdir The output directory to scan
|
|
193
|
+
* @returns List of all files with their paths
|
|
194
|
+
*/
|
|
195
|
+
async function scanAllFiles(outdir) {
|
|
196
|
+
const absoluteOutdir = path.resolve(outdir);
|
|
197
|
+
if (!await fs_extra.default.exists(absoluteOutdir)) return [];
|
|
198
|
+
return (await findAllFiles(absoluteOutdir)).map((file) => ({
|
|
199
|
+
absolutePath: file,
|
|
200
|
+
relativePath: path.relative(absoluteOutdir, file)
|
|
201
|
+
}));
|
|
751
202
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
return shadow;
|
|
203
|
+
/**
|
|
204
|
+
* Find invalid files that are not in the current artifacts list
|
|
205
|
+
* This includes both non-generated files and outdated generated files
|
|
206
|
+
* @param outdir The output directory
|
|
207
|
+
* @param validFilePaths List of valid file paths (relative to outdir)
|
|
208
|
+
* @returns List of invalid files
|
|
209
|
+
*/
|
|
210
|
+
async function findInvalidFiles(outdir, validFilePaths) {
|
|
211
|
+
const allFiles = await scanAllFiles(outdir);
|
|
212
|
+
const validPathsSet = new Set(validFilePaths.map((p) => path.normalize(p)));
|
|
213
|
+
return allFiles.filter((file) => {
|
|
214
|
+
const normalizedPath = path.normalize(file.relativePath);
|
|
215
|
+
return !validPathsSet.has(normalizedPath);
|
|
216
|
+
});
|
|
767
217
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
function
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/commands/list.ts
|
|
220
|
+
function registerListCommand(program) {
|
|
221
|
+
program.command("list").description("List generated files based on current configuration").option("-c --config <config>", "The keq-cli config file").option("--invalid", "List only invalid generated files (files not in current build)").option("--debug", "Print debug information").option("--tolerant", "Tolerate wrong swagger/openapi structure").action(async (options) => {
|
|
222
|
+
const compiler = new require_compiler.Compiler({
|
|
223
|
+
build: true,
|
|
224
|
+
persist: false,
|
|
225
|
+
silent: true,
|
|
226
|
+
config: options.config,
|
|
227
|
+
debug: !!options.debug,
|
|
228
|
+
tolerant: !!options.tolerant
|
|
229
|
+
});
|
|
230
|
+
await compiler.run();
|
|
231
|
+
const context = compiler.context;
|
|
232
|
+
if (!context.rc) throw new Error("Failed to load configuration");
|
|
233
|
+
if (options.invalid) {
|
|
234
|
+
const validFilePaths = (context.artifacts || []).map((artifact) => artifact.filepath);
|
|
235
|
+
const invalidFiles = await findInvalidFiles(context.rc.outdir, validFilePaths);
|
|
236
|
+
for (const file of invalidFiles) {
|
|
237
|
+
const fullPath = `./${path.join(context.rc.outdir, file.relativePath)}`;
|
|
238
|
+
console.log(fullPath);
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
const artifacts = context.artifacts || [];
|
|
242
|
+
for (const artifact of artifacts) {
|
|
243
|
+
const fullPath = `./${path.join(context.rc.outdir, artifact.filepath)}`;
|
|
244
|
+
console.log(fullPath);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
});
|
|
780
248
|
}
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/commands/apis.ts
|
|
251
|
+
function registerApisCommand(program) {
|
|
252
|
+
program.command("apis").description("List API operations and components from OpenAPI/Swagger specifications").option("-c --config <config>", "The keq-cli config file").option("--tolerant", "Tolerate wrong swagger/openapi structure").addOption(new commander.Option("--includes <includes...>", "Include specific parts").choices(["operations", "components"])).option("--module <modules...>", "Filter module(s) to list").addOption(new commander.Option("--method <method>", "Only generate files of the specified operation method").choices([...require_plugins.SupportedMethods, ...require_plugins.SupportedMethods.map((method) => method.toUpperCase())])).option("--pathname <pathnames>", "Only generate files of the specified operation pathname").addOption(new commander.Option("--format <format>", "Output format").choices(["compact", "json"])).option("--json", "Output in JSON format (shortcut for --format json)").option("--all", "Ignore .keqfilter rules and show all modules/operations").option("--debug", "Print debug information").action(async (options) => {
|
|
253
|
+
if (options.all && (options.module || options.method || options.pathname)) throw new Error("'--all' cannot be used with '--module', '--method', or '--pathname'");
|
|
254
|
+
const filterRules = [];
|
|
255
|
+
if (options.module || options.method || options.pathname) filterRules.push({
|
|
256
|
+
deny: true,
|
|
257
|
+
persist: false,
|
|
258
|
+
moduleName: "*",
|
|
259
|
+
operationMethod: "*",
|
|
260
|
+
operationPathname: "/**"
|
|
261
|
+
}, ...xprodFilterRules({
|
|
262
|
+
module: options.module,
|
|
263
|
+
method: options.method,
|
|
264
|
+
pathname: options.pathname,
|
|
265
|
+
persist: false
|
|
266
|
+
}));
|
|
267
|
+
const compiler = new require_compiler.Compiler({
|
|
268
|
+
build: true,
|
|
269
|
+
persist: false,
|
|
270
|
+
silent: true,
|
|
271
|
+
config: options.config,
|
|
272
|
+
debug: !!options.debug,
|
|
273
|
+
tolerant: !!options.tolerant,
|
|
274
|
+
filter: options.all ? false : filterRules.length > 0 ? { rules: filterRules } : void 0
|
|
275
|
+
});
|
|
276
|
+
await compiler.run();
|
|
277
|
+
const documents = compiler.context.documents || [];
|
|
278
|
+
const includesList = options.includes || ["operations", "components"];
|
|
279
|
+
const includeOperations = includesList.includes("operations");
|
|
280
|
+
const includeComponents = includesList.includes("components");
|
|
281
|
+
const result = documents.map((document) => {
|
|
282
|
+
const item = { module: document.module.name };
|
|
283
|
+
if (includeOperations) item.operations = document.operations.map((operation) => ({
|
|
284
|
+
method: operation.method.toUpperCase(),
|
|
285
|
+
path: operation.pathname,
|
|
286
|
+
operationId: operation.operationId,
|
|
287
|
+
summary: operation.operation.summary || "",
|
|
288
|
+
description: operation.operation.description || ""
|
|
289
|
+
}));
|
|
290
|
+
if (includeComponents) item.components = { schemas: document.schemas.map((schema) => {
|
|
291
|
+
const schemaObj = schema.schema;
|
|
292
|
+
return {
|
|
293
|
+
name: schema.name,
|
|
294
|
+
description: schemaObj.description || ""
|
|
295
|
+
};
|
|
296
|
+
}) };
|
|
297
|
+
return item;
|
|
298
|
+
});
|
|
299
|
+
const format = options.format || (options.json ? "json" : void 0);
|
|
300
|
+
if (format === "json") console.log(JSON.stringify(result, null, 2));
|
|
301
|
+
else if (format === "compact") {
|
|
302
|
+
for (const item of result) {
|
|
303
|
+
console.log(`\nModule: ${item.module}`);
|
|
304
|
+
console.log("─".repeat(70));
|
|
305
|
+
if (includeOperations) {
|
|
306
|
+
console.log("\n APIs:");
|
|
307
|
+
if (!item.operations || item.operations.length === 0) console.log(" (No APIs)");
|
|
308
|
+
else for (const operation of item.operations) {
|
|
309
|
+
const method = operation.method.padEnd(7);
|
|
310
|
+
const desc = operation.summary || operation.description;
|
|
311
|
+
const descText = desc ? ` ${desc}` : "";
|
|
312
|
+
console.log(` ${method} ${operation.path}${descText}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (includeComponents) {
|
|
316
|
+
console.log("\n Schemas:");
|
|
317
|
+
if (!item.components || item.components.schemas.length === 0) console.log(" (No Schemas)");
|
|
318
|
+
else for (const schema of item.components.schemas) {
|
|
319
|
+
const desc = schema.description ? ` ${schema.description}` : "";
|
|
320
|
+
console.log(` ${schema.name}${desc}`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const totalApis = result.reduce((sum, item) => sum + (item.operations?.length || 0), 0);
|
|
325
|
+
const totalSchemas = result.reduce((sum, item) => sum + (item.components?.schemas.length || 0), 0);
|
|
326
|
+
console.log("\n" + "─".repeat(70));
|
|
327
|
+
const parts = [`${result.length} modules`];
|
|
328
|
+
if (includeOperations) parts.push(`${totalApis} APIs`);
|
|
329
|
+
if (includeComponents) parts.push(`${totalSchemas} Schemas`);
|
|
330
|
+
console.log(`Total: ${parts.join(", ")}`);
|
|
331
|
+
} else {
|
|
332
|
+
for (const item of result) {
|
|
333
|
+
console.log(`\nModule: ${item.module}`);
|
|
334
|
+
console.log("─".repeat(70));
|
|
335
|
+
if (includeOperations) {
|
|
336
|
+
console.log("\n APIs:");
|
|
337
|
+
if (!item.operations || item.operations.length === 0) console.log(" (No APIs)");
|
|
338
|
+
else for (const operation of item.operations) {
|
|
339
|
+
const method = operation.method.padEnd(7);
|
|
340
|
+
console.log(` ${method} ${operation.path}`);
|
|
341
|
+
const desc = operation.summary || operation.description;
|
|
342
|
+
if (desc) console.log(` ${desc}`);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
if (includeComponents) {
|
|
346
|
+
console.log("\n Schemas:");
|
|
347
|
+
if (!item.components || item.components.schemas.length === 0) console.log(" (No Schemas)");
|
|
348
|
+
else for (const schema of item.components.schemas) {
|
|
349
|
+
console.log(` ${schema.name}`);
|
|
350
|
+
if (schema.description) console.log(` ${schema.description}`);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
const totalApis = result.reduce((sum, item) => sum + (item.operations?.length || 0), 0);
|
|
355
|
+
const totalSchemas = result.reduce((sum, item) => sum + (item.components?.schemas.length || 0), 0);
|
|
356
|
+
console.log("\n" + "─".repeat(70));
|
|
357
|
+
const parts = [`${result.length} modules`];
|
|
358
|
+
if (includeOperations) parts.push(`${totalApis} APIs`);
|
|
359
|
+
if (includeComponents) parts.push(`${totalSchemas} Schemas`);
|
|
360
|
+
console.log(`Total: ${parts.join(", ")}`);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
791
363
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
...(0, import_jsonpath_plus4.JSONPath)({
|
|
800
|
-
path: "$.paths.*.*.responses.*.headers.*.$ref^",
|
|
801
|
-
json: swagger,
|
|
802
|
-
resultType: "all"
|
|
803
|
-
})
|
|
804
|
-
];
|
|
805
|
-
for (const match of matches) {
|
|
806
|
-
const value = dereference(match.value.$ref, swagger);
|
|
807
|
-
import_jsonpointer2.default.set(swagger, match.pointer, value);
|
|
808
|
-
}
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region src/commands/mock.ts
|
|
366
|
+
function registerMockCommand(program) {
|
|
367
|
+
program.command("mock").description("Start a mock server based on OpenAPI specifications").option("-c --config <config>", "The keq-cli config file").option("-p --port <port>", "Port to listen on", "3939").option("--host <host>", "Host to bind to", "localhost").option("--module <modules...>", "Filter module(s) to mock").option("--cors", "Enable CORS headers", true).option("--delay <delay>", "Response delay in ms (or min-max range like \"100-500\")").option("--max-depth <depth>", "Max schema depth for mock data generation", "10").option("--ref-depth <depth>", "Max $ref recursion depth for circular schemas", "5").option("--debug", "Print debug information").option("--tolerant", "Tolerate wrong swagger/openapi structure").action(async (options) => {
|
|
368
|
+
const { mockCommand } = await Promise.resolve().then(() => require("./mock-command-WZcfy5Iq.cjs"));
|
|
369
|
+
await mockCommand(options);
|
|
370
|
+
});
|
|
809
371
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
const value = dereference(match.value.$ref, swagger);
|
|
818
|
-
import_jsonpointer2.default.set(swagger, match.pointer, value);
|
|
819
|
-
}
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region src/commands/init.ts
|
|
374
|
+
function registerInitCommand(program) {
|
|
375
|
+
program.command("init").description("Initialize keq configuration file").option("-f --force", "Force overwrite existing config file").action(async (options) => {
|
|
376
|
+
const { initConfig } = await Promise.resolve().then(() => require("./init-DqxLcRSQ.cjs"));
|
|
377
|
+
await initConfig(options);
|
|
378
|
+
});
|
|
820
379
|
}
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region src/search/embedder.ts
|
|
382
|
+
const MODEL_NAME = "intfloat/multilingual-e5-small";
|
|
383
|
+
const CACHE_DIR = path.default.join(os.default.homedir(), ".cache", "keq", "models");
|
|
384
|
+
let transformers = null;
|
|
385
|
+
let loadError = null;
|
|
386
|
+
let extractor = null;
|
|
387
|
+
var EmbedderUnavailableError = class extends Error {
|
|
388
|
+
constructor(cause) {
|
|
389
|
+
super("@huggingface/transformers is not installed. Semantic search is unavailable.\nRun `pnpm add @huggingface/transformers` to enable this feature.");
|
|
390
|
+
this.name = "EmbedderUnavailableError";
|
|
391
|
+
if (cause) this.cause = cause;
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
async function loadTransformers() {
|
|
395
|
+
if (transformers) return transformers;
|
|
396
|
+
if (loadError) throw new EmbedderUnavailableError(loadError);
|
|
397
|
+
try {
|
|
398
|
+
transformers = await import("@huggingface/transformers");
|
|
399
|
+
return transformers;
|
|
400
|
+
} catch (e) {
|
|
401
|
+
loadError = e instanceof Error ? e : new Error(String(e));
|
|
402
|
+
throw new EmbedderUnavailableError(loadError);
|
|
403
|
+
}
|
|
828
404
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
405
|
+
async function getEmbedder() {
|
|
406
|
+
if (extractor) return extractor;
|
|
407
|
+
const { pipeline, env } = await loadTransformers();
|
|
408
|
+
env.cacheDir = CACHE_DIR;
|
|
409
|
+
env.allowLocalModels = true;
|
|
410
|
+
extractor = await pipeline("feature-extraction", MODEL_NAME, { dtype: "fp32" });
|
|
411
|
+
return extractor;
|
|
833
412
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
413
|
+
async function embed(texts) {
|
|
414
|
+
return (await (await getEmbedder())(texts.map((t) => `query: ${t}`), {
|
|
415
|
+
pooling: "mean",
|
|
416
|
+
normalize: true
|
|
417
|
+
})).tolist().map((vec) => new Float32Array(vec));
|
|
838
418
|
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
419
|
+
async function embedDocuments(texts) {
|
|
420
|
+
return (await (await getEmbedder())(texts.map((t) => `passage: ${t}`), {
|
|
421
|
+
pooling: "mean",
|
|
422
|
+
normalize: true
|
|
423
|
+
})).tolist().map((vec) => new Float32Array(vec));
|
|
843
424
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
425
|
+
function cosineSimilarity(a, b) {
|
|
426
|
+
let dot = 0;
|
|
427
|
+
for (let i = 0; i < a.length; i++) dot += a[i] * b[i];
|
|
428
|
+
return dot;
|
|
848
429
|
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
var
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/search/search-engine.ts
|
|
432
|
+
var SearchEngine = class {
|
|
433
|
+
operations = [];
|
|
434
|
+
async buildIndex(documents) {
|
|
435
|
+
this.operations = [];
|
|
436
|
+
for (const document of documents) for (const op of document.operations) {
|
|
437
|
+
const tags = op.operation.tags || [];
|
|
438
|
+
const summary = op.operation.summary || "";
|
|
439
|
+
const description = op.operation.description || "";
|
|
440
|
+
const text = [
|
|
441
|
+
op.method.toUpperCase(),
|
|
442
|
+
op.pathname,
|
|
443
|
+
op.operationId,
|
|
444
|
+
summary,
|
|
445
|
+
description,
|
|
446
|
+
...tags
|
|
447
|
+
].filter(Boolean).join(" ");
|
|
448
|
+
this.operations.push({
|
|
449
|
+
id: `${document.module.name}:${op.method}:${op.pathname}`,
|
|
450
|
+
module: document.module.name,
|
|
451
|
+
method: op.method.toUpperCase(),
|
|
452
|
+
pathname: op.pathname,
|
|
453
|
+
operationId: op.operationId,
|
|
454
|
+
summary,
|
|
455
|
+
description,
|
|
456
|
+
tags,
|
|
457
|
+
text,
|
|
458
|
+
operation: op.operation
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
const embeddings = await embedDocuments(this.operations.map((op) => op.text));
|
|
462
|
+
for (let i = 0; i < this.operations.length; i++) this.operations[i].embedding = embeddings[i];
|
|
463
|
+
}
|
|
464
|
+
async search(query, options) {
|
|
465
|
+
const limit = options?.limit ?? 10;
|
|
466
|
+
const modules = options?.module;
|
|
467
|
+
let candidates = this.operations;
|
|
468
|
+
if (modules && modules.length > 0) candidates = candidates.filter((op) => modules.includes(op.module));
|
|
469
|
+
if (candidates.length === 0) return [];
|
|
470
|
+
const [queryEmbedding] = await embed([query]);
|
|
471
|
+
return candidates.filter((op) => op.embedding).map((op) => ({
|
|
472
|
+
op,
|
|
473
|
+
score: cosineSimilarity(queryEmbedding, op.embedding)
|
|
474
|
+
})).sort((a, b) => b.score - a.score).slice(0, limit).map(({ op, score }) => ({
|
|
475
|
+
score: Math.round(score * 1e3) / 1e3,
|
|
476
|
+
module: op.module,
|
|
477
|
+
method: op.method,
|
|
478
|
+
pathname: op.pathname,
|
|
479
|
+
operationId: op.operationId,
|
|
480
|
+
summary: op.summary,
|
|
481
|
+
description: op.description,
|
|
482
|
+
tags: op.tags
|
|
483
|
+
}));
|
|
484
|
+
}
|
|
485
|
+
getDetail(module, method, pathname) {
|
|
486
|
+
const op = this.operations.find((o) => o.module === module && o.method === method.toUpperCase() && o.pathname === pathname);
|
|
487
|
+
if (!op) return void 0;
|
|
488
|
+
const operation = op.operation;
|
|
489
|
+
return {
|
|
490
|
+
score: 1,
|
|
491
|
+
module: op.module,
|
|
492
|
+
method: op.method,
|
|
493
|
+
pathname: op.pathname,
|
|
494
|
+
operationId: op.operationId,
|
|
495
|
+
summary: op.summary,
|
|
496
|
+
description: op.description,
|
|
497
|
+
tags: op.tags,
|
|
498
|
+
parameters: operation.parameters || [],
|
|
499
|
+
requestBody: operation.requestBody || null,
|
|
500
|
+
responses: operation.responses || null
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
listModules() {
|
|
504
|
+
return [...new Set(this.operations.map((op) => op.module))];
|
|
505
|
+
}
|
|
856
506
|
};
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
function
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/commands/search.ts
|
|
509
|
+
function registerSearchCommand(program) {
|
|
510
|
+
program.command("search").description("Semantic search for API operations using natural language").argument("<query>", "Natural language search query").option("-c --config <config>", "The keq-cli config file").option("--module <modules...>", "Filter module(s) to search").option("--limit <limit>", "Maximum number of results", "10").option("--detail", "Include full request/response schema in results").addOption(new commander.Option("--format <format>", "Output format").choices(["json", "compact"]).default("json")).option("--all", "Ignore .keqfilter rules").option("--tolerant", "Tolerate wrong swagger/openapi structure").option("--debug", "Print debug information").action(async (query, options) => {
|
|
511
|
+
const filterRules = [];
|
|
512
|
+
if (options.module && !options.all) filterRules.push({
|
|
513
|
+
deny: true,
|
|
514
|
+
persist: false,
|
|
515
|
+
moduleName: "*",
|
|
516
|
+
operationMethod: "*",
|
|
517
|
+
operationPathname: "/**"
|
|
518
|
+
}, ...xprodFilterRules({
|
|
519
|
+
module: options.module,
|
|
520
|
+
persist: false
|
|
521
|
+
}));
|
|
522
|
+
const compiler = new require_compiler.Compiler({
|
|
523
|
+
build: true,
|
|
524
|
+
persist: false,
|
|
525
|
+
silent: true,
|
|
526
|
+
config: options.config,
|
|
527
|
+
debug: !!options.debug,
|
|
528
|
+
tolerant: !!options.tolerant,
|
|
529
|
+
filter: options.all ? false : filterRules.length > 0 ? { rules: filterRules } : void 0
|
|
530
|
+
});
|
|
531
|
+
await compiler.run();
|
|
532
|
+
const documents = compiler.context.documents || [];
|
|
533
|
+
const engine = new SearchEngine();
|
|
534
|
+
try {
|
|
535
|
+
await engine.buildIndex(documents);
|
|
536
|
+
} catch (e) {
|
|
537
|
+
if (e instanceof EmbedderUnavailableError) {
|
|
538
|
+
console.error(e.message);
|
|
539
|
+
process.exit(1);
|
|
540
|
+
}
|
|
541
|
+
throw e;
|
|
542
|
+
}
|
|
543
|
+
const limit = parseInt(options.limit, 10);
|
|
544
|
+
const results = await engine.search(query, {
|
|
545
|
+
limit,
|
|
546
|
+
module: options.module
|
|
547
|
+
});
|
|
548
|
+
if (options.detail) printResults(results.map((r) => {
|
|
549
|
+
return engine.getDetail(r.module, r.method, r.pathname) || r;
|
|
550
|
+
}), options.format);
|
|
551
|
+
else printResults(results, options.format);
|
|
552
|
+
});
|
|
899
553
|
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
554
|
+
function printResults(results, format) {
|
|
555
|
+
if (format === "json") console.log(JSON.stringify({
|
|
556
|
+
results,
|
|
557
|
+
total: results.length
|
|
558
|
+
}, null, 2));
|
|
559
|
+
else {
|
|
560
|
+
for (const r of results) {
|
|
561
|
+
const method = String(r.method).padEnd(7);
|
|
562
|
+
const score = String(r.score);
|
|
563
|
+
console.log(` [${score}] ${method} ${String(r.pathname)}`);
|
|
564
|
+
if (typeof r.summary === "string") console.log(` ${r.summary}`);
|
|
565
|
+
console.log(` ${String(r.module)} | ${String(r.operationId)}`);
|
|
566
|
+
console.log();
|
|
567
|
+
}
|
|
568
|
+
console.log(`Total: ${results.length} results`);
|
|
569
|
+
}
|
|
908
570
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
571
|
+
//#endregion
|
|
572
|
+
//#region src/mcp/compiler-provider.ts
|
|
573
|
+
/**
|
|
574
|
+
* Manages the Compiler lifecycle with automatic lazy reload.
|
|
575
|
+
* Tracks .keqrc and .keqfilter for changes; getters transparently
|
|
576
|
+
* re-compile when config files are modified, with built-in concurrency protection.
|
|
577
|
+
*/
|
|
578
|
+
var CompilerProvider = class CompilerProvider {
|
|
579
|
+
tracker = new require_plugins.FileTracker();
|
|
580
|
+
_engine = new SearchEngine();
|
|
581
|
+
_engineAvailable = false;
|
|
582
|
+
_documents = [];
|
|
583
|
+
_context = {};
|
|
584
|
+
_matcher = new require_compiler.Matcher([]);
|
|
585
|
+
_keqfilterPath = "";
|
|
586
|
+
_configPath = "";
|
|
587
|
+
_loaded = false;
|
|
588
|
+
_loadPromise = null;
|
|
589
|
+
options;
|
|
590
|
+
constructor(options) {
|
|
591
|
+
this.options = options;
|
|
592
|
+
}
|
|
593
|
+
get configPath() {
|
|
594
|
+
return this._configPath;
|
|
595
|
+
}
|
|
596
|
+
static async init(options) {
|
|
597
|
+
const provider = new CompilerProvider(options);
|
|
598
|
+
const explore = (0, cosmiconfig.cosmiconfig)("keq");
|
|
599
|
+
const result = options.config ? await explore.load(options.config) : await explore.search();
|
|
600
|
+
if (!result) throw new Error("Cannot find config file.");
|
|
601
|
+
const configFilepath = result.filepath;
|
|
602
|
+
const keqfilterPath = path.default.resolve(path.default.dirname(configFilepath), ".keqfilter");
|
|
603
|
+
provider._keqfilterPath = keqfilterPath;
|
|
604
|
+
provider._configPath = configFilepath;
|
|
605
|
+
await provider.tracker.track(configFilepath);
|
|
606
|
+
await provider.tracker.track(keqfilterPath);
|
|
607
|
+
return provider;
|
|
608
|
+
}
|
|
609
|
+
async getDocuments() {
|
|
610
|
+
await this.ensureLoaded();
|
|
611
|
+
return this._documents;
|
|
612
|
+
}
|
|
613
|
+
async getEngine() {
|
|
614
|
+
await this.ensureLoaded();
|
|
615
|
+
if (!this._engineAvailable) throw new EmbedderUnavailableError();
|
|
616
|
+
return this._engine;
|
|
617
|
+
}
|
|
618
|
+
async getContext() {
|
|
619
|
+
await this.ensureLoaded();
|
|
620
|
+
return this._context;
|
|
621
|
+
}
|
|
622
|
+
async getMatcher() {
|
|
623
|
+
await this.ensureLoaded();
|
|
624
|
+
return this._matcher;
|
|
625
|
+
}
|
|
626
|
+
async invalidate() {
|
|
627
|
+
await this.tracker.forceReload(() => this.reload());
|
|
628
|
+
}
|
|
629
|
+
async ensureLoaded() {
|
|
630
|
+
if (this._loaded) {
|
|
631
|
+
await this.tracker.ensureFresh(() => this.reload());
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
if (this._loadPromise) {
|
|
635
|
+
await this._loadPromise;
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
this._loadPromise = this.reload().finally(() => {
|
|
639
|
+
this._loadPromise = null;
|
|
640
|
+
});
|
|
641
|
+
await this._loadPromise;
|
|
642
|
+
}
|
|
643
|
+
async reload() {
|
|
644
|
+
const { config, debug, tolerant } = this.options;
|
|
645
|
+
const compiler = new require_compiler.Compiler({
|
|
646
|
+
build: true,
|
|
647
|
+
persist: false,
|
|
648
|
+
silent: true,
|
|
649
|
+
config,
|
|
650
|
+
debug,
|
|
651
|
+
tolerant,
|
|
652
|
+
filter: false
|
|
653
|
+
});
|
|
654
|
+
await compiler.run();
|
|
655
|
+
this._context = compiler.context;
|
|
656
|
+
this._documents = compiler.context.documents || [];
|
|
657
|
+
try {
|
|
658
|
+
await this._engine.buildIndex(this._documents);
|
|
659
|
+
this._engineAvailable = true;
|
|
660
|
+
} catch (e) {
|
|
661
|
+
if (e instanceof EmbedderUnavailableError) this._engineAvailable = false;
|
|
662
|
+
else throw e;
|
|
663
|
+
}
|
|
664
|
+
if (await fs_extra.default.exists(this._keqfilterPath)) this._matcher = await require_compiler.Matcher.read(this._keqfilterPath);
|
|
665
|
+
else this._matcher = new require_compiler.Matcher([]);
|
|
666
|
+
await this.tracker.snapshot();
|
|
667
|
+
this._loaded = true;
|
|
668
|
+
}
|
|
921
669
|
};
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
const { valid, errors } = await (0, import_openapi_parser2.validate)(spec);
|
|
948
|
-
if (!valid) {
|
|
949
|
-
const message = `${moduleDefinition.name} module openapi/swagger file does not conform to the openapi specifications or have grammatical errors, which may cause unexpected errors:
|
|
950
|
-
${errors?.map((e) => ` - ${e.message}`).join("\n")}`;
|
|
951
|
-
task2.output = message;
|
|
952
|
-
}
|
|
953
|
-
OpenapiUtils.dereferenceOperation(spec);
|
|
954
|
-
const document = new ApiDocumentV3_1(
|
|
955
|
-
spec,
|
|
956
|
-
moduleDefinition
|
|
957
|
-
);
|
|
958
|
-
ctx.documents?.push(document);
|
|
959
|
-
}
|
|
960
|
-
})),
|
|
961
|
-
{
|
|
962
|
-
concurrent: true,
|
|
963
|
-
exitOnError: false,
|
|
964
|
-
collectErrors: "minimal",
|
|
965
|
-
rendererOptions: {
|
|
966
|
-
collapseSubtasks: false,
|
|
967
|
-
// collapseSkips: false,
|
|
968
|
-
suffixSkips: true,
|
|
969
|
-
timer: import_listr2.PRESET_TIMER
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
);
|
|
973
|
-
}
|
|
974
|
-
};
|
|
975
|
-
}
|
|
976
|
-
function createDownloadTask(compiler, options) {
|
|
977
|
-
return {
|
|
978
|
-
title: "Download",
|
|
979
|
-
enabled: options?.enabled,
|
|
980
|
-
skip: options?.skip,
|
|
981
|
-
task: (_, task) => task.newListr(
|
|
982
|
-
[
|
|
983
|
-
main2(compiler, options),
|
|
984
|
-
{
|
|
985
|
-
task: (context, task2) => compiler.hooks.afterDownload.promise(task2)
|
|
986
|
-
}
|
|
987
|
-
],
|
|
988
|
-
{
|
|
989
|
-
concurrent: false
|
|
990
|
-
}
|
|
991
|
-
)
|
|
992
|
-
};
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
// src/compiler/tasks/persist/index.ts
|
|
996
|
-
var path6 = __toESM(require("path"), 1);
|
|
997
|
-
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
998
|
-
function createPersistArtifactTask() {
|
|
999
|
-
return {
|
|
1000
|
-
title: "Write files",
|
|
1001
|
-
task: async (context, task) => {
|
|
1002
|
-
if (!context.rc) throw new Error("Please run setup task first.");
|
|
1003
|
-
if (!context.artifacts || context.artifacts.length === 0) {
|
|
1004
|
-
task.skip("No compiled artifacts to persist.");
|
|
1005
|
-
return;
|
|
1006
|
-
}
|
|
1007
|
-
const rc = context.rc;
|
|
1008
|
-
const artifacts = context.artifacts;
|
|
1009
|
-
const total = artifacts.length;
|
|
1010
|
-
let completed = 0;
|
|
1011
|
-
const files = await Promise.all(artifacts.map(async (artifact) => {
|
|
1012
|
-
const realpath = `./${path6.join(rc.outdir, artifact.filepath)}`;
|
|
1013
|
-
await import_fs_extra3.default.ensureFile(realpath);
|
|
1014
|
-
await import_fs_extra3.default.writeFile(realpath, artifact.renderer());
|
|
1015
|
-
completed += 1;
|
|
1016
|
-
task.output = `Persisted ${completed}/${total} files`;
|
|
1017
|
-
return new Asset(path6.resolve(realpath));
|
|
1018
|
-
}));
|
|
1019
|
-
context.assets = files;
|
|
1020
|
-
}
|
|
1021
|
-
};
|
|
1022
|
-
}
|
|
1023
|
-
function createPersistIgnoreTask() {
|
|
1024
|
-
return {
|
|
1025
|
-
title: "Update .keqignore",
|
|
1026
|
-
task: async (context, task) => {
|
|
1027
|
-
if (!context.matcher) throw new Error("Please run setup task first.");
|
|
1028
|
-
const matcher = context.matcher;
|
|
1029
|
-
await matcher.write(".keqignore");
|
|
1030
|
-
}
|
|
1031
|
-
};
|
|
1032
|
-
}
|
|
1033
|
-
function main3() {
|
|
1034
|
-
return {
|
|
1035
|
-
task: (context, task) => task.newListr(
|
|
1036
|
-
[
|
|
1037
|
-
createPersistArtifactTask(),
|
|
1038
|
-
createPersistIgnoreTask()
|
|
1039
|
-
],
|
|
1040
|
-
{
|
|
1041
|
-
concurrent: true,
|
|
1042
|
-
rendererOptions: {
|
|
1043
|
-
collapseSubtasks: true
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
)
|
|
1047
|
-
};
|
|
1048
|
-
}
|
|
1049
|
-
function createPersistTask(compiler, options) {
|
|
1050
|
-
return {
|
|
1051
|
-
title: "Persist",
|
|
1052
|
-
enabled: options?.enabled,
|
|
1053
|
-
skip: options?.skip,
|
|
1054
|
-
task: (context, task) => task.newListr(
|
|
1055
|
-
[
|
|
1056
|
-
main3(),
|
|
1057
|
-
{
|
|
1058
|
-
task: (context2, task2) => compiler.hooks.afterPersist.promise(task2)
|
|
1059
|
-
}
|
|
1060
|
-
],
|
|
1061
|
-
{
|
|
1062
|
-
concurrent: false
|
|
1063
|
-
}
|
|
1064
|
-
)
|
|
1065
|
-
};
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
// src/compiler/tasks/compile/index.ts
|
|
1069
|
-
function main4(compiler) {
|
|
1070
|
-
return {
|
|
1071
|
-
task: async (context, task) => {
|
|
1072
|
-
if (!context.rc) throw new Error("Please run setup task first.");
|
|
1073
|
-
if (!context.documents) throw new Error("Please run shaking task first.");
|
|
1074
|
-
context.artifacts = [];
|
|
1075
|
-
await compiler.hooks.compile.promise(task);
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region src/mcp/find-config-in-dir.ts
|
|
672
|
+
const CONFIG_FILENAMES = [
|
|
673
|
+
".keqrc",
|
|
674
|
+
".keqrc.ts",
|
|
675
|
+
".keqrc.js",
|
|
676
|
+
".keqrc.mjs",
|
|
677
|
+
".keqrc.cjs",
|
|
678
|
+
".keqrc.json",
|
|
679
|
+
".keqrc.yml",
|
|
680
|
+
".keqrc.yaml",
|
|
681
|
+
"keq.config.ts",
|
|
682
|
+
"keq.config.js",
|
|
683
|
+
"keq.config.mjs",
|
|
684
|
+
"keq.config.cjs",
|
|
685
|
+
"keq.config.json",
|
|
686
|
+
"keq.config.yml",
|
|
687
|
+
"keq.config.yaml"
|
|
688
|
+
];
|
|
689
|
+
async function findConfigInDir(dir) {
|
|
690
|
+
for (const filename of CONFIG_FILENAMES) {
|
|
691
|
+
const filePath = path.default.resolve(dir, filename);
|
|
692
|
+
if (await fs_extra.default.pathExists(filePath)) return filePath;
|
|
693
|
+
}
|
|
694
|
+
return null;
|
|
1078
695
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
696
|
+
//#endregion
|
|
697
|
+
//#region src/mcp/compiler-provider-registry.ts
|
|
698
|
+
/**
|
|
699
|
+
* Manages multiple CompilerProvider instances for monorepo/multi-project support.
|
|
700
|
+
* Lazily initializes providers on first access and dynamically registers new projects
|
|
701
|
+
* when an unknown project directory is requested.
|
|
702
|
+
*/
|
|
703
|
+
var CompilerProviderRegistry = class {
|
|
704
|
+
entries = /* @__PURE__ */ new Map();
|
|
705
|
+
providers = /* @__PURE__ */ new Map();
|
|
706
|
+
options;
|
|
707
|
+
constructor(options) {
|
|
708
|
+
this.options = options;
|
|
709
|
+
}
|
|
710
|
+
register(entry) {
|
|
711
|
+
this.entries.set(entry.projectDir, entry);
|
|
712
|
+
}
|
|
713
|
+
has(projectDir) {
|
|
714
|
+
return this.entries.has(projectDir);
|
|
715
|
+
}
|
|
716
|
+
list() {
|
|
717
|
+
return [...this.entries.values()];
|
|
718
|
+
}
|
|
719
|
+
async resolve(projectDir) {
|
|
720
|
+
const entry = await this.resolveEntry(projectDir);
|
|
721
|
+
const cached = this.providers.get(entry.projectDir);
|
|
722
|
+
if (cached) return cached;
|
|
723
|
+
const provider = await CompilerProvider.init({
|
|
724
|
+
config: entry.configPath,
|
|
725
|
+
debug: this.options.debug,
|
|
726
|
+
tolerant: this.options.tolerant
|
|
727
|
+
});
|
|
728
|
+
this.providers.set(entry.projectDir, provider);
|
|
729
|
+
return provider;
|
|
730
|
+
}
|
|
731
|
+
getConfigPath(projectDir) {
|
|
732
|
+
return this.resolveEntrySync(projectDir).configPath;
|
|
733
|
+
}
|
|
734
|
+
async resolveEntry(projectDir) {
|
|
735
|
+
if (!projectDir) return this.resolveDefault();
|
|
736
|
+
if (!path.default.isAbsolute(projectDir)) throw new Error(`The 'project' parameter must be an absolute path. Received: ${projectDir}`);
|
|
737
|
+
const existing = this.entries.get(projectDir);
|
|
738
|
+
if (existing) return existing;
|
|
739
|
+
const configPath = await findConfigInDir(projectDir);
|
|
740
|
+
if (!configPath) throw new Error(`No keqrc config file found in ${projectDir}`);
|
|
741
|
+
const entry = {
|
|
742
|
+
configPath,
|
|
743
|
+
projectDir
|
|
744
|
+
};
|
|
745
|
+
this.register(entry);
|
|
746
|
+
return entry;
|
|
747
|
+
}
|
|
748
|
+
resolveEntrySync(projectDir) {
|
|
749
|
+
if (!projectDir) return this.resolveDefault();
|
|
750
|
+
if (!path.default.isAbsolute(projectDir)) throw new Error(`The 'project' parameter must be an absolute path. Received: ${projectDir}`);
|
|
751
|
+
const existing = this.entries.get(projectDir);
|
|
752
|
+
if (!existing) throw new Error(`No keqrc config file found in ${projectDir}`);
|
|
753
|
+
return existing;
|
|
754
|
+
}
|
|
755
|
+
resolveDefault() {
|
|
756
|
+
if (this.entries.size === 0) throw new Error("No keq project found. Please specify 'project' parameter with the absolute path to your project directory containing a keqrc config file.");
|
|
757
|
+
if (this.entries.size === 1) return this.entries.values().next().value;
|
|
758
|
+
const projects = [...this.entries.values()].map((e) => `- ${e.projectDir} (${path.default.basename(e.configPath)})`).join("\n");
|
|
759
|
+
throw new Error(`This is a monorepo with multiple keq projects. Please specify 'project' parameter with one of the following project directories:\n${projects}`);
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
//#endregion
|
|
763
|
+
//#region src/mcp/discover-projects.ts
|
|
764
|
+
async function discoverProjects(config) {
|
|
765
|
+
if (config) {
|
|
766
|
+
const configPath = path.default.resolve(config);
|
|
767
|
+
return [{
|
|
768
|
+
configPath,
|
|
769
|
+
projectDir: path.default.dirname(configPath)
|
|
770
|
+
}];
|
|
771
|
+
}
|
|
772
|
+
const monorepoEntries = await discoverFromMonorepo(process.cwd());
|
|
773
|
+
if (monorepoEntries.length > 0) return monorepoEntries;
|
|
774
|
+
const result = await (0, cosmiconfig.cosmiconfig)("keq").search();
|
|
775
|
+
if (result) return [{
|
|
776
|
+
configPath: result.filepath,
|
|
777
|
+
projectDir: path.default.dirname(result.filepath)
|
|
778
|
+
}];
|
|
779
|
+
return [];
|
|
1099
780
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
781
|
+
async function discoverFromMonorepo(root) {
|
|
782
|
+
const workspaceGlobs = await getWorkspaceGlobs(root);
|
|
783
|
+
if (workspaceGlobs.length === 0) return [];
|
|
784
|
+
const dirs = [root, ...await expandWorkspaceGlobs(root, workspaceGlobs)];
|
|
785
|
+
const entries = [];
|
|
786
|
+
for (const dir of dirs) {
|
|
787
|
+
const configPath = await findConfigInDir(dir);
|
|
788
|
+
if (configPath) entries.push({
|
|
789
|
+
configPath,
|
|
790
|
+
projectDir: dir
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
return entries;
|
|
1112
794
|
}
|
|
1113
|
-
function
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
tap.fn = (...args) => {
|
|
1128
|
-
const task = args[taskIndex];
|
|
1129
|
-
const proxyTask = proxyTaskWrapper(tap.name, task);
|
|
1130
|
-
args[taskIndex] = proxyTask;
|
|
1131
|
-
proxyTask.output = "Processing...";
|
|
1132
|
-
return fn(...args);
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
if (tap.type === "async") {
|
|
1136
|
-
tap.fn = (...args) => {
|
|
1137
|
-
const task = args[taskIndex];
|
|
1138
|
-
const proxyTask = proxyTaskWrapper(tap.name, task);
|
|
1139
|
-
args[taskIndex] = proxyTask;
|
|
1140
|
-
proxyTask.output = "Processing...";
|
|
1141
|
-
return fn(...args);
|
|
1142
|
-
};
|
|
1143
|
-
}
|
|
1144
|
-
return tap;
|
|
1145
|
-
}
|
|
1146
|
-
};
|
|
795
|
+
async function getWorkspaceGlobs(root) {
|
|
796
|
+
const pnpmWorkspacePath = path.default.join(root, "pnpm-workspace.yaml");
|
|
797
|
+
if (await fs_extra.default.pathExists(pnpmWorkspacePath)) {
|
|
798
|
+
const content = await fs_extra.default.readFile(pnpmWorkspacePath, "utf-8");
|
|
799
|
+
const parsed = js_yaml.load(content);
|
|
800
|
+
if (parsed?.packages) return parsed.packages;
|
|
801
|
+
}
|
|
802
|
+
const packageJsonPath = path.default.join(root, "package.json");
|
|
803
|
+
if (await fs_extra.default.pathExists(packageJsonPath)) {
|
|
804
|
+
const pkg = await fs_extra.default.readJson(packageJsonPath);
|
|
805
|
+
if (Array.isArray(pkg.workspaces)) return pkg.workspaces;
|
|
806
|
+
if (Array.isArray(pkg.workspaces?.packages)) return pkg.workspaces.packages;
|
|
807
|
+
}
|
|
808
|
+
return [];
|
|
1147
809
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
throw err;
|
|
1177
|
-
}
|
|
1178
|
-
};
|
|
1179
|
-
}
|
|
1180
|
-
if (tap.type === "async") {
|
|
1181
|
-
tap.fn = (...args) => {
|
|
1182
|
-
const callback = R10.last(args);
|
|
1183
|
-
return fn(...R10.init(args), (err, result) => {
|
|
1184
|
-
prefix(err);
|
|
1185
|
-
return callback(err, result);
|
|
1186
|
-
});
|
|
1187
|
-
};
|
|
1188
|
-
}
|
|
1189
|
-
return tap;
|
|
1190
|
-
}
|
|
1191
|
-
};
|
|
810
|
+
async function expandWorkspaceGlobs(root, globs) {
|
|
811
|
+
const dirs = [];
|
|
812
|
+
for (const glob of globs) {
|
|
813
|
+
const parts = glob.split("/");
|
|
814
|
+
const baseParts = [];
|
|
815
|
+
let globPart = "";
|
|
816
|
+
for (let i = 0; i < parts.length; i++) {
|
|
817
|
+
if (parts[i].includes("*") || parts[i].includes("{") || parts[i].includes("?")) {
|
|
818
|
+
globPart = parts.slice(i).join("/");
|
|
819
|
+
break;
|
|
820
|
+
}
|
|
821
|
+
baseParts.push(parts[i]);
|
|
822
|
+
}
|
|
823
|
+
const baseDir = path.default.join(root, ...baseParts);
|
|
824
|
+
if (!await fs_extra.default.pathExists(baseDir)) continue;
|
|
825
|
+
if (!globPart) {
|
|
826
|
+
const fullPath = path.default.resolve(root, glob);
|
|
827
|
+
if (await fs_extra.default.pathExists(fullPath)) dirs.push(fullPath);
|
|
828
|
+
continue;
|
|
829
|
+
}
|
|
830
|
+
const matcher = (0, picomatch.default)(globPart);
|
|
831
|
+
const candidates = await fs_extra.default.readdir(baseDir, { withFileTypes: true });
|
|
832
|
+
for (const entry of candidates) {
|
|
833
|
+
if (!entry.isDirectory()) continue;
|
|
834
|
+
if (matcher(entry.name)) dirs.push(path.default.join(baseDir, entry.name));
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
return dirs;
|
|
1192
838
|
}
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
var import_child_process = require("child_process");
|
|
1199
|
-
var import_util = require("util");
|
|
1200
|
-
var execAsync = (0, import_util.promisify)(import_child_process.exec);
|
|
1201
|
-
|
|
1202
|
-
// src/plugins/body-fallback/index.ts
|
|
1203
|
-
var R22 = __toESM(require("ramda"), 1);
|
|
1204
|
-
|
|
1205
|
-
// src/plugins/generate-micro-function/generate-micro-function.plugin.ts
|
|
1206
|
-
var import_tapable2 = require("tapable");
|
|
1207
|
-
|
|
1208
|
-
// src/plugins/generate-micro-function/constants/metadata-storage.ts
|
|
1209
|
-
var MetadataStorage = /* @__PURE__ */ new WeakMap();
|
|
1210
|
-
|
|
1211
|
-
// src/plugins/generate-micro-function/generators/micro_function/micro-function.generator.ts
|
|
1212
|
-
var R21 = __toESM(require("ramda"), 1);
|
|
1213
|
-
var path10 = __toESM(require("path"), 1);
|
|
1214
|
-
var changeCase6 = __toESM(require("change-case"), 1);
|
|
1215
|
-
|
|
1216
|
-
// src/plugins/generate-declaration/generate-declaration.plugin.ts
|
|
1217
|
-
var import_tapable = require("tapable");
|
|
1218
|
-
|
|
1219
|
-
// src/plugins/generate-declaration/generators/operation-declaration/operation.generator.ts
|
|
1220
|
-
var path9 = __toESM(require("path"), 1);
|
|
1221
|
-
var changeCase5 = __toESM(require("change-case"), 1);
|
|
1222
|
-
|
|
1223
|
-
// src/transformers/json-schema/comment.renderer.ts
|
|
1224
|
-
var CommentRenderer = class {
|
|
1225
|
-
constructor(schema) {
|
|
1226
|
-
this.schema = schema;
|
|
1227
|
-
}
|
|
1228
|
-
render() {
|
|
1229
|
-
const schema = this.schema;
|
|
1230
|
-
const lines = ["/**"];
|
|
1231
|
-
if (schema.description) {
|
|
1232
|
-
const description = schema.description.replace("*/", "*\\/");
|
|
1233
|
-
lines.push(...description.split("\n").map((line) => ` * ${line}`));
|
|
1234
|
-
}
|
|
1235
|
-
if (schema.deprecated) {
|
|
1236
|
-
lines.push(" * @deprecated");
|
|
1237
|
-
}
|
|
1238
|
-
if (schema.readOnly) {
|
|
1239
|
-
lines.push(" * @readonly");
|
|
1240
|
-
}
|
|
1241
|
-
if (schema.format) {
|
|
1242
|
-
lines.push(` * @format ${schema.format}`);
|
|
1243
|
-
}
|
|
1244
|
-
lines.push(" */");
|
|
1245
|
-
if (lines.length === 2) return "";
|
|
1246
|
-
return lines.join("\n");
|
|
1247
|
-
}
|
|
1248
|
-
};
|
|
1249
|
-
|
|
1250
|
-
// src/transformers/json-schema/declaration.renderer.ts
|
|
1251
|
-
var R12 = __toESM(require("ramda"), 1);
|
|
1252
|
-
|
|
1253
|
-
// src/utils/indent.ts
|
|
1254
|
-
function indent(space, text) {
|
|
1255
|
-
if (text === "") return "";
|
|
1256
|
-
const indentation = " ".repeat(space);
|
|
1257
|
-
return text.split("\n").map((line) => line ? `${indentation}${line}` : line).join("\n");
|
|
839
|
+
//#endregion
|
|
840
|
+
//#region src/commands/mcp.ts
|
|
841
|
+
function getFilterAnnotation(matcher, op) {
|
|
842
|
+
if (op && matcher.isOperationDenied(op)) return "This API is excluded from the code generation list by .keqfilter rules";
|
|
843
|
+
return "This API is included in the code generation list";
|
|
1258
844
|
}
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
};
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
};
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
845
|
+
function registerMcpCommand(program) {
|
|
846
|
+
program.command("mcp").description("Start keq MCP server").option("-c --config <config>", "The keq-cli config file").option("--tolerant", "Tolerate wrong swagger/openapi structure").option("--debug", "Print debug information").action(async (options) => {
|
|
847
|
+
const config = options.config;
|
|
848
|
+
const tolerant = !!options.tolerant;
|
|
849
|
+
const debug = !!options.debug;
|
|
850
|
+
const entries = await discoverProjects(config);
|
|
851
|
+
const registry = new CompilerProviderRegistry({
|
|
852
|
+
debug,
|
|
853
|
+
tolerant
|
|
854
|
+
});
|
|
855
|
+
for (const entry of entries) registry.register(entry);
|
|
856
|
+
const server = new _modelcontextprotocol_sdk_server_mcp_js.McpServer({
|
|
857
|
+
name: "keq",
|
|
858
|
+
version: "1.0.0",
|
|
859
|
+
description: "查询和搜索项目中对接的所有后端服务 API 接口。当用户想了解后端有哪些接口、查找某个功能的 API、查看接口的请求参数和响应格式时使用。支持自然语言语义搜索(中英文)。也可为接口生成 TypeScript 客户端代码。数据来源:项目配置的 Swagger/OpenAPI 规范文档。"
|
|
860
|
+
});
|
|
861
|
+
const projectParam = zod.z.string().optional().describe("项目目录绝对路径,用于 monorepo 中指定操作哪个子项目。非 monorepo 项目无需提供。");
|
|
862
|
+
server.registerTool("search_apis", {
|
|
863
|
+
description: "通过语义匹配搜索项目中的后端 API 接口。仅当用户描述了具体功能或业务场景(如\"用户登录\"、\"搜索商品\")来查找相关接口时使用。如果用户想查看所有接口或按模块/路径浏览接口列表,应使用 list_apis 而非此工具。支持中英文自然语言,返回按相关度排序的接口列表。",
|
|
864
|
+
inputSchema: {
|
|
865
|
+
project: projectParam,
|
|
866
|
+
query: zod.z.string().describe("自然语言搜索词,如\"用户登录\"、\"搜索商品\"、\"订单列表\"等"),
|
|
867
|
+
module: zod.z.array(zod.z.string()).optional().describe("按模块名筛选,限定在特定后端服务中搜索"),
|
|
868
|
+
limit: zod.z.number().optional().default(10).describe("返回结果数量上限")
|
|
869
|
+
},
|
|
870
|
+
annotations: {
|
|
871
|
+
readOnlyHint: true,
|
|
872
|
+
destructiveHint: false
|
|
873
|
+
}
|
|
874
|
+
}, async ({ project, query, module, limit }) => {
|
|
875
|
+
try {
|
|
876
|
+
const provider = await registry.resolve(project);
|
|
877
|
+
const engine = await provider.getEngine();
|
|
878
|
+
const matcher = await provider.getMatcher();
|
|
879
|
+
const documents = await provider.getDocuments();
|
|
880
|
+
const annotated = (await engine.search(query, {
|
|
881
|
+
limit,
|
|
882
|
+
module
|
|
883
|
+
})).map((result) => {
|
|
884
|
+
const { score, ...rest } = result;
|
|
885
|
+
const op = documents.find((d) => d.module.name === result.module)?.operations.find((o) => o.method.toLowerCase() === result.method.toLowerCase() && o.pathname === result.pathname);
|
|
886
|
+
return {
|
|
887
|
+
...rest,
|
|
888
|
+
"x-keq-score": score,
|
|
889
|
+
"x-keq-filter": getFilterAnnotation(matcher, op)
|
|
890
|
+
};
|
|
891
|
+
});
|
|
892
|
+
return { content: [{
|
|
893
|
+
type: "text",
|
|
894
|
+
text: JSON.stringify(annotated, null, 2)
|
|
895
|
+
}] };
|
|
896
|
+
} catch (error) {
|
|
897
|
+
return {
|
|
898
|
+
content: [{
|
|
899
|
+
type: "text",
|
|
900
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
901
|
+
}],
|
|
902
|
+
isError: true
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
server.registerTool("get_api_detail", {
|
|
907
|
+
description: "获取某个 API 接口的完整详情,包含请求参数、请求体、响应体的结构定义。当用户想知道某个接口怎么调用、需要传什么参数、返回什么数据时使用。需要先通过 search_apis 或 list_apis 获取接口的 module、method、pathname。",
|
|
908
|
+
inputSchema: {
|
|
909
|
+
project: projectParam,
|
|
910
|
+
module: zod.z.string().describe("Module name"),
|
|
911
|
+
method: zod.z.string().describe("HTTP method (GET, POST, PUT, DELETE, etc.)"),
|
|
912
|
+
pathname: zod.z.string().describe("API pathname (e.g. /api/v1/users)")
|
|
913
|
+
},
|
|
914
|
+
annotations: {
|
|
915
|
+
readOnlyHint: true,
|
|
916
|
+
destructiveHint: false
|
|
917
|
+
}
|
|
918
|
+
}, async ({ project, module, method, pathname }) => {
|
|
919
|
+
try {
|
|
920
|
+
const provider = await registry.resolve(project);
|
|
921
|
+
const engine = await provider.getEngine();
|
|
922
|
+
const matcher = await provider.getMatcher();
|
|
923
|
+
const documents = await provider.getDocuments();
|
|
924
|
+
const detail = engine.getDetail(module, method, pathname);
|
|
925
|
+
if (!detail) return {
|
|
926
|
+
content: [{
|
|
927
|
+
type: "text",
|
|
928
|
+
text: "API not found"
|
|
929
|
+
}],
|
|
930
|
+
isError: true
|
|
931
|
+
};
|
|
932
|
+
const op = documents.find((d) => d.module.name === module)?.operations.find((o) => o.method.toLowerCase() === method.toLowerCase() && o.pathname === pathname);
|
|
933
|
+
return { content: [{
|
|
934
|
+
type: "text",
|
|
935
|
+
text: JSON.stringify({
|
|
936
|
+
...detail,
|
|
937
|
+
"x-keq-filter": getFilterAnnotation(matcher, op)
|
|
938
|
+
}, null, 2)
|
|
939
|
+
}] };
|
|
940
|
+
} catch (error) {
|
|
941
|
+
return {
|
|
942
|
+
content: [{
|
|
943
|
+
type: "text",
|
|
944
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
945
|
+
}],
|
|
946
|
+
isError: true
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
});
|
|
950
|
+
server.registerTool("list_modules", {
|
|
951
|
+
description: "列出项目对接的所有后端服务模块。当用户想知道项目接入了哪些后端系统、有哪些服务可用时使用。每个模块对应一个后端服务的 API 文档。",
|
|
952
|
+
inputSchema: { project: projectParam },
|
|
953
|
+
annotations: {
|
|
954
|
+
readOnlyHint: true,
|
|
955
|
+
destructiveHint: false
|
|
956
|
+
}
|
|
957
|
+
}, async ({ project }) => {
|
|
958
|
+
try {
|
|
959
|
+
const modules = (await (await registry.resolve(project)).getEngine()).listModules();
|
|
960
|
+
return { content: [{
|
|
961
|
+
type: "text",
|
|
962
|
+
text: JSON.stringify(modules, null, 2)
|
|
963
|
+
}] };
|
|
964
|
+
} catch (error) {
|
|
965
|
+
return {
|
|
966
|
+
content: [{
|
|
967
|
+
type: "text",
|
|
968
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
969
|
+
}],
|
|
970
|
+
isError: true
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
});
|
|
974
|
+
server.registerTool("list_apis", {
|
|
975
|
+
description: "列出项目中所有可用的后端 API 接口。当用户想查看所有接口、浏览某个服务的全部接口、查询某个系统有哪些接口、或按条件筛选接口(如只看 GET 请求或某个路径下的接口)时使用。如果用户描述了具体功能来查找接口(如\"搜索商品的接口\"),应使用 search_apis。",
|
|
976
|
+
inputSchema: {
|
|
977
|
+
project: projectParam,
|
|
978
|
+
module: zod.z.array(zod.z.string()).optional().describe("Filter by module names"),
|
|
979
|
+
method: zod.z.string().optional().describe("Filter by HTTP method (GET, POST, PUT, DELETE, etc.)"),
|
|
980
|
+
pathname: zod.z.string().optional().describe("Filter by pathname pattern (glob supported)"),
|
|
981
|
+
includes: zod.z.array(zod.z.enum(["operations", "components"])).optional().default(["operations"]).describe("What to include in results")
|
|
982
|
+
},
|
|
983
|
+
annotations: {
|
|
984
|
+
readOnlyHint: true,
|
|
985
|
+
destructiveHint: false
|
|
986
|
+
}
|
|
987
|
+
}, async ({ project, module, method, pathname, includes }) => {
|
|
988
|
+
try {
|
|
989
|
+
const provider = await registry.resolve(project);
|
|
990
|
+
const documents = await provider.getDocuments();
|
|
991
|
+
const matcher = await provider.getMatcher();
|
|
992
|
+
const result = documents.filter((doc) => !module || module.includes(doc.module.name)).map((document) => {
|
|
993
|
+
const item = { module: document.module.name };
|
|
994
|
+
if (includes.includes("operations")) {
|
|
995
|
+
let ops = document.operations;
|
|
996
|
+
if (method) ops = ops.filter((op) => op.method.toLowerCase() === method.toLowerCase());
|
|
997
|
+
if (pathname) {
|
|
998
|
+
const match = (0, picomatch.default)(pathname);
|
|
999
|
+
ops = ops.filter((op) => match(op.pathname));
|
|
1000
|
+
}
|
|
1001
|
+
item.operations = ops.map((op) => ({
|
|
1002
|
+
method: op.method.toUpperCase(),
|
|
1003
|
+
path: op.pathname,
|
|
1004
|
+
operationId: op.operationId,
|
|
1005
|
+
summary: op.operation.summary || "",
|
|
1006
|
+
description: op.operation.description || "",
|
|
1007
|
+
"x-keq-filter": getFilterAnnotation(matcher, op)
|
|
1008
|
+
}));
|
|
1009
|
+
}
|
|
1010
|
+
if (includes.includes("components")) item.components = { schemas: document.schemas.map((schema) => {
|
|
1011
|
+
const schemaObj = schema.schema;
|
|
1012
|
+
return {
|
|
1013
|
+
name: schema.name,
|
|
1014
|
+
description: schemaObj.description || ""
|
|
1015
|
+
};
|
|
1016
|
+
}) };
|
|
1017
|
+
return item;
|
|
1018
|
+
});
|
|
1019
|
+
return { content: [{
|
|
1020
|
+
type: "text",
|
|
1021
|
+
text: JSON.stringify(result, null, 2)
|
|
1022
|
+
}] };
|
|
1023
|
+
} catch (error) {
|
|
1024
|
+
return {
|
|
1025
|
+
content: [{
|
|
1026
|
+
type: "text",
|
|
1027
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
1028
|
+
}],
|
|
1029
|
+
isError: true
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
server.registerTool("build_apis", {
|
|
1034
|
+
description: "为后端 API 接口生成类型安全的 TypeScript 请求函数代码。当用户想生成某个接口的调用代码、需要类型安全的 HTTP 客户端时使用。可按模块、方法、路径范围筛选要生成的接口。生成的文件写入项目配置的输出目录。",
|
|
1035
|
+
inputSchema: {
|
|
1036
|
+
project: projectParam,
|
|
1037
|
+
module: zod.z.array(zod.z.string()).optional().describe("Module(s) to generate code for"),
|
|
1038
|
+
method: zod.z.string().optional().describe("HTTP method filter (e.g. GET, POST)"),
|
|
1039
|
+
pathname: zod.z.string().optional().describe("Pathname filter (glob pattern supported, e.g. /api/v1/users/**)"),
|
|
1040
|
+
fresh: zod.z.boolean().optional().default(false).describe("Clean output directory before building")
|
|
1041
|
+
},
|
|
1042
|
+
annotations: {
|
|
1043
|
+
readOnlyHint: false,
|
|
1044
|
+
destructiveHint: false
|
|
1045
|
+
}
|
|
1046
|
+
}, async ({ project, module, method, pathname, fresh }) => {
|
|
1047
|
+
try {
|
|
1048
|
+
const provider = await registry.resolve(project);
|
|
1049
|
+
const configPath = registry.getConfigPath(project);
|
|
1050
|
+
const filterRules = [];
|
|
1051
|
+
if (module || method || pathname) filterRules.push({
|
|
1052
|
+
deny: true,
|
|
1053
|
+
persist: false,
|
|
1054
|
+
moduleName: "*",
|
|
1055
|
+
operationMethod: "*",
|
|
1056
|
+
operationPathname: "/**"
|
|
1057
|
+
}, ...xprodFilterRules({
|
|
1058
|
+
module,
|
|
1059
|
+
method,
|
|
1060
|
+
pathname,
|
|
1061
|
+
persist: false
|
|
1062
|
+
}));
|
|
1063
|
+
const buildCompiler = new require_compiler.Compiler({
|
|
1064
|
+
build: true,
|
|
1065
|
+
persist: true,
|
|
1066
|
+
silent: true,
|
|
1067
|
+
fresh,
|
|
1068
|
+
config: configPath,
|
|
1069
|
+
debug,
|
|
1070
|
+
tolerant,
|
|
1071
|
+
filter: filterRules.length > 0 ? { rules: filterRules } : void 0
|
|
1072
|
+
});
|
|
1073
|
+
await buildCompiler.run();
|
|
1074
|
+
const artifacts = buildCompiler.context.artifacts || [];
|
|
1075
|
+
const rc = buildCompiler.context.rc;
|
|
1076
|
+
const files = artifacts.map((a) => rc ? `./${path.join(rc.outdir, a.filepath)}` : a.filepath);
|
|
1077
|
+
await provider.invalidate();
|
|
1078
|
+
return { content: [{
|
|
1079
|
+
type: "text",
|
|
1080
|
+
text: JSON.stringify({
|
|
1081
|
+
generated: files.length,
|
|
1082
|
+
files
|
|
1083
|
+
}, null, 2)
|
|
1084
|
+
}] };
|
|
1085
|
+
} catch (error) {
|
|
1086
|
+
return {
|
|
1087
|
+
content: [{
|
|
1088
|
+
type: "text",
|
|
1089
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
1090
|
+
}],
|
|
1091
|
+
isError: true
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1095
|
+
server.registerTool("list_generated_files", {
|
|
1096
|
+
description: "列出已生成的 API 客户端代码文件。当用户想查看哪些接口已经生成了代码、或想找出过期/无效的生成文件时使用。",
|
|
1097
|
+
inputSchema: {
|
|
1098
|
+
project: projectParam,
|
|
1099
|
+
invalid: zod.z.boolean().optional().default(false).describe("If true, only list invalid/stale files not matching current build")
|
|
1100
|
+
},
|
|
1101
|
+
annotations: {
|
|
1102
|
+
readOnlyHint: true,
|
|
1103
|
+
destructiveHint: false
|
|
1104
|
+
}
|
|
1105
|
+
}, async ({ project, invalid }) => {
|
|
1106
|
+
try {
|
|
1107
|
+
const context = await (await registry.resolve(project)).getContext();
|
|
1108
|
+
const rc = context.rc;
|
|
1109
|
+
if (!rc) return {
|
|
1110
|
+
content: [{
|
|
1111
|
+
type: "text",
|
|
1112
|
+
text: "Error: Failed to load configuration"
|
|
1113
|
+
}],
|
|
1114
|
+
isError: true
|
|
1115
|
+
};
|
|
1116
|
+
if (invalid) {
|
|
1117
|
+
const validFilePaths = (context.artifacts || []).map((a) => a.filepath);
|
|
1118
|
+
const files = (await findInvalidFiles(rc.outdir, validFilePaths)).map((f) => `./${path.join(rc.outdir, f.relativePath)}`);
|
|
1119
|
+
return { content: [{
|
|
1120
|
+
type: "text",
|
|
1121
|
+
text: JSON.stringify({
|
|
1122
|
+
count: files.length,
|
|
1123
|
+
files
|
|
1124
|
+
}, null, 2)
|
|
1125
|
+
}] };
|
|
1126
|
+
}
|
|
1127
|
+
const files = (context.artifacts || []).map((a) => `./${path.join(rc.outdir, a.filepath)}`);
|
|
1128
|
+
return { content: [{
|
|
1129
|
+
type: "text",
|
|
1130
|
+
text: JSON.stringify({
|
|
1131
|
+
count: files.length,
|
|
1132
|
+
files
|
|
1133
|
+
}, null, 2)
|
|
1134
|
+
}] };
|
|
1135
|
+
} catch (error) {
|
|
1136
|
+
return {
|
|
1137
|
+
content: [{
|
|
1138
|
+
type: "text",
|
|
1139
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
1140
|
+
}],
|
|
1141
|
+
isError: true
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
server.registerTool("get_filter_rules", {
|
|
1146
|
+
description: "查看当前的接口过滤规则。过滤规则决定哪些 API 接口会被纳入代码生成范围。当用户想了解哪些接口被排除或包含在生成列表中时使用。",
|
|
1147
|
+
inputSchema: { project: projectParam },
|
|
1148
|
+
annotations: {
|
|
1149
|
+
readOnlyHint: true,
|
|
1150
|
+
destructiveHint: false
|
|
1151
|
+
}
|
|
1152
|
+
}, async ({ project }) => {
|
|
1153
|
+
try {
|
|
1154
|
+
await registry.resolve(project);
|
|
1155
|
+
const configPath = registry.getConfigPath(project);
|
|
1156
|
+
const filterPath = path.resolve(path.dirname(configPath), ".keqfilter");
|
|
1157
|
+
if (!await fs_extra.default.exists(filterPath)) return { content: [{
|
|
1158
|
+
type: "text",
|
|
1159
|
+
text: JSON.stringify({
|
|
1160
|
+
exists: false,
|
|
1161
|
+
content: ""
|
|
1162
|
+
}, null, 2)
|
|
1163
|
+
}] };
|
|
1164
|
+
const content = await fs_extra.default.readFile(filterPath, "utf-8");
|
|
1165
|
+
return { content: [{
|
|
1166
|
+
type: "text",
|
|
1167
|
+
text: JSON.stringify({
|
|
1168
|
+
exists: true,
|
|
1169
|
+
content
|
|
1170
|
+
}, null, 2)
|
|
1171
|
+
}] };
|
|
1172
|
+
} catch (error) {
|
|
1173
|
+
return {
|
|
1174
|
+
content: [{
|
|
1175
|
+
type: "text",
|
|
1176
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
1177
|
+
}],
|
|
1178
|
+
isError: true
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
});
|
|
1182
|
+
server.registerTool("add_filter_rule", {
|
|
1183
|
+
description: "添加接口过滤规则,控制哪些 API 需要生成代码。当用户想排除某些不需要的接口、或只保留特定接口时使用。deny 模式排除接口,allow 模式包含接口。",
|
|
1184
|
+
inputSchema: {
|
|
1185
|
+
project: projectParam,
|
|
1186
|
+
mode: zod.z.enum(["deny", "allow"]).describe("Rule mode: deny excludes APIs, allow includes them"),
|
|
1187
|
+
module: zod.z.string().optional().default("*").describe("Module name pattern (glob supported)"),
|
|
1188
|
+
method: zod.z.string().optional().default("*").describe("HTTP method pattern (e.g. GET, POST, or * for all)"),
|
|
1189
|
+
pathname: zod.z.string().describe("Pathname pattern (glob supported, e.g. /api/v1/users/**)"),
|
|
1190
|
+
build: zod.z.boolean().optional().default(false).describe("Whether to rebuild after adding the rule")
|
|
1191
|
+
},
|
|
1192
|
+
annotations: {
|
|
1193
|
+
readOnlyHint: false,
|
|
1194
|
+
destructiveHint: false
|
|
1195
|
+
}
|
|
1196
|
+
}, async ({ project, mode, module, method, pathname, build }) => {
|
|
1197
|
+
try {
|
|
1198
|
+
const provider = await registry.resolve(project);
|
|
1199
|
+
await new require_compiler.Compiler({
|
|
1200
|
+
build,
|
|
1201
|
+
persist: true,
|
|
1202
|
+
silent: true,
|
|
1203
|
+
config: registry.getConfigPath(project),
|
|
1204
|
+
debug,
|
|
1205
|
+
tolerant,
|
|
1206
|
+
filter: { rules: [{
|
|
1207
|
+
persist: true,
|
|
1208
|
+
deny: mode === "deny",
|
|
1209
|
+
moduleName: module,
|
|
1210
|
+
operationMethod: method.toLowerCase(),
|
|
1211
|
+
operationPathname: pathname
|
|
1212
|
+
}] }
|
|
1213
|
+
}).run();
|
|
1214
|
+
if (build) await provider.invalidate();
|
|
1215
|
+
return { content: [{
|
|
1216
|
+
type: "text",
|
|
1217
|
+
text: JSON.stringify({
|
|
1218
|
+
success: true,
|
|
1219
|
+
rule: {
|
|
1220
|
+
mode,
|
|
1221
|
+
module,
|
|
1222
|
+
method,
|
|
1223
|
+
pathname
|
|
1224
|
+
}
|
|
1225
|
+
}, null, 2)
|
|
1226
|
+
}] };
|
|
1227
|
+
} catch (error) {
|
|
1228
|
+
return {
|
|
1229
|
+
content: [{
|
|
1230
|
+
type: "text",
|
|
1231
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
1232
|
+
}],
|
|
1233
|
+
isError: true
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
server.registerTool("remove_filter_rule", {
|
|
1238
|
+
description: "移除已有的接口过滤规则。当用户想恢复之前被排除的接口、或调整过滤策略时使用。",
|
|
1239
|
+
inputSchema: {
|
|
1240
|
+
project: projectParam,
|
|
1241
|
+
mode: zod.z.enum(["deny", "allow"]).describe("Which section the rule is in"),
|
|
1242
|
+
module: zod.z.string().describe("Exact module name pattern to match"),
|
|
1243
|
+
method: zod.z.string().describe("Exact method pattern to match"),
|
|
1244
|
+
pathname: zod.z.string().describe("Exact pathname pattern to match"),
|
|
1245
|
+
build: zod.z.boolean().optional().default(false).describe("Whether to rebuild after removing the rule")
|
|
1246
|
+
},
|
|
1247
|
+
annotations: {
|
|
1248
|
+
readOnlyHint: false,
|
|
1249
|
+
destructiveHint: false
|
|
1250
|
+
}
|
|
1251
|
+
}, async ({ project, mode, module, method, pathname, build }) => {
|
|
1252
|
+
try {
|
|
1253
|
+
const provider = await registry.resolve(project);
|
|
1254
|
+
const configPath = registry.getConfigPath(project);
|
|
1255
|
+
const filterPath = path.resolve(path.dirname(configPath), ".keqfilter");
|
|
1256
|
+
if (!await fs_extra.default.exists(filterPath)) return {
|
|
1257
|
+
content: [{
|
|
1258
|
+
type: "text",
|
|
1259
|
+
text: "Error: .keqfilter file not found"
|
|
1260
|
+
}],
|
|
1261
|
+
isError: true
|
|
1262
|
+
};
|
|
1263
|
+
const content = await fs_extra.default.readFile(filterPath, "utf-8");
|
|
1264
|
+
const isDeny = mode === "deny";
|
|
1265
|
+
const targetMethod = method.toLowerCase();
|
|
1266
|
+
const lines = content.split("\n");
|
|
1267
|
+
const resultLines = [];
|
|
1268
|
+
let currentSection = null;
|
|
1269
|
+
let skipNext = false;
|
|
1270
|
+
for (const line of lines) {
|
|
1271
|
+
const trimmed = line.replace(/#.*$/, "").trim();
|
|
1272
|
+
if (trimmed === "[deny]") {
|
|
1273
|
+
currentSection = "deny";
|
|
1274
|
+
resultLines.push(line);
|
|
1275
|
+
continue;
|
|
1276
|
+
}
|
|
1277
|
+
if (trimmed === "[allow]") {
|
|
1278
|
+
currentSection = "allow";
|
|
1279
|
+
resultLines.push(line);
|
|
1280
|
+
continue;
|
|
1281
|
+
}
|
|
1282
|
+
if (!trimmed) {
|
|
1283
|
+
if (!skipNext) resultLines.push(line);
|
|
1284
|
+
skipNext = false;
|
|
1285
|
+
continue;
|
|
1286
|
+
}
|
|
1287
|
+
const matched = trimmed.match(/^([^\s]+)\s+([^:\s]+):(.*)$/);
|
|
1288
|
+
if (matched && currentSection === (isDeny ? "deny" : "allow")) {
|
|
1289
|
+
const [, ruleMethod, ruleModule, rulePathname] = matched;
|
|
1290
|
+
if (ruleMethod.toLowerCase() === targetMethod && ruleModule === module && rulePathname === pathname) {
|
|
1291
|
+
skipNext = false;
|
|
1292
|
+
continue;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
resultLines.push(line);
|
|
1296
|
+
skipNext = false;
|
|
1297
|
+
}
|
|
1298
|
+
await fs_extra.default.writeFile(filterPath, resultLines.join("\n"), "utf-8");
|
|
1299
|
+
if (build) {
|
|
1300
|
+
await new require_compiler.Compiler({
|
|
1301
|
+
build: true,
|
|
1302
|
+
persist: true,
|
|
1303
|
+
silent: true,
|
|
1304
|
+
config: configPath,
|
|
1305
|
+
debug,
|
|
1306
|
+
tolerant
|
|
1307
|
+
}).run();
|
|
1308
|
+
await provider.invalidate();
|
|
1309
|
+
}
|
|
1310
|
+
return { content: [{
|
|
1311
|
+
type: "text",
|
|
1312
|
+
text: JSON.stringify({
|
|
1313
|
+
success: true,
|
|
1314
|
+
removed: {
|
|
1315
|
+
mode,
|
|
1316
|
+
module,
|
|
1317
|
+
method,
|
|
1318
|
+
pathname
|
|
1319
|
+
}
|
|
1320
|
+
}, null, 2)
|
|
1321
|
+
}] };
|
|
1322
|
+
} catch (error) {
|
|
1323
|
+
return {
|
|
1324
|
+
content: [{
|
|
1325
|
+
type: "text",
|
|
1326
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
1327
|
+
}],
|
|
1328
|
+
isError: true
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
const transport = new _modelcontextprotocol_sdk_server_stdio_js.StdioServerTransport();
|
|
1333
|
+
await server.connect(transport);
|
|
1334
|
+
if (registry.list().length === 1) (await registry.resolve()).getEngine().catch(() => {});
|
|
1335
|
+
});
|
|
1462
1336
|
}
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
}
|
|
1487
|
-
}).join("\n");
|
|
1488
|
-
return [
|
|
1489
|
-
`export interface ${this.typeName("ResponseBodies")} {`,
|
|
1490
|
-
$responses,
|
|
1491
|
-
"}"
|
|
1492
|
-
].join("\n");
|
|
1493
|
-
}
|
|
1494
|
-
renderRequestBodies(operation, options) {
|
|
1495
|
-
let $requestBodies = `export interface ${this.typeName("RequestBodies")} {}`;
|
|
1496
|
-
if (operation.requestBody && !JsonSchemaUtils.isRef(operation.requestBody)) {
|
|
1497
|
-
const $mediaTypes = Object.entries(operation.requestBody.content || {}).map(([mediaType, mediaTypeObject]) => [mediaType, mediaTypeObject.schema]).map(([mediaType, schema]) => {
|
|
1498
|
-
if (!schema) return `${JSON.stringify(mediaType)}: unknown`;
|
|
1499
|
-
return `${JSON.stringify(mediaType)}: ${JsonSchemaTransformer.toDeclaration(schema, options)}`;
|
|
1500
|
-
}).map((pair) => indent(2, pair));
|
|
1501
|
-
$requestBodies = [
|
|
1502
|
-
`export interface ${this.typeName("RequestBodies")} {`,
|
|
1503
|
-
...$mediaTypes,
|
|
1504
|
-
"}"
|
|
1505
|
-
].join("\n");
|
|
1506
|
-
}
|
|
1507
|
-
return $requestBodies;
|
|
1508
|
-
}
|
|
1509
|
-
renderParameterBodies(operationDefinition, options) {
|
|
1510
|
-
const { operation } = operationDefinition;
|
|
1511
|
-
let parameterBodies = "";
|
|
1512
|
-
if (operation.requestBody && !JsonSchemaUtils.isRef(operation.requestBody)) {
|
|
1513
|
-
const $mediaTypes = Object.entries(operation.requestBody.content || {}).map(([mediaType, mediaTypeObject]) => [mediaType, mediaTypeObject.schema]).map(([mediaType, schemaOrRef]) => {
|
|
1514
|
-
if (!schemaOrRef) return `${JSON.stringify(mediaType)}: unknown`;
|
|
1515
|
-
const schema = JsonSchemaUtils.isRef(schemaOrRef) ? OpenapiUtils.dereferenceDeep(schemaOrRef.$ref, operationDefinition.document.specification) : schemaOrRef;
|
|
1516
|
-
if (schema.type === "object" || schema.properties) {
|
|
1517
|
-
return `${JSON.stringify(mediaType)}: ${JsonSchemaTransformer.toDeclaration(schemaOrRef, options)} & { [key: string]: any }`;
|
|
1518
|
-
}
|
|
1519
|
-
return `${JSON.stringify(mediaType)}: { [key: string]: any }`;
|
|
1520
|
-
}).map((pair) => indent(2, pair));
|
|
1521
|
-
parameterBodies = [
|
|
1522
|
-
`interface ${this.typeName("ParameterBodies")} {`,
|
|
1523
|
-
...$mediaTypes,
|
|
1524
|
-
"}",
|
|
1525
|
-
""
|
|
1526
|
-
].join("\n");
|
|
1527
|
-
}
|
|
1528
|
-
return parameterBodies;
|
|
1529
|
-
}
|
|
1530
|
-
renderRequestParameters(operation, options) {
|
|
1531
|
-
const mediaTypes = operation.requestBody && !JsonSchemaUtils.isRef(operation.requestBody) ? Object.keys(operation.requestBody.content || {}) : [];
|
|
1532
|
-
const base = `${this.typeName("RequestQuery")} & ${this.typeName("RouteParameters")} & ${this.typeName("RequestHeaders")}`;
|
|
1533
|
-
if (mediaTypes.length === 1) {
|
|
1534
|
-
return `export type ${this.typeName("RequestParameters")} = ${base} & ${this.typeName("RequestBodies")}[${JSON.stringify(mediaTypes[0])}]`;
|
|
1535
|
-
}
|
|
1536
|
-
if (mediaTypes.length > 1) {
|
|
1537
|
-
const unions = mediaTypes.map((mediaType) => `(${base} & ${this.typeName("RequestBodies")}[${JSON.stringify(mediaType)}] & { "content-type": ${JSON.stringify(mediaType)} })`).join("\n| ");
|
|
1538
|
-
return `export type ${this.typeName("RequestParameters")} = ${unions}`;
|
|
1539
|
-
}
|
|
1540
|
-
return `export type ${this.typeName("RequestParameters")} = ${base}`;
|
|
1541
|
-
}
|
|
1542
|
-
rendererParameters(name, parameters, options) {
|
|
1543
|
-
if (parameters.length === 0) {
|
|
1544
|
-
return `export type ${name} = {}`;
|
|
1545
|
-
}
|
|
1546
|
-
const $parameters = parameters.map((parameter) => {
|
|
1547
|
-
const parameterName = `"${parameter.name}"`;
|
|
1548
|
-
const $key = parameter.required ? parameterName : `${parameterName}?`;
|
|
1549
|
-
const $value = JsonSchemaTransformer.toDeclaration(parameter.schema || { type: "any" }, options);
|
|
1550
|
-
return indent(2, `${$key}: ${$value}`);
|
|
1551
|
-
}).join("\n");
|
|
1552
|
-
return [
|
|
1553
|
-
`export type ${name} = {`,
|
|
1554
|
-
$parameters,
|
|
1555
|
-
"}"
|
|
1556
|
-
].filter(Boolean).join("\n");
|
|
1557
|
-
}
|
|
1558
|
-
renderDependencies() {
|
|
1559
|
-
const schemaDefinitions = this.operationDefinition.getDependencies().filter((schemaDefinition) => !SchemaDefinition.isUnknown(schemaDefinition));
|
|
1560
|
-
const $schemaDefinitions = schemaDefinitions.map((schemaDefinition) => {
|
|
1561
|
-
const filepath = this.options.getDependentSchemaDefinitionFilepath(schemaDefinition);
|
|
1562
|
-
const schemaName = schemaDefinition.name;
|
|
1563
|
-
return `import type { ${schemaName} as ${alias(schemaName)} } from "${filepath}"`;
|
|
1564
|
-
}).map((str) => str.replace(/ from "(\.\.?\/.+?)(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?"/, this.options.esm ? ' from "$1.js"' : ' from "$1"'));
|
|
1565
|
-
return [
|
|
1566
|
-
'import type { KeqOperation, KeqPathParameterInit, KeqQueryInit, ServerSentEvent } from "keq"',
|
|
1567
|
-
...$schemaDefinitions
|
|
1568
|
-
].join("\n");
|
|
1569
|
-
}
|
|
1570
|
-
render() {
|
|
1571
|
-
const { operation } = this.operationDefinition;
|
|
1572
|
-
if (!operation.responses) return "";
|
|
1573
|
-
const jsonSchemaDeclarationRendererOptions = {
|
|
1574
|
-
referenceTransformer: (schema) => {
|
|
1575
|
-
return ReferenceTransformer.toDeclaration(schema, alias);
|
|
1576
|
-
}
|
|
1577
|
-
};
|
|
1578
|
-
const $dependencies = this.renderDependencies();
|
|
1579
|
-
const $responseBodies = this.renderResponseBodies(operation, jsonSchemaDeclarationRendererOptions);
|
|
1580
|
-
const $requestBodies = this.renderRequestBodies(operation, jsonSchemaDeclarationRendererOptions);
|
|
1581
|
-
const $parameterBodies = this.renderParameterBodies(this.operationDefinition, jsonSchemaDeclarationRendererOptions);
|
|
1582
|
-
const $requestParameters = this.renderRequestParameters(operation, jsonSchemaDeclarationRendererOptions);
|
|
1583
|
-
const $requestQuery = this.rendererParameters(
|
|
1584
|
-
`${this.typeName("RequestQuery")}`,
|
|
1585
|
-
operation.parameters?.filter((p) => !JsonSchemaUtils.isRef(p) && p.in === "query") || [],
|
|
1586
|
-
jsonSchemaDeclarationRendererOptions
|
|
1587
|
-
);
|
|
1588
|
-
const $routeParameters = this.rendererParameters(
|
|
1589
|
-
`${this.typeName("RouteParameters")}`,
|
|
1590
|
-
operation.parameters?.filter((p) => !JsonSchemaUtils.isRef(p) && p.in === "path") || [],
|
|
1591
|
-
jsonSchemaDeclarationRendererOptions
|
|
1592
|
-
);
|
|
1593
|
-
const $requestHeaders = this.rendererParameters(
|
|
1594
|
-
`${this.typeName("RequestHeaders")}`,
|
|
1595
|
-
operation.parameters?.filter((p) => !JsonSchemaUtils.isRef(p) && p.in === "header") || [],
|
|
1596
|
-
jsonSchemaDeclarationRendererOptions
|
|
1597
|
-
);
|
|
1598
|
-
return [
|
|
1599
|
-
"/* @anchor:file:start */",
|
|
1600
|
-
"",
|
|
1601
|
-
$dependencies,
|
|
1602
|
-
"",
|
|
1603
|
-
$responseBodies,
|
|
1604
|
-
"",
|
|
1605
|
-
$requestBodies,
|
|
1606
|
-
"",
|
|
1607
|
-
$requestQuery,
|
|
1608
|
-
"",
|
|
1609
|
-
$routeParameters,
|
|
1610
|
-
"",
|
|
1611
|
-
$requestHeaders,
|
|
1612
|
-
"",
|
|
1613
|
-
$parameterBodies || void 0,
|
|
1614
|
-
$requestParameters,
|
|
1615
|
-
"",
|
|
1616
|
-
`export interface ${this.typeName("Operation")}<STATUS extends keyof ${this.typeName("ResponseBodies")}, CONTENT_TYPE extends ${$parameterBodies ? `keyof ${this.typeName("ParameterBodies")}` : "string"} > extends KeqOperation {`,
|
|
1617
|
-
` requestParams: ${this.typeName("RouteParameters")} & { [key: string]: KeqPathParameterInit }`,
|
|
1618
|
-
` requestQuery: ${this.typeName("RequestQuery")} & { [key: string]: KeqQueryInit }`,
|
|
1619
|
-
` requestHeaders: ${this.typeName("RequestHeaders")} & { [key: string]: string | number }`,
|
|
1620
|
-
` requestBody: ${$parameterBodies ? `${this.typeName("ParameterBodies")}[CONTENT_TYPE] | ` : "object | "}BodyInit`,
|
|
1621
|
-
` responseBody: ${this.typeName("ResponseBodies")}[STATUS]`,
|
|
1622
|
-
"}",
|
|
1623
|
-
"",
|
|
1624
|
-
"/* @anchor:file:end */"
|
|
1625
|
-
].filter(R15.isNotNil).join("\n");
|
|
1626
|
-
}
|
|
1627
|
-
};
|
|
1628
|
-
|
|
1629
|
-
// src/transformers/operation-definition/micro-function.renderer.ts
|
|
1630
|
-
var R17 = __toESM(require("ramda"), 1);
|
|
1631
|
-
|
|
1632
|
-
// src/transformers/operation-definition/typescript-snippet.ts
|
|
1633
|
-
var R16 = __toESM(require("ramda"), 1);
|
|
1634
|
-
|
|
1635
|
-
// src/constants/qs-array-format.ts
|
|
1636
|
-
var QsArrayFormat = /* @__PURE__ */ ((QsArrayFormat2) => {
|
|
1637
|
-
QsArrayFormat2["brackets"] = "brackets";
|
|
1638
|
-
QsArrayFormat2["indices"] = "indices";
|
|
1639
|
-
QsArrayFormat2["repeat"] = "repeat";
|
|
1640
|
-
QsArrayFormat2["comma"] = "comma";
|
|
1641
|
-
QsArrayFormat2["space"] = "space";
|
|
1642
|
-
QsArrayFormat2["pipe"] = "pipe";
|
|
1643
|
-
return QsArrayFormat2;
|
|
1644
|
-
})(QsArrayFormat || {});
|
|
1645
|
-
|
|
1646
|
-
// src/transformers/operation-definition/typescript-snippet.ts
|
|
1647
|
-
var OperationDefinitionSnippet = class {
|
|
1648
|
-
constructor(operationDefinition, options) {
|
|
1649
|
-
this.operationDefinition = operationDefinition;
|
|
1650
|
-
this.options = options;
|
|
1651
|
-
this.typeName = typeNameFactory(operationDefinition);
|
|
1652
|
-
}
|
|
1653
|
-
typeName;
|
|
1654
|
-
getQsParameters(parameter) {
|
|
1655
|
-
let arrayFormat;
|
|
1656
|
-
let allowDots;
|
|
1657
|
-
let indices;
|
|
1658
|
-
const style = parameter.style || "form";
|
|
1659
|
-
const explode = parameter.explode ?? true;
|
|
1660
|
-
if ("x-qs-array-format" in parameter) {
|
|
1661
|
-
arrayFormat = parameter["x-qs-array-format"];
|
|
1662
|
-
} else {
|
|
1663
|
-
if (style === "deepObject") {
|
|
1664
|
-
arrayFormat = "brackets" /* brackets */;
|
|
1665
|
-
} else if (explode) {
|
|
1666
|
-
arrayFormat = "repeat" /* repeat */;
|
|
1667
|
-
} else {
|
|
1668
|
-
if (style === "form") {
|
|
1669
|
-
arrayFormat = "comma" /* comma */;
|
|
1670
|
-
} else if (style === "spaceDelimited") {
|
|
1671
|
-
arrayFormat = "space" /* space */;
|
|
1672
|
-
} else if (style === "pipeDelimited") {
|
|
1673
|
-
arrayFormat = "pipe" /* pipe */;
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
if ("x-qs-allow-dots" in parameter) {
|
|
1678
|
-
allowDots = Boolean(parameter["x-qs-allow-dots"]);
|
|
1679
|
-
}
|
|
1680
|
-
if ("x-qs-indices" in parameter) {
|
|
1681
|
-
indices = Boolean(parameter["x-qs-indices"]);
|
|
1682
|
-
}
|
|
1683
|
-
if (arrayFormat || allowDots !== void 0 || indices !== void 0) {
|
|
1684
|
-
return {
|
|
1685
|
-
...arrayFormat ? { arrayFormat } : {},
|
|
1686
|
-
...allowDots !== void 0 ? { allowDots } : {},
|
|
1687
|
-
...indices !== void 0 ? { indices } : {}
|
|
1688
|
-
};
|
|
1689
|
-
}
|
|
1690
|
-
return void 0;
|
|
1691
|
-
}
|
|
1692
|
-
// render: "if (args && 'Authorization' in args) req.header('Authorization', args['Authorization'])"
|
|
1693
|
-
renderRequestHeaders() {
|
|
1694
|
-
const { operation } = this.operationDefinition;
|
|
1695
|
-
const $headers = (operation.parameters || []).filter((p) => !JsonSchemaUtils.isRef(p)).filter((p) => p.in === "header").map((p) => `if (args && ${JSON.stringify(p.name)} in args) req.header(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}])`).join("\n");
|
|
1696
|
-
return $headers;
|
|
1697
|
-
}
|
|
1698
|
-
// render: "if (args && 'id' in args) req.query('id', args['id'], options)"
|
|
1699
|
-
renderRequestQuery() {
|
|
1700
|
-
const { operation } = this.operationDefinition;
|
|
1701
|
-
const $query = (operation.parameters || []).filter((p) => !JsonSchemaUtils.isRef(p)).filter((p) => p.in === "query").map((p) => {
|
|
1702
|
-
const option = this.getQsParameters(p);
|
|
1703
|
-
const $option = !option || R16.isEmpty(option) ? "" : `, ${JSON.stringify(option)}`;
|
|
1704
|
-
return `if (args && ${JSON.stringify(p.name)} in args) req.query(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}]${$option})`;
|
|
1705
|
-
}).join("\n");
|
|
1706
|
-
return $query;
|
|
1707
|
-
}
|
|
1708
|
-
// render: "if (args && 'id' in args) req.params('id', args['id'])"
|
|
1709
|
-
renderRequestPathParameters() {
|
|
1710
|
-
const { operation } = this.operationDefinition;
|
|
1711
|
-
const $pathParameters = (operation.parameters || []).filter((p) => !JsonSchemaUtils.isRef(p)).filter((p) => p.in === "path").map((p) => `if (args && ${JSON.stringify(p.name)} in args) req.params(${JSON.stringify(p.name)}, args[${JSON.stringify(p.name)}])`).join("\n");
|
|
1712
|
-
return $pathParameters;
|
|
1713
|
-
}
|
|
1714
|
-
getRequestMediaTypes() {
|
|
1715
|
-
const { operation } = this.operationDefinition;
|
|
1716
|
-
const requestBodyContent = operation.requestBody?.content || {};
|
|
1717
|
-
return Object.keys(requestBodyContent);
|
|
1718
|
-
}
|
|
1719
|
-
// render "req.type("application/json")"
|
|
1720
|
-
renderMediaType() {
|
|
1721
|
-
const mediaTypes = this.getRequestMediaTypes();
|
|
1722
|
-
if (mediaTypes.length === 1 && !mediaTypes[0].endsWith("/*")) {
|
|
1723
|
-
return `req.type("${mediaTypes[0]}")
|
|
1724
|
-
`;
|
|
1725
|
-
} else if (mediaTypes.some((mediaType) => mediaType === "*/*")) {
|
|
1726
|
-
} else if (mediaTypes.some((mediaType) => mediaType.endsWith("/*"))) {
|
|
1727
|
-
return 'if(args?.["content-type"]) req.type(args["content-type"])\n';
|
|
1728
|
-
} else if (mediaTypes.length > 1) {
|
|
1729
|
-
return 'if(args?.["content-type"]) req.type(args["content-type"])\n';
|
|
1730
|
-
}
|
|
1731
|
-
return "";
|
|
1732
|
-
}
|
|
1733
|
-
// render body
|
|
1734
|
-
requestBodyFormDataPropertyRenderer(propertyName, propertySchema, mediaType) {
|
|
1735
|
-
try {
|
|
1736
|
-
const $propertyName = JSON.stringify(propertyName);
|
|
1737
|
-
const schema = JsonSchemaUtils.isRef(propertySchema) ? OpenapiUtils.dereferenceDeep(propertySchema.$ref, this.operationDefinition.document.specification) : propertySchema;
|
|
1738
|
-
if (schema.type === "string" && schema.format === "binary" || schema.contentMediaType === "application/octet-stream") {
|
|
1739
|
-
return `if (args && ${$propertyName} in args && args[${$propertyName}]) req.attach(${$propertyName}, args[${$propertyName}])`;
|
|
1740
|
-
} else if (schema.type === "string" || schema.type === "array" && schema.items && schema.items.type === "string") {
|
|
1741
|
-
return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, args[${$propertyName}])`;
|
|
1742
|
-
} else if (schema.type === "number" || schema.type === "integer") {
|
|
1743
|
-
return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, String(args[${$propertyName}]))`;
|
|
1744
|
-
}
|
|
1745
|
-
return `if (args && ${$propertyName} in args && args[${$propertyName}] !== undefined) req.field(${$propertyName}, String(args[${$propertyName}]) /* type is non-string in schema; triggers type coercion here */)`;
|
|
1746
|
-
} catch (err) {
|
|
1747
|
-
return this.renderErrorComment(err, mediaType);
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1750
|
-
requestBodyPropertyRenderer(propertyName, propertySchema, mediaType) {
|
|
1751
|
-
if (mediaType === "application/json") {
|
|
1752
|
-
const $propertyName = JSON.stringify(propertyName);
|
|
1753
|
-
return `if (args && ${$propertyName} in args) req.send({ ${$propertyName}: args[${$propertyName}] })`;
|
|
1754
|
-
} else if (mediaType === "multipart/form-data") {
|
|
1755
|
-
return this.requestBodyFormDataPropertyRenderer(propertyName, propertySchema, mediaType);
|
|
1756
|
-
} else {
|
|
1757
|
-
throw new Error(`Unsupported media type: ${mediaType}`);
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
renderRequestBody() {
|
|
1761
|
-
const { operation } = this.operationDefinition;
|
|
1762
|
-
const requestBodyContent = operation.requestBody?.content || {};
|
|
1763
|
-
const $requestBody = Object.entries(requestBodyContent).map(([mediaType, mediaTypeObject]) => {
|
|
1764
|
-
if (!mediaTypeObject.schema) return;
|
|
1765
|
-
try {
|
|
1766
|
-
const schema = JsonSchemaUtils.isRef(mediaTypeObject.schema) ? OpenapiUtils.dereferenceDeep(mediaTypeObject.schema.$ref, this.operationDefinition.document.specification) : mediaTypeObject.schema;
|
|
1767
|
-
if (schema.type !== "object") return;
|
|
1768
|
-
const properties = schema.properties || {};
|
|
1769
|
-
return Object.entries(properties).map(([propertyName, propertySchema]) => this.requestBodyPropertyRenderer(propertyName, propertySchema, mediaType)).join("\n");
|
|
1770
|
-
} catch (err) {
|
|
1771
|
-
return this.renderErrorComment(err, mediaType);
|
|
1772
|
-
}
|
|
1773
|
-
}).filter(R16.isNotNil).join("\n");
|
|
1774
|
-
return $requestBody;
|
|
1775
|
-
}
|
|
1776
|
-
renderErrorComment(err, mediaType) {
|
|
1777
|
-
const $err = String(err).split("\n").map(((line) => ` * ${line}`)).join("\n");
|
|
1778
|
-
return [
|
|
1779
|
-
"/**",
|
|
1780
|
-
` * Unable to dereference schema for media type ${mediaType}`,
|
|
1781
|
-
$err,
|
|
1782
|
-
" */"
|
|
1783
|
-
].join("\n");
|
|
1784
|
-
}
|
|
1785
|
-
};
|
|
1786
|
-
|
|
1787
|
-
// src/transformers/operation-definition/micro-function.renderer.ts
|
|
1788
|
-
var OperationDefinitionMicroFunctionRenderer = class {
|
|
1789
|
-
constructor(operationDefinition, options) {
|
|
1790
|
-
this.operationDefinition = operationDefinition;
|
|
1791
|
-
this.options = options;
|
|
1792
|
-
this.typeName = typeNameFactory(operationDefinition);
|
|
1793
|
-
this.helper = new OperationDefinitionSnippet(operationDefinition, options);
|
|
1794
|
-
}
|
|
1795
|
-
helper;
|
|
1796
|
-
typeName;
|
|
1797
|
-
render() {
|
|
1798
|
-
const { operation, operationId, method, pathname } = this.operationDefinition;
|
|
1799
|
-
if (!operation.responses) return "";
|
|
1800
|
-
const $dependencies = this.renderDependencies();
|
|
1801
|
-
const $comment = new CommentRenderer2(this.operationDefinition).render();
|
|
1802
|
-
const moduleName = this.operationDefinition.module.name;
|
|
1803
|
-
const $method = method.toLowerCase();
|
|
1804
|
-
const $queryParameters = this.helper.renderRequestQuery();
|
|
1805
|
-
const $headerParameters = this.helper.renderRequestHeaders();
|
|
1806
|
-
const $pathParameters = this.helper.renderRequestPathParameters();
|
|
1807
|
-
const $mediaType = this.helper.renderMediaType();
|
|
1808
|
-
const $requestBody = this.helper.renderRequestBody();
|
|
1809
|
-
const $operationDeclaration = this.renderOperationDeclaration();
|
|
1810
|
-
return [
|
|
1811
|
-
"/* @anchor:file:start */",
|
|
1812
|
-
"",
|
|
1813
|
-
$dependencies,
|
|
1814
|
-
"",
|
|
1815
|
-
`const moduleName = "${moduleName}"`,
|
|
1816
|
-
`const method = "${method}"`,
|
|
1817
|
-
`const pathname = "${pathname}"`,
|
|
1818
|
-
"",
|
|
1819
|
-
$comment || void 0,
|
|
1820
|
-
`export ${$operationDeclaration} {`,
|
|
1821
|
-
` const req = request.${$method}<${this.typeName("ResponseBodies")}[STATUS]>("${pathname}")`,
|
|
1822
|
-
" .option('module', { name: moduleName, pathname, method })",
|
|
1823
|
-
"",
|
|
1824
|
-
$mediaType ? indent(2, $mediaType) : void 0,
|
|
1825
|
-
" /* @anchor:query:start */",
|
|
1826
|
-
$queryParameters ? indent(2, $queryParameters) : void 0,
|
|
1827
|
-
" /* @anchor:query:end */",
|
|
1828
|
-
"",
|
|
1829
|
-
" /* @anchor:headers:start */",
|
|
1830
|
-
$headerParameters ? indent(2, $headerParameters) : void 0,
|
|
1831
|
-
" /* @anchor:headers:end */",
|
|
1832
|
-
"",
|
|
1833
|
-
" /* @anchor:path-parameters:start */",
|
|
1834
|
-
$pathParameters ? indent(2, $pathParameters) : void 0,
|
|
1835
|
-
" /* @anchor:path-parameters:end */",
|
|
1836
|
-
"",
|
|
1837
|
-
" /* @anchor:body:start */",
|
|
1838
|
-
$requestBody ? indent(2, $requestBody) : void 0,
|
|
1839
|
-
" /* @anchor:body:end */",
|
|
1840
|
-
"",
|
|
1841
|
-
" /* @anchor:operation-return */",
|
|
1842
|
-
` return req as ReturnType<typeof ${operationId}<STATUS${$operationDeclaration.includes("CONTENT_TYPE") ? ", CONTENT_TYPE" : ""}>>`,
|
|
1843
|
-
"}",
|
|
1844
|
-
"",
|
|
1845
|
-
`${operationId}.pathname = pathname`,
|
|
1846
|
-
`${operationId}.method = method`,
|
|
1847
|
-
"/* @anchor:file:end */"
|
|
1848
|
-
].filter(R17.isNotNil).join("\n");
|
|
1849
|
-
}
|
|
1850
|
-
renderDependencies() {
|
|
1851
|
-
const declarationFilepath = this.options.getOperationDefinitionDeclarationFilepath(this.operationDefinition);
|
|
1852
|
-
const requestFilepath = this.options.getRequestFilepath();
|
|
1853
|
-
return [
|
|
1854
|
-
'import { Keq } from "keq"',
|
|
1855
|
-
`import { request } from "${requestFilepath}"`,
|
|
1856
|
-
`import type { ${this.typeName("Operation")}, ${this.typeName("ResponseBodies")}, ${this.typeName("RequestParameters")} } from "${declarationFilepath}"`,
|
|
1857
|
-
`export type { ${this.typeName("RequestQuery")}, ${this.typeName("RequestHeaders")}, ${this.typeName("RequestBodies")} } from "${declarationFilepath}"`
|
|
1858
|
-
].map((str) => str.replace(/ from "(\.\.?\/.+?)(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?"/, this.options.esm ? ' from "$1.js"' : ' from "$1"')).join("\n");
|
|
1859
|
-
}
|
|
1860
|
-
renderOperationDeclaration() {
|
|
1861
|
-
const { operationId } = this.operationDefinition;
|
|
1862
|
-
const mediaTypes = this.helper.getRequestMediaTypes();
|
|
1863
|
-
if (mediaTypes.length === 0) {
|
|
1864
|
-
return `function ${operationId}<STATUS extends keyof ${this.typeName("ResponseBodies")}, CONTENT_TYPE extends never = never>(args?: ${this.typeName("RequestParameters")}): Keq<${this.typeName("Operation")}<STATUS, CONTENT_TYPE>>`;
|
|
1865
|
-
} else if (mediaTypes.length === 1) {
|
|
1866
|
-
return `function ${operationId}<STATUS extends keyof ${this.typeName("ResponseBodies")}, CONTENT_TYPE extends ${JSON.stringify(mediaTypes[0])} = ${JSON.stringify(mediaTypes[0])}>(args?: ${this.typeName("RequestParameters")}): Keq<${this.typeName("Operation")}<STATUS, CONTENT_TYPE>>`;
|
|
1867
|
-
} else if (mediaTypes.length > 1) {
|
|
1868
|
-
return `function ${operationId}<STATUS extends keyof ${this.typeName("ResponseBodies")}, CONTENT_TYPE extends ${this.typeName("RequestParameters")}["content-type"]>(args?: Extract<${this.typeName("RequestParameters")}, { "content-type": CONTENT_TYPE }>): Keq<${this.typeName("Operation")}<STATUS, CONTENT_TYPE>>`;
|
|
1869
|
-
}
|
|
1870
|
-
throw new Exception(this.operationDefinition.module, "[operationDeclarationRenderer] Unreachable");
|
|
1871
|
-
}
|
|
1872
|
-
};
|
|
1873
|
-
|
|
1874
|
-
// src/transformers/operation-definition/nestjs-method.renderer.ts
|
|
1875
|
-
var R18 = __toESM(require("ramda"), 1);
|
|
1876
|
-
var OperationDefinitionNestjsMethodRenderer = class {
|
|
1877
|
-
constructor(operationDefinition, options) {
|
|
1878
|
-
this.operationDefinition = operationDefinition;
|
|
1879
|
-
this.options = options;
|
|
1880
|
-
this.typeName = typeNameFactory(operationDefinition);
|
|
1881
|
-
this.helper = new OperationDefinitionSnippet(operationDefinition, options);
|
|
1882
|
-
}
|
|
1883
|
-
helper;
|
|
1884
|
-
typeName;
|
|
1885
|
-
render() {
|
|
1886
|
-
const pathname = this.operationDefinition.pathname;
|
|
1887
|
-
const $comment = new CommentRenderer2(this.operationDefinition).render();
|
|
1888
|
-
const $method = this.operationDefinition.method.toLowerCase();
|
|
1889
|
-
const $mediaType = this.helper.renderMediaType();
|
|
1890
|
-
const $operationDeclaration = this.renderOperationDeclaration(this.operationDefinition);
|
|
1891
|
-
const $queryParameters = this.helper.renderRequestQuery();
|
|
1892
|
-
const $headerParameters = this.helper.renderRequestHeaders();
|
|
1893
|
-
const $pathParameters = this.helper.renderRequestPathParameters();
|
|
1894
|
-
const $requestBody = this.helper.renderRequestBody();
|
|
1895
|
-
return [
|
|
1896
|
-
$comment,
|
|
1897
|
-
`${$operationDeclaration} {`,
|
|
1898
|
-
` const req = this.request.${$method}<${this.typeName("ResponseBodies")}[STATUS]>(${JSON.stringify(pathname)})`,
|
|
1899
|
-
" .option(",
|
|
1900
|
-
' "module",',
|
|
1901
|
-
" {",
|
|
1902
|
-
` name: ${JSON.stringify(this.operationDefinition.module.name)},`,
|
|
1903
|
-
` pathname: ${JSON.stringify(pathname)},`,
|
|
1904
|
-
` method: ${JSON.stringify($method)},`,
|
|
1905
|
-
" },",
|
|
1906
|
-
" )",
|
|
1907
|
-
"",
|
|
1908
|
-
$mediaType ? indent(2, $mediaType) : void 0,
|
|
1909
|
-
"",
|
|
1910
|
-
" /* @anchor:query:start */",
|
|
1911
|
-
$queryParameters ? indent(2, $queryParameters) : void 0,
|
|
1912
|
-
" /* @anchor:query:end */",
|
|
1913
|
-
"",
|
|
1914
|
-
" /* @anchor:headers:start */",
|
|
1915
|
-
$headerParameters ? indent(2, $headerParameters) : void 0,
|
|
1916
|
-
" /* @anchor:headers:end */",
|
|
1917
|
-
"",
|
|
1918
|
-
" /* @anchor:path-parameters:start */",
|
|
1919
|
-
$pathParameters ? indent(2, $pathParameters) : void 0,
|
|
1920
|
-
" /* @anchor:path-parameters:end */",
|
|
1921
|
-
"",
|
|
1922
|
-
" /* @anchor:body:start */",
|
|
1923
|
-
$requestBody ? indent(2, $requestBody) : void 0,
|
|
1924
|
-
" /* @anchor:body:end */",
|
|
1925
|
-
"",
|
|
1926
|
-
" return req",
|
|
1927
|
-
"}"
|
|
1928
|
-
].filter(R18.isNotNil).join("\n");
|
|
1929
|
-
}
|
|
1930
|
-
renderOperationDeclaration(operationDefinition) {
|
|
1931
|
-
const { operationId } = operationDefinition;
|
|
1932
|
-
const typeName = typeNameFactory(operationDefinition);
|
|
1933
|
-
const mediaTypes = this.helper.getRequestMediaTypes();
|
|
1934
|
-
if (mediaTypes.length === 0) {
|
|
1935
|
-
return `${operationId}<STATUS extends keyof ${typeName("ResponseBodies")}, CONTENT_TYPE extends never = never>(args?: ${typeName("RequestParameters")}): Keq<${typeName("Operation")}<STATUS, CONTENT_TYPE>>`;
|
|
1936
|
-
} else if (mediaTypes.length === 1) {
|
|
1937
|
-
return `${operationId}<STATUS extends keyof ${typeName("ResponseBodies")}, CONTENT_TYPE extends ${JSON.stringify(mediaTypes[0])} = ${JSON.stringify(mediaTypes[0])}>(args?: ${typeName("RequestParameters")}): Keq<${typeName("Operation")}<STATUS, CONTENT_TYPE>>`;
|
|
1938
|
-
} else if (mediaTypes.length > 1) {
|
|
1939
|
-
return `${operationId}<STATUS extends keyof ${typeName("ResponseBodies")}, CONTENT_TYPE extends ${typeName("RequestParameters")}["content-type"]>(args?: Extract<${typeName("RequestParameters")}, { "content-type": CONTENT_TYPE }>): Keq<${typeName("Operation")}<STATUS, CONTENT_TYPE>>`;
|
|
1940
|
-
}
|
|
1941
|
-
throw new Exception(operationDefinition.module, "[operationDeclarationRenderer] Unreachable");
|
|
1942
|
-
}
|
|
1943
|
-
};
|
|
1944
|
-
|
|
1945
|
-
// src/transformers/operation-definition/operation-definition.transformer.ts
|
|
1946
|
-
var OperationDefinitionTransformer = class {
|
|
1947
|
-
static toDeclaration(operationDefinition, options) {
|
|
1948
|
-
return new DeclarationRenderer2(operationDefinition, options).render();
|
|
1949
|
-
}
|
|
1950
|
-
static toMicroFunction(operationDefinition, options) {
|
|
1951
|
-
return new OperationDefinitionMicroFunctionRenderer(operationDefinition, options).render();
|
|
1952
|
-
}
|
|
1953
|
-
static toNestjsMethod(operationDefinition, options) {
|
|
1954
|
-
return new OperationDefinitionNestjsMethodRenderer(operationDefinition, options).render();
|
|
1955
|
-
}
|
|
1956
|
-
static toComment(operationDefinition) {
|
|
1957
|
-
return new CommentRenderer2(operationDefinition).render();
|
|
1958
|
-
}
|
|
1959
|
-
};
|
|
1960
|
-
|
|
1961
|
-
// src/transformers/entrypoint/entrypoint.transformer.ts
|
|
1962
|
-
var path7 = __toESM(require("path"), 1);
|
|
1963
|
-
var EntrypointTransformer = class {
|
|
1964
|
-
static toTypescript(exports2, options) {
|
|
1965
|
-
const $exports = exports2.map((exportArtifact) => {
|
|
1966
|
-
const relativePath = path7.relative(
|
|
1967
|
-
options.dirpath,
|
|
1968
|
-
exportArtifact.filepath
|
|
1969
|
-
).replace(/(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?$/, options.esm ? ".js" : "");
|
|
1970
|
-
return relativePath.startsWith(".") ? `export * from '${relativePath}'` : `export * from './${relativePath}'`;
|
|
1971
|
-
});
|
|
1972
|
-
return [
|
|
1973
|
-
"/* @anchor:file:start */",
|
|
1974
|
-
"",
|
|
1975
|
-
...$exports,
|
|
1976
|
-
"",
|
|
1977
|
-
"/* @anchor:file:end */"
|
|
1978
|
-
].join("\n");
|
|
1979
|
-
}
|
|
1980
|
-
};
|
|
1981
|
-
|
|
1982
|
-
// src/transformers/api-document/nestjs-client.renderer.ts
|
|
1983
|
-
var R19 = __toESM(require("ramda"), 1);
|
|
1984
|
-
var changeCase2 = __toESM(require("change-case"), 1);
|
|
1985
|
-
var NestjsClientRenderer = class {
|
|
1986
|
-
constructor(document, options) {
|
|
1987
|
-
this.document = document;
|
|
1988
|
-
this.options = options;
|
|
1989
|
-
}
|
|
1990
|
-
renderDependencies() {
|
|
1991
|
-
const $operations = this.document.operations.map((operationDefinition) => {
|
|
1992
|
-
const filepath = this.options.getOperationDefinitionDeclarationFilepath(operationDefinition);
|
|
1993
|
-
const typeName = typeNameFactory(operationDefinition);
|
|
1994
|
-
return `import type { ${typeName("Operation")}, ${typeName("ResponseBodies")}, ${typeName("RequestParameters")} } from "${filepath}"`;
|
|
1995
|
-
}).map((str) => str.replace(/ from "(\.\.?\/.+?)(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?"/, this.options.esm ? ' from "$1.js"' : ' from "$1"'));
|
|
1996
|
-
return [
|
|
1997
|
-
'import { Injectable, Logger } from "@nestjs/common"',
|
|
1998
|
-
'import { Keq, KeqRequest } from "keq"',
|
|
1999
|
-
...$operations
|
|
2000
|
-
].join("\n");
|
|
2001
|
-
}
|
|
2002
|
-
render() {
|
|
2003
|
-
const moduleName = changeCase2.pascalCase(this.document.module.name);
|
|
2004
|
-
const $dependencies = this.renderDependencies();
|
|
2005
|
-
const $operations = this.document.operations.map((operation) => OperationDefinitionTransformer.toNestjsMethod(operation, {
|
|
2006
|
-
esm: this.options.esm
|
|
2007
|
-
})).join("\n\n");
|
|
2008
|
-
return [
|
|
2009
|
-
"/* @anchor:file:start */",
|
|
2010
|
-
"",
|
|
2011
|
-
$dependencies,
|
|
2012
|
-
"",
|
|
2013
|
-
"@Injectable()",
|
|
2014
|
-
`export class ${moduleName}Client {`,
|
|
2015
|
-
` private readonly logger = new Logger(${moduleName}Client.name)`,
|
|
2016
|
-
"",
|
|
2017
|
-
" constructor(",
|
|
2018
|
-
" // @anchor:client-constructor-parameters:start",
|
|
2019
|
-
" private readonly request: KeqRequest,",
|
|
2020
|
-
" // @anchor:client-constructor-parameters:end",
|
|
2021
|
-
" ) {}",
|
|
2022
|
-
"",
|
|
2023
|
-
indent(2, $operations),
|
|
2024
|
-
"}",
|
|
2025
|
-
"",
|
|
2026
|
-
"/* @anchor:file:end */"
|
|
2027
|
-
].filter(R19.isNotNil).join("\n");
|
|
2028
|
-
}
|
|
2029
|
-
};
|
|
2030
|
-
|
|
2031
|
-
// src/transformers/api-document/nestjs-module.renderer.ts
|
|
2032
|
-
var changeCase3 = __toESM(require("change-case"), 1);
|
|
2033
|
-
var NestjsModuleRenderer = class {
|
|
2034
|
-
constructor(document, options) {
|
|
2035
|
-
this.document = document;
|
|
2036
|
-
this.options = options;
|
|
2037
|
-
}
|
|
2038
|
-
render() {
|
|
2039
|
-
const moduleName = changeCase3.pascalCase(this.document.module.name);
|
|
2040
|
-
const clientFilepath = this.options.getNestjsClientFilepath(this.document).replace(/(\.ts|\.mts|\.cts|\.js|\.cjs|\.mjs)?$/, this.options.esm ? ".js" : "");
|
|
2041
|
-
return [
|
|
2042
|
-
"/* @anchor:file:start */",
|
|
2043
|
-
'import { Module, Inject, ConfigurableModuleBuilder, Global } from "@nestjs/common"',
|
|
2044
|
-
'import { KeqRequest } from "keq"',
|
|
2045
|
-
'import { KeqModuleOptions } from "@keq-request/nestjs"',
|
|
2046
|
-
`import { ${moduleName}Client } from "${clientFilepath}"`,
|
|
2047
|
-
"",
|
|
2048
|
-
"",
|
|
2049
|
-
"const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE, ASYNC_OPTIONS_TYPE } = new ConfigurableModuleBuilder<KeqModuleOptions>().build()",
|
|
2050
|
-
"",
|
|
2051
|
-
"@Global()",
|
|
2052
|
-
"@Module({",
|
|
2053
|
-
" imports: [],",
|
|
2054
|
-
" controllers: [],",
|
|
2055
|
-
` providers: [${moduleName}Client],`,
|
|
2056
|
-
` exports: [${moduleName}Client],`,
|
|
2057
|
-
"})",
|
|
2058
|
-
`export class ${moduleName}Module extends ConfigurableModuleClass {`,
|
|
2059
|
-
"",
|
|
2060
|
-
" constructor(",
|
|
2061
|
-
" @Inject(MODULE_OPTIONS_TOKEN) private readonly options: KeqModuleOptions,",
|
|
2062
|
-
" private readonly request: KeqRequest,",
|
|
2063
|
-
" ) {",
|
|
2064
|
-
" super()",
|
|
2065
|
-
" }",
|
|
2066
|
-
"",
|
|
2067
|
-
" onModuleInit() {",
|
|
2068
|
-
" if (this.options.middlewares) {",
|
|
2069
|
-
" for (const middleware of this.options.middlewares) {",
|
|
2070
|
-
" this.request.use(middleware)",
|
|
2071
|
-
" }",
|
|
2072
|
-
" }",
|
|
2073
|
-
" }",
|
|
2074
|
-
"}",
|
|
2075
|
-
"",
|
|
2076
|
-
"/* @anchor:file:end */"
|
|
2077
|
-
].join("\n");
|
|
2078
|
-
}
|
|
2079
|
-
};
|
|
2080
|
-
|
|
2081
|
-
// src/transformers/api-document/api-document.transformer.ts
|
|
2082
|
-
var ApiDocumentTransformer = class {
|
|
2083
|
-
static toNestjsModule(document, options) {
|
|
2084
|
-
return new NestjsModuleRenderer(document, options).render();
|
|
2085
|
-
}
|
|
2086
|
-
static toNestjsClient(document, options) {
|
|
2087
|
-
return new NestjsClientRenderer(document, options).render();
|
|
2088
|
-
}
|
|
2089
|
-
};
|
|
2090
|
-
|
|
2091
|
-
// src/plugins/generate-declaration/generators/schema-declaration/schema.generator.ts
|
|
2092
|
-
var R20 = __toESM(require("ramda"), 1);
|
|
2093
|
-
var path8 = __toESM(require("path"), 1);
|
|
2094
|
-
var changeCase4 = __toESM(require("change-case"), 1);
|
|
2095
|
-
|
|
2096
|
-
// src/plugins/generate-declaration/constants/metadata-storage.ts
|
|
2097
|
-
var MetadataStorage2 = /* @__PURE__ */ new WeakMap();
|
|
2098
|
-
|
|
2099
|
-
// src/plugins/generate-declaration/generators/schema-declaration/schema.generator.ts
|
|
2100
|
-
var SCHEMA_GENERATOR = "schemaGenerator";
|
|
2101
|
-
var SchemaDeclarationGenerator = class _SchemaDeclarationGenerator {
|
|
2102
|
-
async compile(compiler, task) {
|
|
2103
|
-
const context = compiler.context;
|
|
2104
|
-
const metadata = MetadataStorage2.get(compiler);
|
|
2105
|
-
const rc = context.rc;
|
|
2106
|
-
const documents = context.documents;
|
|
2107
|
-
const schemaDefinitions = documents.flatMap((document) => document.schemas);
|
|
2108
|
-
const artifactMap = new Map(
|
|
2109
|
-
await Promise.all(
|
|
2110
|
-
schemaDefinitions.map(async (schemaDefinition) => [
|
|
2111
|
-
schemaDefinition,
|
|
2112
|
-
await metadata.hooks.afterSchemaDeclarationArtifactGenerated.promise(
|
|
2113
|
-
this.generateSchemaDefinitionsArtifact(schemaDefinition, rc),
|
|
2114
|
-
schemaDefinition,
|
|
2115
|
-
task
|
|
2116
|
-
)
|
|
2117
|
-
])
|
|
2118
|
-
)
|
|
2119
|
-
);
|
|
2120
|
-
const entrypoints = R20.collectBy(
|
|
2121
|
-
(schemaDefinition) => schemaDefinition.module.name,
|
|
2122
|
-
schemaDefinitions
|
|
2123
|
-
).map((schemaDefinitions2) => [
|
|
2124
|
-
schemaDefinitions2[0].module,
|
|
2125
|
-
schemaDefinitions2.map((schemaDefinition) => artifactMap.get(schemaDefinition)).filter((artifact) => Boolean(artifact))
|
|
2126
|
-
]).map(([moduleDefinition, artifacts]) => this.generateEntrypointArtifact(
|
|
2127
|
-
moduleDefinition,
|
|
2128
|
-
artifacts,
|
|
2129
|
-
rc
|
|
2130
|
-
));
|
|
2131
|
-
return [...artifactMap.values(), ...entrypoints];
|
|
2132
|
-
}
|
|
2133
|
-
generateSchemaDefinitionsArtifact(schemaDefinition, rc) {
|
|
2134
|
-
const filepath = _SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(schemaDefinition, rc.fileNamingStyle);
|
|
2135
|
-
const dirpath = path8.dirname(filepath);
|
|
2136
|
-
const artifact = new Artifact({
|
|
2137
|
-
id: _SchemaDeclarationGenerator.getSchemaDefinitionArtifactId(schemaDefinition),
|
|
2138
|
-
filepath,
|
|
2139
|
-
content: SchemaDefinitionTransformer.toDeclaration(
|
|
2140
|
-
schemaDefinition,
|
|
2141
|
-
{
|
|
2142
|
-
esm: rc.esm,
|
|
2143
|
-
getDependentSchemaDefinitionFilepath(dependentSchemaDefinition) {
|
|
2144
|
-
const relativePath = path8.relative(
|
|
2145
|
-
dirpath,
|
|
2146
|
-
_SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(dependentSchemaDefinition, rc.fileNamingStyle)
|
|
2147
|
-
);
|
|
2148
|
-
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
2149
|
-
}
|
|
2150
|
-
}
|
|
2151
|
-
),
|
|
2152
|
-
extensionName: ".schema.ts"
|
|
2153
|
-
});
|
|
2154
|
-
return artifact;
|
|
2155
|
-
}
|
|
2156
|
-
generateEntrypointArtifact(moduleDefinition, exports2, rc) {
|
|
2157
|
-
const filepath = _SchemaDeclarationGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle);
|
|
2158
|
-
const dirpath = path8.dirname(filepath);
|
|
2159
|
-
const artifact = new Artifact({
|
|
2160
|
-
id: _SchemaDeclarationGenerator.getEntrypointArtifactId(moduleDefinition),
|
|
2161
|
-
filepath,
|
|
2162
|
-
content: EntrypointTransformer.toTypescript(exports2, { dirpath })
|
|
2163
|
-
});
|
|
2164
|
-
return artifact;
|
|
2165
|
-
}
|
|
2166
|
-
static getEntrypointArtifactFilepath(moduleDefinition, fileNamingStyle) {
|
|
2167
|
-
return [
|
|
2168
|
-
".",
|
|
2169
|
-
changeCase4[fileNamingStyle](moduleDefinition.name),
|
|
2170
|
-
"types",
|
|
2171
|
-
"components",
|
|
2172
|
-
"schemas",
|
|
2173
|
-
"index.ts"
|
|
2174
|
-
].join("/");
|
|
2175
|
-
}
|
|
2176
|
-
static getEntrypointArtifactId(moduleDefinition) {
|
|
2177
|
-
return `${moduleDefinition.address}/components/schemas/entrypoint?generator=${SCHEMA_GENERATOR}`;
|
|
2178
|
-
}
|
|
2179
|
-
static getSchemaDefinitionArtifactFilepath(schemaDefinition, fileNamingStyle) {
|
|
2180
|
-
const filename = `${changeCase4[fileNamingStyle](schemaDefinition.name)}.schema.ts`;
|
|
2181
|
-
return [
|
|
2182
|
-
".",
|
|
2183
|
-
changeCase4[fileNamingStyle](schemaDefinition.module.name),
|
|
2184
|
-
"types",
|
|
2185
|
-
"components",
|
|
2186
|
-
"schemas",
|
|
2187
|
-
filename
|
|
2188
|
-
].join("/");
|
|
2189
|
-
}
|
|
2190
|
-
static getSchemaDefinitionArtifactId(schemaDefinition) {
|
|
2191
|
-
return `${schemaDefinition.id}?generator=${SCHEMA_GENERATOR}`;
|
|
2192
|
-
}
|
|
2193
|
-
};
|
|
2194
|
-
|
|
2195
|
-
// src/plugins/generate-declaration/generators/operation-declaration/operation.generator.ts
|
|
2196
|
-
var OPERATION_GENERATOR = "operationDeclarationGenerator";
|
|
2197
|
-
var OperationDeclarationGenerator = class _OperationDeclarationGenerator {
|
|
2198
|
-
async compile(compiler, task) {
|
|
2199
|
-
const context = compiler.context;
|
|
2200
|
-
const metadata = MetadataStorage2.get(compiler);
|
|
2201
|
-
const rc = context.rc;
|
|
2202
|
-
const documents = context.documents;
|
|
2203
|
-
const operationDefinitions = documents.flatMap((document) => document.operations);
|
|
2204
|
-
const artifactMap = new Map(
|
|
2205
|
-
await Promise.all(
|
|
2206
|
-
operationDefinitions.map(async (operationDefinition) => [
|
|
2207
|
-
operationDefinition,
|
|
2208
|
-
await metadata.hooks.afterOperationDeclarationArtifactGenerated.promise(
|
|
2209
|
-
this.generateOperationDefinitionArtifact(operationDefinition, rc),
|
|
2210
|
-
operationDefinition,
|
|
2211
|
-
task
|
|
2212
|
-
)
|
|
2213
|
-
])
|
|
2214
|
-
)
|
|
2215
|
-
);
|
|
2216
|
-
return Array.from(artifactMap.values());
|
|
2217
|
-
}
|
|
2218
|
-
generateOperationDefinitionArtifact(operationDefinition, rc) {
|
|
2219
|
-
const filepath = _OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle);
|
|
2220
|
-
const dirpath = path9.dirname(filepath);
|
|
2221
|
-
const artifact = new Artifact({
|
|
2222
|
-
id: _OperationDeclarationGenerator.getOperationDefinitionArtifactId(operationDefinition),
|
|
2223
|
-
filepath,
|
|
2224
|
-
content: OperationDefinitionTransformer.toDeclaration(
|
|
2225
|
-
operationDefinition,
|
|
2226
|
-
{
|
|
2227
|
-
esm: rc.esm,
|
|
2228
|
-
getDependentSchemaDefinitionFilepath(dependentSchemaDefinition) {
|
|
2229
|
-
const relativePath = path9.relative(
|
|
2230
|
-
dirpath,
|
|
2231
|
-
SchemaDeclarationGenerator.getSchemaDefinitionArtifactFilepath(dependentSchemaDefinition, rc.fileNamingStyle)
|
|
2232
|
-
);
|
|
2233
|
-
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2236
|
-
),
|
|
2237
|
-
extensionName: ".type.ts"
|
|
2238
|
-
});
|
|
2239
|
-
return artifact;
|
|
2240
|
-
}
|
|
2241
|
-
generateEntrypointArtifact(moduleDefinition, exports2, rc) {
|
|
2242
|
-
const filepath = _OperationDeclarationGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle);
|
|
2243
|
-
const dirpath = path9.dirname(filepath);
|
|
2244
|
-
const artifact = new Artifact({
|
|
2245
|
-
id: _OperationDeclarationGenerator.getEntrypointArtifactId(moduleDefinition),
|
|
2246
|
-
filepath,
|
|
2247
|
-
content: EntrypointTransformer.toTypescript(exports2, { dirpath })
|
|
2248
|
-
});
|
|
2249
|
-
return artifact;
|
|
2250
|
-
}
|
|
2251
|
-
static getOperationDefinitionArtifactFilepath(operationDefinition, fileNamingStyle) {
|
|
2252
|
-
const filename = `${changeCase5[fileNamingStyle](operationDefinition.operationId)}.type.ts`;
|
|
2253
|
-
const filepath = [
|
|
2254
|
-
".",
|
|
2255
|
-
changeCase5[fileNamingStyle](operationDefinition.module.name),
|
|
2256
|
-
"types",
|
|
2257
|
-
"operations",
|
|
2258
|
-
filename
|
|
2259
|
-
].join("/");
|
|
2260
|
-
return filepath;
|
|
2261
|
-
}
|
|
2262
|
-
static getOperationDefinitionArtifactId(operationDefinition) {
|
|
2263
|
-
return `${operationDefinition.id}?generator=${OPERATION_GENERATOR}`;
|
|
2264
|
-
}
|
|
2265
|
-
static getEntrypointArtifactFilepath(moduleDefinition, fileNamingStyle) {
|
|
2266
|
-
return [
|
|
2267
|
-
".",
|
|
2268
|
-
changeCase5[fileNamingStyle](moduleDefinition.name),
|
|
2269
|
-
"types",
|
|
2270
|
-
"operations",
|
|
2271
|
-
"index.ts"
|
|
2272
|
-
].join("/");
|
|
2273
|
-
}
|
|
2274
|
-
static getEntrypointArtifactId(moduleDefinition) {
|
|
2275
|
-
return `${moduleDefinition.address}/paths/entrypoint?generator=${OPERATION_GENERATOR}`;
|
|
2276
|
-
}
|
|
2277
|
-
};
|
|
2278
|
-
|
|
2279
|
-
// src/plugins/generate-declaration/generate-declaration.plugin.ts
|
|
2280
|
-
var DECLARATION_GENERATOR = "declarationGenerator";
|
|
2281
|
-
var GenerateDeclarationPlugin = class _GenerateDeclarationPlugin {
|
|
2282
|
-
name = DECLARATION_GENERATOR;
|
|
2283
|
-
operationGenerator = new OperationDeclarationGenerator();
|
|
2284
|
-
schemaGenerator = new SchemaDeclarationGenerator();
|
|
2285
|
-
constructor() {
|
|
2286
|
-
}
|
|
2287
|
-
apply(compiler) {
|
|
2288
|
-
_GenerateDeclarationPlugin.register(compiler);
|
|
2289
|
-
compiler.hooks.compile.tapPromise(_GenerateDeclarationPlugin.name, async (task) => {
|
|
2290
|
-
compiler.context.artifacts?.push(
|
|
2291
|
-
...await this.schemaGenerator.compile(compiler, task),
|
|
2292
|
-
...await this.operationGenerator.compile(compiler, task)
|
|
2293
|
-
);
|
|
2294
|
-
});
|
|
2295
|
-
}
|
|
2296
|
-
static register(compiler) {
|
|
2297
|
-
if (!MetadataStorage2.has(compiler)) {
|
|
2298
|
-
MetadataStorage2.set(compiler, {
|
|
2299
|
-
hooks: {
|
|
2300
|
-
afterEntrypointArtifactGenerated: new import_tapable.AsyncSeriesWaterfallHook(["artifact", "task"]),
|
|
2301
|
-
afterSchemaDeclarationArtifactGenerated: new import_tapable.AsyncSeriesWaterfallHook(["artifact", "schemaDefinition", "task"]),
|
|
2302
|
-
afterOperationDeclarationArtifactGenerated: new import_tapable.AsyncSeriesWaterfallHook(["artifact", "operationDefinition", "task"])
|
|
2303
|
-
}
|
|
2304
|
-
});
|
|
2305
|
-
}
|
|
2306
|
-
return MetadataStorage2.get(compiler);
|
|
2307
|
-
}
|
|
2308
|
-
static of(compiler) {
|
|
2309
|
-
return this.register(compiler);
|
|
2310
|
-
}
|
|
2311
|
-
};
|
|
2312
|
-
|
|
2313
|
-
// src/plugins/generate-micro-function/generators/request/request.generator.ts
|
|
2314
|
-
var MICRO_FUNCTION_REQUEST_GENERATOR = "microFunctionRequestGenerator";
|
|
2315
|
-
var RequestGenerator = class _RequestGenerator {
|
|
2316
|
-
generateRequestArtifact() {
|
|
2317
|
-
const content = [
|
|
2318
|
-
"/* @anchor:file:start */",
|
|
2319
|
-
"",
|
|
2320
|
-
'import { KeqRequest } from "keq"',
|
|
2321
|
-
"",
|
|
2322
|
-
"/* @anchor:request-declaration */",
|
|
2323
|
-
"export const request = new KeqRequest()",
|
|
2324
|
-
"",
|
|
2325
|
-
"/* @anchor:file:end */"
|
|
2326
|
-
].join("\n");
|
|
2327
|
-
return new Artifact({
|
|
2328
|
-
id: _RequestGenerator.getRequestArtifactId(),
|
|
2329
|
-
filepath: _RequestGenerator.getRequestArtifactFilepath(),
|
|
2330
|
-
content
|
|
2331
|
-
});
|
|
2332
|
-
}
|
|
2333
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
2334
|
-
async compile(compiler, task) {
|
|
2335
|
-
return [
|
|
2336
|
-
this.generateRequestArtifact()
|
|
2337
|
-
];
|
|
2338
|
-
}
|
|
2339
|
-
static getRequestArtifactFilepath() {
|
|
2340
|
-
return "./request.ts";
|
|
2341
|
-
}
|
|
2342
|
-
static getRequestArtifactId() {
|
|
2343
|
-
return `request?generator=${MICRO_FUNCTION_REQUEST_GENERATOR}`;
|
|
2344
|
-
}
|
|
2345
|
-
};
|
|
2346
|
-
|
|
2347
|
-
// src/plugins/generate-micro-function/generators/micro_function/micro-function.generator.ts
|
|
2348
|
-
var MICRO_FUNCTION_GENERATOR = "microFunctionGenerator";
|
|
2349
|
-
var MicroFunctionGenerator = class _MicroFunctionGenerator {
|
|
2350
|
-
async compile(compiler, task) {
|
|
2351
|
-
const metadata = MetadataStorage.get(compiler);
|
|
2352
|
-
const context = compiler.context;
|
|
2353
|
-
const rc = context.rc;
|
|
2354
|
-
const documents = context.documents;
|
|
2355
|
-
const operationDefinitions = documents.flatMap((document) => document.operations);
|
|
2356
|
-
const artifactMap = new Map(
|
|
2357
|
-
await Promise.all(
|
|
2358
|
-
operationDefinitions.map(async (operationDefinition) => [
|
|
2359
|
-
operationDefinition,
|
|
2360
|
-
await metadata.hooks.afterMicroFunctionArtifactGenerated.promise(
|
|
2361
|
-
this.generateOperationDefinitionArtifact(operationDefinition, rc),
|
|
2362
|
-
operationDefinition,
|
|
2363
|
-
task
|
|
2364
|
-
)
|
|
2365
|
-
])
|
|
2366
|
-
)
|
|
2367
|
-
);
|
|
2368
|
-
const entrypoints = await Promise.all(
|
|
2369
|
-
R21.collectBy(
|
|
2370
|
-
(operationDefinition) => operationDefinition.module.name,
|
|
2371
|
-
operationDefinitions
|
|
2372
|
-
).map((operationDefinitions2) => [
|
|
2373
|
-
operationDefinitions2[0].module,
|
|
2374
|
-
operationDefinitions2.map((operationDefinition) => artifactMap.get(operationDefinition)).filter((artifact) => Boolean(artifact))
|
|
2375
|
-
]).map(async ([moduleDefinition, artifacts]) => await metadata.hooks.afterEntrypointArtifactGenerated.promise(
|
|
2376
|
-
this.generateEntrypointArtifact(
|
|
2377
|
-
moduleDefinition,
|
|
2378
|
-
artifacts,
|
|
2379
|
-
rc
|
|
2380
|
-
),
|
|
2381
|
-
task
|
|
2382
|
-
))
|
|
2383
|
-
);
|
|
2384
|
-
return [...entrypoints, ...artifactMap.values()];
|
|
2385
|
-
}
|
|
2386
|
-
generateOperationDefinitionArtifact(operationDefinition, rc) {
|
|
2387
|
-
const filepath = _MicroFunctionGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle);
|
|
2388
|
-
const dirpath = path10.dirname(filepath);
|
|
2389
|
-
const artifact = new Artifact({
|
|
2390
|
-
id: _MicroFunctionGenerator.getOperationDefinitionArtifactId(operationDefinition),
|
|
2391
|
-
filepath,
|
|
2392
|
-
content: OperationDefinitionTransformer.toMicroFunction(operationDefinition, {
|
|
2393
|
-
esm: rc.esm,
|
|
2394
|
-
getOperationDefinitionDeclarationFilepath(operationDefinition2) {
|
|
2395
|
-
const relativePath = path10.relative(
|
|
2396
|
-
dirpath,
|
|
2397
|
-
OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition2, rc.fileNamingStyle)
|
|
2398
|
-
);
|
|
2399
|
-
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
2400
|
-
},
|
|
2401
|
-
getRequestFilepath() {
|
|
2402
|
-
const relativePath = path10.relative(
|
|
2403
|
-
dirpath,
|
|
2404
|
-
RequestGenerator.getRequestArtifactFilepath()
|
|
2405
|
-
);
|
|
2406
|
-
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
2407
|
-
}
|
|
2408
|
-
}),
|
|
2409
|
-
extensionName: ".type.ts"
|
|
2410
|
-
});
|
|
2411
|
-
return artifact;
|
|
2412
|
-
}
|
|
2413
|
-
generateEntrypointArtifact(moduleDefinition, exports2, rc) {
|
|
2414
|
-
const filepath = _MicroFunctionGenerator.getEntrypointArtifactFilepath(moduleDefinition, rc.fileNamingStyle);
|
|
2415
|
-
const dirpath = filepath.substring(0, filepath.lastIndexOf("/"));
|
|
2416
|
-
const artifact = new Artifact({
|
|
2417
|
-
id: _MicroFunctionGenerator.getEntrypointArtifactId(moduleDefinition),
|
|
2418
|
-
filepath,
|
|
2419
|
-
content: EntrypointTransformer.toTypescript(exports2, { dirpath })
|
|
2420
|
-
});
|
|
2421
|
-
return artifact;
|
|
2422
|
-
}
|
|
2423
|
-
static getOperationDefinitionArtifactFilepath(operationDefinition, fileNamingStyle) {
|
|
2424
|
-
const filename = `${changeCase6[fileNamingStyle](operationDefinition.operationId)}.fn.ts`;
|
|
2425
|
-
const filepath = [
|
|
2426
|
-
".",
|
|
2427
|
-
changeCase6[fileNamingStyle](operationDefinition.module.name),
|
|
2428
|
-
"operations",
|
|
2429
|
-
filename
|
|
2430
|
-
].join("/");
|
|
2431
|
-
return filepath;
|
|
2432
|
-
}
|
|
2433
|
-
static getOperationDefinitionArtifactId(operationDefinition) {
|
|
2434
|
-
return `${operationDefinition.id}?generator=${MICRO_FUNCTION_GENERATOR}`;
|
|
2435
|
-
}
|
|
2436
|
-
static getEntrypointArtifactFilepath(moduleDefinition, fileNamingStyle) {
|
|
2437
|
-
return [
|
|
2438
|
-
".",
|
|
2439
|
-
changeCase6[fileNamingStyle](moduleDefinition.name),
|
|
2440
|
-
"operations",
|
|
2441
|
-
"index.ts"
|
|
2442
|
-
].join("/");
|
|
2443
|
-
}
|
|
2444
|
-
static getEntrypointArtifactId(moduleDefinition) {
|
|
2445
|
-
return `${moduleDefinition.address}/paths/entrypoint?generator=${MICRO_FUNCTION_GENERATOR}`;
|
|
2446
|
-
}
|
|
2447
|
-
};
|
|
2448
|
-
|
|
2449
|
-
// src/plugins/generate-micro-function/generate-micro-function.plugin.ts
|
|
2450
|
-
var GenerateMicroFunctionPlugin = class _GenerateMicroFunctionPlugin {
|
|
2451
|
-
microFunctionGenerator = new MicroFunctionGenerator();
|
|
2452
|
-
requestGenerator = new RequestGenerator();
|
|
2453
|
-
apply(compiler) {
|
|
2454
|
-
_GenerateMicroFunctionPlugin.register(compiler);
|
|
2455
|
-
compiler.hooks.compile.tapPromise(_GenerateMicroFunctionPlugin.name, async (task) => {
|
|
2456
|
-
const artifacts = [
|
|
2457
|
-
...await this.requestGenerator.compile(compiler, task),
|
|
2458
|
-
...await this.microFunctionGenerator.compile(compiler, task)
|
|
2459
|
-
];
|
|
2460
|
-
compiler.context.artifacts.push(...artifacts);
|
|
2461
|
-
});
|
|
2462
|
-
}
|
|
2463
|
-
static register(compiler) {
|
|
2464
|
-
if (!MetadataStorage.has(compiler)) {
|
|
2465
|
-
MetadataStorage.set(compiler, {
|
|
2466
|
-
hooks: {
|
|
2467
|
-
afterEntrypointArtifactGenerated: new import_tapable2.AsyncSeriesWaterfallHook(["artifact", "task"]),
|
|
2468
|
-
afterMicroFunctionArtifactGenerated: new import_tapable2.AsyncSeriesWaterfallHook(["artifact", "operationDefinition", "task"])
|
|
2469
|
-
}
|
|
2470
|
-
});
|
|
2471
|
-
}
|
|
2472
|
-
return MetadataStorage.get(compiler);
|
|
2473
|
-
}
|
|
2474
|
-
static of(compiler) {
|
|
2475
|
-
return this.register(compiler);
|
|
2476
|
-
}
|
|
2477
|
-
};
|
|
2478
|
-
|
|
2479
|
-
// src/plugins/generate-nestjs-module/generate-nestjs-module.ts
|
|
2480
|
-
var import_tapable3 = require("tapable");
|
|
2481
|
-
|
|
2482
|
-
// src/plugins/generate-nestjs-module/constants/metadata-storage.ts
|
|
2483
|
-
var MetadataStorage3 = /* @__PURE__ */ new WeakMap();
|
|
2484
|
-
|
|
2485
|
-
// src/plugins/generate-nestjs-module/generators/nestjs-module.generator.ts
|
|
2486
|
-
var path11 = __toESM(require("path"), 1);
|
|
2487
|
-
var changeCase7 = __toESM(require("change-case"), 1);
|
|
2488
|
-
var NESTJS_MODULE_GENERATOR = "nestjs-module-generator";
|
|
2489
|
-
var NestjsModuleGenerator = class _NestjsModuleGenerator {
|
|
2490
|
-
generateNestjsModuleArtifact(document, rc) {
|
|
2491
|
-
const filepath = _NestjsModuleGenerator.getNestjsModuleArtifactFilepath(document, rc.fileNamingStyle);
|
|
2492
|
-
const dirname6 = path11.dirname(filepath);
|
|
2493
|
-
const artifact = new Artifact({
|
|
2494
|
-
id: _NestjsModuleGenerator.getNestjsModuleArtifactId(document),
|
|
2495
|
-
filepath,
|
|
2496
|
-
content: ApiDocumentTransformer.toNestjsModule(document, {
|
|
2497
|
-
esm: rc.esm,
|
|
2498
|
-
getNestjsClientFilepath(document2) {
|
|
2499
|
-
const relativePath = path11.relative(
|
|
2500
|
-
dirname6,
|
|
2501
|
-
_NestjsModuleGenerator.getNestjsClientArtifactFilepath(document2, rc.fileNamingStyle)
|
|
2502
|
-
);
|
|
2503
|
-
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
2504
|
-
}
|
|
2505
|
-
})
|
|
2506
|
-
});
|
|
2507
|
-
return artifact;
|
|
2508
|
-
}
|
|
2509
|
-
generateNestjsClientArtifact(document, rc) {
|
|
2510
|
-
const filepath = _NestjsModuleGenerator.getNestjsClientArtifactFilepath(document, rc.fileNamingStyle);
|
|
2511
|
-
const dirpath = path11.dirname(filepath);
|
|
2512
|
-
const artifact = new Artifact({
|
|
2513
|
-
id: _NestjsModuleGenerator.getNestjsClientArtifactId(document),
|
|
2514
|
-
filepath,
|
|
2515
|
-
content: ApiDocumentTransformer.toNestjsClient(document, {
|
|
2516
|
-
esm: rc.esm,
|
|
2517
|
-
getOperationDefinitionDeclarationFilepath(operationDefinition) {
|
|
2518
|
-
const relativePath = path11.relative(
|
|
2519
|
-
dirpath,
|
|
2520
|
-
OperationDeclarationGenerator.getOperationDefinitionArtifactFilepath(operationDefinition, rc.fileNamingStyle)
|
|
2521
|
-
);
|
|
2522
|
-
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
2523
|
-
}
|
|
2524
|
-
})
|
|
2525
|
-
});
|
|
2526
|
-
return artifact;
|
|
2527
|
-
}
|
|
2528
|
-
async compile(compiler, task) {
|
|
2529
|
-
const metadata = MetadataStorage3.get(compiler);
|
|
2530
|
-
const rc = compiler.context.rc;
|
|
2531
|
-
const documents = compiler.context.documents;
|
|
2532
|
-
const nestjsModuleArtifacts = await Promise.all(
|
|
2533
|
-
documents.map((document) => metadata.hooks.afterNestjsModuleArtifactGenerated.promise(
|
|
2534
|
-
this.generateNestjsModuleArtifact(document, rc),
|
|
2535
|
-
document,
|
|
2536
|
-
task
|
|
2537
|
-
))
|
|
2538
|
-
);
|
|
2539
|
-
const nestjsClientArtifacts = await Promise.all(
|
|
2540
|
-
documents.map((document) => metadata.hooks.afterNestjsModuleArtifactGenerated.promise(
|
|
2541
|
-
this.generateNestjsClientArtifact(document, rc),
|
|
2542
|
-
document,
|
|
2543
|
-
task
|
|
2544
|
-
))
|
|
2545
|
-
);
|
|
2546
|
-
return [...nestjsModuleArtifacts, ...nestjsClientArtifacts];
|
|
2547
|
-
}
|
|
2548
|
-
static getNestjsModuleArtifactFilepath(document, fileNamingStyle) {
|
|
2549
|
-
const filename = `${changeCase7[fileNamingStyle](document.module.name)}.module.ts`;
|
|
2550
|
-
const filepath = [
|
|
2551
|
-
".",
|
|
2552
|
-
changeCase7[fileNamingStyle](document.module.name),
|
|
2553
|
-
filename
|
|
2554
|
-
];
|
|
2555
|
-
return filepath.join("/");
|
|
2556
|
-
}
|
|
2557
|
-
static getNestjsModuleArtifactId(document) {
|
|
2558
|
-
return `${document.module.address}?generate=${NESTJS_MODULE_GENERATOR}`;
|
|
2559
|
-
}
|
|
2560
|
-
static getNestjsClientArtifactFilepath(document, fileNamingStyle) {
|
|
2561
|
-
const filename = `${changeCase7[fileNamingStyle](document.module.name)}.client.ts`;
|
|
2562
|
-
const filepath = [
|
|
2563
|
-
".",
|
|
2564
|
-
changeCase7[fileNamingStyle](document.module.name),
|
|
2565
|
-
filename
|
|
2566
|
-
];
|
|
2567
|
-
return filepath.join("/");
|
|
2568
|
-
}
|
|
2569
|
-
static getNestjsClientArtifactId(document) {
|
|
2570
|
-
return `${document.module.address}?generate=${NESTJS_MODULE_GENERATOR}-client`;
|
|
2571
|
-
}
|
|
2572
|
-
};
|
|
2573
|
-
|
|
2574
|
-
// src/plugins/generate-nestjs-module/generate-nestjs-module.ts
|
|
2575
|
-
var GenerateNestjsModulePlugin = class _GenerateNestjsModulePlugin {
|
|
2576
|
-
nestjsModuleGenerator = new NestjsModuleGenerator();
|
|
2577
|
-
apply(compiler) {
|
|
2578
|
-
_GenerateNestjsModulePlugin.register(compiler);
|
|
2579
|
-
compiler.hooks.compile.tapPromise(_GenerateNestjsModulePlugin.name, async (task) => {
|
|
2580
|
-
const artifacts = await this.nestjsModuleGenerator.compile(compiler, task);
|
|
2581
|
-
compiler.context.artifacts.push(...artifacts);
|
|
2582
|
-
});
|
|
2583
|
-
}
|
|
2584
|
-
static register(compiler) {
|
|
2585
|
-
if (!MetadataStorage3.has(compiler)) {
|
|
2586
|
-
MetadataStorage3.set(compiler, {
|
|
2587
|
-
hooks: {
|
|
2588
|
-
afterNestjsModuleArtifactGenerated: new import_tapable3.AsyncSeriesWaterfallHook(["artifact", "document", "task"])
|
|
2589
|
-
}
|
|
2590
|
-
});
|
|
2591
|
-
}
|
|
2592
|
-
return MetadataStorage3.get(compiler);
|
|
2593
|
-
}
|
|
2594
|
-
static of(compiler) {
|
|
2595
|
-
return MetadataStorage3.get(compiler);
|
|
2596
|
-
}
|
|
2597
|
-
};
|
|
2598
|
-
|
|
2599
|
-
// src/plugins/chinese-to-pinyin/chinese-to-pinyin.plugin.ts
|
|
2600
|
-
var import_swagger_fix = require("swagger-fix");
|
|
2601
|
-
|
|
2602
|
-
// src/plugins/download-http-file/download-http-file.plugin.ts
|
|
2603
|
-
var DownloadHttpFilePlugin = class _DownloadHttpFilePlugin {
|
|
2604
|
-
apply(compiler) {
|
|
2605
|
-
compiler.hooks.download.tapPromise(_DownloadHttpFilePlugin.name, async (address, task) => {
|
|
2606
|
-
const { url } = address;
|
|
2607
|
-
if (!url.startsWith("http://") && !url.startsWith("https://")) return void 0;
|
|
2608
|
-
const content = await this.download(address);
|
|
2609
|
-
const spec = this.deserialize(content);
|
|
2610
|
-
return JSON.stringify(spec);
|
|
2611
|
-
});
|
|
2612
|
-
}
|
|
2613
|
-
async download(address) {
|
|
2614
|
-
const { url, headers } = address;
|
|
2615
|
-
try {
|
|
2616
|
-
const res = await fetch(url, { headers });
|
|
2617
|
-
if (res.status >= 400) throw new Error(`failed with status code ${res.status}`);
|
|
2618
|
-
return await res.text();
|
|
2619
|
-
} catch (e) {
|
|
2620
|
-
if (e instanceof Error) {
|
|
2621
|
-
e.message = `Unable get the openapi/swagger file from ${url}: ${e.message}`;
|
|
2622
|
-
}
|
|
2623
|
-
throw e;
|
|
2624
|
-
}
|
|
2625
|
-
}
|
|
2626
|
-
deserialize(content) {
|
|
2627
|
-
const json = JSON.parse(content);
|
|
2628
|
-
const spec = OpenapiUtils.to3_1(json);
|
|
2629
|
-
return spec;
|
|
2630
|
-
}
|
|
2631
|
-
};
|
|
2632
|
-
|
|
2633
|
-
// src/plugins/download-local-file/download-local-file.plugin.ts
|
|
2634
|
-
var path12 = __toESM(require("path"), 1);
|
|
2635
|
-
var fs5 = __toESM(require("fs/promises"), 1);
|
|
2636
|
-
var yaml = __toESM(require("js-yaml"), 1);
|
|
2637
|
-
var import_url = require("url");
|
|
2638
|
-
var DownloadLocalFilePlugin = class _DownloadLocalFilePlugin {
|
|
2639
|
-
apply(compiler) {
|
|
2640
|
-
compiler.hooks.download.tapPromise(_DownloadLocalFilePlugin.name, async (address, task) => {
|
|
2641
|
-
const { url, encoding } = address;
|
|
2642
|
-
if (!url.startsWith("file://")) return void 0;
|
|
2643
|
-
const filepath = (0, import_url.fileURLToPath)(url);
|
|
2644
|
-
const fileExt = path12.extname(filepath);
|
|
2645
|
-
const content = await fs5.readFile(filepath, encoding);
|
|
2646
|
-
const str = typeof content === "string" ? content : content.toString(encoding);
|
|
2647
|
-
if ([".yml", ".yaml"].includes(fileExt)) {
|
|
2648
|
-
const value = yaml.load(str);
|
|
2649
|
-
return JSON.stringify(OpenapiUtils.to3_1(value));
|
|
2650
|
-
} else if (fileExt === ".json") {
|
|
2651
|
-
return JSON.stringify(OpenapiUtils.to3_1(JSON.parse(str)));
|
|
2652
|
-
}
|
|
2653
|
-
});
|
|
2654
|
-
}
|
|
2655
|
-
};
|
|
2656
|
-
|
|
2657
|
-
// src/plugins/shaking/shaking.plugin.ts
|
|
2658
|
-
var import_openapi_shaking = require("@opendoc/openapi-shaking");
|
|
2659
|
-
var ShakingPlugin = class _ShakingPlugin {
|
|
2660
|
-
apply(compiler) {
|
|
2661
|
-
compiler.hooks.beforeCompile.tap(_ShakingPlugin.name, (task) => {
|
|
2662
|
-
const matcher = compiler.context.matcher;
|
|
2663
|
-
const documents = compiler.context.documents;
|
|
2664
|
-
compiler.context.documents = documents.map((document) => this.shaking(compiler, document)).filter((document) => !document.isEmpty()).filter((document) => !matcher.isModuleIgnored(document.module));
|
|
2665
|
-
});
|
|
2666
|
-
}
|
|
2667
|
-
shaking(compiler, document) {
|
|
2668
|
-
const rc = compiler.context.rc;
|
|
2669
|
-
const matcher = compiler.context.matcher;
|
|
2670
|
-
const isAccepted = (pathname, method, operation) => {
|
|
2671
|
-
if (!SupportedMethods.includes(method)) return false;
|
|
2672
|
-
return !matcher.isOperationIgnored(new OperationDefinition({
|
|
2673
|
-
method,
|
|
2674
|
-
pathname,
|
|
2675
|
-
operation,
|
|
2676
|
-
module: document.module,
|
|
2677
|
-
document
|
|
2678
|
-
}));
|
|
2679
|
-
};
|
|
2680
|
-
const sharkedSwagger = (0, import_openapi_shaking.openapiShakingSync)(
|
|
2681
|
-
document.specification,
|
|
2682
|
-
isAccepted,
|
|
2683
|
-
{ tolerant: rc.tolerant }
|
|
2684
|
-
);
|
|
2685
|
-
return new ApiDocumentV3_1(
|
|
2686
|
-
sharkedSwagger,
|
|
2687
|
-
new ModuleDefinition(
|
|
2688
|
-
document.module.name,
|
|
2689
|
-
{
|
|
2690
|
-
url: `memory://${document.module.name}.v3_1.sharked.json`,
|
|
2691
|
-
headers: {},
|
|
2692
|
-
encoding: "utf8"
|
|
2693
|
-
}
|
|
2694
|
-
)
|
|
2695
|
-
);
|
|
2696
|
-
}
|
|
2697
|
-
};
|
|
2698
|
-
|
|
2699
|
-
// src/plugins/terminal-select/utils/select-operation-definitions.ts
|
|
2700
|
-
var import_inquirer_select_pro = require("inquirer-select-pro");
|
|
2701
|
-
var import_prompt_adapter_inquirer = require("@listr2/prompt-adapter-inquirer");
|
|
2702
|
-
async function selectOperationDefinitions(task, operationDefinitions) {
|
|
2703
|
-
const selectedOperationDefinitions = await task.prompt(import_prompt_adapter_inquirer.ListrInquirerPromptAdapter).run(
|
|
2704
|
-
import_inquirer_select_pro.select,
|
|
2705
|
-
{
|
|
2706
|
-
message: "Select Pathname",
|
|
2707
|
-
defaultValue: [],
|
|
2708
|
-
options: (input) => {
|
|
2709
|
-
const items = operationDefinitions.map((op) => ({ name: `${op.module.name} ${op.method.toUpperCase()} ${op.pathname}`, value: op }));
|
|
2710
|
-
if (!input) return items;
|
|
2711
|
-
const keys2 = input.trim().toLowerCase().split(/\s+/);
|
|
2712
|
-
return items.filter((i) => {
|
|
2713
|
-
const name = i.name.toLowerCase();
|
|
2714
|
-
return keys2.every((q) => name.includes(q));
|
|
2715
|
-
});
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
|
-
);
|
|
2719
|
-
return selectedOperationDefinitions;
|
|
1337
|
+
//#endregion
|
|
1338
|
+
//#region src/cli.ts
|
|
1339
|
+
if (semver.default.lt(process.version, "20.0.0")) throw new Error("Node.js version must be greater than 20");
|
|
1340
|
+
const program = new commander.Command();
|
|
1341
|
+
registerBuildCommand(program);
|
|
1342
|
+
registerFilterCommand(program);
|
|
1343
|
+
registerListCommand(program);
|
|
1344
|
+
registerApisCommand(program);
|
|
1345
|
+
registerMockCommand(program);
|
|
1346
|
+
registerInitCommand(program);
|
|
1347
|
+
registerSearchCommand(program);
|
|
1348
|
+
registerMcpCommand(program);
|
|
1349
|
+
async function main() {
|
|
1350
|
+
program.on("command:*", function(operands) {
|
|
1351
|
+
throw new Error(`Unknown command '${String(operands[0])}'`);
|
|
1352
|
+
});
|
|
1353
|
+
try {
|
|
1354
|
+
await program.parseAsync(process.argv);
|
|
1355
|
+
} catch (err) {
|
|
1356
|
+
if (process.argv.includes("--debug")) console.error(err);
|
|
1357
|
+
else require_logger.logger.error(err instanceof Error ? err.message : String(err));
|
|
1358
|
+
process.exit(1);
|
|
1359
|
+
}
|
|
2720
1360
|
}
|
|
1361
|
+
main();
|
|
1362
|
+
//#endregion
|
|
2721
1363
|
|
|
2722
|
-
// src/plugins/terminal-select/terminal-select.plugin.ts
|
|
2723
|
-
var TerminalSelectPlugin = class _TerminalSelectPlugin {
|
|
2724
|
-
constructor(options) {
|
|
2725
|
-
this.options = options;
|
|
2726
|
-
}
|
|
2727
|
-
apply(compiler) {
|
|
2728
|
-
compiler.hooks.afterDownload.tapPromise(_TerminalSelectPlugin.name, async (task) => {
|
|
2729
|
-
const context = compiler.context;
|
|
2730
|
-
const matcher = context.matcher;
|
|
2731
|
-
const documents = context.documents;
|
|
2732
|
-
const operationDefinitions = documents.flatMap((document) => document.operations);
|
|
2733
|
-
const selectedOperationDefinitions = await selectOperationDefinitions(task, operationDefinitions);
|
|
2734
|
-
if (this.options.clear) {
|
|
2735
|
-
matcher.append({
|
|
2736
|
-
persist: false,
|
|
2737
|
-
ignore: true,
|
|
2738
|
-
moduleName: "*",
|
|
2739
|
-
operationMethod: "*",
|
|
2740
|
-
operationPathname: "*"
|
|
2741
|
-
});
|
|
2742
|
-
}
|
|
2743
|
-
for (const op of selectedOperationDefinitions) {
|
|
2744
|
-
matcher.append({
|
|
2745
|
-
persist: !!this.options.persist,
|
|
2746
|
-
ignore: this.options.mode === "add",
|
|
2747
|
-
moduleName: op.module.name,
|
|
2748
|
-
operationMethod: op.method,
|
|
2749
|
-
operationPathname: op.pathname
|
|
2750
|
-
});
|
|
2751
|
-
}
|
|
2752
|
-
});
|
|
2753
|
-
}
|
|
2754
|
-
};
|
|
2755
|
-
|
|
2756
|
-
// src/plugins/initialize/initialize.plugin.ts
|
|
2757
|
-
var R23 = __toESM(require("ramda"), 1);
|
|
2758
|
-
var InitializePlugin = class _InitializePlugin {
|
|
2759
|
-
constructor(options) {
|
|
2760
|
-
this.options = options;
|
|
2761
|
-
}
|
|
2762
|
-
apply(compiler) {
|
|
2763
|
-
compiler.hooks.setup.tap(_InitializePlugin.name, (task) => {
|
|
2764
|
-
new DownloadHttpFilePlugin().apply(compiler);
|
|
2765
|
-
new DownloadLocalFilePlugin().apply(compiler);
|
|
2766
|
-
new GenerateDeclarationPlugin().apply(compiler);
|
|
2767
|
-
if (this.options.build) {
|
|
2768
|
-
new ShakingPlugin().apply(compiler);
|
|
2769
|
-
}
|
|
2770
|
-
if (this.options.interactive) {
|
|
2771
|
-
new TerminalSelectPlugin(
|
|
2772
|
-
typeof this.options.interactive === "object" ? this.options.interactive : { mode: "except" }
|
|
2773
|
-
).apply(compiler);
|
|
2774
|
-
}
|
|
2775
|
-
const rc = compiler.context.rc;
|
|
2776
|
-
if (rc.mode === "micro-function") {
|
|
2777
|
-
new GenerateMicroFunctionPlugin().apply(compiler);
|
|
2778
|
-
} else if (rc.mode === "nestjs-module") {
|
|
2779
|
-
new GenerateNestjsModulePlugin().apply(compiler);
|
|
2780
|
-
}
|
|
2781
|
-
if (rc.plugins && rc.plugins.length) {
|
|
2782
|
-
for (const plugin of rc.plugins) {
|
|
2783
|
-
plugin.apply(compiler);
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
});
|
|
2787
|
-
if (this.options.includes && this.options.includes.length) {
|
|
2788
|
-
const modulesIncludes = this.options.includes;
|
|
2789
|
-
compiler.hooks.afterSetup.tap(_InitializePlugin.name, (task) => {
|
|
2790
|
-
const rc = compiler.context.rc;
|
|
2791
|
-
const matcher = compiler.context.matcher;
|
|
2792
|
-
const notExistModules = modulesIncludes.filter((moduleName) => !(moduleName in rc.modules));
|
|
2793
|
-
if (notExistModules.length) {
|
|
2794
|
-
throw new Error(`Cannot find module(s) ${notExistModules.join(", ")} in config file.`);
|
|
2795
|
-
}
|
|
2796
|
-
const ignoredModules = R23.difference(R23.keys(rc.modules), modulesIncludes);
|
|
2797
|
-
for (const moduleName of ignoredModules) {
|
|
2798
|
-
matcher.append({
|
|
2799
|
-
persist: false,
|
|
2800
|
-
ignore: true,
|
|
2801
|
-
moduleName,
|
|
2802
|
-
operationMethod: "*",
|
|
2803
|
-
operationPathname: "*"
|
|
2804
|
-
});
|
|
2805
|
-
}
|
|
2806
|
-
});
|
|
2807
|
-
}
|
|
2808
|
-
}
|
|
2809
|
-
};
|
|
2810
|
-
|
|
2811
|
-
// src/plugins/overwrite-query-options/overwrite-query-options.plugin.ts
|
|
2812
|
-
var QsArrayFormatUnion = Object.values(QsArrayFormat);
|
|
2813
|
-
|
|
2814
|
-
// src/compiler/compiler.ts
|
|
2815
|
-
var Compiler = class {
|
|
2816
|
-
constructor(options) {
|
|
2817
|
-
this.options = options;
|
|
2818
|
-
for (const hook of Object.values(this.hooks)) {
|
|
2819
|
-
hook.intercept(perfectErrorMessage());
|
|
2820
|
-
}
|
|
2821
|
-
this.hooks.afterSetup.intercept(printInformation(0));
|
|
2822
|
-
this.hooks.afterPersist.intercept(printInformation(0));
|
|
2823
|
-
new InitializePlugin({
|
|
2824
|
-
build: options.build,
|
|
2825
|
-
interactive: options.interactive,
|
|
2826
|
-
includes: options.includes
|
|
2827
|
-
}).apply(this);
|
|
2828
|
-
}
|
|
2829
|
-
context = {};
|
|
2830
|
-
hooks = {
|
|
2831
|
-
setup: new import_tapable4.AsyncParallelHook(["task"]),
|
|
2832
|
-
afterSetup: new import_tapable4.AsyncSeriesHook(["task"]),
|
|
2833
|
-
beforeDownload: new import_tapable4.AsyncSeriesHook(["task"]),
|
|
2834
|
-
download: new import_tapable4.AsyncSeriesBailHook(["address", "moduleDefinition", "task"]),
|
|
2835
|
-
afterDownload: new import_tapable4.AsyncSeriesHook(["task"]),
|
|
2836
|
-
beforeCompile: new import_tapable4.AsyncSeriesHook(["task"]),
|
|
2837
|
-
compile: new import_tapable4.AsyncParallelHook(["task"]),
|
|
2838
|
-
afterCompile: new import_tapable4.AsyncSeriesHook(["task"]),
|
|
2839
|
-
beforePersist: new import_tapable4.AsyncSeriesHook(["task"]),
|
|
2840
|
-
persist: new import_tapable4.AsyncParallelHook(["task"]),
|
|
2841
|
-
afterPersist: new import_tapable4.AsyncSeriesHook(["task"]),
|
|
2842
|
-
done: new import_tapable4.SyncHook()
|
|
2843
|
-
};
|
|
2844
|
-
async run() {
|
|
2845
|
-
const options = this.options;
|
|
2846
|
-
const tasks = new import_listr22.Listr(
|
|
2847
|
-
[
|
|
2848
|
-
createSetupTask(this, options),
|
|
2849
|
-
createDownloadTask(this, { skipIgnoredModules: !options.interactive }),
|
|
2850
|
-
createCompileTask(this, { enabled: !!options.build }),
|
|
2851
|
-
createPersistTask(this)
|
|
2852
|
-
],
|
|
2853
|
-
{
|
|
2854
|
-
concurrent: false,
|
|
2855
|
-
renderer: "default",
|
|
2856
|
-
rendererOptions: {
|
|
2857
|
-
suffixSkips: true,
|
|
2858
|
-
collapseSubtasks: false,
|
|
2859
|
-
collapseErrors: false
|
|
2860
|
-
}
|
|
2861
|
-
}
|
|
2862
|
-
);
|
|
2863
|
-
await tasks.run(this.context);
|
|
2864
|
-
await this.hooks.done.promise();
|
|
2865
|
-
}
|
|
2866
|
-
};
|
|
2867
|
-
|
|
2868
|
-
// src/cli.ts
|
|
2869
|
-
if (import_semver.default.lt(process.version, "20.0.0")) {
|
|
2870
|
-
throw new Error("Node.js version must be greater than 20");
|
|
2871
|
-
}
|
|
2872
|
-
var program = new import_commander.Command();
|
|
2873
|
-
program.command("build").option("-c --config <config>", "The keq-cli config file").option("--module <modules...>", "Filter module(s) to generate").option("--debug", "Print debug information").option("--tolerant", "Tolerate wrong swagger/openapi structure").option("-i --interactive", "Interactive select the scope of generation").action(async (options) => {
|
|
2874
|
-
const compiler = new Compiler({
|
|
2875
|
-
build: true,
|
|
2876
|
-
config: options.config,
|
|
2877
|
-
includes: options.module,
|
|
2878
|
-
debug: !!options.debug,
|
|
2879
|
-
tolerant: !!options.tolerant,
|
|
2880
|
-
interactive: !!options.interactive && {
|
|
2881
|
-
mode: "except",
|
|
2882
|
-
clear: true
|
|
2883
|
-
}
|
|
2884
|
-
});
|
|
2885
|
-
await compiler.run();
|
|
2886
|
-
});
|
|
2887
|
-
program.command("ignore").addArgument(
|
|
2888
|
-
new import_commander.Argument("<mode>", "The ignore mode").choices(["all", "add", "except"]).argRequired()
|
|
2889
|
-
).option("-c --config <config>", "The keq-cli config file").option("--debug", "Print debug information").option("--module <modules...>").option("--build", "Build after updating .keqignore file").addOption(
|
|
2890
|
-
new import_commander.Option("--method <method>", "Only generate files of the specified operation method").choices([
|
|
2891
|
-
...SupportedMethods,
|
|
2892
|
-
...SupportedMethods.map((method) => method.toUpperCase())
|
|
2893
|
-
])
|
|
2894
|
-
).option("--pathname <pathnames>", "Only generate files of the specified operation pathname").option("-i --interactive", "Interactive select the scope of generation").action(async (mode, options) => {
|
|
2895
|
-
let compiler;
|
|
2896
|
-
if (mode === "all") {
|
|
2897
|
-
if (options.build) throw new Error("'--build' cannot be used with 'all' mode");
|
|
2898
|
-
compiler = new Compiler({
|
|
2899
|
-
build: false,
|
|
2900
|
-
config: options.config,
|
|
2901
|
-
includes: options.module,
|
|
2902
|
-
debug: !!options.debug,
|
|
2903
|
-
interactive: false,
|
|
2904
|
-
ignore: {
|
|
2905
|
-
rules: [{
|
|
2906
|
-
persist: true,
|
|
2907
|
-
ignore: true,
|
|
2908
|
-
moduleName: "*",
|
|
2909
|
-
operationMethod: "*",
|
|
2910
|
-
operationPathname: "*"
|
|
2911
|
-
}]
|
|
2912
|
-
}
|
|
2913
|
-
});
|
|
2914
|
-
} else if (options.interactive) {
|
|
2915
|
-
if (options.interactive) {
|
|
2916
|
-
if (options.method) throw new Error("'--method' cannot be used with '--interactive'");
|
|
2917
|
-
if (options.pathname) throw new Error("'--pathname' cannot be used with '--interactive'");
|
|
2918
|
-
}
|
|
2919
|
-
compiler = new Compiler({
|
|
2920
|
-
build: !!options.build,
|
|
2921
|
-
config: options.config,
|
|
2922
|
-
includes: options.module,
|
|
2923
|
-
debug: !!options.debug,
|
|
2924
|
-
interactive: {
|
|
2925
|
-
mode,
|
|
2926
|
-
persist: true
|
|
2927
|
-
}
|
|
2928
|
-
});
|
|
2929
|
-
} else {
|
|
2930
|
-
if (!options.method && !options.pathname) {
|
|
2931
|
-
throw new Error("at least one of '-i --interactive', '--method' or '--pathname' must be specified");
|
|
2932
|
-
}
|
|
2933
|
-
const moduleNames = options.module || ["*"];
|
|
2934
|
-
compiler = new Compiler({
|
|
2935
|
-
build: !!options.build,
|
|
2936
|
-
config: options.config,
|
|
2937
|
-
debug: !!options.debug,
|
|
2938
|
-
includes: options.module,
|
|
2939
|
-
ignore: {
|
|
2940
|
-
rules: moduleNames.map((moduleNames2) => ({
|
|
2941
|
-
persist: true,
|
|
2942
|
-
ignore: mode === "add",
|
|
2943
|
-
moduleName: moduleNames2,
|
|
2944
|
-
operationMethod: options.method,
|
|
2945
|
-
operationPathname: options.pathname
|
|
2946
|
-
}))
|
|
2947
|
-
},
|
|
2948
|
-
interactive: false
|
|
2949
|
-
});
|
|
2950
|
-
}
|
|
2951
|
-
await compiler.run();
|
|
2952
|
-
});
|
|
2953
|
-
async function main5() {
|
|
2954
|
-
program.on("command:*", function(operands) {
|
|
2955
|
-
throw new Error(`Unknown command '${String(operands[0])}'`);
|
|
2956
|
-
});
|
|
2957
|
-
try {
|
|
2958
|
-
await program.parseAsync(process.argv);
|
|
2959
|
-
} catch (err) {
|
|
2960
|
-
if (process.argv.includes("--debug")) {
|
|
2961
|
-
console.error(err);
|
|
2962
|
-
} else {
|
|
2963
|
-
logger.error(err instanceof Error ? err.message : String(err));
|
|
2964
|
-
}
|
|
2965
|
-
}
|
|
2966
|
-
}
|
|
2967
|
-
void main5();
|
|
2968
1364
|
//# sourceMappingURL=cli.cjs.map
|