@azure-rest/communication-job-router 1.1.0-alpha.20241213.1 → 1.1.0-alpha.20241218.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +77 -57
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -11,7 +11,6 @@ Key links:
11
11
  - [Package (NPM)](https://www.npmjs.com/package/@azure-rest/communication-job-router)
12
12
  - [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-job-router-rest/samples)
13
13
 
14
-
15
14
  ## Getting started
16
15
 
17
16
  ### Currently supported environments
@@ -86,7 +85,8 @@ First we need to construct an `AzureCommunicationRoutingServiceClient`.
86
85
  ```js
87
86
  const JobRouterClient = require("@azure-rest/communication-job-router").default;
88
87
 
89
- const connectionString = "endpoint=https://<YOUR_ACS>.communication.azure.com/;accesskey=<YOUR_ACCESS_KEY>";
88
+ const connectionString =
89
+ "endpoint=https://<YOUR_ACS>.communication.azure.com/;accesskey=<YOUR_ACCESS_KEY>";
90
90
  const routerClient = JobRouterClient(connectionString);
91
91
  ```
92
92
 
@@ -96,18 +96,20 @@ This policy determines which workers will receive job offers as jobs are distrib
96
96
 
97
97
  ```js
98
98
  const distributionPolicyId = "distribution-policy-id-1";
99
- const distributionPolicy = await routerClient.path("/routing/distributionPolicies/{id}", distributionPolicyId).patch({
100
- contentType: "application/merge-patch+json",
101
- body: {
102
- name: "Default Distribution Policy",
103
- offerExpiresAfterSeconds: 30,
104
- mode: {
105
- kind: "longestIdle",
106
- minConcurrentOffers: 1,
107
- maxConcurrentOffers: 3,
99
+ const distributionPolicy = await routerClient
100
+ .path("/routing/distributionPolicies/{id}", distributionPolicyId)
101
+ .patch({
102
+ contentType: "application/merge-patch+json",
103
+ body: {
104
+ name: "Default Distribution Policy",
105
+ offerExpiresAfterSeconds: 30,
106
+ mode: {
107
+ kind: "longestIdle",
108
+ minConcurrentOffers: 1,
109
+ maxConcurrentOffers: 3,
110
+ },
108
111
  },
109
- }
110
- });
112
+ });
111
113
  ```
112
114
 
113
115
  ### Create a Queue
@@ -122,7 +124,7 @@ const salesQueue = await routerClient.path("/routing/queues/{id}", salesQueueId)
122
124
  distributionPolicyId: distributionPolicyId,
123
125
  name: "Main",
124
126
  labels: {},
125
- }
127
+ },
126
128
  });
127
129
  ```
128
130
 
@@ -144,7 +146,7 @@ const workerAlice = await routerClient.path("/routing/workers/{id}", workerAlice
144
146
  labels: {
145
147
  Xbox: 5,
146
148
  german: 4,
147
- name: "Alice"
149
+ name: "Alice",
148
150
  },
149
151
  channels: [
150
152
  {
@@ -156,7 +158,7 @@ const workerAlice = await routerClient.path("/routing/workers/{id}", workerAlice
156
158
  capacityCostPerJob: 100,
157
159
  },
158
160
  ],
159
- }
161
+ },
160
162
  });
161
163
 
162
164
  // Create worker "Bob".
@@ -169,7 +171,7 @@ const workerBob = await routerClient.path("/routing/workers/{id}", workerBobId).
169
171
  labels: {
170
172
  Xbox: 5,
171
173
  english: 3,
172
- name: "Alice"
174
+ name: "Alice",
173
175
  },
174
176
  channels: [
175
177
  {
@@ -181,7 +183,7 @@ const workerBob = await routerClient.path("/routing/workers/{id}", workerBobId).
181
183
  capacityCostPerJob: 100,
182
184
  },
183
185
  ],
184
- }
186
+ },
185
187
  });
186
188
  ```
187
189
 
@@ -203,7 +205,7 @@ const result = await routerClient.path("/routing/jobs/{id}", jobId).patch({
203
205
  priority: 2,
204
206
  queueId: salesQueueId,
205
207
  labels: {},
206
- }
208
+ },
207
209
  });
208
210
  ```
209
211
 
@@ -215,30 +217,32 @@ This policy classifies jobs upon creation.
215
217
 
216
218
  ```js
217
219
  const classificationPolicyId = "classification-policy-1";
