diff --git a/.scripts/automation_init.sh b/.scripts/automation_init.sh index 72d5d3b22b6f..2025e750e03a 100644 --- a/.scripts/automation_init.sh +++ b/.scripts/automation_init.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash npm install -g @microsoft/rush -npm install -g @azure-tools/js-sdk-release-tools +npm install -g azure-tools-js-sdk-release-tools diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 2d67d5ed07dc..83b3b2ff4fc8 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -222,6 +222,7 @@ specifiers: '@rush-temp/communication-sms': file:./projects/communication-sms.tgz '@rush-temp/confidential-ledger': file:./projects/confidential-ledger.tgz '@rush-temp/container-registry': file:./projects/container-registry.tgz + '@rush-temp/contosowidgetmanager-rest': file:./projects/contosowidgetmanager-rest.tgz '@rush-temp/core-amqp': file:./projects/core-amqp.tgz '@rush-temp/core-auth': file:./projects/core-auth.tgz '@rush-temp/core-client': file:./projects/core-client.tgz @@ -546,6 +547,7 @@ dependencies: '@rush-temp/communication-sms': file:projects/communication-sms.tgz '@rush-temp/confidential-ledger': file:projects/confidential-ledger.tgz '@rush-temp/container-registry': file:projects/container-registry.tgz + '@rush-temp/contosowidgetmanager-rest': file:projects/contosowidgetmanager-rest.tgz '@rush-temp/core-amqp': file:projects/core-amqp.tgz '@rush-temp/core-auth': file:projects/core-auth.tgz '@rush-temp/core-client': file:projects/core-client.tgz @@ -2736,6 +2738,13 @@ packages: picomatch: 2.3.1 dev: false + /append-transform/1.0.0: + resolution: {integrity: sha512-P009oYkeHyU742iSZJzZZywj4QRJdnTWffaKuJQLablCZ1uz6/cW4yaRgcDaoQ+uwOxxnt0gRUcwfsNP2ri0gw==} + engines: {node: '>=4'} + dependencies: + default-require-extensions: 2.0.0 + dev: false + /append-transform/2.0.0: resolution: {integrity: sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==} engines: {node: '>=8'} @@ -2843,8 +2852,8 @@ packages: hasBin: true dev: false - /autorest/3.6.2: - resolution: {integrity: sha512-JRMmAsSG4wplYUkjVOWELidF+P/OG9BjF542aQcbt4Qj85bJ+7EzRCTV09vbf8f4ScOB+I68+9IcskjNTU9UkQ==} + /autorest/3.6.3: + resolution: {integrity: sha512-j/Axwk9bniifTNtBLYVxfQZGQIGPKljFaCQCBWOiybVar2j3tkHP1btiC4a/t9pAJXY6IaFgWctoPM3G/Puhyg==} engines: {node: '>=12.0.0'} hasBin: true requiresBuild: true @@ -3044,6 +3053,16 @@ packages: engines: {node: '>= 0.8'} dev: false + /caching-transform/3.0.2: + resolution: {integrity: sha512-Mtgcv3lh3U0zRii/6qVgQODdPA4G3zhG+jtbCWj39RXuUFTMzH0vcdMtaJS1jPowd+It2Pqr6y3NJMQqOqCE2w==} + engines: {node: '>=6'} + dependencies: + hasha: 3.0.0 + make-dir: 2.1.0 + package-hash: 3.0.0 + write-file-atomic: 2.4.3 + dev: false + /caching-transform/4.0.0: resolution: {integrity: sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==} engines: {node: '>=8'} @@ -3408,6 +3427,17 @@ packages: path-type: 4.0.0 dev: false + /cp-file/6.2.0: + resolution: {integrity: sha512-fmvV4caBnofhPe8kOcitBwSn2f39QLjnAnGq3gO9dfd75mUytzKNZB1hde6QHunW2Rt+OwuBOMc3i1tNElbszA==} + engines: {node: '>=6'} + dependencies: + graceful-fs: 4.2.10 + make-dir: 2.1.0 + nested-error-stacks: 2.1.1 + pify: 4.0.1 + safe-buffer: 5.2.1 + dev: false + /create-require/1.1.1: resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} dev: false @@ -3428,6 +3458,13 @@ packages: - encoding dev: false + /cross-spawn/4.0.2: + resolution: {integrity: sha512-yAXz/pA1tD8Gtg2S98Ekf/sewp3Lcp3YoFKJ4Hkp5h5yLWnKVTDU0kwjKJ8NDCYcfTLfyGkzTikst+jWypT1iA==} + dependencies: + lru-cache: 4.1.5 + which: 1.3.1 + dev: false + /cross-spawn/6.0.5: resolution: {integrity: sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==} engines: {node: '>=4.8'} @@ -3554,6 +3591,13 @@ packages: engines: {node: '>=0.10.0'} dev: false + /default-require-extensions/2.0.0: + resolution: {integrity: sha512-B0n2zDIXpzLzKeoEozorDSa1cHc1t0NjmxP0zuAxbizNU2MBqYJJKYXrrFdKuQliojXynrxgd7l4ahfg/+aA5g==} + engines: {node: '>=4'} + dependencies: + strip-bom: 3.0.0 + dev: false + /default-require-extensions/3.0.1: resolution: {integrity: sha512-eXTJmRbm2TIt9MgWTsOH1wEuhew6XGZcMeGKCtLedIg/NCsg1iBePXkceTdK4Fii7pzmN9tGsZhKzZ4h7O/fxw==} engines: {node: '>=8'} @@ -3673,7 +3717,7 @@ packages: dependencies: semver: 7.3.8 shelljs: 0.8.5 - typescript: 5.0.0-dev.20230103 + typescript: 5.0.0-dev.20230106 dev: false /downlevel-dts/0.7.0: @@ -4442,6 +4486,15 @@ packages: unpipe: 1.0.0 dev: false + /find-cache-dir/2.1.0: + resolution: {integrity: sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==} + engines: {node: '>=6'} + dependencies: + commondir: 1.0.1 + make-dir: 2.1.0 + pkg-dir: 3.0.0 + dev: false + /find-cache-dir/3.3.2: resolution: {integrity: sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==} engines: {node: '>=8'} @@ -4521,6 +4574,13 @@ packages: is-callable: 1.2.7 dev: false + /foreground-child/1.5.6: + resolution: {integrity: sha512-3TOY+4TKV0Ml83PXJQY+JFQaHNV38lzQDIzzXYg1kWdBLenGgoZhAs0CKgzI31vi2pWEpQMq/Yi4bpKwCPkw7g==} + dependencies: + cross-spawn: 4.0.2 + signal-exit: 3.0.7 + dev: false + /foreground-child/2.0.0: resolution: {integrity: sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==} engines: {node: '>=8.0.0'} @@ -4872,6 +4932,13 @@ packages: function-bind: 1.1.1 dev: false + /hasha/3.0.0: + resolution: {integrity: sha512-w0Kz8lJFBoyaurBiNrIvxPqr/gJ6fOfSkpAPOepN3oECqGJag37xPbOv57izi/KP8auHgNYxn5fXtAb+1LsJ6w==} + engines: {node: '>=4'} + dependencies: + is-stream: 1.1.0 + dev: false + /hasha/5.2.2: resolution: {integrity: sha512-Hrp5vIK/xr5SkeN2onO32H0MgNZ0f17HRNH39WfL0SYUNOTZ5Lz1TJ8Pajo/87dYGEFlLMm7mIc/k/s6Bvz9HQ==} engines: {node: '>=8'} @@ -5254,6 +5321,11 @@ packages: call-bind: 1.0.2 dev: false + /is-stream/1.1.0: + resolution: {integrity: sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==} + engines: {node: '>=0.10.0'} + dev: false + /is-stream/2.0.1: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} @@ -5342,11 +5414,23 @@ packages: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: false + /istanbul-lib-coverage/2.0.5: + resolution: {integrity: sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA==} + engines: {node: '>=6'} + dev: false + /istanbul-lib-coverage/3.2.0: resolution: {integrity: sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==} engines: {node: '>=8'} dev: false + /istanbul-lib-hook/2.0.7: + resolution: {integrity: sha512-vrRztU9VRRFDyC+aklfLoeXyNdTfga2EI3udDGn4cZ6fpSXpHLV9X6CHvfoMCPtggg8zvDDmC4b9xfu0z6/llA==} + engines: {node: '>=6'} + dependencies: + append-transform: 1.0.0 + dev: false + /istanbul-lib-hook/3.0.0: resolution: {integrity: sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==} engines: {node: '>=8'} @@ -5354,6 +5438,21 @@ packages: append-transform: 2.0.0 dev: false + /istanbul-lib-instrument/3.3.0: + resolution: {integrity: sha512-5nnIN4vo5xQZHdXno/YDXJ0G+I3dAm4XgzfSVTPLQpj/zAV2dV6Juy0yaf10/zrJOJeHoN3fraFe+XRq2bFVZA==} + engines: {node: '>=6'} + dependencies: + '@babel/generator': 7.20.7 + '@babel/parser': 7.20.7 + '@babel/template': 7.20.7 + '@babel/traverse': 7.20.10 + '@babel/types': 7.20.7 + istanbul-lib-coverage: 2.0.5 + semver: 6.3.0 + transitivePeerDependencies: + - supports-color + dev: false + /istanbul-lib-instrument/4.0.3: resolution: {integrity: sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==} engines: {node: '>=8'} @@ -5391,6 +5490,15 @@ packages: uuid: 8.3.2 dev: false + /istanbul-lib-report/2.0.8: + resolution: {integrity: sha512-fHBeG573EIihhAblwgxrSenp0Dby6tJMFR/HvlerBsrCTD5bkUuoNtn3gVh29ZCS824cGGBPn7Sg7cNk+2xUsQ==} + engines: {node: '>=6'} + dependencies: + istanbul-lib-coverage: 2.0.5 + make-dir: 2.1.0 + supports-color: 6.1.0 + dev: false + /istanbul-lib-report/3.0.0: resolution: {integrity: sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==} engines: {node: '>=8'} @@ -5400,6 +5508,19 @@ packages: supports-color: 7.2.0 dev: false + /istanbul-lib-source-maps/3.0.6: + resolution: {integrity: sha512-R47KzMtDJH6X4/YW9XTx+jrLnZnscW4VpNN+1PViSYTejLVPWv7oov+Duf8YQSPyVRUvueQqz1TcsC6mooZTXw==} + engines: {node: '>=6'} + dependencies: + debug: 4.3.4 + istanbul-lib-coverage: 2.0.5 + make-dir: 2.1.0 + rimraf: 2.7.1 + source-map: 0.6.1 + transitivePeerDependencies: + - supports-color + dev: false + /istanbul-lib-source-maps/4.0.1: resolution: {integrity: sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==} engines: {node: '>=10'} @@ -5411,6 +5532,13 @@ packages: - supports-color dev: false + /istanbul-reports/2.2.7: + resolution: {integrity: sha512-uu1F/L1o5Y6LzPVSVZXNOoD/KXpJue9aeLRd0sM9uMXfZvzomB0WxVamWb5ue8kA2vVWEmW7EG+A5n3f1kqHKg==} + engines: {node: '>=6'} + dependencies: + html-escaper: 2.0.2 + dev: false + /istanbul-reports/3.1.5: resolution: {integrity: sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==} engines: {node: '>=8'} @@ -5940,6 +6068,13 @@ packages: get-func-name: 2.0.0 dev: false + /lru-cache/4.1.5: + resolution: {integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==} + dependencies: + pseudomap: 1.0.2 + yallist: 2.1.2 + dev: false + /lru-cache/5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} dependencies: @@ -5978,6 +6113,14 @@ packages: '@jridgewell/sourcemap-codec': 1.4.14 dev: false + /make-dir/2.1.0: + resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==} + engines: {node: '>=6'} + dependencies: + pify: 4.0.1 + semver: 5.7.1 + dev: false + /make-dir/3.1.0: resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} engines: {node: '>=8'} @@ -6047,6 +6190,12 @@ packages: resolution: {integrity: sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==} dev: false + /merge-source-map/1.1.0: + resolution: {integrity: sha512-Qkcp7P2ygktpMPh2mCQZaf3jhN6D3Z/qVZHSdWvQ+2Ef5HgRAPBO57A77+ENm0CPx2+1Ce/MYKi3ymqdfuqibw==} + dependencies: + source-map: 0.6.1 + dev: false + /merge-stream/2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} dev: false @@ -6295,6 +6444,10 @@ packages: engines: {node: '>= 0.6'} dev: false + /nested-error-stacks/2.1.1: + resolution: {integrity: sha512-9iN1ka/9zmX1ZvLV9ewJYEk9h7RyRRtqdK0woXcqohu8EWIerfPUjYJPg0ULy0UqP7cslmdGc8xKDJcojlKiaw==} + dev: false + /next-tick/1.0.0: resolution: {integrity: sha512-mc/caHeUcdjnC/boPWJefDr4KUIWQNv+tlnFnJd38QMou86QtxQzBJfxgGRzvx8jazYRqrVlaHarfO72uNxPOg==} dev: false @@ -6435,6 +6588,40 @@ packages: path-key: 4.0.0 dev: false + /nyc/14.1.1: + resolution: {integrity: sha512-OI0vm6ZGUnoGZv/tLdZ2esSVzDwUC88SNs+6JoSOMVxA+gKMB8Tk7jBwgemLx4O40lhhvZCVw1C+OYLOBOPXWw==} + engines: {node: '>=6'} + hasBin: true + dependencies: + archy: 1.0.0 + caching-transform: 3.0.2 + convert-source-map: 1.9.0 + cp-file: 6.2.0 + find-cache-dir: 2.1.0 + find-up: 3.0.0 + foreground-child: 1.5.6 + glob: 7.2.3 + istanbul-lib-coverage: 2.0.5 + istanbul-lib-hook: 2.0.7 + istanbul-lib-instrument: 3.3.0 + istanbul-lib-report: 2.0.8 + istanbul-lib-source-maps: 3.0.6 + istanbul-reports: 2.2.7 + js-yaml: 3.14.1 + make-dir: 2.1.0 + merge-source-map: 1.1.0 + resolve-from: 4.0.0 + rimraf: 2.7.1 + signal-exit: 3.0.7 + spawn-wrap: 1.4.3 + test-exclude: 5.2.3 + uuid: 3.4.0 + yargs: 13.3.2 + yargs-parser: 13.1.2 + transitivePeerDependencies: + - supports-color + dev: false + /nyc/15.1.0: resolution: {integrity: sha512-jMW04n9SxKdKi1ZMGhvUTHBN0EICCRkHemEoE5jm6mTYcqcdas0ATzgUgejlQUHMvpnOZqGB5Xxsv9KxJW1j8A==} engines: {node: '>=8.9'} @@ -6594,6 +6781,11 @@ packages: wcwidth: 1.0.1 dev: false + /os-homedir/1.0.2: + resolution: {integrity: sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==} + engines: {node: '>=0.10.0'} + dev: false + /os-tmpdir/1.0.2: resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} engines: {node: '>=0.10.0'} @@ -6646,6 +6838,16 @@ packages: engines: {node: '>=6'} dev: false + /package-hash/3.0.0: + resolution: {integrity: sha512-lOtmukMDVvtkL84rJHI7dpTYq+0rli8N2wlnqUcBuDWCfVhRUfOmnR9SsoHFMLpACvEV60dX7rd0rFaYDZI+FA==} + engines: {node: '>=6'} + dependencies: + graceful-fs: 4.2.10 + hasha: 3.0.0 + lodash.flattendeep: 4.4.0 + release-zalgo: 1.0.0 + dev: false + /package-hash/4.0.0: resolution: {integrity: sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==} engines: {node: '>=8'} @@ -6794,6 +6996,18 @@ packages: engines: {node: '>=4'} dev: false + /pify/4.0.1: + resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} + engines: {node: '>=6'} + dev: false + + /pkg-dir/3.0.0: + resolution: {integrity: sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==} + engines: {node: '>=6'} + dependencies: + find-up: 3.0.0 + dev: false + /pkg-dir/4.2.0: resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==} engines: {node: '>=8'} @@ -6825,6 +7039,12 @@ packages: engines: {node: '>= 0.8.0'} dev: false + /prettier/2.2.1: + resolution: {integrity: sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==} + engines: {node: '>=10.13.0'} + hasBin: true + dev: false + /prettier/2.8.1: resolution: {integrity: sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==} engines: {node: '>=10.13.0'} @@ -6879,6 +7099,10 @@ packages: resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} dev: false + /pseudomap/1.0.2: + resolution: {integrity: sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==} + dev: false + /psl/1.9.0: resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==} dev: false @@ -6994,6 +7218,14 @@ packages: strip-json-comments: 2.0.1 dev: false + /read-pkg-up/4.0.0: + resolution: {integrity: sha512-6etQSH7nJGsK0RbG/2TeDzZFa8shjQ1um+SwQQ5cwKy0dhSXdOncEhb1CPpvQG4h7FyOV6EB6YlV0yJvZQNAkA==} + engines: {node: '>=6'} + dependencies: + find-up: 3.0.0 + read-pkg: 3.0.0 + dev: false + /read-pkg/3.0.0: resolution: {integrity: sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA==} engines: {node: '>=4'} @@ -7191,6 +7423,13 @@ packages: debug: 3.2.7 dev: false + /rimraf/2.7.1: + resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==} + hasBin: true + dependencies: + glob: 7.2.3 + dev: false + /rimraf/3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} hasBin: true @@ -7593,6 +7832,17 @@ packages: resolution: {integrity: sha512-n98l9E2RMSJ9ON1AKisHzz7V42VDiBQGY6PB1BwRglz99wpVsSuGzQ+jOi6lFXBGVTCrRpltvjm+/XA+tpeJrg==} dev: false + /spawn-wrap/1.4.3: + resolution: {integrity: sha512-IgB8md0QW/+tWqcavuFgKYR/qIRvJkRLPJDFaoXtLLUaVcCDK0+HeFTkmQHj3eprcYhc+gOl0aEA1w7qZlYezw==} + dependencies: + foreground-child: 1.5.6 + mkdirp: 0.5.6 + os-homedir: 1.0.2 + rimraf: 2.7.1 + signal-exit: 3.0.7 + which: 1.3.1 + dev: false + /spawn-wrap/2.0.0: resolution: {integrity: sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==} engines: {node: '>=8'} @@ -7803,6 +8053,13 @@ packages: has-flag: 3.0.0 dev: false + /supports-color/6.1.0: + resolution: {integrity: sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==} + engines: {node: '>=6'} + dependencies: + has-flag: 3.0.0 + dev: false + /supports-color/7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} engines: {node: '>=8'} @@ -7853,6 +8110,16 @@ packages: readable-stream: 3.6.0 dev: false + /test-exclude/5.2.3: + resolution: {integrity: sha512-M+oxtseCFO3EDtAaGH7iiej3CBkzXqFMbzqYAACdzKui4eZA+pq3tZEwChvOdNfa7xxy8BfbmgJSIr43cC/+2g==} + engines: {node: '>=6'} + dependencies: + glob: 7.2.3 + minimatch: 3.1.2 + read-pkg-up: 4.0.0 + require-main-filename: 2.0.0 + dev: false + /test-exclude/6.0.0: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} @@ -8270,8 +8537,8 @@ packages: hasBin: true dev: false - /typescript/5.0.0-dev.20230103: - resolution: {integrity: sha512-vHf8Y8+op6MsFIDgvNmZhAIAUGVmzFzYCUBysMS6hlxlhSWIh1h5AXAW7WKs4GYr325jwTF/L72NKUYZHSD6Mw==} + /typescript/5.0.0-dev.20230106: + resolution: {integrity: sha512-l5MlIodeUoKfl4WO8vnF4x90a6SgOPBiSXeaeVlEdCLuw0XcrBbRHYU6x1FErNqBS4rky+2cj/GX5TA97FJBlQ==} engines: {node: '>=4.2.0'} hasBin: true dev: false @@ -8394,6 +8661,12 @@ packages: engines: {node: '>= 0.4.0'} dev: false + /uuid/3.4.0: + resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==} + deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. + hasBin: true + dev: false + /uuid/8.3.2: resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} hasBin: true @@ -8546,6 +8819,14 @@ packages: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: false + /write-file-atomic/2.4.3: + resolution: {integrity: sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==} + dependencies: + graceful-fs: 4.2.10 + imurmurhash: 0.1.4 + signal-exit: 3.0.7 + dev: false + /write-file-atomic/3.0.3: resolution: {integrity: sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==} dependencies: @@ -8643,6 +8924,10 @@ packages: engines: {node: '>=10'} dev: false + /yallist/2.1.2: + resolution: {integrity: sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==} + dev: false + /yallist/3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} dev: false @@ -8874,7 +9159,7 @@ packages: '@types/chai': 4.3.4 '@types/mocha': 7.0.2 '@types/node': 14.18.36 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 csv-parse: 5.3.3 @@ -9163,7 +9448,7 @@ packages: '@microsoft/api-extractor': 7.33.7 '@types/chai': 4.3.4 '@types/node': 14.18.36 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -9696,7 +9981,7 @@ packages: '@microsoft/api-extractor': 7.33.7 '@types/chai': 4.3.4 '@types/node': 14.18.36 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -10387,7 +10672,7 @@ packages: '@microsoft/api-extractor': 7.33.7 '@types/chai': 4.3.4 '@types/node': 14.18.36 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -10622,7 +10907,7 @@ packages: '@microsoft/api-extractor': 7.33.7 '@types/chai': 4.3.4 '@types/node': 14.18.36 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -12816,7 +13101,7 @@ packages: '@microsoft/api-extractor': 7.33.7 '@types/chai': 4.3.4 '@types/node': 14.18.36 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -13970,7 +14255,7 @@ packages: '@microsoft/api-extractor': 7.33.7 '@types/chai': 4.3.4 '@types/node': 14.18.36 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -15298,7 +15583,7 @@ packages: '@types/chai': 4.3.4 '@types/mocha': 7.0.2 '@types/node': 14.18.36 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -15376,6 +15661,50 @@ packages: - utf-8-validate dev: false + file:projects/contosowidgetmanager-rest.tgz: + resolution: {integrity: sha512-THQYV+r/IKi8F9aRAWkJ37NQowISwsftTafU08Usskkj/WfN5UDIwqqrSfjpWXkkn/Fa/IIRCb9RekpVfDTrow==, tarball: file:projects/contosowidgetmanager-rest.tgz} + name: '@rush-temp/contosowidgetmanager-rest' + version: 0.0.0 + dependencies: + '@azure-rest/core-client': 1.0.0-beta.10 + '@azure/identity': 2.1.0 + '@microsoft/api-extractor': 7.33.7 + '@types/chai': 4.3.4 + '@types/mocha': 7.0.2 + '@types/node': 14.18.36 + autorest: 3.6.3 + chai: 4.3.7 + cross-env: 7.0.3 + dotenv: 8.6.0 + eslint: 8.31.0 + karma: 6.4.1 + karma-chrome-launcher: 3.1.1 + karma-coverage: 2.2.0 + karma-edge-launcher: 0.4.2_karma@6.4.1 + karma-env-preprocessor: 0.1.1 + karma-firefox-launcher: 1.3.0 + karma-ie-launcher: 1.0.0_karma@6.4.1 + karma-junit-reporter: 2.0.1_karma@6.4.1 + karma-mocha: 2.0.1 + karma-mocha-reporter: 2.2.5_karma@6.4.1 + karma-source-map-support: 1.4.0 + karma-sourcemap-loader: 0.3.8 + mkdirp: 1.0.4 + mocha: 7.2.0 + mocha-junit-reporter: 1.23.3_mocha@7.2.0 + nyc: 14.1.1 + prettier: 2.2.1 + rimraf: 3.0.2 + source-map-support: 0.5.21 + tslib: 2.4.1 + typescript: 4.8.4 + transitivePeerDependencies: + - bufferutil + - debug + - supports-color + - utf-8-validate + dev: false + file:projects/core-amqp.tgz: resolution: {integrity: sha512-vJ7aD2zobl65Rwr8xx9e21lUr0OnvQSx5Wnhyy4YWdtZA77wD5hTLqB3nXbtQhni6siHOObS5UgZepNRivjq/g==, tarball: file:projects/core-amqp.tgz} name: '@rush-temp/core-amqp' @@ -15992,7 +16321,7 @@ packages: '@types/node': 14.18.36 '@types/prettier': 2.7.2 '@types/semver': 7.3.13 - autorest: 3.6.2 + autorest: 3.6.3 builtin-modules: 3.3.0 chai: 4.3.7 chai-as-promised: 7.1.1_chai@4.3.7 @@ -16038,7 +16367,7 @@ packages: '@microsoft/api-extractor': 7.33.7 '@types/chai': 4.3.4 '@types/node': 14.18.36 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -16854,7 +17183,7 @@ packages: '@types/chai': 4.3.4 '@types/node': 12.20.55 '@types/uuid': 8.3.4 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -16960,7 +17289,7 @@ packages: '@types/chai': 4.3.4 '@types/mocha': 7.0.2 '@types/node': 14.18.36 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -17004,7 +17333,7 @@ packages: '@types/chai': 4.3.4 '@types/mocha': 7.0.2 '@types/node': 14.18.36 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -17048,7 +17377,7 @@ packages: '@types/chai': 4.3.4 '@types/mocha': 7.0.2 '@types/node': 12.20.55 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -17139,7 +17468,7 @@ packages: '@types/chai': 4.3.4 '@types/mocha': 7.0.2 '@types/node': 14.18.36 - autorest: 3.6.2 + autorest: 3.6.3 chai: 4.3.7 cross-env: 7.0.3 dotenv: 8.6.0 @@ -19213,7 +19542,7 @@ packages: dev: false file:projects/web-pubsub-client.tgz: - resolution: {integrity: sha512-Oc9P1qEG7j1/x5vxElDNAR1HvB4MjTHj49e6G4eZZHSDjCS9EDFNtYg+gauXUYmJe0ESYPLAy4dfz2tdifps2A==, tarball: file:projects/web-pubsub-client.tgz} + resolution: {integrity: sha512-+Apad1BfmHLxmvPilgDRLuuW5MS/769gUHJZoNLd6g+CicZnt/no0bsPcSOuXXler5WqeM0kFu7grG0q2MOCzg==, tarball: file:projects/web-pubsub-client.tgz} name: '@rush-temp/web-pubsub-client' version: 0.0.0 dependencies: diff --git a/eng/typescript-emitter-package.json b/eng/typescript-emitter-package.json new file mode 100644 index 000000000000..22345813c417 --- /dev/null +++ b/eng/typescript-emitter-package.json @@ -0,0 +1,11 @@ +{ + "dependencies": { + "@cadl-lang/compiler": "~0.38.5", + "@azure-tools/cadl-typescript": "1.0.0-beta.7", + "@cadl-lang/versioning": "0.38.0", + "@azure-tools/cadl-autorest": "0.24.0", + "@cadl-lang/eslint-config-cadl": "0.5.0", + "@cadl-lang/eslint-plugin": "0.38.0", + "@cadl-lang/library-linter": "0.38.0" + } +} diff --git a/rush.json b/rush.json index 0520cabd8ab3..62f1db8c170e 100644 --- a/rush.json +++ b/rush.json @@ -1,7 +1,7 @@ /** * This is the main configuration file for Rush. * For full documentation, please see https://rushjs.io - */ { + */{ "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json", /** * (Required) This specifies the version of the Rush engine to be used in this repo. @@ -1928,6 +1928,11 @@ "packageName": "@azure/arm-billingbenefits", "projectFolder": "sdk/billingbenefits/arm-billingbenefits", "versionPolicyName": "management" + }, + { + "packageName": "@azure-rest/contosowidgetmanager-rest", + "projectFolder": "sdk/contosowidgetmanager/contosowidgetmanager-rest", + "versionPolicyName": "client" } ] -} +} \ No newline at end of file diff --git a/sdk/contosowidgetmanager/ci.yml b/sdk/contosowidgetmanager/ci.yml new file mode 100644 index 000000000000..7ecfab5f1fbc --- /dev/null +++ b/sdk/contosowidgetmanager/ci.yml @@ -0,0 +1,33 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/contosowidgetmanager/ +pr: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/contosowidgetmanager/ +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: contosowidgetmanager + Artifacts: + - name: azure-rest-contosowidgetmanager-rest + safeName: azurerestcontosowidgetmanagerrest diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/.eslintrc.json b/sdk/contosowidgetmanager/contosowidgetmanager-rest/.eslintrc.json new file mode 100644 index 000000000000..619797ac39b6 --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/.eslintrc.json @@ -0,0 +1,11 @@ +{ + "plugins": ["@azure/azure-sdk"], + "extends": ["plugin:@azure/azure-sdk/azure-sdk-base"], + "rules": { + "@azure/azure-sdk/ts-modules-only-named": "warn", + "@azure/azure-sdk/ts-apiextractor-json-types": "warn", + "@azure/azure-sdk/ts-package-json-types": "warn", + "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", + "tsdoc/syntax": "warn" + } +} diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/README.md b/sdk/contosowidgetmanager/contosowidgetmanager-rest/README.md new file mode 100644 index 000000000000..2910b21c4a5b --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/README.md @@ -0,0 +1,59 @@ +# Azure ContosoWidgetManager REST client library for JavaScript + +Contoso WidgetManager Service + +**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library** + +Key links: + +- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/contosowidgetmanager/contosowidgetmanager-rest) +- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/contosowidgetmanager-rest) +- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/contosowidgetmanager-rest?view=azure-node-preview) +- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/contosowidgetmanager/contosowidgetmanager-rest/samples) + +## Getting started + +### Currently supported environments + +- LTS versions of Node.js + +### Prerequisites + +- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package. + +### Install the `@azure-rest/contosowidgetmanager-rest` package + +Install the Azure ContosoWidgetManager REST client REST client library for JavaScript with `npm`: + +```bash +npm install @azure-rest/contosowidgetmanager-rest +``` + +### Create and authenticate a `ContosoWidgetManagerClient` + +To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token), +provide an instance of the desired credential type obtained from the +[@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library. + +To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity) + +After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use. +As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential) +can be used to authenticate the client. + +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: +AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET + +## Troubleshooting + +### Logging + +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: + +```javascript +const { setLogLevel } = require("@azure/logger"); + +setLogLevel("info"); +``` + +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/api-extractor.json b/sdk/contosowidgetmanager/contosowidgetmanager-rest/api-extractor.json new file mode 100644 index 000000000000..a76b6c9e43f5 --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/api-extractor.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "./types/src/index.d.ts", + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/contosowidgetmanager-rest.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} \ No newline at end of file diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/karma.conf.js b/sdk/contosowidgetmanager/contosowidgetmanager-rest/karma.conf.js new file mode 100644 index 000000000000..85f5daf9d351 --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/karma.conf.js @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +// https://github.com/karma-runner/karma-chrome-launcher +process.env.CHROME_BIN = require("puppeteer").executablePath(); +require("dotenv").config(); +const { relativeRecordingsPath } = require("@azure-tools/test-recorder"); +process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath(); + +module.exports = function (config) { + config.set({ + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: "./", + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ["source-map-support", "mocha"], + + plugins: [ + "karma-mocha", + "karma-mocha-reporter", + "karma-chrome-launcher", + "karma-edge-launcher", + "karma-firefox-launcher", + "karma-ie-launcher", + "karma-env-preprocessor", + "karma-coverage", + "karma-sourcemap-loader", + "karma-junit-reporter", + "karma-source-map-support", + ], + + // list of files / patterns to load in the browser + files: [ + "dist-test/index.browser.js", + { + pattern: "dist-test/index.browser.js.map", + type: "html", + included: false, + served: true, + }, + ], + + // list of files / patterns to exclude + exclude: [], + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + "**/*.js": ["sourcemap", "env"], + // IMPORTANT: COMMENT following line if you want to debug in your browsers!! + // Preprocess source file to calculate code coverage, however this will make source file unreadable + // "dist-test/index.js": ["coverage"] + }, + + envPreprocessor: [ + "TEST_MODE", + "ENDPOINT", + "AZURE_CLIENT_SECRET", + "AZURE_CLIENT_ID", + "AZURE_TENANT_ID", + "SUBSCRIPTION_ID", + "RECORDINGS_RELATIVE_PATH", + ], + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ["mocha", "coverage", "junit"], + + coverageReporter: { + // specify a common output directory + dir: "coverage-browser/", + reporters: [ + { type: "json", subdir: ".", file: "coverage.json" }, + { type: "lcovonly", subdir: ".", file: "lcov.info" }, + { type: "html", subdir: "html" }, + { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }, + ], + }, + + junitReporter: { + outputDir: "", // results will be saved as $outputDir/$browserName.xml + outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile + suite: "", // suite will become the package name attribute in xml testsuite element + useBrowserName: false, // add browser name to report and classes names + nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element + classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element + properties: {}, // key value pair of properties to add to the section of the report + }, + + // web server port + port: 9876, + + // enable / disable colors in the output (reporters and logs) + colors: true, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: false, + + // --no-sandbox allows our tests to run in Linux without having to change the system. + // --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex. + browsers: ["ChromeHeadlessNoSandbox"], + customLaunchers: { + ChromeHeadlessNoSandbox: { + base: "ChromeHeadless", + flags: ["--no-sandbox", "--disable-web-security"], + }, + }, + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: 1, + + browserNoActivityTimeout: 60000000, + browserDisconnectTimeout: 10000, + browserDisconnectTolerance: 3, + + client: { + mocha: { + // change Karma's debug.html to the mocha web reporter + reporter: "html", + timeout: "600000", + }, + }, + }); +}; diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/package.json b/sdk/contosowidgetmanager/contosowidgetmanager-rest/package.json new file mode 100644 index 000000000000..fc1766c73600 --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/package.json @@ -0,0 +1,120 @@ +{ + "name": "@azure-rest/contosowidgetmanager-rest", + "sdk-type": "client", + "author": "Microsoft Corporation", + "version": "1.0.0-beta.1", + "description": "Contoso WidgetManager Service", + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "dist/index.js", + "module": "./dist-esm/src/index.js", + "types": "./types/contosowidgetmanager-rest.d.ts", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "files": [ + "dist/", + "dist-esm/src/", + "types/contosowidgetmanager-rest.d.ts", + "README.md", + "LICENSE", + "review/*" + ], + "engines": { + "node": ">=14.0.0" + }, + "scripts": { + "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", + "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1", + "build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1", + "build:samples": "echo skipped.", + "build:test": "tsc -p . && dev-tool run bundle", + "build:debug": "tsc -p . && dev-tool run bundle && api-extractor run --local", + "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"test/**/*.ts\"", + "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "execute:samples": "echo skipped", + "extract-api": "rimraf review && mkdirp ./review && api-extractor run --local", + "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" \"test/**/*.ts\"", + "generate:client": "autorest --typescript swagger/README.md && npm run format", + "integration-test:browser": "dev-tool run test:browser", + "integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]", + "lint": "eslint package.json api-extractor.json src test --ext .ts", + "pack": "npm pack 2>&1", + "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser", + "test:node": "npm run clean && npm run build:test && npm run unit-test:node", + "test": "npm run clean && npm run build:test && npm run unit-test", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'", + "unit-test:browser": "dev-tool run test:browser", + "build": "npm run clean && tsc -p . && dev-tool run bundle && mkdirp ./review && api-extractor run --local" + }, + "sideEffects": false, + "autoPublish": false, + "dependencies": { + "@azure/core-auth": "^1.3.0", + "@azure-rest/core-client": "1.0.0-beta.10", + "@azure/core-rest-pipeline": "^1.8.0", + "@azure/logger": "^1.0.0", + "tslib": "^2.2.0", + "@azure/core-paging": "^1.2.0", + "@azure/core-lro": "^2.2.0" + }, + "devDependencies": { + "@microsoft/api-extractor": "^7.31.1", + "autorest": "latest", + "@types/node": "^14.0.0", + "dotenv": "^8.2.0", + "eslint": "^8.0.0", + "mkdirp": "^1.0.4", + "prettier": "2.2.1", + "rimraf": "^3.0.0", + "source-map-support": "^0.5.9", + "typescript": "~4.8.0", + "@azure/dev-tool": "^1.0.0", + "@azure/eslint-plugin-azure-sdk": "^3.0.0", + "@azure-tools/test-credential": "^1.0.0", + "@azure/identity": "^2.0.1", + "@azure-tools/test-recorder": "^2.0.0", + "mocha": "^7.1.1", + "@types/mocha": "^7.0.2", + "mocha-junit-reporter": "^1.18.0", + "cross-env": "^7.0.2", + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "karma-chrome-launcher": "^3.0.0", + "karma-coverage": "^2.0.0", + "karma-edge-launcher": "^0.4.2", + "karma-env-preprocessor": "^0.1.1", + "karma-firefox-launcher": "^1.1.0", + "karma-ie-launcher": "^1.0.0", + "karma-junit-reporter": "^2.0.1", + "karma-mocha-reporter": "^2.2.5", + "karma-mocha": "^2.0.1", + "karma-source-map-support": "~1.4.0", + "karma-sourcemap-loader": "^0.3.8", + "karma": "^6.2.0", + "nyc": "^14.0.0" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/contosowidgetmanager/contosowidgetmanager-rest/README.md", + "//metadata": { + "constantPaths": [ + { + "path": "swagger/README.md", + "prefix": "package-version" + } + ] + }, + "browser": { + "./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js" + } +} \ No newline at end of file diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/clientDefinitions.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/clientDefinitions.ts new file mode 100644 index 000000000000..1455b6210a4c --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/clientDefinitions.ts @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { + GetWidgetParameters, + CreateOrUpdateWidgetParameters, + DeleteWidgetParameters, + GetWidgetOperationStatusParameters, + ListWidgetsParameters, +} from "./parameters"; +import { + GetWidget200Response, + GetWidgetDefaultResponse, + CreateOrUpdateWidget200Response, + CreateOrUpdateWidget201Response, + CreateOrUpdateWidgetDefaultResponse, + DeleteWidget202Response, + DeleteWidgetDefaultResponse, + GetWidgetOperationStatus200Response, + GetWidgetOperationStatusDefaultResponse, + ListWidgets200Response, + ListWidgetsDefaultResponse, +} from "./responses"; +import { Client, StreamableMethod } from "@azure-rest/core-client"; + +export interface GetWidget { + /** Fetch a Widget by name. */ + get( + options?: GetWidgetParameters + ): StreamableMethod; + /** Creates or updates a Widget asynchronously. */ + patch( + options: CreateOrUpdateWidgetParameters + ): StreamableMethod< + | CreateOrUpdateWidget200Response + | CreateOrUpdateWidget201Response + | CreateOrUpdateWidgetDefaultResponse + >; + /** Delete a Widget asynchronously. */ + delete( + options?: DeleteWidgetParameters + ): StreamableMethod; +} + +export interface GetWidgetOperationStatus { + /** Gets status of a Widget operation. */ + get( + options?: GetWidgetOperationStatusParameters + ): StreamableMethod< + | GetWidgetOperationStatus200Response + | GetWidgetOperationStatusDefaultResponse + >; +} + +export interface ListWidgets { + /** List Widget resources */ + get( + options?: ListWidgetsParameters + ): StreamableMethod; +} + +export interface Routes { + /** Resource for '/widgets/\{widgetName\}' has methods for the following verbs: get, patch, delete */ + (path: "/widgets/{widgetName}", widgetName: string): GetWidget; + /** Resource for '/widgets/\{widgetName\}/operations/\{operationId\}' has methods for the following verbs: get */ + ( + path: "/widgets/{widgetName}/operations/{operationId}", + widgetName: string, + operationId: string + ): GetWidgetOperationStatus; + /** Resource for '/widgets' has methods for the following verbs: get */ + (path: "/widgets"): ListWidgets; +} + +export type ContosoWidgetManagerClient = Client & { + path: Routes; +}; diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/contosoWidgetManager.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/contosoWidgetManager.ts new file mode 100644 index 000000000000..c86acabc92bf --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/contosoWidgetManager.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { getClient, ClientOptions } from "@azure-rest/core-client"; +import { ContosoWidgetManagerClient } from "./clientDefinitions"; + +/** + * Initialize a new instance of the class ContosoWidgetManagerClient class. + * @param endpoint type: string + */ +export default function createClient( + endpoint: string, + options: ClientOptions = {} +): ContosoWidgetManagerClient { + const baseUrl = options.baseUrl ?? `${endpoint}`; + + const userAgentInfo = `azsdk-js-contosowidgetmanager-rest/1.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` + : `${userAgentInfo}`; + options = { + ...options, + userAgentOptions: { + userAgentPrefix, + }, + }; + + const client = getClient(baseUrl, options) as ContosoWidgetManagerClient; + + return client; +} diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/index.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/index.ts new file mode 100644 index 000000000000..e9eb390b6490 --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/index.ts @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import ContosoWidgetManager from "./contosoWidgetManager"; + +export * from "./contosoWidgetManager"; +export * from "./parameters"; +export * from "./responses"; +export * from "./clientDefinitions"; +export * from "./isUnexpected"; +export * from "./models"; +export * from "./outputModels"; +export * from "./paginateHelper"; +export * from "./pollingHelper"; + +export default ContosoWidgetManager; diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/isUnexpected.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/isUnexpected.ts new file mode 100644 index 000000000000..c86ec8577859 --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/isUnexpected.ts @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { + GetWidget200Response, + GetWidgetDefaultResponse, + CreateOrUpdateWidget200Response, + CreateOrUpdateWidget201Response, + CreateOrUpdateWidgetDefaultResponse, + DeleteWidget202Response, + DeleteWidgetDefaultResponse, + GetWidgetOperationStatus200Response, + GetWidgetOperationStatusDefaultResponse, + ListWidgets200Response, + ListWidgetsDefaultResponse, +} from "./responses"; + +const responseMap: Record = { + "GET /widgets/{widgetName}": ["200"], + "PATCH /widgets/{widgetName}": ["200", "201"], + "DELETE /widgets/{widgetName}": ["202"], + "GET /widgets/{widgetName}/operations/{operationId}": ["200"], + "GET /widgets": ["200"], +}; + +export function isUnexpected( + response: GetWidget200Response | GetWidgetDefaultResponse +): response is GetWidgetDefaultResponse; +export function isUnexpected( + response: + | CreateOrUpdateWidget200Response + | CreateOrUpdateWidget201Response + | CreateOrUpdateWidgetDefaultResponse +): response is CreateOrUpdateWidgetDefaultResponse; +export function isUnexpected( + response: DeleteWidget202Response | DeleteWidgetDefaultResponse +): response is DeleteWidgetDefaultResponse; +export function isUnexpected( + response: + | GetWidgetOperationStatus200Response + | GetWidgetOperationStatusDefaultResponse +): response is GetWidgetOperationStatusDefaultResponse; +export function isUnexpected( + response: ListWidgets200Response | ListWidgetsDefaultResponse +): response is ListWidgetsDefaultResponse; +export function isUnexpected( + response: + | GetWidget200Response + | GetWidgetDefaultResponse + | CreateOrUpdateWidget200Response + | CreateOrUpdateWidget201Response + | CreateOrUpdateWidgetDefaultResponse + | DeleteWidget202Response + | DeleteWidgetDefaultResponse + | GetWidgetOperationStatus200Response + | GetWidgetOperationStatusDefaultResponse + | ListWidgets200Response + | ListWidgetsDefaultResponse +): response is + | GetWidgetDefaultResponse + | CreateOrUpdateWidgetDefaultResponse + | DeleteWidgetDefaultResponse + | GetWidgetOperationStatusDefaultResponse + | ListWidgetsDefaultResponse { + const lroOriginal = response.headers["x-ms-original-url"]; + const url = new URL(lroOriginal ?? response.request.url); + const method = response.request.method; + let pathDetails = responseMap[`${method} ${url.pathname}`]; + if (!pathDetails) { + pathDetails = getParametrizedPathSuccess(method, url.pathname); + } + return !pathDetails.includes(response.status); +} + +function getParametrizedPathSuccess(method: string, path: string): string[] { + const pathParts = path.split("/"); + + // Traverse list to match the longest candidate + // matchedLen: the length of candidate path + // matchedValue: the matched status code array + let matchedLen = -1, + matchedValue: string[] = []; + + // Iterate the responseMap to find a match + for (const [key, value] of Object.entries(responseMap)) { + // Extracting the path from the map key which is in format + // GET /path/foo + if (!key.startsWith(method)) { + continue; + } + const candidatePath = getPathFromMapKey(key); + // Get each part of the url path + const candidateParts = candidatePath.split("/"); + + // track if we have found a match to return the values found. + let found = true; + for ( + let i = candidateParts.length - 1, j = pathParts.length - 1; + i >= 1 && j >= 1; + i--, j-- + ) { + if ( + candidateParts[i]?.startsWith("{") && + candidateParts[i]?.indexOf("}") !== -1 + ) { + const start = candidateParts[i]!.indexOf("}") + 1, + end = candidateParts[i]?.length; + // If the current part of the candidate is a "template" part + // Try to use the suffix of pattern to match the path + // {guid} ==> $ + // {guid}:export ==> :export$ + const isMatched = new RegExp( + `${candidateParts[i]?.slice(start, end)}` + ).test(pathParts[j] || ""); + + if (!isMatched) { + found = false; + break; + } + continue; + } + + // If the candidate part is not a template and + // the parts don't match mark the candidate as not found + // to move on with the next candidate path. + if (candidateParts[i] !== pathParts[j]) { + found = false; + break; + } + } + + // We finished evaluating the current candidate parts + // Update the matched value if and only if we found the longer pattern + if (found && candidatePath.length > matchedLen) { + matchedLen = candidatePath.length; + matchedValue = value; + } + } + + return matchedValue; +} + +function getPathFromMapKey(mapKey: string): string { + const pathStart = mapKey.indexOf("/"); + return mapKey.slice(pathStart); +} diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/models.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/models.ts new file mode 100644 index 000000000000..26d3a69873f7 --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/models.ts @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** A widget. */ +export interface Widget { + /** The ID of the widget's manufacturer. */ + manufacturerId: string; + /** The faked shared model. */ + sharedModel?: FakedSharedModel; +} + +/** Faked shared model */ +export interface FakedSharedModel { + /** The tag. */ + tag: string; + /** The created date. */ + createdDate: Date | string; +} diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/outputModels.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/outputModels.ts new file mode 100644 index 000000000000..94c51d705718 --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/outputModels.ts @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** A widget. */ +export interface WidgetOutput { + /** The widget name. */ + readonly name: string; + /** The ID of the widget's manufacturer. */ + manufacturerId: string; + /** The faked shared model. */ + sharedModel?: FakedSharedModelOutput; +} + +/** Faked shared model */ +export interface FakedSharedModelOutput { + /** The tag. */ + tag: string; + /** The created date. */ + createdDate: string; +} + +/** A response containing error details. */ +export interface ErrorResponseOutput { + /** The error object. */ + error: ErrorModelOutput; +} + +/** The error object. */ +export interface ErrorModelOutput { + /** One of a server-defined set of error codes. */ + code: string; + /** A human-readable representation of the error. */ + message: string; + /** The target of the error. */ + target?: string; + /** An array of details about specific errors that led to this reported error. */ + details: Array; + /** An object containing more specific information than the current object about the error. */ + innererror?: InnerErrorOutput; +} + +/** An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. */ +export interface InnerErrorOutput { + /** One of a server-defined set of error codes. */ + code: string; + /** Inner error. */ + innererror?: InnerErrorOutput; +} + +/** Provides status details for long running operations. */ +export interface OperationStatusOutput { + /** The unique ID of the operation. */ + id: string; + /** + * The status of the operation + * + * Possible values: InProgress, Succeeded, Failed, Canceled + */ + status: string; + /** Error object that describes the error when status is "Failed". */ + error?: ErrorModelOutput; +} + +/** Paged collection of Widget items */ +export interface WidgetListOutput { + /** The Widget items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/paginateHelper.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/paginateHelper.ts new file mode 100644 index 000000000000..1c9af35b1efd --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/paginateHelper.ts @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { + getPagedAsyncIterator, + PagedAsyncIterableIterator, + PagedResult, +} from "@azure/core-paging"; +import { + Client, + createRestError, + PathUncheckedResponse, +} from "@azure-rest/core-client"; + +/** + * Helper type to extract the type of an array + */ +export type GetArrayType = T extends Array ? TData : never; + +/** + * The type of a custom function that defines how to get a page and a link to the next one if any. + */ +export type GetPage = ( + pageLink: string, + maxPageSize?: number +) => Promise<{ + page: TPage; + nextPageLink?: string; +}>; + +/** + * Options for the paging helper + */ +export interface PagingOptions { + /** + * Custom function to extract pagination details for crating the PagedAsyncIterableIterator + */ + customGetPage?: GetPage[]>; +} + +/** + * Helper type to infer the Type of the paged elements from the response type + * This type is generated based on the swagger information for x-ms-pageable + * specifically on the itemName property which indicates the property of the response + * where the page items are found. The default value is `value`. + * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter + */ +export type PaginateReturn = TResult extends { + body: { value?: infer TPage }; +} + ? GetArrayType + : Array; + +/** + * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension + * @param client - Client to use for sending the next page requests + * @param initialResponse - Initial response containing the nextLink and current page of elements + * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results + * @returns - PagedAsyncIterableIterator to iterate the elements + */ +export function paginate( + client: Client, + initialResponse: TResponse, + options: PagingOptions = {} +): PagedAsyncIterableIterator> { + // Extract element type from initial response + type TElement = PaginateReturn; + let firstRun = true; + const itemName = "value"; + const nextLinkName = "nextLink"; + const { customGetPage } = options; + const pagedResult: PagedResult = { + firstPageLink: "", + getPage: + typeof customGetPage === "function" + ? customGetPage + : async (pageLink: string) => { + const result = firstRun + ? initialResponse + : await client.pathUnchecked(pageLink).get(); + firstRun = false; + checkPagingRequest(result); + const nextLink = getNextLink(result.body, nextLinkName); + const values = getElements(result.body, itemName); + return { + page: values, + nextPageLink: nextLink, + }; + }, + }; + + return getPagedAsyncIterator(pagedResult); +} + +/** + * Gets for the value of nextLink in the body + */ +function getNextLink(body: unknown, nextLinkName?: string): string | undefined { + if (!nextLinkName) { + return undefined; + } + + const nextLink = (body as Record)[nextLinkName]; + + if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { + throw new Error( + `Body Property ${nextLinkName} should be a string or undefined` + ); + } + + return nextLink; +} + +/** + * Gets the elements of the current request in the body. + */ +function getElements(body: unknown, itemName: string): T[] { + const value = (body as Record)[itemName] as T[]; + + // value has to be an array according to the x-ms-pageable extension. + // The fact that this must be an array is used above to calculate the + // type of elements in the page in PaginateReturn + if (!Array.isArray(value)) { + throw new Error( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}` + ); + } + + return value ?? []; +} + +/** + * Checks if a request failed + */ +function checkPagingRequest(response: PathUncheckedResponse): void { + const Http2xxStatusCodes = [ + "200", + "201", + "202", + "203", + "204", + "205", + "206", + "207", + "208", + "226", + ]; + if (!Http2xxStatusCodes.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response + ); + } +} diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/parameters.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/parameters.ts new file mode 100644 index 000000000000..597470a01ace --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/parameters.ts @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { RequestParameters } from "@azure-rest/core-client"; +import { Widget } from "./models"; + +export type GetWidgetParameters = RequestParameters; +export type GetWidgetOperationStatusParameters = RequestParameters; +export type WidgetResourceMergeAndPatch = Partial; + +export interface CreateOrUpdateWidgetBodyParam { + body?: WidgetResourceMergeAndPatch; +} + +export interface CreateOrUpdateWidgetMediaTypesParam { + /** This request has a JSON Merge Patch body. */ + contentType: "application/merge-patch+json"; +} + +export type CreateOrUpdateWidgetParameters = + CreateOrUpdateWidgetMediaTypesParam & + CreateOrUpdateWidgetBodyParam & + RequestParameters; +export type DeleteWidgetParameters = RequestParameters; + +export interface ListWidgetsQueryParamProperties { + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; + /** Select the specified fields to be included in the response. */ + select?: string[]; +} + +export interface ListWidgetsQueryParam { + queryParameters?: ListWidgetsQueryParamProperties; +} + +export type ListWidgetsParameters = ListWidgetsQueryParam & RequestParameters; diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/pollingHelper.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/pollingHelper.ts new file mode 100644 index 000000000000..166b02947458 --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/pollingHelper.ts @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { Client, HttpResponse } from "@azure-rest/core-client"; +import { + LongRunningOperation, + LroEngine, + LroEngineOptions, + LroResponse, + PollerLike, + PollOperationState, +} from "@azure/core-lro"; + +/** + * Helper function that builds a Poller object to help polling a long running operation. + * @param client - Client to use for sending the request to get additional pages. + * @param initialResponse - The initial response. + * @param options - Options to set a resume state or custom polling interval. + * @returns - A poller object to poll for operation state updates and eventually get the final response. + */ +export function getLongRunningPoller( + client: Client, + initialResponse: TResult, + options: LroEngineOptions> = {} +): PollerLike, TResult> { + const poller: LongRunningOperation = { + requestMethod: initialResponse.request.method, + requestPath: initialResponse.request.url, + sendInitialRequest: async () => { + // In the case of Rest Clients we are building the LRO poller object from a response that's the reason + // we are not triggering the initial request here, just extracting the information from the + // response we were provided. + return getLroResponse(initialResponse); + }, + sendPollRequest: async (path) => { + // This is the callback that is going to be called to poll the service + // to get the latest status. We use the client provided and the polling path + // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location + // depending on the lro pattern that the service implements. If non is provided we default to the initial path. + const response = await client + .pathUnchecked(path ?? initialResponse.request.url) + .get(); + const lroResponse = getLroResponse(response as TResult); + lroResponse.rawResponse.headers["x-ms-original-url"] = + initialResponse.request.url; + return lroResponse; + }, + }; + + return new LroEngine(poller, options); +} + +/** + * Converts a Rest Client response to a response that the LRO engine knows about + * @param response - a rest client http response + * @returns - An LRO response that the LRO engine can work with + */ +function getLroResponse( + response: TResult +): LroResponse { + if (Number.isNaN(response.status)) { + throw new TypeError( + `Status code of the response is not a number. Value: ${response.status}` + ); + } + + return { + flatResponse: response, + rawResponse: { + ...response, + statusCode: Number.parseInt(response.status), + body: response.body, + }, + }; +} diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/responses.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/responses.ts new file mode 100644 index 000000000000..224e72acb44b --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/src/responses.ts @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { RawHttpHeaders } from "@azure/core-rest-pipeline"; +import { HttpResponse } from "@azure-rest/core-client"; +import { + WidgetOutput, + ErrorResponseOutput, + ResourceOperationStatusOutput, + OperationStatusOutput, + WidgetListOutput, +} from "./outputModels"; + +/** The request has succeeded. */ +export interface GetWidget200Response extends HttpResponse { + status: "200"; + body: WidgetOutput; +} + +export interface GetWidgetDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponseOutput; +} + +/** The request has succeeded. */ +export interface GetWidgetOperationStatus200Response extends HttpResponse { + status: "200"; + body: ResourceOperationStatusOutput; +} + +export interface GetWidgetOperationStatusDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponseOutput; +} + +export interface CreateOrUpdateWidget200Headers { + /** The location for monitoring the operation state. */ + "operation-location": string; +} + +/** The request has succeeded. */ +export interface CreateOrUpdateWidget200Response extends HttpResponse { + status: "200"; + body: WidgetOutput; + headers: RawHttpHeaders & CreateOrUpdateWidget200Headers; +} + +export interface CreateOrUpdateWidget201Headers { + /** The location for monitoring the operation state. */ + "operation-location": string; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface CreateOrUpdateWidget201Response extends HttpResponse { + status: "201"; + body: WidgetOutput; + headers: RawHttpHeaders & CreateOrUpdateWidget201Headers; +} + +export interface CreateOrUpdateWidgetDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponseOutput; +} + +export interface DeleteWidget202Headers { + /** The location for monitoring the operation state. */ + "operation-location": string; +} + +/** The request has been accepted for processing, but processing has not yet completed. */ +export interface DeleteWidget202Response extends HttpResponse { + status: "202"; + body: OperationStatusOutput; + headers: RawHttpHeaders & DeleteWidget202Headers; +} + +export interface DeleteWidgetDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponseOutput; +} + +/** The request has succeeded. */ +export interface ListWidgets200Response extends HttpResponse { + status: "200"; + body: WidgetListOutput; +} + +export interface ListWidgetsDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponseOutput; +} diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/test/public/sampleTest.spec.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/test/public/sampleTest.spec.ts new file mode 100644 index 000000000000..bce68e428645 --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/test/public/sampleTest.spec.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { Recorder } from "@azure-tools/test-recorder"; +import { assert } from "chai"; +import { createRecorder } from "./utils/recordedClient"; +import { Context } from "mocha"; + +describe("My test", () => { + let recorder: Recorder; + + beforeEach(async function (this: Context) { + recorder = await createRecorder(this); + }); + + afterEach(async function () { + await recorder.stop(); + }); + + it("sample test", async function () { + assert.equal(1, 1); + }); +}); diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/test/public/utils/env.browser.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/test/public/utils/env.browser.ts new file mode 100644 index 000000000000..fd2aca680c7b --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/test/public/utils/env.browser.ts @@ -0,0 +1,2 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/test/public/utils/env.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/test/public/utils/env.ts new file mode 100644 index 000000000000..0e06855b73ae --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/test/public/utils/env.ts @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import * as dotenv from "dotenv"; + +dotenv.config(); diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/test/public/utils/recordedClient.ts b/sdk/contosowidgetmanager/contosowidgetmanager-rest/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..6cc58bc15e11 --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/test/public/utils/recordedClient.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { Context } from "mocha"; +import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder"; +import "./env"; + +const envSetupForPlayback: Record = { + ENDPOINT: "https://endpoint", + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id", +}; + +const recorderEnvSetup: RecorderStartOptions = { + envSetupForPlayback, +}; + +/** + * creates the recorder and reads the environment variables from the `.env` file. + * Should be called first in the test suite to make sure environment variables are + * read before they are being used. + */ +export async function createRecorder(context: Context): Promise { + const recorder = new Recorder(context.currentTest); + await recorder.start(recorderEnvSetup); + return recorder; +} diff --git a/sdk/contosowidgetmanager/contosowidgetmanager-rest/tsconfig.json b/sdk/contosowidgetmanager/contosowidgetmanager-rest/tsconfig.json new file mode 100644 index 000000000000..d5bf593423c9 --- /dev/null +++ b/sdk/contosowidgetmanager/contosowidgetmanager-rest/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../../tsconfig.package", + "compilerOptions": { + "outDir": "./dist-esm", + "declarationDir": "./types" + }, + "include": [ + "src/**/*.ts", + "./test/**/*.ts" + ] +} \ No newline at end of file diff --git a/sdk/purview/purview-administration-rest/swagger/README.md b/sdk/purview/purview-administration-rest/swagger/README.md index 10099375fe9a..4f6f98a9c6a9 100644 --- a/sdk/purview/purview-administration-rest/swagger/README.md +++ b/sdk/purview/purview-administration-rest/swagger/README.md @@ -1,35 +1,32 @@ -# Azure Purview Catalog TypeScript Protocol Layer +# JavaScript > see https://aka.ms/autorest ## Configuration -```yaml $(purview-account) == true -title: PurviewAccount -description: Purview Account Client -output-folder: ../src/account -source-code-folder-path: ./ -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/purview/data-plane/Azure.Analytics.Purview.Account/preview/2019-11-01-preview/account.json -``` - -```yaml $(purview-metadata) == true -title: PurviewMetadataPolicies -description: Purview Metadata Policies Client -output-folder: ../src/metadataPolicies -source-code-folder-path: ./ -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/purview/data-plane/Azure.Analytics.Purview.MetadataPolicies/preview/2021-07-01-preview/purviewMetadataPolicy.json -``` - - -```yaml -modelerfour.lenient-model-deduplication: true -package-name: "@azure-rest/purview-administration" -generate-metadata: false +```yaml $(multi-client) +package-name: '@azure-rest/purview-administration' +generate-metadata: true license-header: MICROSOFT_MIT_NO_VERSION -package-version: 1.0.0-beta.2 rest-level-client: true add-credentials: true -credential-scopes: "https://purview.azure.net/.default" +credential-scopes: https://purview.azure.net/.default +require: + - https://github.com/Azure/azure-rest-api-specs/blob/9e30496a8803beb5a84909997e5cd7ea0f242fd8/specification/purview/data-plane/administration/readme.md use-extension: - "@autorest/typescript": "latest" + '@autorest/typescript': 6.0.0-beta.20 +tag: false +batch: + - purview-account: true + - purview-metadata: true +``` +```yaml $(purview-account) +output-folder: ../ +source-code-folder-path: ./src/account +title: PurviewAccount +``` +```yaml $(purview-metadata) +output-folder: ../ +source-code-folder-path: ./src/metadataPolicies +title: PurviewMetadataPolicies ```