npm update

Notably, this gets us `@actions/github` 6.0.1, which is necessary for
`github.context.runAttempt` (so I have also updated `package.json`
accordingly). On that note... great job following semver, GitHub!
Between this and the non-breaking major version change on
`@actions/cache`, I'm starting to feel like nobody on the Actions team
understands how software versioning works.
This commit is contained in:
mlugg
2025-06-29 17:06:44 +01:00
parent edd2134a44
commit 048396053b
2241 changed files with 707535 additions and 17309 deletions
+148 -97
View File
@@ -5,9 +5,9 @@
"requires": true,
"packages": {
"node_modules/@actions/cache": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-4.0.2.tgz",
"integrity": "sha512-cBr7JL1q+JKjbBd3w3SZN5OQ1Xg+/D8QLMcE7MpgpghZlL4biBO0ZEeraoTxCZyfN0YY0dxXlLgsgGv/sT5BTg==",
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-4.0.3.tgz",
"integrity": "sha512-SvrqFtYJ7I48A/uXNkoJrnukx5weQv1fGquhs3+4nkByZThBH109KTIqj5x/cGV7JGNvb8dLPVywUOqX1fjiXg==",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.11.1",
@@ -42,15 +42,18 @@
}
},
"node_modules/@actions/github": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@actions/github/-/github-6.0.0.tgz",
"integrity": "sha512-alScpSVnYmjNEXboZjarjukQEzgCRmjMv6Xj47fsdnqGS73bjJNDpiiXmp8jr0UZLdUB6d9jW63IcmddUP+l0g==",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/@actions/github/-/github-6.0.1.tgz",
"integrity": "sha512-xbZVcaqD4XnQAe35qSQqskb3SqIAfRyLBrHMd/8TuL7hJSz2QtbDwnNM8zWx4zO5l2fnGtseNE3MbEvD7BxVMw==",
"license": "MIT",
"dependencies": {
"@actions/http-client": "^2.2.0",
"@octokit/core": "^5.0.1",
"@octokit/plugin-paginate-rest": "^9.0.0",
"@octokit/plugin-rest-endpoint-methods": "^10.0.0"
"@octokit/plugin-paginate-rest": "^9.2.2",
"@octokit/plugin-rest-endpoint-methods": "^10.4.0",
"@octokit/request": "^8.4.1",
"@octokit/request-error": "^5.1.1",
"undici": "^5.28.5"
}
},
"node_modules/@actions/glob": {
@@ -131,14 +134,14 @@
}
},
"node_modules/@azure/core-client": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/@azure/core-client/-/core-client-1.9.3.tgz",
"integrity": "sha512-/wGw8fJ4mdpJ1Cum7s1S+VQyXt1ihwKLzfabS1O/RDADnmzVc01dHn44qD0BvGH6KlZNzOMW95tEpKqhkCChPA==",
"version": "1.9.4",
"resolved": "https://registry.npmjs.org/@azure/core-client/-/core-client-1.9.4.tgz",
"integrity": "sha512-f7IxTD15Qdux30s2qFARH+JxgwxWLG2Rlr4oSkPGuLWm+1p5y1+C04XGLA0vmX6EtqfutmjvpNmAfgwVIS5hpw==",
"license": "MIT",
"dependencies": {
"@azure/abort-controller": "^2.0.0",
"@azure/core-auth": "^1.4.0",
"@azure/core-rest-pipeline": "^1.9.1",
"@azure/core-rest-pipeline": "^1.20.0",
"@azure/core-tracing": "^1.0.0",
"@azure/core-util": "^1.6.1",
"@azure/logger": "^1.0.0",
@@ -161,14 +164,14 @@
}
},
"node_modules/@azure/core-http-compat": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@azure/core-http-compat/-/core-http-compat-2.2.0.tgz",
"integrity": "sha512-1kW8ZhN0CfbNOG6C688z5uh2yrzALE7dDXHiR9dY4vt+EbhGZQSbjDa5bQd2rf3X2pdWMsXbqbArxUyeNdvtmg==",
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@azure/core-http-compat/-/core-http-compat-2.3.0.tgz",
"integrity": "sha512-qLQujmUypBBG0gxHd0j6/Jdmul6ttl24c8WGiLXIk7IHXdBlfoBqW27hyz3Xn6xbfdyVSarl1Ttbk0AwnZBYCw==",
"license": "MIT",
"dependencies": {
"@azure/abort-controller": "^2.0.0",
"@azure/core-client": "^1.3.0",
"@azure/core-rest-pipeline": "^1.19.0"
"@azure/core-rest-pipeline": "^1.20.0"
},
"engines": {
"node": ">=18.0.0"
@@ -226,9 +229,9 @@
}
},
"node_modules/@azure/core-rest-pipeline": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.19.1.tgz",
"integrity": "sha512-zHeoI3NCs53lLBbWNzQycjnYKsA1CVKlnzSNuSFcUDwBp8HHVObePxrM7HaX+Ha5Ks639H7chNC9HOaIhNS03w==",
"version": "1.21.0",
"resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.21.0.tgz",
"integrity": "sha512-a4MBwe/5WKbq9MIxikzgxLBbruC5qlkFYlBdI7Ev50Y7ib5Vo/Jvt5jnJo7NaWeJ908LCHL0S1Us4UMf1VoTfg==",
"license": "MIT",
"dependencies": {
"@azure/abort-controller": "^2.0.0",
@@ -236,8 +239,7 @@
"@azure/core-tracing": "^1.0.1",
"@azure/core-util": "^1.11.0",
"@azure/logger": "^1.0.0",
"http-proxy-agent": "^7.0.0",
"https-proxy-agent": "^7.0.0",
"@typespec/ts-http-runtime": "^0.2.3",
"tslib": "^2.6.2"
},
"engines": {
@@ -269,12 +271,13 @@
}
},
"node_modules/@azure/core-util": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.11.0.tgz",
"integrity": "sha512-DxOSLua+NdpWoSqULhjDyAZTXFdP/LKkqtYuxxz1SCN289zk3OG8UOpnCQAz/tygyACBtWp/BoO72ptK7msY8g==",
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.12.0.tgz",
"integrity": "sha512-13IyjTQgABPARvG90+N2dXpC+hwp466XCdQXPCRlbWHgd3SJd5Q1VvaBGv6k1BIa4MQm6hAF1UBU1m8QUxV8sQ==",
"license": "MIT",
"dependencies": {
"@azure/abort-controller": "^2.0.0",
"@typespec/ts-http-runtime": "^0.2.2",
"tslib": "^2.6.2"
},
"engines": {
@@ -307,11 +310,12 @@
}
},
"node_modules/@azure/logger": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.1.4.tgz",
"integrity": "sha512-4IXXzcCdLdlXuCG+8UKEwLA1T1NHqUfanhXYHiQTn+6sfWCZXduqbtXDGceg3Ce5QxTGo7EqmbV6Bi+aqKuClQ==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.2.0.tgz",
"integrity": "sha512-0hKEzLhpw+ZTAfNJyRrn6s+V0nDWzXk9OjBr2TiGIu0OfMr5s2V4FpKLTAK3Ca5r5OKLbf4hkOGDPyiRjie/jA==",
"license": "MIT",
"dependencies": {
"@typespec/ts-http-runtime": "^0.2.2",
"tslib": "^2.6.2"
},
"engines": {
@@ -341,9 +345,9 @@
"license": "0BSD"
},
"node_modules/@azure/storage-blob": {
"version": "12.26.0",
"resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.26.0.tgz",
"integrity": "sha512-SriLPKezypIsiZ+TtlFfE46uuBIap2HeaQVS78e1P7rz5OSbq0rsd52WE1mC5f7vAeLiXqv7I7oRhL3WFZEw3Q==",
"version": "12.27.0",
"resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.27.0.tgz",
"integrity": "sha512-IQjj9RIzAKatmNca3D6bT0qJ+Pkox1WZGOg2esJF2YLHb45pQKOwGPIAV+w3rfgkj7zV3RMxpn/c6iftzSOZJQ==",
"license": "MIT",
"dependencies": {
"@azure/abort-controller": "^2.1.2",
@@ -376,6 +380,36 @@
"node": ">=18.0.0"
}
},
"node_modules/@bufbuild/protobuf": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-2.6.0.tgz",
"integrity": "sha512-6cuonJVNOIL7lTj5zgo/Rc2bKAo4/GvN+rKCrUj7GdEHRzCk8zKOfFwUsL9nAVk5rSIsRmlgcpLzTRysopEeeg==",
"license": "(Apache-2.0 AND BSD-3-Clause)"
},
"node_modules/@bufbuild/protoplugin": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@bufbuild/protoplugin/-/protoplugin-2.6.0.tgz",
"integrity": "sha512-mfAwI+4GqUtbw/ddfyolEHaAL86ozRIVlOg2A+SVRbjx1CjsMc1YJO+hBSkt/pqfpR+PmWBbZLstHbXP8KGtMQ==",
"license": "Apache-2.0",
"dependencies": {
"@bufbuild/protobuf": "2.6.0",
"@typescript/vfs": "^1.5.2",
"typescript": "5.4.5"
}
},
"node_modules/@bufbuild/protoplugin/node_modules/typescript": {
"version": "5.4.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz",
"integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==",
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/@fastify/busboy": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
@@ -395,15 +429,15 @@
}
},
"node_modules/@octokit/core": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.0.tgz",
"integrity": "sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==",
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.1.tgz",
"integrity": "sha512-dKYCMuPO1bmrpuogcjQ8z7ICCH3FP6WmxpwC03yjzGfZhj9fTJg6+bS1+UAplekbN2C+M61UNllGOOoAfGCrdQ==",
"license": "MIT",
"dependencies": {
"@octokit/auth-token": "^4.0.0",
"@octokit/graphql": "^7.1.0",
"@octokit/request": "^8.3.1",
"@octokit/request-error": "^5.1.0",
"@octokit/request": "^8.4.1",
"@octokit/request-error": "^5.1.1",
"@octokit/types": "^13.0.0",
"before-after-hook": "^2.2.0",
"universal-user-agent": "^6.0.0"
@@ -440,9 +474,9 @@
}
},
"node_modules/@octokit/openapi-types": {
"version": "23.0.1",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-23.0.1.tgz",
"integrity": "sha512-izFjMJ1sir0jn0ldEKhZ7xegCTj/ObmEDlEfpFrx4k/JyZSMRHbO3/rBwgE7f3m2DHt+RrNGIVw4wSmwnm3t/g==",
"version": "24.2.0",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-24.2.0.tgz",
"integrity": "sha512-9sIH3nSUttelJSXUrmGzl7QUBFul0/mB8HRYl3fOlgHbIWG+WnYDXU3v/2zMtAvuzZ/ed00Ei6on975FhBfzrg==",
"license": "MIT"
},
"node_modules/@octokit/plugin-paginate-rest": {
@@ -535,24 +569,25 @@
}
},
"node_modules/@octokit/types": {
"version": "13.8.0",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.8.0.tgz",
"integrity": "sha512-x7DjTIbEpEWXK99DMd01QfWy0hd5h4EN+Q7shkdKds3otGQP+oWE/y0A76i1OvH9fygo4ddvNf7ZvF0t78P98A==",
"version": "13.10.0",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.10.0.tgz",
"integrity": "sha512-ifLaO34EbbPj0Xgro4G5lP5asESjwHracYJvVaPIyXMuiuXLlhic3S47cBdTb+jfODkTE5YtGCLt3Ay3+J97sA==",
"license": "MIT",
"dependencies": {
"@octokit/openapi-types": "^23.0.1"
"@octokit/openapi-types": "^24.2.0"
}
},
"node_modules/@protobuf-ts/plugin": {
"version": "2.9.5",
"resolved": "https://registry.npmjs.org/@protobuf-ts/plugin/-/plugin-2.9.5.tgz",
"integrity": "sha512-KCzNRTFye837XdfPjS85gGzxgPGVDR3W8Px2G3etXuouNog9W+Cr+U0IBTFADrRWXC2x+OSNjXxrdZEiw+H5Cw==",
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@protobuf-ts/plugin/-/plugin-2.11.1.tgz",
"integrity": "sha512-HyuprDcw0bEEJqkOWe1rnXUP0gwYLij8YhPuZyZk6cJbIgc/Q0IFgoHQxOXNIXAcXM4Sbehh6kjVnCzasElw1A==",
"license": "Apache-2.0",
"dependencies": {
"@protobuf-ts/plugin-framework": "^2.9.5",
"@protobuf-ts/protoc": "^2.9.5",
"@protobuf-ts/runtime": "^2.9.5",
"@protobuf-ts/runtime-rpc": "^2.9.5",
"@bufbuild/protobuf": "^2.4.0",
"@bufbuild/protoplugin": "^2.4.0",
"@protobuf-ts/protoc": "^2.11.1",
"@protobuf-ts/runtime": "^2.11.1",
"@protobuf-ts/runtime-rpc": "^2.11.1",
"typescript": "^3.9"
},
"bin": {
@@ -560,38 +595,54 @@
"protoc-gen-ts": "bin/protoc-gen-ts"
}
},
"node_modules/@protobuf-ts/plugin-framework": {
"version": "2.9.5",
"resolved": "https://registry.npmjs.org/@protobuf-ts/plugin-framework/-/plugin-framework-2.9.5.tgz",
"integrity": "sha512-DYNQ8Ga3xwPZMfaZGRCnDOcEdQZK9MorTXngVoFLnHWEE8zLhUjFVtdkChZtTih6rl8Z6akyA7hRgj/GrJF58Q==",
"license": "(Apache-2.0 AND BSD-3-Clause)",
"dependencies": {
"@protobuf-ts/runtime": "^2.9.5",
"typescript": "^3.9"
}
},
"node_modules/@protobuf-ts/protoc": {
"version": "2.9.5",
"resolved": "https://registry.npmjs.org/@protobuf-ts/protoc/-/protoc-2.9.5.tgz",
"integrity": "sha512-n6a7OHfr/Ubw483L6kNJB0wBCe/Ops0A652zB6J6nR2x1o+pjVFrMCeeQQsqxkYpQwQ8FCIETSxrMpfOBKTIvQ==",
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@protobuf-ts/protoc/-/protoc-2.11.1.tgz",
"integrity": "sha512-mUZJaV0daGO6HUX90o/atzQ6A7bbN2RSuHtdwo8SSF2Qoe3zHwa4IHyCN1evftTeHfLmdz+45qo47sL+5P8nyg==",
"license": "Apache-2.0",
"bin": {
"protoc": "protoc.js"
}
},
"node_modules/@protobuf-ts/runtime": {
"version": "2.9.5",
"resolved": "https://registry.npmjs.org/@protobuf-ts/runtime/-/runtime-2.9.5.tgz",
"integrity": "sha512-SsumigRe3IqNTCQvVZUqDQExsKF72eyAMiWlYb5Jwj3eU4z8UH7JLlSfb/Wjidz4b/chTN6zh5AXBSKl0Asm3A==",
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@protobuf-ts/runtime/-/runtime-2.11.1.tgz",
"integrity": "sha512-KuDaT1IfHkugM2pyz+FwiY80ejWrkH1pAtOBOZFuR6SXEFTsnb/jiQWQ1rCIrcKx2BtyxnxW6BWwsVSA/Ie+WQ==",
"license": "(Apache-2.0 AND BSD-3-Clause)"
},
"node_modules/@protobuf-ts/runtime-rpc": {
"version": "2.9.5",
"resolved": "https://registry.npmjs.org/@protobuf-ts/runtime-rpc/-/runtime-rpc-2.9.5.tgz",
"integrity": "sha512-NWAb1TaV4CR+BknZr1WRVT5Ws2AupVwGgRNes4oPAFrgLNXQotDFl2E6pmsjPwME8sAgJVzeSr7bUqQVyoAK2A==",
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/@protobuf-ts/runtime-rpc/-/runtime-rpc-2.11.1.tgz",
"integrity": "sha512-4CqqUmNA+/uMz00+d3CYKgElXO9VrEbucjnBFEjqI4GuDrEQ32MaI3q+9qPBvIGOlL4PmHXrzM32vBPWRhQKWQ==",
"license": "Apache-2.0",
"dependencies": {
"@protobuf-ts/runtime": "^2.9.5"
"@protobuf-ts/runtime": "^2.11.1"
}
},
"node_modules/@typescript/vfs": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/@typescript/vfs/-/vfs-1.6.1.tgz",
"integrity": "sha512-JwoxboBh7Oz1v38tPbkrZ62ZXNHAk9bJ7c9x0eI5zBfBnBYGhURdbnh7Z4smN/MV48Y5OCcZb58n972UtbazsA==",
"license": "MIT",
"dependencies": {
"debug": "^4.1.1"
},
"peerDependencies": {
"typescript": "*"
}
},
"node_modules/@typespec/ts-http-runtime": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/@typespec/ts-http-runtime/-/ts-http-runtime-0.2.3.tgz",
"integrity": "sha512-oRhjSzcVjX8ExyaF8hC0zzTqxlVuRlgMHL/Bh4w3xB9+wjbm0FpXylVU/lBrn+kgphwYTrOk3tp+AVShGmlYCg==",
"license": "MIT",
"dependencies": {
"http-proxy-agent": "^7.0.0",
"https-proxy-agent": "^7.0.0",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/abort-controller": {
@@ -628,9 +679,9 @@
"license": "MIT"
},
"node_modules/bare-addon-resolve": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/bare-addon-resolve/-/bare-addon-resolve-1.9.3.tgz",
"integrity": "sha512-0W343p8kVy9KimDMrxJtJct/ILWL8gzC0Wwg/Fn/GgQplHvrllyz4fPobUVG5+gx9BokWttzg8FYypQP7V5nrA==",
"version": "1.9.4",
"resolved": "https://registry.npmjs.org/bare-addon-resolve/-/bare-addon-resolve-1.9.4.tgz",
"integrity": "sha512-unn6Vy/Yke6F99vg/7tcrvM2KUvIhTNniaSqDbam4AWkd4NhvDVSrQiRYVlNzUV2P7SPobkCK7JFVxrJk9btCg==",
"license": "Apache-2.0",
"dependencies": {
"bare-module-resolve": "^1.10.0",
@@ -646,9 +697,9 @@
}
},
"node_modules/bare-module-resolve": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/bare-module-resolve/-/bare-module-resolve-1.10.2.tgz",
"integrity": "sha512-C9COe/GhWfVXKytW3DElTkiBU+Gb2OXeaVkdGdRB/lp26TVLESHkTGS876iceAGdvtPgohfp9nX8vXHGvN3++Q==",
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/bare-module-resolve/-/bare-module-resolve-1.11.1.tgz",
"integrity": "sha512-DCxeT9i8sTs3vUMA3w321OX/oXtNEu5EjObQOnTmCdNp5RXHBAvAaBDHvAi9ta0q/948QPz+co6SsGi6aQMYRg==",
"license": "Apache-2.0",
"dependencies": {
"bare-semver": "^1.0.0"
@@ -663,9 +714,9 @@
}
},
"node_modules/bare-os": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/bare-os/-/bare-os-3.5.1.tgz",
"integrity": "sha512-LvfVNDcWLw2AnIw5f2mWUgumW3I3N/WYGiWeimhQC1Ybt71n2FjlS9GJKeCnFeg1MKZHxzIFmpFnBXDI+sBeFg==",
"version": "3.6.1",
"resolved": "https://registry.npmjs.org/bare-os/-/bare-os-3.6.1.tgz",
"integrity": "sha512-uaIjxokhFidJP+bmmvKSgiMzj2sV5GPHaZVAIktcxcpCyBFFWO+YlikVAdhmUo2vYFvFhOXIAlldqV29L8126g==",
"license": "Apache-2.0",
"engines": {
"bare": ">=1.14.0"
@@ -687,9 +738,9 @@
"license": "Apache-2.0"
},
"node_modules/bare-url": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/bare-url/-/bare-url-2.1.3.tgz",
"integrity": "sha512-c02+eKvn/4esh5E2lSYQFwHL1WoTIL3u3NeFqb9e7ahBVENXw13MWx4/4/wdPyI557GqqB2Cm0bBbOXD0I0qgA==",
"version": "2.1.6",
"resolved": "https://registry.npmjs.org/bare-url/-/bare-url-2.1.6.tgz",
"integrity": "sha512-FgjDeR+/yDH34By4I0qB5NxAoWv7dOTYcOXwn73kr+c93HyC2lU6tnjifqUe33LKMJcDyCYPQjEAqgOQiXkE2Q==",
"license": "Apache-2.0",
"dependencies": {
"bare-path": "^3.0.0"
@@ -702,9 +753,9 @@
"license": "Apache-2.0"
},
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"version": "1.1.12",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
"integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0",
@@ -743,9 +794,9 @@
"license": "MIT"
},
"node_modules/debug": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
"integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
"integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
@@ -852,9 +903,9 @@
}
},
"node_modules/fast-xml-parser": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.0.8.tgz",
"integrity": "sha512-qY8NiI5L8ff00F2giyICiJxSSKHO52tC36LJqx2JtvGyAd5ZfehC/l4iUVVHpmpIa6sM9N5mneSLHQG2INGoHA==",
"version": "5.2.5",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.2.5.tgz",
"integrity": "sha512-pfX9uG9Ki0yekDHx2SiuRIyFdyAr1kMIMitPvb0YBo8SUfKvia7w7FIyd/l6av85pFYRhZscS75MwMnbvY+hcQ==",
"funding": [
{
"type": "github",
@@ -863,7 +914,7 @@
],
"license": "MIT",
"dependencies": {
"strnum": "^2.0.5"
"strnum": "^2.1.0"
},
"bin": {
"fxparser": "src/cli/cli.js"
@@ -1143,9 +1194,9 @@
}
},
"node_modules/strnum": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-2.0.5.tgz",
"integrity": "sha512-YAT3K/sgpCUxhxNMrrdhtod3jckkpYwH6JAuwmUdXZsmzH1wUyzTMrrK2wYCEEqlKwrWDd35NeuUkbBy/1iK+Q==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-2.1.1.tgz",
"integrity": "sha512-7ZvoFTiCnGxBtDqJ//Cu6fWtZtc7Y3x+QOirG15wztbdngGSkht27o2pyGWrVy0b4WAy3jbKmnoK6g5VlVNUUw==",
"funding": [
{
"type": "github",
@@ -1189,9 +1240,9 @@
}
},
"node_modules/undici": {
"version": "5.28.5",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz",
"integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==",
"version": "5.29.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz",
"integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==",
"license": "MIT",
"dependencies": {
"@fastify/busboy": "^2.0.0"
+1 -1
View File
@@ -213,7 +213,7 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
};
const response = yield twirpClient.GetCacheEntryDownloadURL(request);
if (!response.ok) {
core.debug(`Cache not found for keys: ${keys.join(', ')}`);
core.debug(`Cache not found for version ${request.version} of keys: ${keys.join(', ')}`);
return undefined;
}
core.info(`Cache hit for: ${request.key}`);
+1 -1
View File
File diff suppressed because one or more lines are too long
+2
View File
@@ -18,6 +18,7 @@ const cacheUtils_1 = require("../cacheUtils");
const auth_1 = require("@actions/http-client/lib/auth");
const http_client_1 = require("@actions/http-client");
const cache_twirp_client_1 = require("../../generated/results/api/v1/cache.twirp-client");
const util_1 = require("./util");
/**
* This class is a wrapper around the CacheServiceClientJSON class generated by Twirp.
*
@@ -77,6 +78,7 @@ class CacheServiceClient {
(0, core_1.debug)(`[Response] - ${response.message.statusCode}`);
(0, core_1.debug)(`Headers: ${JSON.stringify(response.message.headers, null, 2)}`);
const body = JSON.parse(rawBody);
(0, util_1.maskSecretUrls)(body);
(0, core_1.debug)(`Body: ${JSON.stringify(body, null, 2)}`);
if (this.isSuccessStatusCode(statusCode)) {
return { response, body };
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"cacheTwirpClient.js","sourceRoot":"","sources":["../../../src/internal/shared/cacheTwirpClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAyC;AACzC,6CAA+C;AAC/C,qCAAiD;AACjD,sCAA4C;AAC5C,8CAA6C;AAC7C,wDAAqE;AACrE,sDAA8E;AAC9E,0FAAwF;AAYxF;;;;;;GAMG;AACH,MAAM,kBAAkB;IAOtB,YACE,SAAiB,EACjB,WAAoB,EACpB,6BAAsC,EACtC,eAAwB;QARlB,gBAAW,GAAG,CAAC,CAAA;QACf,kCAA6B,GAAG,IAAI,CAAA;QACpC,oBAAe,GAAG,GAAG,CAAA;QAQ3B,MAAM,KAAK,GAAG,IAAA,4BAAe,GAAE,CAAA;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAA,2BAAkB,GAAE,CAAA;QACnC,IAAI,WAAW,EAAE;YACf,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;SAC/B;QACD,IAAI,6BAA6B,EAAE;YACjC,IAAI,CAAC,6BAA6B,GAAG,6BAA6B,CAAA;SACnE;QACD,IAAI,eAAe,EAAE;YACnB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;SACvC;QAED,IAAI,CAAC,UAAU,GAAG,IAAI,wBAAU,CAAC,SAAS,EAAE;YAC1C,IAAI,8BAAuB,CAAC,KAAK,CAAC;SACnC,CAAC,CAAA;IACJ,CAAC;IAED,4EAA4E;IAC5E,yBAAyB;IACnB,OAAO,CACX,OAAe,EACf,MAAc,EACd,WAAwD,EACxD,IAAyB;;YAEzB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CAAE,eAAe,CACzB,CAAA;IACD,OAAO,IAAI,2CAAsB,CAAC,MAAM,CAAC,CAAA;AAC3C,CAAC;AAZD,4DAYC"}
+40
View File
@@ -0,0 +1,40 @@
/**
* Masks the `sig` parameter in a URL and sets it as a secret.
*
* @param url - The URL containing the signature parameter to mask
* @remarks
* This function attempts to parse the provided URL and identify the 'sig' query parameter.
* If found, it registers both the raw and URL-encoded signature values as secrets using
* the Actions `setSecret` API, which prevents them from being displayed in logs.
*
* The function handles errors gracefully if URL parsing fails, logging them as debug messages.
*
* @example
* ```typescript
* // Mask a signature in an Azure SAS token URL
* maskSigUrl('https://example.blob.core.windows.net/container/file.txt?sig=abc123&se=2023-01-01');
* ```
*/
export declare function maskSigUrl(url: string): void;
/**
* Masks sensitive information in URLs containing signature parameters.
* Currently supports masking 'sig' parameters in the 'signed_upload_url'
* and 'signed_download_url' properties of the provided object.
*
* @param body - The object should contain a signature
* @remarks
* This function extracts URLs from the object properties and calls maskSigUrl
* on each one to redact sensitive signature information. The function doesn't
* modify the original object; it only marks the signatures as secrets for
* logging purposes.
*
* @example
* ```typescript
* const responseBody = {
* signed_upload_url: 'https://blob.core.windows.net/?sig=abc123',
* signed_download_url: 'https://blob.core/windows.net/?sig=def456'
* };
* maskSecretUrls(responseBody);
* ```
*/
export declare function maskSecretUrls(body: Record<string, unknown> | null): void;
+74
View File
@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.maskSecretUrls = exports.maskSigUrl = void 0;
const core_1 = require("@actions/core");
/**
* Masks the `sig` parameter in a URL and sets it as a secret.
*
* @param url - The URL containing the signature parameter to mask
* @remarks
* This function attempts to parse the provided URL and identify the 'sig' query parameter.
* If found, it registers both the raw and URL-encoded signature values as secrets using
* the Actions `setSecret` API, which prevents them from being displayed in logs.
*
* The function handles errors gracefully if URL parsing fails, logging them as debug messages.
*
* @example
* ```typescript
* // Mask a signature in an Azure SAS token URL
* maskSigUrl('https://example.blob.core.windows.net/container/file.txt?sig=abc123&se=2023-01-01');
* ```
*/
function maskSigUrl(url) {
if (!url)
return;
try {
const parsedUrl = new URL(url);
const signature = parsedUrl.searchParams.get('sig');
if (signature) {
(0, core_1.setSecret)(signature);
(0, core_1.setSecret)(encodeURIComponent(signature));
}
}
catch (error) {
(0, core_1.debug)(`Failed to parse URL: ${url} ${error instanceof Error ? error.message : String(error)}`);
}
}
exports.maskSigUrl = maskSigUrl;
/**
* Masks sensitive information in URLs containing signature parameters.
* Currently supports masking 'sig' parameters in the 'signed_upload_url'
* and 'signed_download_url' properties of the provided object.
*
* @param body - The object should contain a signature
* @remarks
* This function extracts URLs from the object properties and calls maskSigUrl
* on each one to redact sensitive signature information. The function doesn't
* modify the original object; it only marks the signatures as secrets for
* logging purposes.
*
* @example
* ```typescript
* const responseBody = {
* signed_upload_url: 'https://blob.core.windows.net/?sig=abc123',
* signed_download_url: 'https://blob.core/windows.net/?sig=def456'
* };
* maskSecretUrls(responseBody);
* ```
*/
function maskSecretUrls(body) {
if (typeof body !== 'object' || body === null) {
(0, core_1.debug)('body is not an object or is null');
return;
}
if ('signed_upload_url' in body &&
typeof body.signed_upload_url === 'string') {
maskSigUrl(body.signed_upload_url);
}
if ('signed_download_url' in body &&
typeof body.signed_download_url === 'string') {
maskSigUrl(body.signed_download_url);
}
}
exports.maskSecretUrls = maskSecretUrls;
//# sourceMappingURL=util.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/internal/shared/util.ts"],"names":[],"mappings":";;;AAAA,wCAA8C;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,UAAU,CAAC,GAAW;IACpC,IAAI,CAAC,GAAG;QAAE,OAAM;IAChB,IAAI;QACF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QAC9B,MAAM,SAAS,GAAG,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACnD,IAAI,SAAS,EAAE;YACb,IAAA,gBAAS,EAAC,SAAS,CAAC,CAAA;YACpB,IAAA,gBAAS,EAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAA;SACzC;KACF;IAAC,OAAO,KAAK,EAAE;QACd,IAAA,YAAK,EACH,wBAAwB,GAAG,IACzB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAA;KACF;AACH,CAAC;AAhBD,gCAgBC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,cAAc,CAAC,IAAoC;IACjE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE;QAC7C,IAAA,YAAK,EAAC,kCAAkC,CAAC,CAAA;QACzC,OAAM;KACP;IACD,IACE,mBAAmB,IAAI,IAAI;QAC3B,OAAO,IAAI,CAAC,iBAAiB,KAAK,QAAQ,EAC1C;QACA,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;KACnC;IACD,IACE,qBAAqB,IAAI,IAAI;QAC7B,OAAO,IAAI,CAAC,mBAAmB,KAAK,QAAQ,EAC5C;QACA,UAAU,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;KACrC;AACH,CAAC;AAjBD,wCAiBC"}
+2 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@actions/cache",
"version": "4.0.2",
"version": "4.0.3",
"preview": true,
"description": "Actions cache lib",
"keywords": [
@@ -49,6 +49,7 @@
"semver": "^6.3.1"
},
"devDependencies": {
"@types/node": "^22.13.9",
"@types/semver": "^6.0.0",
"typescript": "^5.2.2"
}
+1
View File
@@ -11,6 +11,7 @@ export declare class Context {
action: string;
actor: string;
job: string;
runAttempt: number;
runNumber: number;
runId: number;
apiUrl: string;
+1
View File
@@ -26,6 +26,7 @@ class Context {
this.action = process.env.GITHUB_ACTION;
this.actor = process.env.GITHUB_ACTOR;
this.job = process.env.GITHUB_JOB;
this.runAttempt = parseInt(process.env.GITHUB_RUN_ATTEMPT, 10);
this.runNumber = parseInt(process.env.GITHUB_RUN_NUMBER, 10);
this.runId = parseInt(process.env.GITHUB_RUN_ID, 10);
this.apiUrl = (_a = process.env.GITHUB_API_URL) !== null && _a !== void 0 ? _a : `https://api.github.com`;
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;AAEA,2BAA2C;AAC3C,2BAAsB;AAEtB,MAAa,OAAO;IAmBlB;;OAEG;IACH;;QACE,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;YACjC,IAAI,IAAA,eAAU,EAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE;gBAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CACvB,IAAA,iBAAY,EAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAChE,CAAA;aACF;iBAAM;gBACL,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAA;gBAC1C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,IAAI,kBAAkB,QAAG,EAAE,CAAC,CAAA;aACvE;SACF;QACD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,iBAA2B,CAAA;QACxD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,UAAoB,CAAA;QAC3C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,UAAoB,CAAA;QAC3C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,eAAyB,CAAA;QACrD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAuB,CAAA;QACjD,IAAI,CAAC,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AM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAA;IACH,CAAC;CACF;AA7ED,0BA6EC"}
+7 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@actions/github",
"version": "6.0.0",
"version": "6.0.1",
"description": "Actions github lib",
"keywords": [
"github",
@@ -40,10 +40,13 @@
"dependencies": {
"@actions/http-client": "^2.2.0",
"@octokit/core": "^5.0.1",
"@octokit/plugin-paginate-rest": "^9.0.0",
"@octokit/plugin-rest-endpoint-methods": "^10.0.0"
"@octokit/plugin-paginate-rest": "^9.2.2",
"@octokit/plugin-rest-endpoint-methods": "^10.4.0",
"@octokit/request": "^8.4.1",
"@octokit/request-error": "^5.1.1",
"undici": "^5.28.5"
},
"devDependencies": {
"proxy": "^2.1.1"
}
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.50.1"
"packageVersion": "7.52.5"
}
]
}
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@azure/core-client",
"version": "1.9.3",
"version": "1.9.4",
"description": "Core library for interfacing with AutoRest generated code",
"sdk-type": "client",
"type": "module",
@@ -77,7 +77,7 @@
"dependencies": {
"@azure/abort-controller": "^2.0.0",
"@azure/core-auth": "^1.4.0",
"@azure/core-rest-pipeline": "^1.9.1",
"@azure/core-rest-pipeline": "^1.20.0",
"@azure/core-tracing": "^1.0.0",
"@azure/core-util": "^1.6.1",
"@azure/logger": "^1.0.0",
@@ -88,12 +88,12 @@
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@types/node": "^18.0.0",
"@vitest/browser": "^3.0.3",
"@vitest/coverage-istanbul": "^3.0.3",
"@vitest/browser": "^3.0.9",
"@vitest/coverage-istanbul": "^3.0.9",
"eslint": "^9.9.0",
"playwright": "^1.41.2",
"typescript": "~5.7.2",
"vitest": "^3.0.3"
"typescript": "~5.8.2",
"vitest": "^3.0.9"
},
"//metadata": {
"migrationDate": "2023-03-08T18:36:03.000Z"
+11
View File
@@ -259,6 +259,17 @@ export interface WebResourceLike {
* Does nothing when running in the browser.
*/
agent?: Agent;
/**
* Additional options to set on the request. This provides a way to override
* existing ones or provide request properties that are not declared.
*
* For possible valid properties, see
* - NodeJS https.request options: https://nodejs.org/api/http.html#httprequestoptions-callback
* - Browser RequestInit: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit
*
* WARNING: Options specified here will override any properties of same names when request is sent by {@link HttpClient}.
*/
requestOverrides?: Record<string, unknown>;
/**
* Clone this request object.
*/
+3
View File
@@ -34,6 +34,7 @@ export function toPipelineRequest(webResource, options = {}) {
proxySettings: webResource.proxySettings,
streamResponseStatusCodes: webResource.streamResponseStatusCodes,
agent: webResource.agent,
requestOverrides: webResource.requestOverrides,
});
if (options.originalRequest) {
newRequest[originalClientRequestSymbol] =
@@ -61,6 +62,7 @@ export function toWebResourceLike(request, options) {
proxySettings: request.proxySettings,
streamResponseStatusCodes: request.streamResponseStatusCodes,
agent: request.agent,
requestOverrides: request.requestOverrides,
clone() {
throw new Error("Cannot clone a non-proxied WebResourceLike");
},
@@ -105,6 +107,7 @@ export function toWebResourceLike(request, options) {
"proxySettings",
"streamResponseStatusCodes",
"agent",
"requestOverrides",
];
if (typeof prop === "string" && passThroughProps.includes(prop)) {
request[prop] = value;
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -5,7 +5,7 @@
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.49.2"
"packageVersion": "7.52.5"
}
]
}
+11
View File
@@ -259,6 +259,17 @@ export interface WebResourceLike {
* Does nothing when running in the browser.
*/
agent?: Agent;
/**
* Additional options to set on the request. This provides a way to override
* existing ones or provide request properties that are not declared.
*
* For possible valid properties, see
* - NodeJS https.request options: https://nodejs.org/api/http.html#httprequestoptions-callback
* - Browser RequestInit: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit
*
* WARNING: Options specified here will override any properties of same names when request is sent by {@link HttpClient}.
*/
requestOverrides?: Record<string, unknown>;
/**
* Clone this request object.
*/
+3
View File
@@ -40,6 +40,7 @@ function toPipelineRequest(webResource, options = {}) {
proxySettings: webResource.proxySettings,
streamResponseStatusCodes: webResource.streamResponseStatusCodes,
agent: webResource.agent,
requestOverrides: webResource.requestOverrides,
});
if (options.originalRequest) {
newRequest[originalClientRequestSymbol] =
@@ -67,6 +68,7 @@ function toWebResourceLike(request, options) {
proxySettings: request.proxySettings,
streamResponseStatusCodes: request.streamResponseStatusCodes,
agent: request.agent,
requestOverrides: request.requestOverrides,
clone() {
throw new Error("Cannot clone a non-proxied WebResourceLike");
},
@@ -111,6 +113,7 @@ function toWebResourceLike(request, options) {
"proxySettings",
"streamResponseStatusCodes",
"agent",
"requestOverrides",
];
if (typeof prop === "string" && passThroughProps.includes(prop)) {
request[prop] = value;
File diff suppressed because one or more lines are too long
+11
View File
@@ -259,6 +259,17 @@ export interface WebResourceLike {
* Does nothing when running in the browser.
*/
agent?: Agent;
/**
* Additional options to set on the request. This provides a way to override
* existing ones or provide request properties that are not declared.
*
* For possible valid properties, see
* - NodeJS https.request options: https://nodejs.org/api/http.html#httprequestoptions-callback
* - Browser RequestInit: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit
*
* WARNING: Options specified here will override any properties of same names when request is sent by {@link HttpClient}.
*/
requestOverrides?: Record<string, unknown>;
/**
* Clone this request object.
*/
+3
View File
@@ -34,6 +34,7 @@ export function toPipelineRequest(webResource, options = {}) {
proxySettings: webResource.proxySettings,
streamResponseStatusCodes: webResource.streamResponseStatusCodes,
agent: webResource.agent,
requestOverrides: webResource.requestOverrides,
});
if (options.originalRequest) {
newRequest[originalClientRequestSymbol] =
@@ -61,6 +62,7 @@ export function toWebResourceLike(request, options) {
proxySettings: request.proxySettings,
streamResponseStatusCodes: request.streamResponseStatusCodes,
agent: request.agent,
requestOverrides: request.requestOverrides,
clone() {
throw new Error("Cannot clone a non-proxied WebResourceLike");
},
@@ -105,6 +107,7 @@ export function toWebResourceLike(request, options) {
"proxySettings",
"streamResponseStatusCodes",
"agent",
"requestOverrides",
];
if (typeof prop === "string" && passThroughProps.includes(prop)) {
request[prop] = value;
File diff suppressed because one or more lines are too long
+11
View File
@@ -259,6 +259,17 @@ export interface WebResourceLike {
* Does nothing when running in the browser.
*/
agent?: Agent;
/**
* Additional options to set on the request. This provides a way to override
* existing ones or provide request properties that are not declared.
*
* For possible valid properties, see
* - NodeJS https.request options: https://nodejs.org/api/http.html#httprequestoptions-callback
* - Browser RequestInit: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit
*
* WARNING: Options specified here will override any properties of same names when request is sent by {@link HttpClient}.
*/
requestOverrides?: Record<string, unknown>;
/**
* Clone this request object.
*/
+3
View File
@@ -34,6 +34,7 @@ export function toPipelineRequest(webResource, options = {}) {
proxySettings: webResource.proxySettings,
streamResponseStatusCodes: webResource.streamResponseStatusCodes,
agent: webResource.agent,
requestOverrides: webResource.requestOverrides,
});
if (options.originalRequest) {
newRequest[originalClientRequestSymbol] =
@@ -61,6 +62,7 @@ export function toWebResourceLike(request, options) {
proxySettings: request.proxySettings,
streamResponseStatusCodes: request.streamResponseStatusCodes,
agent: request.agent,
requestOverrides: request.requestOverrides,
clone() {
throw new Error("Cannot clone a non-proxied WebResourceLike");
},
@@ -105,6 +107,7 @@ export function toWebResourceLike(request, options) {
"proxySettings",
"streamResponseStatusCodes",
"agent",
"requestOverrides",
];
if (typeof prop === "string" && passThroughProps.includes(prop)) {
request[prop] = value;
File diff suppressed because one or more lines are too long
+6 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@azure/core-http-compat",
"version": "2.2.0",
"version": "2.3.0",
"description": "Core HTTP Compatibility Library to bridge the gap between Core V1 & V2 packages.",
"sdk-type": "client",
"type": "module",
@@ -77,19 +77,18 @@
"dependencies": {
"@azure/abort-controller": "^2.0.0",
"@azure/core-client": "^1.3.0",
"@azure/core-rest-pipeline": "^1.19.0"
"@azure/core-rest-pipeline": "^1.20.0"
},
"devDependencies": {
"@azure-tools/test-utils": "^1.0.1",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@types/node": "^18.0.0",
"@vitest/browser": "^3.0.3",
"@vitest/coverage-istanbul": "^3.0.3",
"@vitest/browser": "^3.0.9",
"@vitest/coverage-istanbul": "^3.0.9",
"eslint": "^9.9.0",
"playwright": "^1.41.2",
"typescript": "~5.7.2",
"vitest": "^3.0.3"
"typescript": "~5.8.2",
"vitest": "^3.0.9"
},
"//metadata": {
"migrationDate": "2023-03-08T18:36:03.000Z"
@@ -1,40 +0,0 @@
import type { AccessToken } from "@azure/core-auth";
/**
* Defines the default token refresh buffer duration.
*/
export declare const DefaultTokenRefreshBufferMs: number;
/**
* Provides a cache for an AccessToken that was that
* was returned from a TokenCredential.
*/
export interface AccessTokenCache {
/**
* Sets the cached token.
*
* @param accessToken - The AccessToken to be cached or null to
* clear the cached token.
*/
setCachedToken(accessToken: AccessToken | undefined): void;
/**
* Returns the cached AccessToken or undefined if nothing is cached.
*/
getCachedToken(): AccessToken | undefined;
}
/**
* Provides an AccessTokenCache implementation which clears
* the cached AccessToken's after the expiresOnTimestamp has
* passed.
* @internal
*/
export declare class ExpiringAccessTokenCache implements AccessTokenCache {
private tokenRefreshBufferMs;
private cachedToken?;
/**
* Constructs an instance of ExpiringAccessTokenCache with
* an optional expiration buffer time.
*/
constructor(tokenRefreshBufferMs?: number);
setCachedToken(accessToken: AccessToken | undefined): void;
getCachedToken(): AccessToken | undefined;
}
//# sourceMappingURL=accessTokenCache.d.ts.map
@@ -1,32 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* Defines the default token refresh buffer duration.
*/
export const DefaultTokenRefreshBufferMs = 2 * 60 * 1000; // 2 Minutes
/**
* Provides an AccessTokenCache implementation which clears
* the cached AccessToken's after the expiresOnTimestamp has
* passed.
* @internal
*/
export class ExpiringAccessTokenCache {
/**
* Constructs an instance of ExpiringAccessTokenCache with
* an optional expiration buffer time.
*/
constructor(tokenRefreshBufferMs = DefaultTokenRefreshBufferMs) {
this.tokenRefreshBufferMs = tokenRefreshBufferMs;
}
setCachedToken(accessToken) {
this.cachedToken = accessToken;
}
getCachedToken() {
if (this.cachedToken &&
Date.now() + this.tokenRefreshBufferMs >= this.cachedToken.expiresOnTimestamp) {
this.cachedToken = undefined;
}
return this.cachedToken;
}
}
//# sourceMappingURL=accessTokenCache.js.map
@@ -1 +0,0 @@
{"version":3,"file":"accessTokenCache.js","sourceRoot":"","sources":["../../src/accessTokenCache.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AAqBtE;;;;;GAKG;AACH,MAAM,OAAO,wBAAwB;IAInC;;;OAGG;IACH,YAAY,uBAA+B,2BAA2B;QACpE,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IAED,cAAc,CAAC,WAAoC;QACjD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,cAAc;QACZ,IACE,IAAI,CAAC,WAAW;YAChB,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAC7E,CAAC;YACD,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC/B,CAAC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken } from \"@azure/core-auth\";\n\n/**\n * Defines the default token refresh buffer duration.\n */\nexport const DefaultTokenRefreshBufferMs = 2 * 60 * 1000; // 2 Minutes\n\n/**\n * Provides a cache for an AccessToken that was that\n * was returned from a TokenCredential.\n */\nexport interface AccessTokenCache {\n /**\n * Sets the cached token.\n *\n * @param accessToken - The AccessToken to be cached or null to\n * clear the cached token.\n */\n setCachedToken(accessToken: AccessToken | undefined): void;\n\n /**\n * Returns the cached AccessToken or undefined if nothing is cached.\n */\n getCachedToken(): AccessToken | undefined;\n}\n\n/**\n * Provides an AccessTokenCache implementation which clears\n * the cached AccessToken's after the expiresOnTimestamp has\n * passed.\n * @internal\n */\nexport class ExpiringAccessTokenCache implements AccessTokenCache {\n private tokenRefreshBufferMs: number;\n private cachedToken?: AccessToken;\n\n /**\n * Constructs an instance of ExpiringAccessTokenCache with\n * an optional expiration buffer time.\n */\n constructor(tokenRefreshBufferMs: number = DefaultTokenRefreshBufferMs) {\n this.tokenRefreshBufferMs = tokenRefreshBufferMs;\n }\n\n setCachedToken(accessToken: AccessToken | undefined): void {\n this.cachedToken = accessToken;\n }\n\n getCachedToken(): AccessToken | undefined {\n if (\n this.cachedToken &&\n Date.now() + this.tokenRefreshBufferMs >= this.cachedToken.expiresOnTimestamp\n ) {\n this.cachedToken = undefined;\n }\n\n return this.cachedToken;\n }\n}\n"]}
+1 -1
View File
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export const SDK_VERSION = "1.19.1";
export const SDK_VERSION = "1.21.0";
export const DEFAULT_RETRY_POLICY_COUNT = 3;
//# sourceMappingURL=constants.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAW,QAAQ,CAAC;AAE5C,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const SDK_VERSION: string = \"1.19.1\";\n\nexport const DEFAULT_RETRY_POLICY_COUNT = 3;\n"]}
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAW,QAAQ,CAAC;AAE5C,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const SDK_VERSION: string = \"1.21.0\";\n\nexport const DEFAULT_RETRY_POLICY_COUNT = 3;\n"]}
@@ -14,6 +14,7 @@ import { setClientRequestIdPolicy } from "./policies/setClientRequestIdPolicy.js
import { agentPolicy } from "./policies/agentPolicy.js";
import { tlsPolicy } from "./policies/tlsPolicy.js";
import { tracingPolicy } from "./policies/tracingPolicy.js";
import { wrapAbortSignalLikePolicy } from "./policies/wrapAbortSignalLikePolicy.js";
/**
* Create a new pipeline with a default set of customizable policies.
* @param options - Options to configure a custom pipeline.
@@ -31,6 +32,7 @@ export function createPipelineFromOptions(options) {
pipeline.addPolicy(proxyPolicy(options.proxyOptions));
pipeline.addPolicy(decompressResponsePolicy());
}
pipeline.addPolicy(wrapAbortSignalLikePolicy());
pipeline.addPolicy(formDataPolicy(), { beforePolicies: [multipartPolicyName] });
pipeline.addPolicy(userAgentPolicy(options.userAgentOptions));
pipeline.addPolicy(setClientRequestIdPolicy((_a = options.telemetryOptions) === null || _a === void 0 ? void 0 : _a.clientRequestIdHeaderName));
File diff suppressed because one or more lines are too long
@@ -3,4 +3,4 @@ import type { HttpClient } from "./interfaces.js";
* Create the correct HttpClient for the current environment.
*/
export declare function createDefaultHttpClient(): HttpClient;
//# sourceMappingURL=defaultHttpClient-browser.d.mts.map
//# sourceMappingURL=defaultHttpClient.d.ts.map
+21 -3
View File
@@ -1,10 +1,28 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { createFetchHttpClient } from "./fetchHttpClient.js";
import { createDefaultHttpClient as tspCreateDefaultHttpClient } from "@typespec/ts-http-runtime";
import { wrapAbortSignalLike } from "./util/wrapAbortSignal.js";
/**
* Create the correct HttpClient for the current environment.
*/
export function createDefaultHttpClient() {
return createFetchHttpClient();
const client = tspCreateDefaultHttpClient();
return {
async sendRequest(request) {
// we wrap any AbortSignalLike here since the TypeSpec runtime expects a native AbortSignal.
// 99% of the time, this should be a no-op since a native AbortSignal is passed in.
const { abortSignal, cleanup } = request.abortSignal
? wrapAbortSignalLike(request.abortSignal)
: {};
try {
// eslint-disable-next-line no-param-reassign
request.abortSignal = abortSignal;
return await client.sendRequest(request);
}
finally {
cleanup === null || cleanup === void 0 ? void 0 : cleanup();
}
},
};
}
//# sourceMappingURL=defaultHttpClient-browser.mjs.map
//# sourceMappingURL=defaultHttpClient.js.map
@@ -0,0 +1 @@
{"version":3,"file":"defaultHttpClient.js","sourceRoot":"","sources":["../../src/defaultHttpClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,uBAAuB,IAAI,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGhE;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,MAAM,MAAM,GAAG,0BAA0B,EAAE,CAAC;IAC5C,OAAO;QACL,KAAK,CAAC,WAAW,CAAC,OAAO;YACvB,4FAA4F;YAC5F,mFAAmF;YACnF,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW;gBAClD,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC;gBAC1C,CAAC,CAAC,EAAE,CAAC;YACP,IAAI,CAAC;gBACH,6CAA6C;gBAC7C,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;gBAClC,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC,OAA6B,CAAC,CAAC;YACjE,CAAC;oBAAS,CAAC;gBACT,OAAO,aAAP,OAAO,uBAAP,OAAO,EAAI,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient } from \"./interfaces.js\";\nimport { createDefaultHttpClient as tspCreateDefaultHttpClient } from \"@typespec/ts-http-runtime\";\nimport { wrapAbortSignalLike } from \"./util/wrapAbortSignal.js\";\nimport { type PipelineRequest as TspPipelineRequest } from \"@typespec/ts-http-runtime\";\n\n/**\n * Create the correct HttpClient for the current environment.\n */\nexport function createDefaultHttpClient(): HttpClient {\n const client = tspCreateDefaultHttpClient();\n return {\n async sendRequest(request) {\n // we wrap any AbortSignalLike here since the TypeSpec runtime expects a native AbortSignal.\n // 99% of the time, this should be a no-op since a native AbortSignal is passed in.\n const { abortSignal, cleanup } = request.abortSignal\n ? wrapAbortSignalLike(request.abortSignal)\n : {};\n try {\n // eslint-disable-next-line no-param-reassign\n request.abortSignal = abortSignal;\n return await client.sendRequest(request as TspPipelineRequest);\n } finally {\n cleanup?.();\n }\n },\n };\n}\n"]}
File diff suppressed because one or more lines are too long
+2 -80
View File
@@ -1,89 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
function normalizeName(name) {
return name.toLowerCase();
}
function* headerIterator(map) {
for (const entry of map.values()) {
yield [entry.name, entry.value];
}
}
class HttpHeadersImpl {
constructor(rawHeaders) {
this._headersMap = new Map();
if (rawHeaders) {
for (const headerName of Object.keys(rawHeaders)) {
this.set(headerName, rawHeaders[headerName]);
}
}
}
/**
* Set a header in this collection with the provided name and value. The name is
* case-insensitive.
* @param name - The name of the header to set. This value is case-insensitive.
* @param value - The value of the header to set.
*/
set(name, value) {
this._headersMap.set(normalizeName(name), { name, value: String(value).trim() });
}
/**
* Get the header value for the provided header name, or undefined if no header exists in this
* collection with the provided name.
* @param name - The name of the header. This value is case-insensitive.
*/
get(name) {
var _a;
return (_a = this._headersMap.get(normalizeName(name))) === null || _a === void 0 ? void 0 : _a.value;
}
/**
* Get whether or not this header collection contains a header entry for the provided header name.
* @param name - The name of the header to set. This value is case-insensitive.
*/
has(name) {
return this._headersMap.has(normalizeName(name));
}
/**
* Remove the header with the provided headerName.
* @param name - The name of the header to remove.
*/
delete(name) {
this._headersMap.delete(normalizeName(name));
}
/**
* Get the JSON object representation of this HTTP header collection.
*/
toJSON(options = {}) {
const result = {};
if (options.preserveCase) {
for (const entry of this._headersMap.values()) {
result[entry.name] = entry.value;
}
}
else {
for (const [normalizedName, entry] of this._headersMap) {
result[normalizedName] = entry.value;
}
}
return result;
}
/**
* Get the string representation of this HTTP header collection.
*/
toString() {
return JSON.stringify(this.toJSON({ preserveCase: true }));
}
/**
* Iterate over tuples of header [name, value] pairs.
*/
[Symbol.iterator]() {
return headerIterator(this._headersMap);
}
}
import { createHttpHeaders as tspCreateHttpHeaders } from "@typespec/ts-http-runtime";
/**
* Creates an object that satisfies the `HttpHeaders` interface.
* @param rawHeaders - A simple object representing initial headers
*/
export function createHttpHeaders(rawHeaders) {
return new HttpHeadersImpl(rawHeaders);
return tspCreateHttpHeaders(rawHeaders);
}
//# sourceMappingURL=httpHeaders.js.map
File diff suppressed because one or more lines are too long
+2 -3
View File
@@ -17,7 +17,7 @@ export { createPipelineFromOptions, type TelemetryOptions, type InternalPipeline
export { createDefaultHttpClient } from "./defaultHttpClient.js";
export { createHttpHeaders } from "./httpHeaders.js";
export { createPipelineRequest, type PipelineRequestOptions } from "./pipelineRequest.js";
export { RestError, type RestErrorOptions, isRestError } from "./restError.js";
export { RestError, type RestErrorOptions, type RestErrorConstructor, isRestError, } from "./restError.js";
export { decompressResponsePolicy, decompressResponsePolicyName, } from "./policies/decompressResponsePolicy.js";
export { exponentialRetryPolicy, type ExponentialRetryPolicyOptions, exponentialRetryPolicyName, } from "./policies/exponentialRetryPolicy.js";
export { setClientRequestIdPolicy, setClientRequestIdPolicyName, } from "./policies/setClientRequestIdPolicy.js";
@@ -27,8 +27,7 @@ export { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from "./policie
export { redirectPolicy, redirectPolicyName, type RedirectPolicyOptions, } from "./policies/redirectPolicy.js";
export { systemErrorRetryPolicy, type SystemErrorRetryPolicyOptions, systemErrorRetryPolicyName, } from "./policies/systemErrorRetryPolicy.js";
export { throttlingRetryPolicy, throttlingRetryPolicyName, type ThrottlingRetryPolicyOptions, } from "./policies/throttlingRetryPolicy.js";
export { retryPolicy, type RetryPolicyOptions } from "./policies/retryPolicy.js";
export type { RetryStrategy, RetryInformation, RetryModifiers, } from "./retryStrategies/retryStrategy.js";
export { retryPolicy, type RetryPolicyOptions, type RetryStrategy, type RetryInformation, type RetryModifiers, } from "./policies/retryPolicy.js";
export { tracingPolicy, tracingPolicyName, type TracingPolicyOptions, } from "./policies/tracingPolicy.js";
export { defaultRetryPolicy, type DefaultRetryPolicyOptions, } from "./policies/defaultRetryPolicy.js";
export { userAgentPolicy, userAgentPolicyName, type UserAgentPolicyOptions, } from "./policies/userAgentPolicy.js";
+2 -2
View File
@@ -5,7 +5,7 @@ export { createPipelineFromOptions, } from "./createPipelineFromOptions.js";
export { createDefaultHttpClient } from "./defaultHttpClient.js";
export { createHttpHeaders } from "./httpHeaders.js";
export { createPipelineRequest } from "./pipelineRequest.js";
export { RestError, isRestError } from "./restError.js";
export { RestError, isRestError, } from "./restError.js";
export { decompressResponsePolicy, decompressResponsePolicyName, } from "./policies/decompressResponsePolicy.js";
export { exponentialRetryPolicy, exponentialRetryPolicyName, } from "./policies/exponentialRetryPolicy.js";
export { setClientRequestIdPolicy, setClientRequestIdPolicyName, } from "./policies/setClientRequestIdPolicy.js";
@@ -15,7 +15,7 @@ export { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from "./policie
export { redirectPolicy, redirectPolicyName, } from "./policies/redirectPolicy.js";
export { systemErrorRetryPolicy, systemErrorRetryPolicyName, } from "./policies/systemErrorRetryPolicy.js";
export { throttlingRetryPolicy, throttlingRetryPolicyName, } from "./policies/throttlingRetryPolicy.js";
export { retryPolicy } from "./policies/retryPolicy.js";
export { retryPolicy, } from "./policies/retryPolicy.js";
export { tracingPolicy, tracingPolicyName, } from "./policies/tracingPolicy.js";
export { defaultRetryPolicy, } from "./policies/defaultRetryPolicy.js";
export { userAgentPolicy, userAgentPolicyName, } from "./policies/userAgentPolicy.js";
File diff suppressed because one or more lines are too long
+12
View File
@@ -197,6 +197,17 @@ export interface PipelineRequest {
enableBrowserStreams?: boolean;
/** Settings for configuring TLS authentication */
tlsSettings?: TlsSettings;
/**
* Additional options to set on the request. This provides a way to override
* existing ones or provide request properties that are not declared.
*
* For possible valid properties, see
* - NodeJS https.request options: https://nodejs.org/api/http.html#httprequestoptions-callback
* - Browser RequestInit: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit
*
* WARNING: Options specified here will override any properties of same names when request is sent by {@link HttpClient}.
*/
requestOverrides?: Record<string, unknown>;
}
/**
* Metadata about a response received by the pipeline.
@@ -269,6 +280,7 @@ export type TransferProgressEvent = {
export interface ProxySettings {
/**
* The proxy's host address.
* Must include the protocol (e.g., http:// or https://).
*/
host: string;
/**
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -253
View File
@@ -1,262 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const ValidPhaseNames = new Set(["Deserialize", "Serialize", "Retry", "Sign"]);
/**
* A private implementation of Pipeline.
* Do not export this class from the package.
* @internal
*/
class HttpPipeline {
constructor(policies) {
var _a;
this._policies = [];
this._policies = (_a = policies === null || policies === void 0 ? void 0 : policies.slice(0)) !== null && _a !== void 0 ? _a : [];
this._orderedPolicies = undefined;
}
addPolicy(policy, options = {}) {
if (options.phase && options.afterPhase) {
throw new Error("Policies inside a phase cannot specify afterPhase.");
}
if (options.phase && !ValidPhaseNames.has(options.phase)) {
throw new Error(`Invalid phase name: ${options.phase}`);
}
if (options.afterPhase && !ValidPhaseNames.has(options.afterPhase)) {
throw new Error(`Invalid afterPhase name: ${options.afterPhase}`);
}
this._policies.push({
policy,
options,
});
this._orderedPolicies = undefined;
}
removePolicy(options) {
const removedPolicies = [];
this._policies = this._policies.filter((policyDescriptor) => {
if ((options.name && policyDescriptor.policy.name === options.name) ||
(options.phase && policyDescriptor.options.phase === options.phase)) {
removedPolicies.push(policyDescriptor.policy);
return false;
}
else {
return true;
}
});
this._orderedPolicies = undefined;
return removedPolicies;
}
sendRequest(httpClient, request) {
const policies = this.getOrderedPolicies();
const pipeline = policies.reduceRight((next, policy) => {
return (req) => {
return policy.sendRequest(req, next);
};
}, (req) => httpClient.sendRequest(req));
return pipeline(request);
}
getOrderedPolicies() {
if (!this._orderedPolicies) {
this._orderedPolicies = this.orderPolicies();
}
return this._orderedPolicies;
}
clone() {
return new HttpPipeline(this._policies);
}
static create() {
return new HttpPipeline();
}
orderPolicies() {
/**
* The goal of this method is to reliably order pipeline policies
* based on their declared requirements when they were added.
*
* Order is first determined by phase:
*
* 1. Serialize Phase
* 2. Policies not in a phase
* 3. Deserialize Phase
* 4. Retry Phase
* 5. Sign Phase
*
* Within each phase, policies are executed in the order
* they were added unless they were specified to execute
* before/after other policies or after a particular phase.
*
* To determine the final order, we will walk the policy list
* in phase order multiple times until all dependencies are
* satisfied.
*
* `afterPolicies` are the set of policies that must be
* executed before a given policy. This requirement is
* considered satisfied when each of the listed policies
* have been scheduled.
*
* `beforePolicies` are the set of policies that must be
* executed after a given policy. Since this dependency
* can be expressed by converting it into a equivalent
* `afterPolicies` declarations, they are normalized
* into that form for simplicity.
*
* An `afterPhase` dependency is considered satisfied when all
* policies in that phase have scheduled.
*
*/
const result = [];
// Track all policies we know about.
const policyMap = new Map();
function createPhase(name) {
return {
name,
policies: new Set(),
hasRun: false,
hasAfterPolicies: false,
};
}
// Track policies for each phase.
const serializePhase = createPhase("Serialize");
const noPhase = createPhase("None");
const deserializePhase = createPhase("Deserialize");
const retryPhase = createPhase("Retry");
const signPhase = createPhase("Sign");
// a list of phases in order
const orderedPhases = [serializePhase, noPhase, deserializePhase, retryPhase, signPhase];
// Small helper function to map phase name to each Phase
function getPhase(phase) {
if (phase === "Retry") {
return retryPhase;
}
else if (phase === "Serialize") {
return serializePhase;
}
else if (phase === "Deserialize") {
return deserializePhase;
}
else if (phase === "Sign") {
return signPhase;
}
else {
return noPhase;
}
}
// First walk each policy and create a node to track metadata.
for (const descriptor of this._policies) {
const policy = descriptor.policy;
const options = descriptor.options;
const policyName = policy.name;
if (policyMap.has(policyName)) {
throw new Error("Duplicate policy names not allowed in pipeline");
}
const node = {
policy,
dependsOn: new Set(),
dependants: new Set(),
};
if (options.afterPhase) {
node.afterPhase = getPhase(options.afterPhase);
node.afterPhase.hasAfterPolicies = true;
}
policyMap.set(policyName, node);
const phase = getPhase(options.phase);
phase.policies.add(node);
}
// Now that each policy has a node, connect dependency references.
for (const descriptor of this._policies) {
const { policy, options } = descriptor;
const policyName = policy.name;
const node = policyMap.get(policyName);
if (!node) {
throw new Error(`Missing node for policy ${policyName}`);
}
if (options.afterPolicies) {
for (const afterPolicyName of options.afterPolicies) {
const afterNode = policyMap.get(afterPolicyName);
if (afterNode) {
// Linking in both directions helps later
// when we want to notify dependants.
node.dependsOn.add(afterNode);
afterNode.dependants.add(node);
}
}
}
if (options.beforePolicies) {
for (const beforePolicyName of options.beforePolicies) {
const beforeNode = policyMap.get(beforePolicyName);
if (beforeNode) {
// To execute before another node, make it
// depend on the current node.
beforeNode.dependsOn.add(node);
node.dependants.add(beforeNode);
}
}
}
}
function walkPhase(phase) {
phase.hasRun = true;
// Sets iterate in insertion order
for (const node of phase.policies) {
if (node.afterPhase && (!node.afterPhase.hasRun || node.afterPhase.policies.size)) {
// If this node is waiting on a phase to complete,
// we need to skip it for now.
// Even if the phase is empty, we should wait for it
// to be walked to avoid re-ordering policies.
continue;
}
if (node.dependsOn.size === 0) {
// If there's nothing else we're waiting for, we can
// add this policy to the result list.
result.push(node.policy);
// Notify anything that depends on this policy that
// the policy has been scheduled.
for (const dependant of node.dependants) {
dependant.dependsOn.delete(node);
}
policyMap.delete(node.policy.name);
phase.policies.delete(node);
}
}
}
function walkPhases() {
for (const phase of orderedPhases) {
walkPhase(phase);
// if the phase isn't complete
if (phase.policies.size > 0 && phase !== noPhase) {
if (!noPhase.hasRun) {
// Try running noPhase to see if that unblocks this phase next tick.
// This can happen if a phase that happens before noPhase
// is waiting on a noPhase policy to complete.
walkPhase(noPhase);
}
// Don't proceed to the next phase until this phase finishes.
return;
}
if (phase.hasAfterPolicies) {
// Run any policies unblocked by this phase
walkPhase(noPhase);
}
}
}
// Iterate until we've put every node in the result list.
let iteration = 0;
while (policyMap.size > 0) {
iteration++;
const initialResultLength = result.length;
// Keep walking each phase in order until we can order every node.
walkPhases();
// The result list *should* get at least one larger each time
// after the first full pass.
// Otherwise, we're going to loop forever.
if (result.length <= initialResultLength && iteration > 1) {
throw new Error("Cannot satisfy policy dependencies due to requirements cycle.");
}
}
return result;
}
}
import { createEmptyPipeline as tspCreateEmptyPipeline } from "@typespec/ts-http-runtime";
/**
* Creates a totally empty pipeline.
* Useful for testing or creating a custom one.
*/
export function createEmptyPipeline() {
return HttpPipeline.create();
return tspCreateEmptyPipeline();
}
//# sourceMappingURL=pipeline.js.map
File diff suppressed because one or more lines are too long
@@ -95,6 +95,17 @@ export interface PipelineRequestOptions {
onDownloadProgress?: (progress: TransferProgressEvent) => void;
/** Set to true if the request is sent over HTTP instead of HTTPS */
allowInsecureConnection?: boolean;
/**
* Additional options to set on the request. This provides a way to override
* existing ones or provide request properties that are not declared.
*
* For possible valid properties, see
* - NodeJS https.request options: https://nodejs.org/api/http.html#httprequestoptions-callback
* - Browser RequestInit: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit
*
* WARNING: Options specified here will override any properties of same names when request is sent by {@link HttpClient}.
*/
requestOverrides?: Record<string, unknown>;
}
/**
* Creates a new pipeline request with the given options.
+5 -28
View File
@@ -1,38 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { createHttpHeaders } from "./httpHeaders.js";
import { randomUUID } from "@azure/core-util";
class PipelineRequestImpl {
constructor(options) {
var _a, _b, _c, _d, _e, _f, _g;
this.url = options.url;
this.body = options.body;
this.headers = (_a = options.headers) !== null && _a !== void 0 ? _a : createHttpHeaders();
this.method = (_b = options.method) !== null && _b !== void 0 ? _b : "GET";
this.timeout = (_c = options.timeout) !== null && _c !== void 0 ? _c : 0;
this.multipartBody = options.multipartBody;
this.formData = options.formData;
this.disableKeepAlive = (_d = options.disableKeepAlive) !== null && _d !== void 0 ? _d : false;
this.proxySettings = options.proxySettings;
this.streamResponseStatusCodes = options.streamResponseStatusCodes;
this.withCredentials = (_e = options.withCredentials) !== null && _e !== void 0 ? _e : false;
this.abortSignal = options.abortSignal;
this.tracingOptions = options.tracingOptions;
this.onUploadProgress = options.onUploadProgress;
this.onDownloadProgress = options.onDownloadProgress;
this.requestId = options.requestId || randomUUID();
this.allowInsecureConnection = (_f = options.allowInsecureConnection) !== null && _f !== void 0 ? _f : false;
this.enableBrowserStreams = (_g = options.enableBrowserStreams) !== null && _g !== void 0 ? _g : false;
this.agent = options.agent;
this.tlsSettings = options.tlsSettings;
}
}
import { createPipelineRequest as tspCreatePipelineRequest, } from "@typespec/ts-http-runtime";
/**
* Creates a new pipeline request with the given options.
* This method is to allow for the easy setting of default values and not required.
* @param options - The options to create the request with.
*/
export function createPipelineRequest(options) {
return new PipelineRequestImpl(options);
// Cast required due to difference between ts-http-runtime requiring AbortSignal while core-rest-pipeline allows
// the more generic AbortSignalLike. The wrapAbortSignalLike pipeline policy will take care of ensuring that any AbortSignalLike in the request
// is converted into a true AbortSignal.
return tspCreatePipelineRequest(options);
}
//# sourceMappingURL=pipelineRequest.js.map
File diff suppressed because one or more lines are too long
@@ -1,22 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { agentPolicyName as tspAgentPolicyName, agentPolicy as tspAgentPolicy, } from "@typespec/ts-http-runtime/internal/policies";
/**
* Name of the Agent Policy
*/
export const agentPolicyName = "agentPolicy";
export const agentPolicyName = tspAgentPolicyName;
/**
* Gets a pipeline policy that sets http.agent
*/
export function agentPolicy(agent) {
return {
name: agentPolicyName,
sendRequest: async (req, next) => {
// Users may define an agent on the request, honor it over the client level one
if (!req.agent) {
req.agent = agent;
}
return next(req);
},
};
return tspAgentPolicy(agent);
}
//# sourceMappingURL=agentPolicy.js.map
@@ -1 +1 @@
{"version":3,"file":"agentPolicy.js","sourceRoot":"","sources":["../../../src/policies/agentPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YAC/B,+EAA+E;YAC/E,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;gBACf,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;YACpB,CAAC;YACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport type { Agent } from \"../interfaces.js\";\n\n/**\n * Name of the Agent Policy\n */\nexport const agentPolicyName = \"agentPolicy\";\n\n/**\n * Gets a pipeline policy that sets http.agent\n */\nexport function agentPolicy(agent?: Agent): PipelinePolicy {\n return {\n name: agentPolicyName,\n sendRequest: async (req, next) => {\n // Users may define an agent on the request, honor it over the client level one\n if (!req.agent) {\n req.agent = agent;\n }\n return next(req);\n },\n };\n}\n"]}
{"version":3,"file":"agentPolicy.js","sourceRoot":"","sources":["../../../src/policies/agentPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EACL,eAAe,IAAI,kBAAkB,EACrC,WAAW,IAAI,cAAc,GAC9B,MAAM,6CAA6C,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport type { Agent } from \"../interfaces.js\";\nimport {\n agentPolicyName as tspAgentPolicyName,\n agentPolicy as tspAgentPolicy,\n} from \"@typespec/ts-http-runtime/internal/policies\";\n\n/**\n * Name of the Agent Policy\n */\nexport const agentPolicyName = tspAgentPolicyName;\n\n/**\n * Gets a pipeline policy that sets http.agent\n */\nexport function agentPolicy(agent?: Agent): PipelinePolicy {\n return tspAgentPolicy(agent);\n}\n"]}
@@ -27,7 +27,7 @@ export interface AuxiliaryAuthenticationHeaderPolicyOptions {
* A policy for external tokens to `x-ms-authorization-auxiliary` header.
* This header will be used when creating a cross-tenant application we may need to handle authentication requests
* for resources that are in different tenants.
* You could see [ARM docs](https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant) for a rundown of how this feature works
* You could see [ARM docs](https://learn.microsoft.com/azure/azure-resource-manager/management/authenticate-multi-tenant) for a rundown of how this feature works
*/
export declare function auxiliaryAuthenticationHeaderPolicy(options: AuxiliaryAuthenticationHeaderPolicyOptions): PipelinePolicy;
//# sourceMappingURL=auxiliaryAuthenticationHeaderPolicy.d.ts.map
@@ -20,7 +20,7 @@ async function sendAuthorizeRequest(options) {
* A policy for external tokens to `x-ms-authorization-auxiliary` header.
* This header will be used when creating a cross-tenant application we may need to handle authentication requests
* for resources that are in different tenants.
* You could see [ARM docs](https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant) for a rundown of how this feature works
* You could see [ARM docs](https://learn.microsoft.com/azure/azure-resource-manager/management/authenticate-multi-tenant) for a rundown of how this feature works
*/
export function auxiliaryAuthenticationHeaderPolicy(options) {
const { credentials, scopes } = options;
File diff suppressed because one or more lines are too long
@@ -1,7 +1,11 @@
import type { PipelinePolicy } from "../pipeline.js";
/**
* The programmatic identifier of the decompressResponsePolicy.
*/
export declare const decompressResponsePolicyName = "decompressResponsePolicy";
/**
* decompressResponsePolicy is not supported in the browser and attempting
* to use it will raise an error.
* A policy to enable response decompression according to Accept-Encoding header
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding
*/
export declare function decompressResponsePolicy(): never;
//# sourceMappingURL=decompressResponsePolicy-browser.d.mts.map
export declare function decompressResponsePolicy(): PipelinePolicy;
//# sourceMappingURL=decompressResponsePolicy.d.ts.map
@@ -1,14 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/*
* NOTE: When moving this file, please update "browser" section in package.json
*/
export const decompressResponsePolicyName = "decompressResponsePolicy";
import { decompressResponsePolicyName as tspDecompressResponsePolicyName, decompressResponsePolicy as tspDecompressResponsePolicy, } from "@typespec/ts-http-runtime/internal/policies";
/**
* decompressResponsePolicy is not supported in the browser and attempting
* to use it will raise an error.
* The programmatic identifier of the decompressResponsePolicy.
*/
export const decompressResponsePolicyName = tspDecompressResponsePolicyName;
/**
* A policy to enable response decompression according to Accept-Encoding header
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding
*/
export function decompressResponsePolicy() {
throw new Error("decompressResponsePolicy is not supported in browser environment");
return tspDecompressResponsePolicy();
}
//# sourceMappingURL=decompressResponsePolicy-browser.mjs.map
//# sourceMappingURL=decompressResponsePolicy.js.map
@@ -0,0 +1 @@
{"version":3,"file":"decompressResponsePolicy.js","sourceRoot":"","sources":["../../../src/policies/decompressResponsePolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EACL,4BAA4B,IAAI,+BAA+B,EAC/D,wBAAwB,IAAI,2BAA2B,GACxD,MAAM,6CAA6C,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,+BAA+B,CAAC;AAE5E;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,2BAA2B,EAAE,CAAC;AACvC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\nimport {\n decompressResponsePolicyName as tspDecompressResponsePolicyName,\n decompressResponsePolicy as tspDecompressResponsePolicy,\n} from \"@typespec/ts-http-runtime/internal/policies\";\n\n/**\n * The programmatic identifier of the decompressResponsePolicy.\n */\nexport const decompressResponsePolicyName = tspDecompressResponsePolicyName;\n\n/**\n * A policy to enable response decompression according to Accept-Encoding header\n * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding\n */\nexport function decompressResponsePolicy(): PipelinePolicy {\n return tspDecompressResponsePolicy();\n}\n"]}
@@ -1,13 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { exponentialRetryStrategy } from "../retryStrategies/exponentialRetryStrategy.js";
import { throttlingRetryStrategy } from "../retryStrategies/throttlingRetryStrategy.js";
import { retryPolicy } from "./retryPolicy.js";
import { DEFAULT_RETRY_POLICY_COUNT } from "../constants.js";
import { defaultRetryPolicyName as tspDefaultRetryPolicyName, defaultRetryPolicy as tspDefaultRetryPolicy, } from "@typespec/ts-http-runtime/internal/policies";
/**
* Name of the {@link defaultRetryPolicy}
*/
export const defaultRetryPolicyName = "defaultRetryPolicy";
export const defaultRetryPolicyName = tspDefaultRetryPolicyName;
/**
* A policy that retries according to three strategies:
* - When the server sends a 429 response with a Retry-After header.
@@ -15,12 +12,6 @@ export const defaultRetryPolicyName = "defaultRetryPolicy";
* - Or otherwise if the outgoing request fails, it will retry with an exponentially increasing delay.
*/
export function defaultRetryPolicy(options = {}) {
var _a;
return {
name: defaultRetryPolicyName,
sendRequest: retryPolicy([throttlingRetryStrategy(), exponentialRetryStrategy(options)], {
maxRetries: (_a = options.maxRetries) !== null && _a !== void 0 ? _a : DEFAULT_RETRY_POLICY_COUNT,
}).sendRequest,
};
return tspDefaultRetryPolicy(options);
}
//# sourceMappingURL=defaultRetryPolicy.js.map
@@ -1 +1 @@
{"version":3,"file":"defaultRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/defaultRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAO3D;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAqC,EAAE;;IACxE,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,WAAW,CAAC,CAAC,uBAAuB,EAAE,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC,EAAE;YACvF,UAAU,EAAE,MAAA,OAAO,CAAC,UAAU,mCAAI,0BAA0B;SAC7D,CAAC,CAAC,WAAW;KACf,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRetryOptions } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { exponentialRetryStrategy } from \"../retryStrategies/exponentialRetryStrategy.js\";\nimport { throttlingRetryStrategy } from \"../retryStrategies/throttlingRetryStrategy.js\";\nimport { retryPolicy } from \"./retryPolicy.js\";\nimport { DEFAULT_RETRY_POLICY_COUNT } from \"../constants.js\";\n\n/**\n * Name of the {@link defaultRetryPolicy}\n */\nexport const defaultRetryPolicyName = \"defaultRetryPolicy\";\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface DefaultRetryPolicyOptions extends PipelineRetryOptions {}\n\n/**\n * A policy that retries according to three strategies:\n * - When the server sends a 429 response with a Retry-After header.\n * - When there are errors in the underlying transport layer (e.g. DNS lookup failures).\n * - Or otherwise if the outgoing request fails, it will retry with an exponentially increasing delay.\n */\nexport function defaultRetryPolicy(options: DefaultRetryPolicyOptions = {}): PipelinePolicy {\n return {\n name: defaultRetryPolicyName,\n sendRequest: retryPolicy([throttlingRetryStrategy(), exponentialRetryStrategy(options)], {\n maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT,\n }).sendRequest,\n };\n}\n"]}
{"version":3,"file":"defaultRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/defaultRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EACL,sBAAsB,IAAI,yBAAyB,EACnD,kBAAkB,IAAI,qBAAqB,GAC5C,MAAM,6CAA6C,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAOhE;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAqC,EAAE;IACxE,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRetryOptions } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\nimport {\n defaultRetryPolicyName as tspDefaultRetryPolicyName,\n defaultRetryPolicy as tspDefaultRetryPolicy,\n} from \"@typespec/ts-http-runtime/internal/policies\";\n\n/**\n * Name of the {@link defaultRetryPolicy}\n */\nexport const defaultRetryPolicyName = tspDefaultRetryPolicyName;\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface DefaultRetryPolicyOptions extends PipelineRetryOptions {}\n\n/**\n * A policy that retries according to three strategies:\n * - When the server sends a 429 response with a Retry-After header.\n * - When there are errors in the underlying transport layer (e.g. DNS lookup failures).\n * - Or otherwise if the outgoing request fails, it will retry with an exponentially increasing delay.\n */\nexport function defaultRetryPolicy(options: DefaultRetryPolicyOptions = {}): PipelinePolicy {\n return tspDefaultRetryPolicy(options);\n}\n"]}
@@ -1,22 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { exponentialRetryStrategy } from "../retryStrategies/exponentialRetryStrategy.js";
import { retryPolicy } from "./retryPolicy.js";
import { DEFAULT_RETRY_POLICY_COUNT } from "../constants.js";
import { exponentialRetryPolicyName as tspExponentialRetryPolicyName, exponentialRetryPolicy as tspExponentialRetryPolicy, } from "@typespec/ts-http-runtime/internal/policies";
/**
* The programmatic identifier of the exponentialRetryPolicy.
*/
export const exponentialRetryPolicyName = "exponentialRetryPolicy";
export const exponentialRetryPolicyName = tspExponentialRetryPolicyName;
/**
* A policy that attempts to retry requests while introducing an exponentially increasing delay.
* @param options - Options that configure retry logic.
*/
export function exponentialRetryPolicy(options = {}) {
var _a;
return retryPolicy([
exponentialRetryStrategy(Object.assign(Object.assign({}, options), { ignoreSystemErrors: true })),
], {
maxRetries: (_a = options.maxRetries) !== null && _a !== void 0 ? _a : DEFAULT_RETRY_POLICY_COUNT,
});
return tspExponentialRetryPolicy(options);
}
//# sourceMappingURL=exponentialRetryPolicy.js.map
@@ -1 +1 @@
{"version":3,"file":"exponentialRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/exponentialRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAyBnE;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAyC,EAAE;;IAE3C,OAAO,WAAW,CAChB;QACE,wBAAwB,iCACnB,OAAO,KACV,kBAAkB,EAAE,IAAI,IACxB;KACH,EACD;QACE,UAAU,EAAE,MAAA,OAAO,CAAC,UAAU,mCAAI,0BAA0B;KAC7D,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { exponentialRetryStrategy } from \"../retryStrategies/exponentialRetryStrategy.js\";\nimport { retryPolicy } from \"./retryPolicy.js\";\nimport { DEFAULT_RETRY_POLICY_COUNT } from \"../constants.js\";\n\n/**\n * The programmatic identifier of the exponentialRetryPolicy.\n */\nexport const exponentialRetryPolicyName = \"exponentialRetryPolicy\";\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface ExponentialRetryPolicyOptions {\n /**\n * The maximum number of retry attempts. Defaults to 3.\n */\n maxRetries?: number;\n\n /**\n * The amount of delay in milliseconds between retry attempts. Defaults to 1000\n * (1 second.) The delay increases exponentially with each retry up to a maximum\n * specified by maxRetryDelayInMs.\n */\n retryDelayInMs?: number;\n\n /**\n * The maximum delay in milliseconds allowed before retrying an operation. Defaults\n * to 64000 (64 seconds).\n */\n maxRetryDelayInMs?: number;\n}\n\n/**\n * A policy that attempts to retry requests while introducing an exponentially increasing delay.\n * @param options - Options that configure retry logic.\n */\nexport function exponentialRetryPolicy(\n options: ExponentialRetryPolicyOptions = {},\n): PipelinePolicy {\n return retryPolicy(\n [\n exponentialRetryStrategy({\n ...options,\n ignoreSystemErrors: true,\n }),\n ],\n {\n maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT,\n },\n );\n}\n"]}
{"version":3,"file":"exponentialRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/exponentialRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EACL,0BAA0B,IAAI,6BAA6B,EAC3D,sBAAsB,IAAI,yBAAyB,GACpD,MAAM,6CAA6C,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,6BAA6B,CAAC;AAyBxE;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAyC,EAAE;IAE3C,OAAO,yBAAyB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\nimport {\n exponentialRetryPolicyName as tspExponentialRetryPolicyName,\n exponentialRetryPolicy as tspExponentialRetryPolicy,\n} from \"@typespec/ts-http-runtime/internal/policies\";\n\n/**\n * The programmatic identifier of the exponentialRetryPolicy.\n */\nexport const exponentialRetryPolicyName = tspExponentialRetryPolicyName;\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface ExponentialRetryPolicyOptions {\n /**\n * The maximum number of retry attempts. Defaults to 3.\n */\n maxRetries?: number;\n\n /**\n * The amount of delay in milliseconds between retry attempts. Defaults to 1000\n * (1 second.) The delay increases exponentially with each retry up to a maximum\n * specified by maxRetryDelayInMs.\n */\n retryDelayInMs?: number;\n\n /**\n * The maximum delay in milliseconds allowed before retrying an operation. Defaults\n * to 64000 (64 seconds).\n */\n maxRetryDelayInMs?: number;\n}\n\n/**\n * A policy that attempts to retry requests while introducing an exponentially increasing delay.\n * @param options - Options that configure retry logic.\n */\nexport function exponentialRetryPolicy(\n options: ExponentialRetryPolicyOptions = {},\n): PipelinePolicy {\n return tspExponentialRetryPolicy(options);\n}\n"]}
@@ -1,96 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { isNodeLike, stringToUint8Array } from "@azure/core-util";
import { createHttpHeaders } from "../httpHeaders.js";
import { formDataPolicyName as tspFormDataPolicyName, formDataPolicy as tspFormDataPolicy, } from "@typespec/ts-http-runtime/internal/policies";
/**
* The programmatic identifier of the formDataPolicy.
*/
export const formDataPolicyName = "formDataPolicy";
function formDataToFormDataMap(formData) {
var _a;
const formDataMap = {};
for (const [key, value] of formData.entries()) {
(_a = formDataMap[key]) !== null && _a !== void 0 ? _a : (formDataMap[key] = []);
formDataMap[key].push(value);
}
return formDataMap;
}
export const formDataPolicyName = tspFormDataPolicyName;
/**
* A policy that encodes FormData on the request into the body.
*/
export function formDataPolicy() {
return {
name: formDataPolicyName,
async sendRequest(request, next) {
if (isNodeLike && typeof FormData !== "undefined" && request.body instanceof FormData) {
request.formData = formDataToFormDataMap(request.body);
request.body = undefined;
}
if (request.formData) {
const contentType = request.headers.get("Content-Type");
if (contentType && contentType.indexOf("application/x-www-form-urlencoded") !== -1) {
request.body = wwwFormUrlEncode(request.formData);
}
else {
await prepareFormData(request.formData, request);
}
request.formData = undefined;
}
return next(request);
},
};
}
function wwwFormUrlEncode(formData) {
const urlSearchParams = new URLSearchParams();
for (const [key, value] of Object.entries(formData)) {
if (Array.isArray(value)) {
for (const subValue of value) {
urlSearchParams.append(key, subValue.toString());
}
}
else {
urlSearchParams.append(key, value.toString());
}
}
return urlSearchParams.toString();
}
async function prepareFormData(formData, request) {
// validate content type (multipart/form-data)
const contentType = request.headers.get("Content-Type");
if (contentType && !contentType.startsWith("multipart/form-data")) {
// content type is specified and is not multipart/form-data. Exit.
return;
}
request.headers.set("Content-Type", contentType !== null && contentType !== void 0 ? contentType : "multipart/form-data");
// set body to MultipartRequestBody using content from FormDataMap
const parts = [];
for (const [fieldName, values] of Object.entries(formData)) {
for (const value of Array.isArray(values) ? values : [values]) {
if (typeof value === "string") {
parts.push({
headers: createHttpHeaders({
"Content-Disposition": `form-data; name="${fieldName}"`,
}),
body: stringToUint8Array(value, "utf-8"),
});
}
else if (value === undefined || value === null || typeof value !== "object") {
throw new Error(`Unexpected value for key ${fieldName}: ${value}. Value should be serialized to string first.`);
}
else {
// using || instead of ?? here since if value.name is empty we should create a file name
const fileName = value.name || "blob";
const headers = createHttpHeaders();
headers.set("Content-Disposition", `form-data; name="${fieldName}"; filename="${fileName}"`);
// again, || is used since an empty value.type means the content type is unset
headers.set("Content-Type", value.type || "application/octet-stream");
parts.push({
headers,
body: value,
});
}
}
}
request.multipartBody = { parts };
return tspFormDataPolicy();
}
//# sourceMappingURL=formDataPolicy.js.map
File diff suppressed because one or more lines are too long
+3 -21
View File
@@ -1,34 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { logger as coreLogger } from "../log.js";
import { Sanitizer } from "../util/sanitizer.js";
import { logPolicyName as tspLogPolicyName, logPolicy as tspLogPolicy, } from "@typespec/ts-http-runtime/internal/policies";
/**
* The programmatic identifier of the logPolicy.
*/
export const logPolicyName = "logPolicy";
export const logPolicyName = tspLogPolicyName;
/**
* A policy that logs all requests and responses.
* @param options - Options to configure logPolicy.
*/
export function logPolicy(options = {}) {
var _a;
const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : coreLogger.info;
const sanitizer = new Sanitizer({
additionalAllowedHeaderNames: options.additionalAllowedHeaderNames,
additionalAllowedQueryParameters: options.additionalAllowedQueryParameters,
});
return {
name: logPolicyName,
async sendRequest(request, next) {
if (!logger.enabled) {
return next(request);
}
logger(`Request: ${sanitizer.sanitize(request)}`);
const response = await next(request);
logger(`Response status code: ${response.status}`);
logger(`Headers: ${sanitizer.sanitize(response.headers)}`);
return response;
},
};
return tspLogPolicy(Object.assign({ logger: coreLogger.info }, options));
}
//# sourceMappingURL=logPolicy.js.map
@@ -1 +1 @@
{"version":3,"file":"logPolicy.js","sourceRoot":"","sources":["../../../src/policies/logPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AA4BzC;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,UAA4B,EAAE;;IACtD,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,UAAU,CAAC,IAAI,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC;QAC9B,4BAA4B,EAAE,OAAO,CAAC,4BAA4B;QAClE,gCAAgC,EAAE,OAAO,CAAC,gCAAgC;KAC3E,CAAC,CAAC;IACH,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YAED,MAAM,CAAC,YAAY,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAElD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;YAErC,MAAM,CAAC,yBAAyB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YACnD,MAAM,CAAC,YAAY,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAE3D,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Debugger } from \"@azure/logger\";\nimport type { PipelineRequest, PipelineResponse, SendRequest } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { logger as coreLogger } from \"../log.js\";\nimport { Sanitizer } from \"../util/sanitizer.js\";\n\n/**\n * The programmatic identifier of the logPolicy.\n */\nexport const logPolicyName = \"logPolicy\";\n\n/**\n * Options to configure the logPolicy.\n */\nexport interface LogPolicyOptions {\n /**\n * Header names whose values will be logged when logging is enabled.\n * Defaults include a list of well-known safe headers. Any headers\n * specified in this field will be added to that list. Any other values will\n * be written to logs as \"REDACTED\".\n */\n additionalAllowedHeaderNames?: string[];\n\n /**\n * Query string names whose values will be logged when logging is enabled. By default no\n * query string values are logged.\n */\n additionalAllowedQueryParameters?: string[];\n\n /**\n * The log function to use for writing pipeline logs.\n * Defaults to core-http's built-in logger.\n * Compatible with the `debug` library.\n */\n logger?: Debugger;\n}\n\n/**\n * A policy that logs all requests and responses.\n * @param options - Options to configure logPolicy.\n */\nexport function logPolicy(options: LogPolicyOptions = {}): PipelinePolicy {\n const logger = options.logger ?? coreLogger.info;\n const sanitizer = new Sanitizer({\n additionalAllowedHeaderNames: options.additionalAllowedHeaderNames,\n additionalAllowedQueryParameters: options.additionalAllowedQueryParameters,\n });\n return {\n name: logPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (!logger.enabled) {\n return next(request);\n }\n\n logger(`Request: ${sanitizer.sanitize(request)}`);\n\n const response = await next(request);\n\n logger(`Response status code: ${response.status}`);\n logger(`Headers: ${sanitizer.sanitize(response.headers)}`);\n\n return response;\n },\n };\n}\n"]}
{"version":3,"file":"logPolicy.js","sourceRoot":"","sources":["../../../src/policies/logPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EACL,aAAa,IAAI,gBAAgB,EACjC,SAAS,IAAI,YAAY,GAC1B,MAAM,6CAA6C,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC;AA4B9C;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,UAA4B,EAAE;IACtD,OAAO,YAAY,iBACjB,MAAM,EAAE,UAAU,CAAC,IAAI,IACpB,OAAO,EACV,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Debugger } from \"@azure/logger\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { logger as coreLogger } from \"../log.js\";\nimport {\n logPolicyName as tspLogPolicyName,\n logPolicy as tspLogPolicy,\n} from \"@typespec/ts-http-runtime/internal/policies\";\n\n/**\n * The programmatic identifier of the logPolicy.\n */\nexport const logPolicyName = tspLogPolicyName;\n\n/**\n * Options to configure the logPolicy.\n */\nexport interface LogPolicyOptions {\n /**\n * Header names whose values will be logged when logging is enabled.\n * Defaults include a list of well-known safe headers. Any headers\n * specified in this field will be added to that list. Any other values will\n * be written to logs as \"REDACTED\".\n */\n additionalAllowedHeaderNames?: string[];\n\n /**\n * Query string names whose values will be logged when logging is enabled. By default no\n * query string values are logged.\n */\n additionalAllowedQueryParameters?: string[];\n\n /**\n * The log function to use for writing pipeline logs.\n * Defaults to core-http's built-in logger.\n * Compatible with the `debug` library.\n */\n logger?: Debugger;\n}\n\n/**\n * A policy that logs all requests and responses.\n * @param options - Options to configure logPolicy.\n */\nexport function logPolicy(options: LogPolicyOptions = {}): PipelinePolicy {\n return tspLogPolicy({\n logger: coreLogger.info,\n ...options,\n });\n}\n"]}
@@ -1,110 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { randomUUID, stringToUint8Array } from "@azure/core-util";
import { concat } from "../util/concat.js";
import { isBlob } from "../util/typeGuards.js";
function generateBoundary() {
return `----AzSDKFormBoundary${randomUUID()}`;
}
function encodeHeaders(headers) {
let result = "";
for (const [key, value] of headers) {
result += `${key}: ${value}\r\n`;
}
return result;
}
function getLength(source) {
if (source instanceof Uint8Array) {
return source.byteLength;
}
else if (isBlob(source)) {
// if was created using createFile then -1 means we have an unknown size
return source.size === -1 ? undefined : source.size;
}
else {
return undefined;
}
}
function getTotalLength(sources) {
let total = 0;
for (const source of sources) {
const partLength = getLength(source);
if (partLength === undefined) {
return undefined;
}
else {
total += partLength;
}
}
return total;
}
async function buildRequestBody(request, parts, boundary) {
const sources = [
stringToUint8Array(`--${boundary}`, "utf-8"),
...parts.flatMap((part) => [
stringToUint8Array("\r\n", "utf-8"),
stringToUint8Array(encodeHeaders(part.headers), "utf-8"),
stringToUint8Array("\r\n", "utf-8"),
part.body,
stringToUint8Array(`\r\n--${boundary}`, "utf-8"),
]),
stringToUint8Array("--\r\n\r\n", "utf-8"),
];
const contentLength = getTotalLength(sources);
if (contentLength) {
request.headers.set("Content-Length", contentLength);
}
request.body = await concat(sources);
}
import { multipartPolicyName as tspMultipartPolicyName, multipartPolicy as tspMultipartPolicy, } from "@typespec/ts-http-runtime/internal/policies";
import { getRawContent, hasRawContent } from "../util/file.js";
/**
* Name of multipart policy
*/
export const multipartPolicyName = "multipartPolicy";
const maxBoundaryLength = 70;
const validBoundaryCharacters = new Set(`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'()+,-./:=?`);
function assertValidBoundary(boundary) {
if (boundary.length > maxBoundaryLength) {
throw new Error(`Multipart boundary "${boundary}" exceeds maximum length of 70 characters`);
}
if (Array.from(boundary).some((x) => !validBoundaryCharacters.has(x))) {
throw new Error(`Multipart boundary "${boundary}" contains invalid characters`);
}
}
export const multipartPolicyName = tspMultipartPolicyName;
/**
* Pipeline policy for multipart requests
*/
export function multipartPolicy() {
const tspPolicy = tspMultipartPolicy();
return {
name: multipartPolicyName,
async sendRequest(request, next) {
var _a;
if (!request.multipartBody) {
return next(request);
sendRequest: async (request, next) => {
if (request.multipartBody) {
for (const part of request.multipartBody.parts) {
if (hasRawContent(part.body)) {
part.body = getRawContent(part.body);
}
}
}
if (request.body) {
throw new Error("multipartBody and regular body cannot be set at the same time");
}
let boundary = request.multipartBody.boundary;
const contentTypeHeader = (_a = request.headers.get("Content-Type")) !== null && _a !== void 0 ? _a : "multipart/mixed";
const parsedHeader = contentTypeHeader.match(/^(multipart\/[^ ;]+)(?:; *boundary=(.+))?$/);
if (!parsedHeader) {
throw new Error(`Got multipart request body, but content-type header was not multipart: ${contentTypeHeader}`);
}
const [, contentType, parsedBoundary] = parsedHeader;
if (parsedBoundary && boundary && parsedBoundary !== boundary) {
throw new Error(`Multipart boundary was specified as ${parsedBoundary} in the header, but got ${boundary} in the request body`);
}
boundary !== null && boundary !== void 0 ? boundary : (boundary = parsedBoundary);
if (boundary) {
assertValidBoundary(boundary);
}
else {
boundary = generateBoundary();
}
request.headers.set("Content-Type", `${contentType}; boundary=${boundary}`);
await buildRequestBody(request, request.multipartBody.parts, boundary);
request.multipartBody = undefined;
return next(request);
return tspPolicy.sendRequest(request, next);
},
};
}
File diff suppressed because one or more lines are too long
@@ -1,2 +1,26 @@
export * from "./proxyPolicy.common.js";
//# sourceMappingURL=proxyPolicy-browser.d.mts.map
import type { ProxySettings } from "../interfaces.js";
import type { PipelinePolicy } from "../pipeline.js";
/**
* The programmatic identifier of the proxyPolicy.
*/
export declare const proxyPolicyName = "proxyPolicy";
/**
* This method converts a proxy url into `ProxySettings` for use with ProxyPolicy.
* If no argument is given, it attempts to parse a proxy URL from the environment
* variables `HTTPS_PROXY` or `HTTP_PROXY`.
* @param proxyUrl - The url of the proxy to use. May contain authentication information.
* @deprecated - Internally this method is no longer necessary when setting proxy information.
*/
export declare function getDefaultProxySettings(proxyUrl?: string): ProxySettings | undefined;
/**
* A policy that allows one to apply proxy settings to all requests.
* If not passed static settings, they will be retrieved from the HTTPS_PROXY
* or HTTP_PROXY environment variables.
* @param proxySettings - ProxySettings to use on each request.
* @param options - additional settings, for example, custom NO_PROXY patterns
*/
export declare function proxyPolicy(proxySettings?: ProxySettings, options?: {
/** a list of patterns to override those loaded from NO_PROXY environment variable. */
customNoProxyList?: string[];
}): PipelinePolicy;
//# sourceMappingURL=proxyPolicy.d.ts.map
@@ -1,4 +1,28 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export * from "./proxyPolicy.common.js";
//# sourceMappingURL=proxyPolicy-browser.mjs.map
import { proxyPolicy as tspProxyPolicy, proxyPolicyName as tspProxyPolicyName, getDefaultProxySettings as tspGetDefaultProxySettings, } from "@typespec/ts-http-runtime/internal/policies";
/**
* The programmatic identifier of the proxyPolicy.
*/
export const proxyPolicyName = tspProxyPolicyName;
/**
* This method converts a proxy url into `ProxySettings` for use with ProxyPolicy.
* If no argument is given, it attempts to parse a proxy URL from the environment
* variables `HTTPS_PROXY` or `HTTP_PROXY`.
* @param proxyUrl - The url of the proxy to use. May contain authentication information.
* @deprecated - Internally this method is no longer necessary when setting proxy information.
*/
export function getDefaultProxySettings(proxyUrl) {
return tspGetDefaultProxySettings(proxyUrl);
}
/**
* A policy that allows one to apply proxy settings to all requests.
* If not passed static settings, they will be retrieved from the HTTPS_PROXY
* or HTTP_PROXY environment variables.
* @param proxySettings - ProxySettings to use on each request.
* @param options - additional settings, for example, custom NO_PROXY patterns
*/
export function proxyPolicy(proxySettings, options) {
return tspProxyPolicy(proxySettings, options);
}
//# sourceMappingURL=proxyPolicy.js.map
@@ -0,0 +1 @@
{"version":3,"file":"proxyPolicy.js","sourceRoot":"","sources":["../../../src/policies/proxyPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EACL,WAAW,IAAI,cAAc,EAC7B,eAAe,IAAI,kBAAkB,EACrC,uBAAuB,IAAI,0BAA0B,GACtD,MAAM,6CAA6C,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAiB;IACvD,OAAO,0BAA0B,CAAC,QAAQ,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,aAA6B,EAC7B,OAGC;IAED,OAAO,cAAc,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ProxySettings } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\nimport {\n proxyPolicy as tspProxyPolicy,\n proxyPolicyName as tspProxyPolicyName,\n getDefaultProxySettings as tspGetDefaultProxySettings,\n} from \"@typespec/ts-http-runtime/internal/policies\";\n\n/**\n * The programmatic identifier of the proxyPolicy.\n */\nexport const proxyPolicyName = tspProxyPolicyName;\n\n/**\n * This method converts a proxy url into `ProxySettings` for use with ProxyPolicy.\n * If no argument is given, it attempts to parse a proxy URL from the environment\n * variables `HTTPS_PROXY` or `HTTP_PROXY`.\n * @param proxyUrl - The url of the proxy to use. May contain authentication information.\n * @deprecated - Internally this method is no longer necessary when setting proxy information.\n */\nexport function getDefaultProxySettings(proxyUrl?: string): ProxySettings | undefined {\n return tspGetDefaultProxySettings(proxyUrl);\n}\n\n/**\n * A policy that allows one to apply proxy settings to all requests.\n * If not passed static settings, they will be retrieved from the HTTPS_PROXY\n * or HTTP_PROXY environment variables.\n * @param proxySettings - ProxySettings to use on each request.\n * @param options - additional settings, for example, custom NO_PROXY patterns\n */\nexport function proxyPolicy(\n proxySettings?: ProxySettings,\n options?: {\n /** a list of patterns to override those loaded from NO_PROXY environment variable. */\n customNoProxyList?: string[];\n },\n): PipelinePolicy {\n return tspProxyPolicy(proxySettings, options);\n}\n"]}
@@ -1,13 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { redirectPolicyName as tspRedirectPolicyName, redirectPolicy as tspRedirectPolicy, } from "@typespec/ts-http-runtime/internal/policies";
/**
* The programmatic identifier of the redirectPolicy.
*/
export const redirectPolicyName = "redirectPolicy";
/**
* Methods that are allowed to follow redirects 301 and 302
*/
const allowedRedirect = ["GET", "HEAD"];
export const redirectPolicyName = tspRedirectPolicyName;
/**
* A policy to follow Location headers from the server in order
* to support server-side redirection.
@@ -15,38 +12,6 @@ const allowedRedirect = ["GET", "HEAD"];
* @param options - Options to control policy behavior.
*/
export function redirectPolicy(options = {}) {
const { maxRetries = 20 } = options;
return {
name: redirectPolicyName,
async sendRequest(request, next) {
const response = await next(request);
return handleRedirect(next, response, maxRetries);
},
};
}
async function handleRedirect(next, response, maxRetries, currentRetries = 0) {
const { request, status, headers } = response;
const locationHeader = headers.get("location");
if (locationHeader &&
(status === 300 ||
(status === 301 && allowedRedirect.includes(request.method)) ||
(status === 302 && allowedRedirect.includes(request.method)) ||
(status === 303 && request.method === "POST") ||
status === 307) &&
currentRetries < maxRetries) {
const url = new URL(locationHeader, request.url);
request.url = url.toString();
// POST request with Status code 303 should be converted into a
// redirected GET request if the redirect url is present in the location header
if (status === 303) {
request.method = "GET";
request.headers.delete("Content-Length");
delete request.body;
}
request.headers.delete("Authorization");
const res = await next(request);
return handleRedirect(next, res, maxRetries, currentRetries + 1);
}
return response;
return tspRedirectPolicy(options);
}
//# sourceMappingURL=redirectPolicy.js.map
@@ -1 +1 @@
{"version":3,"file":"redirectPolicy.js","sourceRoot":"","sources":["../../../src/policies/redirectPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAEnD;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAaxC;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,UAAiC,EAAE;IAChE,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IACpC,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;YACrC,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,cAAc,CAC3B,IAAiB,EACjB,QAA0B,EAC1B,UAAkB,EAClB,iBAAyB,CAAC;IAE1B,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC9C,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/C,IACE,cAAc;QACd,CAAC,MAAM,KAAK,GAAG;YACb,CAAC,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC5D,CAAC,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC5D,CAAC,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC;YAC7C,MAAM,KAAK,GAAG,CAAC;QACjB,cAAc,GAAG,UAAU,EAC3B,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QACjD,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;QAE7B,+DAA+D;QAC/D,+EAA+E;QAC/E,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;YACvB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;YACzC,OAAO,OAAO,CAAC,IAAI,CAAC;QACtB,CAAC;QAED,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QAExC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,OAAO,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,cAAc,GAAG,CAAC,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRequest, PipelineResponse, SendRequest } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\n/**\n * The programmatic identifier of the redirectPolicy.\n */\nexport const redirectPolicyName = \"redirectPolicy\";\n\n/**\n * Methods that are allowed to follow redirects 301 and 302\n */\nconst allowedRedirect = [\"GET\", \"HEAD\"];\n\n/**\n * Options for how redirect responses are handled.\n */\nexport interface RedirectPolicyOptions {\n /**\n * The maximum number of times the redirect URL will be tried before\n * failing. Defaults to 20.\n */\n maxRetries?: number;\n}\n\n/**\n * A policy to follow Location headers from the server in order\n * to support server-side redirection.\n * In the browser, this policy is not used.\n * @param options - Options to control policy behavior.\n */\nexport function redirectPolicy(options: RedirectPolicyOptions = {}): PipelinePolicy {\n const { maxRetries = 20 } = options;\n return {\n name: redirectPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n const response = await next(request);\n return handleRedirect(next, response, maxRetries);\n },\n };\n}\n\nasync function handleRedirect(\n next: SendRequest,\n response: PipelineResponse,\n maxRetries: number,\n currentRetries: number = 0,\n): Promise<PipelineResponse> {\n const { request, status, headers } = response;\n const locationHeader = headers.get(\"location\");\n if (\n locationHeader &&\n (status === 300 ||\n (status === 301 && allowedRedirect.includes(request.method)) ||\n (status === 302 && allowedRedirect.includes(request.method)) ||\n (status === 303 && request.method === \"POST\") ||\n status === 307) &&\n currentRetries < maxRetries\n ) {\n const url = new URL(locationHeader, request.url);\n request.url = url.toString();\n\n // POST request with Status code 303 should be converted into a\n // redirected GET request if the redirect url is present in the location header\n if (status === 303) {\n request.method = \"GET\";\n request.headers.delete(\"Content-Length\");\n delete request.body;\n }\n\n request.headers.delete(\"Authorization\");\n\n const res = await next(request);\n return handleRedirect(next, res, maxRetries, currentRetries + 1);\n }\n\n return response;\n}\n"]}
{"version":3,"file":"redirectPolicy.js","sourceRoot":"","sources":["../../../src/policies/redirectPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EACL,kBAAkB,IAAI,qBAAqB,EAC3C,cAAc,IAAI,iBAAiB,GACpC,MAAM,6CAA6C,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAaxD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,UAAiC,EAAE;IAChE,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\nimport {\n redirectPolicyName as tspRedirectPolicyName,\n redirectPolicy as tspRedirectPolicy,\n} from \"@typespec/ts-http-runtime/internal/policies\";\n\n/**\n * The programmatic identifier of the redirectPolicy.\n */\nexport const redirectPolicyName = tspRedirectPolicyName;\n\n/**\n * Options for how redirect responses are handled.\n */\nexport interface RedirectPolicyOptions {\n /**\n * The maximum number of times the redirect URL will be tried before\n * failing. Defaults to 20.\n */\n maxRetries?: number;\n}\n\n/**\n * A policy to follow Location headers from the server in order\n * to support server-side redirection.\n * In the browser, this policy is not used.\n * @param options - Options to control policy behavior.\n */\nexport function redirectPolicy(options: RedirectPolicyOptions = {}): PipelinePolicy {\n return tspRedirectPolicy(options);\n}\n"]}
@@ -1,6 +1,64 @@
import type { PipelinePolicy } from "../pipeline.js";
import { type AzureLogger } from "@azure/logger";
import type { RetryStrategy } from "../retryStrategies/retryStrategy.js";
import type { PipelineResponse } from "../interfaces.js";
import type { RestError } from "../restError.js";
/**
* Information provided to the retry strategy about the current progress of the retry policy.
*/
export interface RetryInformation {
/**
* A {@link PipelineResponse}, if the last retry attempt succeeded.
*/
response?: PipelineResponse;
/**
* A {@link RestError}, if the last retry attempt failed.
*/
responseError?: RestError;
/**
* Total number of retries so far.
*/
retryCount: number;
}
/**
* Properties that can modify the behavior of the retry policy.
*/
export interface RetryModifiers {
/**
* If true, allows skipping the current strategy from running on the retry policy.
*/
skipStrategy?: boolean;
/**
* Indicates to retry against this URL.
*/
redirectTo?: string;
/**
* Controls whether to retry in a given number of milliseconds.
* If provided, a new retry will be attempted.
*/
retryAfterInMs?: number;
/**
* Indicates to throw this error instead of retrying.
*/
errorToThrow?: RestError;
}
/**
* A retry strategy is intended to define whether to retry or not, and how to retry.
*/
export interface RetryStrategy {
/**
* Name of the retry strategy. Used for logging.
*/
name: string;
/**
* Logger. If it's not provided, a default logger for all retry strategies is used.
*/
logger?: AzureLogger;
/**
* Function that determines how to proceed with the subsequent requests.
* @param state - Retry state
*/
retry(state: RetryInformation): RetryModifiers;
}
/**
* Options to the {@link retryPolicy}
*/
@@ -1,105 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { delay } from "../util/helpers.js";
import { createClientLogger } from "@azure/logger";
import { AbortError } from "@azure/abort-controller";
import { DEFAULT_RETRY_POLICY_COUNT } from "../constants.js";
import { retryPolicy as tspRetryPolicy, } from "@typespec/ts-http-runtime/internal/policies";
const retryPolicyLogger = createClientLogger("core-rest-pipeline retryPolicy");
/**
* The programmatic identifier of the retryPolicy.
*/
const retryPolicyName = "retryPolicy";
/**
* retryPolicy is a generic policy to enable retrying requests when certain conditions are met
*/
export function retryPolicy(strategies, options = { maxRetries: DEFAULT_RETRY_POLICY_COUNT }) {
const logger = options.logger || retryPolicyLogger;
return {
name: retryPolicyName,
async sendRequest(request, next) {
var _a, _b;
let response;
let responseError;
let retryCount = -1;
retryRequest: while (true) {
retryCount += 1;
response = undefined;
responseError = undefined;
try {
logger.info(`Retry ${retryCount}: Attempting to send request`, request.requestId);
response = await next(request);
logger.info(`Retry ${retryCount}: Received a response from request`, request.requestId);
}
catch (e) {
logger.error(`Retry ${retryCount}: Received an error from request`, request.requestId);
// RestErrors are valid targets for the retry strategies.
// If none of the retry strategies can work with them, they will be thrown later in this policy.
// If the received error is not a RestError, it is immediately thrown.
responseError = e;
if (!e || responseError.name !== "RestError") {
throw e;
}
response = responseError.response;
}
if ((_a = request.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
logger.error(`Retry ${retryCount}: Request aborted.`);
const abortError = new AbortError();
throw abortError;
}
if (retryCount >= ((_b = options.maxRetries) !== null && _b !== void 0 ? _b : DEFAULT_RETRY_POLICY_COUNT)) {
logger.info(`Retry ${retryCount}: Maximum retries reached. Returning the last received response, or throwing the last received error.`);
if (responseError) {
throw responseError;
}
else if (response) {
return response;
}
else {
throw new Error("Maximum retries reached with no response or error to throw");
}
}
logger.info(`Retry ${retryCount}: Processing ${strategies.length} retry strategies.`);
strategiesLoop: for (const strategy of strategies) {
const strategyLogger = strategy.logger || retryPolicyLogger;
strategyLogger.info(`Retry ${retryCount}: Processing retry strategy ${strategy.name}.`);
const modifiers = strategy.retry({
retryCount,
response,
responseError,
});
if (modifiers.skipStrategy) {
strategyLogger.info(`Retry ${retryCount}: Skipped.`);
continue strategiesLoop;
}
const { errorToThrow, retryAfterInMs, redirectTo } = modifiers;
if (errorToThrow) {
strategyLogger.error(`Retry ${retryCount}: Retry strategy ${strategy.name} throws error:`, errorToThrow);
throw errorToThrow;
}
if (retryAfterInMs || retryAfterInMs === 0) {
strategyLogger.info(`Retry ${retryCount}: Retry strategy ${strategy.name} retries after ${retryAfterInMs}`);
await delay(retryAfterInMs, undefined, { abortSignal: request.abortSignal });
continue retryRequest;
}
if (redirectTo) {
strategyLogger.info(`Retry ${retryCount}: Retry strategy ${strategy.name} redirects to ${redirectTo}`);
request.url = redirectTo;
continue retryRequest;
}
}
if (responseError) {
logger.info(`None of the retry strategies could work with the received error. Throwing it.`);
throw responseError;
}
if (response) {
logger.info(`None of the retry strategies could work with the received response. Returning it.`);
return response;
}
// If all the retries skip and there's no response,
// we're still in the retry loop, so a new request will be sent
// until `maxRetries` is reached.
}
},
};
// Cast is required since the TSP runtime retry strategy type is slightly different
// very deep down (using real AbortSignal vs. AbortSignalLike in RestError).
// In practice the difference doesn't actually matter.
return tspRetryPolicy(strategies, Object.assign({ logger: retryPolicyLogger }, options));
}
//# sourceMappingURL=retryPolicy.js.map
File diff suppressed because one or more lines are too long
@@ -1,12 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { exponentialRetryStrategy } from "../retryStrategies/exponentialRetryStrategy.js";
import { retryPolicy } from "./retryPolicy.js";
import { DEFAULT_RETRY_POLICY_COUNT } from "../constants.js";
import { systemErrorRetryPolicy as tspSystemErrorRetryPolicy, systemErrorRetryPolicyName as tspSystemErrorRetryPolicyName, } from "@typespec/ts-http-runtime/internal/policies";
/**
* Name of the {@link systemErrorRetryPolicy}
*/
export const systemErrorRetryPolicyName = "systemErrorRetryPolicy";
export const systemErrorRetryPolicyName = tspSystemErrorRetryPolicyName;
/**
* A retry policy that specifically seeks to handle errors in the
* underlying transport layer (e.g. DNS lookup failures) rather than
@@ -14,14 +12,6 @@ export const systemErrorRetryPolicyName = "systemErrorRetryPolicy";
* @param options - Options that customize the policy.
*/
export function systemErrorRetryPolicy(options = {}) {
var _a;
return {
name: systemErrorRetryPolicyName,
sendRequest: retryPolicy([
exponentialRetryStrategy(Object.assign(Object.assign({}, options), { ignoreHttpStatusCodes: true })),
], {
maxRetries: (_a = options.maxRetries) !== null && _a !== void 0 ? _a : DEFAULT_RETRY_POLICY_COUNT,
}).sendRequest,
};
return tspSystemErrorRetryPolicy(options);
}
//# sourceMappingURL=systemErrorRetryPolicy.js.map
@@ -1 +1 @@
{"version":3,"file":"systemErrorRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/systemErrorRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAyBnE;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAyC,EAAE;;IAE3C,OAAO;QACL,IAAI,EAAE,0BAA0B;QAChC,WAAW,EAAE,WAAW,CACtB;YACE,wBAAwB,iCACnB,OAAO,KACV,qBAAqB,EAAE,IAAI,IAC3B;SACH,EACD;YACE,UAAU,EAAE,MAAA,OAAO,CAAC,UAAU,mCAAI,0BAA0B;SAC7D,CACF,CAAC,WAAW;KACd,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { exponentialRetryStrategy } from \"../retryStrategies/exponentialRetryStrategy.js\";\nimport { retryPolicy } from \"./retryPolicy.js\";\nimport { DEFAULT_RETRY_POLICY_COUNT } from \"../constants.js\";\n\n/**\n * Name of the {@link systemErrorRetryPolicy}\n */\nexport const systemErrorRetryPolicyName = \"systemErrorRetryPolicy\";\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface SystemErrorRetryPolicyOptions {\n /**\n * The maximum number of retry attempts. Defaults to 3.\n */\n maxRetries?: number;\n\n /**\n * The amount of delay in milliseconds between retry attempts. Defaults to 1000\n * (1 second.) The delay increases exponentially with each retry up to a maximum\n * specified by maxRetryDelayInMs.\n */\n retryDelayInMs?: number;\n\n /**\n * The maximum delay in milliseconds allowed before retrying an operation. Defaults\n * to 64000 (64 seconds).\n */\n maxRetryDelayInMs?: number;\n}\n\n/**\n * A retry policy that specifically seeks to handle errors in the\n * underlying transport layer (e.g. DNS lookup failures) rather than\n * retryable error codes from the server itself.\n * @param options - Options that customize the policy.\n */\nexport function systemErrorRetryPolicy(\n options: SystemErrorRetryPolicyOptions = {},\n): PipelinePolicy {\n return {\n name: systemErrorRetryPolicyName,\n sendRequest: retryPolicy(\n [\n exponentialRetryStrategy({\n ...options,\n ignoreHttpStatusCodes: true,\n }),\n ],\n {\n maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT,\n },\n ).sendRequest,\n };\n}\n"]}
{"version":3,"file":"systemErrorRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/systemErrorRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EACL,sBAAsB,IAAI,yBAAyB,EACnD,0BAA0B,IAAI,6BAA6B,GAC5D,MAAM,6CAA6C,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,6BAA6B,CAAC;AAyBxE;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAyC,EAAE;IAE3C,OAAO,yBAAyB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\nimport {\n systemErrorRetryPolicy as tspSystemErrorRetryPolicy,\n systemErrorRetryPolicyName as tspSystemErrorRetryPolicyName,\n} from \"@typespec/ts-http-runtime/internal/policies\";\n\n/**\n * Name of the {@link systemErrorRetryPolicy}\n */\nexport const systemErrorRetryPolicyName = tspSystemErrorRetryPolicyName;\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface SystemErrorRetryPolicyOptions {\n /**\n * The maximum number of retry attempts. Defaults to 3.\n */\n maxRetries?: number;\n\n /**\n * The amount of delay in milliseconds between retry attempts. Defaults to 1000\n * (1 second.) The delay increases exponentially with each retry up to a maximum\n * specified by maxRetryDelayInMs.\n */\n retryDelayInMs?: number;\n\n /**\n * The maximum delay in milliseconds allowed before retrying an operation. Defaults\n * to 64000 (64 seconds).\n */\n maxRetryDelayInMs?: number;\n}\n\n/**\n * A retry policy that specifically seeks to handle errors in the\n * underlying transport layer (e.g. DNS lookup failures) rather than\n * retryable error codes from the server itself.\n * @param options - Options that customize the policy.\n */\nexport function systemErrorRetryPolicy(\n options: SystemErrorRetryPolicyOptions = {},\n): PipelinePolicy {\n return tspSystemErrorRetryPolicy(options);\n}\n"]}
@@ -16,9 +16,9 @@ export interface ThrottlingRetryPolicyOptions {
* A policy that retries when the server sends a 429 response with a Retry-After header.
*
* To learn more, please refer to
* https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits,
* https://learn.microsoft.com/en-us/azure/azure-subscription-service-limits and
* https://learn.microsoft.com/en-us/azure/virtual-machines/troubleshooting/troubleshooting-throttling-errors
* https://learn.microsoft.com/azure/azure-resource-manager/resource-manager-request-limits,
* https://learn.microsoft.com/azure/azure-subscription-service-limits and
* https://learn.microsoft.com/azure/virtual-machines/troubleshooting/troubleshooting-throttling-errors
*
* @param options - Options that configure retry logic.
*/
@@ -1,29 +1,21 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { throttlingRetryStrategy } from "../retryStrategies/throttlingRetryStrategy.js";
import { retryPolicy } from "./retryPolicy.js";
import { DEFAULT_RETRY_POLICY_COUNT } from "../constants.js";
import { throttlingRetryPolicyName as tspThrottlingRetryPolicyName, throttlingRetryPolicy as tspThrottlingRetryPolicy, } from "@typespec/ts-http-runtime/internal/policies";
/**
* Name of the {@link throttlingRetryPolicy}
*/
export const throttlingRetryPolicyName = "throttlingRetryPolicy";
export const throttlingRetryPolicyName = tspThrottlingRetryPolicyName;
/**
* A policy that retries when the server sends a 429 response with a Retry-After header.
*
* To learn more, please refer to
* https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits,
* https://learn.microsoft.com/en-us/azure/azure-subscription-service-limits and
* https://learn.microsoft.com/en-us/azure/virtual-machines/troubleshooting/troubleshooting-throttling-errors
* https://learn.microsoft.com/azure/azure-resource-manager/resource-manager-request-limits,
* https://learn.microsoft.com/azure/azure-subscription-service-limits and
* https://learn.microsoft.com/azure/virtual-machines/troubleshooting/troubleshooting-throttling-errors
*
* @param options - Options that configure retry logic.
*/
export function throttlingRetryPolicy(options = {}) {
var _a;
return {
name: throttlingRetryPolicyName,
sendRequest: retryPolicy([throttlingRetryStrategy()], {
maxRetries: (_a = options.maxRetries) !== null && _a !== void 0 ? _a : DEFAULT_RETRY_POLICY_COUNT,
}).sendRequest,
};
return tspThrottlingRetryPolicy(options);
}
//# sourceMappingURL=throttlingRetryPolicy.js.map
@@ -1 +1 @@
{"version":3,"file":"throttlingRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/throttlingRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAYjE;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAwC,EAAE;;IAC9E,OAAO;QACL,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EAAE,WAAW,CAAC,CAAC,uBAAuB,EAAE,CAAC,EAAE;YACpD,UAAU,EAAE,MAAA,OAAO,CAAC,UAAU,mCAAI,0BAA0B;SAC7D,CAAC,CAAC,WAAW;KACf,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { throttlingRetryStrategy } from \"../retryStrategies/throttlingRetryStrategy.js\";\nimport { retryPolicy } from \"./retryPolicy.js\";\nimport { DEFAULT_RETRY_POLICY_COUNT } from \"../constants.js\";\n\n/**\n * Name of the {@link throttlingRetryPolicy}\n */\nexport const throttlingRetryPolicyName = \"throttlingRetryPolicy\";\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface ThrottlingRetryPolicyOptions {\n /**\n * The maximum number of retry attempts. Defaults to 3.\n */\n maxRetries?: number;\n}\n\n/**\n * A policy that retries when the server sends a 429 response with a Retry-After header.\n *\n * To learn more, please refer to\n * https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits,\n * https://learn.microsoft.com/en-us/azure/azure-subscription-service-limits and\n * https://learn.microsoft.com/en-us/azure/virtual-machines/troubleshooting/troubleshooting-throttling-errors\n *\n * @param options - Options that configure retry logic.\n */\nexport function throttlingRetryPolicy(options: ThrottlingRetryPolicyOptions = {}): PipelinePolicy {\n return {\n name: throttlingRetryPolicyName,\n sendRequest: retryPolicy([throttlingRetryStrategy()], {\n maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT,\n }).sendRequest,\n };\n}\n"]}
{"version":3,"file":"throttlingRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/throttlingRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EACL,yBAAyB,IAAI,4BAA4B,EACzD,qBAAqB,IAAI,wBAAwB,GAClD,MAAM,6CAA6C,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,4BAA4B,CAAC;AAYtE;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAwC,EAAE;IAC9E,OAAO,wBAAwB,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\nimport {\n throttlingRetryPolicyName as tspThrottlingRetryPolicyName,\n throttlingRetryPolicy as tspThrottlingRetryPolicy,\n} from \"@typespec/ts-http-runtime/internal/policies\";\n\n/**\n * Name of the {@link throttlingRetryPolicy}\n */\nexport const throttlingRetryPolicyName = tspThrottlingRetryPolicyName;\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface ThrottlingRetryPolicyOptions {\n /**\n * The maximum number of retry attempts. Defaults to 3.\n */\n maxRetries?: number;\n}\n\n/**\n * A policy that retries when the server sends a 429 response with a Retry-After header.\n *\n * To learn more, please refer to\n * https://learn.microsoft.com/azure/azure-resource-manager/resource-manager-request-limits,\n * https://learn.microsoft.com/azure/azure-subscription-service-limits and\n * https://learn.microsoft.com/azure/virtual-machines/troubleshooting/troubleshooting-throttling-errors\n *\n * @param options - Options that configure retry logic.\n */\nexport function throttlingRetryPolicy(options: ThrottlingRetryPolicyOptions = {}): PipelinePolicy {\n return tspThrottlingRetryPolicy(options);\n}\n"]}
+3 -11
View File
@@ -1,22 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { tlsPolicy as tspTlsPolicy, tlsPolicyName as tspTlsPolicyName, } from "@typespec/ts-http-runtime/internal/policies";
/**
* Name of the TLS Policy
*/
export const tlsPolicyName = "tlsPolicy";
export const tlsPolicyName = tspTlsPolicyName;
/**
* Gets a pipeline policy that adds the client certificate to the HttpClient agent for authentication.
*/
export function tlsPolicy(tlsSettings) {
return {
name: tlsPolicyName,
sendRequest: async (req, next) => {
// Users may define a request tlsSettings, honor those over the client level one
if (!req.tlsSettings) {
req.tlsSettings = tlsSettings;
}
return next(req);
},
};
return tspTlsPolicy(tlsSettings);
}
//# sourceMappingURL=tlsPolicy.js.map
@@ -1 +1 @@
{"version":3,"file":"tlsPolicy.js","sourceRoot":"","sources":["../../../src/policies/tlsPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,WAAyB;IACjD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YAC/B,gFAAgF;YAChF,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;gBACrB,GAAG,CAAC,WAAW,GAAG,WAAW,CAAC;YAChC,CAAC;YACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport type { TlsSettings } from \"../interfaces.js\";\n\n/**\n * Name of the TLS Policy\n */\nexport const tlsPolicyName = \"tlsPolicy\";\n\n/**\n * Gets a pipeline policy that adds the client certificate to the HttpClient agent for authentication.\n */\nexport function tlsPolicy(tlsSettings?: TlsSettings): PipelinePolicy {\n return {\n name: tlsPolicyName,\n sendRequest: async (req, next) => {\n // Users may define a request tlsSettings, honor those over the client level one\n if (!req.tlsSettings) {\n req.tlsSettings = tlsSettings;\n }\n return next(req);\n },\n };\n}\n"]}
{"version":3,"file":"tlsPolicy.js","sourceRoot":"","sources":["../../../src/policies/tlsPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EACL,SAAS,IAAI,YAAY,EACzB,aAAa,IAAI,gBAAgB,GAClC,MAAM,6CAA6C,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAE9C;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,WAAyB;IACjD,OAAO,YAAY,CAAC,WAAW,CAAC,CAAC;AACnC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport type { TlsSettings } from \"../interfaces.js\";\n\nimport {\n tlsPolicy as tspTlsPolicy,\n tlsPolicyName as tspTlsPolicyName,\n} from \"@typespec/ts-http-runtime/internal/policies\";\n\n/**\n * Name of the TLS Policy\n */\nexport const tlsPolicyName = tspTlsPolicyName;\n\n/**\n * Gets a pipeline policy that adds the client certificate to the HttpClient agent for authentication.\n */\nexport function tlsPolicy(tlsSettings?: TlsSettings): PipelinePolicy {\n return tspTlsPolicy(tlsSettings);\n}\n"]}
@@ -6,7 +6,7 @@ import { getUserAgentValue } from "../util/userAgent.js";
import { logger } from "../log.js";
import { getErrorMessage, isError } from "@azure/core-util";
import { isRestError } from "../restError.js";
import { Sanitizer } from "../util/sanitizer.js";
import { Sanitizer } from "@typespec/ts-http-runtime/internal/util";
/**
* The programmatic identifier of the tracingPolicy.
*/
File diff suppressed because one or more lines are too long
@@ -0,0 +1,10 @@
import { type PipelinePolicy } from "../pipeline.js";
export declare const wrapAbortSignalLikePolicyName = "wrapAbortSignalLikePolicy";
/**
* Policy that ensure that any AbortSignalLike is wrapped in a native AbortSignal for processing by the pipeline.
* Since the ts-http-runtime expects a native AbortSignal, this policy is used to ensure that any AbortSignalLike is wrapped in a native AbortSignal.
*
* @returns - created policy
*/
export declare function wrapAbortSignalLikePolicy(): PipelinePolicy;
//# sourceMappingURL=wrapAbortSignalLikePolicy.d.ts.map
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { wrapAbortSignalLike } from "../util/wrapAbortSignal.js";
export const wrapAbortSignalLikePolicyName = "wrapAbortSignalLikePolicy";
/**
* Policy that ensure that any AbortSignalLike is wrapped in a native AbortSignal for processing by the pipeline.
* Since the ts-http-runtime expects a native AbortSignal, this policy is used to ensure that any AbortSignalLike is wrapped in a native AbortSignal.
*
* @returns - created policy
*/
export function wrapAbortSignalLikePolicy() {
return {
name: wrapAbortSignalLikePolicyName,
sendRequest: async (request, next) => {
if (!request.abortSignal) {
return next(request);
}
const { abortSignal, cleanup } = wrapAbortSignalLike(request.abortSignal);
// eslint-disable-next-line no-param-reassign
request.abortSignal = abortSignal;
try {
return await next(request);
}
finally {
cleanup === null || cleanup === void 0 ? void 0 : cleanup();
}
},
};
}
//# sourceMappingURL=wrapAbortSignalLikePolicy.js.map
@@ -0,0 +1 @@
{"version":3,"file":"wrapAbortSignalLikePolicy.js","sourceRoot":"","sources":["../../../src/policies/wrapAbortSignalLikePolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,CAAC,MAAM,6BAA6B,GAAG,2BAA2B,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB;IACvC,OAAO;QACL,IAAI,EAAE,6BAA6B;QACnC,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;YACnC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;gBACzB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YAED,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC1E,6CAA6C;YAC7C,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;YAClC,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC;oBAAS,CAAC;gBACT,OAAO,aAAP,OAAO,uBAAP,OAAO,EAAI,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { type PipelinePolicy } from \"../pipeline.js\";\nimport { wrapAbortSignalLike } from \"../util/wrapAbortSignal.js\";\n\nexport const wrapAbortSignalLikePolicyName = \"wrapAbortSignalLikePolicy\";\n\n/**\n * Policy that ensure that any AbortSignalLike is wrapped in a native AbortSignal for processing by the pipeline.\n * Since the ts-http-runtime expects a native AbortSignal, this policy is used to ensure that any AbortSignalLike is wrapped in a native AbortSignal.\n *\n * @returns - created policy\n */\nexport function wrapAbortSignalLikePolicy(): PipelinePolicy {\n return {\n name: wrapAbortSignalLikePolicyName,\n sendRequest: async (request, next) => {\n if (!request.abortSignal) {\n return next(request);\n }\n\n const { abortSignal, cleanup } = wrapAbortSignalLike(request.abortSignal);\n // eslint-disable-next-line no-param-reassign\n request.abortSignal = abortSignal;\n try {\n return await next(request);\n } finally {\n cleanup?.();\n }\n },\n };\n}\n"]}
+20 -5
View File
@@ -23,19 +23,31 @@ export interface RestErrorOptions {
/**
* A custom error type for failed pipeline requests.
*/
export declare class RestError extends Error {
[x: symbol]: () => string;
export interface RestErrorConstructor {
/**
* Something went wrong when making the request.
* This means the actual request failed for some reason,
* such as a DNS issue or the connection being lost.
*/
static readonly REQUEST_SEND_ERROR: string;
readonly REQUEST_SEND_ERROR: string;
/**
* This means that parsing the response from the server failed.
* It may have been malformed.
*/
static readonly PARSE_ERROR: string;
readonly PARSE_ERROR: string;
/**
* Prototype of RestError
*/
readonly prototype: RestError;
/**
* Construct a new RestError.
*/
new (message: string, options?: RestErrorOptions): RestError;
}
/**
* A custom error type for failed pipeline requests.
*/
export interface RestError extends Error {
/**
* The code of the error itself (use statics on RestError if possible.)
*/
@@ -58,8 +70,11 @@ export declare class RestError extends Error {
* Bonus property set by the throw site.
*/
details?: unknown;
constructor(message: string, options?: RestErrorOptions);
}
/**
* A custom error type for failed pipeline requests.
*/
export declare const RestError: RestErrorConstructor;
/**
* Typeguard for RestError
* @param e - Something caught by a catch clause.
+4 -42
View File
@@ -1,54 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { isError } from "@azure/core-util";
import { custom } from "./util/inspect.js";
import { Sanitizer } from "./util/sanitizer.js";
const errorSanitizer = new Sanitizer();
import { RestError as TspRestError, isRestError as tspIsRestError, } from "@typespec/ts-http-runtime";
/**
* A custom error type for failed pipeline requests.
*/
export class RestError extends Error {
constructor(message, options = {}) {
super(message);
this.name = "RestError";
this.code = options.code;
this.statusCode = options.statusCode;
// The request and response may contain sensitive information in the headers or body.
// To help prevent this sensitive information being accidentally logged, the request and response
// properties are marked as non-enumerable here. This prevents them showing up in the output of
// JSON.stringify and console.log.
Object.defineProperty(this, "request", { value: options.request, enumerable: false });
Object.defineProperty(this, "response", { value: options.response, enumerable: false });
Object.setPrototypeOf(this, RestError.prototype);
}
/**
* Logging method for util.inspect in Node
*/
[custom]() {
// Extract non-enumerable properties and add them back. This is OK since in this output the request and
// response get sanitized.
return `RestError: ${this.message} \n ${errorSanitizer.sanitize(Object.assign(Object.assign({}, this), { request: this.request, response: this.response }))}`;
}
}
/**
* Something went wrong when making the request.
* This means the actual request failed for some reason,
* such as a DNS issue or the connection being lost.
*/
RestError.REQUEST_SEND_ERROR = "REQUEST_SEND_ERROR";
/**
* This means that parsing the response from the server failed.
* It may have been malformed.
*/
RestError.PARSE_ERROR = "PARSE_ERROR";
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const RestError = TspRestError;
/**
* Typeguard for RestError
* @param e - Something caught by a catch clause.
*/
export function isRestError(e) {
if (e instanceof RestError) {
return true;
}
return isError(e) && e.name === "RestError";
return tspIsRestError(e);
}
//# sourceMappingURL=restError.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"restError.js","sourceRoot":"","sources":["../../src/restError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,cAAc,GAAG,IAAI,SAAS,EAAE,CAAC;AAwBvC;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAoClC,YAAY,OAAe,EAAE,UAA4B,EAAE;QACzD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QAErC,qFAAqF;QACrF,iGAAiG;QACjG,+FAA+F;QAC/F,kCAAkC;QAClC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QACtF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAExF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC;QACN,uGAAuG;QACvG,0BAA0B;QAC1B,OAAO,cAAc,IAAI,CAAC,OAAO,OAAO,cAAc,CAAC,QAAQ,iCAC1D,IAAI,KACP,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IACvB,EAAE,CAAC;IACP,CAAC;;AA9DD;;;;GAIG;AACa,4BAAkB,GAAW,oBAAoB,CAAC;AAClE;;;GAGG;AACa,qBAAW,GAAW,aAAa,CAAC;AAuDtD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,IAAI,CAAC,YAAY,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC;AAC9C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isError } from \"@azure/core-util\";\nimport type { PipelineRequest, PipelineResponse } from \"./interfaces.js\";\nimport { custom } from \"./util/inspect.js\";\nimport { Sanitizer } from \"./util/sanitizer.js\";\n\nconst errorSanitizer = new Sanitizer();\n\n/**\n * The options supported by RestError.\n */\nexport interface RestErrorOptions {\n /**\n * The code of the error itself (use statics on RestError if possible.)\n */\n code?: string;\n /**\n * The HTTP status code of the request (if applicable.)\n */\n statusCode?: number;\n /**\n * The request that was made.\n */\n request?: PipelineRequest;\n /**\n * The response received (if any.)\n */\n response?: PipelineResponse;\n}\n\n/**\n * A custom error type for failed pipeline requests.\n */\nexport class RestError extends Error {\n /**\n * Something went wrong when making the request.\n * This means the actual request failed for some reason,\n * such as a DNS issue or the connection being lost.\n */\n static readonly REQUEST_SEND_ERROR: string = \"REQUEST_SEND_ERROR\";\n /**\n * This means that parsing the response from the server failed.\n * It may have been malformed.\n */\n static readonly PARSE_ERROR: string = \"PARSE_ERROR\";\n\n /**\n * The code of the error itself (use statics on RestError if possible.)\n */\n public code?: string;\n /**\n * The HTTP status code of the request (if applicable.)\n */\n public statusCode?: number;\n /**\n * The request that was made.\n * This property is non-enumerable.\n */\n public request?: PipelineRequest;\n /**\n * The response received (if any.)\n * This property is non-enumerable.\n */\n public response?: PipelineResponse;\n /**\n * Bonus property set by the throw site.\n */\n public details?: unknown;\n\n constructor(message: string, options: RestErrorOptions = {}) {\n super(message);\n this.name = \"RestError\";\n this.code = options.code;\n this.statusCode = options.statusCode;\n\n // The request and response may contain sensitive information in the headers or body.\n // To help prevent this sensitive information being accidentally logged, the request and response\n // properties are marked as non-enumerable here. This prevents them showing up in the output of\n // JSON.stringify and console.log.\n Object.defineProperty(this, \"request\", { value: options.request, enumerable: false });\n Object.defineProperty(this, \"response\", { value: options.response, enumerable: false });\n\n Object.setPrototypeOf(this, RestError.prototype);\n }\n\n /**\n * Logging method for util.inspect in Node\n */\n [custom](): string {\n // Extract non-enumerable properties and add them back. This is OK since in this output the request and\n // response get sanitized.\n return `RestError: ${this.message} \\n ${errorSanitizer.sanitize({\n ...this,\n request: this.request,\n response: this.response,\n })}`;\n }\n}\n\n/**\n * Typeguard for RestError\n * @param e - Something caught by a catch clause.\n */\nexport function isRestError(e: unknown): e is RestError {\n if (e instanceof RestError) {\n return true;\n }\n return isError(e) && e.name === \"RestError\";\n}\n"]}
{"version":3,"file":"restError.js","sourceRoot":"","sources":["../../src/restError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EACL,SAAS,IAAI,YAAY,EACzB,WAAW,IAAI,cAAc,GAC9B,MAAM,2BAA2B,CAAC;AA+EnC;;GAEG;AACH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,SAAS,GAAyB,YAAoC,CAAC;AAEpF;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRequest, PipelineResponse } from \"./interfaces.js\";\n\nimport {\n RestError as TspRestError,\n isRestError as tspIsRestError,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * The options supported by RestError.\n */\nexport interface RestErrorOptions {\n /**\n * The code of the error itself (use statics on RestError if possible.)\n */\n code?: string;\n /**\n * The HTTP status code of the request (if applicable.)\n */\n statusCode?: number;\n /**\n * The request that was made.\n */\n request?: PipelineRequest;\n /**\n * The response received (if any.)\n */\n response?: PipelineResponse;\n}\n\n/**\n * A custom error type for failed pipeline requests.\n */\nexport interface RestErrorConstructor {\n /**\n * Something went wrong when making the request.\n * This means the actual request failed for some reason,\n * such as a DNS issue or the connection being lost.\n */\n readonly REQUEST_SEND_ERROR: string;\n /**\n * This means that parsing the response from the server failed.\n * It may have been malformed.\n */\n readonly PARSE_ERROR: string;\n\n /**\n * Prototype of RestError\n */\n readonly prototype: RestError;\n\n /**\n * Construct a new RestError.\n */\n new (message: string, options?: RestErrorOptions): RestError;\n}\n\n/**\n * A custom error type for failed pipeline requests.\n */\nexport interface RestError extends Error {\n /**\n * The code of the error itself (use statics on RestError if possible.)\n */\n code?: string;\n /**\n * The HTTP status code of the request (if applicable.)\n */\n statusCode?: number;\n /**\n * The request that was made.\n * This property is non-enumerable.\n */\n request?: PipelineRequest;\n /**\n * The response received (if any.)\n * This property is non-enumerable.\n */\n response?: PipelineResponse;\n /**\n * Bonus property set by the throw site.\n */\n details?: unknown;\n}\n\n/**\n * A custom error type for failed pipeline requests.\n */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const RestError: RestErrorConstructor = TspRestError as RestErrorConstructor;\n\n/**\n * Typeguard for RestError\n * @param e - Something caught by a catch clause.\n */\nexport function isRestError(e: unknown): e is RestError {\n return tspIsRestError(e);\n}\n"]}
@@ -1 +0,0 @@
{"version":3,"file":"retryStrategy.js","sourceRoot":"","sources":["../../../src/retryStrategies/retryStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AzureLogger } from \"@azure/logger\";\nimport type { PipelineResponse } from \"../interfaces.js\";\nimport type { RestError } from \"../restError.js\";\n\n/**\n * Information provided to the retry strategy about the current progress of the retry policy.\n */\nexport interface RetryInformation {\n /**\n * A {@link PipelineResponse}, if the last retry attempt succeeded.\n */\n response?: PipelineResponse;\n /**\n * A {@link RestError}, if the last retry attempt failed.\n */\n responseError?: RestError;\n /**\n * Total number of retries so far.\n */\n retryCount: number;\n}\n\n/**\n * Properties that can modify the behavior of the retry policy.\n */\nexport interface RetryModifiers {\n /**\n * If true, allows skipping the current strategy from running on the retry policy.\n */\n skipStrategy?: boolean;\n /**\n * Indicates to retry against this URL.\n */\n redirectTo?: string;\n /**\n * Controls whether to retry in a given number of milliseconds.\n * If provided, a new retry will be attempted.\n */\n retryAfterInMs?: number;\n /**\n * Indicates to throw this error instead of retrying.\n */\n errorToThrow?: RestError;\n}\n\n/**\n * A retry strategy is intended to define whether to retry or not, and how to retry.\n */\nexport interface RetryStrategy {\n /**\n * Name of the retry strategy. Used for logging.\n */\n name: string;\n /**\n * Logger. If it's not provided, a default logger for all retry strategies is used.\n */\n logger?: AzureLogger;\n /**\n * Function that determines how to proceed with the subsequent requests.\n * @param state - Retry state\n */\n retry(state: RetryInformation): RetryModifiers;\n}\n"]}
@@ -1 +0,0 @@
{"version":3,"file":"throttlingRetryStrategy.js","sourceRoot":"","sources":["../../../src/retryStrategies/throttlingRetryStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAG9D;;;GAGG;AACH,MAAM,gBAAgB,GAAG,aAAa,CAAC;AACvC;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAa,CAAC,gBAAgB,EAAE,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;AAEnG;;;;;;;;GAQG;AACH,SAAS,iBAAiB,CAAC,QAA2B;IACpD,IAAI,CAAC,CAAC,QAAQ,IAAI,CA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AAyB;QAC/B,KAAK,CAAC,EAAE,QAAQ,EAAE;YAChB,MAAM,cAAc,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;YACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;gBACrC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;YAChC,CAAC;YACD,OAAO;gBACL,cAAc;aACf,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineResponse } from \"../index.js\";\nimport { parseHeaderValueAsNumber } from \"../util/helpers.js\";\nimport type { RetryStrategy } from \"./retryStrategy.js\";\n\n/**\n * The header that comes back from Azure services representing\n * the amount of time (minimum) to wait to retry (in seconds or timestamp after which we can retry).\n */\nconst RetryAfterHeader = \"Retry-After\";\n/**\n * The headers that come back from Azure services representing\n * the amount of time (minimum) to wait to retry.\n *\n * \"retry-after-ms\", \"x-ms-retry-after-ms\" : milliseconds\n * \"Retry-After\" : seconds or timestamp\n */\nconst AllRetryAfterHeaders: string[] = [\"retry-after-ms\", \"x-ms-retry-after-ms\", RetryAfterHeader];\n\n/**\n * A response is a throttling retry response if it has a throttling status code (429 or 503),\n * as long as one of the [ \"Retry-After\" or \"retry-after-ms\" or \"x-ms-retry-after-ms\" ] headers has a valid value.\n *\n * Returns the `retryAfterInMs` value if the response is a throttling retry response.\n * If not throttling retry response, returns `undefined`.\n *\n * @internal\n */\nfunction getRetryAfterInMs(response?: PipelineResponse): number | undefined {\n if (!(response && [429, 503].includes(response.status))) return undefined;\n try {\n // Headers: \"retry-after-ms\", \"x-ms-retry-after-ms\", \"Retry-After\"\n for (const header of AllRetryAfterHeaders) {\n const retryAfterValue = parseHeaderValueAsNumber(response, header);\n if (retryAfterValue === 0 || retryAfterValue) {\n // \"Retry-After\" header ==> seconds\n // \"retry-after-ms\", \"x-ms-retry-after-ms\" headers ==> milli-seconds\n const multiplyingFactor = header === RetryAfterHeader ? 1000 : 1;\n return retryAfterValue * multiplyingFactor; // in milli-seconds\n }\n }\n\n // RetryAfterHeader (\"Retry-After\") has a special case where it might be formatted as a date instead of a number of seconds\n const retryAfterHeader = response.headers.get(RetryAfterHeader);\n if (!retryAfterHeader) return;\n\n const date = Date.parse(retryAfterHeader);\n const diff = date - Date.now();\n // negative diff would mean a date in the past, so retry asap with 0 milliseconds\n return Number.isFinite(diff) ? Math.max(0, diff) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * A response is a retry response if it has a throttling status code (429 or 503),\n * as long as one of the [ \"Retry-After\" or \"retry-after-ms\" or \"x-ms-retry-after-ms\" ] headers has a valid value.\n */\nexport function isThrottlingRetryResponse(response?: PipelineResponse): boolean {\n return Number.isFinite(getRetryAfterInMs(response));\n}\n\nexport function throttlingRetryStrategy(): RetryStrategy {\n return {\n name: \"throttlingRetryStrategy\",\n retry({ response }) {\n const retryAfterInMs = getRetryAfterInMs(response);\n if (!Number.isFinite(retryAfterInMs)) {\n return { skipStrategy: true };\n }\n return {\n retryAfterInMs,\n };\n },\n };\n}\n"]}
@@ -1 +0,0 @@
{"version":3,"file":"concat.common.js","sourceRoot":"","sources":["../../../src/util/concat.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE5E;;;GAGG;AACH,SAAS,KAAK,CAAC,MAAkC;IAC/C,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC;AAED,KAAK,UAAU,UAAU,CACvB,MAAsD;IAEtD,IAAI,MAAM,YAAY,IAAI,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;QAC3D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,+EAA+E;IAC/E,oFAAoF;IACpF,uBAAuB;IACvB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAEzC,2CAA2C;IAC3C,IAAI,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,iJAAiJ,CAClJ,CAAC;IACJ,CAAC;IAED,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC;AASD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAgD;IAEhD,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,MAAM,UAAU,CAAC,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACjF,CAAC;IAED,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { getRawContent } from \"./file.js\";\nimport { isNodeReadableStream, isWebReadableStream } from \"./typeGuards.js\";\n\n/**\n * Drain the content of the given ReadableStream into a Blob.\n * The blob's content may end up in memory or on disk dependent on size.\n */\nfunction drain(stream: ReadableStream<Uint8Array>): Promise<Blob> {\n return new Response(stream).blob();\n}\n\nasync function toBlobPart(\n source: ReadableStream<Uint8Array> | Blob | Uint8Array,\n): Promise<BlobPart> {\n if (source instanceof Blob || source instanceof Uint8Array) {\n return source;\n }\n\n if (isWebReadableStream(source)) {\n return drain(source);\n }\n\n // If it's not a true Blob, and it's not a Uint8Array, we can assume the source\n // is a fake File created by createFileFromStream and we can get the original stream\n // using getRawContent.\n const rawContent = getRawContent(source);\n\n // Shouldn't happen but guard for it anyway\n if (isNodeReadableStream(rawContent)) {\n throw new Error(\n \"Encountered unexpected type. In the browser, `concat` supports Web ReadableStream, Blob, Uint8Array, and files created using `createFile` only.\",\n );\n }\n\n return toBlobPart(rawContent);\n}\n\n/**\n * Accepted binary data types for concat\n *\n * @internal\n */\ntype ConcatSource = ReadableStream<Uint8Array> | Blob | Uint8Array;\n\n/**\n * Utility function that concatenates a set of binary inputs into one combined output.\n *\n * @param sources - array of sources for the concatenation\n * @returns - in Node, a (() =\\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.\n * In browser, returns a `Blob` representing all the concatenated inputs.\n *\n * @internal\n */\nexport async function concat(\n sources: (ConcatSource | (() => ConcatSource))[],\n): Promise<(() => NodeJS.ReadableStream) | Blob> {\n const parts = [];\n for (const source of sources) {\n parts.push(await toBlobPart(typeof source === \"function\" ? source() : source));\n }\n\n return new Blob(parts);\n}\n"]}
+30 -4
View File
@@ -29,13 +29,38 @@ export interface CreateFileFromStreamOptions extends CreateFileOptions {
size?: number;
}
/**
* Extract the raw content from a given blob-like object. If the input was created using createFile
* or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.
* For true instances of Blob and File, returns the blob's content as a Web ReadableStream<Uint8Array>.
* Private symbol used as key on objects created using createFile containing the
* original source of the file object.
*
* This is used in Node to access the original Node stream without using Blob#stream, which
* returns a web stream. This is done to avoid a couple of bugs to do with Blob#stream and
* Readable#to/fromWeb in Node versions we support:
* - https://github.com/nodejs/node/issues/42694 (fixed in Node 18.14)
* - https://github.com/nodejs/node/issues/48916 (fixed in Node 20.6)
*
* Once these versions are no longer supported, we may be able to stop doing this.
*
* @internal
*/
export declare function getRawContent(blob: Blob): NodeJS.ReadableStream | ReadableStream<Uint8Array> | Uint8Array;
declare const rawContent: unique symbol;
/**
* Type signature of a blob-like object with a raw content property.
*/
export interface RawContent extends Blob {
[rawContent](): Uint8Array | NodeJS.ReadableStream | ReadableStream<Uint8Array>;
}
/**
* Type guard to check if a given object is a blob-like object with a raw content property.
*/
export declare function hasRawContent(x: unknown): x is RawContent;
/**
* Extract the raw content from a given blob-like object. If the input was created using createFile
* or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.
* For true instances of Blob and File, returns the actual blob.
*
* @internal
*/
export declare function getRawContent(blob: Blob): Blob | NodeJS.ReadableStream | ReadableStream<Uint8Array> | Uint8Array;
/**
* Create an object that implements the File interface. This object is intended to be
* passed into RequestBodyType.formData, and is not guaranteed to work as expected in
@@ -66,4 +91,5 @@ export declare function createFileFromStream(stream: () => ReadableStream<Uint8A
* @param options - optional metadata about the file, e.g. file name, file size, MIME type.
*/
export declare function createFile(content: Uint8Array, name: string, options?: CreateFileOptions): File;
export {};
//# sourceMappingURL=file.d.ts.map
+9 -4
View File
@@ -1,7 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { isNodeLike } from "@azure/core-util";
import { isNodeReadableStream } from "./typeGuards.js";
function isNodeReadableStream(x) {
return Boolean(x && typeof x["pipe"] === "function");
}
const unimplementedMethods = {
arrayBuffer: () => {
throw new Error("Not implemented");
@@ -31,13 +33,16 @@ const unimplementedMethods = {
* @internal
*/
const rawContent = Symbol("rawContent");
function hasRawContent(x) {
/**
* Type guard to check if a given object is a blob-like object with a raw content property.
*/
export function hasRawContent(x) {
return typeof x[rawContent] === "function";
}
/**
* Extract the raw content from a given blob-like object. If the input was created using createFile
* or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.
* For true instances of Blob and File, returns the blob's content as a Web ReadableStream<Uint8Array>.
* For true instances of Blob and File, returns the actual blob.
*
* @internal
*/
@@ -46,7 +51,7 @@ export function getRawContent(blob) {
return blob[rawContent]();
}
else {
return blob.stream();
return blob;
}
}
/**
File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More