[monitor] Update @azure/monitor-query to ESM/vitest (#31598)

### Packages impacted by this PR

- @azure/monitor-query

### Issues associated with this PR

- #31338

### Describe the problem that is addressed by this PR

Upgrade to ESM/vitest for @azure/monitor-query

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_


### Provide a list of related PRs _(if any)_


### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
This commit is contained in:
Matthew Podwysocki 2024-10-31 21:52:28 -04:00 коммит произвёл GitHub
Родитель c70a0ca281
Коммит 55c573f3ae
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
73 изменённых файлов: 685 добавлений и 711 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,19 +0,0 @@
{
"include": [
"dist-esm/src/**/*.js"
],
"exclude": [
"**/*.d.ts",
"dist-esm/src/generated/*"
],
"reporter": [
"text-summary",
"html",
"cobertura"
],
"exclude-after-remap": false,
"sourceMap": true,
"produce-source-map": true,
"instrument": true,
"all": true
}

Просмотреть файл

@ -1,6 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "types/src/index.d.ts",
"mainEntryPointFilePath": "dist/esm/index.d.ts",
"docModel": {
"enabled": true
},
@ -11,7 +11,7 @@
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/latest/monitor-query.d.ts"
"publicTrimmedFilePath": "dist/monitor-query.d.ts"
},
"messages": {
"tsdocMessageReporting": {

Просмотреть файл

@ -1,125 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// 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: ["mocha"],
plugins: [
"karma-mocha",
"karma-mocha-reporter",
"karma-chrome-launcher",
"karma-firefox-launcher",
"karma-env-preprocessor",
"karma-coverage",
"karma-junit-reporter",
],
// 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": ["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.browser.js": ["coverage"]
},
envPreprocessor: [
"TEST_MODE",
"MONITOR_WORKSPACE_ID",
"METRICS_RESOURCE_ID",
"LOGS_RESOURCE_ID",
"MONITOR_SECONDARY_WORKSPACE_ID",
"MQ_APPLICATIONINSIGHTS_CONNECTION_STRING",
"AZURE_CLIENT_ID",
"AZURE_CLIENT_SECRET",
"AZURE_TENANT_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: "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: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: 1,
browserNoActivityTimeout: 600000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
client: {
mocha: {
// change Karma's debug.html to the mocha web reporter
reporter: "html",
timeout: "600000",
},
},
});
};

Просмотреть файл

@ -3,9 +3,9 @@
"version": "1.3.1",
"description": "An isomorphic client library for querying Azure Monitor's Logs and Metrics data sources.",
"sdk-type": "client",
"main": "dist/index.js",
"module": "dist-esm/src/index.js",
"browser": {},
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
"browser": "./dist/browser/index.js",
"//metadata": {
"constantPaths": [
{
@ -30,18 +30,18 @@
}
]
},
"types": "types/latest/monitor-query.d.ts",
"types": "./dist/commonjs/index.d.ts",
"scripts": {
"build": "npm run clean && tsc -p . && npm run build:nodebrowser && dev-tool run extract-api",
"build:browser": "tsc -p . && dev-tool run bundle",
"build:node": "tsc -p . && dev-tool run bundle",
"build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
"build:browser": "dev-tool run build-package && dev-tool run bundle",
"build:node": "dev-tool run build-package && dev-tool run bundle",
"build:nodebrowser": "dev-tool run bundle",
"build:samples": "dev-tool samples publish --force",
"build:test": "tsc -p . && dev-tool run bundle",
"build:test": "dev-tool run build-package && dev-tool run bundle",
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"clean": "dev-tool run vendored rimraf --glob dist dist-* temp types *.tgz *.log coverage coverage-browser",
"execute:samples": "echo Obsolete",
"extract-api": "tsc -p . && dev-tool run extract-api",
"extract-api": "dev-tool run build-package && dev-tool run extract-api",
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"generate:client": "npm run generate:client:logquery && npm run generate:client:metrics && npm run generate:client:metrics-namespaces && npm run generate:client:metrics-definitions",
"generate:client:logquery": "autorest --typescript swagger/logquery.md",
@ -49,8 +49,8 @@
"generate:client:metrics-definitions": "autorest --typescript swagger/metric-definitions.md",
"generate:client:metrics-namespaces": "autorest --typescript swagger/metric-namespaces.md",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"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' 'dist-esm/test/**/**/*.spec.js'",
"integration-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser -- -c vitest.browser.int.config.ts",
"integration-test:node": "dev-tool run test:vitest -- -c vitest.int.config.ts",
"lint": "eslint package.json api-extractor.json src test",
"lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]",
"pack": "npm pack 2>&1",
@ -58,14 +58,12 @@
"test:browser": "npm run build:test && npm run integration-test:browser",
"test:node": "npm run build:test && npm run integration-test:node",
"unit-test": "npm run build:test && npm run unit-test:node && npm run unit-test:browser",
"unit-test:browser": "dev-tool run test:browser",
"unit-test:node": "dev-tool run test:node-tsx-ts -- --timeout 1200000 'test/**/*.spec.ts' 'test/**/**/*.spec.ts'",
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser -- -c vitest.browser.unit.config.ts",
"unit-test:node": "dev-tool run test:vitest -- -c vitest.unit.config.ts",
"update-snippets": "echo skipped"
},
"files": [
"dist/",
"dist-esm/src/",
"types/latest/monitor-query.d.ts",
"README.md",
"LICENSE"
],
@ -87,19 +85,19 @@
"sideEffects": false,
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
"dependencies": {
"@azure/core-auth": "^1.3.0",
"@azure/core-auth": "^1.9.0",
"@azure/core-client": "^1.9.2",
"@azure/core-paging": "^1.1.1",
"@azure/core-rest-pipeline": "^1.1.0",
"@azure/core-tracing": "^1.0.0",
"@azure/core-util": "^1.3.2",
"@azure/logger": "^1.0.0",
"tslib": "^2.6.2"
"@azure/core-paging": "^1.6.2",
"@azure/core-rest-pipeline": "^1.17.0",
"@azure/core-tracing": "^1.2.0",
"@azure/core-util": "^1.11.0",
"@azure/logger": "^1.1.4",
"tslib": "^2.7.0"
},
"devDependencies": {
"@azure-tools/test-credential": "^1.0.0",
"@azure-tools/test-recorder": "^3.0.0",
"@azure-tools/test-utils": "^1.0.1",
"@azure-tools/test-credential": "^2.0.0",
"@azure-tools/test-recorder": "^4.1.0",
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/abort-controller": "^2.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
@ -108,29 +106,15 @@
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/sdk-trace-base": "^1.27.0",
"@opentelemetry/sdk-trace-node": "^1.27.0",
"@types/chai": "^4.1.6",
"@types/chai-as-promised": "^7.1.0",
"@types/mocha": "^10.0.0",
"@types/node": "^18.0.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"cross-env": "^7.0.2",
"@vitest/browser": "^2.1.4",
"@vitest/coverage-istanbul": "^2.1.4",
"cross-env": "^7.0.3",
"dotenv": "^16.0.0",
"eslint": "^9.9.0",
"inherits": "^2.0.3",
"karma": "^6.2.0",
"karma-chrome-launcher": "^3.0.0",
"karma-coverage": "^2.0.0",
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^1.1.0",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"mocha": "^10.0.0",
"nyc": "^17.0.0",
"source-map-support": "^0.5.9",
"tsx": "^4.7.1",
"typescript": "~5.6.2"
"playwright": "^1.48.2",
"typescript": "~5.6.2",
"vitest": "^2.1.4"
},
"//sampleConfiguration": {
"skipFolder": false,
@ -141,5 +125,42 @@
"requiredResources": {
"Azure Monitor": "https://docs.microsoft.com/azure/azure-monitor/"
}
},
"type": "module",
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
},
"dialects": [
"esm",
"commonjs"
],
"esmDialects": [
"browser",
"react-native"
],
"selfLink": false
},
"exports": {
"./package.json": "./package.json",
".": {
"browser": {
"types": "./dist/browser/index.d.ts",
"default": "./dist/browser/index.js"
},
"react-native": {
"types": "./dist/react-native/index.d.ts",
"default": "./dist/react-native/index.js"
},
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
}
}

