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 e550e0bff042..a7a2a30c7ed4 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 40f180178d8b..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 { @@ -279,10 +277,7 @@ export interface ConditionalWorkerSelectorAttachmentOutput extends WorkerSelecto } // @public -function createClient(connectionString: 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) diff --git a/sdk/communication/communication-job-router-rest/src/azureCommunicationRoutingServiceClient.ts b/sdk/communication/communication-job-router-rest/src/azureCommunicationRoutingServiceClient.ts index 698e283615e5..4e9b85122be3 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 connectionString - The connectionString or url of your Communication Services resource. - * @param options - the parameter for all optional parameters - */ -export default function createClient( - connectionString: string, - options: ClientOptions -): AzureCommunicationRoutingServiceClient; - -/** - * Initialize a new instance of `AzureCommunicationRoutingServiceClient` - * @param endpoint - The endpoint of your Communication Services resource. - * @param credentialOrOptions The key or token credential. + * @param endpoint - Uri of your Communication resource * @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.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 9a4800cf7d92..83c2d75070c6 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 b9c8bd0bf93e..1a4834290266 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. */ @@ -125,7 +126,8 @@ export interface RouterQueueSelector { } /** Attaches a queue selector where the value is passed through from a job's label with the same key. */ -export interface PassThroughQueueSelectorAttachment extends QueueSelectorAttachmentParent { +export interface PassThroughQueueSelectorAttachment + extends QueueSelectorAttachmentParent { /** The label key to query against. */ key: string; /** @@ -139,7 +141,8 @@ export interface PassThroughQueueSelectorAttachment extends QueueSelectorAttachm } /** 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. */ @@ -147,7 +150,8 @@ export interface RuleEngineQueueSelectorAttachment extends QueueSelectorAttachme } /** Describes a queue selector that will be attached to a 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,7 +159,8 @@ 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. */ @@ -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 a job's label with the same key. */ -export interface PassThroughWorkerSelectorAttachment extends WorkerSelectorAttachmentParent { +export interface PassThroughWorkerSelectorAttachment + extends WorkerSelectorAttachmentParent { /** The label key to query against. */ key: string; /** @@ -220,7 +227,8 @@ export interface PassThroughWorkerSelectorAttachment extends WorkerSelectorAttac } /** 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. */ @@ -228,7 +236,8 @@ export interface RuleEngineWorkerSelectorAttachment extends WorkerSelectorAttach } /** Describes a worker selector that will be attached to a 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,7 +245,8 @@ 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. */ @@ -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; /** Abstract base class for defining a trigger for exception rules. */ -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 bb24f25a1787..fdbb3974976b 100644 --- a/sdk/communication/communication-job-router-rest/src/outputModels.ts +++ b/sdk/communication/communication-job-router-rest/src/outputModels.ts @@ -156,7 +156,8 @@ export interface RuleEngineQueueSelectorAttachmentOutput } /** Describes a queue selector that will be attached to a 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. */ @@ -249,7 +250,8 @@ export interface RuleEngineWorkerSelectorAttachmentOutput } /** Describes a worker selector that will be attached to a 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. */ @@ -363,7 +365,8 @@ 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. */ @@ -371,7 +374,8 @@ export interface QueueLengthExceptionTriggerOutput extends ExceptionTriggerOutpu } /** 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. */ @@ -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 a job's notes collection with the current timestamp. */ note?: string; /** Indicates the outcome of a 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. */ @@ -408,7 +414,8 @@ export interface ManualReclassifyExceptionActionOutput extends ExceptionActionOu } /** 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,7 +517,8 @@ 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 { /** Requested schedule time. */ scheduleAt: string; /** The type discriminator describing ScheduleAndSuspendMode */ 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 a5c42cdad64f..d0adefa032ca 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: 3537d756aa5605cba02a100713a0b3dec2674866 additionalDirectories: [] -directory: - specification/communication/Communication.JobRouter -commit: - 8cd51b5240f4773621ec74346b6f5fb13f2c0e83 \ No newline at end of file +repo: Azure/azure-rest-api-specs +directory: specification/communication/Communication.JobRouter +