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,1991 +1,1876 @@
|
|
|
1
|
-
"
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
9
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
20
18
|
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Keq: () => Keq,
|
|
46
|
-
KeqExecutionContext: () => KeqExecutionContext,
|
|
47
|
-
KeqMiddlewareExecutor: () => KeqMiddlewareExecutor,
|
|
48
|
-
KeqMiddlewareOrchestrator: () => KeqMiddlewareOrchestrator,
|
|
49
|
-
KeqRequest: () => KeqRequest,
|
|
50
|
-
KeqSharedContext: () => KeqSharedContext,
|
|
51
|
-
MethodNotAllowedException: () => MethodNotAllowedException,
|
|
52
|
-
NotAcceptableException: () => NotAcceptableException,
|
|
53
|
-
NotFoundedException: () => NotFoundedException,
|
|
54
|
-
NotImplementedException: () => NotImplementedException,
|
|
55
|
-
PreconditionFailedException: () => PreconditionFailedException,
|
|
56
|
-
ProxyAuthenticationRequiredException: () => ProxyAuthenticationRequiredException,
|
|
57
|
-
RequestException: () => RequestException,
|
|
58
|
-
RequestTimeoutException: () => RequestTimeoutException,
|
|
59
|
-
ServiceUnavailableException: () => ServiceUnavailableException,
|
|
60
|
-
TimeoutException: () => TimeoutException,
|
|
61
|
-
TooManyRequestsException: () => TooManyRequestsException,
|
|
62
|
-
TypeException: () => TypeException,
|
|
63
|
-
UnauthorizedException: () => UnauthorizedException,
|
|
64
|
-
UnsupportedMediaTypeException: () => UnsupportedMediaTypeException,
|
|
65
|
-
UriTooLongException: () => UriTooLongException,
|
|
66
|
-
composeMiddleware: () => composeMiddleware,
|
|
67
|
-
composeRoute: () => composeRoute,
|
|
68
|
-
createProxyResponse: () => createProxyResponse,
|
|
69
|
-
createRequest: () => createRequest,
|
|
70
|
-
request: () => request
|
|
71
|
-
});
|
|
72
|
-
module.exports = __toCommonJS(index_exports);
|
|
73
|
-
|
|
74
|
-
// src/exception/exception.ts
|
|
75
|
-
var import_ts_custom_error = require("ts-custom-error");
|
|
76
|
-
var Exception = class extends import_ts_custom_error.CustomError {
|
|
77
|
-
constructor(message) {
|
|
78
|
-
super(message);
|
|
79
|
-
Object.defineProperty(this, "name", { value: "KeqError" });
|
|
80
|
-
}
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let ts_custom_error = require("ts-custom-error");
|
|
25
|
+
let _opendoc_uri_template = require("@opendoc/uri-template");
|
|
26
|
+
let mitt = require("mitt");
|
|
27
|
+
mitt = __toESM(mitt);
|
|
28
|
+
let klona = require("klona");
|
|
29
|
+
let klona_json = require("klona/json");
|
|
30
|
+
let eventsource_parser_stream = require("eventsource-parser/stream");
|
|
31
|
+
let qs = require("qs");
|
|
32
|
+
qs = __toESM(qs);
|
|
33
|
+
let picomatch = require("picomatch");
|
|
34
|
+
picomatch = __toESM(picomatch);
|
|
35
|
+
let fastq = require("fastq");
|
|
36
|
+
fastq = __toESM(fastq);
|
|
37
|
+
//#region src/exception/exception.ts
|
|
38
|
+
var Exception = class extends ts_custom_error.CustomError {
|
|
39
|
+
constructor(message) {
|
|
40
|
+
super(message);
|
|
41
|
+
Object.defineProperty(this, "name", { value: "KeqError" });
|
|
42
|
+
}
|
|
81
43
|
};
|
|
82
|
-
|
|
83
|
-
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/exception/type.exception.ts
|
|
84
46
|
var TypeException = class extends Exception {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
47
|
+
constructor(msg) {
|
|
48
|
+
super(msg || "Invalid Type");
|
|
49
|
+
}
|
|
88
50
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
var AbortException = class
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/exception/abort.exception.ts
|
|
53
|
+
var AbortException = class AbortException extends DOMException {
|
|
54
|
+
constructor(msg) {
|
|
55
|
+
super(msg, "AbortError");
|
|
56
|
+
Object.setPrototypeOf(this, AbortException.prototype);
|
|
57
|
+
}
|
|
96
58
|
};
|
|
97
|
-
|
|
98
|
-
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/exception/timeout.exception.ts
|
|
99
61
|
var TimeoutException = class extends AbortException {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
62
|
+
constructor(msg) {
|
|
63
|
+
super(msg);
|
|
64
|
+
}
|
|
103
65
|
};
|
|
104
|
-
|
|
105
|
-
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/exception/mutex.exception.ts
|
|
68
|
+
var MutexException = class extends Exception {
|
|
69
|
+
constructor(message) {
|
|
70
|
+
super(message);
|
|
71
|
+
Object.defineProperty(this, "name", { value: "MutexException" });
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/typeof.js
|
|
76
|
+
function _typeof(o) {
|
|
77
|
+
"@babel/helpers - typeof";
|
|
78
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
79
|
+
return typeof o;
|
|
80
|
+
} : function(o) {
|
|
81
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
82
|
+
}, _typeof(o);
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/toPrimitive.js
|
|
86
|
+
function toPrimitive(t, r) {
|
|
87
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
88
|
+
var e = t[Symbol.toPrimitive];
|
|
89
|
+
if (void 0 !== e) {
|
|
90
|
+
var i = e.call(t, r || "default");
|
|
91
|
+
if ("object" != _typeof(i)) return i;
|
|
92
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
93
|
+
}
|
|
94
|
+
return ("string" === r ? String : Number)(t);
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/toPropertyKey.js
|
|
98
|
+
function toPropertyKey(t) {
|
|
99
|
+
var i = toPrimitive(t, "string");
|
|
100
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/defineProperty.js
|
|
104
|
+
function _defineProperty(e, r, t) {
|
|
105
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
106
|
+
value: t,
|
|
107
|
+
enumerable: !0,
|
|
108
|
+
configurable: !0,
|
|
109
|
+
writable: !0
|
|
110
|
+
}) : e[r] = t, e;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/exception/http-exceptions/request.exception.ts
|
|
106
114
|
var RequestException = class extends Exception {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
constructor(statusCode, message, options) {
|
|
116
|
+
super(message);
|
|
117
|
+
_defineProperty(this, "statusCode", void 0);
|
|
118
|
+
_defineProperty(this, "retry", void 0);
|
|
119
|
+
_defineProperty(this, "response", void 0);
|
|
120
|
+
this.statusCode = statusCode;
|
|
121
|
+
this.retry = !options?.fatal;
|
|
122
|
+
this.response = options?.response;
|
|
123
|
+
Object.defineProperty(this, "name", { value: "RequestException" });
|
|
124
|
+
}
|
|
117
125
|
};
|
|
118
|
-
|
|
119
|
-
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/exception/http-exceptions/bad-request.exception.ts
|
|
120
128
|
var BadRequestException = class extends RequestException {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
129
|
+
constructor(message = "Bad Request", options) {
|
|
130
|
+
super(400, message, {
|
|
131
|
+
fatal: true,
|
|
132
|
+
...options
|
|
133
|
+
});
|
|
134
|
+
Object.defineProperty(this, "name", { value: "BadRequestException" });
|
|
135
|
+
}
|
|
125
136
|
};
|
|
126
|
-
|
|
127
|
-
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/exception/http-exceptions/unauthorized.exception.ts
|
|
128
139
|
var UnauthorizedException = class extends RequestException {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
140
|
+
constructor(message = "Unauthorized", options) {
|
|
141
|
+
super(401, message, {
|
|
142
|
+
fatal: true,
|
|
143
|
+
...options
|
|
144
|
+
});
|
|
145
|
+
Object.defineProperty(this, "name", { value: "UnauthorizedException" });
|
|
146
|
+
}
|
|
133
147
|
};
|
|
134
|
-
|
|
135
|
-
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/exception/http-exceptions/forbidden.exception.ts
|
|
136
150
|
var ForbiddenException = class extends RequestException {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
151
|
+
constructor(message = "Forbidden", options) {
|
|
152
|
+
super(403, message, {
|
|
153
|
+
fatal: true,
|
|
154
|
+
...options
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(this, "name", { value: "ForbiddenException" });
|
|
157
|
+
}
|
|
141
158
|
};
|
|
142
|
-
|
|
143
|
-
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/exception/http-exceptions/not-founded.exception.ts
|
|
144
161
|
var NotFoundedException = class extends RequestException {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
162
|
+
constructor(message = "Not Founded", options) {
|
|
163
|
+
super(404, message, {
|
|
164
|
+
fatal: true,
|
|
165
|
+
...options
|
|
166
|
+
});
|
|
167
|
+
Object.defineProperty(this, "name", { value: "NotFoundedException" });
|
|
168
|
+
}
|
|
149
169
|
};
|
|
150
|
-
|
|
151
|
-
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/exception/http-exceptions/method-not-allowed.exception.ts
|
|
152
172
|
var MethodNotAllowedException = class extends RequestException {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
173
|
+
constructor(message = "Method Not Allowed", options) {
|
|
174
|
+
super(405, message, {
|
|
175
|
+
fatal: true,
|
|
176
|
+
...options
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(this, "name", { value: "MethodNotAllowedException" });
|
|
179
|
+
}
|
|
159
180
|
};
|
|
160
|
-
|
|
161
|
-
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/exception/http-exceptions/not-acceptable.exception.ts
|
|
162
183
|
var NotAcceptableException = class extends RequestException {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
184
|
+
constructor(message = "Not Acceptable", options) {
|
|
185
|
+
super(406, message, {
|
|
186
|
+
fatal: true,
|
|
187
|
+
...options
|
|
188
|
+
});
|
|
189
|
+
Object.defineProperty(this, "name", { value: "NotAcceptableException" });
|
|
190
|
+
}
|
|
167
191
|
};
|
|
168
|
-
|
|
169
|
-
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/exception/http-exceptions/proxy-authentication-required.exception.ts
|
|
170
194
|
var ProxyAuthenticationRequiredException = class extends RequestException {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
195
|
+
constructor(message = "Proxy Authentication Required", options) {
|
|
196
|
+
super(407, message, {
|
|
197
|
+
fatal: true,
|
|
198
|
+
...options
|
|
199
|
+
});
|
|
200
|
+
Object.defineProperty(this, "name", { value: "ProxyAuthenticationRequiredException" });
|
|
201
|
+
}
|
|
177
202
|
};
|
|
178
|
-
|
|
179
|
-
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/exception/http-exceptions/request-timeout.exception.ts
|
|
180
205
|
var RequestTimeoutException = class extends RequestException {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
206
|
+
constructor(message = "Request Timeout", options) {
|
|
207
|
+
super(408, message, {
|
|
208
|
+
fatal: false,
|
|
209
|
+
...options
|
|
210
|
+
});
|
|
211
|
+
Object.defineProperty(this, "name", { value: "RequestTimeoutException" });
|
|
212
|
+
}
|
|
187
213
|
};
|
|
188
|
-
|
|
189
|
-
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/exception/http-exceptions/conflict.exception.ts
|
|
190
216
|
var ConflictException = class extends RequestException {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
217
|
+
constructor(message = "Conflict", options) {
|
|
218
|
+
super(409, message, {
|
|
219
|
+
fatal: true,
|
|
220
|
+
...options
|
|
221
|
+
});
|
|
222
|
+
Object.defineProperty(this, "name", { value: "ConflictException" });
|
|
223
|
+
}
|
|
195
224
|
};
|
|
196
|
-
|
|
197
|
-
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/exception/http-exceptions/precondition-failed.exception.ts
|
|
198
227
|
var PreconditionFailedException = class extends RequestException {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
228
|
+
constructor(message = "Precondition Failed", options) {
|
|
229
|
+
super(412, message, {
|
|
230
|
+
fatal: true,
|
|
231
|
+
...options
|
|
232
|
+
});
|
|
233
|
+
Object.defineProperty(this, "name", { value: "PreconditionFailedException" });
|
|
234
|
+
}
|
|
205
235
|
};
|
|
206
|
-
|
|
207
|
-
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/exception/http-exceptions/content-too-large.exception.ts
|
|
208
238
|
var ContentTooLargeException = class extends RequestException {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
239
|
+
constructor(message = "Content Too Large", options) {
|
|
240
|
+
super(413, message, {
|
|
241
|
+
fatal: true,
|
|
242
|
+
...options
|
|
243
|
+
});
|
|
244
|
+
Object.defineProperty(this, "name", { value: "ContentTooLargeException" });
|
|
245
|
+
}
|
|
215
246
|
};
|
|
216
|
-
|
|
217
|
-
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/exception/http-exceptions/uri-too-long.exception.ts
|
|
218
249
|
var UriTooLongException = class extends RequestException {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
250
|
+
constructor(message = "URI Too Long", options) {
|
|
251
|
+
super(414, message, {
|
|
252
|
+
fatal: true,
|
|
253
|
+
...options
|
|
254
|
+
});
|
|
255
|
+
Object.defineProperty(this, "name", { value: "UriTooLongException" });
|
|
256
|
+
}
|
|
223
257
|
};
|
|
224
|
-
|
|
225
|
-
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/exception/http-exceptions/unsupported-media-type.exception.ts
|
|
226
260
|
var UnsupportedMediaTypeException = class extends RequestException {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
261
|
+
constructor(message = "Unsupported Media Type", options) {
|
|
262
|
+
super(415, message, {
|
|
263
|
+
fatal: true,
|
|
264
|
+
...options
|
|
265
|
+
});
|
|
266
|
+
Object.defineProperty(this, "name", { value: "UnsupportedMediaTypeException" });
|
|
267
|
+
}
|
|
231
268
|
};
|
|
232
|
-
|
|
233
|
-
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/exception/http-exceptions/im-a-teapot.exception.ts
|
|
234
271
|
var ImATeapotException = class extends RequestException {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
272
|
+
constructor(message = "I'm a teapot", options) {
|
|
273
|
+
super(418, message, {
|
|
274
|
+
fatal: true,
|
|
275
|
+
...options
|
|
276
|
+
});
|
|
277
|
+
Object.defineProperty(this, "name", { value: "ImATeapotException" });
|
|
278
|
+
}
|
|
239
279
|
};
|
|
240
|
-
|
|
241
|
-
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/exception/http-exceptions/too-many-requests.exception.ts
|
|
242
282
|
var TooManyRequestsException = class extends RequestException {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
283
|
+
constructor(message = "Too Many Requests", options) {
|
|
284
|
+
super(429, message, {
|
|
285
|
+
fatal: false,
|
|
286
|
+
...options
|
|
287
|
+
});
|
|
288
|
+
Object.defineProperty(this, "name", { value: "TooManyRequestsException" });
|
|
289
|
+
}
|
|
247
290
|
};
|
|
248
|
-
|
|
249
|
-
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/exception/http-exceptions/internal-server-error.exception.ts
|
|
250
293
|
var InternalServerErrorException = class extends RequestException {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
294
|
+
constructor(message = "Internal Server Error", options) {
|
|
295
|
+
super(500, message, {
|
|
296
|
+
fatal: false,
|
|
297
|
+
...options
|
|
298
|
+
});
|
|
299
|
+
Object.defineProperty(this, "name", { value: "InternalServerErrorException" });
|
|
300
|
+
}
|
|
257
301
|
};
|
|
258
|
-
|
|
259
|
-
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/exception/http-exceptions/not-implemented.exception.ts
|
|
260
304
|
var NotImplementedException = class extends RequestException {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
305
|
+
constructor(message = "Not Implemented", options) {
|
|
306
|
+
super(501, message, {
|
|
307
|
+
fatal: true,
|
|
308
|
+
...options
|
|
309
|
+
});
|
|
310
|
+
Object.defineProperty(this, "name", { value: "NotImplementedException" });
|
|
311
|
+
}
|
|
265
312
|
};
|
|
266
|
-
|
|
267
|
-
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/exception/http-exceptions/bad-gateway.exception.ts
|
|
268
315
|
var BadGatewayException = class extends RequestException {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
316
|
+
constructor(message = "Bad Gateway", options) {
|
|
317
|
+
super(502, message, {
|
|
318
|
+
fatal: false,
|
|
319
|
+
...options
|
|
320
|
+
});
|
|
321
|
+
Object.defineProperty(this, "name", { value: "BadGatewayException" });
|
|
322
|
+
}
|
|
273
323
|
};
|
|
274
|
-
|
|
275
|
-
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region src/exception/http-exceptions/service-unavailable.exception.ts
|
|
276
326
|
var ServiceUnavailableException = class extends RequestException {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
327
|
+
constructor(message = "Service Unavailable", options) {
|
|
328
|
+
super(503, message, {
|
|
329
|
+
fatal: false,
|
|
330
|
+
...options
|
|
331
|
+
});
|
|
332
|
+
Object.defineProperty(this, "name", { value: "ServiceUnavailableException" });
|
|
333
|
+
}
|
|
283
334
|
};
|
|
284
|
-
|
|
285
|
-
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/exception/http-exceptions/gateway-timeout.exception.ts
|
|
286
337
|
var GatewayTimeoutException = class extends RequestException {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
338
|
+
constructor(message = "Gateway Timeout", options) {
|
|
339
|
+
super(504, message, {
|
|
340
|
+
fatal: false,
|
|
341
|
+
...options
|
|
342
|
+
});
|
|
343
|
+
Object.defineProperty(this, "name", { value: "GatewayTimeoutException" });
|
|
344
|
+
}
|
|
291
345
|
};
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
-
|
|
338
|
-
|
|
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
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/utils/base64.ts
|
|
348
|
+
const base64Encode = globalThis.btoa || ((str) => Buffer.from(str).toString("base64"));
|
|
349
|
+
globalThis.atob;
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region src/validator/validator.ts
|
|
352
|
+
/**
|
|
353
|
+
* Validator 类用于类型检查
|
|
354
|
+
*/
|
|
355
|
+
var Validator = class Validator {
|
|
356
|
+
/**
|
|
357
|
+
* 检查是否为浏览器环境
|
|
358
|
+
*/
|
|
359
|
+
static isBrowser() {
|
|
360
|
+
return typeof window !== "undefined";
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* 检查是否为字符串
|
|
364
|
+
*/
|
|
365
|
+
static isString(value) {
|
|
366
|
+
return typeof value === "string";
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* 检查是否为对象
|
|
370
|
+
*/
|
|
371
|
+
static isObject(value) {
|
|
372
|
+
return typeof value === "object" && value !== null;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* 检查是否为函数
|
|
376
|
+
*/
|
|
377
|
+
static isFunction(value) {
|
|
378
|
+
return typeof value === "function";
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* 检查是否为 ArrayBuffer
|
|
382
|
+
*/
|
|
383
|
+
static isArrayBuffer(body) {
|
|
384
|
+
return body instanceof ArrayBuffer;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* 检查是否为 ReadableStream
|
|
388
|
+
*/
|
|
389
|
+
static isReadableStream(body) {
|
|
390
|
+
return body instanceof ReadableStream;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* 检查是否为 Blob 或 File 类对象
|
|
394
|
+
*/
|
|
395
|
+
static isBlob(value) {
|
|
396
|
+
if (value instanceof Blob) return true;
|
|
397
|
+
return Validator.isObject(value) && Validator.isString(value["type"]) && Validator.isFunction(value["arrayBuffer"]) && Validator.isFunction(value["stream"]) && Validator.isFunction(value.constructor) && ["Blob", "File"].includes(value.constructor.name) && "size" in value;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* 检查是否为 File
|
|
401
|
+
*/
|
|
402
|
+
static isFile(object) {
|
|
403
|
+
if (Validator.isBrowser()) return object instanceof Blob;
|
|
404
|
+
return Validator.isBlob(object);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* 检查是否为 Buffer
|
|
408
|
+
*/
|
|
409
|
+
static isBuffer(obj) {
|
|
410
|
+
return Validator.isBrowser() ? false : Buffer.isBuffer(obj);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* 检查是否为 FormData
|
|
414
|
+
*/
|
|
415
|
+
static isFormData(object) {
|
|
416
|
+
if (object instanceof FormData) return true;
|
|
417
|
+
return Validator.isObject(object) && Validator.isFunction(object["append"]) && Validator.isFunction(object["delete"]) && Validator.isFunction(object["get"]) && Validator.isFunction(object["getAll"]) && Validator.isFunction(object["has"]) && Validator.isFunction(object["set"]) && Validator.isFunction(object["entries"]) && Validator.isFunction(object["keys"]) && Validator.isFunction(object["values"]);
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* 检查是否为 Headers
|
|
421
|
+
*/
|
|
422
|
+
static isHeaders(obj) {
|
|
423
|
+
if (obj instanceof Headers) return true;
|
|
424
|
+
if (Validator.isObject(obj) && Validator.isFunction(obj["forEach"]) && Validator.isFunction(obj["get"]) && Validator.isFunction(obj["has"]) && Validator.isFunction(obj["set"]) && Validator.isFunction(obj["append"]) && Validator.isFunction(obj["delete"]) && Validator.isFunction(obj["entries"]) && Validator.isFunction(obj["keys"]) && Validator.isFunction(obj["values"])) return true;
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* 检查是否为 URLSearchParams
|
|
429
|
+
*/
|
|
430
|
+
static isUrlSearchParams(obj) {
|
|
431
|
+
if (obj instanceof URLSearchParams) return true;
|
|
432
|
+
return Validator.isObject(obj) && Validator.isFunction(obj["append"]) && Validator.isFunction(obj["delete"]) && Validator.isFunction(obj["entries"]) && Validator.isFunction(obj["forEach"]) && Validator.isFunction(obj["get"]) && Validator.isFunction(obj["getAll"]) && Validator.isFunction(obj["has"]) && Validator.isFunction(obj["keys"]) && Validator.isFunction(obj["set"]) && Validator.isFunction(obj["values"]) && Validator.isFunction(obj["sort"]) && Validator.isFunction(obj["toString"]);
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* 检查是否为合法的 Header 值
|
|
436
|
+
* 允许范围: HTAB(\t), 0x20-0x7E, 0x80-0xFF
|
|
437
|
+
* 禁止换行等控制字符
|
|
438
|
+
*/
|
|
439
|
+
static isHeaderValue(str) {
|
|
440
|
+
return /^[\t\x20-\x7E\x80-\xFF]*$/.test(String(str));
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* 检查是否为 BodyInit 类型
|
|
444
|
+
* BodyInit 包括: Blob | ArrayBuffer | TypedArray | DataView | FormData | URLSearchParams | ReadableStream | string
|
|
445
|
+
*/
|
|
446
|
+
static isBodyInit(value) {
|
|
447
|
+
if (value === null || value === void 0) return false;
|
|
448
|
+
return Validator.isString(value) || Validator.isBlob(value) || Validator.isArrayBuffer(value) || Validator.isFormData(value) || Validator.isUrlSearchParams(value) || Validator.isReadableStream(value) || Validator.isBuffer(value) || ArrayBuffer.isView(value);
|
|
449
|
+
}
|
|
397
450
|
};
|
|
398
|
-
|
|
399
|
-
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/utils/shallow-clone.ts
|
|
453
|
+
/**
|
|
454
|
+
* @description 浅拷贝
|
|
455
|
+
*/
|
|
400
456
|
function shallowClone(obj) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
if (Validator.isObject(obj)) {
|
|
405
|
-
return { ...obj };
|
|
406
|
-
}
|
|
407
|
-
return obj;
|
|
457
|
+
if (Array.isArray(obj)) return [...obj];
|
|
458
|
+
if (Validator.isObject(obj)) return { ...obj };
|
|
459
|
+
return obj;
|
|
408
460
|
}
|
|
409
|
-
|
|
410
|
-
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/utils/sleep.ts
|
|
411
463
|
function sleep(ms) {
|
|
412
|
-
|
|
464
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
413
465
|
}
|
|
414
|
-
|
|
415
|
-
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region src/request-init/utils/clone-body.ts
|
|
416
468
|
function cloneBody(obj) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
return obj;
|
|
439
|
-
}
|
|
440
|
-
if (obj === null) {
|
|
441
|
-
return null;
|
|
442
|
-
}
|
|
443
|
-
if (Array.isArray(obj)) {
|
|
444
|
-
return obj.map(cloneBody);
|
|
445
|
-
}
|
|
446
|
-
if (Validator.isObject(obj)) {
|
|
447
|
-
const cloned = {};
|
|
448
|
-
for (const key in obj) {
|
|
449
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
450
|
-
cloned[key] = cloneBody(obj[key]);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
return cloned;
|
|
454
|
-
}
|
|
455
|
-
return obj;
|
|
469
|
+
if (Validator.isFormData(obj)) {
|
|
470
|
+
const formData = new FormData();
|
|
471
|
+
for (const [key, value] of obj.entries()) formData.append(key, value);
|
|
472
|
+
return formData;
|
|
473
|
+
}
|
|
474
|
+
if (Validator.isUrlSearchParams(obj)) {
|
|
475
|
+
const urlSearchParams = new URLSearchParams();
|
|
476
|
+
for (const [key, value] of obj.entries()) urlSearchParams.append(key, value);
|
|
477
|
+
return urlSearchParams;
|
|
478
|
+
}
|
|
479
|
+
if (Validator.isFile(obj)) return obj;
|
|
480
|
+
if (Validator.isBlob(obj)) return obj;
|
|
481
|
+
if (Validator.isBuffer(obj)) return obj;
|
|
482
|
+
if (obj === null) return null;
|
|
483
|
+
if (Array.isArray(obj)) return obj.map(cloneBody);
|
|
484
|
+
if (Validator.isObject(obj)) {
|
|
485
|
+
const cloned = {};
|
|
486
|
+
for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) cloned[key] = cloneBody(obj[key]);
|
|
487
|
+
return cloned;
|
|
488
|
+
}
|
|
489
|
+
return obj;
|
|
456
490
|
}
|
|
457
|
-
|
|
458
|
-
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region src/request-init/utils/clone-headers.ts
|
|
459
493
|
function cloneHeaders(headers) {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
return cloned;
|
|
494
|
+
const cloned = new Headers();
|
|
495
|
+
for (const [key, value] of headers.entries()) cloned.append(key, value);
|
|
496
|
+
return cloned;
|
|
465
497
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
var import_uri_template = require("@opendoc/uri-template");
|
|
498
|
+
//#endregion
|
|
499
|
+
//#region src/request-init/utils/compile-url.ts
|
|
469
500
|
function compileUrl(obj, pathParameters) {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
pathParameters
|
|
474
|
-
).expand();
|
|
475
|
-
return url;
|
|
501
|
+
const url = new URL(typeof obj === "string" ? obj : obj.href);
|
|
502
|
+
url.pathname = new _opendoc_uri_template.UriTemplateParser(decodeURIComponent(url.pathname), pathParameters).expand();
|
|
503
|
+
return url;
|
|
476
504
|
}
|
|
477
|
-
|
|
478
|
-
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/request-init/utils/to-form-data.ts
|
|
479
507
|
function toFormData(body) {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
form.append(key, v);
|
|
485
|
-
}
|
|
486
|
-
} else {
|
|
487
|
-
form.append(key, value);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
return form;
|
|
508
|
+
const form = new FormData();
|
|
509
|
+
for (const [key, value] of Object.entries(body)) if (Array.isArray(value)) for (const v of value) form.append(key, v);
|
|
510
|
+
else form.append(key, value);
|
|
511
|
+
return form;
|
|
491
512
|
}
|
|
492
|
-
|
|
493
|
-
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region src/request-init/utils/to-url-search-params.ts
|
|
494
515
|
function toUrlSearchParams(body) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
} else {
|
|
502
|
-
params.append(key, value);
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
return params;
|
|
516
|
+
const params = new URLSearchParams();
|
|
517
|
+
Object.entries(body).map(([key, value]) => {
|
|
518
|
+
if (Array.isArray(value)) for (const v of value) params.append(key, v);
|
|
519
|
+
else params.append(key, value);
|
|
520
|
+
});
|
|
521
|
+
return params;
|
|
506
522
|
}
|
|
507
|
-
|
|
508
|
-
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/request-init/utils/clone-request-init.ts
|
|
509
525
|
function cloneRequestInit(init) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
526
|
+
return new KeqRequestInit({
|
|
527
|
+
url: init.url,
|
|
528
|
+
pathParameters: init.pathParameters,
|
|
529
|
+
method: init.method,
|
|
530
|
+
headers: init.headers,
|
|
531
|
+
body: init.body,
|
|
532
|
+
cache: init.cache,
|
|
533
|
+
credentials: init.credentials,
|
|
534
|
+
integrity: init.integrity,
|
|
535
|
+
keepalive: init.keepalive,
|
|
536
|
+
mode: init.mode,
|
|
537
|
+
redirect: init.redirect,
|
|
538
|
+
referrer: init.referrer,
|
|
539
|
+
referrerPolicy: init.referrerPolicy
|
|
540
|
+
});
|
|
525
541
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
var _a;
|
|
530
|
-
_a = AbortControllerProperty;
|
|
542
|
+
//#endregion
|
|
543
|
+
//#region src/request-init/request-init.ts
|
|
544
|
+
const AbortControllerProperty = "__KeqProtectedProperty(context.request.abortController)__";
|
|
531
545
|
var KeqRequestInit = class {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
cache: this.cache,
|
|
618
|
-
credentials: this.credentials,
|
|
619
|
-
integrity: this.integrity,
|
|
620
|
-
keepalive: this.keepalive,
|
|
621
|
-
mode: this.mode,
|
|
622
|
-
redirect: this.redirect,
|
|
623
|
-
referrer: this.referrer,
|
|
624
|
-
referrerPolicy: this.referrerPolicy,
|
|
625
|
-
signal: this.signal
|
|
626
|
-
};
|
|
627
|
-
return [this.__url__.href, requestInit];
|
|
628
|
-
}
|
|
546
|
+
constructor(options) {
|
|
547
|
+
_defineProperty(this, "url", void 0);
|
|
548
|
+
_defineProperty(this, "pathParameters", void 0);
|
|
549
|
+
_defineProperty(this, "method", void 0);
|
|
550
|
+
_defineProperty(this, "headers", void 0);
|
|
551
|
+
_defineProperty(this, "body", void 0);
|
|
552
|
+
_defineProperty(this, "cache", void 0);
|
|
553
|
+
_defineProperty(this, "credentials", void 0);
|
|
554
|
+
_defineProperty(this, "integrity", void 0);
|
|
555
|
+
_defineProperty(this, "keepalive", void 0);
|
|
556
|
+
_defineProperty(this, "mode", void 0);
|
|
557
|
+
_defineProperty(this, "redirect", void 0);
|
|
558
|
+
_defineProperty(this, "referrer", void 0);
|
|
559
|
+
_defineProperty(this, "referrerPolicy", void 0);
|
|
560
|
+
_defineProperty(this, AbortControllerProperty, new AbortController());
|
|
561
|
+
this.url = new URL(options.url.href);
|
|
562
|
+
this.pathParameters = shallowClone(options.pathParameters);
|
|
563
|
+
this.method = options.method;
|
|
564
|
+
this.headers = cloneHeaders(options.headers);
|
|
565
|
+
this.body = cloneBody(options.body);
|
|
566
|
+
this.cache = options.cache;
|
|
567
|
+
this.credentials = options.credentials;
|
|
568
|
+
this.integrity = options.integrity;
|
|
569
|
+
this.keepalive = options.keepalive;
|
|
570
|
+
this.mode = options.mode;
|
|
571
|
+
this.redirect = options.redirect;
|
|
572
|
+
this.referrer = options.referrer;
|
|
573
|
+
this.referrerPolicy = options.referrerPolicy;
|
|
574
|
+
}
|
|
575
|
+
get __url__() {
|
|
576
|
+
return compileUrl(this.url, this.pathParameters);
|
|
577
|
+
}
|
|
578
|
+
get signal() {
|
|
579
|
+
return this[AbortControllerProperty].signal;
|
|
580
|
+
}
|
|
581
|
+
abort(reason) {
|
|
582
|
+
if (!this["__KeqProtectedProperty(context.request.abortController)__"].signal.aborted) this[AbortControllerProperty].abort(reason);
|
|
583
|
+
}
|
|
584
|
+
getContentType() {
|
|
585
|
+
const contentType = this.headers.get("Content-Type");
|
|
586
|
+
if (contentType) return contentType;
|
|
587
|
+
if (!this.body) return void 0;
|
|
588
|
+
if (Validator.isFormData(this.body)) return "multipart/form-data";
|
|
589
|
+
if (Validator.isUrlSearchParams(this.body)) return "application/x-www-form-urlencoded";
|
|
590
|
+
if (Validator.isArrayBuffer(this.body)) return "application/octet-stream";
|
|
591
|
+
if (typeof this.body === "object") return "application/json";
|
|
592
|
+
}
|
|
593
|
+
toFetchBody(contentType) {
|
|
594
|
+
const body = this.body;
|
|
595
|
+
if (body === void 0) return;
|
|
596
|
+
if (body === null) return null;
|
|
597
|
+
if (Validator.isBodyInit(body)) return body;
|
|
598
|
+
if (!contentType || contentType === "application/json") return JSON.stringify(body);
|
|
599
|
+
if (contentType === "application/x-www-form-urlencoded") {
|
|
600
|
+
if (Array.isArray(body)) throw new Exception("request.body is an array, that cannot be serialized as application/x-www-form-urlencoded format");
|
|
601
|
+
return toUrlSearchParams(body);
|
|
602
|
+
}
|
|
603
|
+
if (contentType === "multipart/form-data") {
|
|
604
|
+
if (Array.isArray(body)) throw new Exception("FormData cannot send array");
|
|
605
|
+
return toFormData(body);
|
|
606
|
+
}
|
|
607
|
+
throw new Exception(`Cannot auto serialize request.body with Content-Type: ${contentType}`);
|
|
608
|
+
}
|
|
609
|
+
toFetchArguments() {
|
|
610
|
+
const contentType = this.getContentType();
|
|
611
|
+
const headers = cloneHeaders(this.headers);
|
|
612
|
+
if (contentType) headers.set("Content-Type", contentType);
|
|
613
|
+
const body = this.toFetchBody(contentType);
|
|
614
|
+
if (contentType === "multipart/form-data") headers.delete("Content-Type");
|
|
615
|
+
const requestInit = {
|
|
616
|
+
method: this.method.toUpperCase(),
|
|
617
|
+
headers,
|
|
618
|
+
body,
|
|
619
|
+
cache: this.cache,
|
|
620
|
+
credentials: this.credentials,
|
|
621
|
+
integrity: this.integrity,
|
|
622
|
+
keepalive: this.keepalive,
|
|
623
|
+
mode: this.mode,
|
|
624
|
+
redirect: this.redirect,
|
|
625
|
+
referrer: this.referrer,
|
|
626
|
+
referrerPolicy: this.referrerPolicy,
|
|
627
|
+
signal: this.signal
|
|
628
|
+
};
|
|
629
|
+
return [this.__url__.href, requestInit];
|
|
630
|
+
}
|
|
629
631
|
};
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
var _a2, _b;
|
|
635
|
-
_b = OrchestratorProperty, _a2 = ExecutorProperty;
|
|
632
|
+
//#endregion
|
|
633
|
+
//#region src/context/orchestrator-context.ts
|
|
634
|
+
const OrchestratorProperty = "__KeyProtectedProperty(context.orchestration.orchestrator)__";
|
|
635
|
+
const ExecutorProperty$1 = "__KeyProtectedProperty(context.orchestration.executor)__";
|
|
636
636
|
var KeqOrchestratorContext = class {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
}
|
|
659
|
-
fork() {
|
|
660
|
-
return this[OrchestratorProperty].fork();
|
|
661
|
-
}
|
|
662
|
-
merge(source) {
|
|
663
|
-
this[OrchestratorProperty].merge(source);
|
|
664
|
-
}
|
|
637
|
+
constructor(orchestrator, executor) {
|
|
638
|
+
_defineProperty(this, OrchestratorProperty, void 0);
|
|
639
|
+
_defineProperty(this, ExecutorProperty$1, void 0);
|
|
640
|
+
this[OrchestratorProperty] = orchestrator;
|
|
641
|
+
this[ExecutorProperty$1] = executor;
|
|
642
|
+
}
|
|
643
|
+
get middlewares() {
|
|
644
|
+
return this[OrchestratorProperty].executors.map((exe) => exe.context);
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* The middleware context of the current middleware
|
|
648
|
+
*/
|
|
649
|
+
get middleware() {
|
|
650
|
+
return this[ExecutorProperty$1].context;
|
|
651
|
+
}
|
|
652
|
+
fork() {
|
|
653
|
+
return this[OrchestratorProperty].fork();
|
|
654
|
+
}
|
|
655
|
+
merge(source) {
|
|
656
|
+
this[OrchestratorProperty].merge(source);
|
|
657
|
+
}
|
|
665
658
|
};
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
var _a3, _b2;
|
|
671
|
-
_b2 = ContextOrchestratorProperty, _a3 = ContextOrchestrationProperty;
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/context/execution-context.ts
|
|
661
|
+
const ContextOrchestratorProperty = "__KeyProtectedProperty(context.orchestrator)__";
|
|
662
|
+
const ContextOrchestrationProperty = "__KeyProtectedProperty(context.orchestration)__";
|
|
672
663
|
var KeqExecutionContext = class {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
get response() {
|
|
717
|
-
return this[ContextOrchestratorProperty].context.response;
|
|
718
|
-
}
|
|
719
|
-
// The properties extends by middleware
|
|
720
|
-
get data() {
|
|
721
|
-
return this[ContextOrchestratorProperty].context.data;
|
|
722
|
-
}
|
|
664
|
+
constructor(orchestrator, executor) {
|
|
665
|
+
_defineProperty(this, ContextOrchestratorProperty, void 0);
|
|
666
|
+
_defineProperty(this, ContextOrchestrationProperty, void 0);
|
|
667
|
+
this[ContextOrchestratorProperty] = orchestrator;
|
|
668
|
+
this[ContextOrchestrationProperty] = new KeqOrchestratorContext(orchestrator, executor);
|
|
669
|
+
}
|
|
670
|
+
get orchestration() {
|
|
671
|
+
return this[ContextOrchestrationProperty];
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* The unique identifier of the request's location in the code
|
|
675
|
+
*/
|
|
676
|
+
get locationId() {
|
|
677
|
+
return this[ContextOrchestratorProperty].context.locationId;
|
|
678
|
+
}
|
|
679
|
+
get request() {
|
|
680
|
+
return this[ContextOrchestratorProperty].context.request;
|
|
681
|
+
}
|
|
682
|
+
get global() {
|
|
683
|
+
return this[ContextOrchestratorProperty].context.global;
|
|
684
|
+
}
|
|
685
|
+
get emitter() {
|
|
686
|
+
return this[ContextOrchestratorProperty].context.emitter;
|
|
687
|
+
}
|
|
688
|
+
get options() {
|
|
689
|
+
return this[ContextOrchestratorProperty].context.options;
|
|
690
|
+
}
|
|
691
|
+
set output(value) {
|
|
692
|
+
if (this.options.resolveWith && this.options.resolveWith !== "intelligent") console.warn(`The request is configured to resolve with ${this.options.resolveWith}, so setting context.output maybe no effect.`);
|
|
693
|
+
this[ContextOrchestratorProperty].context.output = value;
|
|
694
|
+
}
|
|
695
|
+
get res() {
|
|
696
|
+
return this[ContextOrchestratorProperty].context.res;
|
|
697
|
+
}
|
|
698
|
+
set res(value) {
|
|
699
|
+
this[ContextOrchestratorProperty].context.res = value;
|
|
700
|
+
}
|
|
701
|
+
get response() {
|
|
702
|
+
return this[ContextOrchestratorProperty].context.response;
|
|
703
|
+
}
|
|
704
|
+
get data() {
|
|
705
|
+
return this[ContextOrchestratorProperty].context.data;
|
|
706
|
+
}
|
|
723
707
|
};
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
var import_mitt = __toESM(require("mitt"));
|
|
727
|
-
|
|
728
|
-
// src/context/utils/watch-object.ts
|
|
708
|
+
//#endregion
|
|
709
|
+
//#region src/context/utils/watch-object.ts
|
|
729
710
|
function watchObject(obj, listeners) {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
}
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
return target[prop];
|
|
742
|
-
}
|
|
743
|
-
});
|
|
711
|
+
return new Proxy(obj, { get(target, prop) {
|
|
712
|
+
if (prop in listeners) return new Proxy(target[prop], { apply(target, thisArg, argArray) {
|
|
713
|
+
const listener = listeners[prop];
|
|
714
|
+
listener(target, thisArg, argArray);
|
|
715
|
+
return target.apply(thisArg, argArray);
|
|
716
|
+
} });
|
|
717
|
+
return target[prop];
|
|
718
|
+
} });
|
|
744
719
|
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
var import_klona = require("klona");
|
|
720
|
+
//#endregion
|
|
721
|
+
//#region src/context/utils/clone-shared-context.ts
|
|
748
722
|
function cloneSharedContext(context) {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
});
|
|
761
|
-
return cloned;
|
|
723
|
+
const cloned = new KeqSharedContext({
|
|
724
|
+
locationId: context[ContextLocationIdProperty],
|
|
725
|
+
request: cloneRequestInit(context[ContextRequestProperty]),
|
|
726
|
+
global: context[ContextGlobalProperty],
|
|
727
|
+
options: (0, klona.klona)(context[ContextOptionsProperty]),
|
|
728
|
+
data: (0, klona.klona)(context[ContextDataProperty])
|
|
729
|
+
});
|
|
730
|
+
context[ContextEmitterProperty].all.forEach((handlers, type) => {
|
|
731
|
+
for (const handler of handlers) cloned.emitter.on(type, handler);
|
|
732
|
+
});
|
|
733
|
+
return cloned;
|
|
762
734
|
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
"copyWithin"
|
|
735
|
+
//#endregion
|
|
736
|
+
//#region src/context/utils/fork.ts
|
|
737
|
+
const ForkedObjectBrandPropertyKey = "__KeqProtectedProperty(forked.object.brand)__";
|
|
738
|
+
const ARRAY_MUTATORS = new Set([
|
|
739
|
+
"push",
|
|
740
|
+
"pop",
|
|
741
|
+
"shift",
|
|
742
|
+
"unshift",
|
|
743
|
+
"splice",
|
|
744
|
+
"sort",
|
|
745
|
+
"reverse",
|
|
746
|
+
"fill",
|
|
747
|
+
"copyWithin"
|
|
777
748
|
]);
|
|
778
749
|
function objectPath(obj, path) {
|
|
779
|
-
|
|
750
|
+
return path.reduce((o, k) => o[k], obj);
|
|
780
751
|
}
|
|
752
|
+
/**
|
|
753
|
+
* Fork an json object, using copy-on-write strategy to avoid unnecessary deep cloning.
|
|
754
|
+
*/
|
|
781
755
|
function fork(original) {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
},
|
|
826
|
-
ownKeys(target) {
|
|
827
|
-
const realTarget = getTarget();
|
|
828
|
-
return Reflect.ownKeys(realTarget);
|
|
829
|
-
},
|
|
830
|
-
getOwnPropertyDescriptor(target, prop) {
|
|
831
|
-
const realTarget = getTarget();
|
|
832
|
-
return Reflect.getOwnPropertyDescriptor(realTarget, prop);
|
|
833
|
-
}
|
|
834
|
-
});
|
|
835
|
-
};
|
|
836
|
-
return createProxy();
|
|
756
|
+
if (original === null || typeof original !== "object") return original;
|
|
757
|
+
let current = original;
|
|
758
|
+
const ensureCopy = () => {
|
|
759
|
+
if (current === original) current = (0, klona_json.klona)(original);
|
|
760
|
+
return current;
|
|
761
|
+
};
|
|
762
|
+
const createProxy = (path = []) => {
|
|
763
|
+
const getTarget = () => objectPath(current, path);
|
|
764
|
+
return new Proxy(getTarget(), {
|
|
765
|
+
get(target, prop) {
|
|
766
|
+
const realTarget = getTarget();
|
|
767
|
+
if (prop === ForkedObjectBrandPropertyKey) return realTarget;
|
|
768
|
+
const value = realTarget[prop];
|
|
769
|
+
if (current !== original) return value;
|
|
770
|
+
if (Array.isArray(realTarget) && ARRAY_MUTATORS.has(prop)) return new Proxy(value, { apply(fn, thisArg, args) {
|
|
771
|
+
ensureCopy();
|
|
772
|
+
const t = objectPath(current, path);
|
|
773
|
+
return Reflect.apply(t[prop], t, args);
|
|
774
|
+
} });
|
|
775
|
+
if (typeof value === "object" && value !== null) return createProxy([...path, prop]);
|
|
776
|
+
return value;
|
|
777
|
+
},
|
|
778
|
+
set(target, prop, value) {
|
|
779
|
+
ensureCopy();
|
|
780
|
+
objectPath(current, path)[prop] = value;
|
|
781
|
+
return true;
|
|
782
|
+
},
|
|
783
|
+
deleteProperty(target, prop) {
|
|
784
|
+
ensureCopy();
|
|
785
|
+
delete objectPath(current, path)[prop];
|
|
786
|
+
return true;
|
|
787
|
+
},
|
|
788
|
+
ownKeys(target) {
|
|
789
|
+
const realTarget = getTarget();
|
|
790
|
+
return Reflect.ownKeys(realTarget);
|
|
791
|
+
},
|
|
792
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
793
|
+
const realTarget = getTarget();
|
|
794
|
+
return Reflect.getOwnPropertyDescriptor(realTarget, prop);
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
};
|
|
798
|
+
return createProxy();
|
|
837
799
|
}
|
|
838
800
|
function unwrap(proxy) {
|
|
839
|
-
|
|
801
|
+
return proxy && proxy[ForkedObjectBrandPropertyKey] ? proxy[ForkedObjectBrandPropertyKey] : proxy;
|
|
840
802
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
803
|
+
//#endregion
|
|
804
|
+
//#region src/context/utils/create-proxy-response.ts
|
|
805
|
+
const JsonCachePropertyKey = "__KeqProtectedProperty(response.proxy.cache.json)__";
|
|
806
|
+
const TextCachePropertyKey = "__KeqProtectedProperty(response.proxy.cache.text)__";
|
|
845
807
|
function createProxyResponse(response) {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
const mirror = res.clone();
|
|
881
|
-
return mirror.body;
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
if (typeof res[prop] === "function") {
|
|
885
|
-
return res[prop].bind(res);
|
|
886
|
-
}
|
|
887
|
-
return res[prop];
|
|
888
|
-
}
|
|
889
|
-
});
|
|
808
|
+
return new Proxy(response, { get(res, prop) {
|
|
809
|
+
if (typeof prop === "string") {
|
|
810
|
+
if (prop === "json") return new Proxy(res[prop], { apply() {
|
|
811
|
+
if (res[JsonCachePropertyKey]) return fork(res[JsonCachePropertyKey]);
|
|
812
|
+
return res.clone().json().then((body) => {
|
|
813
|
+
res[JsonCachePropertyKey] = body;
|
|
814
|
+
return fork(body);
|
|
815
|
+
});
|
|
816
|
+
} });
|
|
817
|
+
else if (prop === "text") return new Proxy(res[prop], { apply() {
|
|
818
|
+
if (res[TextCachePropertyKey]) return fork(res[TextCachePropertyKey]);
|
|
819
|
+
return res.clone().text().then((body) => {
|
|
820
|
+
res[TextCachePropertyKey] = body;
|
|
821
|
+
return body;
|
|
822
|
+
});
|
|
823
|
+
} });
|
|
824
|
+
else if ([
|
|
825
|
+
"arrayBuffer",
|
|
826
|
+
"blob",
|
|
827
|
+
"buffer",
|
|
828
|
+
"formData"
|
|
829
|
+
].includes(prop))
|
|
830
|
+
/**
|
|
831
|
+
* clone when invoking body, json, text, arrayBuffer, blob, buffer, formData
|
|
832
|
+
* to avoid time-consuming cloning
|
|
833
|
+
*/
|
|
834
|
+
return new Proxy(res[prop], { apply(target, thisArg, argArray) {
|
|
835
|
+
return res.clone()[prop](...argArray);
|
|
836
|
+
} });
|
|
837
|
+
else if (prop === "body") return res.clone().body;
|
|
838
|
+
}
|
|
839
|
+
if (typeof res[prop] === "function") return res[prop].bind(res);
|
|
840
|
+
return res[prop];
|
|
841
|
+
} });
|
|
890
842
|
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
var _a4, _b3, _c, _d, _e, _f, _g;
|
|
901
|
-
_g = ContextLocationIdProperty, _f = ContextRequestProperty, _e = ContextGlobalProperty, _d = ContextEmitterProperty, _c = ContextOptionsProperty, _b3 = ContextOutputProperty, _a4 = ContextDataProperty;
|
|
843
|
+
//#endregion
|
|
844
|
+
//#region src/context/shared-context.ts
|
|
845
|
+
const ContextLocationIdProperty = "__KeqProtectedProperty(context.locationId)__";
|
|
846
|
+
const ContextRequestProperty = "__KeqProtectedProperty(context.request)__";
|
|
847
|
+
const ContextGlobalProperty = "__KeqProtectedProperty(context.global)__";
|
|
848
|
+
const ContextEmitterProperty = "__KeqProtectedProperty(context.emitter)__";
|
|
849
|
+
const ContextOptionsProperty = "__KeqProtectedProperty(context.options)__";
|
|
850
|
+
const ContextDataProperty = "__KeqProtectedProperty(context.data)__";
|
|
851
|
+
const ContextOutputProperty = "__KeqProtectedProperty(context.output)__";
|
|
902
852
|
var KeqSharedContext = class {
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
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
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
853
|
+
constructor(options) {
|
|
854
|
+
_defineProperty(this, ContextLocationIdProperty, void 0);
|
|
855
|
+
_defineProperty(this, ContextRequestProperty, void 0);
|
|
856
|
+
_defineProperty(this, ContextGlobalProperty, void 0);
|
|
857
|
+
_defineProperty(this, ContextEmitterProperty, void 0);
|
|
858
|
+
_defineProperty(this, ContextOptionsProperty, void 0);
|
|
859
|
+
_defineProperty(this, ContextOutputProperty, void 0);
|
|
860
|
+
_defineProperty(this, ContextDataProperty, {});
|
|
861
|
+
_defineProperty(
|
|
862
|
+
this,
|
|
863
|
+
/**
|
|
864
|
+
* original response
|
|
865
|
+
*/
|
|
866
|
+
"res",
|
|
867
|
+
void 0
|
|
868
|
+
);
|
|
869
|
+
this[ContextLocationIdProperty] = options.locationId;
|
|
870
|
+
this[ContextRequestProperty] = watchObject(new KeqRequestInit(options.request), { abort: (target, thisArg, argArray) => {
|
|
871
|
+
this[ContextEmitterProperty].emit("abort", {
|
|
872
|
+
context: this,
|
|
873
|
+
reason: argArray[0]
|
|
874
|
+
});
|
|
875
|
+
} });
|
|
876
|
+
this[ContextEmitterProperty] = options.emitter || (0, mitt.default)();
|
|
877
|
+
this[ContextGlobalProperty] = options.global;
|
|
878
|
+
this[ContextOptionsProperty] = options.options ? shallowClone(options.options) : {};
|
|
879
|
+
this[ContextDataProperty] = options.data || {};
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* The unique identifier of the request's location in the code
|
|
883
|
+
*/
|
|
884
|
+
get locationId() {
|
|
885
|
+
return this[ContextLocationIdProperty];
|
|
886
|
+
}
|
|
887
|
+
get request() {
|
|
888
|
+
return this[ContextRequestProperty];
|
|
889
|
+
}
|
|
890
|
+
get global() {
|
|
891
|
+
return this[ContextGlobalProperty];
|
|
892
|
+
}
|
|
893
|
+
get emitter() {
|
|
894
|
+
return this[ContextEmitterProperty];
|
|
895
|
+
}
|
|
896
|
+
get options() {
|
|
897
|
+
return this[ContextOptionsProperty];
|
|
898
|
+
}
|
|
899
|
+
set output(value) {
|
|
900
|
+
this[ContextOutputProperty] = value;
|
|
901
|
+
}
|
|
902
|
+
get response() {
|
|
903
|
+
if (!this.res) return void 0;
|
|
904
|
+
return createProxyResponse(this.res);
|
|
905
|
+
}
|
|
906
|
+
get data() {
|
|
907
|
+
return this[ContextDataProperty];
|
|
908
|
+
}
|
|
955
909
|
};
|
|
956
|
-
|
|
957
|
-
|
|
910
|
+
//#endregion
|
|
911
|
+
//#region src/middleware/utils/get-middleware-name.ts
|
|
958
912
|
function getMiddlewareName(middleware) {
|
|
959
|
-
|
|
913
|
+
return middleware.__keqMiddlewareName__ || middleware.name || "anonymous";
|
|
960
914
|
}
|
|
961
|
-
|
|
962
|
-
|
|
915
|
+
//#endregion
|
|
916
|
+
//#region src/middleware/utils/compose-middleware.ts
|
|
963
917
|
function composeMiddleware(middlewares, options) {
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
middleware.__keqMiddlewareName__ = options.name;
|
|
974
|
-
} else {
|
|
975
|
-
middleware.__keqMiddlewareName__ = "composeMiddleware(".concat(middlewares.map((i) => getMiddlewareName(i)).join(", "), ")");
|
|
976
|
-
}
|
|
977
|
-
return middleware;
|
|
918
|
+
if (!middlewares.length) throw new TypeException("At least one middleware");
|
|
919
|
+
const middleware = [...middlewares].reverse().reduce(function(prev, curr) {
|
|
920
|
+
return async (ctx, next) => {
|
|
921
|
+
await curr(ctx, async () => prev(ctx, next));
|
|
922
|
+
};
|
|
923
|
+
});
|
|
924
|
+
if (options?.name) middleware.__keqMiddlewareName__ = options.name;
|
|
925
|
+
else middleware.__keqMiddlewareName__ = `composeMiddleware(${middlewares.map((i) => getMiddlewareName(i)).join(", ")})`;
|
|
926
|
+
return middleware;
|
|
978
927
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
var _a5;
|
|
983
|
-
_a5 = ExecutorProperty2;
|
|
928
|
+
//#endregion
|
|
929
|
+
//#region src/context/middleware-context.ts
|
|
930
|
+
const ExecutorProperty = "__KeyProtectedProperty(context.orchestration.middlewares)__";
|
|
984
931
|
var KeqMiddlewareContext = class {
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
932
|
+
constructor(executor) {
|
|
933
|
+
_defineProperty(this, ExecutorProperty, void 0);
|
|
934
|
+
this[ExecutorProperty] = executor;
|
|
935
|
+
}
|
|
936
|
+
get name() {
|
|
937
|
+
return this[ExecutorProperty].name;
|
|
938
|
+
}
|
|
939
|
+
get status() {
|
|
940
|
+
return this[ExecutorProperty].status;
|
|
941
|
+
}
|
|
942
|
+
get finished() {
|
|
943
|
+
return this.status === "fulfilled" || this.status === "rejected";
|
|
944
|
+
}
|
|
998
945
|
};
|
|
999
|
-
|
|
1000
|
-
|
|
946
|
+
//#endregion
|
|
947
|
+
//#region src/orchestrator/executor.ts
|
|
1001
948
|
var KeqMiddlewareExecutor = class {
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
if (this.status === "pending") {
|
|
1024
|
-
this.status = "rejected";
|
|
1025
|
-
}
|
|
1026
|
-
throw error;
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
949
|
+
constructor(middleware) {
|
|
950
|
+
this.middleware = middleware;
|
|
951
|
+
_defineProperty(this, "name", void 0);
|
|
952
|
+
_defineProperty(this, "status", "idle");
|
|
953
|
+
_defineProperty(this, "context", void 0);
|
|
954
|
+
this.name = getMiddlewareName(middleware);
|
|
955
|
+
this.context = new KeqMiddlewareContext(this);
|
|
956
|
+
}
|
|
957
|
+
async execute(context, next) {
|
|
958
|
+
if (this.status !== "idle") throw new Exception(`Middleware "${this.name}" has already been executed.`);
|
|
959
|
+
try {
|
|
960
|
+
this.status = "pending";
|
|
961
|
+
context.emitter.emit("middleware:before", { context });
|
|
962
|
+
await this.middleware(context, next);
|
|
963
|
+
context.emitter.emit("middleware:after", { context });
|
|
964
|
+
if (this.status === "pending") this.status = "fulfilled";
|
|
965
|
+
} catch (error) {
|
|
966
|
+
if (this.status === "pending") this.status = "rejected";
|
|
967
|
+
throw error;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
1029
970
|
};
|
|
1030
|
-
|
|
1031
|
-
|
|
971
|
+
//#endregion
|
|
972
|
+
//#region src/request-init/utils/assign-request-init.ts
|
|
1032
973
|
function assignRequestInit(target, source) {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
974
|
+
target.url = source.url;
|
|
975
|
+
target.pathParameters = source.pathParameters;
|
|
976
|
+
target.method = source.method;
|
|
977
|
+
target.headers = source.headers;
|
|
978
|
+
target.body = source.body;
|
|
979
|
+
target.cache = source.cache;
|
|
980
|
+
target.credentials = source.credentials;
|
|
981
|
+
target.integrity = source.integrity;
|
|
982
|
+
target.keepalive = source.keepalive;
|
|
983
|
+
target.mode = source.mode;
|
|
984
|
+
target.redirect = source.redirect;
|
|
985
|
+
target.referrer = source.referrer;
|
|
986
|
+
target.referrerPolicy = source.referrerPolicy;
|
|
987
|
+
target[AbortControllerProperty] = source[AbortControllerProperty];
|
|
1047
988
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
989
|
+
//#endregion
|
|
990
|
+
//#region src/context/utils/assign-shared-context.ts
|
|
1050
991
|
function assignSharedContext(target, source) {
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
992
|
+
assignRequestInit(target.request, source.request);
|
|
993
|
+
Object.assign(target.global, source.global);
|
|
994
|
+
Object.assign(target.options, source.options);
|
|
995
|
+
Object.assign(target.data, source.data);
|
|
996
|
+
target[ContextEmitterProperty] = source[ContextEmitterProperty];
|
|
997
|
+
target[ContextOutputProperty] = source[ContextOutputProperty];
|
|
998
|
+
target.res = source.res;
|
|
1058
999
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
var KeqMiddlewareOrchestrator = class
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
index: this.main ? this.main.index + next : next
|
|
1133
|
-
}
|
|
1134
|
-
});
|
|
1135
|
-
return forkedOrchestrator;
|
|
1136
|
-
}
|
|
1137
|
-
merge(source) {
|
|
1138
|
-
if (!source.main) throw new TypeException("Source orchestrator is not a forked orchestrator.");
|
|
1139
|
-
const target = this.main ? this.main.orchestrator : this;
|
|
1140
|
-
if (source.main.orchestrator !== target) throw new TypeException("Cannot rebase to unrelated orchestrator");
|
|
1141
|
-
if (source.main.index !== this.current + 1) throw new TypeException("Cannot merge from non-current(expected: ".concat(this.current + 1, ", actual: ").concat(source.main.index, ") forked orchestrator"));
|
|
1142
|
-
assignSharedContext(this.context, source.context);
|
|
1143
|
-
for (const [i, executor] of this.executors.slice(source.main.index).entries()) {
|
|
1144
|
-
executor.status = source.executors[i].status;
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1000
|
+
//#endregion
|
|
1001
|
+
//#region src/orchestrator/orchestrator.ts
|
|
1002
|
+
var KeqMiddlewareOrchestrator = class KeqMiddlewareOrchestrator {
|
|
1003
|
+
constructor(context, middlewares = [], inherit) {
|
|
1004
|
+
_defineProperty(this, "main", void 0);
|
|
1005
|
+
_defineProperty(this, "status", "idle");
|
|
1006
|
+
_defineProperty(this, "context", void 0);
|
|
1007
|
+
_defineProperty(this, "executors", []);
|
|
1008
|
+
_defineProperty(this, "current", -1);
|
|
1009
|
+
this.context = context;
|
|
1010
|
+
this.executors = middlewares.map((mw) => new KeqMiddlewareExecutor(mw));
|
|
1011
|
+
if (inherit?.main) this.main = inherit.main;
|
|
1012
|
+
}
|
|
1013
|
+
cancelNotFinished() {
|
|
1014
|
+
const current = this.current;
|
|
1015
|
+
for (let i = current + 1; i < this.executors.length; i++) {
|
|
1016
|
+
const executor = this.executors[i];
|
|
1017
|
+
if (executor.status === "pending") executor.status = "canceled";
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
async run() {
|
|
1021
|
+
if (this.executors.length === 0) return;
|
|
1022
|
+
const executors = [...this.executors];
|
|
1023
|
+
const next = async (nextIndex) => {
|
|
1024
|
+
if (nextIndex >= executors.length) return;
|
|
1025
|
+
const nextExecutor = executors[nextIndex];
|
|
1026
|
+
if (nextExecutor.status !== "idle") throw new Exception(`Cannot call next() because the next Middleware(${nextExecutor.name}) status is ${nextExecutor.status}. If you want to re-execute it, please fork a new orchestrator.`);
|
|
1027
|
+
if (this.current + 1 !== nextIndex) {
|
|
1028
|
+
const parentExecutor = executors[nextIndex - 1];
|
|
1029
|
+
throw new Exception(parentExecutor ? `Cannot call next() outside Middleware(${parentExecutor.name}) runtime. You can fork a new orchestration and execute the forked one anywhere.` : "Cannot jump to non-sequential middleware. Please call next() in order.");
|
|
1030
|
+
}
|
|
1031
|
+
const last = this.current;
|
|
1032
|
+
this.current = nextIndex;
|
|
1033
|
+
const context = new KeqExecutionContext(this, nextExecutor);
|
|
1034
|
+
try {
|
|
1035
|
+
await nextExecutor.execute(context, () => next.call(this, nextIndex + 1));
|
|
1036
|
+
} finally {
|
|
1037
|
+
if (this.current === last + 1) this.current = last;
|
|
1038
|
+
else if (this.current > last) {
|
|
1039
|
+
this.cancelNotFinished();
|
|
1040
|
+
this.current = last;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
1044
|
+
await next.call(this, 0);
|
|
1045
|
+
}
|
|
1046
|
+
async execute() {
|
|
1047
|
+
if (this.status !== "idle") throw new Exception("Orchestrator has already been executed.");
|
|
1048
|
+
this.status = "pending";
|
|
1049
|
+
try {
|
|
1050
|
+
await this.run();
|
|
1051
|
+
this.status = "fulfilled";
|
|
1052
|
+
} catch (error) {
|
|
1053
|
+
this.status = "rejected";
|
|
1054
|
+
throw error;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
fork() {
|
|
1058
|
+
const context = cloneSharedContext(this.context);
|
|
1059
|
+
const next = this.current + 1;
|
|
1060
|
+
return new KeqMiddlewareOrchestrator(context, this.executors.slice(next).map((executor) => executor.middleware), { main: {
|
|
1061
|
+
orchestrator: this.main ? this.main.orchestrator : this,
|
|
1062
|
+
index: this.main ? this.main.index + next : next
|
|
1063
|
+
} });
|
|
1064
|
+
}
|
|
1065
|
+
merge(source) {
|
|
1066
|
+
if (!source.main) throw new TypeException("Source orchestrator is not a forked orchestrator.");
|
|
1067
|
+
const target = this.main ? this.main.orchestrator : this;
|
|
1068
|
+
if (source.main.orchestrator !== target) throw new TypeException("Cannot rebase to unrelated orchestrator");
|
|
1069
|
+
if (source.main.index !== this.current + 1) throw new TypeException(`Cannot merge from non-current(expected: ${this.current + 1}, actual: ${source.main.index}) forked orchestrator`);
|
|
1070
|
+
assignSharedContext(this.context, source.context);
|
|
1071
|
+
for (const [i, executor] of this.executors.slice(source.main.index).entries()) executor.status = source.executors[i].status;
|
|
1072
|
+
}
|
|
1147
1073
|
};
|
|
1148
|
-
|
|
1149
|
-
|
|
1074
|
+
//#endregion
|
|
1075
|
+
//#region src/request/utils/fix-content-type.ts
|
|
1150
1076
|
function fixContentType(contentType) {
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1077
|
+
if (["json", "xml"].includes(contentType)) return `application/${contentType}`;
|
|
1078
|
+
else if (["html", "css"].includes(contentType)) return `text/${contentType}`;
|
|
1079
|
+
else if (["form-data"].includes(contentType)) return `multipart/${contentType}`;
|
|
1080
|
+
else if ([
|
|
1081
|
+
"jpeg",
|
|
1082
|
+
"bmp",
|
|
1083
|
+
"apng",
|
|
1084
|
+
"gif",
|
|
1085
|
+
"x-icon",
|
|
1086
|
+
"png",
|
|
1087
|
+
"webp",
|
|
1088
|
+
"tiff"
|
|
1089
|
+
].includes(contentType)) return `image/${contentType}`;
|
|
1090
|
+
else if (contentType === "form") return "application/x-www-form-urlencoded";
|
|
1091
|
+
else if (contentType === "svg") return "image/svg+xml";
|
|
1092
|
+
return contentType;
|
|
1165
1093
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1094
|
+
//#endregion
|
|
1095
|
+
//#region src/request/utils/get-location-id.ts
|
|
1168
1096
|
function getLocationId(depth = 0) {
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
return stackLine.trim();
|
|
1097
|
+
const err = /* @__PURE__ */ new Error();
|
|
1098
|
+
if (!err.stack) return "";
|
|
1099
|
+
return err.stack.split("\n")[depth + 2].trim();
|
|
1173
1100
|
}
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
var import_stream = require("eventsource-parser/stream");
|
|
1101
|
+
//#endregion
|
|
1102
|
+
//#region src/request/utils/resolve-with.ts
|
|
1177
1103
|
async function resolveWith(response, mode) {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
return void 0;
|
|
1104
|
+
if (mode === "response") return response.clone();
|
|
1105
|
+
if (mode === "text") return await response.text();
|
|
1106
|
+
if (mode === "json") return unwrap(await response.json());
|
|
1107
|
+
if (mode === "form-data") return await response.formData();
|
|
1108
|
+
if (mode === "blob") return await response.blob();
|
|
1109
|
+
if (mode === "array-buffer") return await response.arrayBuffer();
|
|
1110
|
+
if (mode === "sse") {
|
|
1111
|
+
if (!response.body) return response.body;
|
|
1112
|
+
return response.clone().body.pipeThrough(new TextDecoderStream()).pipeThrough(new eventsource_parser_stream.EventSourceParserStream());
|
|
1113
|
+
}
|
|
1189
1114
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1115
|
+
//#endregion
|
|
1116
|
+
//#region src/request/utils/intelligent-parse-response.ts
|
|
1192
1117
|
async function intelligentParseResponse(response) {
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
} else if (contentType.includes("text/event-stream")) {
|
|
1206
|
-
return resolveWith(response, "sse");
|
|
1207
|
-
}
|
|
1208
|
-
} catch (err) {
|
|
1209
|
-
console.warn("Failed to intelligent parse response body: ".concat(response.url), err);
|
|
1210
|
-
throw err;
|
|
1211
|
-
}
|
|
1212
|
-
return void 0;
|
|
1118
|
+
if (!response) return void 0;
|
|
1119
|
+
if (response.status === 204) return;
|
|
1120
|
+
const contentType = response.headers.get("content-type") || "";
|
|
1121
|
+
try {
|
|
1122
|
+
if (contentType.match(/^application\/(.+\+)?json/)) return resolveWith(response, "json");
|
|
1123
|
+
else if (contentType.includes("multipart/form-data")) return resolveWith(response, "form-data");
|
|
1124
|
+
else if (contentType.includes("plain/text")) return resolveWith(response, "text");
|
|
1125
|
+
else if (contentType.includes("text/event-stream")) return resolveWith(response, "sse");
|
|
1126
|
+
} catch (err) {
|
|
1127
|
+
console.warn(`Failed to intelligent parse response body: ${response.url}`, err);
|
|
1128
|
+
throw err;
|
|
1129
|
+
}
|
|
1213
1130
|
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1131
|
+
//#endregion
|
|
1132
|
+
//#region src/request/utils/merge-keq-request-body.ts
|
|
1216
1133
|
function mergeKeqRequestBody(left, right) {
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
const values = right.getAll(key);
|
|
1239
|
-
if (values.length === 1) {
|
|
1240
|
-
result[key] = values[0];
|
|
1241
|
-
} else if (values.length > 1) {
|
|
1242
|
-
result[key] = values;
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
} else if (typeof right === "object") {
|
|
1246
|
-
for (const key in right) {
|
|
1247
|
-
result[key] = right[key];
|
|
1248
|
-
}
|
|
1249
|
-
} else {
|
|
1250
|
-
throw new Exception("Not support request body type: ".concat(typeof right));
|
|
1251
|
-
}
|
|
1252
|
-
return result;
|
|
1134
|
+
if (right === void 0) return left;
|
|
1135
|
+
if (typeof right === "number") throw new TypeError("Cannot set request body to a number.");
|
|
1136
|
+
if (left === null || right === null || Validator.isBuffer(right) || Validator.isArrayBuffer(right) || Validator.isBlob(right) || Validator.isReadableStream(right) || Validator.isBuffer(left) || Validator.isArrayBuffer(left) || Validator.isBlob(left) || Validator.isReadableStream(left) || Array.isArray(left) || Array.isArray(right) || typeof left !== "object" && left !== void 0 || typeof right !== "object") return Array.isArray(right) ? [...right] : right;
|
|
1137
|
+
const result = left || {};
|
|
1138
|
+
if (Validator.isUrlSearchParams(right)) {
|
|
1139
|
+
const keys = right.keys();
|
|
1140
|
+
for (const key of keys) {
|
|
1141
|
+
const values = right.getAll(key);
|
|
1142
|
+
if (values.length === 1) result[key] = values[0];
|
|
1143
|
+
else if (values.length > 1) result[key] = values;
|
|
1144
|
+
}
|
|
1145
|
+
} else if (Validator.isFormData(right)) {
|
|
1146
|
+
const keys = right.keys();
|
|
1147
|
+
for (const key of keys) {
|
|
1148
|
+
const values = right.getAll(key);
|
|
1149
|
+
if (values.length === 1) result[key] = values[0];
|
|
1150
|
+
else if (values.length > 1) result[key] = values;
|
|
1151
|
+
}
|
|
1152
|
+
} else if (typeof right === "object") for (const key in right) result[key] = right[key];
|
|
1153
|
+
else throw new Exception(`Not support request body type: ${typeof right}`);
|
|
1154
|
+
return result;
|
|
1253
1155
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
var import_qs = __toESM(require("qs"));
|
|
1156
|
+
//#endregion
|
|
1157
|
+
//#region src/request/utils/query-stringify.ts
|
|
1257
1158
|
function normalize(value, options) {
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
for (const key of Object.keys(obj)) {
|
|
1267
|
-
obj[key] = normalize(obj[key], options);
|
|
1268
|
-
}
|
|
1269
|
-
return obj;
|
|
1270
|
-
}
|
|
1271
|
-
return value;
|
|
1159
|
+
if (Array.isArray(value)) return value.map((v) => normalize(v, options));
|
|
1160
|
+
if (typeof value === "bigint") return value.toString();
|
|
1161
|
+
if (typeof value === "object" && value !== null) {
|
|
1162
|
+
const obj = { ...value };
|
|
1163
|
+
for (const key of Object.keys(obj)) obj[key] = normalize(obj[key], options);
|
|
1164
|
+
return obj;
|
|
1165
|
+
}
|
|
1166
|
+
return value;
|
|
1272
1167
|
}
|
|
1273
1168
|
function queryStringify(query, options) {
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
opts.filter = (_, val) => {
|
|
1289
|
-
if (Array.isArray(val)) return val.join(" ");
|
|
1290
|
-
return val;
|
|
1291
|
-
};
|
|
1292
|
-
} else if (options == null ? void 0 : options.arrayFormat) {
|
|
1293
|
-
opts.arrayFormat = options.arrayFormat;
|
|
1294
|
-
}
|
|
1295
|
-
return import_qs.default.stringify(value, opts);
|
|
1169
|
+
const value = normalize(query, options);
|
|
1170
|
+
const opts = {};
|
|
1171
|
+
if (options?.allowDots !== void 0) opts.allowDots = options.allowDots;
|
|
1172
|
+
if (options?.indices !== void 0) opts.indices = options.indices;
|
|
1173
|
+
if (options?.arrayFormat === "pipe") opts.filter = (_, val) => {
|
|
1174
|
+
if (Array.isArray(val)) return val.join("|");
|
|
1175
|
+
return val;
|
|
1176
|
+
};
|
|
1177
|
+
else if (options?.arrayFormat === "space") opts.filter = (_, val) => {
|
|
1178
|
+
if (Array.isArray(val)) return val.join(" ");
|
|
1179
|
+
return val;
|
|
1180
|
+
};
|
|
1181
|
+
else if (options?.arrayFormat) opts.arrayFormat = options.arrayFormat;
|
|
1182
|
+
return qs.default.stringify(value, opts);
|
|
1296
1183
|
}
|
|
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
|
-
|
|
1184
|
+
//#endregion
|
|
1185
|
+
//#region src/request/core.ts
|
|
1186
|
+
let _Symbol$species;
|
|
1187
|
+
_Symbol$species = Symbol.species;
|
|
1188
|
+
/**
|
|
1189
|
+
* Core class that provides the foundational structure for managing middlewares, events, and request execution.
|
|
1190
|
+
*/
|
|
1191
|
+
var Core = class extends Promise {
|
|
1192
|
+
/**
|
|
1193
|
+
* Ensures `.then()`, `.catch()`, `.finally()` return plain Promise instances instead of Core/Keq instances.
|
|
1194
|
+
*/
|
|
1195
|
+
static get [_Symbol$species]() {
|
|
1196
|
+
return Promise;
|
|
1197
|
+
}
|
|
1198
|
+
get __middlewares__() {
|
|
1199
|
+
return [...this.__prepend_middlewares__, ...this.__append_middlewares__];
|
|
1200
|
+
}
|
|
1201
|
+
constructor(url, options) {
|
|
1202
|
+
let resolve;
|
|
1203
|
+
let reject;
|
|
1204
|
+
super((res, rej) => {
|
|
1205
|
+
resolve = res;
|
|
1206
|
+
reject = rej;
|
|
1207
|
+
});
|
|
1208
|
+
_defineProperty(
|
|
1209
|
+
this,
|
|
1210
|
+
/**
|
|
1211
|
+
* The unique identifier of the request's location in the code
|
|
1212
|
+
*/
|
|
1213
|
+
"__locationId__",
|
|
1214
|
+
void 0
|
|
1215
|
+
);
|
|
1216
|
+
_defineProperty(this, "__resolve__", void 0);
|
|
1217
|
+
_defineProperty(this, "__reject__", void 0);
|
|
1218
|
+
_defineProperty(this, "__triggered__", false);
|
|
1219
|
+
_defineProperty(this, "__requestPromise__", void 0);
|
|
1220
|
+
_defineProperty(this, "requestInit", void 0);
|
|
1221
|
+
_defineProperty(this, "__listeners__", {});
|
|
1222
|
+
_defineProperty(this, "__global__", void 0);
|
|
1223
|
+
_defineProperty(this, "__prepend_middlewares__", []);
|
|
1224
|
+
_defineProperty(this, "__append_middlewares__", []);
|
|
1225
|
+
_defineProperty(this, "__qs__", void 0);
|
|
1226
|
+
_defineProperty(this, "__options__", {
|
|
1227
|
+
resolveWithFullResponse: false,
|
|
1228
|
+
resolveWith: "intelligent"
|
|
1229
|
+
});
|
|
1230
|
+
this.__resolve__ = resolve;
|
|
1231
|
+
this.__reject__ = reject;
|
|
1232
|
+
this.__global__ = options.global || {};
|
|
1233
|
+
this.__locationId__ = options.locationId;
|
|
1234
|
+
this.__qs__ = options.qs;
|
|
1235
|
+
this.requestInit = new KeqRequestInit({
|
|
1236
|
+
method: "get",
|
|
1237
|
+
headers: new Headers(),
|
|
1238
|
+
pathParameters: {},
|
|
1239
|
+
body: void 0,
|
|
1240
|
+
...options,
|
|
1241
|
+
url: new URL(url.href)
|
|
1242
|
+
});
|
|
1243
|
+
if (options.middlewares) this.__append_middlewares__.push(...options.middlewares);
|
|
1244
|
+
}
|
|
1245
|
+
use(...middlewares) {
|
|
1246
|
+
this.__prepend_middlewares__.push(...middlewares);
|
|
1247
|
+
return this;
|
|
1248
|
+
}
|
|
1249
|
+
on(event, listener) {
|
|
1250
|
+
this.__listeners__[event] = this.__listeners__[event] || [];
|
|
1251
|
+
this.__listeners__[event].push(listener);
|
|
1252
|
+
return this;
|
|
1253
|
+
}
|
|
1254
|
+
option(key, value = true) {
|
|
1255
|
+
this.__options__[key] = value;
|
|
1256
|
+
return this;
|
|
1257
|
+
}
|
|
1258
|
+
options(opts) {
|
|
1259
|
+
for (const [key, value] of Object.entries(opts)) this.__options__[key] = value;
|
|
1260
|
+
return this;
|
|
1261
|
+
}
|
|
1262
|
+
derive() {
|
|
1263
|
+
const derived = new this.constructor(this.requestInit.url, {
|
|
1264
|
+
method: this.requestInit.method,
|
|
1265
|
+
headers: this.requestInit.headers,
|
|
1266
|
+
body: this.requestInit.body,
|
|
1267
|
+
pathParameters: this.requestInit.pathParameters,
|
|
1268
|
+
cache: this.requestInit.cache,
|
|
1269
|
+
credentials: this.requestInit.credentials,
|
|
1270
|
+
integrity: this.requestInit.integrity,
|
|
1271
|
+
keepalive: this.requestInit.keepalive,
|
|
1272
|
+
mode: this.requestInit.mode,
|
|
1273
|
+
redirect: this.requestInit.redirect,
|
|
1274
|
+
referrer: this.requestInit.referrer,
|
|
1275
|
+
referrerPolicy: this.requestInit.referrerPolicy,
|
|
1276
|
+
locationId: this.__locationId__,
|
|
1277
|
+
global: this.__global__,
|
|
1278
|
+
qs: this.__qs__ ? { ...this.__qs__ } : void 0,
|
|
1279
|
+
middlewares: [...this.__append_middlewares__]
|
|
1280
|
+
});
|
|
1281
|
+
derived.__prepend_middlewares__ = [...this.__prepend_middlewares__];
|
|
1282
|
+
derived.__listeners__ = {};
|
|
1283
|
+
for (const key in this.__listeners__) derived.__listeners__[key] = [...this.__listeners__[key]];
|
|
1284
|
+
derived.__options__ = (0, klona_json.klona)(this.__options__);
|
|
1285
|
+
return derived;
|
|
1286
|
+
}
|
|
1287
|
+
buildSharedContext() {
|
|
1288
|
+
const coreContext = new KeqSharedContext({
|
|
1289
|
+
locationId: this.__locationId__,
|
|
1290
|
+
request: this.requestInit,
|
|
1291
|
+
global: this.__global__,
|
|
1292
|
+
options: this.__options__
|
|
1293
|
+
});
|
|
1294
|
+
for (const eventName in this.__listeners__) {
|
|
1295
|
+
const listeners = this.__listeners__[eventName];
|
|
1296
|
+
for (const listener of listeners) coreContext.emitter.on(eventName, listener);
|
|
1297
|
+
}
|
|
1298
|
+
return coreContext;
|
|
1299
|
+
}
|
|
1300
|
+
async run() {
|
|
1301
|
+
let attempt;
|
|
1302
|
+
while (true) {
|
|
1303
|
+
const attemptWithDefault = attempt || 0;
|
|
1304
|
+
const sharedContext = this.buildSharedContext();
|
|
1305
|
+
const orchestrator = new KeqMiddlewareOrchestrator(sharedContext, this.__middlewares__);
|
|
1306
|
+
if (attempt !== void 0) sharedContext.data.retry = { attempt };
|
|
1307
|
+
if (attempt && attempt >= 1) sharedContext.emitter.emit("retry", { context: sharedContext });
|
|
1308
|
+
let error = null;
|
|
1309
|
+
try {
|
|
1310
|
+
await orchestrator.execute();
|
|
1311
|
+
} catch (err) {
|
|
1312
|
+
error = err;
|
|
1313
|
+
}
|
|
1314
|
+
const retryOn = typeof sharedContext.options.retry?.on === "function" ? sharedContext.options.retry.on : (attempt, error) => {
|
|
1315
|
+
if (error instanceof RequestException && error.retry === false) return false;
|
|
1316
|
+
return !!error;
|
|
1317
|
+
};
|
|
1318
|
+
let retryTimes = sharedContext.options.retry?.times || 0;
|
|
1319
|
+
if (retryTimes) {
|
|
1320
|
+
if (retryTimes < 0) retryTimes = 0;
|
|
1321
|
+
else if (!Number.isInteger(retryTimes)) retryTimes = Math.floor(retryTimes);
|
|
1322
|
+
}
|
|
1323
|
+
if (attemptWithDefault >= retryTimes || await retryOn(attemptWithDefault, error, sharedContext) === false) {
|
|
1324
|
+
if (error) {
|
|
1325
|
+
sharedContext.emitter.emit("error", { context: sharedContext });
|
|
1326
|
+
throw error;
|
|
1327
|
+
}
|
|
1328
|
+
return sharedContext;
|
|
1329
|
+
}
|
|
1330
|
+
const retryDelay = typeof sharedContext.options.retry?.delay === "function" ? await sharedContext.options.retry.delay(attemptWithDefault, error, sharedContext) : sharedContext.options.retry?.delay || 0;
|
|
1331
|
+
if (retryDelay) await sleep(retryDelay);
|
|
1332
|
+
attempt = attemptWithDefault + 1;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
__execute__() {
|
|
1336
|
+
if (!this.__requestPromise__) this.__requestPromise__ = (async () => {
|
|
1337
|
+
const coreContext = await this.run();
|
|
1338
|
+
const resolveWithMode = coreContext.options.resolveWith;
|
|
1339
|
+
if (resolveWithMode === "response") return coreContext.response?.clone();
|
|
1340
|
+
const response = coreContext.response;
|
|
1341
|
+
if (!resolveWithMode || resolveWithMode === "intelligent") {
|
|
1342
|
+
const output = coreContext.output;
|
|
1343
|
+
if (output !== void 0) return output;
|
|
1344
|
+
return await intelligentParseResponse(response);
|
|
1345
|
+
}
|
|
1346
|
+
if (!response) throw new Exception([
|
|
1347
|
+
`Unable to process the response with '${resolveWithMode}'. Possible causes:`,
|
|
1348
|
+
"1. The request was never initiated or sent",
|
|
1349
|
+
"2. The request failed before a response was received."
|
|
1350
|
+
].join("\n"));
|
|
1351
|
+
return await resolveWith(response, resolveWithMode);
|
|
1352
|
+
})();
|
|
1353
|
+
return this.__requestPromise__;
|
|
1354
|
+
}
|
|
1355
|
+
fire() {
|
|
1356
|
+
if (!this.__triggered__) {
|
|
1357
|
+
this.__triggered__ = true;
|
|
1358
|
+
this.__execute__().then(this.__resolve__, this.__reject__);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
then(onfulfilled, onrejected) {
|
|
1362
|
+
if (!this.__triggered__) {
|
|
1363
|
+
this.__triggered__ = true;
|
|
1364
|
+
this.__execute__().then(this.__resolve__, this.__reject__);
|
|
1365
|
+
}
|
|
1366
|
+
return super.then(onfulfilled, onrejected);
|
|
1367
|
+
}
|
|
1457
1368
|
};
|
|
1458
|
-
|
|
1459
|
-
|
|
1369
|
+
//#endregion
|
|
1370
|
+
//#region src/request/keq.ts
|
|
1371
|
+
/**
|
|
1372
|
+
* extends Core to provide a fluent API for building HTTP requests
|
|
1373
|
+
*/
|
|
1460
1374
|
var Keq = class extends Core {
|
|
1461
|
-
|
|
1462
|
-
|
|
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
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
*/
|
|
1597
|
-
retry(retryTimes, retryDelay = 0, retryOn = (attempt, error) => !!error) {
|
|
1598
|
-
this.option("retry", {
|
|
1599
|
-
times: retryTimes,
|
|
1600
|
-
delay: retryDelay,
|
|
1601
|
-
on: retryOn
|
|
1602
|
-
});
|
|
1603
|
-
return this;
|
|
1604
|
-
}
|
|
1605
|
-
redirect(mod) {
|
|
1606
|
-
this.requestInit.redirect = mod;
|
|
1607
|
-
return this;
|
|
1608
|
-
}
|
|
1609
|
-
credentials(mod) {
|
|
1610
|
-
this.requestInit.credentials = mod;
|
|
1611
|
-
return this;
|
|
1612
|
-
}
|
|
1613
|
-
mode(mod) {
|
|
1614
|
-
this.requestInit.mode = mod;
|
|
1615
|
-
return this;
|
|
1616
|
-
}
|
|
1617
|
-
flowControl(mode, arg2, arg3) {
|
|
1618
|
-
const concurrencyLimit = typeof arg2 === "number" ? arg2 : void 0;
|
|
1619
|
-
const sig = typeof arg2 === "function" || typeof arg2 === "string" ? arg2 : arg3 && (typeof arg3 === "function" || typeof arg3 === "string") ? arg3 : this.__locationId__;
|
|
1620
|
-
if (!sig) {
|
|
1621
|
-
throw new Exception("please set signal to .flowControl()");
|
|
1622
|
-
}
|
|
1623
|
-
const flowControl = {
|
|
1624
|
-
mode,
|
|
1625
|
-
concurrencyLimit,
|
|
1626
|
-
signal: sig
|
|
1627
|
-
};
|
|
1628
|
-
this.option("flowControl", flowControl);
|
|
1629
|
-
return this;
|
|
1630
|
-
}
|
|
1631
|
-
timeout(milliseconds) {
|
|
1632
|
-
this.option("timeout", { millisecond: milliseconds });
|
|
1633
|
-
return this;
|
|
1634
|
-
}
|
|
1635
|
-
resolveWith(m2) {
|
|
1636
|
-
this.option("resolveWith", m2);
|
|
1637
|
-
return this;
|
|
1638
|
-
}
|
|
1375
|
+
set(headersOrName, value) {
|
|
1376
|
+
if (Validator.isHeaders(headersOrName)) headersOrName.forEach((value, key) => {
|
|
1377
|
+
this.requestInit.headers.set(key, value);
|
|
1378
|
+
});
|
|
1379
|
+
else if (typeof headersOrName === "string" && value) {
|
|
1380
|
+
if (!Validator.isHeaderValue(value)) throw new Exception(`[Invalid header] Key: ${headersOrName} Value: ${value}`);
|
|
1381
|
+
this.requestInit.headers.set(headersOrName, String(value));
|
|
1382
|
+
} else if (typeof headersOrName === "object") for (const [key, value] of Object.entries(headersOrName)) {
|
|
1383
|
+
if (!Validator.isHeaderValue(value)) throw new Exception(`[Invalid header] Key: ${key} Value: ${String(value)}`);
|
|
1384
|
+
this.requestInit.headers.set(key, String(value));
|
|
1385
|
+
}
|
|
1386
|
+
return this;
|
|
1387
|
+
}
|
|
1388
|
+
headers(headersOrName, value) {
|
|
1389
|
+
return this.set(headersOrName, value);
|
|
1390
|
+
}
|
|
1391
|
+
query(arg1, arg2, arg3) {
|
|
1392
|
+
if (Validator.isObject(arg1)) {
|
|
1393
|
+
const str = queryStringify(arg1, arg2 || this.__qs__);
|
|
1394
|
+
for (const [k, v] of new URLSearchParams(str).entries()) for (const item of Array.isArray(v) ? v : [v]) this.requestInit.url.searchParams.append(k, item);
|
|
1395
|
+
this.requestInit.url.search = this.requestInit.url.searchParams.toString().replace(/\+/g, "%20");
|
|
1396
|
+
return this;
|
|
1397
|
+
}
|
|
1398
|
+
if (typeof arg1 === "string") {
|
|
1399
|
+
this.query({ [arg1]: arg2 }, arg3);
|
|
1400
|
+
return this;
|
|
1401
|
+
}
|
|
1402
|
+
throw new TypeException("Invalid Arguments for .query()");
|
|
1403
|
+
}
|
|
1404
|
+
params(arg1, arg2) {
|
|
1405
|
+
if (typeof arg1 === "string" && arg2 !== void 0) this.requestInit.pathParameters[arg1] = arg2;
|
|
1406
|
+
else if (typeof arg1 === "object" && arg1 !== null) {
|
|
1407
|
+
for (const k of Object.keys(arg1)) if (arg1[k]) this.requestInit.pathParameters[k] = arg1[k];
|
|
1408
|
+
} else throw new TypeError("Invalid Arguments for .params()");
|
|
1409
|
+
return this;
|
|
1410
|
+
}
|
|
1411
|
+
/**
|
|
1412
|
+
* Set request body
|
|
1413
|
+
*/
|
|
1414
|
+
body(value) {
|
|
1415
|
+
this.requestInit.body = value;
|
|
1416
|
+
return this;
|
|
1417
|
+
}
|
|
1418
|
+
type(contentType) {
|
|
1419
|
+
const type = fixContentType(contentType);
|
|
1420
|
+
this.set("content-type", type);
|
|
1421
|
+
return this;
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Http Basic Authentication
|
|
1425
|
+
*/
|
|
1426
|
+
auth(username, password) {
|
|
1427
|
+
this.set("Authorization", `Basic ${base64Encode(`${username}:${password}`)}`);
|
|
1428
|
+
return this;
|
|
1429
|
+
}
|
|
1430
|
+
setTypeIfEmpty(contentType) {
|
|
1431
|
+
if (!this.requestInit.headers.has("Content-Type")) this.type(contentType);
|
|
1432
|
+
}
|
|
1433
|
+
send(value) {
|
|
1434
|
+
this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, value);
|
|
1435
|
+
if (Validator.isUrlSearchParams(value)) this.setTypeIfEmpty("form");
|
|
1436
|
+
else if (Validator.isFormData(value)) this.setTypeIfEmpty("form-data");
|
|
1437
|
+
else if (Validator.isBlob(value) || Validator.isReadableStream(value) || Validator.isArrayBuffer(value)) {} else if (typeof value === "object") this.setTypeIfEmpty("json");
|
|
1438
|
+
return this;
|
|
1439
|
+
}
|
|
1440
|
+
field(arg1, arg2) {
|
|
1441
|
+
if (typeof arg1 === "object") this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, arg1);
|
|
1442
|
+
else if (arg2) this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, { [arg1]: arg2 });
|
|
1443
|
+
else throw new TypeException("Invalid arguments for .field()");
|
|
1444
|
+
this.setTypeIfEmpty("form-data");
|
|
1445
|
+
return this;
|
|
1446
|
+
}
|
|
1447
|
+
attach(key, value, arg3 = "file") {
|
|
1448
|
+
const formData = new FormData();
|
|
1449
|
+
const appendFile = (file) => {
|
|
1450
|
+
if (Validator.isBlob(file)) formData.append(key, file, arg3);
|
|
1451
|
+
else if (Validator.isFile(file)) formData.append(key, file);
|
|
1452
|
+
else if (Validator.isBuffer(file)) formData.append(key, new Blob([file]), arg3);
|
|
1453
|
+
else throw new TypeException("Invalid file type for .attach()");
|
|
1454
|
+
};
|
|
1455
|
+
if (Array.isArray(value)) {
|
|
1456
|
+
if (value.length === 0) throw new TypeException("Empty array provided to .attach() is not valid");
|
|
1457
|
+
for (const item of value) appendFile(item);
|
|
1458
|
+
} else appendFile(value);
|
|
1459
|
+
const files = formData.getAll(key);
|
|
1460
|
+
this.requestInit.body = mergeKeqRequestBody(this.requestInit.body, { [key]: files.length === 1 ? files[0] : files });
|
|
1461
|
+
this.setTypeIfEmpty("form-data");
|
|
1462
|
+
return this;
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
*
|
|
1466
|
+
* @param retryTimes Max number of retries per call
|
|
1467
|
+
* @param retryDelay Initial value used to calculate the retry in milliseconds (This is still randomized following the randomization factor)
|
|
1468
|
+
* @param retryCallback Will be called after request failed
|
|
1469
|
+
*/
|
|
1470
|
+
retry(retryTimes, retryDelay = 0, retryOn = (attempt, error) => !!error) {
|
|
1471
|
+
this.option("retry", {
|
|
1472
|
+
times: retryTimes,
|
|
1473
|
+
delay: retryDelay,
|
|
1474
|
+
on: retryOn
|
|
1475
|
+
});
|
|
1476
|
+
return this;
|
|
1477
|
+
}
|
|
1478
|
+
redirect(mod) {
|
|
1479
|
+
this.requestInit.redirect = mod;
|
|
1480
|
+
return this;
|
|
1481
|
+
}
|
|
1482
|
+
credentials(mod) {
|
|
1483
|
+
this.requestInit.credentials = mod;
|
|
1484
|
+
return this;
|
|
1485
|
+
}
|
|
1486
|
+
mode(mod) {
|
|
1487
|
+
this.requestInit.mode = mod;
|
|
1488
|
+
return this;
|
|
1489
|
+
}
|
|
1490
|
+
flowControl(mode, arg2, arg3) {
|
|
1491
|
+
const concurrencyLimit = typeof arg2 === "number" ? arg2 : void 0;
|
|
1492
|
+
const sig = typeof arg2 === "function" || typeof arg2 === "string" ? arg2 : arg3 && (typeof arg3 === "function" || typeof arg3 === "string") ? arg3 : this.__locationId__;
|
|
1493
|
+
if (!sig) throw new Exception("please set signal to .flowControl()");
|
|
1494
|
+
const flowControl = {
|
|
1495
|
+
mode,
|
|
1496
|
+
concurrencyLimit,
|
|
1497
|
+
signal: sig
|
|
1498
|
+
};
|
|
1499
|
+
this.option("flowControl", flowControl);
|
|
1500
|
+
return this;
|
|
1501
|
+
}
|
|
1502
|
+
timeout(milliseconds) {
|
|
1503
|
+
this.option("timeout", { millisecond: milliseconds });
|
|
1504
|
+
return this;
|
|
1505
|
+
}
|
|
1506
|
+
resolveWith(m) {
|
|
1507
|
+
this.option("resolveWith", m);
|
|
1508
|
+
return this;
|
|
1509
|
+
}
|
|
1639
1510
|
};
|
|
1640
|
-
|
|
1641
|
-
|
|
1511
|
+
//#endregion
|
|
1512
|
+
//#region src/router/utils/compose-route.ts
|
|
1642
1513
|
function composeRoute(routes) {
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
const results = await Promise.all(routes.map((route) => route(ctx)));
|
|
1648
|
-
return results.every((result) => result === true);
|
|
1649
|
-
};
|
|
1514
|
+
if (!routes.length) throw new Exception("At least one route");
|
|
1515
|
+
return async (ctx) => {
|
|
1516
|
+
return (await Promise.all(routes.map((route) => route(ctx)))).every((result) => result === true);
|
|
1517
|
+
};
|
|
1650
1518
|
}
|
|
1651
|
-
|
|
1652
|
-
|
|
1519
|
+
//#endregion
|
|
1520
|
+
//#region src/router/keq-host-route.ts
|
|
1653
1521
|
function keqHostRoute(host) {
|
|
1654
|
-
|
|
1522
|
+
return (ctx) => ctx.request.url.host === host;
|
|
1655
1523
|
}
|
|
1656
|
-
|
|
1657
|
-
|
|
1524
|
+
//#endregion
|
|
1525
|
+
//#region src/router/keq-location-route.ts
|
|
1658
1526
|
function keqLocationRoute() {
|
|
1659
|
-
|
|
1527
|
+
return (ctx) => Validator.isBrowser() && ctx.request.url.host === window.location.host;
|
|
1660
1528
|
}
|
|
1661
|
-
|
|
1662
|
-
|
|
1529
|
+
//#endregion
|
|
1530
|
+
//#region src/router/keq-method-route.ts
|
|
1663
1531
|
function keqMethodRoute(method) {
|
|
1664
|
-
|
|
1532
|
+
return (ctx) => ctx.request.method.toLowerCase() === method.toLowerCase();
|
|
1665
1533
|
}
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
function keqModuleRoute(moduleName) {
|
|
1669
|
-
if (!moduleName) {
|
|
1670
|
-
throw new Exception("Module name should not be empty");
|
|
1671
|
-
}
|
|
1672
|
-
return (ctx) => {
|
|
1673
|
-
var _a6;
|
|
1674
|
-
return ((_a6 = ctx.options.module) == null ? void 0 : _a6.name) === moduleName;
|
|
1675
|
-
};
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
// src/router/keq-pathname-route.ts
|
|
1679
|
-
var m = __toESM(require("minimatch"));
|
|
1534
|
+
//#endregion
|
|
1535
|
+
//#region src/router/keq-pathname-route.ts
|
|
1680
1536
|
function keqPathnameRoute(pathname) {
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1537
|
+
const isMatch = (0, picomatch.default)(pathname);
|
|
1538
|
+
return (ctx) => {
|
|
1539
|
+
return isMatch(ctx.request.url.pathname);
|
|
1540
|
+
};
|
|
1684
1541
|
}
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
var KeqRouter = class
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
return mid;
|
|
1755
|
-
}
|
|
1756
|
-
static location(middleware, ...additionalMiddlewares) {
|
|
1757
|
-
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1758
|
-
const mid = _KeqRouter.buildMiddleware(keqLocationRoute(), list);
|
|
1759
|
-
mid.__keqMiddlewareName__ = "location(".concat(list.map(getMiddlewareName).join(", "), ")");
|
|
1760
|
-
return mid;
|
|
1761
|
-
}
|
|
1762
|
-
static module(moduleName, middleware, ...additionalMiddlewares) {
|
|
1763
|
-
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1764
|
-
const mid = _KeqRouter.buildMiddleware(keqModuleRoute(moduleName), list);
|
|
1765
|
-
mid.__keqMiddlewareName__ = "module(".concat(JSON.stringify(moduleName), ", ").concat(list.map(getMiddlewareName).join(", "), ")");
|
|
1766
|
-
return mid;
|
|
1767
|
-
}
|
|
1542
|
+
//#endregion
|
|
1543
|
+
//#region src/router/keq-router.ts
|
|
1544
|
+
var KeqRouter = class KeqRouter {
|
|
1545
|
+
constructor(middlewares = []) {
|
|
1546
|
+
this.middlewares = middlewares;
|
|
1547
|
+
}
|
|
1548
|
+
static buildMiddleware(route, middlewares) {
|
|
1549
|
+
if (middlewares.length === 0) throw new TypeException("At least one middleware is required to build a route middleware");
|
|
1550
|
+
const composedMiddleware = middlewares.length > 1 ? composeMiddleware(middlewares) : middlewares[0];
|
|
1551
|
+
return async function router(ctx, next) {
|
|
1552
|
+
if (route(ctx)) await composedMiddleware(ctx, next);
|
|
1553
|
+
else await next();
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
route(route, middleware, ...additionalMiddlewares) {
|
|
1557
|
+
const mid = KeqRouter.route(route, middleware, ...additionalMiddlewares);
|
|
1558
|
+
this.middlewares.push(mid);
|
|
1559
|
+
return this;
|
|
1560
|
+
}
|
|
1561
|
+
host(host, middleware, ...additionalMiddlewares) {
|
|
1562
|
+
const mid = KeqRouter.host(host, middleware, ...additionalMiddlewares);
|
|
1563
|
+
this.middlewares.push(mid);
|
|
1564
|
+
return this;
|
|
1565
|
+
}
|
|
1566
|
+
method(method, middleware, ...additionalMiddlewares) {
|
|
1567
|
+
const mid = KeqRouter.method(method, middleware, ...additionalMiddlewares);
|
|
1568
|
+
this.middlewares.push(mid);
|
|
1569
|
+
return this;
|
|
1570
|
+
}
|
|
1571
|
+
pathname(pathname, middleware, ...additionalMiddlewares) {
|
|
1572
|
+
const mid = KeqRouter.pathname(pathname, middleware, ...additionalMiddlewares);
|
|
1573
|
+
this.middlewares.push(mid);
|
|
1574
|
+
return this;
|
|
1575
|
+
}
|
|
1576
|
+
location(middleware, ...additionalMiddlewares) {
|
|
1577
|
+
const mid = KeqRouter.location(middleware, ...additionalMiddlewares);
|
|
1578
|
+
this.middlewares.push(mid);
|
|
1579
|
+
return this;
|
|
1580
|
+
}
|
|
1581
|
+
static route(route, middleware, ...additionalMiddlewares) {
|
|
1582
|
+
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1583
|
+
const mid = KeqRouter.buildMiddleware(route, list);
|
|
1584
|
+
mid.__keqMiddlewareName__ = `route(${route.__keqRouteName__ || route.name}, ${list.map(getMiddlewareName).join(", ")})`;
|
|
1585
|
+
return mid;
|
|
1586
|
+
}
|
|
1587
|
+
static host(host, middleware, ...additionalMiddlewares) {
|
|
1588
|
+
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1589
|
+
const mid = KeqRouter.buildMiddleware(keqHostRoute(host), list);
|
|
1590
|
+
mid.__keqMiddlewareName__ = `host(${JSON.stringify(host)}, ${list.map(getMiddlewareName).join(", ")})`;
|
|
1591
|
+
return mid;
|
|
1592
|
+
}
|
|
1593
|
+
static method(method, middleware, ...additionalMiddlewares) {
|
|
1594
|
+
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1595
|
+
const mid = KeqRouter.buildMiddleware(keqMethodRoute(method), list);
|
|
1596
|
+
mid.__keqMiddlewareName__ = `method(${JSON.stringify(method)}, ${list.map(getMiddlewareName).join(", ")})`;
|
|
1597
|
+
return mid;
|
|
1598
|
+
}
|
|
1599
|
+
static pathname(pathname, middleware, ...additionalMiddlewares) {
|
|
1600
|
+
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1601
|
+
const mid = KeqRouter.buildMiddleware(keqPathnameRoute(pathname), list);
|
|
1602
|
+
mid.__keqMiddlewareName__ = `pathname(${JSON.stringify(pathname)}, ${list.map(getMiddlewareName).join(", ")})`;
|
|
1603
|
+
return mid;
|
|
1604
|
+
}
|
|
1605
|
+
static location(middleware, ...additionalMiddlewares) {
|
|
1606
|
+
const list = Array.isArray(middleware) ? middleware : [middleware, ...additionalMiddlewares];
|
|
1607
|
+
const mid = KeqRouter.buildMiddleware(keqLocationRoute(), list);
|
|
1608
|
+
mid.__keqMiddlewareName__ = `location(${list.map(getMiddlewareName).join(", ")})`;
|
|
1609
|
+
return mid;
|
|
1610
|
+
}
|
|
1768
1611
|
};
|
|
1769
|
-
|
|
1770
|
-
|
|
1612
|
+
//#endregion
|
|
1613
|
+
//#region src/middlewares/timeout-middleware/index.ts
|
|
1771
1614
|
function keqTimeoutMiddleware() {
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1615
|
+
return async function timeoutMiddleware(ctx, next) {
|
|
1616
|
+
if (!ctx.options.timeout || ctx.options.timeout.millisecond <= 0) {
|
|
1617
|
+
await next();
|
|
1618
|
+
return;
|
|
1619
|
+
}
|
|
1620
|
+
const millisecond = ctx.options.timeout.millisecond;
|
|
1621
|
+
let timer;
|
|
1622
|
+
ctx.emitter.on("fetch:before", ({ context }) => {
|
|
1623
|
+
timer = setTimeout(() => {
|
|
1624
|
+
const err = new TimeoutException(`keq request timeout(${millisecond}ms)`);
|
|
1625
|
+
context.request.abort(err);
|
|
1626
|
+
context.emitter.emit("timeout", { context });
|
|
1627
|
+
}, millisecond);
|
|
1628
|
+
});
|
|
1629
|
+
ctx.emitter.on("fetch:after", () => {
|
|
1630
|
+
if (timer !== void 0) {
|
|
1631
|
+
clearTimeout(timer);
|
|
1632
|
+
timer = void 0;
|
|
1633
|
+
}
|
|
1634
|
+
});
|
|
1635
|
+
await next();
|
|
1636
|
+
};
|
|
1790
1637
|
}
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
var fastq = __toESM(require("fastq"));
|
|
1638
|
+
//#endregion
|
|
1639
|
+
//#region src/middlewares/flow-control-middleware/serial-flow-control-middleware.ts
|
|
1794
1640
|
function keqSerialFlowControlMiddleware() {
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
const queue = ctx.global.core.serialFlowControl[key];
|
|
1811
|
-
await queue.push({ next });
|
|
1812
|
-
};
|
|
1641
|
+
return async function serialFlowControlMiddleware(ctx, next) {
|
|
1642
|
+
if (!ctx.options.flowControl || !["serial", "concurrent"].includes(ctx.options.flowControl.mode)) {
|
|
1643
|
+
await next();
|
|
1644
|
+
return;
|
|
1645
|
+
}
|
|
1646
|
+
const { signal } = ctx.options.flowControl;
|
|
1647
|
+
const concurrent = ctx.options.flowControl.mode === "serial" ? 1 : !ctx.options.flowControl.concurrencyLimit || ctx.options.flowControl.concurrencyLimit < 1 ? 1 : Math.floor(ctx.options.flowControl.concurrencyLimit);
|
|
1648
|
+
const key = typeof signal === "string" ? signal : signal(ctx);
|
|
1649
|
+
if (!ctx.global.core) ctx.global.core = {};
|
|
1650
|
+
if (!ctx.global.core.serialFlowControl) ctx.global.core.serialFlowControl = {};
|
|
1651
|
+
if (!ctx.global.core.serialFlowControl[key]) ctx.global.core.serialFlowControl[key] = fastq.promise(async ({ next }) => {
|
|
1652
|
+
await next();
|
|
1653
|
+
}, concurrent);
|
|
1654
|
+
await ctx.global.core.serialFlowControl[key].push({ next });
|
|
1655
|
+
};
|
|
1813
1656
|
}
|
|
1814
|
-
|
|
1815
|
-
|
|
1657
|
+
//#endregion
|
|
1658
|
+
//#region src/middlewares/flow-control-middleware/abort-flow-control-middleware.ts
|
|
1816
1659
|
function keqAbortFlowControlMiddleware() {
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
if (ctx.global.core.abortFlowControl[key] === fn) {
|
|
1837
|
-
ctx.global.core.abortFlowControl[key] = void 0;
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
};
|
|
1660
|
+
return async function abortFlowControlMiddleware(ctx, next) {
|
|
1661
|
+
if (!ctx.options.flowControl || ctx.options.flowControl.mode !== "abort") {
|
|
1662
|
+
await next();
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
const { signal } = ctx.options.flowControl;
|
|
1666
|
+
const key = typeof signal === "string" ? signal : signal(ctx);
|
|
1667
|
+
if (!ctx.global.core) ctx.global.core = {};
|
|
1668
|
+
if (!ctx.global.core.abortFlowControl) ctx.global.core.abortFlowControl = {};
|
|
1669
|
+
const abort = ctx.global.core.abortFlowControl[key];
|
|
1670
|
+
if (abort) abort(new AbortException(`Previous request was aborted by AbortFlowControl with key "${key}"`));
|
|
1671
|
+
const fn = ctx.request.abort.bind(ctx.request);
|
|
1672
|
+
ctx.global.core.abortFlowControl[key] = fn;
|
|
1673
|
+
try {
|
|
1674
|
+
await next();
|
|
1675
|
+
} finally {
|
|
1676
|
+
if (ctx.global.core.abortFlowControl[key] === fn) ctx.global.core.abortFlowControl[key] = void 0;
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1841
1679
|
}
|
|
1842
|
-
|
|
1843
|
-
|
|
1680
|
+
//#endregion
|
|
1681
|
+
//#region src/middlewares/flow-control-middleware/mutex-flow-control-middleware.ts
|
|
1682
|
+
function keqMutexFlowControlMiddleware() {
|
|
1683
|
+
return async function mutexFlowControlMiddleware(ctx, next) {
|
|
1684
|
+
if (!ctx.options.flowControl || ctx.options.flowControl.mode !== "mutex") {
|
|
1685
|
+
await next();
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
const { signal } = ctx.options.flowControl;
|
|
1689
|
+
const key = typeof signal === "string" ? signal : signal(ctx);
|
|
1690
|
+
if (!ctx.global.core) ctx.global.core = {};
|
|
1691
|
+
if (!ctx.global.core.mutexFlowControl) ctx.global.core.mutexFlowControl = /* @__PURE__ */ new Set();
|
|
1692
|
+
if (ctx.global.core.mutexFlowControl.has(key)) throw new MutexException(`Request rejected by MutexFlowControl: a request with key "${key}" is already in-flight`);
|
|
1693
|
+
ctx.global.core.mutexFlowControl.add(key);
|
|
1694
|
+
try {
|
|
1695
|
+
await next();
|
|
1696
|
+
} finally {
|
|
1697
|
+
ctx.global.core.mutexFlowControl.delete(key);
|
|
1698
|
+
}
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
//#endregion
|
|
1702
|
+
//#region src/middlewares/flow-control-middleware/index.ts
|
|
1844
1703
|
function keqFlowControlMiddleware() {
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1704
|
+
return composeMiddleware([
|
|
1705
|
+
keqMutexFlowControlMiddleware(),
|
|
1706
|
+
keqSerialFlowControlMiddleware(),
|
|
1707
|
+
keqAbortFlowControlMiddleware()
|
|
1708
|
+
], { name: "flowControlMiddleware" });
|
|
1849
1709
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1710
|
+
//#endregion
|
|
1711
|
+
//#region src/middlewares/fetch-middleware/index.ts
|
|
1712
|
+
/**
|
|
1713
|
+
* Send Request
|
|
1714
|
+
*/
|
|
1852
1715
|
function keqFetchMiddleware() {
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1716
|
+
return async function fetchMiddleware(context) {
|
|
1717
|
+
const fetch = context.options.fetchAPI || globalThis.fetch;
|
|
1718
|
+
context.emitter.emit("fetch:before", { context });
|
|
1719
|
+
const response = await fetch(...context.request.toFetchArguments());
|
|
1720
|
+
context.emitter.emit("fetch:after", { context });
|
|
1721
|
+
context.res = response;
|
|
1722
|
+
};
|
|
1860
1723
|
}
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
getLocationId(1)
|
|
1966
|
-
);
|
|
1967
|
-
}
|
|
1968
|
-
use(firstMiddleware, ...middleware) {
|
|
1969
|
-
this.preMiddlewares.push(firstMiddleware, ...middleware);
|
|
1970
|
-
return this;
|
|
1971
|
-
}
|
|
1972
|
-
useRouter() {
|
|
1973
|
-
return new KeqRouter(this.preMiddlewares);
|
|
1974
|
-
}
|
|
1975
|
-
on(event, listener) {
|
|
1976
|
-
const middleware = async (context, next) => {
|
|
1977
|
-
context.emitter.on(event, listener);
|
|
1978
|
-
await next();
|
|
1979
|
-
};
|
|
1980
|
-
middleware.__keqMiddlewareName__ = "listen(".concat(event, ", ").concat(listener.name || "anonymous", ")");
|
|
1981
|
-
this.use(middleware);
|
|
1982
|
-
return this;
|
|
1983
|
-
}
|
|
1724
|
+
//#endregion
|
|
1725
|
+
//#region src/request/request.ts
|
|
1726
|
+
/**
|
|
1727
|
+
* Keq instance factory class,
|
|
1728
|
+
* and shares global data and middlewares across requests
|
|
1729
|
+
*/
|
|
1730
|
+
var KeqRequest = class KeqRequest {
|
|
1731
|
+
constructor(options) {
|
|
1732
|
+
_defineProperty(this, "baseOrigin", void 0);
|
|
1733
|
+
_defineProperty(this, "qs", void 0);
|
|
1734
|
+
_defineProperty(this, "global", {});
|
|
1735
|
+
_defineProperty(this, "middlewares", []);
|
|
1736
|
+
_defineProperty(this, "__terminalMiddlewares__", []);
|
|
1737
|
+
_defineProperty(this, "__parent__", void 0);
|
|
1738
|
+
if (options?.baseOrigin) this.baseOrigin = options.baseOrigin;
|
|
1739
|
+
else this.baseOrigin = Validator.isBrowser() ? location.origin : "http://127.0.0.1";
|
|
1740
|
+
this.qs = options?.qs;
|
|
1741
|
+
this.__terminalMiddlewares__ = options?.terminalMiddlewares || [
|
|
1742
|
+
keqFlowControlMiddleware(),
|
|
1743
|
+
keqTimeoutMiddleware(),
|
|
1744
|
+
keqFetchMiddleware()
|
|
1745
|
+
];
|
|
1746
|
+
this.middlewares = options?.middlewares || [];
|
|
1747
|
+
}
|
|
1748
|
+
__formatUrl__(url) {
|
|
1749
|
+
if (typeof url === "string") return new URL(url, this.baseOrigin);
|
|
1750
|
+
return new URL(url.href);
|
|
1751
|
+
}
|
|
1752
|
+
resolveMiddlewares() {
|
|
1753
|
+
if (!this.__parent__) return this.middlewares;
|
|
1754
|
+
return [...this.__parent__.resolveMiddlewares(), ...this.middlewares];
|
|
1755
|
+
}
|
|
1756
|
+
__fetch__(url, init, locationId) {
|
|
1757
|
+
return new Keq(this.__formatUrl__(url), {
|
|
1758
|
+
...init,
|
|
1759
|
+
locationId,
|
|
1760
|
+
global: this.global,
|
|
1761
|
+
qs: this.qs,
|
|
1762
|
+
middlewares: [...this.resolveMiddlewares(), ...this.__terminalMiddlewares__]
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
fetch(url, init) {
|
|
1766
|
+
return this.__fetch__(url, init, getLocationId(1));
|
|
1767
|
+
}
|
|
1768
|
+
get(url) {
|
|
1769
|
+
return this.__fetch__(url, { method: "get" }, getLocationId(1));
|
|
1770
|
+
}
|
|
1771
|
+
put(url) {
|
|
1772
|
+
return this.__fetch__(url, { method: "put" }, getLocationId(1));
|
|
1773
|
+
}
|
|
1774
|
+
delete(url) {
|
|
1775
|
+
return this.__fetch__(url, { method: "delete" }, getLocationId(1));
|
|
1776
|
+
}
|
|
1777
|
+
del(url) {
|
|
1778
|
+
return this.delete(url);
|
|
1779
|
+
}
|
|
1780
|
+
post(url) {
|
|
1781
|
+
return this.__fetch__(url, { method: "post" }, getLocationId(1));
|
|
1782
|
+
}
|
|
1783
|
+
head(url) {
|
|
1784
|
+
return this.__fetch__(url, { method: "head" }, getLocationId(1));
|
|
1785
|
+
}
|
|
1786
|
+
patch(url) {
|
|
1787
|
+
return this.__fetch__(url, { method: "patch" }, getLocationId(1));
|
|
1788
|
+
}
|
|
1789
|
+
options(url) {
|
|
1790
|
+
return this.__fetch__(url, { method: "options" }, getLocationId(1));
|
|
1791
|
+
}
|
|
1792
|
+
use(firstMiddleware, ...middleware) {
|
|
1793
|
+
this.middlewares.push(firstMiddleware, ...middleware);
|
|
1794
|
+
return this;
|
|
1795
|
+
}
|
|
1796
|
+
useRouter() {
|
|
1797
|
+
return new KeqRouter(this.middlewares);
|
|
1798
|
+
}
|
|
1799
|
+
fork(options) {
|
|
1800
|
+
const child = new KeqRequest({
|
|
1801
|
+
baseOrigin: options?.baseOrigin ?? this.baseOrigin,
|
|
1802
|
+
qs: options?.qs ?? (this.qs ? { ...this.qs } : void 0)
|
|
1803
|
+
});
|
|
1804
|
+
child.__parent__ = this;
|
|
1805
|
+
return child;
|
|
1806
|
+
}
|
|
1807
|
+
inherit(parent) {
|
|
1808
|
+
this.__parent__ = parent;
|
|
1809
|
+
return this;
|
|
1810
|
+
}
|
|
1811
|
+
adopt(child) {
|
|
1812
|
+
child.__parent__ = this;
|
|
1813
|
+
return this;
|
|
1814
|
+
}
|
|
1815
|
+
/** @deprecated Use `middlewares` instead */
|
|
1816
|
+
get preMiddlewares() {
|
|
1817
|
+
return this.middlewares;
|
|
1818
|
+
}
|
|
1819
|
+
on(event, listener) {
|
|
1820
|
+
const middleware = async (context, next) => {
|
|
1821
|
+
context.emitter.on(event, listener);
|
|
1822
|
+
await next();
|
|
1823
|
+
};
|
|
1824
|
+
middleware.__keqMiddlewareName__ = `listen(${event}, ${listener.name || "anonymous"})`;
|
|
1825
|
+
this.use(middleware);
|
|
1826
|
+
return this;
|
|
1827
|
+
}
|
|
1984
1828
|
};
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1829
|
+
const request = new KeqRequest();
|
|
1830
|
+
//#endregion
|
|
1831
|
+
//#region src/request/create-request.ts
|
|
1832
|
+
/**
|
|
1833
|
+
* @deprecated use new KeqRequest<SCHEMA>(options) instead
|
|
1834
|
+
*/
|
|
1988
1835
|
function createRequest(options) {
|
|
1989
|
-
|
|
1836
|
+
return new KeqRequest(options);
|
|
1990
1837
|
}
|
|
1838
|
+
//#endregion
|
|
1839
|
+
exports.AbortException = AbortException;
|
|
1840
|
+
exports.BadGatewayException = BadGatewayException;
|
|
1841
|
+
exports.BadRequestException = BadRequestException;
|
|
1842
|
+
exports.ConflictException = ConflictException;
|
|
1843
|
+
exports.ContentTooLargeException = ContentTooLargeException;
|
|
1844
|
+
exports.Exception = Exception;
|
|
1845
|
+
exports.ForbiddenException = ForbiddenException;
|
|
1846
|
+
exports.GatewayTimeoutException = GatewayTimeoutException;
|
|
1847
|
+
exports.ImATeapotException = ImATeapotException;
|
|
1848
|
+
exports.InternalServerErrorException = InternalServerErrorException;
|
|
1849
|
+
exports.Keq = Keq;
|
|
1850
|
+
exports.KeqExecutionContext = KeqExecutionContext;
|
|
1851
|
+
exports.KeqMiddlewareExecutor = KeqMiddlewareExecutor;
|
|
1852
|
+
exports.KeqMiddlewareOrchestrator = KeqMiddlewareOrchestrator;
|
|
1853
|
+
exports.KeqRequest = KeqRequest;
|
|
1854
|
+
exports.KeqSharedContext = KeqSharedContext;
|
|
1855
|
+
exports.MethodNotAllowedException = MethodNotAllowedException;
|
|
1856
|
+
exports.NotAcceptableException = NotAcceptableException;
|
|
1857
|
+
exports.NotFoundedException = NotFoundedException;
|
|
1858
|
+
exports.NotImplementedException = NotImplementedException;
|
|
1859
|
+
exports.PreconditionFailedException = PreconditionFailedException;
|
|
1860
|
+
exports.ProxyAuthenticationRequiredException = ProxyAuthenticationRequiredException;
|
|
1861
|
+
exports.RequestException = RequestException;
|
|
1862
|
+
exports.RequestTimeoutException = RequestTimeoutException;
|
|
1863
|
+
exports.ServiceUnavailableException = ServiceUnavailableException;
|
|
1864
|
+
exports.TimeoutException = TimeoutException;
|
|
1865
|
+
exports.TooManyRequestsException = TooManyRequestsException;
|
|
1866
|
+
exports.TypeException = TypeException;
|
|
1867
|
+
exports.UnauthorizedException = UnauthorizedException;
|
|
1868
|
+
exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException;
|
|
1869
|
+
exports.UriTooLongException = UriTooLongException;
|
|
1870
|
+
exports.composeMiddleware = composeMiddleware;
|
|
1871
|
+
exports.composeRoute = composeRoute;
|
|
1872
|
+
exports.createProxyResponse = createProxyResponse;
|
|
1873
|
+
exports.createRequest = createRequest;
|
|
1874
|
+
exports.request = request;
|
|
1875
|
+
|
|
1991
1876
|
//# sourceMappingURL=index.js.map
|