Просмотреть файл

@ -10,7 +10,7 @@ export const SDK_VERSION: string = "1.3.1";
* Known values for Monitor Audience
*
* **NOTE**: This is applicable only to `MetricsClient` in the `@azure/monitor-query` data plane package.
* The name `KnownMonitorAudience` is added for backward compatibilty.
* The name `KnownMonitorAudience` is added for backward compatibility.
*/
export enum KnownMonitorAudience {
/**

Просмотреть файл

@ -6,10 +6,10 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { QueryImpl, MetadataImpl } from "./operations";
import { Query, Metadata } from "./operationsInterfaces";
import { AzureLogAnalyticsContext } from "./azureLogAnalyticsContext";
import { AzureLogAnalyticsOptionalParams } from "./models";
import { QueryImpl, MetadataImpl } from "./operations/index.js";
import { Query, Metadata } from "./operationsInterfaces/index.js";
import { AzureLogAnalyticsContext } from "./azureLogAnalyticsContext.js";
import { AzureLogAnalyticsOptionalParams } from "./models/index.js";
/** @internal */
export class AzureLogAnalytics extends AzureLogAnalyticsContext {

Просмотреть файл

@ -7,7 +7,7 @@
*/
import * as coreClient from "@azure/core-client";
import { AzureLogAnalyticsOptionalParams } from "./models";
import { AzureLogAnalyticsOptionalParams } from "./models/index.js";
/** @internal */
export class AzureLogAnalyticsContext extends coreClient.ServiceClient {

Просмотреть файл

@ -6,7 +6,7 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./models";
export { AzureLogAnalytics } from "./azureLogAnalytics";
export { AzureLogAnalyticsContext } from "./azureLogAnalyticsContext";
export * from "./operationsInterfaces";
export * from "./models/index.js";
export { AzureLogAnalytics } from "./azureLogAnalytics.js";
export { AzureLogAnalyticsContext } from "./azureLogAnalyticsContext.js";
export * from "./operationsInterfaces/index.js";

Просмотреть файл

@ -14,7 +14,7 @@ import {
import {
QueryBody as QueryBodyMapper,
BatchRequest as BatchRequestMapper
} from "../models/mappers";
} from "../models/mappers.js";
export const accept: OperationParameter = {
parameterPath: "accept",

Просмотреть файл

@ -6,5 +6,5 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./query";
export * from "./metadata";
export * from "./query.js";
export * from "./metadata.js";

Просмотреть файл

@ -6,17 +6,17 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { Metadata } from "../operationsInterfaces";
import { Metadata } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { AzureLogAnalyticsContext } from "../azureLogAnalyticsContext";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { AzureLogAnalyticsContext } from "../azureLogAnalyticsContext.js";
import {
MetadataGetOptionalParams,
MetadataGetResponse,
MetadataPostOptionalParams,
MetadataPostResponse
} from "../models";
} from "../models/index.js";
/** Class containing Metadata operations. */
export class MetadataImpl implements Metadata {

Просмотреть файл

@ -6,11 +6,11 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { Query } from "../operationsInterfaces";
import { Query } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { AzureLogAnalyticsContext } from "../azureLogAnalyticsContext";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { AzureLogAnalyticsContext } from "../azureLogAnalyticsContext.js";
import {
QueryGetOptionalParams,
QueryGetResponse,
@ -28,7 +28,7 @@ import {
QueryResourceGetXmsResponse,
QueryResourceExecuteXmsOptionalParams,
QueryResourceExecuteXmsResponse
} from "../models";
} from "../models/index.js";
/** Class containing Query operations. */
export class QueryImpl implements Query {

Просмотреть файл

@ -6,5 +6,5 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./query";
export * from "./metadata";
export * from "./query.js";
export * from "./metadata.js";

Просмотреть файл

@ -11,7 +11,7 @@ import {
MetadataGetResponse,
MetadataPostOptionalParams,
MetadataPostResponse
} from "../models";
} from "../models/index.js";
/** Interface representing a Metadata. */
export interface Metadata {

Просмотреть файл

@ -23,7 +23,7 @@ import {
QueryResourceGetXmsResponse,
QueryResourceExecuteXmsOptionalParams,
QueryResourceExecuteXmsResponse
} from "../models";
} from "../models/index.js";
/** Interface representing a Query. */
export interface Query {

Просмотреть файл

@ -6,13 +6,13 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { MetricsBatchImpl } from "./operations";
import { MetricsBatch } from "./operationsInterfaces";
import { AzureMonitorMetricBatchContext } from "./azureMonitorMetricBatchContext";
import { MetricsBatchImpl } from "./operations/index.js";
import { MetricsBatch } from "./operationsInterfaces/index.js";
import { AzureMonitorMetricBatchContext } from "./azureMonitorMetricBatchContext.js";
import {
AzureMonitorMetricBatchOptionalParams,
ApiVersion20240201
} from "./models";
} from "./models/index.js";
/** @internal */
export class AzureMonitorMetricBatch extends AzureMonitorMetricBatchContext {

Просмотреть файл

@ -10,7 +10,7 @@ import * as coreClient from "@azure/core-client";
import {
ApiVersion20240201,
AzureMonitorMetricBatchOptionalParams
} from "./models";
} from "./models/index.js";
/** @internal */
export class AzureMonitorMetricBatchContext extends coreClient.ServiceClient {

Просмотреть файл

@ -6,7 +6,7 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./models";
export { AzureMonitorMetricBatch } from "./azureMonitorMetricBatch";
export { AzureMonitorMetricBatchContext } from "./azureMonitorMetricBatchContext";
export * from "./operationsInterfaces";
export * from "./models/index.js";
export { AzureMonitorMetricBatch } from "./azureMonitorMetricBatch.js";
export { AzureMonitorMetricBatchContext } from "./azureMonitorMetricBatchContext.js";
export * from "./operationsInterfaces/index.js";

Просмотреть файл

@ -11,7 +11,7 @@ import {
OperationURLParameter,
OperationQueryParameter
} from "@azure/core-client";
import { ResourceIdList as ResourceIdListMapper } from "../models/mappers";
import { ResourceIdList as ResourceIdListMapper } from "../models/mappers.js";
export const contentType: OperationParameter = {
parameterPath: ["options", "contentType"],

Просмотреть файл

@ -6,4 +6,4 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./metricsBatch";
export * from "./metricsBatch.js";

Просмотреть файл

@ -6,16 +6,16 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { MetricsBatch } from "../operationsInterfaces";
import { MetricsBatch } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { AzureMonitorMetricBatchContext } from "../azureMonitorMetricBatchContext";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { AzureMonitorMetricBatchContext } from "../azureMonitorMetricBatchContext.js";
import {
ResourceIdList,
MetricsBatchBatchOptionalParams,
MetricsBatchBatchResponse
} from "../models";
} from "../models/index.js";
/** Class containing MetricsBatch operations. */
export class MetricsBatchImpl implements MetricsBatch {

Просмотреть файл

@ -6,4 +6,4 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./metricsBatch";
export * from "./metricsBatch.js";

Просмотреть файл

@ -10,7 +10,7 @@ import {
ResourceIdList,
MetricsBatchBatchOptionalParams,
MetricsBatchBatchResponse
} from "../models";
} from "../models/index.js";
/** Interface representing a MetricsBatch. */
export interface MetricsBatch {

Просмотреть файл

@ -6,7 +6,7 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./models";
export { MonitorManagementClient } from "./monitorManagementClient";
export { MonitorManagementClientContext } from "./monitorManagementClientContext";
export * from "./operationsInterfaces";
export * from "./models/index.js";
export { MonitorManagementClient } from "./monitorManagementClient.js";
export { MonitorManagementClientContext } from "./monitorManagementClientContext.js";
export * from "./operationsInterfaces/index.js";

Просмотреть файл

@ -11,7 +11,7 @@ import {
OperationURLParameter,
OperationQueryParameter
} from "@azure/core-client";
import { SubscriptionScopeMetricsRequestBodyParameters as SubscriptionScopeMetricsRequestBodyParametersMapper } from "../models/mappers";
import { SubscriptionScopeMetricsRequestBodyParameters as SubscriptionScopeMetricsRequestBodyParametersMapper } from "../models/mappers.js";
export const accept: OperationParameter = {
parameterPath: "accept",

Просмотреть файл

@ -6,13 +6,13 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { MetricsImpl } from "./operations";
import { Metrics } from "./operationsInterfaces";
import { MonitorManagementClientContext } from "./monitorManagementClientContext";
import { MetricsImpl } from "./operations/index.js";
import { Metrics } from "./operationsInterfaces/index.js";
import { MonitorManagementClientContext } from "./monitorManagementClientContext.js";
import {
MonitorManagementClientOptionalParams,
ApiVersion20240201
} from "./models";
} from "./models/index.js";
/** @internal */
export class MonitorManagementClient extends MonitorManagementClientContext {

Просмотреть файл

@ -10,7 +10,7 @@ import * as coreClient from "@azure/core-client";
import {
ApiVersion20240201,
MonitorManagementClientOptionalParams
} from "./models";
} from "./models/index.js";
/** @internal */
export class MonitorManagementClientContext extends coreClient.ServiceClient {

Просмотреть файл

@ -6,4 +6,4 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./metrics";
export * from "./metrics.js";

Просмотреть файл

@ -6,11 +6,11 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { Metrics } from "../operationsInterfaces";
import { Metrics } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { MonitorManagementClientContext } from "../monitorManagementClientContext";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { MonitorManagementClientContext } from "../monitorManagementClientContext.js";
import {
MetricsListAtSubscriptionScopeOptionalParams,
MetricsListAtSubscriptionScopeResponse,
@ -18,7 +18,7 @@ import {
MetricsListAtSubscriptionScopePostResponse,
MetricsListOptionalParams,
MetricsListResponse
} from "../models";
} from "../models/index.js";
/** Class containing Metrics operations. */
export class MetricsImpl implements Metrics {

Просмотреть файл

@ -6,4 +6,4 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./metrics";
export * from "./metrics.js";

Просмотреть файл

@ -13,7 +13,7 @@ import {
MetricsListAtSubscriptionScopePostResponse,
MetricsListOptionalParams,
MetricsListResponse
} from "../models";
} from "../models/index.js";
/** Interface representing a Metrics. */
export interface Metrics {

Просмотреть файл

@ -6,7 +6,7 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./models";
export { MonitorManagementClient } from "./monitorManagementClient";
export { MonitorManagementClientContext } from "./monitorManagementClientContext";
export * from "./operationsInterfaces";
export * from "./models/index.js";
export { MonitorManagementClient } from "./monitorManagementClient.js";
export { MonitorManagementClientContext } from "./monitorManagementClientContext.js";
export * from "./operationsInterfaces/index.js";

Просмотреть файл

@ -6,13 +6,13 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { MetricDefinitionsImpl } from "./operations";
import { MetricDefinitions } from "./operationsInterfaces";
import { MonitorManagementClientContext } from "./monitorManagementClientContext";
import { MetricDefinitionsImpl } from "./operations/index.js";
import { MetricDefinitions } from "./operationsInterfaces/index.js";
import { MonitorManagementClientContext } from "./monitorManagementClientContext.js";
import {
MonitorManagementClientOptionalParams,
ApiVersion20240201
} from "./models";
} from "./models/index.js";
/** @internal */
export class MonitorManagementClient extends MonitorManagementClientContext {

Просмотреть файл

@ -10,7 +10,7 @@ import * as coreClient from "@azure/core-client";
import {
ApiVersion20240201,
MonitorManagementClientOptionalParams
} from "./models";
} from "./models/index.js";
/** @internal */
export class MonitorManagementClientContext extends coreClient.ServiceClient {

Просмотреть файл

@ -6,4 +6,4 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./metricDefinitions";
export * from "./metricDefinitions.js";

Просмотреть файл

@ -6,17 +6,17 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { MetricDefinitions } from "../operationsInterfaces";
import { MetricDefinitions } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { MonitorManagementClientContext } from "../monitorManagementClientContext";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { MonitorManagementClientContext } from "../monitorManagementClientContext.js";
import {
MetricDefinitionsListAtSubscriptionScopeOptionalParams,
MetricDefinitionsListAtSubscriptionScopeResponse,
MetricDefinitionsListOptionalParams,
MetricDefinitionsListResponse
} from "../models";
} from "../models/index.js";
/** Class containing MetricDefinitions operations. */
export class MetricDefinitionsImpl implements MetricDefinitions {

Просмотреть файл

@ -6,4 +6,4 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./metricDefinitions";
export * from "./metricDefinitions.js";

Просмотреть файл

@ -11,7 +11,7 @@ import {
MetricDefinitionsListAtSubscriptionScopeResponse,
MetricDefinitionsListOptionalParams,
MetricDefinitionsListResponse
} from "../models";
} from "../models/index.js";
/** Interface representing a MetricDefinitions. */
export interface MetricDefinitions {

Просмотреть файл

@ -6,7 +6,7 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./models";
export { MonitorManagementClient } from "./monitorManagementClient";
export { MonitorManagementClientContext } from "./monitorManagementClientContext";
export * from "./operationsInterfaces";
export * from "./models/index.js";
export { MonitorManagementClient } from "./monitorManagementClient.js";
export { MonitorManagementClientContext } from "./monitorManagementClientContext.js";
export * from "./operationsInterfaces/index.js";

Просмотреть файл

@ -6,13 +6,13 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { MetricNamespacesImpl } from "./operations";
import { MetricNamespaces } from "./operationsInterfaces";
import { MonitorManagementClientContext } from "./monitorManagementClientContext";
import { MetricNamespacesImpl } from "./operations/index.js";
import { MetricNamespaces } from "./operationsInterfaces/index.js";
import { MonitorManagementClientContext } from "./monitorManagementClientContext.js";
import {
MonitorManagementClientOptionalParams,
ApiVersion20240201
} from "./models";
} from "./models/index.js";
/** @internal */
export class MonitorManagementClient extends MonitorManagementClientContext {

Просмотреть файл

@ -10,7 +10,7 @@ import * as coreClient from "@azure/core-client";
import {
ApiVersion20240201,
MonitorManagementClientOptionalParams
} from "./models";
} from "./models/index.js";
/** @internal */
export class MonitorManagementClientContext extends coreClient.ServiceClient {

Просмотреть файл

@ -6,4 +6,4 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./metricNamespaces";
export * from "./metricNamespaces.js";

Просмотреть файл

@ -6,15 +6,15 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { MetricNamespaces } from "../operationsInterfaces";
import { MetricNamespaces } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { MonitorManagementClientContext } from "../monitorManagementClientContext";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { MonitorManagementClientContext } from "../monitorManagementClientContext.js";
import {
MetricNamespacesListOptionalParams,
MetricNamespacesListResponse
} from "../models";
} from "../models/index.js";
/** Class containing MetricNamespaces operations. */
export class MetricNamespacesImpl implements MetricNamespaces {

Просмотреть файл

@ -6,4 +6,4 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./metricNamespaces";
export * from "./metricNamespaces.js";

Просмотреть файл

@ -9,7 +9,7 @@
import {
MetricNamespacesListOptionalParams,
MetricNamespacesListResponse
} from "../models";
} from "../models/index.js";
/** Interface representing a MetricNamespaces. */
export interface MetricNamespaces {

Просмотреть файл

@ -4,7 +4,7 @@
//
// Curated exports
//
export { LogsQueryClientOptions, LogsQueryClient } from "./logsQueryClient";
export { LogsQueryClientOptions, LogsQueryClient } from "./logsQueryClient.js";
export {
QueryBatch,
LogsQueryBatchOptions,
@ -18,11 +18,11 @@ export {
LogsColumn,
LogsQueryResultStatus,
LogsErrorInfo,
} from "./models/publicLogsModels";
} from "./models/publicLogsModels.js";
export {
MetricsQueryClient,
MetricsQueryClientOptions as MetricsClientOptions,
} from "./metricsQueryClient";
} from "./metricsQueryClient.js";
export {
ListMetricDefinitionsOptions,
ListMetricNamespacesOptions,
@ -34,10 +34,10 @@ export {
TimeSeriesElement,
MetricNamespace,
MetricAvailability,
} from "./models/publicMetricsModels";
} from "./models/publicMetricsModels.js";
export { Durations } from "./models/constants";
export { QueryTimeInterval } from "./models/timeInterval";
export { Durations } from "./models/constants.js";
export { QueryTimeInterval } from "./models/timeInterval.js";
//
// LogsClient: generated exports
//
@ -46,7 +46,7 @@ export {
// TODO: these are the generated model names. We probably want to run them
// through a manual review to make them consistent with style.
LogsColumnType,
} from "./generated/logquery/src";
} from "./generated/logquery/src/index.js";
//
// MetricsClient: generated exports (from all three clients)
@ -57,15 +57,15 @@ export {
MetricValue,
ResultType,
MetricUnit,
} from "./generated/metrics/src";
} from "./generated/metrics/src/index.js";
export { AggregationType, MetricClass } from "./generated/metricsdefinitions/src";
export { NamespaceClassification } from "./generated/metricsnamespaces/src";
export { AggregationType, MetricClass } from "./generated/metricsdefinitions/src/index.js";
export { NamespaceClassification } from "./generated/metricsnamespaces/src/index.js";
export { MetricsQueryResourcesOptions } from "./models/publicBatchModels";
export { MetricsClient } from "./metricsClient";
export { MetricsQueryResourcesOptions } from "./models/publicBatchModels.js";
export { MetricsClient } from "./metricsClient.js";
export {
KnownMonitorAudience,
KnownMonitorLogsQueryAudience,
KnownMonitorMetricsQueryAudience,
} from "./constants";
} from "./constants.js";

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import type { LogsQueryClientOptions } from "../logsQueryClient";
import type { LogsQueryClientOptions } from "../logsQueryClient.js";
export function getLogQueryEndpoint(options: LogsQueryClientOptions): string {
if (!options.endpoint) {

Просмотреть файл

@ -10,22 +10,22 @@ import type {
QueryBatchResponse as GeneratedQueryBatchResponse,
Table as GeneratedTable,
QueryBody,
} from "../generated/logquery/src";
} from "../generated/logquery/src/index.js";
import type {
Metric as GeneratedMetric,
MetricsListOptionalParams as GeneratedMetricsListOptionalParams,
MetricsListResponse as GeneratedMetricsListResponse,
TimeSeriesElement as GeneratedTimeSeriesElement,
} from "../generated/metrics/src";
} from "../generated/metrics/src/index.js";
import type {
MetricDefinition as GeneratedMetricDefinition,
MetricDefinitionsListOptionalParams as GeneratedMetricDefinitionsListOptionalParams,
} from "../generated/metricsdefinitions/src";
} from "../generated/metricsdefinitions/src/index.js";
import type { MetricNamespace as GeneratedMetricNamespace } from "../generated/metricsnamespaces/src";
import { formatPreferHeader } from "./util";
import type { MetricNamespace as GeneratedMetricNamespace } from "../generated/metricsnamespaces/src/index.js";
import { formatPreferHeader } from "./util.js";
import type {
ListMetricDefinitionsOptions,
@ -34,32 +34,32 @@ import type {
MetricsQueryOptions,
MetricsQueryResult,
QueryBatch,
} from "../../src";
} from "../../src/index.js";
import type {
Metric,
MetricAvailability,
MetricDefinition,
MetricNamespace,
TimeSeriesElement,
} from "../models/publicMetricsModels";
import { createMetricsQueryResult, getMetricByName } from "../models/publicMetricsModels";
} from "../models/publicMetricsModels.js";
import { createMetricsQueryResult, getMetricByName } from "../models/publicMetricsModels.js";
import type { FullOperationResponse } from "@azure/core-client";
import {
convertIntervalToTimeIntervalObject,
convertTimespanToInterval,
} from "../timespanConversion";
} from "../timespanConversion.js";
import type {
LogsErrorInfo,
LogsQueryError,
LogsQueryPartialResult,
LogsQuerySuccessfulResult,
} from "../models/publicLogsModels";
import { LogsQueryResultStatus } from "../models/publicLogsModels";
} from "../models/publicLogsModels.js";
import { LogsQueryResultStatus } from "../models/publicLogsModels.js";
import type {
MetricsBatchBatchResponse as GeneratedMetricsBatchResponse,
MetricsBatchBatchOptionalParams as GeneratedMetricsBatchOptionalParams,
} from "../generated/metricBatch/src";
import type { MetricsQueryResourcesOptions } from "../models/publicBatchModels";
} from "../generated/metricBatch/src/index.js";
import type { MetricsQueryResourcesOptions } from "../models/publicBatchModels.js";
/**
* @internal

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import type { LogsQueryOptions } from "../models/publicLogsModels";
import type { LogsQueryOptions } from "../models/publicLogsModels.js";
/**
* @internal

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { AzureLogAnalytics } from "./generated/logquery/src/azureLogAnalytics";
import { AzureLogAnalytics } from "./generated/logquery/src/azureLogAnalytics.js";
import type { TokenCredential } from "@azure/core-auth";
import type {
@ -12,26 +12,26 @@ import type {
LogsQueryResult,
LogsQuerySuccessfulResult,
QueryBatch,
} from "./models/publicLogsModels";
import { LogsQueryResultStatus } from "./models/publicLogsModels";
} from "./models/publicLogsModels.js";
import { LogsQueryResultStatus } from "./models/publicLogsModels.js";
import {
convertGeneratedTable,
convertRequestForQueryBatch,
convertResponseForQueryBatch,
mapError,
} from "./internal/modelConverters";
import { formatPreferHeader } from "./internal/util";
} from "./internal/modelConverters.js";
import { formatPreferHeader } from "./internal/util.js";
import type {
CommonClientOptions,
FullOperationResponse,
OperationOptions,
} from "@azure/core-client";
import type { QueryTimeInterval } from "./models/timeInterval";
import { convertTimespanToInterval } from "./timespanConversion";
import { KnownMonitorLogsQueryAudience, SDK_VERSION } from "./constants";
import { tracingClient } from "./tracing";
import { getLogQueryEndpoint } from "./internal/logQueryOptionUtils";
import type { QueryTimeInterval } from "./models/timeInterval.js";
import { convertTimespanToInterval } from "./timespanConversion.js";
import { KnownMonitorLogsQueryAudience, SDK_VERSION } from "./constants.js";
import { tracingClient } from "./tracing.js";
import { getLogQueryEndpoint } from "./internal/logQueryOptionUtils.js";
/**
* Options for the LogsQueryClient.

Просмотреть файл

@ -1,19 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import type { TokenCredential } from "@azure/core-auth";
import { tracingClient } from "./tracing";
import { tracingClient } from "./tracing.js";
import {
AzureMonitorMetricBatch as GeneratedMonitorMetricClient,
KnownApiVersion20240201 as MonitorMetricBatchApiVersion,
} from "./generated/metricBatch/src";
} from "./generated/metricBatch/src/index.js";
import {
convertResponseForMetricBatch,
convertRequestForMetricsBatchQuery,
} from "./internal/modelConverters";
import { SDK_VERSION, KnownMonitorAudience } from "./constants";
import type { MetricsQueryResourcesOptions } from "./models/publicBatchModels";
import type { MetricsQueryResult } from "./models/publicMetricsModels";
import type { MetricsQueryClientOptions } from "./metricsQueryClient";
} from "./internal/modelConverters.js";
import { SDK_VERSION, KnownMonitorAudience } from "./constants.js";
import type { MetricsQueryResourcesOptions } from "./models/publicBatchModels.js";
import type { MetricsQueryResult } from "./models/publicMetricsModels.js";
import type { MetricsQueryClientOptions } from "./metricsQueryClient.js";
export const getSubscriptionFromResourceId = function (resourceId: string): string {
const startPos: number = resourceId.indexOf("subscriptions/") + 14;

Просмотреть файл

@ -3,7 +3,7 @@
import type { TokenCredential } from "@azure/core-auth";
import type { PagedAsyncIterableIterator } from "@azure/core-paging";
import type { CommonClientOptions } from "@azure/core-client";
import { tracingClient } from "./tracing";
import { tracingClient } from "./tracing.js";
import type {
ListMetricDefinitionsOptions,
@ -12,29 +12,29 @@ import type {
MetricNamespace,
MetricsQueryOptions,
MetricsQueryResult,
} from "./models/publicMetricsModels";
} from "./models/publicMetricsModels.js";
import {
MonitorManagementClient as GeneratedMetricsClient,
KnownApiVersion20240201 as MetricsApiVersion,
} from "./generated/metrics/src";
} from "./generated/metrics/src/index.js";
import {
MonitorManagementClient as GeneratedMetricsDefinitionsClient,
KnownApiVersion20240201 as MetricDefinitionsApiVersion,
} from "./generated/metricsdefinitions/src";
import type { MetricNamespacesListOptionalParams } from "./generated/metricsnamespaces/src";
} from "./generated/metricsdefinitions/src/index.js";
import type { MetricNamespacesListOptionalParams } from "./generated/metricsnamespaces/src/index.js";
import {
MonitorManagementClient as GeneratedMetricsNamespacesClient,
KnownApiVersion20240201 as MetricNamespacesApiVersion,
} from "./generated/metricsnamespaces/src";
} from "./generated/metricsnamespaces/src/index.js";
import {
convertRequestForMetrics,
convertRequestOptionsForMetricsDefinitions,
convertResponseForMetricNamespaces,
convertResponseForMetrics,
convertResponseForMetricsDefinitions,
} from "./internal/modelConverters";
import { SDK_VERSION, KnownMonitorMetricsQueryAudience } from "./constants";
} from "./internal/modelConverters.js";
import { SDK_VERSION, KnownMonitorMetricsQueryAudience } from "./constants.js";
/**
* Options for the MetricsQueryClient.

Просмотреть файл

@ -2,8 +2,8 @@
// Licensed under the MIT License.
import type { OperationOptions } from "@azure/core-client";
import type { LogsColumnType } from "../generated/logquery/src";
import type { QueryTimeInterval } from "./timeInterval";
import type { LogsColumnType } from "../generated/logquery/src/index.js";
import type { QueryTimeInterval } from "./timeInterval.js";
// https://dev.loganalytics.io/documentation/Using-the-API/RequestOptions
// https://dev.loganalytics.io/documentation/Using-the-API/Timeouts

Просмотреть файл

@ -9,8 +9,8 @@ import type {
MetricValue,
NamespaceClassification,
ResultType,
} from "..";
import type { QueryTimeInterval } from "./timeInterval";
} from "../index.js";
import type { QueryTimeInterval } from "./timeInterval.js";
/**
* Options used when querying metrics.

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import type { QueryTimeInterval } from "./models/timeInterval";
import type { QueryTimeInterval } from "./models/timeInterval.js";
import { isObjectWithProperties } from "@azure/core-util";
export function convertTimespanToInterval(timespan: QueryTimeInterval): string {

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT License.
import { createTracingClient } from "@azure/core-tracing";
import { SDK_VERSION } from "./constants";
import { SDK_VERSION } from "./constants.js";
/**
* Global tracing client used by this package.

Просмотреть файл

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { assert } from "@azure-tools/test-utils";
import { getLogQueryEndpoint } from "../../../src/internal/logQueryOptionUtils";
import { getLogQueryEndpoint } from "../../../src/internal/logQueryOptionUtils.js";
import { describe, it, assert } from "vitest";
describe("logQueryOptionsUtils", () => {
describe("getLogQueryEndpoint", () => {

Просмотреть файл

@ -1,9 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { Durations, LogsQueryClient } from "../../../src";
import { Durations, LogsQueryClient } from "../../../src/index.js";
import type { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-auth";
import { assert } from "@azure-tools/test-utils";
import { describe, it, assert, expect } from "vitest";
import type { OperationOptions } from "@azure/core-client";
import { toSupportTracing } from "@azure-tools/test-utils-vitest";
expect.extend({ toSupportTracing });
describe("LogsQueryClient unit tests", () => {
/**
@ -49,30 +53,22 @@ describe("LogsQueryClient unit tests", () => {
const client = new LogsQueryClient(tokenCredential, {
endpoint: "https://customEndpoint1",
});
await assert.supportsTracing(
async (options) => {
const promises: Promise<any>[] = [
client.queryWorkspace(
"workspaceId",
"query",
{ duration: Durations.fiveMinutes },
options,
),
client.queryBatch(
[
{
workspaceId: "monitorWorkspaceId",
query: "AppEvents | project TimeGenerated, Name, AppRoleInstance | limit 1",
timespan: { duration: "P1D" },
},
],
options,
),
];
// We don't care about errors, only that we created (and closed) the appropriate spans.
await Promise.all(promises.map((p) => p.catch(() => undefined)));
},
["LogsQueryClient.queryWorkspace", "LogsQueryClient.queryBatch"],
);
await expect(async (options: OperationOptions) => {
const promises: Promise<any>[] = [
client.queryWorkspace("workspaceId", "query", { duration: Durations.fiveMinutes }, options),
client.queryBatch(
[
{
workspaceId: "monitorWorkspaceId",
query: "AppEvents | project TimeGenerated, Name, AppRoleInstance | limit 1",
timespan: { duration: "P1D" },
},
],
options,
),
];
// We don't care about errors, only that we created (and closed) the appropriate spans.
await Promise.all(promises.map((p) => p.catch(() => undefined)));
}).toSupportTracing(["LogsQueryClient.queryWorkspace", "LogsQueryClient.queryBatch"]);
});
});

Просмотреть файл

@ -2,31 +2,35 @@
// Licensed under the MIT License.
import type { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-auth";
import { assert } from "@azure-tools/test-utils";
import { Durations, MetricsQueryClient } from "../../../src";
import { Durations, MetricsQueryClient } from "../../../src/index.js";
import { describe, it, expect } from "vitest";
import type { OperationOptions } from "@azure/core-client";
import { toSupportTracing } from "@azure-tools/test-utils-vitest";
it("verify tracing", async () => {
const scopesPassed: string[] = [];
expect.extend({ toSupportTracing });
const tokenCredential: TokenCredential = {
async getToken(
scopes: string | string[],
_options?: GetTokenOptions,
): Promise<AccessToken | null> {
if (Array.isArray(scopes)) {
scopesPassed.push(...scopes);
} else {
scopesPassed.push(scopes);
}
describe("MetricsQueryClient unit tests", () => {
it("verify tracing", async () => {
const scopesPassed: string[] = [];
throw new Error("Shortcircuit auth exception");
},
};
const client = new MetricsQueryClient(tokenCredential, {
endpoint: "https://customEndpoint1",
});
await assert.supportsTracing(
async (options) => {
const tokenCredential: TokenCredential = {
async getToken(
scopes: string | string[],
_options?: GetTokenOptions,
): Promise<AccessToken | null> {
if (Array.isArray(scopes)) {
scopesPassed.push(...scopes);
} else {
scopesPassed.push(scopes);
}
throw new Error("Shortcircuit auth exception");
},
};
const client = new MetricsQueryClient(tokenCredential, {
endpoint: "https://customEndpoint1",
});
await expect(async (options: OperationOptions) => {
const promises: Promise<any>[] = [
client.queryResource("resourceId", ["metricName1", "metricName2"], {
granularity: "PT1M",
@ -38,11 +42,10 @@ it("verify tracing", async () => {
];
// We don't care about errors, only that we created (and closed) the appropriate spans.
await Promise.all(promises.map((p) => p.catch(() => undefined)));
},
[
}).toSupportTracing([
"MetricsQueryClient.queryResource",
"MetricsQueryClient.listSegmentOfMetricNamespaces",
"MetricsQueryClient.listSegmentOfMetricDefinitions",
],
);
]);
});
});

Просмотреть файл

@ -1,23 +1,22 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { assert } from "chai";
import type {
BatchQueryRequest,
BatchRequest as GeneratedBatchRequest,
} from "../../../src/generated/logquery/src";
} from "../../../src/generated/logquery/src/index.js";
import type {
MetricsListOptionalParams as GeneratedMetricsListOptionalParams,
MetricsListResponse as GeneratedMetricsListResponse,
} from "../../../src/generated/metrics/src";
import type { MetricDefinitionsListOptionalParams as GeneratedMetricDefinitionsListOptionalParams } from "../../../src/generated/metricsdefinitions/src";
} from "../../../src/generated/metrics/src/index.js";
import type { MetricDefinitionsListOptionalParams as GeneratedMetricDefinitionsListOptionalParams } from "../../../src/generated/metricsdefinitions/src/index.js";
import {
convertRequestForMetrics,
convertRequestForQueryBatch,
convertRequestOptionsForMetricsDefinitions,
convertResponseForMetrics,
convertResponseForMetricsDefinitions,
} from "../../../src/internal/modelConverters";
} from "../../../src/internal/modelConverters.js";
import type {
OperationRequestOptions,
RawResponseCallback,
@ -28,13 +27,14 @@ import type {
ListMetricDefinitionsOptions,
MetricsQueryOptions,
MetricsQueryResult,
} from "../../../src";
import { Durations } from "../../../src";
} from "../../../src/index.js";
import { Durations } from "../../../src/index.js";
import type { AbortSignalLike } from "@azure/abort-controller";
import {
convertIntervalToTimeIntervalObject,
convertTimespanToInterval,
} from "../../../src/timespanConversion";
} from "../../../src/timespanConversion.js";
import { describe, it, assert } from "vitest";
describe("Model unit tests", () => {
describe("LogsClient", () => {

Просмотреть файл

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { assert } from "chai";
import { formatPreferHeader } from "../../../src/internal/util";
import { formatPreferHeader } from "../../../src/internal/util.js";
import { describe, it, assert } from "vitest";
describe("Utils unit tests", () => {
type PreferHeadersArg = Parameters<typeof formatPreferHeader>[0];

Просмотреть файл

@ -1,20 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { assert } from "chai";
import type { Context } from "mocha";
import { env } from "process";
import type { RecorderAndLogsClient } from "./shared/testShared";
import { createRecorderAndLogsClient, getLogsArmResourceId } from "./shared/testShared";
import type { RecorderAndLogsClient } from "./shared/testShared.js";
import { createRecorderAndLogsClient, getLogsArmResourceId } from "./shared/testShared.js";
import { Recorder } from "@azure-tools/test-recorder";
import type { LogsQueryClient, QueryBatch } from "../../src";
import { Durations, LogsQueryResultStatus } from "../../src";
// import { runWithTelemetry } from "../setupOpenTelemetry";
import { assertQueryTable, getMonitorWorkspaceId, loggerForTest } from "./shared/testShared";
import type { ErrorInfo } from "../../src/generated/logquery/src";
import type { LogsQueryClient, QueryBatch } from "../../src/index.js";
import { Durations, LogsQueryResultStatus } from "../../src/index.js";
import { assertQueryTable, getMonitorWorkspaceId, loggerForTest } from "./shared/testShared.js";
import type { ErrorInfo } from "../../src/generated/logquery/src/index.js";
import type { RestError } from "@azure/core-rest-pipeline";
import { setLogLevel } from "@azure/logger";
import { describe, it, assert, beforeEach, afterEach, beforeAll } from "vitest";
describe("LogsQueryClient live tests", function () {
let monitorWorkspaceId: string;
@ -24,9 +20,9 @@ describe("LogsQueryClient live tests", function () {
let testRunId: string;
beforeEach(async function (this: Context) {
beforeEach(async function (ctx) {
loggerForTest.verbose(`Recorder: starting...`);
recorder = new Recorder(this.currentTest);
recorder = new Recorder(ctx);
const recordedClient: RecorderAndLogsClient = await createRecorderAndLogsClient(recorder);
logsResourceId = getLogsArmResourceId();
monitorWorkspaceId = getMonitorWorkspaceId();
@ -357,10 +353,10 @@ describe("LogsQueryClient live tests", function () {
});
describe.skip("Ingested data tests (can be slow due to loading times)", () => {
before(async function (this: Context) {
if (env.TEST_RUN_ID) {
loggerForTest.warning(`Using cached test run ID ${env.TEST_RUN_ID}`);
testRunId = env.TEST_RUN_ID;
beforeAll(async function () {
if (globalThis?.process?.env?.TEST_RUN_ID) {
loggerForTest.warning(`Using cached test run ID ${globalThis.process.env.TEST_RUN_ID}`);
testRunId = process.env.TEST_RUN_ID!;
} else {
testRunId = `ingestedDataTest-${Date.now()}`;
// send some events
@ -514,10 +510,10 @@ describe("LogsQueryClient live tests - server timeout", function () {
let logsClient: LogsQueryClient;
let recorder: Recorder;
beforeEach(async function (this: Context) {
beforeEach(async function (ctx) {
setLogLevel("verbose");
loggerForTest.verbose(`Recorder: starting...`);
recorder = new Recorder(this.currentTest);
recorder = new Recorder(ctx);
const recordedClient: RecorderAndLogsClient = await createRecorderAndLogsClient(recorder, {
maxRetries: 0,
retryDelayInMs: 0,
@ -533,7 +529,7 @@ describe("LogsQueryClient live tests - server timeout", function () {
});
// disabling http retries otherwise we'll waste retries to realize that the
// query has timed out on purpose.
it("serverTimeoutInSeconds", async function (this: Context) {
it("serverTimeoutInSeconds", async function () {
try {
const randomLimit = Math.round((Math.random() + 1) * 10000000000000);
await logsClient.queryWorkspace(

Просмотреть файл

@ -1,16 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { assert } from "chai";
import type { Context } from "mocha";
import type { MetricsClient, MetricsQueryResult } from "../../src";
import type { RecorderAndMetricsBatchQueryClient } from "./shared/testShared";
import type { MetricsClient, MetricsQueryResult } from "../../src/index.js";
import type { RecorderAndMetricsBatchQueryClient } from "./shared/testShared.js";
import {
createRecorderAndMetricsBatchQueryClient,
getMetricsBatchResourceIds,
getMetricsBatchNamespace,
getMetricsBatchNames,
} from "./shared/testShared";
} from "./shared/testShared.js";
import { describe, it, assert, beforeEach } from "vitest";
describe.skip("MetricsBatchClient live tests", function () {
let resourceIds: string[];
@ -18,7 +16,7 @@ describe.skip("MetricsBatchClient live tests", function () {
let metricNames: string[];
let metricsBatchQueryClient: MetricsClient;
beforeEach(async function (this: Context) {
beforeEach(async function () {
const recordedClient: RecorderAndMetricsBatchQueryClient =
await createRecorderAndMetricsBatchQueryClient();
resourceIds = getMetricsBatchResourceIds();
@ -27,16 +25,11 @@ describe.skip("MetricsBatchClient live tests", function () {
metricsBatchQueryClient = recordedClient.client;
});
// afterEach(async function () {
// loggerForTest.verbose("Recorder: stopping");
// await recorder.stop();
// });
it("batch query with no resource ids", async () => {
try {
await metricsBatchQueryClient.queryResources([], metricNames, metricsNamespace);
assert.fail("Code should not reach here.");
} catch (e) {
} catch {
assert.equal(1, 1);
}
});

Просмотреть файл

@ -1,27 +1,26 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { getYieldedValue } from "@azure-tools/test-utils-vitest";
import type { MetricsQueryClient } from "../../src/index.js";
import { Durations } from "../../src/index.js";
import { assert } from "chai";
import type { Context } from "mocha";
import { getYieldedValue } from "@azure-tools/test-utils";
import type { MetricsQueryClient } from "../../src";
import { Durations } from "../../src";
import type { RecorderAndMetricsClient } from "./shared/testShared";
import type { RecorderAndMetricsClient } from "./shared/testShared.js";
import {
createRecorderAndMetricsClient,
getMetricsArmResourceId,
loggerForTest,
} from "./shared/testShared";
} from "./shared/testShared.js";
import { Recorder } from "@azure-tools/test-recorder";
import { describe, it, assert, beforeEach, afterEach } from "vitest";
describe("MetricsClient live tests", function () {
let resourceId: string;
let metricsQueryClient: MetricsQueryClient;
let recorder: Recorder;
beforeEach(async function (this: Context) {
beforeEach(async function (ctx) {
loggerForTest.verbose(`Recorder: starting...`);
recorder = new Recorder(this.currentTest);
recorder = new Recorder(ctx);
const recordedClient: RecorderAndMetricsClient = await createRecorderAndMetricsClient(recorder);
resourceId = getMetricsArmResourceId();
metricsQueryClient = recordedClient.client;

Просмотреть файл

@ -1,14 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { createTestCredential } from "@azure-tools/test-credential";
import type { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";
import { assertEnvironmentVariable, env } from "@azure-tools/test-recorder";
import * as assert from "assert";
import { assert } from "vitest";
import { createClientLogger } from "@azure/logger";
import type { LogsTable } from "../../../src";
import { LogsQueryClient, MetricsQueryClient, MetricsClient } from "../../../src";
import type { LogsTable } from "../../../src/index.js";
import { LogsQueryClient, MetricsQueryClient, MetricsClient } from "../../../src/index.js";
import type { ExponentialRetryPolicyOptions } from "@azure/core-rest-pipeline";
export const loggerForTest = createClientLogger("test");
const replacementForLogsResourceId = env["LOGS_RESOURCE_ID"]?.startsWith("/")
? "/logs-arm-resource-id"
: "logs-arm-resource-id";

Просмотреть файл

@ -0,0 +1,10 @@
{
"extends": "./.tshy/build.json",
"include": ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.spec.ts", "./test/**/*.mts"],
"exclude": ["./test/**/node/**/*.ts"],
"compilerOptions": {
"outDir": "./dist-test/browser",
"rootDir": ".",
"skipLibCheck": true
}
}

