diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 84d91e0ecae0..0e82aba0c92d 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -734,6 +734,7 @@ packages: /@azure/ai-form-recognizer/3.1.0-beta.3: resolution: {integrity: sha512-+4QtFKNyxAmdqpcYjuAtmWKm/MuOe9kZsbpS9jA9h0YHzngNj5gc67AA4egV9BXOq9x+1phjYTNC/rxiOUr1uQ==} engines: {node: '>=8.0.0'} + deprecated: Please migrate to a supported (non-beta) version of this package dependencies: '@azure/core-auth': 1.4.0 '@azure/core-http': 1.2.6 @@ -4035,7 +4036,7 @@ packages: dependencies: semver: 7.3.8 shelljs: 0.8.5 - typescript: 5.1.0-dev.20230327 + typescript: 5.1.0-dev.20230328 dev: false /ecdsa-sig-formatter/1.0.11: @@ -8677,37 +8678,6 @@ packages: hasBin: true dev: false - /ts-node/10.9.1_cda5npvz5vidcibznbsxxfupne: - resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} - hasBin: true - peerDependencies: - '@swc/core': '>=1.2.50' - '@swc/wasm': '>=1.2.50' - '@types/node': '*' - typescript: '>=2.7' - peerDependenciesMeta: - '@swc/core': - optional: true - '@swc/wasm': - optional: true - dependencies: - '@cspotcode/source-map-support': 0.8.1 - '@tsconfig/node10': 1.0.9 - '@tsconfig/node12': 1.0.11 - '@tsconfig/node14': 1.0.3 - '@tsconfig/node16': 1.0.3 - '@types/node': 14.18.41 - acorn: 8.8.2 - acorn-walk: 8.2.0 - arg: 4.1.3 - create-require: 1.1.1 - diff: 4.0.2 - make-error: 1.3.6 - typescript: 5.0.2 - v8-compile-cache-lib: 3.0.1 - yn: 3.1.1 - dev: false - /ts-node/10.9.1_ksn4eycaeggbrckn3ykh37hwf4: resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true @@ -8913,8 +8883,8 @@ packages: hasBin: true dev: false - /typescript/5.1.0-dev.20230327: - resolution: {integrity: sha512-tzeS6vmUF8qC4zFdvos88Oer1oNVrg0CVlIaxfI//pDrq8rur4nIUTLRWRlEMCeLQporHhD+z9sESoSr5GL+lw==} + /typescript/5.1.0-dev.20230328: + resolution: {integrity: sha512-pylwLhhCSsZX72UUJTSD+5DKoEUUKsqQg6w4bLdRVbYVXDCxPLExUayWWCaRSmx9WJjf00YwMA2MXS2z2t5+2g==} engines: {node: '>=12.20'} hasBin: true dev: false @@ -15307,7 +15277,7 @@ packages: dev: false file:projects/arm-support.tgz: - resolution: {integrity: sha512-GfG1aZ4/Qvb9dHOZJOAiGJ9rOn5Hd2lG/sXJkHiJYgHV2Cpi9YNmOnJhl9QPZndHG9DJqEGMwGyIqDgSZLCnGQ==, tarball: file:projects/arm-support.tgz} + resolution: {integrity: sha512-rEQstVXRF+3dwaspRdUSD3FWjMX74KxPJw9+uqd3AQXXodQcLAPx48NmmQHZoR/QpwA2hPXkrA4qFZtoXvZRag==, tarball: file:projects/arm-support.tgz} name: '@rush-temp/arm-support' version: 0.0.0 dependencies: @@ -15321,8 +15291,8 @@ packages: '@types/node': 14.18.41 chai: 4.3.7 cross-env: 7.0.3 - dotenv: 8.6.0 - mkdirp: 1.0.4 + dotenv: 16.0.3 + mkdirp: 2.1.6 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 @@ -17018,7 +16988,7 @@ packages: rollup-plugin-sourcemaps: 0.6.3_qg36w4uagpty5et2swcu4ykn64 rollup-plugin-visualizer: 5.9.0_rollup@2.79.1 semver: 7.3.8 - ts-node: 10.9.1_cda5npvz5vidcibznbsxxfupne + ts-node: 10.9.1_rwcdhhaqkims6irrp2ypnntvry tslib: 2.5.0 typescript: 4.8.4 yaml: 1.10.2 diff --git a/sdk/support/arm-support/_meta.json b/sdk/support/arm-support/_meta.json index dccd4eb30070..4e311321ad15 100644 --- a/sdk/support/arm-support/_meta.json +++ b/sdk/support/arm-support/_meta.json @@ -1,8 +1,8 @@ { - "commit": "d600759c3516b61a7c353bc8682bccbab85a6f65", - "readme": "specification\\support\\resource-manager\\readme.md", - "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=F:\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\support\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.7 --generate-sample=true", + "commit": "68494cb6a41d1f32332868e58c7850aab4194a7d", + "readme": "specification/support/resource-manager/readme.md", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/support/resource-manager/readme.md --use=@autorest/typescript@6.0.0-rc.10", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.6.0", - "use": "@autorest/typescript@6.0.0-rc.7" + "release_tool": "@azure-tools/js-sdk-release-tools@2.7.0", + "use": "@autorest/typescript@6.0.0-rc.10" } \ No newline at end of file diff --git a/sdk/support/arm-support/package.json b/sdk/support/arm-support/package.json index 40734b515044..ac22f2c844af 100644 --- a/sdk/support/arm-support/package.json +++ b/sdk/support/arm-support/package.json @@ -8,10 +8,10 @@ "node": ">=14.0.0" }, "dependencies": { - "@azure/core-lro": "^2.2.0", + "@azure/core-lro": "^2.5.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.6.1", + "@azure/core-client": "^1.7.0", "@azure/core-auth": "^1.3.0", "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" @@ -33,13 +33,13 @@ "@rollup/plugin-json": "^6.0.0", "@rollup/plugin-multi-entry": "^6.0.0", "@rollup/plugin-node-resolve": "^13.1.3", - "mkdirp": "^1.0.4", + "mkdirp": "^2.1.2", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", - "dotenv": "^8.2.0", + "dotenv": "^16.0.0", "@azure/identity": "^2.0.1", "@azure-tools/test-recorder": "^3.0.0", "@azure-tools/test-credential": "^1.0.0", @@ -111,13 +111,5 @@ ] }, "autoPublish": true, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/support/arm-support", - "//sampleConfiguration": { - "productName": "", - "productSlugs": [ - "azure" - ], - "disableDocsMs": true, - "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-support?view=azure-node-preview" - } -} + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/support/arm-support" +} \ No newline at end of file diff --git a/sdk/support/arm-support/review/arm-support.api.md b/sdk/support/arm-support/review/arm-support.api.md index d06b47bfce77..972042c99bcd 100644 --- a/sdk/support/arm-support/review/arm-support.api.md +++ b/sdk/support/arm-support/review/arm-support.api.md @@ -6,9 +6,9 @@ import * as coreAuth from '@azure/core-auth'; import * as coreClient from '@azure/core-client'; +import { OperationState } from '@azure/core-lro'; import { PagedAsyncIterableIterator } from '@azure/core-paging'; -import { PollerLike } from '@azure/core-lro'; -import { PollOperationState } from '@azure/core-lro'; +import { SimplePollerLike } from '@azure/core-lro'; // @public export interface CheckNameAvailabilityInput { @@ -41,7 +41,7 @@ export type CommunicationDirection = string; // @public export interface Communications { - beginCreate(supportTicketName: string, communicationName: string, createCommunicationParameters: CommunicationDetails, options?: CommunicationsCreateOptionalParams): Promise, CommunicationsCreateResponse>>; + beginCreate(supportTicketName: string, communicationName: string, createCommunicationParameters: CommunicationDetails, options?: CommunicationsCreateOptionalParams): Promise, CommunicationsCreateResponse>>; beginCreateAndWait(supportTicketName: string, communicationName: string, createCommunicationParameters: CommunicationDetails, options?: CommunicationsCreateOptionalParams): Promise; checkNameAvailability(supportTicketName: string, checkNameAvailabilityInput: CheckNameAvailabilityInput, options?: CommunicationsCheckNameAvailabilityOptionalParams): Promise; get(supportTicketName: string, communicationName: string, options?: CommunicationsGetOptionalParams): Promise; @@ -353,7 +353,7 @@ export interface SupportTicketDetails { // @public export interface SupportTickets { - beginCreate(supportTicketName: string, createSupportTicketParameters: SupportTicketDetails, options?: SupportTicketsCreateOptionalParams): Promise, SupportTicketsCreateResponse>>; + beginCreate(supportTicketName: string, createSupportTicketParameters: SupportTicketDetails, options?: SupportTicketsCreateOptionalParams): Promise, SupportTicketsCreateResponse>>; beginCreateAndWait(supportTicketName: string, createSupportTicketParameters: SupportTicketDetails, options?: SupportTicketsCreateOptionalParams): Promise; checkNameAvailability(checkNameAvailabilityInput: CheckNameAvailabilityInput, options?: SupportTicketsCheckNameAvailabilityOptionalParams): Promise; get(supportTicketName: string, options?: SupportTicketsGetOptionalParams): Promise; diff --git a/sdk/support/arm-support/src/lroImpl.ts b/sdk/support/arm-support/src/lroImpl.ts index 518d5f053b4e..dd803cd5e28c 100644 --- a/sdk/support/arm-support/src/lroImpl.ts +++ b/sdk/support/arm-support/src/lroImpl.ts @@ -6,29 +6,37 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { AbortSignalLike } from "@azure/abort-controller"; import { LongRunningOperation, LroResponse } from "@azure/core-lro"; -export class LroImpl implements LongRunningOperation { - constructor( - private sendOperationFn: (args: any, spec: any) => Promise>, - private args: Record, - private spec: { - readonly requestBody?: unknown; - readonly path?: string; - readonly httpMethod: string; - } & Record, - public requestPath: string = spec.path!, - public requestMethod: string = spec.httpMethod - ) {} - public async sendInitialRequest(): Promise> { - return this.sendOperationFn(this.args, this.spec); - } - public async sendPollRequest(path: string): Promise> { - const { requestBody, ...restSpec } = this.spec; - return this.sendOperationFn(this.args, { - ...restSpec, - path, - httpMethod: "GET" - }); - } +export function createLroSpec(inputs: { + sendOperationFn: (args: any, spec: any) => Promise>; + args: Record; + spec: { + readonly requestBody?: unknown; + readonly path?: string; + readonly httpMethod: string; + } & Record; +}): LongRunningOperation { + const { args, spec, sendOperationFn } = inputs; + return { + requestMethod: spec.httpMethod, + requestPath: spec.path!, + sendInitialRequest: () => sendOperationFn(args, spec), + sendPollRequest: ( + path: string, + options?: { abortSignal?: AbortSignalLike } + ) => { + const { requestBody, ...restSpec } = spec; + return sendOperationFn(args, { + ...restSpec, + httpMethod: "GET", + path, + abortSignal: options?.abortSignal + }); + } + }; } diff --git a/sdk/support/arm-support/src/models/index.ts b/sdk/support/arm-support/src/models/index.ts index f454ba2164e2..7d33a4c59fb2 100644 --- a/sdk/support/arm-support/src/models/index.ts +++ b/sdk/support/arm-support/src/models/index.ts @@ -558,7 +558,7 @@ export interface SupportTicketsListOptionalParams extends coreClient.OperationOptions { /** The number of values to return in the collection. Default is 25 and max is 100. */ top?: number; - /** The filter to apply on the operation. We support 'odata v4.0' filter semantics. [Learn more](https://docs.microsoft.com/odata/concepts/queryoptions-overview). _Status_ filter can only be used with Equals ('eq') operator. For _CreatedDate_ filter, the supported operators are Greater Than ('gt') and Greater Than or Equals ('ge'). When using both filters, combine them using the logical 'AND'. */ + /** The filter to apply on the operation. We support 'odata v4.0' filter semantics. [Learn more](https://docs.microsoft.com/odata/concepts/queryoptions-overview). _Status_, _ServiceId_, and _ProblemClassificationId_ filters can only be used with Equals ('eq') operator. For _CreatedDate_ filter, the supported operators are Greater Than ('gt') and Greater Than or Equals ('ge'). When using both filters, combine them using the logical 'AND'. */ filter?: string; } diff --git a/sdk/support/arm-support/src/operations/communications.ts b/sdk/support/arm-support/src/operations/communications.ts index c2902d43cccf..e3d44af1d028 100644 --- a/sdk/support/arm-support/src/operations/communications.ts +++ b/sdk/support/arm-support/src/operations/communications.ts @@ -13,8 +13,12 @@ import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { MicrosoftSupport } from "../microsoftSupport"; -import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; -import { LroImpl } from "../lroImpl"; +import { + SimplePollerLike, + OperationState, + createHttpPoller +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; import { CommunicationDetails, CommunicationsListNextOptionalParams, @@ -178,8 +182,8 @@ export class CommunicationsImpl implements Communications { createCommunicationParameters: CommunicationDetails, options?: CommunicationsCreateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, CommunicationsCreateResponse > > { @@ -189,7 +193,7 @@ export class CommunicationsImpl implements Communications { ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -222,20 +226,23 @@ export class CommunicationsImpl implements Communications { }; }; - const lro = new LroImpl( - sendOperation, - { + const lro = createLroSpec({ + sendOperationFn, + args: { supportTicketName, communicationName, createCommunicationParameters, options }, - createOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + spec: createOperationSpec + }); + const poller = await createHttpPoller< + CommunicationsCreateResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, - lroResourceLocationConfig: "azure-async-operation" + resourceLocationConfig: "azure-async-operation" }); await poller.poll(); return poller; diff --git a/sdk/support/arm-support/src/operations/supportTickets.ts b/sdk/support/arm-support/src/operations/supportTickets.ts index bfa4b103e229..b6d6bec54c92 100644 --- a/sdk/support/arm-support/src/operations/supportTickets.ts +++ b/sdk/support/arm-support/src/operations/supportTickets.ts @@ -13,8 +13,12 @@ import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { MicrosoftSupport } from "../microsoftSupport"; -import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; -import { LroImpl } from "../lroImpl"; +import { + SimplePollerLike, + OperationState, + createHttpPoller +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; import { SupportTicketDetails, SupportTicketsListNextOptionalParams, @@ -48,10 +52,10 @@ export class SupportTicketsImpl implements SupportTickets { /** * Lists all the support tickets for an Azure subscription. You can also filter the support tickets by - * _Status_ or _CreatedDate_ using the $filter parameter. Output will be a paged result with - * _nextLink_, using which you can retrieve the next set of support tickets.

Support ticket - * data is available for 18 months after ticket creation. If a ticket was created more than 18 months - * ago, a request for data might cause an error. + * _Status_, _CreatedDate_, _ServiceId_, and _ProblemClassificationId_ using the $filter parameter. + * Output will be a paged result with _nextLink_, using which you can retrieve the next set of support + * tickets.

Support ticket data is available for 18 months after ticket creation. If a ticket + * was created more than 18 months ago, a request for data might cause an error. * @param options The options parameters. */ public list( @@ -122,10 +126,10 @@ export class SupportTicketsImpl implements SupportTickets { /** * Lists all the support tickets for an Azure subscription. You can also filter the support tickets by - * _Status_ or _CreatedDate_ using the $filter parameter. Output will be a paged result with - * _nextLink_, using which you can retrieve the next set of support tickets.

Support ticket - * data is available for 18 months after ticket creation. If a ticket was created more than 18 months - * ago, a request for data might cause an error. + * _Status_, _CreatedDate_, _ServiceId_, and _ProblemClassificationId_ using the $filter parameter. + * Output will be a paged result with _nextLink_, using which you can retrieve the next set of support + * tickets.

Support ticket data is available for 18 months after ticket creation. If a ticket + * was created more than 18 months ago, a request for data might cause an error. * @param options The options parameters. */ private _list( @@ -201,8 +205,8 @@ export class SupportTicketsImpl implements SupportTickets { createSupportTicketParameters: SupportTicketDetails, options?: SupportTicketsCreateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, SupportTicketsCreateResponse > > { @@ -212,7 +216,7 @@ export class SupportTicketsImpl implements SupportTickets { ): Promise => { return this.client.sendOperationRequest(args, spec); }; - const sendOperation = async ( + const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { @@ -245,15 +249,18 @@ export class SupportTicketsImpl implements SupportTickets { }; }; - const lro = new LroImpl( - sendOperation, - { supportTicketName, createSupportTicketParameters, options }, - createOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, + const lro = createLroSpec({ + sendOperationFn, + args: { supportTicketName, createSupportTicketParameters, options }, + spec: createOperationSpec + }); + const poller = await createHttpPoller< + SupportTicketsCreateResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, - lroResourceLocationConfig: "azure-async-operation" + resourceLocationConfig: "azure-async-operation" }); await poller.poll(); return poller; diff --git a/sdk/support/arm-support/src/operationsInterfaces/communications.ts b/sdk/support/arm-support/src/operationsInterfaces/communications.ts index a4241c24682c..432d779d2f72 100644 --- a/sdk/support/arm-support/src/operationsInterfaces/communications.ts +++ b/sdk/support/arm-support/src/operationsInterfaces/communications.ts @@ -7,7 +7,7 @@ */ import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { SimplePollerLike, OperationState } from "@azure/core-lro"; import { CommunicationDetails, CommunicationsListOptionalParams, @@ -73,8 +73,8 @@ export interface Communications { createCommunicationParameters: CommunicationDetails, options?: CommunicationsCreateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, CommunicationsCreateResponse > >; diff --git a/sdk/support/arm-support/src/operationsInterfaces/supportTickets.ts b/sdk/support/arm-support/src/operationsInterfaces/supportTickets.ts index 8b92e8d21423..61e17dd3d778 100644 --- a/sdk/support/arm-support/src/operationsInterfaces/supportTickets.ts +++ b/sdk/support/arm-support/src/operationsInterfaces/supportTickets.ts @@ -7,7 +7,7 @@ */ import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { SimplePollerLike, OperationState } from "@azure/core-lro"; import { SupportTicketDetails, SupportTicketsListOptionalParams, @@ -28,10 +28,10 @@ import { export interface SupportTickets { /** * Lists all the support tickets for an Azure subscription. You can also filter the support tickets by - * _Status_ or _CreatedDate_ using the $filter parameter. Output will be a paged result with - * _nextLink_, using which you can retrieve the next set of support tickets.

Support ticket - * data is available for 18 months after ticket creation. If a ticket was created more than 18 months - * ago, a request for data might cause an error. + * _Status_, _CreatedDate_, _ServiceId_, and _ProblemClassificationId_ using the $filter parameter. + * Output will be a paged result with _nextLink_, using which you can retrieve the next set of support + * tickets.

Support ticket data is available for 18 months after ticket creation. If a ticket + * was created more than 18 months ago, a request for data might cause an error. * @param options The options parameters. */ list( @@ -102,8 +102,8 @@ export interface SupportTickets { createSupportTicketParameters: SupportTicketDetails, options?: SupportTicketsCreateOptionalParams ): Promise< - PollerLike< - PollOperationState, + SimplePollerLike< + OperationState, SupportTicketsCreateResponse > >; diff --git a/sdk/support/arm-support/tsconfig.json b/sdk/support/arm-support/tsconfig.json index 4ec227977454..3e6ae96443f3 100644 --- a/sdk/support/arm-support/tsconfig.json +++ b/sdk/support/arm-support/tsconfig.json @@ -15,17 +15,11 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true, - "paths": { - "@azure/arm-support": [ - "./src/index" - ] - } + "importHelpers": true }, "include": [ "./src/**/*.ts", - "./test/**/*.ts", - "samples-dev/**/*.ts" + "./test/**/*.ts" ], "exclude": [ "node_modules"