ali-skills 0.0.21 → 0.0.23
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/node_modules/@ali/cli-skills/dist/cli.mjs +1410 -316
- package/node_modules/@ali/cli-skills/package.json +5 -2
- package/node_modules/@ali/o2-open-client/.editorconfig +11 -0
- package/node_modules/@ali/o2-open-client/README.md +80 -0
- package/node_modules/@ali/o2-open-client/abc.json +8 -0
- package/node_modules/@ali/o2-open-client/es/browser/ee.d.ts +23 -0
- package/node_modules/@ali/o2-open-client/es/browser/ee.js +82 -0
- package/node_modules/@ali/o2-open-client/es/browser/entry.d.ts +32 -0
- package/node_modules/@ali/o2-open-client/es/browser/entry.js +306 -0
- package/node_modules/@ali/o2-open-client/es/browser/escape.d.ts +12 -0
- package/node_modules/@ali/o2-open-client/es/browser/escape.js +178 -0
- package/node_modules/@ali/o2-open-client/es/browser/fetch.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/browser/fetch.js +14 -0
- package/node_modules/@ali/o2-open-client/es/browser/index.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/browser/index.js +1 -0
- package/node_modules/@ali/o2-open-client/es/common/constant.d.ts +42 -0
- package/node_modules/@ali/o2-open-client/es/common/constant.js +53 -0
- package/node_modules/@ali/o2-open-client/es/common/format.d.ts +14 -0
- package/node_modules/@ali/o2-open-client/es/common/format.js +43 -0
- package/node_modules/@ali/o2-open-client/es/common/service-meta.d.ts +33 -0
- package/node_modules/@ali/o2-open-client/es/common/service-meta.js +33 -0
- package/node_modules/@ali/o2-open-client/es/index.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/index.js +8 -0
- package/node_modules/@ali/o2-open-client/es/node/config.d.ts +47 -0
- package/node_modules/@ali/o2-open-client/es/node/config.js +188 -0
- package/node_modules/@ali/o2-open-client/es/node/escape.d.ts +22 -0
- package/node_modules/@ali/o2-open-client/es/node/escape.js +131 -0
- package/node_modules/@ali/o2-open-client/es/node/help.d.ts +10 -0
- package/node_modules/@ali/o2-open-client/es/node/help.js +96 -0
- package/node_modules/@ali/o2-open-client/es/node/index.d.ts +48 -0
- package/node_modules/@ali/o2-open-client/es/node/index.js +247 -0
- package/node_modules/@ali/o2-open-client/es/node/token-handler.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/node/token-handler.js +21 -0
- package/node_modules/@ali/o2-open-client/lib/browser/ee.d.ts +23 -0
- package/node_modules/@ali/o2-open-client/lib/browser/ee.js +86 -0
- package/node_modules/@ali/o2-open-client/lib/browser/entry.d.ts +32 -0
- package/node_modules/@ali/o2-open-client/lib/browser/entry.js +310 -0
- package/node_modules/@ali/o2-open-client/lib/browser/escape.d.ts +12 -0
- package/node_modules/@ali/o2-open-client/lib/browser/escape.js +185 -0
- package/node_modules/@ali/o2-open-client/lib/browser/fetch.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/lib/browser/fetch.js +18 -0
- package/node_modules/@ali/o2-open-client/lib/common/constant.d.ts +42 -0
- package/node_modules/@ali/o2-open-client/lib/common/constant.js +56 -0
- package/node_modules/@ali/o2-open-client/lib/common/format.d.ts +14 -0
- package/node_modules/@ali/o2-open-client/lib/common/format.js +48 -0
- package/node_modules/@ali/o2-open-client/lib/common/service-meta.d.ts +33 -0
- package/node_modules/@ali/o2-open-client/lib/common/service-meta.js +36 -0
- package/node_modules/@ali/o2-open-client/lib/index.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/lib/index.js +20 -0
- package/node_modules/@ali/o2-open-client/lib/node/config.d.ts +47 -0
- package/node_modules/@ali/o2-open-client/lib/node/config.js +192 -0
- package/node_modules/@ali/o2-open-client/lib/node/escape.d.ts +22 -0
- package/node_modules/@ali/o2-open-client/lib/node/escape.js +137 -0
- package/node_modules/@ali/o2-open-client/lib/node/help.d.ts +10 -0
- package/node_modules/@ali/o2-open-client/lib/node/help.js +100 -0
- package/node_modules/@ali/o2-open-client/lib/node/index.d.ts +48 -0
- package/node_modules/@ali/o2-open-client/lib/node/index.js +250 -0
- package/node_modules/@ali/o2-open-client/lib/node/token-handler.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/lib/node/token-handler.js +25 -0
- package/node_modules/@ali/o2-open-client/package.json +46 -0
- package/node_modules/@ali/o2-open-client/playwright.config.ts +54 -0
- package/node_modules/@ali/o2-open-client/tsconfig.es.json +31 -0
- package/node_modules/@ali/o2-open-client/tsconfig.json +31 -0
- package/node_modules/@ali/o2-open-client/tsx2doc.config.js +5 -0
- package/node_modules/@ali/o2-open-client/typings/index.d.ts +36 -0
- package/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/@types/node/README.md +15 -0
- package/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/node_modules/@types/node/assert.d.ts +1062 -0
- package/node_modules/@types/node/async_hooks.d.ts +605 -0
- package/node_modules/@types/node/buffer.buffer.d.ts +471 -0
- package/node_modules/@types/node/buffer.d.ts +1936 -0
- package/node_modules/@types/node/child_process.d.ts +1475 -0
- package/node_modules/@types/node/cluster.d.ts +577 -0
- package/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
- package/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/node_modules/@types/node/console.d.ts +452 -0
- package/node_modules/@types/node/constants.d.ts +21 -0
- package/node_modules/@types/node/crypto.d.ts +4590 -0
- package/node_modules/@types/node/dgram.d.ts +597 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
- package/node_modules/@types/node/dns/promises.d.ts +479 -0
- package/node_modules/@types/node/dns.d.ts +871 -0
- package/node_modules/@types/node/domain.d.ts +170 -0
- package/node_modules/@types/node/events.d.ts +977 -0
- package/node_modules/@types/node/fs/promises.d.ts +1270 -0
- package/node_modules/@types/node/fs.d.ts +4375 -0
- package/node_modules/@types/node/globals.d.ts +172 -0
- package/node_modules/@types/node/globals.typedarray.d.ts +38 -0
- package/node_modules/@types/node/http.d.ts +2049 -0
- package/node_modules/@types/node/http2.d.ts +2631 -0
- package/node_modules/@types/node/https.d.ts +578 -0
- package/node_modules/@types/node/index.d.ts +93 -0
- package/node_modules/@types/node/inspector.generated.d.ts +3966 -0
- package/node_modules/@types/node/module.d.ts +539 -0
- package/node_modules/@types/node/net.d.ts +1031 -0
- package/node_modules/@types/node/os.d.ts +506 -0
- package/node_modules/@types/node/package.json +140 -0
- package/node_modules/@types/node/path.d.ts +200 -0
- package/node_modules/@types/node/perf_hooks.d.ts +961 -0
- package/node_modules/@types/node/process.d.ts +1961 -0
- package/node_modules/@types/node/punycode.d.ts +117 -0
- package/node_modules/@types/node/querystring.d.ts +152 -0
- package/node_modules/@types/node/readline/promises.d.ts +162 -0
- package/node_modules/@types/node/readline.d.ts +589 -0
- package/node_modules/@types/node/repl.d.ts +430 -0
- package/node_modules/@types/node/sea.d.ts +153 -0
- package/node_modules/@types/node/stream/consumers.d.ts +38 -0
- package/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/node_modules/@types/node/stream/web.d.ts +533 -0
- package/node_modules/@types/node/stream.d.ts +1698 -0
- package/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/node_modules/@types/node/test.d.ts +1787 -0
- package/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/node_modules/@types/node/timers.d.ts +286 -0
- package/node_modules/@types/node/tls.d.ts +1259 -0
- package/node_modules/@types/node/trace_events.d.ts +197 -0
- package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
- package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
- package/node_modules/@types/node/ts5.6/index.d.ts +93 -0
- package/node_modules/@types/node/tty.d.ts +208 -0
- package/node_modules/@types/node/url.d.ts +964 -0
- package/node_modules/@types/node/util.d.ts +2331 -0
- package/node_modules/@types/node/v8.d.ts +809 -0
- package/node_modules/@types/node/vm.d.ts +1001 -0
- package/node_modules/@types/node/wasi.d.ts +181 -0
- package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
- package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/node_modules/@types/node/web-globals/events.d.ts +97 -0
- package/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
- package/node_modules/@types/node/worker_threads.d.ts +715 -0
- package/node_modules/@types/node/zlib.d.ts +598 -0
- package/node_modules/ansi-styles/index.d.ts +345 -0
- package/node_modules/ansi-styles/index.js +163 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +56 -0
- package/node_modules/ansi-styles/readme.md +152 -0
- package/node_modules/await-event/LICENSE +22 -0
- package/node_modules/await-event/README.md +48 -0
- package/node_modules/await-event/index.js +13 -0
- package/node_modules/await-event/package.json +33 -0
- package/node_modules/await-first/LICENSE +21 -0
- package/node_modules/await-first/README.md +80 -0
- package/node_modules/await-first/lib/index.js +21 -0
- package/node_modules/await-first/package.json +49 -0
- package/node_modules/byte/LICENSE.txt +21 -0
- package/node_modules/byte/README.md +207 -0
- package/node_modules/byte/lib/byte.js +635 -0
- package/node_modules/byte/lib/number.js +82 -0
- package/node_modules/byte/package.json +61 -0
- package/node_modules/chalk/index.d.ts +415 -0
- package/node_modules/chalk/license +9 -0
- package/node_modules/chalk/package.json +68 -0
- package/node_modules/chalk/readme.md +341 -0
- package/node_modules/chalk/source/index.js +229 -0
- package/node_modules/chalk/source/templates.js +134 -0
- package/node_modules/chalk/source/util.js +39 -0
- package/node_modules/circular-json-for-egg/LICENSE.txt +19 -0
- package/node_modules/circular-json-for-egg/README.md +148 -0
- package/node_modules/circular-json-for-egg/build/circular-json.amd.js +2 -0
- package/node_modules/circular-json-for-egg/build/circular-json.js +2 -0
- package/node_modules/circular-json-for-egg/build/circular-json.max.amd.js +210 -0
- package/node_modules/circular-json-for-egg/build/circular-json.max.js +210 -0
- package/node_modules/circular-json-for-egg/build/circular-json.node.js +207 -0
- package/node_modules/circular-json-for-egg/package.json +42 -0
- package/node_modules/cluster-client/LICENSE +21 -0
- package/node_modules/cluster-client/README.md +319 -0
- package/node_modules/cluster-client/index.js +66 -0
- package/node_modules/cluster-client/lib/api_client.js +74 -0
- package/node_modules/cluster-client/lib/connection.js +180 -0
- package/node_modules/cluster-client/lib/const.js +5 -0
- package/node_modules/cluster-client/lib/default_logger.js +11 -0
- package/node_modules/cluster-client/lib/default_transcode.js +6 -0
- package/node_modules/cluster-client/lib/follower.js +331 -0
- package/node_modules/cluster-client/lib/index.js +213 -0
- package/node_modules/cluster-client/lib/leader.js +437 -0
- package/node_modules/cluster-client/lib/protocol/byte_buffer.js +8 -0
- package/node_modules/cluster-client/lib/protocol/packet.js +103 -0
- package/node_modules/cluster-client/lib/protocol/request.js +17 -0
- package/node_modules/cluster-client/lib/protocol/response.js +14 -0
- package/node_modules/cluster-client/lib/server.js +256 -0
- package/node_modules/cluster-client/lib/symbol.js +20 -0
- package/node_modules/cluster-client/lib/utils.js +103 -0
- package/node_modules/cluster-client/lib/wrapper/base.js +210 -0
- package/node_modules/cluster-client/lib/wrapper/cluster.js +57 -0
- package/node_modules/cluster-client/lib/wrapper/single.js +192 -0
- package/node_modules/cluster-client/package.json +60 -0
- package/node_modules/co/LICENSE +22 -0
- package/node_modules/co/Readme.md +212 -0
- package/node_modules/co/index.js +237 -0
- package/node_modules/co/package.json +34 -0
- package/node_modules/color-convert/LICENSE +21 -0
- package/node_modules/color-convert/README.md +68 -0
- package/node_modules/color-convert/conversions.js +839 -0
- package/node_modules/color-convert/index.js +81 -0
- package/node_modules/color-convert/package.json +48 -0
- package/node_modules/color-convert/route.js +97 -0
- package/node_modules/color-name/LICENSE +8 -0
- package/node_modules/color-name/README.md +11 -0
- package/node_modules/color-name/index.js +152 -0
- package/node_modules/color-name/package.json +28 -0
- package/node_modules/core-util-is/LICENSE +19 -0
- package/node_modules/core-util-is/README.md +3 -0
- package/node_modules/core-util-is/lib/util.js +107 -0
- package/node_modules/core-util-is/package.json +38 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/depd/History.md +103 -0
- package/node_modules/depd/LICENSE +22 -0
- package/node_modules/depd/Readme.md +280 -0
- package/node_modules/depd/index.js +538 -0
- package/node_modules/depd/lib/browser/index.js +77 -0
- package/node_modules/depd/package.json +45 -0
- package/node_modules/ee-first/LICENSE +22 -0
- package/node_modules/ee-first/README.md +80 -0
- package/node_modules/ee-first/index.js +95 -0
- package/node_modules/ee-first/package.json +29 -0
- package/node_modules/egg-errors/LICENSE +21 -0
- package/node_modules/egg-errors/README.md +259 -0
- package/node_modules/egg-errors/lib/base.d.ts +10 -0
- package/node_modules/egg-errors/lib/base.js +28 -0
- package/node_modules/egg-errors/lib/base_error.d.ts +6 -0
- package/node_modules/egg-errors/lib/base_error.js +13 -0
- package/node_modules/egg-errors/lib/base_exception.d.ts +6 -0
- package/node_modules/egg-errors/lib/base_exception.js +13 -0
- package/node_modules/egg-errors/lib/error.d.ts +6 -0
- package/node_modules/egg-errors/lib/error.js +13 -0
- package/node_modules/egg-errors/lib/error_options.d.ts +5 -0
- package/node_modules/egg-errors/lib/error_options.js +6 -0
- package/node_modules/egg-errors/lib/error_type.d.ts +6 -0
- package/node_modules/egg-errors/lib/error_type.js +10 -0
- package/node_modules/egg-errors/lib/exception.d.ts +6 -0
- package/node_modules/egg-errors/lib/exception.js +13 -0
- package/node_modules/egg-errors/lib/framework/formatter.d.ts +6 -0
- package/node_modules/egg-errors/lib/framework/formatter.js +29 -0
- package/node_modules/egg-errors/lib/framework/framework_base_error.d.ts +10 -0
- package/node_modules/egg-errors/lib/framework/framework_base_error.js +32 -0
- package/node_modules/egg-errors/lib/http/400.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/400.js +13 -0
- package/node_modules/egg-errors/lib/http/401.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/401.js +13 -0
- package/node_modules/egg-errors/lib/http/402.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/402.js +13 -0
- package/node_modules/egg-errors/lib/http/403.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/403.js +13 -0
- package/node_modules/egg-errors/lib/http/404.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/404.js +13 -0
- package/node_modules/egg-errors/lib/http/405.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/405.js +13 -0
- package/node_modules/egg-errors/lib/http/406.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/406.js +13 -0
- package/node_modules/egg-errors/lib/http/407.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/407.js +13 -0
- package/node_modules/egg-errors/lib/http/408.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/408.js +13 -0
- package/node_modules/egg-errors/lib/http/409.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/409.js +13 -0
- package/node_modules/egg-errors/lib/http/410.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/410.js +13 -0
- package/node_modules/egg-errors/lib/http/411.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/411.js +13 -0
- package/node_modules/egg-errors/lib/http/412.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/412.js +13 -0
- package/node_modules/egg-errors/lib/http/413.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/413.js +13 -0
- package/node_modules/egg-errors/lib/http/414.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/414.js +13 -0
- package/node_modules/egg-errors/lib/http/415.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/415.js +13 -0
- package/node_modules/egg-errors/lib/http/416.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/416.js +13 -0
- package/node_modules/egg-errors/lib/http/417.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/417.js +13 -0
- package/node_modules/egg-errors/lib/http/418.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/418.js +13 -0
- package/node_modules/egg-errors/lib/http/421.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/421.js +13 -0
- package/node_modules/egg-errors/lib/http/422.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/422.js +13 -0
- package/node_modules/egg-errors/lib/http/423.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/423.js +13 -0
- package/node_modules/egg-errors/lib/http/424.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/424.js +13 -0
- package/node_modules/egg-errors/lib/http/425.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/425.js +13 -0
- package/node_modules/egg-errors/lib/http/426.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/426.js +13 -0
- package/node_modules/egg-errors/lib/http/428.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/428.js +13 -0
- package/node_modules/egg-errors/lib/http/429.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/429.js +13 -0
- package/node_modules/egg-errors/lib/http/431.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/431.js +13 -0
- package/node_modules/egg-errors/lib/http/451.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/451.js +13 -0
- package/node_modules/egg-errors/lib/http/500.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/500.js +13 -0
- package/node_modules/egg-errors/lib/http/501.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/501.js +13 -0
- package/node_modules/egg-errors/lib/http/502.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/502.js +13 -0
- package/node_modules/egg-errors/lib/http/503.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/503.js +13 -0
- package/node_modules/egg-errors/lib/http/504.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/504.js +13 -0
- package/node_modules/egg-errors/lib/http/505.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/505.js +13 -0
- package/node_modules/egg-errors/lib/http/506.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/506.js +13 -0
- package/node_modules/egg-errors/lib/http/507.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/507.js +13 -0
- package/node_modules/egg-errors/lib/http/508.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/508.js +13 -0
- package/node_modules/egg-errors/lib/http/509.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/509.js +13 -0
- package/node_modules/egg-errors/lib/http/510.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/510.js +13 -0
- package/node_modules/egg-errors/lib/http/511.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/511.js +13 -0
- package/node_modules/egg-errors/lib/http/http_error.d.ts +10 -0
- package/node_modules/egg-errors/lib/http/http_error.js +13 -0
- package/node_modules/egg-errors/lib/http/http_error_options.d.ts +6 -0
- package/node_modules/egg-errors/lib/http/http_error_options.js +7 -0
- package/node_modules/egg-errors/lib/http/http_header.d.ts +3 -0
- package/node_modules/egg-errors/lib/http/http_header.js +3 -0
- package/node_modules/egg-errors/lib/index.d.ts +50 -0
- package/node_modules/egg-errors/lib/index.js +149 -0
- package/node_modules/egg-errors/package.json +49 -0
- package/node_modules/egg-logger/LICENSE +21 -0
- package/node_modules/egg-logger/README.md +128 -0
- package/node_modules/egg-logger/README.zh-CN.md +125 -0
- package/node_modules/egg-logger/index.d.ts +233 -0
- package/node_modules/egg-logger/index.js +18 -0
- package/node_modules/egg-logger/lib/egg/console_logger.js +36 -0
- package/node_modules/egg-logger/lib/egg/context_logger.js +43 -0
- package/node_modules/egg-logger/lib/egg/custom_logger.js +10 -0
- package/node_modules/egg-logger/lib/egg/error_logger.js +31 -0
- package/node_modules/egg-logger/lib/egg/logger.js +128 -0
- package/node_modules/egg-logger/lib/egg/loggers.js +163 -0
- package/node_modules/egg-logger/lib/level.js +34 -0
- package/node_modules/egg-logger/lib/logger.js +170 -0
- package/node_modules/egg-logger/lib/transports/console.js +52 -0
- package/node_modules/egg-logger/lib/transports/file.js +134 -0
- package/node_modules/egg-logger/lib/transports/file_buffer.js +113 -0
- package/node_modules/egg-logger/lib/transports/transport.js +129 -0
- package/node_modules/egg-logger/lib/utils.js +296 -0
- package/node_modules/egg-logger/package.json +54 -0
- package/node_modules/escape-html/LICENSE +24 -0
- package/node_modules/escape-html/Readme.md +43 -0
- package/node_modules/escape-html/index.js +78 -0
- package/node_modules/escape-html/package.json +24 -0
- package/node_modules/extend-shallow/LICENSE +21 -0
- package/node_modules/extend-shallow/README.md +61 -0
- package/node_modules/extend-shallow/index.js +33 -0
- package/node_modules/extend-shallow/package.json +56 -0
- package/node_modules/has-flag/index.d.ts +39 -0
- package/node_modules/has-flag/index.js +8 -0
- package/node_modules/has-flag/license +9 -0
- package/node_modules/has-flag/package.json +46 -0
- package/node_modules/has-flag/readme.md +89 -0
- package/node_modules/heartbeats/.eslintrc +151 -0
- package/node_modules/heartbeats/.npmignore +28 -0
- package/node_modules/heartbeats/.travis.yml +10 -0
- package/node_modules/heartbeats/LICENSE +21 -0
- package/node_modules/heartbeats/README.md +323 -0
- package/node_modules/heartbeats/lib/beatevent.js +35 -0
- package/node_modules/heartbeats/lib/heart.js +178 -0
- package/node_modules/heartbeats/lib/pulse.js +39 -0
- package/node_modules/heartbeats/main.js +34 -0
- package/node_modules/heartbeats/package.json +39 -0
- package/node_modules/heartbeats/test/benchmark.js +138 -0
- package/node_modules/heartbeats/test/spawn.js +16 -0
- package/node_modules/heartbeats/test/test.js +158 -0
- package/node_modules/httpx/README.md +96 -0
- package/node_modules/httpx/lib/index.d.ts +31 -0
- package/node_modules/httpx/lib/index.js +396 -0
- package/node_modules/httpx/package.json +36 -0
- package/node_modules/iconv-lite/.github/dependabot.yml +11 -0
- package/node_modules/iconv-lite/.idea/codeStyles/Project.xml +47 -0
- package/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/node_modules/iconv-lite/.idea/iconv-lite.iml +12 -0
- package/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/node_modules/iconv-lite/.idea/modules.xml +8 -0
- package/node_modules/iconv-lite/.idea/vcs.xml +6 -0
- package/node_modules/iconv-lite/Changelog.md +212 -0
- package/node_modules/iconv-lite/LICENSE +21 -0
- package/node_modules/iconv-lite/README.md +130 -0
- package/node_modules/iconv-lite/encodings/dbcs-codec.js +597 -0
- package/node_modules/iconv-lite/encodings/dbcs-data.js +188 -0
- package/node_modules/iconv-lite/encodings/index.js +23 -0
- package/node_modules/iconv-lite/encodings/internal.js +198 -0
- package/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
- package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/node_modules/iconv-lite/encodings/sbcs-data.js +179 -0
- package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/node_modules/iconv-lite/encodings/utf16.js +197 -0
- package/node_modules/iconv-lite/encodings/utf32.js +319 -0
- package/node_modules/iconv-lite/encodings/utf7.js +290 -0
- package/node_modules/iconv-lite/lib/bom-handling.js +52 -0
- package/node_modules/iconv-lite/lib/index.d.ts +41 -0
- package/node_modules/iconv-lite/lib/index.js +180 -0
- package/node_modules/iconv-lite/lib/streams.js +109 -0
- package/node_modules/iconv-lite/package.json +44 -0
- package/node_modules/ip/README.md +90 -0
- package/node_modules/ip/lib/ip.js +496 -0
- package/node_modules/ip/package.json +25 -0
- package/node_modules/is-class-hotfix/.editorconfig +23 -0
- package/node_modules/is-class-hotfix/.gitattributes +2 -0
- package/node_modules/is-class-hotfix/CHANGELOG.md +7 -0
- package/node_modules/is-class-hotfix/LICENSE.md +21 -0
- package/node_modules/is-class-hotfix/README.md +35 -0
- package/node_modules/is-class-hotfix/bower.json +24 -0
- package/node_modules/is-class-hotfix/is-class.js +28 -0
- package/node_modules/is-class-hotfix/package.json +31 -0
- package/node_modules/is-class-hotfix/test/babel-class.js +27 -0
- package/node_modules/is-class-hotfix/test/is-class.js +31 -0
- package/node_modules/is-extendable/LICENSE +21 -0
- package/node_modules/is-extendable/README.md +72 -0
- package/node_modules/is-extendable/index.js +13 -0
- package/node_modules/is-extendable/package.json +51 -0
- package/node_modules/is-type-of/LICENSE +21 -0
- package/node_modules/is-type-of/README.md +105 -0
- package/node_modules/is-type-of/index.d.ts +65 -0
- package/node_modules/is-type-of/index.js +125 -0
- package/node_modules/is-type-of/package.json +45 -0
- package/node_modules/isstream/.jshintrc +59 -0
- package/node_modules/isstream/.npmignore +1 -0
- package/node_modules/isstream/.travis.yml +12 -0
- package/node_modules/isstream/LICENSE.md +11 -0
- package/node_modules/isstream/README.md +66 -0
- package/node_modules/isstream/isstream.js +27 -0
- package/node_modules/isstream/package.json +33 -0
- package/node_modules/isstream/test.js +168 -0
- package/node_modules/json-stringify-safe/.npmignore +1 -0
- package/node_modules/json-stringify-safe/CHANGELOG.md +14 -0
- package/node_modules/json-stringify-safe/LICENSE +15 -0
- package/node_modules/json-stringify-safe/Makefile +35 -0
- package/node_modules/json-stringify-safe/README.md +52 -0
- package/node_modules/json-stringify-safe/package.json +31 -0
- package/node_modules/json-stringify-safe/stringify.js +27 -0
- package/node_modules/json-stringify-safe/test/mocha.opts +2 -0
- package/node_modules/json-stringify-safe/test/stringify_test.js +246 -0
- package/node_modules/kitx/LICENSE +21 -0
- package/node_modules/kitx/README.md +35 -0
- package/node_modules/kitx/lib/index.d.ts +45 -0
- package/node_modules/kitx/lib/index.js +289 -0
- package/node_modules/kitx/package.json +41 -0
- package/node_modules/long/LICENSE +202 -0
- package/node_modules/long/README.md +246 -0
- package/node_modules/long/dist/long.js +2 -0
- package/node_modules/long/dist/long.js.map +1 -0
- package/node_modules/long/index.js +1 -0
- package/node_modules/long/package.json +34 -0
- package/node_modules/long/src/long.js +1323 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/p-timeout/index.d.ts +113 -0
- package/node_modules/p-timeout/index.js +71 -0
- package/node_modules/p-timeout/license +9 -0
- package/node_modules/p-timeout/package.json +44 -0
- package/node_modules/p-timeout/readme.md +117 -0
- package/node_modules/safer-buffer/LICENSE +21 -0
- package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/node_modules/safer-buffer/Readme.md +156 -0
- package/node_modules/safer-buffer/dangerous.js +58 -0
- package/node_modules/safer-buffer/package.json +34 -0
- package/node_modules/safer-buffer/safer.js +77 -0
- package/node_modules/safer-buffer/tests.js +406 -0
- package/node_modules/sdk-base/LICENSE +21 -0
- package/node_modules/sdk-base/README.md +165 -0
- package/node_modules/sdk-base/index.d.ts +29 -0
- package/node_modules/sdk-base/index.js +251 -0
- package/node_modules/sdk-base/package.json +54 -0
- package/node_modules/serialize-json/LICENSE +21 -0
- package/node_modules/serialize-json/README.md +74 -0
- package/node_modules/serialize-json/lib/decoder.js +190 -0
- package/node_modules/serialize-json/lib/encoder.js +200 -0
- package/node_modules/serialize-json/lib/index.js +15 -0
- package/node_modules/serialize-json/package.json +53 -0
- package/node_modules/supports-color/browser.js +5 -0
- package/node_modules/supports-color/index.js +135 -0
- package/node_modules/supports-color/license +9 -0
- package/node_modules/supports-color/package.json +53 -0
- package/node_modules/supports-color/readme.md +76 -0
- package/node_modules/tcp-base/LICENSE +21 -0
- package/node_modules/tcp-base/README.md +134 -0
- package/node_modules/tcp-base/lib/base.js +456 -0
- package/node_modules/tcp-base/package.json +44 -0
- package/node_modules/undici-types/LICENSE +21 -0
- package/node_modules/undici-types/README.md +6 -0
- package/node_modules/undici-types/agent.d.ts +31 -0
- package/node_modules/undici-types/api.d.ts +43 -0
- package/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/node_modules/undici-types/cache.d.ts +36 -0
- package/node_modules/undici-types/client.d.ts +108 -0
- package/node_modules/undici-types/connector.d.ts +34 -0
- package/node_modules/undici-types/content-type.d.ts +21 -0
- package/node_modules/undici-types/cookies.d.ts +28 -0
- package/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/node_modules/undici-types/dispatcher.d.ts +256 -0
- package/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/node_modules/undici-types/errors.d.ts +149 -0
- package/node_modules/undici-types/eventsource.d.ts +61 -0
- package/node_modules/undici-types/fetch.d.ts +209 -0
- package/node_modules/undici-types/file.d.ts +39 -0
- package/node_modules/undici-types/filereader.d.ts +54 -0
- package/node_modules/undici-types/formdata.d.ts +108 -0
- package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/node_modules/undici-types/global-origin.d.ts +7 -0
- package/node_modules/undici-types/handlers.d.ts +15 -0
- package/node_modules/undici-types/header.d.ts +4 -0
- package/node_modules/undici-types/index.d.ts +71 -0
- package/node_modules/undici-types/interceptors.d.ts +17 -0
- package/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/node_modules/undici-types/mock-client.d.ts +25 -0
- package/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/node_modules/undici-types/package.json +55 -0
- package/node_modules/undici-types/patch.d.ts +33 -0
- package/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/node_modules/undici-types/pool.d.ts +39 -0
- package/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/node_modules/undici-types/readable.d.ts +65 -0
- package/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/node_modules/undici-types/util.d.ts +18 -0
- package/node_modules/undici-types/webidl.d.ts +228 -0
- package/node_modules/undici-types/websocket.d.ts +150 -0
- package/node_modules/unescape/LICENSE +21 -0
- package/node_modules/unescape/README.md +134 -0
- package/node_modules/unescape/index.js +103 -0
- package/node_modules/unescape/package.json +67 -0
- package/node_modules/utility/LICENSE.txt +21 -0
- package/node_modules/utility/README.md +370 -0
- package/node_modules/utility/dist/commonjs/array.d.ts +11 -0
- package/node_modules/utility/dist/commonjs/array.js +46 -0
- package/node_modules/utility/dist/commonjs/crypto.d.ts +86 -0
- package/node_modules/utility/dist/commonjs/crypto.js +159 -0
- package/node_modules/utility/dist/commonjs/date.d.ts +63 -0
- package/node_modules/utility/dist/commonjs/date.js +219 -0
- package/node_modules/utility/dist/commonjs/fs.d.ts +6 -0
- package/node_modules/utility/dist/commonjs/fs.js +20 -0
- package/node_modules/utility/dist/commonjs/function.d.ts +12 -0
- package/node_modules/utility/dist/commonjs/function.js +35 -0
- package/node_modules/utility/dist/commonjs/index.d.ts +12 -0
- package/node_modules/utility/dist/commonjs/index.js +29 -0
- package/node_modules/utility/dist/commonjs/json.d.ts +14 -0
- package/node_modules/utility/dist/commonjs/json.js +41 -0
- package/node_modules/utility/dist/commonjs/number.d.ts +24 -0
- package/node_modules/utility/dist/commonjs/number.js +66 -0
- package/node_modules/utility/dist/commonjs/object.d.ts +20 -0
- package/node_modules/utility/dist/commonjs/object.js +73 -0
- package/node_modules/utility/dist/commonjs/optimize.d.ts +21 -0
- package/node_modules/utility/dist/commonjs/optimize.js +60 -0
- package/node_modules/utility/dist/commonjs/package.json +3 -0
- package/node_modules/utility/dist/commonjs/string.d.ts +29 -0
- package/node_modules/utility/dist/commonjs/string.js +126 -0
- package/node_modules/utility/dist/commonjs/timeout.d.ts +6 -0
- package/node_modules/utility/dist/commonjs/timeout.js +34 -0
- package/node_modules/utility/dist/commonjs/web.d.ts +29 -0
- package/node_modules/utility/dist/commonjs/web.js +61 -0
- package/node_modules/utility/dist/esm/array.d.ts +11 -0
- package/node_modules/utility/dist/esm/array.js +42 -0
- package/node_modules/utility/dist/esm/crypto.d.ts +86 -0
- package/node_modules/utility/dist/esm/crypto.js +146 -0
- package/node_modules/utility/dist/esm/date.d.ts +63 -0
- package/node_modules/utility/dist/esm/date.js +204 -0
- package/node_modules/utility/dist/esm/fs.d.ts +6 -0
- package/node_modules/utility/dist/esm/fs.js +17 -0
- package/node_modules/utility/dist/esm/function.d.ts +12 -0
- package/node_modules/utility/dist/esm/function.js +28 -0
- package/node_modules/utility/dist/esm/index.d.ts +12 -0
- package/node_modules/utility/dist/esm/index.js +13 -0
- package/node_modules/utility/dist/esm/json.d.ts +14 -0
- package/node_modules/utility/dist/esm/json.js +34 -0
- package/node_modules/utility/dist/esm/number.d.ts +24 -0
- package/node_modules/utility/dist/esm/number.js +60 -0
- package/node_modules/utility/dist/esm/object.d.ts +20 -0
- package/node_modules/utility/dist/esm/object.js +67 -0
- package/node_modules/utility/dist/esm/optimize.d.ts +21 -0
- package/node_modules/utility/dist/esm/optimize.js +54 -0
- package/node_modules/utility/dist/esm/package.json +3 -0
- package/node_modules/utility/dist/esm/string.d.ts +29 -0
- package/node_modules/utility/dist/esm/string.js +118 -0
- package/node_modules/utility/dist/esm/timeout.d.ts +6 -0
- package/node_modules/utility/dist/esm/timeout.js +28 -0
- package/node_modules/utility/dist/esm/web.d.ts +29 -0
- package/node_modules/utility/dist/esm/web.js +52 -0
- package/node_modules/utility/dist/package.json +4 -0
- package/node_modules/utility/package.json +85 -0
- package/node_modules/utility/src/array.ts +44 -0
- package/node_modules/utility/src/crypto.ts +160 -0
- package/node_modules/utility/src/date.ts +232 -0
- package/node_modules/utility/src/fs.ts +17 -0
- package/node_modules/utility/src/function.ts +30 -0
- package/node_modules/utility/src/index.ts +12 -0
- package/node_modules/utility/src/json.ts +48 -0
- package/node_modules/utility/src/number.ts +63 -0
- package/node_modules/utility/src/object.ts +72 -0
- package/node_modules/utility/src/optimize.ts +62 -0
- package/node_modules/utility/src/string.ts +132 -0
- package/node_modules/utility/src/timeout.ts +37 -0
- package/node_modules/utility/src/web.ts +53 -0
- package/node_modules/ylru/LICENSE +25 -0
- package/node_modules/ylru/README.md +120 -0
- package/node_modules/ylru/dist/commonjs/index.d.ts +21 -0
- package/node_modules/ylru/dist/commonjs/index.js +112 -0
- package/node_modules/ylru/dist/commonjs/package.json +3 -0
- package/node_modules/ylru/dist/esm/index.d.ts +21 -0
- package/node_modules/ylru/dist/esm/index.js +108 -0
- package/node_modules/ylru/dist/esm/package.json +3 -0
- package/node_modules/ylru/package.json +71 -0
- package/node_modules/ylru/src/index.ts +124 -0
- package/package.json +2 -2
- package/node_modules/@ali/cli-skills/dist/_chunks/libs/abort-controller.mjs +0 -424
- package/node_modules/@ali/cli-skills/dist/_chunks/libs/archiver.mjs +0 -19586
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ConfigClient } from './config';
|
|
2
|
+
export declare enum ESCAPE_ERR_CODE {
|
|
3
|
+
SYSTEM_ERR = "SYSTEM_ERR",
|
|
4
|
+
POP_LAYER_ERR = "POP_LAYER_ERR",
|
|
5
|
+
NOT_JSON_ERR = "NOT_JSON_ERR",
|
|
6
|
+
HOT_SWITCH = "HOT_SWITCH"
|
|
7
|
+
}
|
|
8
|
+
export declare function hotSwitchCheck(configClient: ConfigClient): Promise<boolean>;
|
|
9
|
+
export declare function maybeEscape(result: any, rawData: any, escapeReason: any): boolean;
|
|
10
|
+
export declare const preEscapeWork: (serviceMetaMap: any, env: any, uriPattern: any, escapeReason: any) => {
|
|
11
|
+
requestId: any;
|
|
12
|
+
httpCode: number;
|
|
13
|
+
resultNo: number;
|
|
14
|
+
resultCode: any;
|
|
15
|
+
resultMsg: any;
|
|
16
|
+
} | {
|
|
17
|
+
data: {
|
|
18
|
+
uri: string;
|
|
19
|
+
popVer: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare function doExc(env: any, url: any, options: any): Promise<any>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import * as httpx from 'httpx';
|
|
11
|
+
import * as debug from 'debug';
|
|
12
|
+
import { SERVICE_META } from '../common/service-meta';
|
|
13
|
+
import { handleResponse } from './help';
|
|
14
|
+
import { ESCAPE_REG, ESCAPE_NONSTANDARD_REG, generateEscapeError } from '../common/constant';
|
|
15
|
+
import { ESCAPE_CODE } from './config';
|
|
16
|
+
const escapeDeb = debug('sdk:node:escape');
|
|
17
|
+
export var ESCAPE_ERR_CODE;
|
|
18
|
+
(function (ESCAPE_ERR_CODE) {
|
|
19
|
+
ESCAPE_ERR_CODE["SYSTEM_ERR"] = "SYSTEM_ERR";
|
|
20
|
+
// Pop层故障,如认证层、代理层超时等
|
|
21
|
+
ESCAPE_ERR_CODE["POP_LAYER_ERR"] = "POP_LAYER_ERR";
|
|
22
|
+
ESCAPE_ERR_CODE["NOT_JSON_ERR"] = "NOT_JSON_ERR";
|
|
23
|
+
ESCAPE_ERR_CODE["HOT_SWITCH"] = "HOT_SWITCH";
|
|
24
|
+
})(ESCAPE_ERR_CODE || (ESCAPE_ERR_CODE = {}));
|
|
25
|
+
const sdkEscapeLogger = {
|
|
26
|
+
trace: (code, message = '') => {
|
|
27
|
+
console.log('%s|%s|%s|%s', 'o2open', 'esc', code, message);
|
|
28
|
+
},
|
|
29
|
+
error: (message = '') => {
|
|
30
|
+
console.error('%s|%s|%s', 'o2open', 'esc_err', message);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
// 正式请求前,判断是否热切换
|
|
34
|
+
export function hotSwitchCheck(configClient) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const isSwitch = yield configClient.getData();
|
|
37
|
+
if (isSwitch == ESCAPE_CODE.Y) {
|
|
38
|
+
escapeDeb("hot switch start, start escape");
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function maybeEscape(result, rawData, escapeReason) {
|
|
45
|
+
// dns超时、连接超时等node原生错误
|
|
46
|
+
if (!result) {
|
|
47
|
+
escapeDeb("node system error, start escape");
|
|
48
|
+
escapeReason.code = ESCAPE_ERR_CODE.SYSTEM_ERR;
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (result.resultNo == 0) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
rawData = JSON.parse(rawData.toString());
|
|
56
|
+
// pop错误、认证中心错误
|
|
57
|
+
// 认证中心挂掉,pop返回ServiceUnavailable https://yuque.antfin-inc.com/docs/share/79bd3ed9-908d-4451-86d9-e472b2fe0b4c?#:~:text=%E5%8F%AA%E8%BF%94%E5%9B%9EHTTP%20503%20ServiceUnavailable
|
|
58
|
+
if (result.httpCode == 503 && rawData.Code == 'ServiceUnavailable' && rawData.Message && rawData.HostId && rawData.RequestId) {
|
|
59
|
+
escapeDeb("pop or auth error, start escape");
|
|
60
|
+
escapeReason.code = ESCAPE_ERR_CODE.POP_LAYER_ERR;
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
escapeDeb("response is not json, start escape");
|
|
66
|
+
escapeReason.code = ESCAPE_ERR_CODE.NOT_JSON_ERR;
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
export const preEscapeWork = function (serviceMetaMap, env, uriPattern, escapeReason) {
|
|
72
|
+
let serviceName = '', apiVer = '', apiPath = '', popVer = '';
|
|
73
|
+
let matches = uriPattern && uriPattern.match(ESCAPE_REG) || null;
|
|
74
|
+
let serviceMeta = null;
|
|
75
|
+
if (!matches) {
|
|
76
|
+
matches = uriPattern && uriPattern.match(ESCAPE_NONSTANDARD_REG) || null;
|
|
77
|
+
if (!matches) {
|
|
78
|
+
sdkEscapeLogger.error('当前接口不支持');
|
|
79
|
+
return generateEscapeError('服务暂时不可用', 'escape.apiNotSupport');
|
|
80
|
+
}
|
|
81
|
+
serviceName = matches[1];
|
|
82
|
+
apiPath = matches[2];
|
|
83
|
+
popVer = `${serviceName}_1.0`;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
serviceName = matches[2];
|
|
87
|
+
apiVer = matches[1];
|
|
88
|
+
if (serviceName == 'work') {
|
|
89
|
+
apiPath = `/work${matches[3]}`;
|
|
90
|
+
popVer = `def-work_${apiVer}`;
|
|
91
|
+
serviceMeta = serviceMetaMap && serviceMetaMap['def-work'];
|
|
92
|
+
}
|
|
93
|
+
else if (serviceName == 'flow') {
|
|
94
|
+
apiPath = `/def-flow${matches[3]}`;
|
|
95
|
+
popVer = `flow_${apiVer}`;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
apiPath = `/${serviceName}${matches[3]}`;
|
|
99
|
+
popVer = `${serviceName}_${apiVer}`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
serviceMeta = serviceMeta || (serviceMetaMap && serviceMetaMap[serviceName]);
|
|
103
|
+
if (!(serviceMeta === null || serviceMeta === void 0 ? void 0 : serviceMeta.prod)) {
|
|
104
|
+
serviceMeta = SERVICE_META[serviceName];
|
|
105
|
+
}
|
|
106
|
+
if (!serviceMeta) {
|
|
107
|
+
sdkEscapeLogger.error(`缺少${serviceName}服务元信息,触发环境${env} 接口${uriPattern} 版本${apiVer}`);
|
|
108
|
+
return generateEscapeError('服务因网络故障暂时不可用', 'escape.serviceNotSupport');
|
|
109
|
+
}
|
|
110
|
+
const serviceUrl = serviceMeta[env] || serviceMeta['prod'];
|
|
111
|
+
const urlPath = serviceUrl + apiPath;
|
|
112
|
+
sdkEscapeLogger.trace(escapeReason.code, urlPath);
|
|
113
|
+
return {
|
|
114
|
+
data: {
|
|
115
|
+
uri: urlPath,
|
|
116
|
+
popVer
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
export function doExc(env, url, options) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
escapeDeb(`doExc入参:${env} ${url}`);
|
|
123
|
+
return httpx.request(url, options).then((response) => {
|
|
124
|
+
return httpx.read(response, 'utf8').then((body) => {
|
|
125
|
+
let result = handleResponse(response, body, this, true);
|
|
126
|
+
result.rawData = body;
|
|
127
|
+
return result;
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const DEFAULT_UA: string;
|
|
2
|
+
export declare const DEFAULT_CLIENT: string;
|
|
3
|
+
export declare function handleResponse(response: any, body: any, ctx: any, isEscape?: any): any;
|
|
4
|
+
export declare function extractEagleEyeTraceHeader(): {
|
|
5
|
+
'eagleeye-traceid': string;
|
|
6
|
+
'eagleeye-rpcid': string;
|
|
7
|
+
};
|
|
8
|
+
export declare const logger: {
|
|
9
|
+
error: (msg: string, err?: Error) => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import * as os from 'os';
|
|
3
|
+
import { H_REQ_ID } from '../common/constant';
|
|
4
|
+
import { format, format204 } from '../common/format';
|
|
5
|
+
export const DEFAULT_UA = `O2 (${os.platform()}; ${os.arch()}) ` +
|
|
6
|
+
`Node.js/${process.version} Core`;
|
|
7
|
+
export const DEFAULT_CLIENT = `Node.js(${process.version}), @ali/o2-open-client`;
|
|
8
|
+
export function handleResponse(response, body, ctx, isEscape) {
|
|
9
|
+
const contentType = response.headers['content-type'] || '';
|
|
10
|
+
const statusCode = response.statusCode;
|
|
11
|
+
const headers = response.headers;
|
|
12
|
+
const requestId = isEscape ? 'escape' : headers && headers[H_REQ_ID];
|
|
13
|
+
// JSON
|
|
14
|
+
if (contentType.startsWith('application/json')) {
|
|
15
|
+
// No Content
|
|
16
|
+
if (statusCode === 204) {
|
|
17
|
+
return format204(body);
|
|
18
|
+
}
|
|
19
|
+
let result;
|
|
20
|
+
let res_format;
|
|
21
|
+
try {
|
|
22
|
+
result = JSON.parse(body.toString());
|
|
23
|
+
if (typeof ctx.resultFormatCallback == 'function') {
|
|
24
|
+
res_format = ctx.resultFormatCallback(result);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
res_format = format(result);
|
|
28
|
+
}
|
|
29
|
+
// result = format(result);
|
|
30
|
+
res_format.requestId = requestId;
|
|
31
|
+
res_format.httpCode = statusCode;
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
err.name = 'FormatError';
|
|
35
|
+
err.message = 'parse response to json error';
|
|
36
|
+
err.body = body;
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
return res_format;
|
|
40
|
+
}
|
|
41
|
+
else if (contentType.startsWith('text/html')) {
|
|
42
|
+
let res_format = format({
|
|
43
|
+
error: 'upstream service error',
|
|
44
|
+
code: 'upstream.error'
|
|
45
|
+
});
|
|
46
|
+
res_format.requestId = requestId;
|
|
47
|
+
res_format.httpCode = statusCode;
|
|
48
|
+
return res_format;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
let res_format = format({
|
|
52
|
+
error: `unknown error: ${body}`,
|
|
53
|
+
code: 'unknown.error'
|
|
54
|
+
});
|
|
55
|
+
res_format.requestId = requestId;
|
|
56
|
+
res_format.httpCode = statusCode;
|
|
57
|
+
return res_format;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// 提取请求上下文中trace header
|
|
61
|
+
export function extractEagleEyeTraceHeader() {
|
|
62
|
+
const H_TRACEID = 'eagleeye-traceid';
|
|
63
|
+
const H_RPCID = 'eagleeye-rpcid';
|
|
64
|
+
const defaultHeader = {
|
|
65
|
+
[H_TRACEID]: '',
|
|
66
|
+
[H_RPCID]: ''
|
|
67
|
+
};
|
|
68
|
+
try {
|
|
69
|
+
// 默认需接入@ali/db-tracer
|
|
70
|
+
const ctx = global.asyncLocalStorage && (typeof global.asyncLocalStorage.getStore === 'function') && global.asyncLocalStorage.getStore() || null;
|
|
71
|
+
if (!ctx) {
|
|
72
|
+
return defaultHeader;
|
|
73
|
+
}
|
|
74
|
+
const opts = {
|
|
75
|
+
childOf: null
|
|
76
|
+
};
|
|
77
|
+
if (ctx && ctx.tracer) {
|
|
78
|
+
opts.childOf = ctx.tracer.context;
|
|
79
|
+
}
|
|
80
|
+
const span = ctx.app.eagleeye.tracer.startSpan('http-client', opts);
|
|
81
|
+
const traceCtx = span && span.context();
|
|
82
|
+
const rpcid = traceCtx && traceCtx.rpcId || '0';
|
|
83
|
+
return {
|
|
84
|
+
[H_TRACEID]: ctx.get(H_TRACEID),
|
|
85
|
+
[H_RPCID]: rpcid
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
return defaultHeader;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export const logger = {
|
|
93
|
+
error: (msg, err) => {
|
|
94
|
+
console.error(`[o2-open-client] ${msg}`, err);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { IResponse_DTO } from '../common/format';
|
|
2
|
+
export interface ITokenConfig {
|
|
3
|
+
env: 'pre' | 'prod' | 'daily';
|
|
4
|
+
token: string;
|
|
5
|
+
opts?: {
|
|
6
|
+
fromOXS: boolean;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
resultFormatCallback?: Function;
|
|
10
|
+
}
|
|
11
|
+
export interface IEscapeConfig {
|
|
12
|
+
/** 强制关闭逃逸能力,关闭后不再初始化 configClient,也不再拉取逃逸相关配置 */
|
|
13
|
+
disableEscape?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface IAKConfig {
|
|
16
|
+
env: 'pre' | 'prod' | 'daily';
|
|
17
|
+
accessKeyId: string;
|
|
18
|
+
accessKeySecret: string;
|
|
19
|
+
opts?: {
|
|
20
|
+
fromOXS: boolean;
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
};
|
|
23
|
+
resultFormatCallback?: Function;
|
|
24
|
+
}
|
|
25
|
+
export declare class O2Client {
|
|
26
|
+
env: string;
|
|
27
|
+
accessKeyId: string;
|
|
28
|
+
accessKeySecret: string;
|
|
29
|
+
token: string;
|
|
30
|
+
opts: any;
|
|
31
|
+
resultFormatCallback: Function;
|
|
32
|
+
private endpoint;
|
|
33
|
+
private host;
|
|
34
|
+
private keepAliveAgent;
|
|
35
|
+
private defaultQuery;
|
|
36
|
+
private configClient;
|
|
37
|
+
private serviceMeta;
|
|
38
|
+
private disableEscape;
|
|
39
|
+
constructor(config: Partial<ITokenConfig & IAKConfig & IEscapeConfig>);
|
|
40
|
+
private buildHeaders;
|
|
41
|
+
private signature;
|
|
42
|
+
private buildAuthorization;
|
|
43
|
+
private request;
|
|
44
|
+
put<T>(path: string, query: object, body: object | string, headers?: object, options?: object): Promise<IResponse_DTO<T>>;
|
|
45
|
+
post<T>(path: string, query: object, body: object | string, headers?: object, options?: object): Promise<IResponse_DTO<T>>;
|
|
46
|
+
get<T>(path: string, query?: object, headers?: object, options?: object): Promise<IResponse_DTO<T>>;
|
|
47
|
+
delete<T>(path: string, query: object, headers?: object, options?: object): Promise<IResponse_DTO<T>>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
import * as assert from 'assert';
|
|
12
|
+
import * as url from 'url';
|
|
13
|
+
import * as querystring from 'querystring';
|
|
14
|
+
import * as debug from 'debug';
|
|
15
|
+
import * as kitx from 'kitx';
|
|
16
|
+
import * as httpx from 'httpx';
|
|
17
|
+
import { DEFAULT_UA, DEFAULT_CLIENT, handleResponse, extractEagleEyeTraceHeader, logger } from './help';
|
|
18
|
+
import { OPEN_API, H_ESCAPE_STATE, H_CREADENTIAL, CLIENT_TOKEN, H_POP_VER } from '../common/constant';
|
|
19
|
+
import { processToken } from './token-handler';
|
|
20
|
+
import { doExc, maybeEscape, preEscapeWork, hotSwitchCheck, ESCAPE_ERR_CODE } from './escape';
|
|
21
|
+
import { ConfigClient } from './config';
|
|
22
|
+
const nodeDeb = debug('sdk:node:index');
|
|
23
|
+
function keyLowerify(headers) {
|
|
24
|
+
const keys = Object.keys(headers);
|
|
25
|
+
const newHeaders = {};
|
|
26
|
+
for (let i = 0; i < keys.length; i++) {
|
|
27
|
+
const key = keys[i];
|
|
28
|
+
newHeaders[key.toLowerCase()] = headers[key];
|
|
29
|
+
}
|
|
30
|
+
return newHeaders;
|
|
31
|
+
}
|
|
32
|
+
function buildStringToSign(method, uriPattern, headers) {
|
|
33
|
+
const nonce = headers['x-sdk-nonce'] || '';
|
|
34
|
+
const date = headers['Date'] || '';
|
|
35
|
+
const header = `${method}\n${nonce}\n${date}\n${uriPattern}`;
|
|
36
|
+
return header;
|
|
37
|
+
}
|
|
38
|
+
;
|
|
39
|
+
;
|
|
40
|
+
;
|
|
41
|
+
export class O2Client {
|
|
42
|
+
constructor(config) {
|
|
43
|
+
var _a;
|
|
44
|
+
const configName = config.accessKeyId || config.token;
|
|
45
|
+
this.disableEscape = Boolean(config.disableEscape);
|
|
46
|
+
const fromOXS = (_a = config.opts) === null || _a === void 0 ? void 0 : _a.fromOXS;
|
|
47
|
+
if (config.env == 'pre') {
|
|
48
|
+
this.env = config.env;
|
|
49
|
+
// 支持来自 OXS 区的请求
|
|
50
|
+
this.endpoint = fromOXS ? 'https://pre-oapi-o2.aliyun-inc.com' : 'https://pre-oapi.o2.alibaba-inc.com';
|
|
51
|
+
if (!this.disableEscape) {
|
|
52
|
+
this.configClient = new ConfigClient({
|
|
53
|
+
name: configName,
|
|
54
|
+
endpoint: fromOXS ? 'https://open-o2.aliyun-inc.com' : 'https://pre-open.o2.alibaba-inc.com'
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (config.env == 'daily') {
|
|
59
|
+
this.env = config.env;
|
|
60
|
+
this.endpoint = 'https://oapi-def.taobao.net';
|
|
61
|
+
if (!this.disableEscape) {
|
|
62
|
+
this.configClient = new ConfigClient({
|
|
63
|
+
name: configName,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.env = 'prod';
|
|
69
|
+
this.endpoint = fromOXS ? 'https://oapi-o2.aliyun-inc.com' : 'https://oapi.o2.alibaba-inc.com';
|
|
70
|
+
if (!this.disableEscape) {
|
|
71
|
+
this.configClient = new ConfigClient({
|
|
72
|
+
name: configName,
|
|
73
|
+
endpoint: fromOXS ? 'https://open-o2.aliyun-inc.com' : 'https://open.o2.alibaba-inc.com'
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (config.accessKeyId && config.accessKeySecret) {
|
|
78
|
+
this.accessKeyId = config.accessKeyId;
|
|
79
|
+
this.accessKeySecret = config.accessKeySecret;
|
|
80
|
+
}
|
|
81
|
+
else if (config.token) {
|
|
82
|
+
this.token = config.token;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
assert(null, 'must pass "config.accessKeyId and config.accessKeyId or config.token"');
|
|
86
|
+
}
|
|
87
|
+
this.opts = config.opts || {
|
|
88
|
+
timeout: 10000 // 默认超时10s
|
|
89
|
+
};
|
|
90
|
+
this.resultFormatCallback = config.resultFormatCallback;
|
|
91
|
+
this.host = url.parse(this.endpoint).hostname;
|
|
92
|
+
this.defaultQuery = {
|
|
93
|
+
Format: 'json',
|
|
94
|
+
};
|
|
95
|
+
const httpModule = this.endpoint.startsWith('https://') ? require('https') : require('http');
|
|
96
|
+
this.keepAliveAgent = new httpModule.Agent({
|
|
97
|
+
keepAlive: true,
|
|
98
|
+
keepAliveMsecs: 5000,
|
|
99
|
+
// 日常域名的证书不被系统信任
|
|
100
|
+
rejectUnauthorized: false
|
|
101
|
+
});
|
|
102
|
+
if (!this.disableEscape) {
|
|
103
|
+
this.configClient.getServiceMeta().then((meta) => {
|
|
104
|
+
this.serviceMeta = meta;
|
|
105
|
+
}).catch((e) => {
|
|
106
|
+
logger.error('getServiceMeta error', e);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
buildHeaders() {
|
|
111
|
+
const now = new Date();
|
|
112
|
+
const defaultHeaders = {
|
|
113
|
+
accept: 'application/json',
|
|
114
|
+
Date: now.toGMTString(),
|
|
115
|
+
host: this.host,
|
|
116
|
+
'user-agent': DEFAULT_UA,
|
|
117
|
+
'x-sdk-client': DEFAULT_CLIENT,
|
|
118
|
+
'x-sdk-nonce': kitx.makeNonce(),
|
|
119
|
+
'content-type': 'application/json'
|
|
120
|
+
};
|
|
121
|
+
return defaultHeaders;
|
|
122
|
+
}
|
|
123
|
+
signature(stringToSign) {
|
|
124
|
+
const utf8Buff = Buffer.from(stringToSign, 'utf8');
|
|
125
|
+
return kitx.sha1(utf8Buff, this.accessKeySecret, 'base64');
|
|
126
|
+
}
|
|
127
|
+
buildAuthorization(stringToSign) {
|
|
128
|
+
return encodeURIComponent(`${this.accessKeyId}:${this.signature(stringToSign)}`);
|
|
129
|
+
}
|
|
130
|
+
request(method, uriPattern, query = {}, body = '', headers = {}, opts = {}) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
query = Object.assign({}, this.defaultQuery, query);
|
|
133
|
+
const traceHeader = extractEagleEyeTraceHeader();
|
|
134
|
+
let mixHeaders = Object.assign({}, this.buildHeaders(), keyLowerify(headers), traceHeader);
|
|
135
|
+
if (typeof body == 'object') {
|
|
136
|
+
body = JSON.stringify(body);
|
|
137
|
+
}
|
|
138
|
+
const postBody = Buffer.from(body, 'utf8');
|
|
139
|
+
mixHeaders['content-length'] = postBody.length;
|
|
140
|
+
// 必须是application/json
|
|
141
|
+
// mixHeaders['content-type'] = 'application/json';
|
|
142
|
+
mixHeaders['x-sdk-path'] = uriPattern;
|
|
143
|
+
mixHeaders['x-sdk-method'] = method.toUpperCase();
|
|
144
|
+
// header中有ticket而query中没有ticket,热切换时需保障query中存在ticket,在业务服务侧验证身份
|
|
145
|
+
if (mixHeaders['sso_ticket'] && !query['SSO_TICKET']) {
|
|
146
|
+
query['SSO_TICKET'] = mixHeaders['sso_ticket'];
|
|
147
|
+
}
|
|
148
|
+
// 开放接口,走ak认证鉴权
|
|
149
|
+
if (!query['SSO_TICKET'] && !mixHeaders['sso_ticket']) {
|
|
150
|
+
mixHeaders[OPEN_API] = 'true';
|
|
151
|
+
}
|
|
152
|
+
// client_token认证
|
|
153
|
+
if (this.token) {
|
|
154
|
+
mixHeaders[CLIENT_TOKEN] = this.token;
|
|
155
|
+
processToken(this.token, uriPattern, mixHeaders, query);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// AK认证
|
|
159
|
+
query.AccessKeyId = encodeURIComponent(this.accessKeyId);
|
|
160
|
+
const stringToSign = buildStringToSign(method, uriPattern, mixHeaders);
|
|
161
|
+
mixHeaders['x-sdk-authorization'] = this.buildAuthorization(stringToSign);
|
|
162
|
+
}
|
|
163
|
+
let url = `${this.endpoint}${uriPattern}`;
|
|
164
|
+
if (Object.keys(query).length) {
|
|
165
|
+
url += `?${querystring.stringify(query)}`;
|
|
166
|
+
}
|
|
167
|
+
const options = Object.assign({
|
|
168
|
+
method,
|
|
169
|
+
agent: this.keepAliveAgent,
|
|
170
|
+
headers: mixHeaders,
|
|
171
|
+
data: postBody
|
|
172
|
+
}, this.opts, opts);
|
|
173
|
+
let rawData = null;
|
|
174
|
+
let result = null;
|
|
175
|
+
// 热切换判断
|
|
176
|
+
const switchCheck = this.disableEscape ? false : yield hotSwitchCheck(this.configClient);
|
|
177
|
+
// 非热切换的正常场景
|
|
178
|
+
if (!switchCheck) {
|
|
179
|
+
result = yield httpx.request(url, options).then((response) => {
|
|
180
|
+
return httpx.read(response, 'utf8').then((body) => {
|
|
181
|
+
rawData = body;
|
|
182
|
+
// Return raw body
|
|
183
|
+
if (opts.rawBody) {
|
|
184
|
+
return body;
|
|
185
|
+
}
|
|
186
|
+
return handleResponse(response, body, this);
|
|
187
|
+
});
|
|
188
|
+
}).catch((e) => {
|
|
189
|
+
logger.error('request error', e);
|
|
190
|
+
});
|
|
191
|
+
// 请求被catch时,result为空
|
|
192
|
+
if (result) {
|
|
193
|
+
result.rawData = rawData;
|
|
194
|
+
}
|
|
195
|
+
nodeDeb('origin result', result, rawData);
|
|
196
|
+
}
|
|
197
|
+
// 热切换或者满足逃逸特殊条件的逃逸
|
|
198
|
+
const escapeReason = {
|
|
199
|
+
code: ESCAPE_ERR_CODE.HOT_SWITCH
|
|
200
|
+
};
|
|
201
|
+
if (switchCheck || (!this.disableEscape && maybeEscape(result, rawData, escapeReason))) {
|
|
202
|
+
const preResult = preEscapeWork(this.serviceMeta, this.env, uriPattern, escapeReason);
|
|
203
|
+
// 不满足逃逸前提,返回原错误
|
|
204
|
+
if (preResult && preResult.resultNo == 1) {
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
nodeDeb(`启动逃逸...`);
|
|
208
|
+
// host头会替换url的host
|
|
209
|
+
delete mixHeaders.host;
|
|
210
|
+
const escapeOptions = Object.assign({}, {
|
|
211
|
+
method,
|
|
212
|
+
agent: this.keepAliveAgent,
|
|
213
|
+
headers: Object.assign({}, mixHeaders, keyLowerify(headers), {
|
|
214
|
+
[H_CREADENTIAL]: this.accessKeyId || this.token,
|
|
215
|
+
[H_POP_VER]: preResult.data.popVer,
|
|
216
|
+
// 逃逸流量标识,authPlugin认证需要
|
|
217
|
+
[H_ESCAPE_STATE]: 'true',
|
|
218
|
+
// 兼容
|
|
219
|
+
'is-open': query['SSO_TICKET'] ? '' : 'true',
|
|
220
|
+
'pop-open-sess': this.accessKeyId || this.token,
|
|
221
|
+
'content-type': 'application/json',
|
|
222
|
+
}),
|
|
223
|
+
data: postBody
|
|
224
|
+
}, this.opts, opts);
|
|
225
|
+
let escapeUrl = `${preResult.data.uri}`;
|
|
226
|
+
if (Object.keys(query).length) {
|
|
227
|
+
escapeUrl += `?${querystring.stringify(query)}`;
|
|
228
|
+
}
|
|
229
|
+
const escapeResult = yield doExc.bind(this, this.env, escapeUrl, escapeOptions)();
|
|
230
|
+
return escapeResult;
|
|
231
|
+
}
|
|
232
|
+
return result;
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
put(path, query, body, headers, options) {
|
|
236
|
+
return this.request('PUT', path, query, body, headers || {}, options);
|
|
237
|
+
}
|
|
238
|
+
post(path, query, body, headers, options) {
|
|
239
|
+
return this.request('POST', path, query, body, headers || {}, options);
|
|
240
|
+
}
|
|
241
|
+
get(path, query, headers, options) {
|
|
242
|
+
return this.request('GET', path, query, '', headers || {}, options);
|
|
243
|
+
}
|
|
244
|
+
delete(path, query, headers, options) {
|
|
245
|
+
return this.request('DELETE', path, query, '', headers || {}, options);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function processToken(token: any, path: any, header: any, query: any): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TOKEN_MAP, ESCAPE_REG, ESCAPE_NONSTANDARD_REG } from '../common/constant';
|
|
2
|
+
export function processToken(token, path, header, query) {
|
|
3
|
+
let ms = path && path.match(ESCAPE_REG);
|
|
4
|
+
let appName = ms && ms.length && ms[2];
|
|
5
|
+
if (!appName) {
|
|
6
|
+
ms = path && path.match(ESCAPE_NONSTANDARD_REG);
|
|
7
|
+
appName = ms && ms.length && ms[1];
|
|
8
|
+
if (!appName) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const item = TOKEN_MAP[appName];
|
|
13
|
+
if (item) {
|
|
14
|
+
if (item.type == 'header') {
|
|
15
|
+
header[item.name] = token;
|
|
16
|
+
}
|
|
17
|
+
else if (item.type == 'query') {
|
|
18
|
+
query[item.name] = token;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* on(event, listener):为指定事件注册一个监听器,接受一个字符串 event 和一个回调函数。
|
|
3
|
+
* emit(event, [arg1], [arg2]): 按监听器的顺序执行执行每个监听器
|
|
4
|
+
* addListener(event, listener):on的同名函数(alias)
|
|
5
|
+
* once(event, listener): 和on类似,但只触发一次,随后便解除事件监听
|
|
6
|
+
* removeListener(event, listener): 移除指定事件的某个监听回调
|
|
7
|
+
* removeAllListeners([event]):移除指定事件的所有监听回调
|
|
8
|
+
* setMaxListeners(n):用于提高监听器的默认限制的数量。(默认10监听回调个产生警告)
|
|
9
|
+
* listeners(event): 返回指定事件的监听器数组。
|
|
10
|
+
*/
|
|
11
|
+
export declare class EventEmitter {
|
|
12
|
+
maxListeners: number;
|
|
13
|
+
events: object;
|
|
14
|
+
constructor(ops: any);
|
|
15
|
+
on(event: any, listener: any): void;
|
|
16
|
+
emit(event: any): void;
|
|
17
|
+
addListener(event: any, listener: any): void;
|
|
18
|
+
once(event: any, listener: any): void;
|
|
19
|
+
removeListener(event: any, listener: any): void;
|
|
20
|
+
removeAllListeners(event: any): void;
|
|
21
|
+
setMaxListeners(n: any): void;
|
|
22
|
+
listeners(event: any): any;
|
|
23
|
+
}
|