Просмотреть файл

@ -1,11 +1,12 @@
{
"extends": "../../../tsconfig",
"compilerOptions": {
"outDir": "./dist-esm",
"declarationDir": "./types",
"paths": {
"@azure/monitor-query": ["./src/index"]
}
},
"module": "NodeNext",
"moduleResolution": "NodeNext",
"rootDir": "."
},
"include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"]
"include": ["src/**/*.ts", "src/**/*.mts", "src/**/*.cts", "samples-dev/**/*.ts", "test/**/*.ts"]
}

Просмотреть файл

@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { defineConfig, mergeConfig } from "vitest/config";
import viteConfig from "../../../vitest.browser.shared.config.js";
export default mergeConfig(
viteConfig,
defineConfig({
test: {
include: [
"dist-test/browser/test/internal/**/*.spec.js",
"dist-test/browser/test/public/**/*.spec.js",
],
},
}),
);

Просмотреть файл

@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { defineConfig, mergeConfig } from "vitest/config";
import viteConfig from "../../../vitest.browser.shared.config.js";
export default mergeConfig(
viteConfig,
defineConfig({
test: {
include: ["dist-test/browser/test/internal/unit/*.unittest.spec.js"],
},
}),
);

Просмотреть файл

@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { defineConfig, mergeConfig } from "vitest/config";
import viteConfig from "../../../vitest.shared.config.ts";
export default mergeConfig(
viteConfig,
defineConfig({
test: {
include: ["test/**/*.spec.ts"],
},
}),
);

Просмотреть файл

@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { defineConfig, mergeConfig } from "vitest/config";
import viteConfig from "../../../vitest.shared.config.js";
export default mergeConfig(
viteConfig,
defineConfig({
test: {
include: ["test/internal/**/*.spec.ts", "test/public/**/*.spec.ts"],
exclude: ["test/snippets.spec.ts"],
},
}),
);

Просмотреть файл

@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { defineConfig, mergeConfig } from "vitest/config";
import viteConfig from "../../../vitest.shared.config.js";
export default mergeConfig(
viteConfig,
defineConfig({
test: {
include: ["test/internal/**/*.unittest.spec.ts"],
exclude: ["test/snippets.spec.ts"],
},
}),
);