diff --git a/sdk/communication/communication-job-router-rest/api-extractor.json b/sdk/communication/communication-job-router-rest/api-extractor.json index 5ff7f4621cde..5e2ff3bfe2a0 100644 --- a/sdk/communication/communication-job-router-rest/api-extractor.json +++ b/sdk/communication/communication-job-router-rest/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./types/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/communication-job-router.d.ts" }, "messages": { - "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, "extractorMessageReporting": { - "ae-missing-release-tag": { "logLevel": "none" }, - "ae-unresolved-link": { "logLevel": "none" } + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } } } -} +} \ No newline at end of file diff --git a/sdk/communication/communication-job-router-rest/package.json b/sdk/communication/communication-job-router-rest/package.json index bdb2e6a3d446..c044020272ba 100644 --- a/sdk/communication/communication-job-router-rest/package.json +++ b/sdk/communication/communication-job-router-rest/package.json @@ -123,4 +123,4 @@ "azure-communication-services" ] } -} +} \ No newline at end of file diff --git a/sdk/communication/communication-job-router-rest/review/communication-job-router.api.md b/sdk/communication/communication-job-router-rest/review/communication-job-router.api.md index 33580971f2f3..b5413c5c728f 100644 --- a/sdk/communication/communication-job-router-rest/review/communication-job-router.api.md +++ b/sdk/communication/communication-job-router-rest/review/communication-job-router.api.md @@ -8,7 +8,6 @@ import { Client } from '@azure-rest/core-client'; import { ClientOptions } from '@azure-rest/core-client'; import { ErrorResponse } from '@azure-rest/core-client'; import { HttpResponse } from '@azure-rest/core-client'; -import { KeyCredential } from '@azure/core-auth'; import { Paged } from '@azure/core-paging'; import { PagedAsyncIterableIterator } from '@azure/core-paging'; import { PathUncheckedResponse } from '@azure-rest/core-client'; @@ -16,7 +15,6 @@ import { RawHttpHeaders } from '@azure/core-rest-pipeline'; import { RawHttpHeadersInput } from '@azure/core-rest-pipeline'; import { RequestParameters } from '@azure-rest/core-client'; import { StreamableMethod } from '@azure-rest/core-client'; -import { TokenCredential } from '@azure/core-auth'; // @public (undocumented) export interface Accept { @@ -63,14 +61,14 @@ export type AzureCommunicationRoutingServiceClient = Client & { // @public export interface BestWorkerMode extends DistributionModeParent { - kind: "best-worker"; + kind: "bestWorker"; scoringRule?: RouterRule; scoringRuleOptions?: ScoringRuleOptions; } // @public export interface BestWorkerModeOutput extends DistributionModeOutputParent { - kind: "best-worker"; + kind: "bestWorker"; scoringRule?: RouterRuleOutput; scoringRuleOptions?: ScoringRuleOptionsOutput; } @@ -279,10 +277,7 @@ export interface ConditionalWorkerSelectorAttachmentOutput extends WorkerSelecto } // @public -function createClient(connectionStringOrUrl: string, options: ClientOptions): AzureCommunicationRoutingServiceClient; - -// @public -function createClient(endpoint: string, credentialOrOptions?: KeyCredential | TokenCredential, options?: ClientOptions): AzureCommunicationRoutingServiceClient; +function createClient(endpoint: string, options?: ClientOptions): AzureCommunicationRoutingServiceClient; export default createClient; // @public (undocumented) @@ -476,12 +471,12 @@ export type DeleteWorkerParameters = RequestParameters; // @public export interface DirectMapRouterRule extends RouterRuleParent { - kind: "direct-map-rule"; + kind: "directMap"; } // @public export interface DirectMapRouterRuleOutput extends RouterRuleOutputParent { - kind: "direct-map-rule"; + kind: "directMap"; } // @public @@ -599,14 +594,14 @@ export interface ExceptionTriggerParent { // @public export interface ExpressionRouterRule extends RouterRuleParent { expression: string; - kind: "expression-rule"; + kind: "expression"; language?: string; } // @public export interface ExpressionRouterRuleOutput extends RouterRuleOutputParent { expression: string; - kind: "expression-rule"; + kind: "expression"; language?: string; } @@ -614,7 +609,7 @@ export interface ExpressionRouterRuleOutput extends RouterRuleOutputParent { export interface FunctionRouterRule extends RouterRuleParent { credential?: FunctionRouterRuleCredential; functionUri: string; - kind: "azure-function-rule"; + kind: "function"; } // @public @@ -635,7 +630,7 @@ export interface FunctionRouterRuleCredentialOutput { export interface FunctionRouterRuleOutput extends RouterRuleOutputParent { credential?: FunctionRouterRuleCredentialOutput; functionUri: string; - kind: "azure-function-rule"; + kind: "function"; } // @public @@ -1294,17 +1289,17 @@ export interface ListWorkersQueryParamProperties { // @public export interface LongestIdleMode extends DistributionModeParent { - kind: "longest-idle"; + kind: "longestIdle"; } // @public export interface LongestIdleModeOutput extends DistributionModeOutputParent { - kind: "longest-idle"; + kind: "longestIdle"; } // @public export interface ManualReclassifyExceptionAction extends ExceptionActionParent { - kind: "manual-reclassify"; + kind: "manualReclassify"; priority?: number; queueId?: string; workerSelectors?: Array; @@ -1312,7 +1307,7 @@ export interface ManualReclassifyExceptionAction extends ExceptionActionParent { // @public export interface ManualReclassifyExceptionActionOutput extends ExceptionActionOutputParent { - kind: "manual-reclassify"; + kind: "manualReclassify"; priority?: number; queueId?: string; workerSelectors?: Array; @@ -1366,14 +1361,14 @@ export interface PagingOptions { // @public export interface PassThroughQueueSelectorAttachment extends QueueSelectorAttachmentParent { key: string; - kind: "pass-through"; + kind: "passThrough"; labelOperator: string; } // @public export interface PassThroughQueueSelectorAttachmentOutput extends QueueSelectorAttachmentOutputParent { key: string; - kind: "pass-through"; + kind: "passThrough"; labelOperator: string; } @@ -1381,7 +1376,7 @@ export interface PassThroughQueueSelectorAttachmentOutput extends QueueSelectorA export interface PassThroughWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { expiresAfterSeconds?: number; key: string; - kind: "pass-through"; + kind: "passThrough"; labelOperator: string; } @@ -1389,29 +1384,29 @@ export interface PassThroughWorkerSelectorAttachment extends WorkerSelectorAttac export interface PassThroughWorkerSelectorAttachmentOutput extends WorkerSelectorAttachmentOutputParent { expiresAfterSeconds?: number; key: string; - kind: "pass-through"; + kind: "passThrough"; labelOperator: string; } // @public export interface QueueAndMatchMode extends JobMatchingModeParent { - kind: "queue-and-match"; + kind: "queueAndMatch"; } // @public export interface QueueAndMatchModeOutput extends JobMatchingModeOutputParent { - kind: "queue-and-match"; + kind: "queueAndMatch"; } // @public export interface QueueLengthExceptionTrigger extends ExceptionTriggerParent { - kind: "queue-length"; + kind: "queueLength"; threshold: number; } // @public export interface QueueLengthExceptionTriggerOutput extends ExceptionTriggerOutputParent { - kind: "queue-length"; + kind: "queueLength"; threshold: number; } @@ -1505,12 +1500,12 @@ export type ReclassifyParameters = ReclassifyBodyParam & RequestParameters; // @public export interface RoundRobinMode extends DistributionModeParent { - kind: "round-robin"; + kind: "roundRobin"; } // @public export interface RoundRobinModeOutput extends DistributionModeOutputParent { - kind: "round-robin"; + kind: "roundRobin"; } // @public @@ -1779,37 +1774,37 @@ export interface Routes { // @public export interface RuleEngineQueueSelectorAttachment extends QueueSelectorAttachmentParent { - kind: "rule-engine"; + kind: "ruleEngine"; rule: RouterRule; } // @public export interface RuleEngineQueueSelectorAttachmentOutput extends QueueSelectorAttachmentOutputParent { - kind: "rule-engine"; + kind: "ruleEngine"; rule: RouterRuleOutput; } // @public export interface RuleEngineWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { - kind: "rule-engine"; + kind: "ruleEngine"; rule: RouterRule; } // @public export interface RuleEngineWorkerSelectorAttachmentOutput extends WorkerSelectorAttachmentOutputParent { - kind: "rule-engine"; + kind: "ruleEngine"; rule: RouterRuleOutput; } // @public export interface ScheduleAndSuspendMode extends JobMatchingModeParent { - kind: "schedule-and-suspend"; + kind: "scheduleAndSuspend"; scheduleAt: Date | string; } // @public export interface ScheduleAndSuspendModeOutput extends JobMatchingModeOutputParent { - kind: "schedule-and-suspend"; + kind: "scheduleAndSuspend"; scheduleAt: string; } @@ -1843,13 +1838,13 @@ export interface StaticQueueSelectorAttachmentOutput extends QueueSelectorAttach // @public export interface StaticRouterRule extends RouterRuleParent { - kind: "static-rule"; + kind: "static"; value?: unknown; } // @public export interface StaticRouterRuleOutput extends RouterRuleOutputParent { - kind: "static-rule"; + kind: "static"; value?: any; } @@ -2398,13 +2393,13 @@ export type UpsertWorkerParameters = UpsertWorkerHeaderParam & UpsertWorkerMedia // @public export interface WaitTimeExceptionTrigger extends ExceptionTriggerParent { - kind: "wait-time"; + kind: "waitTime"; thresholdSeconds: number; } // @public export interface WaitTimeExceptionTriggerOutput extends ExceptionTriggerOutputParent { - kind: "wait-time"; + kind: "waitTime"; thresholdSeconds: number; } @@ -2412,7 +2407,7 @@ export interface WaitTimeExceptionTriggerOutput extends ExceptionTriggerOutputPa export interface WebhookRouterRule extends RouterRuleParent { authorizationServerUri?: string; clientCredential?: OAuth2WebhookClientCredential; - kind: "webhook-rule"; + kind: "webhook"; webhookUri?: string; } @@ -2420,32 +2415,32 @@ export interface WebhookRouterRule extends RouterRuleParent { export interface WebhookRouterRuleOutput extends RouterRuleOutputParent { authorizationServerUri?: string; clientCredential?: OAuth2WebhookClientCredentialOutput; - kind: "webhook-rule"; + kind: "webhook"; webhookUri?: string; } // @public export interface WeightedAllocationQueueSelectorAttachment extends QueueSelectorAttachmentParent { allocations: Array; - kind: "weighted-allocation-queue-selector"; + kind: "weightedAllocation"; } // @public export interface WeightedAllocationQueueSelectorAttachmentOutput extends QueueSelectorAttachmentOutputParent { allocations: Array; - kind: "weighted-allocation-queue-selector"; + kind: "weightedAllocation"; } // @public export interface WeightedAllocationWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { allocations: Array; - kind: "weighted-allocation-worker-selector"; + kind: "weightedAllocation"; } // @public export interface WeightedAllocationWorkerSelectorAttachmentOutput extends WorkerSelectorAttachmentOutputParent { allocations: Array; - kind: "weighted-allocation-worker-selector"; + kind: "weightedAllocation"; } // @public diff --git a/sdk/communication/communication-job-router-rest/src/azureCommunicationRoutingServiceClient.ts b/sdk/communication/communication-job-router-rest/src/azureCommunicationRoutingServiceClient.ts index 6c2e526af107..b81741f25401 100644 --- a/sdk/communication/communication-job-router-rest/src/azureCommunicationRoutingServiceClient.ts +++ b/sdk/communication/communication-job-router-rest/src/azureCommunicationRoutingServiceClient.ts @@ -2,67 +2,24 @@ // Licensed under the MIT license. import { getClient, ClientOptions } from "@azure-rest/core-client"; -import { isTokenCredential, KeyCredential, TokenCredential } from "@azure/core-auth"; import { logger } from "./logger"; import { AzureCommunicationRoutingServiceClient } from "./clientDefinitions"; -import { - createCommunicationAuthPolicy, - isKeyCredential, - parseClientArguments, -} from "@azure/communication-common"; /** * Initialize a new instance of `AzureCommunicationRoutingServiceClient` - * @param connectionStringOrUrl - The connectionString or url of the Communication Services resource. - * @param options - the parameter for all optional parameters - */ -export default function createClient( - connectionStringOrUrl: string, - options: ClientOptions -): AzureCommunicationRoutingServiceClient; - -/** - * Initialize a new instance of `AzureCommunicationRoutingServiceClient` - * @param endpoint - The endpoint of the Communication Services resource. - * @param credentialOrOptions The key or token credential. + * @param endpoint - A sequence of textual characters. * @param options - the parameter for all optional parameters */ export default function createClient( endpoint: string, - credentialOrOptions?: KeyCredential | TokenCredential, - options?: ClientOptions -): AzureCommunicationRoutingServiceClient; - -// Implementation -export default function createClient( - arg1: string, - arg2?: ClientOptions | (KeyCredential | TokenCredential), - arg3?: ClientOptions + options: ClientOptions = {} ): AzureCommunicationRoutingServiceClient { - let credentialOrOptions: KeyCredential | TokenCredential | undefined; - let options: ClientOptions | undefined; - const connectionStringOrUrl = arg1; - - // Determine which constructor is being called based on the types of the arguments - if (isTokenCredential(arg2) || isKeyCredential(arg2)) { - credentialOrOptions = arg2 as KeyCredential | TokenCredential; - options = arg3 as ClientOptions; - } else { - options = arg2 as ClientOptions; - } - if (options === undefined) { - options = {}; - } - - // Rest of the function remains the same, using connectionStringOrUrl or endpoint as needed - const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions); - const baseUrl = options?.baseUrl ?? `${url}`; - options.apiVersion = options?.apiVersion ?? "2023-11-01"; - - const userAgentInfo = "azsdk-js-communication-job-router-rest/1.0.0-beta.1"; + const baseUrl = options.baseUrl ?? `${endpoint}`; + options.apiVersion = options.apiVersion ?? "2023-11-01"; + const userAgentInfo = `azsdk-js-communication-job-router-rest/1.0.0-beta.1`; const userAgentPrefix = - options?.userAgentOptions && options?.userAgentOptions.userAgentPrefix - ? `${options?.userAgentOptions.userAgentPrefix} ${userAgentInfo}` + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` : `${userAgentInfo}`; options = { ...options, @@ -70,14 +27,14 @@ export default function createClient( userAgentPrefix, }, loggingOptions: { - logger: options?.loggingOptions?.logger ?? logger.info, + logger: options.loggingOptions?.logger ?? logger.info, }, }; - const client = getClient(baseUrl, options) as AzureCommunicationRoutingServiceClient; - - const authPolicy = createCommunicationAuthPolicy(credential); - client.pipeline.addPolicy(authPolicy); + const client = getClient( + baseUrl, + options + ) as AzureCommunicationRoutingServiceClient; return client; } diff --git a/sdk/communication/communication-job-router-rest/src/clientDefinitions.ts b/sdk/communication/communication-job-router-rest/src/clientDefinitions.ts index 3eeec36514ad..82249d5298bb 100644 --- a/sdk/communication/communication-job-router-rest/src/clientDefinitions.ts +++ b/sdk/communication/communication-job-router-rest/src/clientDefinitions.ts @@ -124,12 +124,15 @@ export interface UpsertClassificationPolicy { /** Retrieves an existing classification policy by Id. */ get( options?: GetClassificationPolicyParameters - ): StreamableMethod; + ): StreamableMethod< + GetClassificationPolicy200Response | GetClassificationPolicyDefaultResponse + >; /** Delete a classification policy by Id. */ delete( options?: DeleteClassificationPolicyParameters ): StreamableMethod< - DeleteClassificationPolicy204Response | DeleteClassificationPolicyDefaultResponse + | DeleteClassificationPolicy204Response + | DeleteClassificationPolicyDefaultResponse >; } @@ -138,7 +141,8 @@ export interface ListClassificationPolicies { get( options?: ListClassificationPoliciesParameters ): StreamableMethod< - ListClassificationPolicies200Response | ListClassificationPoliciesDefaultResponse + | ListClassificationPolicies200Response + | ListClassificationPoliciesDefaultResponse >; } @@ -154,12 +158,15 @@ export interface UpsertDistributionPolicy { /** Retrieves an existing distribution policy by Id. */ get( options?: GetDistributionPolicyParameters - ): StreamableMethod; + ): StreamableMethod< + GetDistributionPolicy200Response | GetDistributionPolicyDefaultResponse + >; /** Delete a distribution policy by Id. */ delete( options?: DeleteDistributionPolicyParameters ): StreamableMethod< - DeleteDistributionPolicy204Response | DeleteDistributionPolicyDefaultResponse + | DeleteDistributionPolicy204Response + | DeleteDistributionPolicyDefaultResponse >; } @@ -168,7 +175,8 @@ export interface ListDistributionPolicies { get( options?: ListDistributionPoliciesParameters ): StreamableMethod< - ListDistributionPolicies200Response | ListDistributionPoliciesDefaultResponse + | ListDistributionPolicies200Response + | ListDistributionPoliciesDefaultResponse >; } @@ -184,25 +192,33 @@ export interface UpsertExceptionPolicy { /** Retrieves an existing exception policy by Id. */ get( options?: GetExceptionPolicyParameters - ): StreamableMethod; + ): StreamableMethod< + GetExceptionPolicy200Response | GetExceptionPolicyDefaultResponse + >; /** Deletes a exception policy by Id. */ delete( options?: DeleteExceptionPolicyParameters - ): StreamableMethod; + ): StreamableMethod< + DeleteExceptionPolicy204Response | DeleteExceptionPolicyDefaultResponse + >; } export interface ListExceptionPolicies { /** Retrieves existing exception policies. */ get( options?: ListExceptionPoliciesParameters - ): StreamableMethod; + ): StreamableMethod< + ListExceptionPolicies200Response | ListExceptionPoliciesDefaultResponse + >; } export interface UpsertQueue { /** Creates or updates a queue. */ patch( options: UpsertQueueParameters - ): StreamableMethod; + ): StreamableMethod< + UpsertQueue200Response | UpsertQueue201Response | UpsertQueueDefaultResponse + >; /** Retrieves an existing queue by Id. */ get( options?: GetQueueParameters @@ -224,9 +240,13 @@ export interface UpsertJob { /** Creates or updates a router job. */ patch( options: UpsertJobParameters - ): StreamableMethod; + ): StreamableMethod< + UpsertJob200Response | UpsertJob201Response | UpsertJobDefaultResponse + >; /** Retrieves an existing job by Id. */ - get(options?: GetJobParameters): StreamableMethod; + get( + options?: GetJobParameters + ): StreamableMethod; /** Deletes a job and all of its traces. */ delete( options?: DeleteJobParameters @@ -242,7 +262,9 @@ export interface Reclassify { export interface Cancel { /** Submits request to cancel an existing job by Id while supplying free-form cancellation reason. */ - post(options?: CancelParameters): StreamableMethod; + post( + options?: CancelParameters + ): StreamableMethod; } export interface Complete { @@ -254,7 +276,9 @@ export interface Complete { export interface Close { /** Closes a completed job. */ - post(options?: CloseParameters): StreamableMethod; + post( + options?: CloseParameters + ): StreamableMethod; } export interface ListJobs { @@ -268,7 +292,9 @@ export interface GetInQueuePosition { /** Gets a job's position details. */ get( options?: GetInQueuePositionParameters - ): StreamableMethod; + ): StreamableMethod< + GetInQueuePosition200Response | GetInQueuePositionDefaultResponse + >; } export interface Unassign { @@ -280,19 +306,25 @@ export interface Unassign { export interface Accept { /** Accepts an offer to work on a job and returns a 409/Conflict if another agent accepted the job already. */ - post(options?: AcceptParameters): StreamableMethod; + post( + options?: AcceptParameters + ): StreamableMethod; } export interface Decline { /** Declines an offer to work on a job. */ - post(options?: DeclineParameters): StreamableMethod; + post( + options?: DeclineParameters + ): StreamableMethod; } export interface GetQueueStatistics { /** Retrieves a queue's statistics. */ get( options?: GetQueueStatisticsParameters - ): StreamableMethod; + ): StreamableMethod< + GetQueueStatistics200Response | GetQueueStatisticsDefaultResponse + >; } export interface UpsertWorker { @@ -300,7 +332,9 @@ export interface UpsertWorker { patch( options: UpsertWorkerParameters ): StreamableMethod< - UpsertWorker200Response | UpsertWorker201Response | UpsertWorkerDefaultResponse + | UpsertWorker200Response + | UpsertWorker201Response + | UpsertWorkerDefaultResponse >; /** Retrieves an existing worker by Id. */ get( @@ -386,7 +420,10 @@ export interface Routes { offerId: string ): Decline; /** Resource for '/routing/queues/\{queueId\}/statistics' has methods for the following verbs: get */ - (path: "/routing/queues/{queueId}/statistics", queueId: string): GetQueueStatistics; + ( + path: "/routing/queues/{queueId}/statistics", + queueId: string + ): GetQueueStatistics; /** Resource for '/routing/workers/\{workerId\}' has methods for the following verbs: patch, get, delete */ (path: "/routing/workers/{workerId}", workerId: string): UpsertWorker; /** Resource for '/routing/workers' has methods for the following verbs: get */ diff --git a/sdk/communication/communication-job-router-rest/src/isUnexpected.ts b/sdk/communication/communication-job-router-rest/src/isUnexpected.ts index 681514646ad1..cb57c2000fa4 100644 --- a/sdk/communication/communication-job-router-rest/src/isUnexpected.ts +++ b/sdk/communication/communication-job-router-rest/src/isUnexpected.ts @@ -77,7 +77,10 @@ import { } from "./responses"; const responseMap: Record = { - "PATCH /routing/classificationPolicies/{classificationPolicyId}": ["200", "201"], + "PATCH /routing/classificationPolicies/{classificationPolicyId}": [ + "200", + "201", + ], "GET /routing/classificationPolicies/{classificationPolicyId}": ["200"], "DELETE /routing/classificationPolicies/{classificationPolicyId}": ["204"], "GET /routing/classificationPolicies": ["200"], @@ -119,13 +122,19 @@ export function isUnexpected( | UpsertClassificationPolicyDefaultResponse ): response is UpsertClassificationPolicyDefaultResponse; export function isUnexpected( - response: GetClassificationPolicy200Response | GetClassificationPolicyDefaultResponse + response: + | GetClassificationPolicy200Response + | GetClassificationPolicyDefaultResponse ): response is GetClassificationPolicyDefaultResponse; export function isUnexpected( - response: DeleteClassificationPolicy204Response | DeleteClassificationPolicyDefaultResponse + response: + | DeleteClassificationPolicy204Response + | DeleteClassificationPolicyDefaultResponse ): response is DeleteClassificationPolicyDefaultResponse; export function isUnexpected( - response: ListClassificationPolicies200Response | ListClassificationPoliciesDefaultResponse + response: + | ListClassificationPolicies200Response + | ListClassificationPoliciesDefaultResponse ): response is ListClassificationPoliciesDefaultResponse; export function isUnexpected( response: @@ -134,13 +143,19 @@ export function isUnexpected( | UpsertDistributionPolicyDefaultResponse ): response is UpsertDistributionPolicyDefaultResponse; export function isUnexpected( - response: GetDistributionPolicy200Response | GetDistributionPolicyDefaultResponse + response: + | GetDistributionPolicy200Response + | GetDistributionPolicyDefaultResponse ): response is GetDistributionPolicyDefaultResponse; export function isUnexpected( - response: DeleteDistributionPolicy204Response | DeleteDistributionPolicyDefaultResponse + response: + | DeleteDistributionPolicy204Response + | DeleteDistributionPolicyDefaultResponse ): response is DeleteDistributionPolicyDefaultResponse; export function isUnexpected( - response: ListDistributionPolicies200Response | ListDistributionPoliciesDefaultResponse + response: + | ListDistributionPolicies200Response + | ListDistributionPoliciesDefaultResponse ): response is ListDistributionPoliciesDefaultResponse; export function isUnexpected( response: @@ -152,13 +167,20 @@ export function isUnexpected( response: GetExceptionPolicy200Response | GetExceptionPolicyDefaultResponse ): response is GetExceptionPolicyDefaultResponse; export function isUnexpected( - response: DeleteExceptionPolicy204Response | DeleteExceptionPolicyDefaultResponse + response: + | DeleteExceptionPolicy204Response + | DeleteExceptionPolicyDefaultResponse ): response is DeleteExceptionPolicyDefaultResponse; export function isUnexpected( - response: ListExceptionPolicies200Response | ListExceptionPoliciesDefaultResponse + response: + | ListExceptionPolicies200Response + | ListExceptionPoliciesDefaultResponse ): response is ListExceptionPoliciesDefaultResponse; export function isUnexpected( - response: UpsertQueue200Response | UpsertQueue201Response | UpsertQueueDefaultResponse + response: + | UpsertQueue200Response + | UpsertQueue201Response + | UpsertQueueDefaultResponse ): response is UpsertQueueDefaultResponse; export function isUnexpected( response: GetQueue200Response | GetQueueDefaultResponse @@ -170,7 +192,10 @@ export function isUnexpected( response: ListQueues200Response | ListQueuesDefaultResponse ): response is ListQueuesDefaultResponse; export function isUnexpected( - response: UpsertJob200Response | UpsertJob201Response | UpsertJobDefaultResponse + response: + | UpsertJob200Response + | UpsertJob201Response + | UpsertJobDefaultResponse ): response is UpsertJobDefaultResponse; export function isUnexpected( response: GetJob200Response | GetJobDefaultResponse @@ -209,7 +234,10 @@ export function isUnexpected( response: GetQueueStatistics200Response | GetQueueStatisticsDefaultResponse ): response is GetQueueStatisticsDefaultResponse; export function isUnexpected( - response: UpsertWorker200Response | UpsertWorker201Response | UpsertWorkerDefaultResponse + response: + | UpsertWorker200Response + | UpsertWorker201Response + | UpsertWorkerDefaultResponse ): response is UpsertWorkerDefaultResponse; export function isUnexpected( response: GetWorker200Response | GetWorkerDefaultResponse @@ -360,17 +388,24 @@ function getParametrizedPathSuccess(method: string, path: string): string[] { // track if we have found a match to return the values found. let found = true; - for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) { - if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) { + for ( + let i = candidateParts.length - 1, j = pathParts.length - 1; + i >= 1 && j >= 1; + i--, j-- + ) { + if ( + candidateParts[i]?.startsWith("{") && + candidateParts[i]?.indexOf("}") !== -1 + ) { const start = candidateParts[i]!.indexOf("}") + 1, end = candidateParts[i]?.length; // If the current part of the candidate is a "template" part // Try to use the suffix of pattern to match the path // {guid} ==> $ // {guid}:export ==> :export$ - const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test( - pathParts[j] || "" - ); + const isMatched = new RegExp( + `${candidateParts[i]?.slice(start, end)}` + ).test(pathParts[j] || ""); if (!isMatched) { found = false; diff --git a/sdk/communication/communication-job-router-rest/src/models.ts b/sdk/communication/communication-job-router-rest/src/models.ts index d62b48561c6b..7dce014e57b8 100644 --- a/sdk/communication/communication-job-router-rest/src/models.ts +++ b/sdk/communication/communication-job-router-rest/src/models.ts @@ -21,7 +21,8 @@ export interface QueueSelectorAttachmentParent { } /** Describes a set of queue selectors that will be attached if the given condition resolves to true */ -export interface ConditionalQueueSelectorAttachment extends QueueSelectorAttachmentParent { +export interface ConditionalQueueSelectorAttachment + extends QueueSelectorAttachmentParent { /** The condition that must be true for the queue selectors to be attached */ condition: RouterRule; /** The queue selectors to attach */ @@ -45,7 +46,7 @@ export interface RouterRuleParent { /** A rule that return the same labels as the input labels. */ export interface DirectMapRouterRule extends RouterRuleParent { /** The type discriminator describing a sub-type of Rule */ - kind: "direct-map-rule"; + kind: "directMap"; } /** A rule providing inline expression rules. */ @@ -59,7 +60,7 @@ export interface ExpressionRouterRule extends RouterRuleParent { /** The string containing the expression to evaluate. Should contain return statement with calculated values. */ expression: string; /** The type discriminator describing a sub-type of Rule */ - kind: "expression-rule"; + kind: "expression"; } /** A rule providing a binding to an HTTP Triggered Azure Function. */ @@ -69,7 +70,7 @@ export interface FunctionRouterRule extends RouterRuleParent { /** Credentials used to access Azure function rule */ credential?: FunctionRouterRuleCredential; /** The type discriminator describing a sub-type of Rule */ - kind: "azure-function-rule"; + kind: "function"; } /** Credentials used to access Azure function rule */ @@ -87,7 +88,7 @@ export interface StaticRouterRule extends RouterRuleParent { /** The static value this rule always returns. Values must be primitive values - number, string, boolean. */ value?: unknown; /** The type discriminator describing a sub-type of Rule */ - kind: "static-rule"; + kind: "static"; } /** A rule providing a binding to an external web server. */ @@ -99,7 +100,7 @@ export interface WebhookRouterRule extends RouterRuleParent { /** Uri for Contoso's Web Server. */ webhookUri?: string; /** The type discriminator describing a sub-type of Rule */ - kind: "webhook-rule"; + kind: "webhook"; } /** OAuth2.0 Credentials used to Contoso's Authorization server. Reference: https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/ */ @@ -125,7 +126,8 @@ export interface RouterQueueSelector { } /** Attaches a queue selector where the value is passed through from the job label with the same key */ -export interface PassThroughQueueSelectorAttachment extends QueueSelectorAttachmentParent { +export interface PassThroughQueueSelectorAttachment + extends QueueSelectorAttachmentParent { /** The label key to query against */ key: string; /** @@ -135,19 +137,21 @@ export interface PassThroughQueueSelectorAttachment extends QueueSelectorAttachm */ labelOperator: string; /** The type discriminator describing the type of queue selector attachment */ - kind: "pass-through"; + kind: "passThrough"; } /** Attaches queue selectors to a job when the RouterRule is resolved */ -export interface RuleEngineQueueSelectorAttachment extends QueueSelectorAttachmentParent { +export interface RuleEngineQueueSelectorAttachment + extends QueueSelectorAttachmentParent { /** A RouterRule that resolves a collection of queue selectors to attach */ rule: RouterRule; /** The type discriminator describing the type of queue selector attachment */ - kind: "rule-engine"; + kind: "ruleEngine"; } /** Describes a queue selector that will be attached to the job */ -export interface StaticQueueSelectorAttachment extends QueueSelectorAttachmentParent { +export interface StaticQueueSelectorAttachment + extends QueueSelectorAttachmentParent { /** The queue selector to attach. */ queueSelector: RouterQueueSelector; /** The type discriminator describing the type of queue selector attachment */ @@ -155,11 +159,12 @@ export interface StaticQueueSelectorAttachment extends QueueSelectorAttachmentPa } /** Describes multiple sets of queue selectors, of which one will be selected and attached according to a weighting */ -export interface WeightedAllocationQueueSelectorAttachment extends QueueSelectorAttachmentParent { +export interface WeightedAllocationQueueSelectorAttachment + extends QueueSelectorAttachmentParent { /** A collection of percentage based weighted allocations. */ allocations: Array; /** The type discriminator describing the type of queue selector attachment */ - kind: "weighted-allocation-queue-selector"; + kind: "weightedAllocation"; } /** Contains the weight percentage and queue selectors to be applied if selected for weighted distributions. */ @@ -176,7 +181,8 @@ export interface WorkerSelectorAttachmentParent { } /** Describes a set of worker selectors that will be attached if the given condition resolves to true */ -export interface ConditionalWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { +export interface ConditionalWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { /** The condition that must be true for the worker selectors to be attached */ condition: RouterRule; /** The worker selectors to attach */ @@ -204,7 +210,8 @@ export interface RouterWorkerSelector { } /** Attaches a worker selector where the value is passed through from the job label with the same key */ -export interface PassThroughWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { +export interface PassThroughWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { /** The label key to query against */ key: string; /** @@ -216,19 +223,21 @@ export interface PassThroughWorkerSelectorAttachment extends WorkerSelectorAttac /** Describes how long the attached label selector is valid in seconds. */ expiresAfterSeconds?: number; /** The type discriminator describing the type of worker selector attachment */ - kind: "pass-through"; + kind: "passThrough"; } /** Attaches worker selectors to a job when a RouterRule is resolved */ -export interface RuleEngineWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { +export interface RuleEngineWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { /** A RouterRule that resolves a collection of worker selectors to attach */ rule: RouterRule; /** The type discriminator describing the type of worker selector attachment */ - kind: "rule-engine"; + kind: "ruleEngine"; } /** Describes a worker selector that will be attached to the job */ -export interface StaticWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { +export interface StaticWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { /** The worker selector to attach. */ workerSelector: RouterWorkerSelector; /** The type discriminator describing the type of worker selector attachment */ @@ -236,11 +245,12 @@ export interface StaticWorkerSelectorAttachment extends WorkerSelectorAttachment } /** Describes multiple sets of worker selectors, of which one will be selected and attached according to a weighting */ -export interface WeightedAllocationWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { +export interface WeightedAllocationWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { /** A collection of percentage based weighted allocations. */ allocations: Array; /** The type discriminator describing the type of worker selector attachment */ - kind: "weighted-allocation-worker-selector"; + kind: "weightedAllocation"; } /** Contains the weight percentage and worker selectors to be applied if selected for weighted distributions. */ @@ -279,7 +289,7 @@ export interface BestWorkerMode extends DistributionModeParent { /** Options to configure 'scoringRule'. If not set, default values are used. */ scoringRuleOptions?: ScoringRuleOptions; /** The type discriminator describing a sub-type of Mode */ - kind: "best-worker"; + kind: "bestWorker"; } /** Encapsulates all options that can be passed as parameters for scoring rule with BestWorkerMode */ @@ -297,13 +307,13 @@ export interface ScoringRuleOptions { /** Jobs are directed to the worker who has been idle longest. */ export interface LongestIdleMode extends DistributionModeParent { /** The type discriminator describing a sub-type of Mode */ - kind: "longest-idle"; + kind: "longestIdle"; } /** Jobs are distributed in order to workers, starting with the worker that is after the last worker to receive a job. */ export interface RoundRobinMode extends DistributionModeParent { /** The type discriminator describing a sub-type of Mode */ - kind: "round-robin"; + kind: "roundRobin"; } /** A policy that defines actions to execute when exception are triggered. */ @@ -334,7 +344,7 @@ export interface QueueLengthExceptionTrigger extends ExceptionTriggerParent { /** Threshold of number of jobs ahead in the queue to for this trigger to fire. */ threshold: number; /** The type discriminator describing a sub-type of ExceptionTrigger */ - kind: "queue-length"; + kind: "queueLength"; } /** Trigger for an exception action on exceeding wait time */ @@ -342,7 +352,7 @@ export interface WaitTimeExceptionTrigger extends ExceptionTriggerParent { /** Threshold for wait time for this trigger. */ thresholdSeconds: number; /** The type discriminator describing a sub-type of ExceptionTrigger */ - kind: "wait-time"; + kind: "waitTime"; } /** The action to take when the exception is triggered */ @@ -371,7 +381,7 @@ export interface ManualReclassifyExceptionAction extends ExceptionActionParent { /** Updated WorkerSelectors. */ workerSelectors?: Array; /** The type discriminator describing a sub-type of ExceptionAction */ - kind: "manual-reclassify"; + kind: "manualReclassify"; } /** An action that modifies labels on a job and then reclassifies it */ @@ -457,13 +467,13 @@ export interface ScheduleAndSuspendMode extends JobMatchingModeParent { /** Scheduled time. */ scheduleAt: Date | string; /** The type discriminator describing ScheduleAndSuspendMode */ - kind: "schedule-and-suspend"; + kind: "scheduleAndSuspend"; } /** Describes a matching mode where matching worker to a job is automatically started after job is queued successfully. */ export interface QueueAndMatchMode extends JobMatchingModeParent { /** The type discriminator describing QueueAndMatchMode */ - kind: "queue-and-match"; + kind: "queueAndMatch"; } /** Describes a matching mode where matching worker to a job is suspended. */ @@ -590,9 +600,14 @@ export type WorkerSelectorAttachment = | StaticWorkerSelectorAttachment | WeightedAllocationWorkerSelectorAttachment; /** Abstract base class for defining a distribution mode */ -export type DistributionMode = BestWorkerMode | LongestIdleMode | RoundRobinMode; +export type DistributionMode = + | BestWorkerMode + | LongestIdleMode + | RoundRobinMode; /** The trigger for this exception rule */ -export type ExceptionTrigger = QueueLengthExceptionTrigger | WaitTimeExceptionTrigger; +export type ExceptionTrigger = + | QueueLengthExceptionTrigger + | WaitTimeExceptionTrigger; /** The action to take when the exception is triggered */ export type ExceptionAction = | CancelExceptionAction @@ -604,4 +619,7 @@ export type ExceptionAction = * ScheduleAndSuspendMode: Used for scheduling jobs to be queued at a future time. At specified time, matching of a worker to the job will not start automatically. * SuspendMode: Used when matching workers to a job needs to be suspended. */ -export type JobMatchingMode = ScheduleAndSuspendMode | QueueAndMatchMode | SuspendMode; +export type JobMatchingMode = + | ScheduleAndSuspendMode + | QueueAndMatchMode + | SuspendMode; diff --git a/sdk/communication/communication-job-router-rest/src/outputModels.ts b/sdk/communication/communication-job-router-rest/src/outputModels.ts index da68872fc720..4c21e42fb9ad 100644 --- a/sdk/communication/communication-job-router-rest/src/outputModels.ts +++ b/sdk/communication/communication-job-router-rest/src/outputModels.ts @@ -52,7 +52,7 @@ export interface RouterRuleOutputParent { /** A rule that return the same labels as the input labels. */ export interface DirectMapRouterRuleOutput extends RouterRuleOutputParent { /** The type discriminator describing a sub-type of Rule */ - kind: "direct-map-rule"; + kind: "directMap"; } /** A rule providing inline expression rules. */ @@ -66,7 +66,7 @@ export interface ExpressionRouterRuleOutput extends RouterRuleOutputParent { /** The string containing the expression to evaluate. Should contain return statement with calculated values. */ expression: string; /** The type discriminator describing a sub-type of Rule */ - kind: "expression-rule"; + kind: "expression"; } /** A rule providing a binding to an HTTP Triggered Azure Function. */ @@ -76,7 +76,7 @@ export interface FunctionRouterRuleOutput extends RouterRuleOutputParent { /** Credentials used to access Azure function rule */ credential?: FunctionRouterRuleCredentialOutput; /** The type discriminator describing a sub-type of Rule */ - kind: "azure-function-rule"; + kind: "function"; } /** Credentials used to access Azure function rule */ @@ -94,7 +94,7 @@ export interface StaticRouterRuleOutput extends RouterRuleOutputParent { /** The static value this rule always returns. Values must be primitive values - number, string, boolean. */ value?: any; /** The type discriminator describing a sub-type of Rule */ - kind: "static-rule"; + kind: "static"; } /** A rule providing a binding to an external web server. */ @@ -106,7 +106,7 @@ export interface WebhookRouterRuleOutput extends RouterRuleOutputParent { /** Uri for Contoso's Web Server. */ webhookUri?: string; /** The type discriminator describing a sub-type of Rule */ - kind: "webhook-rule"; + kind: "webhook"; } /** OAuth2.0 Credentials used to Contoso's Authorization server. Reference: https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/ */ @@ -143,7 +143,7 @@ export interface PassThroughQueueSelectorAttachmentOutput */ labelOperator: string; /** The type discriminator describing the type of queue selector attachment */ - kind: "pass-through"; + kind: "passThrough"; } /** Attaches queue selectors to a job when the RouterRule is resolved */ @@ -152,11 +152,12 @@ export interface RuleEngineQueueSelectorAttachmentOutput /** A RouterRule that resolves a collection of queue selectors to attach */ rule: RouterRuleOutput; /** The type discriminator describing the type of queue selector attachment */ - kind: "rule-engine"; + kind: "ruleEngine"; } /** Describes a queue selector that will be attached to the job */ -export interface StaticQueueSelectorAttachmentOutput extends QueueSelectorAttachmentOutputParent { +export interface StaticQueueSelectorAttachmentOutput + extends QueueSelectorAttachmentOutputParent { /** The queue selector to attach. */ queueSelector: RouterQueueSelectorOutput; /** The type discriminator describing the type of queue selector attachment */ @@ -169,7 +170,7 @@ export interface WeightedAllocationQueueSelectorAttachmentOutput /** A collection of percentage based weighted allocations. */ allocations: Array; /** The type discriminator describing the type of queue selector attachment */ - kind: "weighted-allocation-queue-selector"; + kind: "weightedAllocation"; } /** Contains the weight percentage and queue selectors to be applied if selected for weighted distributions. */ @@ -236,7 +237,7 @@ export interface PassThroughWorkerSelectorAttachmentOutput /** Describes how long the attached label selector is valid in seconds. */ expiresAfterSeconds?: number; /** The type discriminator describing the type of worker selector attachment */ - kind: "pass-through"; + kind: "passThrough"; } /** Attaches worker selectors to a job when a RouterRule is resolved */ @@ -245,11 +246,12 @@ export interface RuleEngineWorkerSelectorAttachmentOutput /** A RouterRule that resolves a collection of worker selectors to attach */ rule: RouterRuleOutput; /** The type discriminator describing the type of worker selector attachment */ - kind: "rule-engine"; + kind: "ruleEngine"; } /** Describes a worker selector that will be attached to the job */ -export interface StaticWorkerSelectorAttachmentOutput extends WorkerSelectorAttachmentOutputParent { +export interface StaticWorkerSelectorAttachmentOutput + extends WorkerSelectorAttachmentOutputParent { /** The worker selector to attach. */ workerSelector: RouterWorkerSelectorOutput; /** The type discriminator describing the type of worker selector attachment */ @@ -262,7 +264,7 @@ export interface WeightedAllocationWorkerSelectorAttachmentOutput /** A collection of percentage based weighted allocations. */ allocations: Array; /** The type discriminator describing the type of worker selector attachment */ - kind: "weighted-allocation-worker-selector"; + kind: "weightedAllocation"; } /** Contains the weight percentage and worker selectors to be applied if selected for weighted distributions. */ @@ -308,7 +310,7 @@ export interface BestWorkerModeOutput extends DistributionModeOutputParent { /** Options to configure 'scoringRule'. If not set, default values are used. */ scoringRuleOptions?: ScoringRuleOptionsOutput; /** The type discriminator describing a sub-type of Mode */ - kind: "best-worker"; + kind: "bestWorker"; } /** Encapsulates all options that can be passed as parameters for scoring rule with BestWorkerMode */ @@ -326,13 +328,13 @@ export interface ScoringRuleOptionsOutput { /** Jobs are directed to the worker who has been idle longest. */ export interface LongestIdleModeOutput extends DistributionModeOutputParent { /** The type discriminator describing a sub-type of Mode */ - kind: "longest-idle"; + kind: "longestIdle"; } /** Jobs are distributed in order to workers, starting with the worker that is after the last worker to receive a job. */ export interface RoundRobinModeOutput extends DistributionModeOutputParent { /** The type discriminator describing a sub-type of Mode */ - kind: "round-robin"; + kind: "roundRobin"; } /** A policy that defines actions to execute when exception are triggered. */ @@ -363,19 +365,21 @@ export interface ExceptionTriggerOutputParent { } /** Trigger for an exception action on exceeding queue length */ -export interface QueueLengthExceptionTriggerOutput extends ExceptionTriggerOutputParent { +export interface QueueLengthExceptionTriggerOutput + extends ExceptionTriggerOutputParent { /** Threshold of number of jobs ahead in the queue to for this trigger to fire. */ threshold: number; /** The type discriminator describing a sub-type of ExceptionTrigger */ - kind: "queue-length"; + kind: "queueLength"; } /** Trigger for an exception action on exceeding wait time */ -export interface WaitTimeExceptionTriggerOutput extends ExceptionTriggerOutputParent { +export interface WaitTimeExceptionTriggerOutput + extends ExceptionTriggerOutputParent { /** Threshold for wait time for this trigger. */ thresholdSeconds: number; /** The type discriminator describing a sub-type of ExceptionTrigger */ - kind: "wait-time"; + kind: "waitTime"; } /** The action to take when the exception is triggered */ @@ -386,7 +390,8 @@ export interface ExceptionActionOutputParent { } /** An action that marks a job as cancelled */ -export interface CancelExceptionActionOutput extends ExceptionActionOutputParent { +export interface CancelExceptionActionOutput + extends ExceptionActionOutputParent { /** A note that will be appended to the jobs' Notes collection with the current timestamp. */ note?: string; /** Indicates the outcome of the job, populate this field with your own custom values. */ @@ -396,7 +401,8 @@ export interface CancelExceptionActionOutput extends ExceptionActionOutputParent } /** An action that manually reclassifies a job by providing the queue, priority and worker selectors. */ -export interface ManualReclassifyExceptionActionOutput extends ExceptionActionOutputParent { +export interface ManualReclassifyExceptionActionOutput + extends ExceptionActionOutputParent { /** Updated QueueId. */ queueId?: string; /** Updated Priority. */ @@ -404,11 +410,12 @@ export interface ManualReclassifyExceptionActionOutput extends ExceptionActionOu /** Updated WorkerSelectors. */ workerSelectors?: Array; /** The type discriminator describing a sub-type of ExceptionAction */ - kind: "manual-reclassify"; + kind: "manualReclassify"; } /** An action that modifies labels on a job and then reclassifies it */ -export interface ReclassifyExceptionActionOutput extends ExceptionActionOutputParent { +export interface ReclassifyExceptionActionOutput + extends ExceptionActionOutputParent { /** The new classification policy that will determine queue, priority and worker selectors. */ classificationPolicyId?: string; /** Dictionary containing the labels to update (or add if not existing) in key-value pairs. Values must be primitive values - number, string, boolean. */ @@ -510,17 +517,18 @@ export interface JobMatchingModeOutputParent { } /** Describes a matching mode used for scheduling jobs to be queued at a future time. At the specified time, matching worker to a job will not start automatically. */ -export interface ScheduleAndSuspendModeOutput extends JobMatchingModeOutputParent { +export interface ScheduleAndSuspendModeOutput + extends JobMatchingModeOutputParent { /** Scheduled time. */ scheduleAt: string; /** The type discriminator describing ScheduleAndSuspendMode */ - kind: "schedule-and-suspend"; + kind: "scheduleAndSuspend"; } /** Describes a matching mode where matching worker to a job is automatically started after job is queued successfully. */ export interface QueueAndMatchModeOutput extends JobMatchingModeOutputParent { /** The type discriminator describing QueueAndMatchMode */ - kind: "queue-and-match"; + kind: "queueAndMatch"; } /** Describes a matching mode where matching worker to a job is suspended. */ diff --git a/sdk/communication/communication-job-router-rest/src/paginateHelper.ts b/sdk/communication/communication-job-router-rest/src/paginateHelper.ts index 477bace4a37f..1c9af35b1efd 100644 --- a/sdk/communication/communication-job-router-rest/src/paginateHelper.ts +++ b/sdk/communication/communication-job-router-rest/src/paginateHelper.ts @@ -1,8 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from "@azure/core-paging"; -import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; +import { + getPagedAsyncIterator, + PagedAsyncIterableIterator, + PagedResult, +} from "@azure/core-paging"; +import { + Client, + createRestError, + PathUncheckedResponse, +} from "@azure-rest/core-client"; /** * Helper type to extract the type of an array @@ -67,7 +75,9 @@ export function paginate( typeof customGetPage === "function" ? customGetPage : async (pageLink: string) => { - const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get(); + const result = firstRun + ? initialResponse + : await client.pathUnchecked(pageLink).get(); firstRun = false; checkPagingRequest(result); const nextLink = getNextLink(result.body, nextLinkName); @@ -93,7 +103,9 @@ function getNextLink(body: unknown, nextLinkName?: string): string | undefined { const nextLink = (body as Record)[nextLinkName]; if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { - throw new Error(`Body Property ${nextLinkName} should be a string or undefined`); + throw new Error( + `Body Property ${nextLinkName} should be a string or undefined` + ); } return nextLink; @@ -121,7 +133,18 @@ function getElements(body: unknown, itemName: string): T[] { * Checks if a request failed */ function checkPagingRequest(response: PathUncheckedResponse): void { - const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"]; + const Http2xxStatusCodes = [ + "200", + "201", + "202", + "203", + "204", + "205", + "206", + "207", + "208", + "226", + ]; if (!Http2xxStatusCodes.includes(response.status)) { throw createRestError( `Pagination failed with unexpected statusCode ${response.status}`, diff --git a/sdk/communication/communication-job-router-rest/src/parameters.ts b/sdk/communication/communication-job-router-rest/src/parameters.ts index 7cbd94ee9036..bfe9cf135261 100644 --- a/sdk/communication/communication-job-router-rest/src/parameters.ts +++ b/sdk/communication/communication-job-router-rest/src/parameters.ts @@ -26,7 +26,8 @@ export interface UpsertClassificationPolicyHeaders { } /** The resource instance. */ -export type ClassificationPolicyResourceMergeAndPatch = Partial; +export type ClassificationPolicyResourceMergeAndPatch = + Partial; export interface UpsertClassificationPolicyBodyParam { /** The resource instance. */ @@ -42,10 +43,11 @@ export interface UpsertClassificationPolicyMediaTypesParam { contentType: "application/merge-patch+json"; } -export type UpsertClassificationPolicyParameters = UpsertClassificationPolicyHeaderParam & - UpsertClassificationPolicyMediaTypesParam & - UpsertClassificationPolicyBodyParam & - RequestParameters; +export type UpsertClassificationPolicyParameters = + UpsertClassificationPolicyHeaderParam & + UpsertClassificationPolicyMediaTypesParam & + UpsertClassificationPolicyBodyParam & + RequestParameters; export type GetClassificationPolicyParameters = RequestParameters; export type DeleteClassificationPolicyParameters = RequestParameters; @@ -58,8 +60,8 @@ export interface ListClassificationPoliciesQueryParam { queryParameters?: ListClassificationPoliciesQueryParamProperties; } -export type ListClassificationPoliciesParameters = ListClassificationPoliciesQueryParam & - RequestParameters; +export type ListClassificationPoliciesParameters = + ListClassificationPoliciesQueryParam & RequestParameters; export interface UpsertDistributionPolicyHeaders { /** The request should only proceed if an entity matches this string. */ @@ -69,7 +71,8 @@ export interface UpsertDistributionPolicyHeaders { } /** The resource instance. */ -export type DistributionPolicyResourceMergeAndPatch = Partial; +export type DistributionPolicyResourceMergeAndPatch = + Partial; export interface UpsertDistributionPolicyBodyParam { /** The resource instance. */ @@ -85,10 +88,11 @@ export interface UpsertDistributionPolicyMediaTypesParam { contentType: "application/merge-patch+json"; } -export type UpsertDistributionPolicyParameters = UpsertDistributionPolicyHeaderParam & - UpsertDistributionPolicyMediaTypesParam & - UpsertDistributionPolicyBodyParam & - RequestParameters; +export type UpsertDistributionPolicyParameters = + UpsertDistributionPolicyHeaderParam & + UpsertDistributionPolicyMediaTypesParam & + UpsertDistributionPolicyBodyParam & + RequestParameters; export type GetDistributionPolicyParameters = RequestParameters; export type DeleteDistributionPolicyParameters = RequestParameters; @@ -101,8 +105,8 @@ export interface ListDistributionPoliciesQueryParam { queryParameters?: ListDistributionPoliciesQueryParamProperties; } -export type ListDistributionPoliciesParameters = ListDistributionPoliciesQueryParam & - RequestParameters; +export type ListDistributionPoliciesParameters = + ListDistributionPoliciesQueryParam & RequestParameters; export interface UpsertExceptionPolicyHeaders { /** The request should only proceed if an entity matches this string. */ @@ -144,7 +148,8 @@ export interface ListExceptionPoliciesQueryParam { queryParameters?: ListExceptionPoliciesQueryParamProperties; } -export type ListExceptionPoliciesParameters = ListExceptionPoliciesQueryParam & RequestParameters; +export type ListExceptionPoliciesParameters = ListExceptionPoliciesQueryParam & + RequestParameters; export interface UpsertQueueHeaders { /** The request should only proceed if an entity matches this string. */ diff --git a/sdk/communication/communication-job-router-rest/src/responses.ts b/sdk/communication/communication-job-router-rest/src/responses.ts index 30419fb969e0..8ccef12cd469 100644 --- a/sdk/communication/communication-job-router-rest/src/responses.ts +++ b/sdk/communication/communication-job-router-rest/src/responses.ts @@ -60,7 +60,8 @@ export interface UpsertClassificationPolicyDefaultHeaders { "x-ms-error-code"?: string; } -export interface UpsertClassificationPolicyDefaultResponse extends HttpResponse { +export interface UpsertClassificationPolicyDefaultResponse + extends HttpResponse { status: string; body: ErrorResponse; headers: RawHttpHeaders & UpsertClassificationPolicyDefaultHeaders; @@ -101,7 +102,8 @@ export interface DeleteClassificationPolicyDefaultHeaders { "x-ms-error-code"?: string; } -export interface DeleteClassificationPolicyDefaultResponse extends HttpResponse { +export interface DeleteClassificationPolicyDefaultResponse + extends HttpResponse { status: string; body: ErrorResponse; headers: RawHttpHeaders & DeleteClassificationPolicyDefaultHeaders; @@ -118,7 +120,8 @@ export interface ListClassificationPoliciesDefaultHeaders { "x-ms-error-code"?: string; } -export interface ListClassificationPoliciesDefaultResponse extends HttpResponse { +export interface ListClassificationPoliciesDefaultResponse + extends HttpResponse { status: string; body: ErrorResponse; headers: RawHttpHeaders & ListClassificationPoliciesDefaultHeaders; diff --git a/sdk/communication/communication-job-router-rest/tsconfig.json b/sdk/communication/communication-job-router-rest/tsconfig.json index 064a66156b54..d5bf593423c9 100644 --- a/sdk/communication/communication-job-router-rest/tsconfig.json +++ b/sdk/communication/communication-job-router-rest/tsconfig.json @@ -1,5 +1,11 @@ { "extends": "../../../tsconfig.package", - "compilerOptions": { "outDir": "./dist-esm", "declarationDir": "./types" }, - "include": ["src/**/*.ts", "./test/**/*.ts"] -} + "compilerOptions": { + "outDir": "./dist-esm", + "declarationDir": "./types" + }, + "include": [ + "src/**/*.ts", + "./test/**/*.ts" + ] +} \ No newline at end of file diff --git a/sdk/communication/communication-job-router-rest/tsp-location.yaml b/sdk/communication/communication-job-router-rest/tsp-location.yaml index d1ed2308cde1..c7e9930db7af 100644 --- a/sdk/communication/communication-job-router-rest/tsp-location.yaml +++ b/sdk/communication/communication-job-router-rest/tsp-location.yaml @@ -1,7 +1,5 @@ -repo: - Azure/azure-rest-api-specs +commit: 952ffd9739be86e9c82c309f12c5c4449b126ca4 additionalDirectories: [] -directory: - specification/communication/Communication.JobRouter -commit: - de1ef0678497c007ddc66fcc42bbc96043fe029f \ No newline at end of file +repo: Azure/azure-rest-api-specs +directory: specification/communication/Communication.JobRouter +