Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the isUnexpected narrowing issue in modular #2654

Merged
merged 43 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e88479e
generate deviceregistry with modular
kazrael2119 May 8, 2024
a223807
Re-generate device registery mgmt
MaryGao May 8, 2024
14bc8df
Merge branch 'main' into pr/2501
v-jiaodi Jul 4, 2024
a29f8a6
update tsp
v-jiaodi Jul 4, 2024
1e670ad
Merge branch 'main' into pr/2501
v-jiaodi Jul 8, 2024
a2572c3
regen code and build
v-jiaodi Jul 8, 2024
c130a0a
Merge remote-tracking branch 'origin/main' into pr/kazrael2119/2501
MaryGao Jul 9, 2024
ec106af
Regen the deviceRegistryClient
MaryGao Jul 9, 2024
3b6fb57
Update the api view
MaryGao Jul 9, 2024
f9eb60e
regen code
v-jiaodi Jul 9, 2024
799d9f5
fix ci
v-jiaodi Jul 9, 2024
fc3a53a
fix ci
MaryGao Jul 9, 2024
5fa7ac3
remove test case
v-jiaodi Jul 9, 2024
c5b2211
update the subset logic for default response
MaryGao Jul 14, 2024
de894d7
Update the responses
MaryGao Jul 15, 2024
1df180e
Update the interface
MaryGao Jul 15, 2024
e23ab54
Update the narrowing with necessary conditions
MaryGao Jul 15, 2024
518c744
update
v-jiaodi Jul 15, 2024
fe31d32
Merge branch isUnexpected into pr/2654
v-jiaodi Jul 15, 2024
e938615
update
v-jiaodi Jul 15, 2024
2aa9c4b
Update the change for this
MaryGao Jul 15, 2024
67c1267
Merge branch 'isUnexpected' of https://github.com/marygao/autorest.ty…
MaryGao Jul 15, 2024
fcef27b
Update packages/typespec-ts/src/modular/helpers/operationHelpers.ts
MaryGao Jul 15, 2024
d908f11
Update the changes
MaryGao Jul 15, 2024
8a5a0e1
fix ci
v-jiaodi Jul 15, 2024
86fb686
update
v-jiaodi Jul 15, 2024
5e6990f
Merge branch 'main' into pr/2654
v-jiaodi Jul 15, 2024
4b2180b
regen smoke test
v-jiaodi Jul 15, 2024
fcfe81a
Merge branch 'main' of https://github.com/Azure/autorest.typescript i…
v-jiaodi Jul 17, 2024
928b219
remove device case
v-jiaodi Jul 17, 2024
9aff09e
Merge branch 'main' of https://github.com/Azure/autorest.typescript i…
v-jiaodi Jul 18, 2024
2ed7d00
fix ci
v-jiaodi Jul 18, 2024
4b6cc00
regen smoke test
v-jiaodi Jul 18, 2024
20785df
Regen with res not _result
MaryGao Jul 18, 2024
a3fd74d
Update the generation detail
MaryGao Jul 18, 2024
c0dd931
regen code
v-jiaodi Jul 18, 2024
47e4064
Resolve comments
MaryGao Jul 18, 2024
7cc7d11
Merge branch 'isUnexpected' of https://github.com/marygao/autorest.ty…
MaryGao Jul 18, 2024
ce6d79b
Update the operation name
MaryGao Jul 18, 2024
587ad42
revert some changes
MaryGao Jul 18, 2024
b01dfa6
Merge to main
MaryGao Jul 18, 2024
c4f7898
Merge remote-tracking branch 'origin/main' into isUnexpected
MaryGao Jul 23, 2024
18001a7
Merge branch 'main' into isUnexpected
MaryGao Jul 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/rlc-common/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ export interface OperationResponse {
operationName: string;
path: string;
responses: ResponseMetadata[];
// Check if the default response is one of superset of non-default responses
isDefaultSupersetOfOthers?: boolean;
}
export interface ResponseMetadata {
statusCode: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
MaryGao marked this conversation as resolved.
Show resolved Hide resolved
"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",
"@azure/azure-sdk/ts-package-json-module": "off",
"@azure/azure-sdk/ts-package-json-files-required": "off",
"@azure/azure-sdk/ts-package-json-main-is-cjs": "off"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
],
"exclude": [],
"compilerOptions": {
"outDir": "../.tshy-build/browser"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../src",
"target": "es2022",
"module": "nodenext",
"moduleResolution": "nodenext"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.cts",
"../src/**/*.tsx"
],
"exclude": [
"../src/**/*.mts"
],
"compilerOptions": {
"outDir": "../.tshy-build/commonjs"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
],
"exclude": [],
"compilerOptions": {
"outDir": "../.tshy-build/esm"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./build.json",
"include": [
"../src/**/*.ts",
"../src/**/*.mts",
"../src/**/*.tsx"
],
"exclude": [],
"compilerOptions": {
"outDir": "../.tshy-build/react-native"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2024 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Azure DeviceRegistry REST client library for JavaScript

Microsoft.DeviceRegistry Resource Provider management API.

**If you are not familiar with our REST client, please spend 5 minutes to take a look at our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library, the REST client provides a light-weighted & developer friendly way to call azure rest api

Key links:

- [Package (NPM)](https://www.npmjs.com/package/@azure/arm-deviceregistry)
- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-deviceregistry?view=azure-node-preview)

## 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/arm-deviceregistry` package

Install the Azure DeviceRegistry REST client REST client library for JavaScript with `npm`:

```bash
npm install @azure/arm-deviceregistry
```

### Create and authenticate a `DeviceRegistryClient`

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).
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "./dist/esm/index.d.ts",
"docModel": { "enabled": true },
"apiReport": { "enabled": true, "reportFolder": "./review" },
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/arm-deviceregistry.d.ts"
},
"messages": {
"tsdocMessageReporting": { "default": { "logLevel": "none" } },
"extractorMessageReporting": {
"ae-missing-release-tag": { "logLevel": "none" },
"ae-unresolved-link": { "logLevel": "none" }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// 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-firefox-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 <properties> 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",
},
},
});
};
Loading
Loading