218
- const classificationPolicy = await routerClient.path("/routing/classificationPolicies/{id}", classificationPolicyId).patch({
219
- contentType: "application/merge-patch+json",
220
- body: {
221
- name: "Default Classification Policy",
222
- fallbackQueueId: salesQueueId,
223
- queueSelectorAttachments: [
224
- {
225
- kind: "static",
226
- queueSelector: { key: "department", labelOperator: "equal", value: "xbox" }
220
+ const classificationPolicy = await routerClient
221
+ .path("/routing/classificationPolicies/{id}", classificationPolicyId)
222
+ .patch({
223
+ contentType: "application/merge-patch+json",
224
+ body: {
225
+ name: "Default Classification Policy",
226
+ fallbackQueueId: salesQueueId,
227
+ queueSelectorAttachments: [
228
+ {
229
+ kind: "static",
230
+ queueSelector: { key: "department", labelOperator: "equal", value: "xbox" },
231
+ },
232
+ ],
233
+ workerSelectorAttachments: [
234
+ {
235
+ kind: "static",
236
+ workerSelector: { key: "english", labelOperator: "greaterThan", value: 5 },
237
+ },
238
+ ],
239
+ prioritizationRule: {
240
+ kind: "expression",
241
+ language: "powerFx",
242
+ expression: 'If(job.department = "xbox", 2, 1)',
227
243
  },
228
- ],
229
- workerSelectorAttachments: [
230
- {
231
- kind: "static",
232
- workerSelector: { key: "english", labelOperator: "greaterThan", value: 5 }
233
- }
234
- ],
235
- prioritizationRule: {
236
- kind: "expression",
237
- language: "powerFx",
238
- expression: "If(job.department = \"xbox\", 2, 1)"
239
- }
240
- }
241
- });
244
+ },
245
+ });
242
246
  ```
243
247
 
244
248
  - Refer to our [classification concepts documentation](https://learn.microsoft.com/azure/communication-services/concepts/router/classification-concepts) to better understand queue selectors and worker selectors.
@@ -256,15 +260,15 @@ const job = await routerClient.path("/routing/jobs/{id}", jobId).patch({
256
260
  channelId: "voice",
257
261
  classificationPolicyId: classificationPolicy.body.id,
258
262
  labels: {
259
- department: "xbox"
263
+ department: "xbox",
260
264
  },
261
- }
265
+ },
262
266
  });
263
267
  ```
264
268
 
265
269
  ## Events
266
270
 
267
- Job Router events are delivered via Azure Event Grid. Refer to our [Azure Event Grid documentation](https://docs.microsoft.com/azure/event-grid/overview) to better understand Azure Event Grid.
271
+ Job Router events are delivered via Azure Event Grid. Refer to our [Azure Event Grid documentation](https://learn.microsoft.com/azure/event-grid/overview) to better understand Azure Event Grid.
268
272
 
269
273
  In the previous example:
270
274
 
@@ -340,9 +344,13 @@ Once you receive a `RouterWorkerOfferIssued` event you can accept or decline the
340
344
  - `offerId` - Id of the offer being accepted or declined.
341
345
 
342
346
  ```js
343
- const acceptResponse = await routerClient.path("/routing/workers/{workerId}/offers/{offerId}:accept", workerId, offerId).post();
347
+ const acceptResponse = await routerClient
348
+ .path("/routing/workers/{workerId}/offers/{offerId}:accept", workerId, offerId)
349
+ .post();
344
350
  // or
345
- const declineResponse = await routerClient.path("/routing/workers/{workerId}/offers/{offerId}:decline", workerId, offerId).post();
351
+ const declineResponse = await routerClient
352
+ .path("/routing/workers/{workerId}/offers/{offerId}:decline", workerId, offerId)
353
+ .post();
346
354
  ```
347
355
 
348
356
  ### Complete the Job
@@ -350,11 +358,17 @@ const declineResponse = await routerClient.path("/routing/workers/{workerId}/off
350
358
  The `assignmentId` received from the previous step's response is required to complete the job. Completing the job puts it in the wrap-up phase of its lifecycle.
351
359
 
352
360
  ```ts
353
- const completeJob = await routerClient.path("/routing/jobs/{jobId}/assignments/{assignmentId}:complete", jobId, acceptResponse.body.assignmentId).post({
354
- body: {
355
- note: `Job has been completed by ${workerId} at ${new Date()}`
356
- }
357
- });
361
+ const completeJob = await routerClient
362
+ .path(
363
+ "/routing/jobs/{jobId}/assignments/{assignmentId}:complete",
364
+ jobId,
365
+ acceptResponse.body.assignmentId,
366
+ )
367
+ .post({
368
+ body: {
369
+ note: `Job has been completed by ${workerId} at ${new Date()}`,
370
+ },
371
+ });
358
372
  ```
359
373
 
360
374
  ### Close the Job
@@ -362,11 +376,17 @@ const completeJob = await routerClient.path("/routing/jobs/{jobId}/assignments/{
362
376
  Once the worker has completed the wrap-up phase of the job we can close the job and attach a note to it for future reference.
363
377
 
364
378
  ```ts
365
- const closeJob = await routerClient.path("/routing/jobs/{jobId}/assignments/{assignmentId}:close", jobId, acceptResponse.body.assignmentId).post({
366
- body: {
367
- note: `Job has been closed by ${workerId} at ${new Date()}`
368
- }
369
- });
379
+ const closeJob = await routerClient
380
+ .path(
381
+ "/routing/jobs/{jobId}/assignments/{assignmentId}:close",
382
+ jobId,
383
+ acceptResponse.body.assignmentId,
384
+ )
385
+ .post({
386
+ body: {
387
+ note: `Job has been closed by ${workerId} at ${new Date()}`,
388
+ },
389
+ });
370
390
  ```
371
391
 
372
392
  ## Troubleshooting
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@azure-rest/communication-job-router",
3
3
  "sdk-type": "client",
4
4
  "author": "Microsoft Corporation",
5
- "version": "1.1.0-alpha.20241213.1",
5
+ "version": "1.1.0-alpha.20241218.1",
6
6
  "description": "Azure client library for Azure Communication Job Router services",
7
7
  "keywords": [
8
8
  "node",