@azure/digital-twins-core 2.0.0-alpha.20250129.1 → 2.0.0-alpha.20250130.2

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.
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 Microsoft
3
+ Copyright (c) 2023 Microsoft
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
package/README.md CHANGED
@@ -57,9 +57,9 @@ Here, we use `DefaultAzureCredential` for credentials from the package `@azure/i
57
57
  It supports different authentication mechanisms and determines the appropriate credential type based of the environment it is executing in.
58
58
  See the [readme for @azure/identity](https://www.npmjs.com/package/@azure/identity) for more information on the different authentication options you can use.
59
59
 
60
- ```javascript
61
- const { DefaultAzureCredential } = require("@azure/identity");
62
- const { DigitalTwinsClient } = require("@azure/digital-twins-core");
60
+ ```ts snippet:ReadmeSampleCreateClient_Node
61
+ import { DefaultAzureCredential } from "@azure/identity";
62
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
63
63
 
64
64
  const url = "<URL to Azure Digital Twins instance>";
65
65
  const credential = new DefaultAzureCredential();
@@ -73,7 +73,14 @@ const serviceClient = new DigitalTwinsClient(url, credential);
73
73
  In order to create models, we pass in a list of models to `createModels`.
74
74
  Here, we only create one model.
75
75
 
76
- ```javascript
76
+ ```ts snippet:ReadmeSampleCreateModels
77
+ import { DefaultAzureCredential } from "@azure/identity";
78
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
79
+
80
+ const url = "<URL to Azure Digital Twins instance>";
81
+ const credential = new DefaultAzureCredential();
82
+ const serviceClient = new DigitalTwinsClient(url, credential);
83
+
77
84
  const myComponent = {
78
85
  "@id": "dtmi:my_component;1",
79
86
  "@type": "Interface",
@@ -95,8 +102,15 @@ const models = await serviceClient.createModels([myComponent]);
95
102
 
96
103
  We use `listModels` to list all the models.
97
104
 
98
- ```javascript
99
- const models = await serviceClient.listModels();
105
+ ```ts snippet:ReadmeSampleListModels
106
+ import { DefaultAzureCredential } from "@azure/identity";
107
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
108
+
109
+ const url = "<URL to Azure Digital Twins instance>";
110
+ const credential = new DefaultAzureCredential();
111
+ const serviceClient = new DigitalTwinsClient(url, credential);
112
+
113
+ const models = serviceClient.listModels();
100
114
  for await (const model of models) {
101
115
  console.log(`Model ID: ${model.id}`);
102
116
  }
@@ -106,7 +120,14 @@ for await (const model of models) {
106
120
 
107
121
  We can get a specific model using `getModel` with the model ID.
108
122
 
109
- ```javascript
123
+ ```ts snippet:ReadmeSampleGetModel
124
+ import { DefaultAzureCredential } from "@azure/identity";
125
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
126
+
127
+ const url = "<URL to Azure Digital Twins instance>";
128
+ const credential = new DefaultAzureCredential();
129
+ const serviceClient = new DigitalTwinsClient(url, credential);
130
+
110
131
  const model = await serviceClient.getModel("<model ID>");
111
132
  ```
112
133
 
@@ -114,7 +135,14 @@ const model = await serviceClient.getModel("<model ID>");
114
135
 
115
136
  We can decommission a model using `decomissionModel` with the model ID.
116
137
 
117
- ```javascript
138
+ ```ts snippet:ReadmeSampleDecomissionModel
139
+ import { DefaultAzureCredential } from "@azure/identity";
140
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
141
+
142
+ const url = "<URL to Azure Digital Twins instance>";
143
+ const credential = new DefaultAzureCredential();
144
+ const serviceClient = new DigitalTwinsClient(url, credential);
145
+
118
146
  await serviceClient.decomissionModel("<model ID>");
119
147
  ```
120
148
 
@@ -122,7 +150,14 @@ await serviceClient.decomissionModel("<model ID>");
122
150
 
123
151
  We can delete a model using `deleteModel` with the model ID.
124
152
 
125
- ```javascript
153
+ ```ts snippet:ReadmeSampleDeleteModel
154
+ import { DefaultAzureCredential } from "@azure/identity";
155
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
156
+
157
+ const url = "<URL to Azure Digital Twins instance>";
158
+ const credential = new DefaultAzureCredential();
159
+ const serviceClient = new DigitalTwinsClient(url, credential);
160
+
126
161
  await serviceClient.deleteModel("<model ID>");
127
162
  ```
128
163
 
@@ -132,7 +167,14 @@ await serviceClient.deleteModel("<model ID>");
132
167
 
133
168
  To create a twin, you will need to provide an ID for the digital twin and a JSON string containing the digital twin object.
134
169
 
135
- ```javascript
170
+ ```ts snippet:ReadmeSampleCreateDigitalTwin
171
+ import { DefaultAzureCredential } from "@azure/identity";
172
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
173
+
174
+ const url = "<URL to Azure Digital Twins instance>";
175
+ const credential = new DefaultAzureCredential();
176
+ const serviceClient = new DigitalTwinsClient(url, credential);
177
+
136
178
  const digitalTwinId = "myTwin";
137
179
  const newTwin = "<JSON containing the digitalTwin object>";
138
180
  const createdTwin = await serviceClient.upsertDigitalTwin(digitalTwinId, newTwin);
@@ -142,7 +184,14 @@ const createdTwin = await serviceClient.upsertDigitalTwin(digitalTwinId, newTwin
142
184
 
143
185
  We can get a digital twin using `getDigitalTwin` with the digital twin ID.
144
186
 
145
- ```javascript
187
+ ```ts snippet:ReadmeSampleGetDigitalTwin
188
+ import { DefaultAzureCredential } from "@azure/identity";
189
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
190
+
191
+ const url = "<URL to Azure Digital Twins instance>";
192
+ const credential = new DefaultAzureCredential();
193
+ const serviceClient = new DigitalTwinsClient(url, credential);
194
+
146
195
  const digitalTwinId = "myTwin";
147
196
  const twin = await serviceClient.getDigitalTwin(digitalTwinId);
148
197
  console.log(`DigitalTwin's etag: ${twin.etag}`);
@@ -154,7 +203,14 @@ console.log(`DigitalTwin: ${twin}`);
154
203
  Query the Azure Digital Twins instance for digital twins using the [Azure Digital Twins query language](https://learn.microsoft.com/azure/digital-twins/how-to-query-graph).
155
204
  Here's an example of how to query for digital twins and how to iterate over the results.
156
205
 
157
- ```javascript
206
+ ```ts snippet:ReadmeSampleQueryDigitalTwins
207
+ import { DefaultAzureCredential } from "@azure/identity";
208
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
209
+
210
+ const url = "<URL to Azure Digital Twins instance>";
211
+ const credential = new DefaultAzureCredential();
212
+ const serviceClient = new DigitalTwinsClient(url, credential);
213
+
158
214
  const query = "SELECT * FROM digitaltwins";
159
215
  const queryResult = serviceClient.queryTwins(query);
160
216
  for await (const item of queryResult) {
@@ -166,7 +222,14 @@ for await (const item of queryResult) {
166
222
 
167
223
  We can delete a digital twin using `deleteDigitalTwin` with the digital twin ID.
168
224
 
169
- ```javascript
225
+ ```ts snippet:ReadmeSampleDeleteDigitalTwin
226
+ import { DefaultAzureCredential } from "@azure/identity";
227
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
228
+
229
+ const url = "<URL to Azure Digital Twins instance>";
230
+ const credential = new DefaultAzureCredential();
231
+ const serviceClient = new DigitalTwinsClient(url, credential);
232
+
170
233
  const digitalTwinId = "myTwin";
171
234
  await serviceClient.deleteDigitalTwin(digitalTwinId);
172
235
  ```
@@ -177,7 +240,14 @@ await serviceClient.deleteDigitalTwin(digitalTwinId);
177
240
 
178
241
  We can get a digital twin component using `getComponent` with the digital twin ID and the path of the component.
179
242
 
180
- ```javascript
243
+ ```ts snippet:ReadmeSampleGetComponent
244
+ import { DefaultAzureCredential } from "@azure/identity";
245
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
246
+
247
+ const url = "<URL to Azure Digital Twins instance>";
248
+ const credential = new DefaultAzureCredential();
249
+ const serviceClient = new DigitalTwinsClient(url, credential);
250
+
181
251
  const digitalTwinId = "myTwin";
182
252
  const componentPath = "Component1";
183
253
  const component = await serviceClient.getComponent(digitalTwinId, componentPath);
@@ -190,7 +260,14 @@ To update a digital twin component (i.e., replace, remove, or add a component pr
190
260
  The value of `op` is "replace", "remove", or "add", and the value of `path` is the path to the digital twin component being updated.
191
261
  For "replace" and "add" operations, the `value` property should be included with your desired value of the component property.
192
262
 
193
- ```javascript
263
+ ```ts snippet:ReadmeSampleUpdateComponent
264
+ import { DefaultAzureCredential } from "@azure/identity";
265
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
266
+
267
+ const url = "<URL to Azure Digital Twins instance>";
268
+ const credential = new DefaultAzureCredential();
269
+ const serviceClient = new DigitalTwinsClient(url, credential);
270
+
194
271
  const digitalTwinId = "myTwin";
195
272
  const componentPath = "Component1";
196
273
  const patch = {
@@ -210,7 +287,14 @@ const updateComponentResponse = await serviceClient.updateComponent(digitalTwinI
210
287
  `upsertRelationship` creates a relationship on a digital twin provided with ID of a digital twin, name of relationship (in this case, "has"), ID of an relationship (in this case "BuildingHasFloor") and the object representing the relationship to be created.
211
288
  The object must contain property with key "\$targetId" to specify the target of the relationship.
212
289
 
213
- ```javascript
290
+ ```ts snippet:ReadmeSampleCreateRelationship
291
+ import { DefaultAzureCredential } from "@azure/identity";
292
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
293
+
294
+ const url = "<URL to Azure Digital Twins instance>";
295
+ const credential = new DefaultAzureCredential();
296
+ const serviceClient = new DigitalTwinsClient(url, credential);
297
+
214
298
  const relationship = {
215
299
  $relationshipId: "BuildingHasFloor",
216
300
  $sourceId: "BuildingTwin",
@@ -230,7 +314,14 @@ await serviceClient.upsertRelationship(
230
314
 
231
315
  For a digital twin, `listRelationships` and `listIncomingRelationships` list all the relationships and all incoming relationships, respectively.
232
316
 
233
- ```javascript
317
+ ```ts snippet:ReadmeSampleListRelationships
318
+ import { DefaultAzureCredential } from "@azure/identity";
319
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
320
+
321
+ const url = "<URL to Azure Digital Twins instance>";
322
+ const credential = new DefaultAzureCredential();
323
+ const serviceClient = new DigitalTwinsClient(url, credential);
324
+
234
325
  const digitalTwinId = "myTwin";
235
326
  const relationships = serviceClient.listRelationships(digitalTwinId);
236
327
  for await (const relationship of relationships) {
@@ -238,7 +329,14 @@ for await (const relationship of relationships) {
238
329
  }
239
330
  ```
240
331
 
241
- ```javascript
332
+ ```ts snippet:ReadmeSampleListIncomingRelationships
333
+ import { DefaultAzureCredential } from "@azure/identity";
334
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
335
+
336
+ const url = "<URL to Azure Digital Twins instance>";
337
+ const credential = new DefaultAzureCredential();
338
+ const serviceClient = new DigitalTwinsClient(url, credential);
339
+
242
340
  const digitalTwinId = "myTwin";
243
341
  const incomingRelationships = serviceClient.listIncomingRelationships(digitalTwinId);
244
342
  for await (const incomingRelationship of incomingRelationships) {
@@ -253,7 +351,14 @@ for await (const incomingRelationship of incomingRelationships) {
253
351
  To create an event route, provide an ID of an event route (in this case, "myEventRouteId") and event route data containing the endpoint and optional filter like the example shown below.
254
352
  For more information on filtering events, see [this documentation](https://learn.microsoft.com/azure/digital-twins/how-to-manage-routes-apis-cli#filter-events).
255
353
 
256
- ```javascript
354
+ ```ts snippet:ReadmeSampleCreateEventRoute
355
+ import { DefaultAzureCredential } from "@azure/identity";
356
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
357
+
358
+ const url = "<URL to Azure Digital Twins instance>";
359
+ const credential = new DefaultAzureCredential();
360
+ const serviceClient = new DigitalTwinsClient(url, credential);
361
+
257
362
  const eventHubEndpointName = "myEventHubEndpointName";
258
363
  const eventRouteId = "myEventRouteId";
259
364
  const eventFilter =
@@ -265,7 +370,14 @@ await serviceClient.upsertEventRoute(eventRouteId, eventHubEndpointName, eventFi
265
370
 
266
371
  We can get an event route using `getEventRoute` with the event route ID.
267
372
 
268
- ```javascript
373
+ ```ts snippet:ReadmeSampleGetEventRoute
374
+ import { DefaultAzureCredential } from "@azure/identity";
375
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
376
+
377
+ const url = "<URL to Azure Digital Twins instance>";
378
+ const credential = new DefaultAzureCredential();
379
+ const serviceClient = new DigitalTwinsClient(url, credential);
380
+
269
381
  const eventRouteId = "myEventRouteId";
270
382
  const eventRoute = serviceClient.getEventRoute(eventRouteId);
271
383
  console.log(`EventRoute: ${eventRoute}`);
@@ -275,7 +387,14 @@ console.log(`EventRoute: ${eventRoute}`);
275
387
 
276
388
  We can list event routes using `listEventRoutes`.
277
389
 
278
- ```javascript
390
+ ```ts snippet:ReadmeSampleListEventRoutes
391
+ import { DefaultAzureCredential } from "@azure/identity";
392
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
393
+
394
+ const url = "<URL to Azure Digital Twins instance>";
395
+ const credential = new DefaultAzureCredential();
396
+ const serviceClient = new DigitalTwinsClient(url, credential);
397
+
279
398
  const eventRoutes = serviceClient.listEventRoutes();
280
399
  for await (const eventRoute of eventRoutes) {
281
400
  console.log(`EventRoute: ${eventRoute}`);
@@ -286,7 +405,14 @@ for await (const eventRoute of eventRoutes) {
286
405
 
287
406
  We can delete an event route using `deleteEventRoute` with the event route ID.
288
407
 
289
- ```javascript
408
+ ```ts snippet:ReadmeSampleDeleteEventRoute
409
+ import { DefaultAzureCredential } from "@azure/identity";
410
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
411
+
412
+ const url = "<URL to Azure Digital Twins instance>";
413
+ const credential = new DefaultAzureCredential();
414
+ const serviceClient = new DigitalTwinsClient(url, credential);
415
+
290
416
  const eventRouteId = "myEventRouteId";
291
417
  await serviceClient.deleteEventRoute(eventRouteId);
292
418
  ```
@@ -295,9 +421,16 @@ await serviceClient.deleteEventRoute(eventRouteId);
295
421
 
296
422
  To publish a telemetry message for a digital twin, you need to provide the digital twin ID, the payload, and a unique ID for the message.
297
423
 
298
- ```javascript
424
+ ```ts snippet:ReadmeSamplePublishTelemetry
425
+ import { DefaultAzureCredential } from "@azure/identity";
426
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
427
+
428
+ const url = "<URL to Azure Digital Twins instance>";
429
+ const credential = new DefaultAzureCredential();
430
+ const serviceClient = new DigitalTwinsClient(url, credential);
431
+
299
432
  const digitalTwinId = "<digital twin ID>";
300
- const telemetryPayload = '{"Telemetry1": 5}';
433
+ const telemetryPayload = { Telemetry1: 5 };
301
434
  const response = await serviceClient.publishTelemetry(
302
435
  digitalTwinId,
303
436
  telemetryPayload,
@@ -308,10 +441,17 @@ const response = await serviceClient.publishTelemetry(
308
441
  You can also publish a telemetry message for a specific component in a digital twin.
309
442
  In addition to the digital twin ID, payload, and unique message ID, you need to specify the target component path.
310
443
 
311
- ```javascript
444
+ ```ts snippet:ReadmeSamplePublishComponentTelemetry
445
+ import { DefaultAzureCredential } from "@azure/identity";
446
+ import { DigitalTwinsClient } from "@azure/digital-twins-core";
447
+
448
+ const url = "<URL to Azure Digital Twins instance>";
449
+ const credential = new DefaultAzureCredential();
450
+ const serviceClient = new DigitalTwinsClient(url, credential);
451
+
312
452
  const digitalTwinId = "<digital twin ID>";
313
453
  const componentPath = "<component path>";
314
- const telemetryPayload = '{"Telemetry1": 5}';
454
+ const telemetryPayload = { Telemetry1: 5 };
315
455
  const response = await serviceClient.publishComponentTelemetry(
316
456
  digitalTwinId,
317
457
  componentPath,
@@ -331,8 +471,8 @@ Additional examples can be found in the
331
471
 
332
472
  Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
333
473
 
334
- ```javascript
335
- const { setlogLevel } = require("@azure/logger");
474
+ ```ts snippet:SetLogLevel
475
+ import { setLogLevel } from "@azure/logger";
336
476
 
337
477
  setLogLevel("info");
338
478
  ```
@@ -21,13 +21,13 @@ export declare class DigitalTwinsClient {
21
21
  * Creates an instance of AzureDigitalTwinsAPI.
22
22
  *
23
23
  * Example usage:
24
- * ```ts
25
- * const { DigitalTwinsClient, ServiceClientCredentials } = require("@azure/digital-twins-core");
24
+ * ```ts snippet:ReadmeSampleCreateClient_Node
25
+ * import { DefaultAzureCredential } from "@azure/identity";
26
+ * import { DigitalTwinsClient } from "@azure/digital-twins-core";
26
27
  *
27
- * const client = new DigitalTwinsClient(
28
- * "<endpoint>",
29
- * new DefaultAzureCredential();
30
- * );
28
+ * const url = "<URL to Azure Digital Twins instance>";
29
+ * const credential = new DefaultAzureCredential();
30
+ * const serviceClient = new DigitalTwinsClient(url, credential);
31
31
  * ```
32
32
  * @param endpointUrl - The endpoint URL of the service.
33
33
  * @param credential - Used to authenticate requests to the service.
@@ -14,13 +14,13 @@ export class DigitalTwinsClient {
14
14
  * Creates an instance of AzureDigitalTwinsAPI.
15
15
  *
16
16
  * Example usage:
17
- * ```ts
18
- * const { DigitalTwinsClient, ServiceClientCredentials } = require("@azure/digital-twins-core");
17
+ * ```ts snippet:ReadmeSampleCreateClient_Node
18
+ * import { DefaultAzureCredential } from "@azure/identity";
19
+ * import { DigitalTwinsClient } from "@azure/digital-twins-core";
19
20
  *
20
- * const client = new DigitalTwinsClient(
21
- * "<endpoint>",
22
- * new DefaultAzureCredential();
23
- * );
21
+ * const url = "<URL to Azure Digital Twins instance>";
22
+ * const credential = new DefaultAzureCredential();
23
+ * const serviceClient = new DigitalTwinsClient(url, credential);
24
24
  * ```
25
25
  * @param endpointUrl - The endpoint URL of the service.
26
26
  * @param credential - Used to authenticate requests to the service.
@@ -1 +1 @@
1
- {"version":3,"file":"digitalTwinsClient.js","sourceRoot":"","sources":["../../src/digitalTwinsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AASlC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAiC9F,OAAO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BACpB,CAAC;gBACH,CAAC;;;;;;;;;QACH,CAAC;KAAA;IAED;;;;;;OAMG;IACI,UAAU,CACf,KAAa,EACb,UAA6B,EAAE;QAE/B,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEhD,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;SACvF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n OperationOptions,\n InternalClientPipelineOptions,\n CommonClientOptions,\n} from \"@azure/core-client\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { randomUUID } from \"@azure/core-util\";\nimport { AzureDigitalTwinsAPI as GeneratedClient } from \"./generated/azureDigitalTwinsAPI.js\";\nimport type {\n DigitalTwinsGetByIdResponse,\n DigitalTwinsAddOptionalParams,\n DigitalTwinsAddResponse,\n DigitalTwinsUpdateOptionalParams,\n DigitalTwinsUpdateResponse,\n DigitalTwinsDeleteOptionalParams,\n DigitalTwinsGetComponentResponse,\n DigitalTwinsUpdateComponentResponse,\n DigitalTwinsUpdateComponentOptionalParams,\n DigitalTwinsAddRelationshipResponse,\n DigitalTwinsAddRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipResponse,\n DigitalTwinsDeleteRelationshipOptionalParams,\n IncomingRelationship,\n DigitalTwinsGetRelationshipByIdResponse,\n DigitalTwinsModelData,\n DigitalTwinModelsGetByIdResponse,\n DigitalTwinModelsAddResponse,\n EventRoutesGetByIdResponse,\n EventRoute,\n QueryQueryTwinsResponse,\n} from \"./generated/models/index.js\";\nimport {\n DigitalTwinModelsGetByIdOptionalParams as GetModelOptions,\n DigitalTwinModelsListOptionalParams as ListModelsOptions,\n QueryQueryTwinsOptionalParams as QueryTwinsOptions,\n EventRoutesListOptionalParams as ListEventRoutesOptions,\n DigitalTwinsListRelationshipsOptionalParams as ListRelationshipsOptions,\n DigitalTwinsListIncomingRelationshipsOptionalParams as ListIncomingRelationshipsOptions,\n} from \"./generated/models/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport { logger } from \"./logger.js\";\nexport {\n GetModelOptions,\n ListModelsOptions,\n QueryTwinsOptions,\n ListEventRoutesOptions,\n ListIncomingRelationshipsOptions,\n ListRelationshipsOptions,\n};\n\n/**\n * Options for the DigitalTwinsClient class\n */\nexport interface DigitalTwinsClientOptions extends CommonClientOptions {}\n\nconst DEFAULT_DIGITALTWINS_SCOPE = \"https://digitaltwins.azure.net/.default\";\n\n/**\n * Client for Azure IoT DigitalTwins API.\n */\nexport class DigitalTwinsClient {\n /**\n * A reference to the auto-generated AzureDigitalTwinsAPI\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of AzureDigitalTwinsAPI.\n *\n * Example usage:\n * ```ts\n * const { DigitalTwinsClient, ServiceClientCredentials } = require(\"@azure/digital-twins-core\");\n *\n * const client = new DigitalTwinsClient(\n * \"<endpoint>\",\n * new DefaultAzureCredential();\n * );\n * ```\n * @param endpointUrl - The endpoint URL of the service.\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the service client.\n */\n constructor(\n endpointUrl: string,\n credential: TokenCredential,\n options: DigitalTwinsClientOptions = {},\n ) {\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\"x-ms-request-id\"],\n },\n };\n\n this.client = new GeneratedClient({\n endpoint: endpointUrl,\n credential,\n credentialScopes: DEFAULT_DIGITALTWINS_SCOPE,\n ...internalPipelineOptions,\n });\n }\n\n /**\n * Get a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param options - The operation options\n * @returns The application/json digital twin.\n */\n public getDigitalTwin(\n digitalTwinId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getById(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Create or update a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to create or update.\n * @param digitalTwinJson - The application/json digital twin to create.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n * @returns The created application/json digital twin.\n */\n public upsertDigitalTwin(\n digitalTwinId: string,\n digitalTwinJson: string,\n options: DigitalTwinsAddOptionalParams = {},\n ): Promise<DigitalTwinsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertDigitalTwin\",\n options,\n async (updatedOptions) => {\n const payload = JSON.parse(digitalTwinJson);\n return this.client.digitalTwins.add(digitalTwinId, payload, updatedOptions);\n },\n );\n }\n\n /**\n * Update a digital twin using a json patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param jsonPatch - An update specification described by JSON Patch. Updates to property values\n * and $model elements may happen in the same request. Operations are limited to add, replace and\n * remove.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateDigitalTwin(\n digitalTwinId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateOptionalParams = {},\n ): Promise<DigitalTwinsUpdateResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.update(digitalTwinId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public deleteDigitalTwin(\n digitalTwinId: string,\n options: DigitalTwinsDeleteOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.delete(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Get a component on a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being retrieved.\n * @param options - The operation options\n * @returns Json string representation of the component corresponding to the provided componentName.\n */\n public getComponent(\n digitalTwinId: string,\n componentName: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getComponent(digitalTwinId, componentName, updatedOptions);\n },\n );\n }\n\n /**\n * Update properties of a component on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's component.\n * @param enableUpdate - If true then update of an existing digital twin is enabled.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateComponent(\n digitalTwinId: string,\n componentName: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateComponentOptionalParams = {},\n ): Promise<DigitalTwinsUpdateComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateComponent(\n digitalTwinId,\n componentName,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Get a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to retrieve.\n * @param options - The operation options\n * @returns The pageable list of application/json relationships belonging to the specified digital twin.\n */\n public getRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetRelationshipByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getRelationshipById(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Create or update a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to create.\n * @param relationship - The application/json relationship to be created.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n */\n public upsertRelationship(\n digitalTwinId: string,\n relationshipId: string,\n relationship: Record<string, unknown>,\n options: DigitalTwinsAddRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsAddRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.addRelationship(\n digitalTwinId,\n relationshipId,\n relationship,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Updates the properties of a relationship on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param relationshipId - The Id of the relationship to be updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's relationship.\n * @param options - Extended operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n */\n public updateRelationship(\n digitalTwinId: string,\n relationshipId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsUpdateRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateRelationship(\n digitalTwinId,\n relationshipId,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Delete a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to delete.\n * @param options - The operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is\n\n */\n public deleteRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: DigitalTwinsDeleteRelationshipOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.deleteRelationship(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Retrieve relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listRelationships(\n digitalTwinId: string,\n options?: ListRelationshipsOptions,\n ): PagedAsyncIterableIterator<Record<string, unknown>> {\n return this.client.digitalTwins.listRelationships(digitalTwinId, options);\n }\n\n /**\n * Retrieve all incoming relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listIncomingRelationships(\n digitalTwinId: string,\n options?: ListIncomingRelationshipsOptions,\n ): PagedAsyncIterableIterator<IncomingRelationship> {\n return this.client.digitalTwins.listIncomingRelationships(digitalTwinId, options);\n }\n\n /**\n * Publish telemetry from a digital twin, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishTelemetry(\n digitalTwinId: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendTelemetry(\n digitalTwinId,\n messageId || randomUUID(),\n payload,\n {\n ...updatedOptions,\n telemetrySourceTime: new Date().toISOString(),\n },\n );\n },\n );\n }\n\n /**\n * Publish telemetry from a digital twin's component, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param componentName - The name of the DTDL component.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishComponentTelemetry(\n digitalTwinId: string,\n componentName: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishComponentTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendComponentTelemetry(\n digitalTwinId,\n componentName,\n messageId || randomUUID(),\n payload,\n { ...updatedOptions, telemetrySourceTime: new Date().toISOString() },\n );\n },\n );\n }\n\n /**\n * Get a model, including the model metadata and the model definition.\n *\n * @param modelId - The Id of the model.\n * @param options - Options for this operation\n * @returns The application/json model.\n */\n public getModel(\n modelId: string,\n options: GetModelOptions = {},\n ): Promise<DigitalTwinModelsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getModel\",\n {\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.getById(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get the list of models\n *\n * @param options - Options for listing models.\n * @returns A pageable set of application/json models.\n */\n public listModels(\n options: ListModelsOptions = {},\n ): PagedAsyncIterableIterator<DigitalTwinsModelData> {\n return this.client.digitalTwinModels.list({\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n });\n }\n\n /**\n * Create one or many\n *\n * @param dtdlModels - The set of models to create. Each string corresponds to exactly one model.\n * @param options - The operation options\n * @returns The created application/json models.\n */\n public createModels(\n dtdlModels: Array<Record<string, unknown>>,\n options: OperationOptions = {},\n ): Promise<DigitalTwinModelsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.createModels\",\n {\n ...options,\n models: dtdlModels,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.add(updatedOptions);\n },\n );\n }\n\n /**\n * Decommission a model using a json patch.\n * When a model is decommissioned, new digital twins will no longer be able to be\n * defined by this model. However, existing digital twins may continue to use this model.\n * Once a model is decommissioned, it may not be recommissioned.\n *\n * @param modelId - The Id of the model to decommission.\n * property can be replaced.\n * @param options - The operation options\n\n *\n */\n public decomissionModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n const jsonPatch = [{ op: \"replace\", path: \"/decommissioned\", value: true }];\n\n return tracingClient.withSpan(\n \"DigitalTwinsClient.decomissionModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.update(modelId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a model.\n *\n * @param modelId - The Id of the model to delete.\n * @param options - The operation options\n\n */\n public deleteModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.delete(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get an event route.\n *\n * @param modelId - The Id of the event route.\n * @param options - The operation options\n * @returns The application/json event route.\n */\n public getEventRoute(\n eventRouteId: string,\n options: OperationOptions = {},\n ): Promise<EventRoutesGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.getById(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * List the event routes in a digital twins instance.\n *\n * @param options - Options for listEventRoutes.\n * @returns The application/json event route.\n */\n public listEventRoutes(options?: ListEventRoutesOptions): PagedAsyncIterableIterator<EventRoute> {\n return this.client.eventRoutes.list(options);\n }\n\n /**\n * Create or update an event route.\n *\n * @param eventRouteId - The Id of the event route to create or update.\n * @param endpointId - The id of the endpoint this event route is bound to.\n * @param filter - An expression which describes the events which are routed to the endpoint.\n * @param options - The operation options\n\n */\n public upsertEventRoute(\n eventRouteId: string,\n endpointId: string,\n filter: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertEventRoute\",\n {\n eventRoute: {\n endpointName: endpointId,\n filter,\n },\n ...options,\n },\n async (updatedOptions) => {\n return this.client.eventRoutes.add(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Delete an event route.\n *\n * @param eventRouteId - The Id of the eventRoute to delete.\n * @param options - The operation options\n\n */\n public deleteEventRoute(eventRouteId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.delete(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Deals with the pagination of {@link query}.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n * @param continuationState - An object that indicates the position of the paginated request.\n *\n */\n private async *queryTwinsPage(\n query: string,\n options: QueryTwinsOptions,\n continuationState?: PageSettings,\n ): AsyncIterableIterator<QueryQueryTwinsResponse> {\n let { continuationToken } = continuationState ?? {};\n if (!continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n while (continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query, continuationToken }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n }\n\n /**\n * Deals with the iteration of all the available results of {@link query}.\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n */\n private async *queryTwinsAll(\n query: string,\n options: QueryTwinsOptions,\n ): AsyncIterableIterator<Record<string, unknown>> {\n for await (const page of this.queryTwinsPage(query, options)) {\n if (page.value) {\n yield* page.value;\n }\n }\n }\n\n /**\n * Query for digital twins.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Options for the query operation.\n * @returns The pageable list of query results.\n */\n public queryTwins(\n query: string,\n options: QueryTwinsOptions = {},\n ): PagedAsyncIterableIterator<Record<string, unknown>, QueryQueryTwinsResponse> {\n const iter = this.queryTwinsAll(query, options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.queryTwinsPage(query, options, settings),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"digitalTwinsClient.js","sourceRoot":"","sources":["../../src/digitalTwinsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AASlC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAiC9F,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAerC,MAAM,0BAA0B,GAAG,yCAAyC,CAAC;AAE7E;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAM7B;;;;;;;;;;;;;;;OAeG;IACH,YACE,WAAmB,EACnB,UAA2B,EAC3B,UAAqC,EAAE;QAEvC,MAAM,uBAAuB,mCACxB,OAAO,KACV,cAAc,EAAE;gBACd,MAAM,EAAE,MAAM,CAAC,IAAI;gBACnB,4BAA4B,EAAE,CAAC,iBAAiB,CAAC;aAClD,GACF,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,iBAC/B,QAAQ,EAAE,WAAW,EACrB,UAAU,EACV,gBAAgB,EAAE,0BAA0B,IACzC,uBAAuB,EAC1B,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CACnB,aAAqB,EACrB,UAA4B,EAAE;QAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,mCAAmC,EACnC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QACzE,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,iBAAiB,CACtB,aAAqB,EACrB,eAAuB,EACvB,UAAyC,EAAE;QAE3C,OAAO,a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EACb,OAA0B;;;;gBAE1B,KAAyB,eAAA,KAAA,cAAA,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA,IAAA,+DAAE,CAAC;oBAAtC,cAAmC;oBAAnC,WAAmC;oBAAjD,MAAM,IAAI,KAAA,CAAA;oBACnB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;wBACf,cAAA,KAAK,CAAC,CAAC,iBAAA,cAAA,IAAI,CAAC,KAAK,CAAA,CAAA,CAAA,CAAC;oBACpB,CAAC;gBACH,CAAC;;;;;;;;;QACH,CAAC;KAAA;IAED;;;;;;OAMG;IACI,UAAU,CACf,KAAa,EACb,UAA6B,EAAE;QAE/B,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEhD,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;SACvF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n OperationOptions,\n InternalClientPipelineOptions,\n CommonClientOptions,\n} from \"@azure/core-client\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { randomUUID } from \"@azure/core-util\";\nimport { AzureDigitalTwinsAPI as GeneratedClient } from \"./generated/azureDigitalTwinsAPI.js\";\nimport type {\n DigitalTwinsGetByIdResponse,\n DigitalTwinsAddOptionalParams,\n DigitalTwinsAddResponse,\n DigitalTwinsUpdateOptionalParams,\n DigitalTwinsUpdateResponse,\n DigitalTwinsDeleteOptionalParams,\n DigitalTwinsGetComponentResponse,\n DigitalTwinsUpdateComponentResponse,\n DigitalTwinsUpdateComponentOptionalParams,\n DigitalTwinsAddRelationshipResponse,\n DigitalTwinsAddRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipResponse,\n DigitalTwinsDeleteRelationshipOptionalParams,\n IncomingRelationship,\n DigitalTwinsGetRelationshipByIdResponse,\n DigitalTwinsModelData,\n DigitalTwinModelsGetByIdResponse,\n DigitalTwinModelsAddResponse,\n EventRoutesGetByIdResponse,\n EventRoute,\n QueryQueryTwinsResponse,\n} from \"./generated/models/index.js\";\nimport {\n DigitalTwinModelsGetByIdOptionalParams as GetModelOptions,\n DigitalTwinModelsListOptionalParams as ListModelsOptions,\n QueryQueryTwinsOptionalParams as QueryTwinsOptions,\n EventRoutesListOptionalParams as ListEventRoutesOptions,\n DigitalTwinsListRelationshipsOptionalParams as ListRelationshipsOptions,\n DigitalTwinsListIncomingRelationshipsOptionalParams as ListIncomingRelationshipsOptions,\n} from \"./generated/models/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport { logger } from \"./logger.js\";\nexport {\n GetModelOptions,\n ListModelsOptions,\n QueryTwinsOptions,\n ListEventRoutesOptions,\n ListIncomingRelationshipsOptions,\n ListRelationshipsOptions,\n};\n\n/**\n * Options for the DigitalTwinsClient class\n */\nexport interface DigitalTwinsClientOptions extends CommonClientOptions {}\n\nconst DEFAULT_DIGITALTWINS_SCOPE = \"https://digitaltwins.azure.net/.default\";\n\n/**\n * Client for Azure IoT DigitalTwins API.\n */\nexport class DigitalTwinsClient {\n /**\n * A reference to the auto-generated AzureDigitalTwinsAPI\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of AzureDigitalTwinsAPI.\n *\n * Example usage:\n * ```ts snippet:ReadmeSampleCreateClient_Node\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { DigitalTwinsClient } from \"@azure/digital-twins-core\";\n *\n * const url = \"<URL to Azure Digital Twins instance>\";\n * const credential = new DefaultAzureCredential();\n * const serviceClient = new DigitalTwinsClient(url, credential);\n * ```\n * @param endpointUrl - The endpoint URL of the service.\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the service client.\n */\n constructor(\n endpointUrl: string,\n credential: TokenCredential,\n options: DigitalTwinsClientOptions = {},\n ) {\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\"x-ms-request-id\"],\n },\n };\n\n this.client = new GeneratedClient({\n endpoint: endpointUrl,\n credential,\n credentialScopes: DEFAULT_DIGITALTWINS_SCOPE,\n ...internalPipelineOptions,\n });\n }\n\n /**\n * Get a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param options - The operation options\n * @returns The application/json digital twin.\n */\n public getDigitalTwin(\n digitalTwinId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getById(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Create or update a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to create or update.\n * @param digitalTwinJson - The application/json digital twin to create.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n * @returns The created application/json digital twin.\n */\n public upsertDigitalTwin(\n digitalTwinId: string,\n digitalTwinJson: string,\n options: DigitalTwinsAddOptionalParams = {},\n ): Promise<DigitalTwinsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertDigitalTwin\",\n options,\n async (updatedOptions) => {\n const payload = JSON.parse(digitalTwinJson);\n return this.client.digitalTwins.add(digitalTwinId, payload, updatedOptions);\n },\n );\n }\n\n /**\n * Update a digital twin using a json patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param jsonPatch - An update specification described by JSON Patch. Updates to property values\n * and $model elements may happen in the same request. Operations are limited to add, replace and\n * remove.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateDigitalTwin(\n digitalTwinId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateOptionalParams = {},\n ): Promise<DigitalTwinsUpdateResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.update(digitalTwinId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public deleteDigitalTwin(\n digitalTwinId: string,\n options: DigitalTwinsDeleteOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.delete(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Get a component on a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being retrieved.\n * @param options - The operation options\n * @returns Json string representation of the component corresponding to the provided componentName.\n */\n public getComponent(\n digitalTwinId: string,\n componentName: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getComponent(digitalTwinId, componentName, updatedOptions);\n },\n );\n }\n\n /**\n * Update properties of a component on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's component.\n * @param enableUpdate - If true then update of an existing digital twin is enabled.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateComponent(\n digitalTwinId: string,\n componentName: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateComponentOptionalParams = {},\n ): Promise<DigitalTwinsUpdateComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateComponent(\n digitalTwinId,\n componentName,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Get a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to retrieve.\n * @param options - The operation options\n * @returns The pageable list of application/json relationships belonging to the specified digital twin.\n */\n public getRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetRelationshipByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getRelationshipById(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Create or update a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to create.\n * @param relationship - The application/json relationship to be created.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n */\n public upsertRelationship(\n digitalTwinId: string,\n relationshipId: string,\n relationship: Record<string, unknown>,\n options: DigitalTwinsAddRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsAddRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.addRelationship(\n digitalTwinId,\n relationshipId,\n relationship,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Updates the properties of a relationship on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param relationshipId - The Id of the relationship to be updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's relationship.\n * @param options - Extended operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n */\n public updateRelationship(\n digitalTwinId: string,\n relationshipId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsUpdateRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateRelationship(\n digitalTwinId,\n relationshipId,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Delete a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to delete.\n * @param options - The operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is\n\n */\n public deleteRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: DigitalTwinsDeleteRelationshipOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.deleteRelationship(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Retrieve relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listRelationships(\n digitalTwinId: string,\n options?: ListRelationshipsOptions,\n ): PagedAsyncIterableIterator<Record<string, unknown>> {\n return this.client.digitalTwins.listRelationships(digitalTwinId, options);\n }\n\n /**\n * Retrieve all incoming relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listIncomingRelationships(\n digitalTwinId: string,\n options?: ListIncomingRelationshipsOptions,\n ): PagedAsyncIterableIterator<IncomingRelationship> {\n return this.client.digitalTwins.listIncomingRelationships(digitalTwinId, options);\n }\n\n /**\n * Publish telemetry from a digital twin, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishTelemetry(\n digitalTwinId: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendTelemetry(\n digitalTwinId,\n messageId || randomUUID(),\n payload,\n {\n ...updatedOptions,\n telemetrySourceTime: new Date().toISOString(),\n },\n );\n },\n );\n }\n\n /**\n * Publish telemetry from a digital twin's component, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param componentName - The name of the DTDL component.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishComponentTelemetry(\n digitalTwinId: string,\n componentName: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishComponentTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendComponentTelemetry(\n digitalTwinId,\n componentName,\n messageId || randomUUID(),\n payload,\n { ...updatedOptions, telemetrySourceTime: new Date().toISOString() },\n );\n },\n );\n }\n\n /**\n * Get a model, including the model metadata and the model definition.\n *\n * @param modelId - The Id of the model.\n * @param options - Options for this operation\n * @returns The application/json model.\n */\n public getModel(\n modelId: string,\n options: GetModelOptions = {},\n ): Promise<DigitalTwinModelsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getModel\",\n {\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.getById(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get the list of models\n *\n * @param options - Options for listing models.\n * @returns A pageable set of application/json models.\n */\n public listModels(\n options: ListModelsOptions = {},\n ): PagedAsyncIterableIterator<DigitalTwinsModelData> {\n return this.client.digitalTwinModels.list({\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n });\n }\n\n /**\n * Create one or many\n *\n * @param dtdlModels - The set of models to create. Each string corresponds to exactly one model.\n * @param options - The operation options\n * @returns The created application/json models.\n */\n public createModels(\n dtdlModels: Array<Record<string, unknown>>,\n options: OperationOptions = {},\n ): Promise<DigitalTwinModelsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.createModels\",\n {\n ...options,\n models: dtdlModels,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.add(updatedOptions);\n },\n );\n }\n\n /**\n * Decommission a model using a json patch.\n * When a model is decommissioned, new digital twins will no longer be able to be\n * defined by this model. However, existing digital twins may continue to use this model.\n * Once a model is decommissioned, it may not be recommissioned.\n *\n * @param modelId - The Id of the model to decommission.\n * property can be replaced.\n * @param options - The operation options\n\n *\n */\n public decomissionModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n const jsonPatch = [{ op: \"replace\", path: \"/decommissioned\", value: true }];\n\n return tracingClient.withSpan(\n \"DigitalTwinsClient.decomissionModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.update(modelId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a model.\n *\n * @param modelId - The Id of the model to delete.\n * @param options - The operation options\n\n */\n public deleteModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.delete(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get an event route.\n *\n * @param modelId - The Id of the event route.\n * @param options - The operation options\n * @returns The application/json event route.\n */\n public getEventRoute(\n eventRouteId: string,\n options: OperationOptions = {},\n ): Promise<EventRoutesGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.getById(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * List the event routes in a digital twins instance.\n *\n * @param options - Options for listEventRoutes.\n * @returns The application/json event route.\n */\n public listEventRoutes(options?: ListEventRoutesOptions): PagedAsyncIterableIterator<EventRoute> {\n return this.client.eventRoutes.list(options);\n }\n\n /**\n * Create or update an event route.\n *\n * @param eventRouteId - The Id of the event route to create or update.\n * @param endpointId - The id of the endpoint this event route is bound to.\n * @param filter - An expression which describes the events which are routed to the endpoint.\n * @param options - The operation options\n\n */\n public upsertEventRoute(\n eventRouteId: string,\n endpointId: string,\n filter: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertEventRoute\",\n {\n eventRoute: {\n endpointName: endpointId,\n filter,\n },\n ...options,\n },\n async (updatedOptions) => {\n return this.client.eventRoutes.add(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Delete an event route.\n *\n * @param eventRouteId - The Id of the eventRoute to delete.\n * @param options - The operation options\n\n */\n public deleteEventRoute(eventRouteId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.delete(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Deals with the pagination of {@link query}.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n * @param continuationState - An object that indicates the position of the paginated request.\n *\n */\n private async *queryTwinsPage(\n query: string,\n options: QueryTwinsOptions,\n continuationState?: PageSettings,\n ): AsyncIterableIterator<QueryQueryTwinsResponse> {\n let { continuationToken } = continuationState ?? {};\n if (!continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n while (continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query, continuationToken }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n }\n\n /**\n * Deals with the iteration of all the available results of {@link query}.\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n */\n private async *queryTwinsAll(\n query: string,\n options: QueryTwinsOptions,\n ): AsyncIterableIterator<Record<string, unknown>> {\n for await (const page of this.queryTwinsPage(query, options)) {\n if (page.value) {\n yield* page.value;\n }\n }\n }\n\n /**\n * Query for digital twins.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Options for the query operation.\n * @returns The pageable list of query results.\n */\n public queryTwins(\n query: string,\n options: QueryTwinsOptions = {},\n ): PagedAsyncIterableIterator<Record<string, unknown>, QueryQueryTwinsResponse> {\n const iter = this.queryTwinsAll(query, options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.queryTwinsPage(query, options, settings),\n };\n }\n}\n"]}
@@ -21,13 +21,13 @@ export declare class DigitalTwinsClient {
21
21
  * Creates an instance of AzureDigitalTwinsAPI.
22
22
  *
23
23
  * Example usage:
24
- * ```ts
25
- * const { DigitalTwinsClient, ServiceClientCredentials } = require("@azure/digital-twins-core");
24
+ * ```ts snippet:ReadmeSampleCreateClient_Node
25
+ * import { DefaultAzureCredential } from "@azure/identity";
26
+ * import { DigitalTwinsClient } from "@azure/digital-twins-core";
26
27
  *
27
- * const client = new DigitalTwinsClient(
28
- * "<endpoint>",
29
- * new DefaultAzureCredential();
30
- * );
28
+ * const url = "<URL to Azure Digital Twins instance>";
29
+ * const credential = new DefaultAzureCredential();
30
+ * const serviceClient = new DigitalTwinsClient(url, credential);
31
31
  * ```
32
32
  * @param endpointUrl - The endpoint URL of the service.
33
33
  * @param credential - Used to authenticate requests to the service.
@@ -17,13 +17,13 @@ class DigitalTwinsClient {
17
17
  * Creates an instance of AzureDigitalTwinsAPI.
18
18
  *
19
19
  * Example usage:
20
- * ```ts
21
- * const { DigitalTwinsClient, ServiceClientCredentials } = require("@azure/digital-twins-core");
20
+ * ```ts snippet:ReadmeSampleCreateClient_Node
21
+ * import { DefaultAzureCredential } from "@azure/identity";
22
+ * import { DigitalTwinsClient } from "@azure/digital-twins-core";
22
23
  *
23
- * const client = new DigitalTwinsClient(
24
- * "<endpoint>",
25
- * new DefaultAzureCredential();
26
- * );
24
+ * const url = "<URL to Azure Digital Twins instance>";
25
+ * const credential = new DefaultAzureCredential();
26
+ * const serviceClient = new DigitalTwinsClient(url, credential);
27
27
  * ```
28
28
  * @param endpointUrl - The endpoint URL of the service.
29
29
  * @param credential - Used to authenticate requests to the service.
@@ -1 +1 @@
1
- {"version":3,"file":"digitalTwinsClient.js","sourceRoot":"","sources":["../../src/digitalTwinsClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AASlC,gDAA8C;AAC9C,iFAA8F;AAiC9F,6CAA6C;AAC7C,2CAAqC;AAerC,MAAM,0BAA0B,GAAG,yCAAyC,CAAC;AAE7E;;GAEG;AACH,MAAa,kBAAkB;IAM7B;;;;;;;;;;;;;;;OAeG;IACH,YACE,WAAmB,EACnB,UAA2B,EAC3B,UAAqC,EAAE;QAEvC,MAAM,uBAAuB,mCACxB,OAAO,KACV,cAAc,EAAE;gBACd,MAAM,EAAE,kBAAM,CAAC,IAAI;gBACnB,4BAA4B,EAAE,CAAC,iBAAiB,CAAC;aAClD,GACF,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,8CAAe,iBAC/B,QAAQ,EAAE,WAAW,EACrB,UAAU,EACV,gBAAgB,EAAE,0BAA0B,IACzC,uBAAuB,EAC1B,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CACnB,aAAqB,EACrB,UAA4B,EAAE;QAE9B,OAAO,0BAAa,CAAC,QAAQ,CAC3B,mCAAmC,EACnC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QACzE,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,iBAAiB,CACtB,aAAqB,EACrB,eAAuB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CAAC;YACpB,CAAC;QACH,CAAC;KAAA;IAED;;;;OAIG;IACY,aAAa,CAC1B,KAAa,EACb,OAA0B;;;;gBAE1B,KAAyB,eAAA,KAAA,sBAAA,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA,IAAA,uEAAE,CAAC;oBAAtC,cAAmC;oBAAnC,WAAmC;oBAAjD,MAAM,IAAI,KAAA,CAAA;oBACnB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;wBACf,sBAAA,KAAK,CAAC,CAAC,yBAAA,sBAAA,IAAI,CAAC,KAAK,CAAA,CAAA,CAAA,CAAC;oBACpB,CAAC;gBACH,CAAC;;;;;;;;;QACH,CAAC;KAAA;IAED;;;;;;OAMG;IACI,UAAU,CACf,KAAa,EACb,UAA6B,EAAE;QAE/B,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEhD,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;SACvF,CAAC;IACJ,CAAC;CACF;AArnBD,gDAqnBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n OperationOptions,\n InternalClientPipelineOptions,\n CommonClientOptions,\n} from \"@azure/core-client\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { randomUUID } from \"@azure/core-util\";\nimport { AzureDigitalTwinsAPI as GeneratedClient } from \"./generated/azureDigitalTwinsAPI.js\";\nimport type {\n DigitalTwinsGetByIdResponse,\n DigitalTwinsAddOptionalParams,\n DigitalTwinsAddResponse,\n DigitalTwinsUpdateOptionalParams,\n DigitalTwinsUpdateResponse,\n DigitalTwinsDeleteOptionalParams,\n DigitalTwinsGetComponentResponse,\n DigitalTwinsUpdateComponentResponse,\n DigitalTwinsUpdateComponentOptionalParams,\n DigitalTwinsAddRelationshipResponse,\n DigitalTwinsAddRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipResponse,\n DigitalTwinsDeleteRelationshipOptionalParams,\n IncomingRelationship,\n DigitalTwinsGetRelationshipByIdResponse,\n DigitalTwinsModelData,\n DigitalTwinModelsGetByIdResponse,\n DigitalTwinModelsAddResponse,\n EventRoutesGetByIdResponse,\n EventRoute,\n QueryQueryTwinsResponse,\n} from \"./generated/models/index.js\";\nimport {\n DigitalTwinModelsGetByIdOptionalParams as GetModelOptions,\n DigitalTwinModelsListOptionalParams as ListModelsOptions,\n QueryQueryTwinsOptionalParams as QueryTwinsOptions,\n EventRoutesListOptionalParams as ListEventRoutesOptions,\n DigitalTwinsListRelationshipsOptionalParams as ListRelationshipsOptions,\n DigitalTwinsListIncomingRelationshipsOptionalParams as ListIncomingRelationshipsOptions,\n} from \"./generated/models/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport { logger } from \"./logger.js\";\nexport {\n GetModelOptions,\n ListModelsOptions,\n QueryTwinsOptions,\n ListEventRoutesOptions,\n ListIncomingRelationshipsOptions,\n ListRelationshipsOptions,\n};\n\n/**\n * Options for the DigitalTwinsClient class\n */\nexport interface DigitalTwinsClientOptions extends CommonClientOptions {}\n\nconst DEFAULT_DIGITALTWINS_SCOPE = \"https://digitaltwins.azure.net/.default\";\n\n/**\n * Client for Azure IoT DigitalTwins API.\n */\nexport class DigitalTwinsClient {\n /**\n * A reference to the auto-generated AzureDigitalTwinsAPI\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of AzureDigitalTwinsAPI.\n *\n * Example usage:\n * ```ts\n * const { DigitalTwinsClient, ServiceClientCredentials } = require(\"@azure/digital-twins-core\");\n *\n * const client = new DigitalTwinsClient(\n * \"<endpoint>\",\n * new DefaultAzureCredential();\n * );\n * ```\n * @param endpointUrl - The endpoint URL of the service.\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the service client.\n */\n constructor(\n endpointUrl: string,\n credential: TokenCredential,\n options: DigitalTwinsClientOptions = {},\n ) {\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\"x-ms-request-id\"],\n },\n };\n\n this.client = new GeneratedClient({\n endpoint: endpointUrl,\n credential,\n credentialScopes: DEFAULT_DIGITALTWINS_SCOPE,\n ...internalPipelineOptions,\n });\n }\n\n /**\n * Get a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param options - The operation options\n * @returns The application/json digital twin.\n */\n public getDigitalTwin(\n digitalTwinId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getById(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Create or update a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to create or update.\n * @param digitalTwinJson - The application/json digital twin to create.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n * @returns The created application/json digital twin.\n */\n public upsertDigitalTwin(\n digitalTwinId: string,\n digitalTwinJson: string,\n options: DigitalTwinsAddOptionalParams = {},\n ): Promise<DigitalTwinsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertDigitalTwin\",\n options,\n async (updatedOptions) => {\n const payload = JSON.parse(digitalTwinJson);\n return this.client.digitalTwins.add(digitalTwinId, payload, updatedOptions);\n },\n );\n }\n\n /**\n * Update a digital twin using a json patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param jsonPatch - An update specification described by JSON Patch. Updates to property values\n * and $model elements may happen in the same request. Operations are limited to add, replace and\n * remove.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateDigitalTwin(\n digitalTwinId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateOptionalParams = {},\n ): Promise<DigitalTwinsUpdateResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.update(digitalTwinId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public deleteDigitalTwin(\n digitalTwinId: string,\n options: DigitalTwinsDeleteOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.delete(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Get a component on a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being retrieved.\n * @param options - The operation options\n * @returns Json string representation of the component corresponding to the provided componentName.\n */\n public getComponent(\n digitalTwinId: string,\n componentName: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getComponent(digitalTwinId, componentName, updatedOptions);\n },\n );\n }\n\n /**\n * Update properties of a component on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's component.\n * @param enableUpdate - If true then update of an existing digital twin is enabled.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateComponent(\n digitalTwinId: string,\n componentName: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateComponentOptionalParams = {},\n ): Promise<DigitalTwinsUpdateComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateComponent(\n digitalTwinId,\n componentName,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Get a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to retrieve.\n * @param options - The operation options\n * @returns The pageable list of application/json relationships belonging to the specified digital twin.\n */\n public getRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetRelationshipByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getRelationshipById(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Create or update a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to create.\n * @param relationship - The application/json relationship to be created.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n */\n public upsertRelationship(\n digitalTwinId: string,\n relationshipId: string,\n relationship: Record<string, unknown>,\n options: DigitalTwinsAddRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsAddRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.addRelationship(\n digitalTwinId,\n relationshipId,\n relationship,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Updates the properties of a relationship on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param relationshipId - The Id of the relationship to be updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's relationship.\n * @param options - Extended operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n */\n public updateRelationship(\n digitalTwinId: string,\n relationshipId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsUpdateRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateRelationship(\n digitalTwinId,\n relationshipId,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Delete a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to delete.\n * @param options - The operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is\n\n */\n public deleteRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: DigitalTwinsDeleteRelationshipOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.deleteRelationship(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Retrieve relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listRelationships(\n digitalTwinId: string,\n options?: ListRelationshipsOptions,\n ): PagedAsyncIterableIterator<Record<string, unknown>> {\n return this.client.digitalTwins.listRelationships(digitalTwinId, options);\n }\n\n /**\n * Retrieve all incoming relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listIncomingRelationships(\n digitalTwinId: string,\n options?: ListIncomingRelationshipsOptions,\n ): PagedAsyncIterableIterator<IncomingRelationship> {\n return this.client.digitalTwins.listIncomingRelationships(digitalTwinId, options);\n }\n\n /**\n * Publish telemetry from a digital twin, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishTelemetry(\n digitalTwinId: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendTelemetry(\n digitalTwinId,\n messageId || randomUUID(),\n payload,\n {\n ...updatedOptions,\n telemetrySourceTime: new Date().toISOString(),\n },\n );\n },\n );\n }\n\n /**\n * Publish telemetry from a digital twin's component, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param componentName - The name of the DTDL component.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishComponentTelemetry(\n digitalTwinId: string,\n componentName: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishComponentTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendComponentTelemetry(\n digitalTwinId,\n componentName,\n messageId || randomUUID(),\n payload,\n { ...updatedOptions, telemetrySourceTime: new Date().toISOString() },\n );\n },\n );\n }\n\n /**\n * Get a model, including the model metadata and the model definition.\n *\n * @param modelId - The Id of the model.\n * @param options - Options for this operation\n * @returns The application/json model.\n */\n public getModel(\n modelId: string,\n options: GetModelOptions = {},\n ): Promise<DigitalTwinModelsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getModel\",\n {\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.getById(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get the list of models\n *\n * @param options - Options for listing models.\n * @returns A pageable set of application/json models.\n */\n public listModels(\n options: ListModelsOptions = {},\n ): PagedAsyncIterableIterator<DigitalTwinsModelData> {\n return this.client.digitalTwinModels.list({\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n });\n }\n\n /**\n * Create one or many\n *\n * @param dtdlModels - The set of models to create. Each string corresponds to exactly one model.\n * @param options - The operation options\n * @returns The created application/json models.\n */\n public createModels(\n dtdlModels: Array<Record<string, unknown>>,\n options: OperationOptions = {},\n ): Promise<DigitalTwinModelsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.createModels\",\n {\n ...options,\n models: dtdlModels,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.add(updatedOptions);\n },\n );\n }\n\n /**\n * Decommission a model using a json patch.\n * When a model is decommissioned, new digital twins will no longer be able to be\n * defined by this model. However, existing digital twins may continue to use this model.\n * Once a model is decommissioned, it may not be recommissioned.\n *\n * @param modelId - The Id of the model to decommission.\n * property can be replaced.\n * @param options - The operation options\n\n *\n */\n public decomissionModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n const jsonPatch = [{ op: \"replace\", path: \"/decommissioned\", value: true }];\n\n return tracingClient.withSpan(\n \"DigitalTwinsClient.decomissionModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.update(modelId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a model.\n *\n * @param modelId - The Id of the model to delete.\n * @param options - The operation options\n\n */\n public deleteModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.delete(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get an event route.\n *\n * @param modelId - The Id of the event route.\n * @param options - The operation options\n * @returns The application/json event route.\n */\n public getEventRoute(\n eventRouteId: string,\n options: OperationOptions = {},\n ): Promise<EventRoutesGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.getById(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * List the event routes in a digital twins instance.\n *\n * @param options - Options for listEventRoutes.\n * @returns The application/json event route.\n */\n public listEventRoutes(options?: ListEventRoutesOptions): PagedAsyncIterableIterator<EventRoute> {\n return this.client.eventRoutes.list(options);\n }\n\n /**\n * Create or update an event route.\n *\n * @param eventRouteId - The Id of the event route to create or update.\n * @param endpointId - The id of the endpoint this event route is bound to.\n * @param filter - An expression which describes the events which are routed to the endpoint.\n * @param options - The operation options\n\n */\n public upsertEventRoute(\n eventRouteId: string,\n endpointId: string,\n filter: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertEventRoute\",\n {\n eventRoute: {\n endpointName: endpointId,\n filter,\n },\n ...options,\n },\n async (updatedOptions) => {\n return this.client.eventRoutes.add(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Delete an event route.\n *\n * @param eventRouteId - The Id of the eventRoute to delete.\n * @param options - The operation options\n\n */\n public deleteEventRoute(eventRouteId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.delete(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Deals with the pagination of {@link query}.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n * @param continuationState - An object that indicates the position of the paginated request.\n *\n */\n private async *queryTwinsPage(\n query: string,\n options: QueryTwinsOptions,\n continuationState?: PageSettings,\n ): AsyncIterableIterator<QueryQueryTwinsResponse> {\n let { continuationToken } = continuationState ?? {};\n if (!continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n while (continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query, continuationToken }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n }\n\n /**\n * Deals with the iteration of all the available results of {@link query}.\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n */\n private async *queryTwinsAll(\n query: string,\n options: QueryTwinsOptions,\n ): AsyncIterableIterator<Record<string, unknown>> {\n for await (const page of this.queryTwinsPage(query, options)) {\n if (page.value) {\n yield* page.value;\n }\n }\n }\n\n /**\n * Query for digital twins.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Options for the query operation.\n * @returns The pageable list of query results.\n */\n public queryTwins(\n query: string,\n options: QueryTwinsOptions = {},\n ): PagedAsyncIterableIterator<Record<string, unknown>, QueryQueryTwinsResponse> {\n const iter = this.queryTwinsAll(query, options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.queryTwinsPage(query, options, settings),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"digitalTwinsClient.js","sourceRoot":"","sources":["../../src/digitalTwinsClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AASlC,gDAA8C;AAC9C,iFAA8F;AAiC9F,6CAA6C;AAC7C,2CAAqC;AAerC,MAAM,0BAA0B,GAAG,yCAAyC,CAAC;AAE7E;;GAEG;AACH,MAAa,kBAAkB;IAM7B;;;;;;;;;;;;;;;OAeG;IACH,YACE,WAAmB,EACnB,UAA2B,EAC3B,UAAqC,EAAE;QAEvC,MAAM,uBAAuB,mCACxB,OAAO,KACV,cAAc,EAAE;gBACd,MAAM,EAAE,kBAAM,CAAC,IAAI;gBACnB,4BAA4B,EAAE,CAAC,iBAAiB,CAAC;aAClD,GACF,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,8CAAe,iBAC/B,QAAQ,EAAE,WAAW,EACrB,UAAU,EACV,gBAAgB,EAAE,0BAA0B,IACzC,uBAAuB,EAC1B,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CACnB,aAAqB,EACrB,UAA4B,EAAE;QAE9B,OAAO,0BAAa,CAAC,QAAQ,CAC3B,mCAAmC,EACnC,OA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C;gBACzB,MAAM,WAAW,GAAG,sBAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE,OAAO,CAAC,CAAA,CAAC;gBAC9F,iBAAiB,GAAG,WAAW,CAAC,iBAAiB,CAAC;gBAClD,4BAAM,WAAW,CAAA,CAAC;YACpB,CAAC;QACH,CAAC;KAAA;IAED;;;;OAIG;IACY,aAAa,CAC1B,KAAa,EACb,OAA0B;;;;gBAE1B,KAAyB,eAAA,KAAA,sBAAA,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA,IAAA,uEAAE,CAAC;oBAAtC,cAAmC;oBAAnC,WAAmC;oBAAjD,MAAM,IAAI,KAAA,CAAA;oBACnB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;wBACf,sBAAA,KAAK,CAAC,CAAC,yBAAA,sBAAA,IAAI,CAAC,KAAK,CAAA,CAAA,CAAA,CAAC;oBACpB,CAAC;gBACH,CAAC;;;;;;;;;QACH,CAAC;KAAA;IAED;;;;;;OAMG;IACI,UAAU,CACf,KAAa,EACb,UAA6B,EAAE;QAE/B,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEhD,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;SACvF,CAAC;IACJ,CAAC;CACF;AArnBD,gDAqnBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n OperationOptions,\n InternalClientPipelineOptions,\n CommonClientOptions,\n} from \"@azure/core-client\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { randomUUID } from \"@azure/core-util\";\nimport { AzureDigitalTwinsAPI as GeneratedClient } from \"./generated/azureDigitalTwinsAPI.js\";\nimport type {\n DigitalTwinsGetByIdResponse,\n DigitalTwinsAddOptionalParams,\n DigitalTwinsAddResponse,\n DigitalTwinsUpdateOptionalParams,\n DigitalTwinsUpdateResponse,\n DigitalTwinsDeleteOptionalParams,\n DigitalTwinsGetComponentResponse,\n DigitalTwinsUpdateComponentResponse,\n DigitalTwinsUpdateComponentOptionalParams,\n DigitalTwinsAddRelationshipResponse,\n DigitalTwinsAddRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipResponse,\n DigitalTwinsDeleteRelationshipOptionalParams,\n IncomingRelationship,\n DigitalTwinsGetRelationshipByIdResponse,\n DigitalTwinsModelData,\n DigitalTwinModelsGetByIdResponse,\n DigitalTwinModelsAddResponse,\n EventRoutesGetByIdResponse,\n EventRoute,\n QueryQueryTwinsResponse,\n} from \"./generated/models/index.js\";\nimport {\n DigitalTwinModelsGetByIdOptionalParams as GetModelOptions,\n DigitalTwinModelsListOptionalParams as ListModelsOptions,\n QueryQueryTwinsOptionalParams as QueryTwinsOptions,\n EventRoutesListOptionalParams as ListEventRoutesOptions,\n DigitalTwinsListRelationshipsOptionalParams as ListRelationshipsOptions,\n DigitalTwinsListIncomingRelationshipsOptionalParams as ListIncomingRelationshipsOptions,\n} from \"./generated/models/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport { logger } from \"./logger.js\";\nexport {\n GetModelOptions,\n ListModelsOptions,\n QueryTwinsOptions,\n ListEventRoutesOptions,\n ListIncomingRelationshipsOptions,\n ListRelationshipsOptions,\n};\n\n/**\n * Options for the DigitalTwinsClient class\n */\nexport interface DigitalTwinsClientOptions extends CommonClientOptions {}\n\nconst DEFAULT_DIGITALTWINS_SCOPE = \"https://digitaltwins.azure.net/.default\";\n\n/**\n * Client for Azure IoT DigitalTwins API.\n */\nexport class DigitalTwinsClient {\n /**\n * A reference to the auto-generated AzureDigitalTwinsAPI\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of AzureDigitalTwinsAPI.\n *\n * Example usage:\n * ```ts snippet:ReadmeSampleCreateClient_Node\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { DigitalTwinsClient } from \"@azure/digital-twins-core\";\n *\n * const url = \"<URL to Azure Digital Twins instance>\";\n * const credential = new DefaultAzureCredential();\n * const serviceClient = new DigitalTwinsClient(url, credential);\n * ```\n * @param endpointUrl - The endpoint URL of the service.\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the service client.\n */\n constructor(\n endpointUrl: string,\n credential: TokenCredential,\n options: DigitalTwinsClientOptions = {},\n ) {\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\"x-ms-request-id\"],\n },\n };\n\n this.client = new GeneratedClient({\n endpoint: endpointUrl,\n credential,\n credentialScopes: DEFAULT_DIGITALTWINS_SCOPE,\n ...internalPipelineOptions,\n });\n }\n\n /**\n * Get a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param options - The operation options\n * @returns The application/json digital twin.\n */\n public getDigitalTwin(\n digitalTwinId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getById(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Create or update a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to create or update.\n * @param digitalTwinJson - The application/json digital twin to create.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n * @returns The created application/json digital twin.\n */\n public upsertDigitalTwin(\n digitalTwinId: string,\n digitalTwinJson: string,\n options: DigitalTwinsAddOptionalParams = {},\n ): Promise<DigitalTwinsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertDigitalTwin\",\n options,\n async (updatedOptions) => {\n const payload = JSON.parse(digitalTwinJson);\n return this.client.digitalTwins.add(digitalTwinId, payload, updatedOptions);\n },\n );\n }\n\n /**\n * Update a digital twin using a json patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param jsonPatch - An update specification described by JSON Patch. Updates to property values\n * and $model elements may happen in the same request. Operations are limited to add, replace and\n * remove.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateDigitalTwin(\n digitalTwinId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateOptionalParams = {},\n ): Promise<DigitalTwinsUpdateResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.update(digitalTwinId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public deleteDigitalTwin(\n digitalTwinId: string,\n options: DigitalTwinsDeleteOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.delete(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Get a component on a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being retrieved.\n * @param options - The operation options\n * @returns Json string representation of the component corresponding to the provided componentName.\n */\n public getComponent(\n digitalTwinId: string,\n componentName: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getComponent(digitalTwinId, componentName, updatedOptions);\n },\n );\n }\n\n /**\n * Update properties of a component on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's component.\n * @param enableUpdate - If true then update of an existing digital twin is enabled.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateComponent(\n digitalTwinId: string,\n componentName: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateComponentOptionalParams = {},\n ): Promise<DigitalTwinsUpdateComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateComponent(\n digitalTwinId,\n componentName,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Get a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to retrieve.\n * @param options - The operation options\n * @returns The pageable list of application/json relationships belonging to the specified digital twin.\n */\n public getRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetRelationshipByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getRelationshipById(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Create or update a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to create.\n * @param relationship - The application/json relationship to be created.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n */\n public upsertRelationship(\n digitalTwinId: string,\n relationshipId: string,\n relationship: Record<string, unknown>,\n options: DigitalTwinsAddRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsAddRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.addRelationship(\n digitalTwinId,\n relationshipId,\n relationship,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Updates the properties of a relationship on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param relationshipId - The Id of the relationship to be updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's relationship.\n * @param options - Extended operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n */\n public updateRelationship(\n digitalTwinId: string,\n relationshipId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsUpdateRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateRelationship(\n digitalTwinId,\n relationshipId,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Delete a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to delete.\n * @param options - The operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is\n\n */\n public deleteRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: DigitalTwinsDeleteRelationshipOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.deleteRelationship(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Retrieve relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listRelationships(\n digitalTwinId: string,\n options?: ListRelationshipsOptions,\n ): PagedAsyncIterableIterator<Record<string, unknown>> {\n return this.client.digitalTwins.listRelationships(digitalTwinId, options);\n }\n\n /**\n * Retrieve all incoming relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listIncomingRelationships(\n digitalTwinId: string,\n options?: ListIncomingRelationshipsOptions,\n ): PagedAsyncIterableIterator<IncomingRelationship> {\n return this.client.digitalTwins.listIncomingRelationships(digitalTwinId, options);\n }\n\n /**\n * Publish telemetry from a digital twin, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishTelemetry(\n digitalTwinId: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendTelemetry(\n digitalTwinId,\n messageId || randomUUID(),\n payload,\n {\n ...updatedOptions,\n telemetrySourceTime: new Date().toISOString(),\n },\n );\n },\n );\n }\n\n /**\n * Publish telemetry from a digital twin's component, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param componentName - The name of the DTDL component.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishComponentTelemetry(\n digitalTwinId: string,\n componentName: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishComponentTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendComponentTelemetry(\n digitalTwinId,\n componentName,\n messageId || randomUUID(),\n payload,\n { ...updatedOptions, telemetrySourceTime: new Date().toISOString() },\n );\n },\n );\n }\n\n /**\n * Get a model, including the model metadata and the model definition.\n *\n * @param modelId - The Id of the model.\n * @param options - Options for this operation\n * @returns The application/json model.\n */\n public getModel(\n modelId: string,\n options: GetModelOptions = {},\n ): Promise<DigitalTwinModelsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getModel\",\n {\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.getById(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get the list of models\n *\n * @param options - Options for listing models.\n * @returns A pageable set of application/json models.\n */\n public listModels(\n options: ListModelsOptions = {},\n ): PagedAsyncIterableIterator<DigitalTwinsModelData> {\n return this.client.digitalTwinModels.list({\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n });\n }\n\n /**\n * Create one or many\n *\n * @param dtdlModels - The set of models to create. Each string corresponds to exactly one model.\n * @param options - The operation options\n * @returns The created application/json models.\n */\n public createModels(\n dtdlModels: Array<Record<string, unknown>>,\n options: OperationOptions = {},\n ): Promise<DigitalTwinModelsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.createModels\",\n {\n ...options,\n models: dtdlModels,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.add(updatedOptions);\n },\n );\n }\n\n /**\n * Decommission a model using a json patch.\n * When a model is decommissioned, new digital twins will no longer be able to be\n * defined by this model. However, existing digital twins may continue to use this model.\n * Once a model is decommissioned, it may not be recommissioned.\n *\n * @param modelId - The Id of the model to decommission.\n * property can be replaced.\n * @param options - The operation options\n\n *\n */\n public decomissionModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n const jsonPatch = [{ op: \"replace\", path: \"/decommissioned\", value: true }];\n\n return tracingClient.withSpan(\n \"DigitalTwinsClient.decomissionModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.update(modelId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a model.\n *\n * @param modelId - The Id of the model to delete.\n * @param options - The operation options\n\n */\n public deleteModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.delete(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get an event route.\n *\n * @param modelId - The Id of the event route.\n * @param options - The operation options\n * @returns The application/json event route.\n */\n public getEventRoute(\n eventRouteId: string,\n options: OperationOptions = {},\n ): Promise<EventRoutesGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.getById(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * List the event routes in a digital twins instance.\n *\n * @param options - Options for listEventRoutes.\n * @returns The application/json event route.\n */\n public listEventRoutes(options?: ListEventRoutesOptions): PagedAsyncIterableIterator<EventRoute> {\n return this.client.eventRoutes.list(options);\n }\n\n /**\n * Create or update an event route.\n *\n * @param eventRouteId - The Id of the event route to create or update.\n * @param endpointId - The id of the endpoint this event route is bound to.\n * @param filter - An expression which describes the events which are routed to the endpoint.\n * @param options - The operation options\n\n */\n public upsertEventRoute(\n eventRouteId: string,\n endpointId: string,\n filter: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertEventRoute\",\n {\n eventRoute: {\n endpointName: endpointId,\n filter,\n },\n ...options,\n },\n async (updatedOptions) => {\n return this.client.eventRoutes.add(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Delete an event route.\n *\n * @param eventRouteId - The Id of the eventRoute to delete.\n * @param options - The operation options\n\n */\n public deleteEventRoute(eventRouteId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.delete(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Deals with the pagination of {@link query}.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n * @param continuationState - An object that indicates the position of the paginated request.\n *\n */\n private async *queryTwinsPage(\n query: string,\n options: QueryTwinsOptions,\n continuationState?: PageSettings,\n ): AsyncIterableIterator<QueryQueryTwinsResponse> {\n let { continuationToken } = continuationState ?? {};\n if (!continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n while (continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query, continuationToken }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n }\n\n /**\n * Deals with the iteration of all the available results of {@link query}.\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n */\n private async *queryTwinsAll(\n query: string,\n options: QueryTwinsOptions,\n ): AsyncIterableIterator<Record<string, unknown>> {\n for await (const page of this.queryTwinsPage(query, options)) {\n if (page.value) {\n yield* page.value;\n }\n }\n }\n\n /**\n * Query for digital twins.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Options for the query operation.\n * @returns The pageable list of query results.\n */\n public queryTwins(\n query: string,\n options: QueryTwinsOptions = {},\n ): PagedAsyncIterableIterator<Record<string, unknown>, QueryQueryTwinsResponse> {\n const iter = this.queryTwinsAll(query, options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.queryTwinsPage(query, options, settings),\n };\n }\n}\n"]}
@@ -21,13 +21,13 @@ export declare class DigitalTwinsClient {
21
21
  * Creates an instance of AzureDigitalTwinsAPI.
22
22
  *
23
23
  * Example usage:
24
- * ```ts
25
- * const { DigitalTwinsClient, ServiceClientCredentials } = require("@azure/digital-twins-core");
24
+ * ```ts snippet:ReadmeSampleCreateClient_Node
25
+ * import { DefaultAzureCredential } from "@azure/identity";
26
+ * import { DigitalTwinsClient } from "@azure/digital-twins-core";
26
27
  *
27
- * const client = new DigitalTwinsClient(
28
- * "<endpoint>",
29
- * new DefaultAzureCredential();
30
- * );
28
+ * const url = "<URL to Azure Digital Twins instance>";
29
+ * const credential = new DefaultAzureCredential();
30
+ * const serviceClient = new DigitalTwinsClient(url, credential);
31
31
  * ```
32
32
  * @param endpointUrl - The endpoint URL of the service.
33
33
  * @param credential - Used to authenticate requests to the service.
@@ -14,13 +14,13 @@ export class DigitalTwinsClient {
14
14
  * Creates an instance of AzureDigitalTwinsAPI.
15
15
  *
16
16
  * Example usage:
17
- * ```ts
18
- * const { DigitalTwinsClient, ServiceClientCredentials } = require("@azure/digital-twins-core");
17
+ * ```ts snippet:ReadmeSampleCreateClient_Node
18
+ * import { DefaultAzureCredential } from "@azure/identity";
19
+ * import { DigitalTwinsClient } from "@azure/digital-twins-core";
19
20
  *
20
- * const client = new DigitalTwinsClient(
21
- * "<endpoint>",
22
- * new DefaultAzureCredential();
23
- * );
21
+ * const url = "<URL to Azure Digital Twins instance>";
22
+ * const credential = new DefaultAzureCredential();
23
+ * const serviceClient = new DigitalTwinsClient(url, credential);
24
24
  * ```
25
25
  * @param endpointUrl - The endpoint URL of the service.
26
26
  * @param credential - Used to authenticate requests to the service.
@@ -1 +1 @@
1
- {"version":3,"file":"digitalTwinsClient.js","sourceRoot":"","sources":["../../src/digitalTwinsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AASlC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAiC9F,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAerC,MAAM,0BAA0B,GAAG,yCAAyC,CAAC;AAE7E;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAM7B;;;;;;;;;;;;;;;OAeG;IACH,YACE,WAAmB,EACnB,UAA2B,EAC3B,UAAqC,EAAE;QAEvC,MAAM,uBAAuB,mCACxB,OAAO,KACV,cAAc,EAAE;gBACd,MAAM,EAAE,MAAM,CAAC,IAAI;gBACnB,4BAA4B,EAAE,CAAC,iBAAiB,CAAC;aAClD,GACF,CAAC;QAEF,IAAI,CAA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AC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;SACvF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n OperationOptions,\n InternalClientPipelineOptions,\n CommonClientOptions,\n} from \"@azure/core-client\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { randomUUID } from \"@azure/core-util\";\nimport { AzureDigitalTwinsAPI as GeneratedClient } from \"./generated/azureDigitalTwinsAPI.js\";\nimport type {\n DigitalTwinsGetByIdResponse,\n DigitalTwinsAddOptionalParams,\n DigitalTwinsAddResponse,\n DigitalTwinsUpdateOptionalParams,\n DigitalTwinsUpdateResponse,\n DigitalTwinsDeleteOptionalParams,\n DigitalTwinsGetComponentResponse,\n DigitalTwinsUpdateComponentResponse,\n DigitalTwinsUpdateComponentOptionalParams,\n DigitalTwinsAddRelationshipResponse,\n DigitalTwinsAddRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipResponse,\n DigitalTwinsDeleteRelationshipOptionalParams,\n IncomingRelationship,\n DigitalTwinsGetRelationshipByIdResponse,\n DigitalTwinsModelData,\n DigitalTwinModelsGetByIdResponse,\n DigitalTwinModelsAddResponse,\n EventRoutesGetByIdResponse,\n EventRoute,\n QueryQueryTwinsResponse,\n} from \"./generated/models/index.js\";\nimport {\n DigitalTwinModelsGetByIdOptionalParams as GetModelOptions,\n DigitalTwinModelsListOptionalParams as ListModelsOptions,\n QueryQueryTwinsOptionalParams as QueryTwinsOptions,\n EventRoutesListOptionalParams as ListEventRoutesOptions,\n DigitalTwinsListRelationshipsOptionalParams as ListRelationshipsOptions,\n DigitalTwinsListIncomingRelationshipsOptionalParams as ListIncomingRelationshipsOptions,\n} from \"./generated/models/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport { logger } from \"./logger.js\";\nexport {\n GetModelOptions,\n ListModelsOptions,\n QueryTwinsOptions,\n ListEventRoutesOptions,\n ListIncomingRelationshipsOptions,\n ListRelationshipsOptions,\n};\n\n/**\n * Options for the DigitalTwinsClient class\n */\nexport interface DigitalTwinsClientOptions extends CommonClientOptions {}\n\nconst DEFAULT_DIGITALTWINS_SCOPE = \"https://digitaltwins.azure.net/.default\";\n\n/**\n * Client for Azure IoT DigitalTwins API.\n */\nexport class DigitalTwinsClient {\n /**\n * A reference to the auto-generated AzureDigitalTwinsAPI\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of AzureDigitalTwinsAPI.\n *\n * Example usage:\n * ```ts\n * const { DigitalTwinsClient, ServiceClientCredentials } = require(\"@azure/digital-twins-core\");\n *\n * const client = new DigitalTwinsClient(\n * \"<endpoint>\",\n * new DefaultAzureCredential();\n * );\n * ```\n * @param endpointUrl - The endpoint URL of the service.\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the service client.\n */\n constructor(\n endpointUrl: string,\n credential: TokenCredential,\n options: DigitalTwinsClientOptions = {},\n ) {\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\"x-ms-request-id\"],\n },\n };\n\n this.client = new GeneratedClient({\n endpoint: endpointUrl,\n credential,\n credentialScopes: DEFAULT_DIGITALTWINS_SCOPE,\n ...internalPipelineOptions,\n });\n }\n\n /**\n * Get a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param options - The operation options\n * @returns The application/json digital twin.\n */\n public getDigitalTwin(\n digitalTwinId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getById(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Create or update a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to create or update.\n * @param digitalTwinJson - The application/json digital twin to create.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n * @returns The created application/json digital twin.\n */\n public upsertDigitalTwin(\n digitalTwinId: string,\n digitalTwinJson: string,\n options: DigitalTwinsAddOptionalParams = {},\n ): Promise<DigitalTwinsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertDigitalTwin\",\n options,\n async (updatedOptions) => {\n const payload = JSON.parse(digitalTwinJson);\n return this.client.digitalTwins.add(digitalTwinId, payload, updatedOptions);\n },\n );\n }\n\n /**\n * Update a digital twin using a json patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param jsonPatch - An update specification described by JSON Patch. Updates to property values\n * and $model elements may happen in the same request. Operations are limited to add, replace and\n * remove.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateDigitalTwin(\n digitalTwinId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateOptionalParams = {},\n ): Promise<DigitalTwinsUpdateResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.update(digitalTwinId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public deleteDigitalTwin(\n digitalTwinId: string,\n options: DigitalTwinsDeleteOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.delete(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Get a component on a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being retrieved.\n * @param options - The operation options\n * @returns Json string representation of the component corresponding to the provided componentName.\n */\n public getComponent(\n digitalTwinId: string,\n componentName: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getComponent(digitalTwinId, componentName, updatedOptions);\n },\n );\n }\n\n /**\n * Update properties of a component on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's component.\n * @param enableUpdate - If true then update of an existing digital twin is enabled.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateComponent(\n digitalTwinId: string,\n componentName: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateComponentOptionalParams = {},\n ): Promise<DigitalTwinsUpdateComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateComponent(\n digitalTwinId,\n componentName,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Get a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to retrieve.\n * @param options - The operation options\n * @returns The pageable list of application/json relationships belonging to the specified digital twin.\n */\n public getRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetRelationshipByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getRelationshipById(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Create or update a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to create.\n * @param relationship - The application/json relationship to be created.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n */\n public upsertRelationship(\n digitalTwinId: string,\n relationshipId: string,\n relationship: Record<string, unknown>,\n options: DigitalTwinsAddRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsAddRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.addRelationship(\n digitalTwinId,\n relationshipId,\n relationship,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Updates the properties of a relationship on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param relationshipId - The Id of the relationship to be updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's relationship.\n * @param options - Extended operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n */\n public updateRelationship(\n digitalTwinId: string,\n relationshipId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsUpdateRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateRelationship(\n digitalTwinId,\n relationshipId,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Delete a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to delete.\n * @param options - The operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is\n\n */\n public deleteRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: DigitalTwinsDeleteRelationshipOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.deleteRelationship(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Retrieve relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listRelationships(\n digitalTwinId: string,\n options?: ListRelationshipsOptions,\n ): PagedAsyncIterableIterator<Record<string, unknown>> {\n return this.client.digitalTwins.listRelationships(digitalTwinId, options);\n }\n\n /**\n * Retrieve all incoming relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listIncomingRelationships(\n digitalTwinId: string,\n options?: ListIncomingRelationshipsOptions,\n ): PagedAsyncIterableIterator<IncomingRelationship> {\n return this.client.digitalTwins.listIncomingRelationships(digitalTwinId, options);\n }\n\n /**\n * Publish telemetry from a digital twin, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishTelemetry(\n digitalTwinId: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendTelemetry(\n digitalTwinId,\n messageId || randomUUID(),\n payload,\n {\n ...updatedOptions,\n telemetrySourceTime: new Date().toISOString(),\n },\n );\n },\n );\n }\n\n /**\n * Publish telemetry from a digital twin's component, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param componentName - The name of the DTDL component.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishComponentTelemetry(\n digitalTwinId: string,\n componentName: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishComponentTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendComponentTelemetry(\n digitalTwinId,\n componentName,\n messageId || randomUUID(),\n payload,\n { ...updatedOptions, telemetrySourceTime: new Date().toISOString() },\n );\n },\n );\n }\n\n /**\n * Get a model, including the model metadata and the model definition.\n *\n * @param modelId - The Id of the model.\n * @param options - Options for this operation\n * @returns The application/json model.\n */\n public getModel(\n modelId: string,\n options: GetModelOptions = {},\n ): Promise<DigitalTwinModelsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getModel\",\n {\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.getById(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get the list of models\n *\n * @param options - Options for listing models.\n * @returns A pageable set of application/json models.\n */\n public listModels(\n options: ListModelsOptions = {},\n ): PagedAsyncIterableIterator<DigitalTwinsModelData> {\n return this.client.digitalTwinModels.list({\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n });\n }\n\n /**\n * Create one or many\n *\n * @param dtdlModels - The set of models to create. Each string corresponds to exactly one model.\n * @param options - The operation options\n * @returns The created application/json models.\n */\n public createModels(\n dtdlModels: Array<Record<string, unknown>>,\n options: OperationOptions = {},\n ): Promise<DigitalTwinModelsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.createModels\",\n {\n ...options,\n models: dtdlModels,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.add(updatedOptions);\n },\n );\n }\n\n /**\n * Decommission a model using a json patch.\n * When a model is decommissioned, new digital twins will no longer be able to be\n * defined by this model. However, existing digital twins may continue to use this model.\n * Once a model is decommissioned, it may not be recommissioned.\n *\n * @param modelId - The Id of the model to decommission.\n * property can be replaced.\n * @param options - The operation options\n\n *\n */\n public decomissionModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n const jsonPatch = [{ op: \"replace\", path: \"/decommissioned\", value: true }];\n\n return tracingClient.withSpan(\n \"DigitalTwinsClient.decomissionModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.update(modelId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a model.\n *\n * @param modelId - The Id of the model to delete.\n * @param options - The operation options\n\n */\n public deleteModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.delete(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get an event route.\n *\n * @param modelId - The Id of the event route.\n * @param options - The operation options\n * @returns The application/json event route.\n */\n public getEventRoute(\n eventRouteId: string,\n options: OperationOptions = {},\n ): Promise<EventRoutesGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.getById(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * List the event routes in a digital twins instance.\n *\n * @param options - Options for listEventRoutes.\n * @returns The application/json event route.\n */\n public listEventRoutes(options?: ListEventRoutesOptions): PagedAsyncIterableIterator<EventRoute> {\n return this.client.eventRoutes.list(options);\n }\n\n /**\n * Create or update an event route.\n *\n * @param eventRouteId - The Id of the event route to create or update.\n * @param endpointId - The id of the endpoint this event route is bound to.\n * @param filter - An expression which describes the events which are routed to the endpoint.\n * @param options - The operation options\n\n */\n public upsertEventRoute(\n eventRouteId: string,\n endpointId: string,\n filter: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertEventRoute\",\n {\n eventRoute: {\n endpointName: endpointId,\n filter,\n },\n ...options,\n },\n async (updatedOptions) => {\n return this.client.eventRoutes.add(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Delete an event route.\n *\n * @param eventRouteId - The Id of the eventRoute to delete.\n * @param options - The operation options\n\n */\n public deleteEventRoute(eventRouteId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.delete(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Deals with the pagination of {@link query}.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n * @param continuationState - An object that indicates the position of the paginated request.\n *\n */\n private async *queryTwinsPage(\n query: string,\n options: QueryTwinsOptions,\n continuationState?: PageSettings,\n ): AsyncIterableIterator<QueryQueryTwinsResponse> {\n let { continuationToken } = continuationState ?? {};\n if (!continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n while (continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query, continuationToken }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n }\n\n /**\n * Deals with the iteration of all the available results of {@link query}.\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n */\n private async *queryTwinsAll(\n query: string,\n options: QueryTwinsOptions,\n ): AsyncIterableIterator<Record<string, unknown>> {\n for await (const page of this.queryTwinsPage(query, options)) {\n if (page.value) {\n yield* page.value;\n }\n }\n }\n\n /**\n * Query for digital twins.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Options for the query operation.\n * @returns The pageable list of query results.\n */\n public queryTwins(\n query: string,\n options: QueryTwinsOptions = {},\n ): PagedAsyncIterableIterator<Record<string, unknown>, QueryQueryTwinsResponse> {\n const iter = this.queryTwinsAll(query, options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.queryTwinsPage(query, options, settings),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"digitalTwinsClient.js","sourceRoot":"","sources":["../../src/digitalTwinsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AASlC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAiC9F,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAerC,M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UAA6B,EAAE;QAE/B,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEhD,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;SACvF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n OperationOptions,\n InternalClientPipelineOptions,\n CommonClientOptions,\n} from \"@azure/core-client\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { randomUUID } from \"@azure/core-util\";\nimport { AzureDigitalTwinsAPI as GeneratedClient } from \"./generated/azureDigitalTwinsAPI.js\";\nimport type {\n DigitalTwinsGetByIdResponse,\n DigitalTwinsAddOptionalParams,\n DigitalTwinsAddResponse,\n DigitalTwinsUpdateOptionalParams,\n DigitalTwinsUpdateResponse,\n DigitalTwinsDeleteOptionalParams,\n DigitalTwinsGetComponentResponse,\n DigitalTwinsUpdateComponentResponse,\n DigitalTwinsUpdateComponentOptionalParams,\n DigitalTwinsAddRelationshipResponse,\n DigitalTwinsAddRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipResponse,\n DigitalTwinsDeleteRelationshipOptionalParams,\n IncomingRelationship,\n DigitalTwinsGetRelationshipByIdResponse,\n DigitalTwinsModelData,\n DigitalTwinModelsGetByIdResponse,\n DigitalTwinModelsAddResponse,\n EventRoutesGetByIdResponse,\n EventRoute,\n QueryQueryTwinsResponse,\n} from \"./generated/models/index.js\";\nimport {\n DigitalTwinModelsGetByIdOptionalParams as GetModelOptions,\n DigitalTwinModelsListOptionalParams as ListModelsOptions,\n QueryQueryTwinsOptionalParams as QueryTwinsOptions,\n EventRoutesListOptionalParams as ListEventRoutesOptions,\n DigitalTwinsListRelationshipsOptionalParams as ListRelationshipsOptions,\n DigitalTwinsListIncomingRelationshipsOptionalParams as ListIncomingRelationshipsOptions,\n} from \"./generated/models/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport { logger } from \"./logger.js\";\nexport {\n GetModelOptions,\n ListModelsOptions,\n QueryTwinsOptions,\n ListEventRoutesOptions,\n ListIncomingRelationshipsOptions,\n ListRelationshipsOptions,\n};\n\n/**\n * Options for the DigitalTwinsClient class\n */\nexport interface DigitalTwinsClientOptions extends CommonClientOptions {}\n\nconst DEFAULT_DIGITALTWINS_SCOPE = \"https://digitaltwins.azure.net/.default\";\n\n/**\n * Client for Azure IoT DigitalTwins API.\n */\nexport class DigitalTwinsClient {\n /**\n * A reference to the auto-generated AzureDigitalTwinsAPI\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of AzureDigitalTwinsAPI.\n *\n * Example usage:\n * ```ts snippet:ReadmeSampleCreateClient_Node\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { DigitalTwinsClient } from \"@azure/digital-twins-core\";\n *\n * const url = \"<URL to Azure Digital Twins instance>\";\n * const credential = new DefaultAzureCredential();\n * const serviceClient = new DigitalTwinsClient(url, credential);\n * ```\n * @param endpointUrl - The endpoint URL of the service.\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the service client.\n */\n constructor(\n endpointUrl: string,\n credential: TokenCredential,\n options: DigitalTwinsClientOptions = {},\n ) {\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\"x-ms-request-id\"],\n },\n };\n\n this.client = new GeneratedClient({\n endpoint: endpointUrl,\n credential,\n credentialScopes: DEFAULT_DIGITALTWINS_SCOPE,\n ...internalPipelineOptions,\n });\n }\n\n /**\n * Get a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param options - The operation options\n * @returns The application/json digital twin.\n */\n public getDigitalTwin(\n digitalTwinId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getById(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Create or update a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to create or update.\n * @param digitalTwinJson - The application/json digital twin to create.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n * @returns The created application/json digital twin.\n */\n public upsertDigitalTwin(\n digitalTwinId: string,\n digitalTwinJson: string,\n options: DigitalTwinsAddOptionalParams = {},\n ): Promise<DigitalTwinsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertDigitalTwin\",\n options,\n async (updatedOptions) => {\n const payload = JSON.parse(digitalTwinJson);\n return this.client.digitalTwins.add(digitalTwinId, payload, updatedOptions);\n },\n );\n }\n\n /**\n * Update a digital twin using a json patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param jsonPatch - An update specification described by JSON Patch. Updates to property values\n * and $model elements may happen in the same request. Operations are limited to add, replace and\n * remove.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateDigitalTwin(\n digitalTwinId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateOptionalParams = {},\n ): Promise<DigitalTwinsUpdateResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.update(digitalTwinId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public deleteDigitalTwin(\n digitalTwinId: string,\n options: DigitalTwinsDeleteOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.delete(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Get a component on a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being retrieved.\n * @param options - The operation options\n * @returns Json string representation of the component corresponding to the provided componentName.\n */\n public getComponent(\n digitalTwinId: string,\n componentName: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getComponent(digitalTwinId, componentName, updatedOptions);\n },\n );\n }\n\n /**\n * Update properties of a component on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's component.\n * @param enableUpdate - If true then update of an existing digital twin is enabled.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateComponent(\n digitalTwinId: string,\n componentName: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateComponentOptionalParams = {},\n ): Promise<DigitalTwinsUpdateComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateComponent(\n digitalTwinId,\n componentName,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Get a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to retrieve.\n * @param options - The operation options\n * @returns The pageable list of application/json relationships belonging to the specified digital twin.\n */\n public getRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetRelationshipByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getRelationshipById(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Create or update a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to create.\n * @param relationship - The application/json relationship to be created.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n */\n public upsertRelationship(\n digitalTwinId: string,\n relationshipId: string,\n relationship: Record<string, unknown>,\n options: DigitalTwinsAddRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsAddRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.addRelationship(\n digitalTwinId,\n relationshipId,\n relationship,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Updates the properties of a relationship on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param relationshipId - The Id of the relationship to be updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's relationship.\n * @param options - Extended operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n */\n public updateRelationship(\n digitalTwinId: string,\n relationshipId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsUpdateRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateRelationship(\n digitalTwinId,\n relationshipId,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Delete a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to delete.\n * @param options - The operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is\n\n */\n public deleteRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: DigitalTwinsDeleteRelationshipOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.deleteRelationship(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Retrieve relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listRelationships(\n digitalTwinId: string,\n options?: ListRelationshipsOptions,\n ): PagedAsyncIterableIterator<Record<string, unknown>> {\n return this.client.digitalTwins.listRelationships(digitalTwinId, options);\n }\n\n /**\n * Retrieve all incoming relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listIncomingRelationships(\n digitalTwinId: string,\n options?: ListIncomingRelationshipsOptions,\n ): PagedAsyncIterableIterator<IncomingRelationship> {\n return this.client.digitalTwins.listIncomingRelationships(digitalTwinId, options);\n }\n\n /**\n * Publish telemetry from a digital twin, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishTelemetry(\n digitalTwinId: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendTelemetry(\n digitalTwinId,\n messageId || randomUUID(),\n payload,\n {\n ...updatedOptions,\n telemetrySourceTime: new Date().toISOString(),\n },\n );\n },\n );\n }\n\n /**\n * Publish telemetry from a digital twin's component, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param componentName - The name of the DTDL component.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishComponentTelemetry(\n digitalTwinId: string,\n componentName: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishComponentTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendComponentTelemetry(\n digitalTwinId,\n componentName,\n messageId || randomUUID(),\n payload,\n { ...updatedOptions, telemetrySourceTime: new Date().toISOString() },\n );\n },\n );\n }\n\n /**\n * Get a model, including the model metadata and the model definition.\n *\n * @param modelId - The Id of the model.\n * @param options - Options for this operation\n * @returns The application/json model.\n */\n public getModel(\n modelId: string,\n options: GetModelOptions = {},\n ): Promise<DigitalTwinModelsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getModel\",\n {\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.getById(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get the list of models\n *\n * @param options - Options for listing models.\n * @returns A pageable set of application/json models.\n */\n public listModels(\n options: ListModelsOptions = {},\n ): PagedAsyncIterableIterator<DigitalTwinsModelData> {\n return this.client.digitalTwinModels.list({\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n });\n }\n\n /**\n * Create one or many\n *\n * @param dtdlModels - The set of models to create. Each string corresponds to exactly one model.\n * @param options - The operation options\n * @returns The created application/json models.\n */\n public createModels(\n dtdlModels: Array<Record<string, unknown>>,\n options: OperationOptions = {},\n ): Promise<DigitalTwinModelsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.createModels\",\n {\n ...options,\n models: dtdlModels,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.add(updatedOptions);\n },\n );\n }\n\n /**\n * Decommission a model using a json patch.\n * When a model is decommissioned, new digital twins will no longer be able to be\n * defined by this model. However, existing digital twins may continue to use this model.\n * Once a model is decommissioned, it may not be recommissioned.\n *\n * @param modelId - The Id of the model to decommission.\n * property can be replaced.\n * @param options - The operation options\n\n *\n */\n public decomissionModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n const jsonPatch = [{ op: \"replace\", path: \"/decommissioned\", value: true }];\n\n return tracingClient.withSpan(\n \"DigitalTwinsClient.decomissionModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.update(modelId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a model.\n *\n * @param modelId - The Id of the model to delete.\n * @param options - The operation options\n\n */\n public deleteModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.delete(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get an event route.\n *\n * @param modelId - The Id of the event route.\n * @param options - The operation options\n * @returns The application/json event route.\n */\n public getEventRoute(\n eventRouteId: string,\n options: OperationOptions = {},\n ): Promise<EventRoutesGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.getById(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * List the event routes in a digital twins instance.\n *\n * @param options - Options for listEventRoutes.\n * @returns The application/json event route.\n */\n public listEventRoutes(options?: ListEventRoutesOptions): PagedAsyncIterableIterator<EventRoute> {\n return this.client.eventRoutes.list(options);\n }\n\n /**\n * Create or update an event route.\n *\n * @param eventRouteId - The Id of the event route to create or update.\n * @param endpointId - The id of the endpoint this event route is bound to.\n * @param filter - An expression which describes the events which are routed to the endpoint.\n * @param options - The operation options\n\n */\n public upsertEventRoute(\n eventRouteId: string,\n endpointId: string,\n filter: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertEventRoute\",\n {\n eventRoute: {\n endpointName: endpointId,\n filter,\n },\n ...options,\n },\n async (updatedOptions) => {\n return this.client.eventRoutes.add(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Delete an event route.\n *\n * @param eventRouteId - The Id of the eventRoute to delete.\n * @param options - The operation options\n\n */\n public deleteEventRoute(eventRouteId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.delete(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Deals with the pagination of {@link query}.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n * @param continuationState - An object that indicates the position of the paginated request.\n *\n */\n private async *queryTwinsPage(\n query: string,\n options: QueryTwinsOptions,\n continuationState?: PageSettings,\n ): AsyncIterableIterator<QueryQueryTwinsResponse> {\n let { continuationToken } = continuationState ?? {};\n if (!continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n while (continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query, continuationToken }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n }\n\n /**\n * Deals with the iteration of all the available results of {@link query}.\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n */\n private async *queryTwinsAll(\n query: string,\n options: QueryTwinsOptions,\n ): AsyncIterableIterator<Record<string, unknown>> {\n for await (const page of this.queryTwinsPage(query, options)) {\n if (page.value) {\n yield* page.value;\n }\n }\n }\n\n /**\n * Query for digital twins.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Options for the query operation.\n * @returns The pageable list of query results.\n */\n public queryTwins(\n query: string,\n options: QueryTwinsOptions = {},\n ): PagedAsyncIterableIterator<Record<string, unknown>, QueryQueryTwinsResponse> {\n const iter = this.queryTwinsAll(query, options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.queryTwinsPage(query, options, settings),\n };\n }\n}\n"]}
@@ -21,13 +21,13 @@ export declare class DigitalTwinsClient {
21
21
  * Creates an instance of AzureDigitalTwinsAPI.
22
22
  *
23
23
  * Example usage:
24
- * ```ts
25
- * const { DigitalTwinsClient, ServiceClientCredentials } = require("@azure/digital-twins-core");
24
+ * ```ts snippet:ReadmeSampleCreateClient_Node
25
+ * import { DefaultAzureCredential } from "@azure/identity";
26
+ * import { DigitalTwinsClient } from "@azure/digital-twins-core";
26
27
  *
27
- * const client = new DigitalTwinsClient(
28
- * "<endpoint>",
29
- * new DefaultAzureCredential();
30
- * );
28
+ * const url = "<URL to Azure Digital Twins instance>";
29
+ * const credential = new DefaultAzureCredential();
30
+ * const serviceClient = new DigitalTwinsClient(url, credential);
31
31
  * ```
32
32
  * @param endpointUrl - The endpoint URL of the service.
33
33
  * @param credential - Used to authenticate requests to the service.
@@ -14,13 +14,13 @@ export class DigitalTwinsClient {
14
14
  * Creates an instance of AzureDigitalTwinsAPI.
15
15
  *
16
16
  * Example usage:
17
- * ```ts
18
- * const { DigitalTwinsClient, ServiceClientCredentials } = require("@azure/digital-twins-core");
17
+ * ```ts snippet:ReadmeSampleCreateClient_Node
18
+ * import { DefaultAzureCredential } from "@azure/identity";
19
+ * import { DigitalTwinsClient } from "@azure/digital-twins-core";
19
20
  *
20
- * const client = new DigitalTwinsClient(
21
- * "<endpoint>",
22
- * new DefaultAzureCredential();
23
- * );
21
+ * const url = "<URL to Azure Digital Twins instance>";
22
+ * const credential = new DefaultAzureCredential();
23
+ * const serviceClient = new DigitalTwinsClient(url, credential);
24
24
  * ```
25
25
  * @param endpointUrl - The endpoint URL of the service.
26
26
  * @param credential - Used to authenticate requests to the service.
@@ -1 +1 @@
1
- {"version":3,"file":"digitalTwinsClient.js","sourceRoot":"","sources":["../../src/digitalTwinsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AASlC,OAAO,EAAE,UAAU,EAAE,MAA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AE,CAAC;wBACf,cAAA,KAAK,CAAC,CAAC,iBAAA,cAAA,IAAI,CAAC,KAAK,CAAA,CAAA,CAAA,CAAC;oBACpB,CAAC;gBACH,CAAC;;;;;;;;;QACH,CAAC;KAAA;IAED;;;;;;OAMG;IACI,UAAU,CACf,KAAa,EACb,UAA6B,EAAE;QAE/B,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEhD,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;SACvF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n OperationOptions,\n InternalClientPipelineOptions,\n CommonClientOptions,\n} from \"@azure/core-client\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { randomUUID } from \"@azure/core-util\";\nimport { AzureDigitalTwinsAPI as GeneratedClient } from \"./generated/azureDigitalTwinsAPI.js\";\nimport type {\n DigitalTwinsGetByIdResponse,\n DigitalTwinsAddOptionalParams,\n DigitalTwinsAddResponse,\n DigitalTwinsUpdateOptionalParams,\n DigitalTwinsUpdateResponse,\n DigitalTwinsDeleteOptionalParams,\n DigitalTwinsGetComponentResponse,\n DigitalTwinsUpdateComponentResponse,\n DigitalTwinsUpdateComponentOptionalParams,\n DigitalTwinsAddRelationshipResponse,\n DigitalTwinsAddRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipResponse,\n DigitalTwinsDeleteRelationshipOptionalParams,\n IncomingRelationship,\n DigitalTwinsGetRelationshipByIdResponse,\n DigitalTwinsModelData,\n DigitalTwinModelsGetByIdResponse,\n DigitalTwinModelsAddResponse,\n EventRoutesGetByIdResponse,\n EventRoute,\n QueryQueryTwinsResponse,\n} from \"./generated/models/index.js\";\nimport {\n DigitalTwinModelsGetByIdOptionalParams as GetModelOptions,\n DigitalTwinModelsListOptionalParams as ListModelsOptions,\n QueryQueryTwinsOptionalParams as QueryTwinsOptions,\n EventRoutesListOptionalParams as ListEventRoutesOptions,\n DigitalTwinsListRelationshipsOptionalParams as ListRelationshipsOptions,\n DigitalTwinsListIncomingRelationshipsOptionalParams as ListIncomingRelationshipsOptions,\n} from \"./generated/models/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport { logger } from \"./logger.js\";\nexport {\n GetModelOptions,\n ListModelsOptions,\n QueryTwinsOptions,\n ListEventRoutesOptions,\n ListIncomingRelationshipsOptions,\n ListRelationshipsOptions,\n};\n\n/**\n * Options for the DigitalTwinsClient class\n */\nexport interface DigitalTwinsClientOptions extends CommonClientOptions {}\n\nconst DEFAULT_DIGITALTWINS_SCOPE = \"https://digitaltwins.azure.net/.default\";\n\n/**\n * Client for Azure IoT DigitalTwins API.\n */\nexport class DigitalTwinsClient {\n /**\n * A reference to the auto-generated AzureDigitalTwinsAPI\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of AzureDigitalTwinsAPI.\n *\n * Example usage:\n * ```ts\n * const { DigitalTwinsClient, ServiceClientCredentials } = require(\"@azure/digital-twins-core\");\n *\n * const client = new DigitalTwinsClient(\n * \"<endpoint>\",\n * new DefaultAzureCredential();\n * );\n * ```\n * @param endpointUrl - The endpoint URL of the service.\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the service client.\n */\n constructor(\n endpointUrl: string,\n credential: TokenCredential,\n options: DigitalTwinsClientOptions = {},\n ) {\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\"x-ms-request-id\"],\n },\n };\n\n this.client = new GeneratedClient({\n endpoint: endpointUrl,\n credential,\n credentialScopes: DEFAULT_DIGITALTWINS_SCOPE,\n ...internalPipelineOptions,\n });\n }\n\n /**\n * Get a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param options - The operation options\n * @returns The application/json digital twin.\n */\n public getDigitalTwin(\n digitalTwinId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getById(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Create or update a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to create or update.\n * @param digitalTwinJson - The application/json digital twin to create.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n * @returns The created application/json digital twin.\n */\n public upsertDigitalTwin(\n digitalTwinId: string,\n digitalTwinJson: string,\n options: DigitalTwinsAddOptionalParams = {},\n ): Promise<DigitalTwinsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertDigitalTwin\",\n options,\n async (updatedOptions) => {\n const payload = JSON.parse(digitalTwinJson);\n return this.client.digitalTwins.add(digitalTwinId, payload, updatedOptions);\n },\n );\n }\n\n /**\n * Update a digital twin using a json patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param jsonPatch - An update specification described by JSON Patch. Updates to property values\n * and $model elements may happen in the same request. Operations are limited to add, replace and\n * remove.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateDigitalTwin(\n digitalTwinId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateOptionalParams = {},\n ): Promise<DigitalTwinsUpdateResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.update(digitalTwinId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public deleteDigitalTwin(\n digitalTwinId: string,\n options: DigitalTwinsDeleteOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.delete(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Get a component on a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being retrieved.\n * @param options - The operation options\n * @returns Json string representation of the component corresponding to the provided componentName.\n */\n public getComponent(\n digitalTwinId: string,\n componentName: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getComponent(digitalTwinId, componentName, updatedOptions);\n },\n );\n }\n\n /**\n * Update properties of a component on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's component.\n * @param enableUpdate - If true then update of an existing digital twin is enabled.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateComponent(\n digitalTwinId: string,\n componentName: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateComponentOptionalParams = {},\n ): Promise<DigitalTwinsUpdateComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateComponent(\n digitalTwinId,\n componentName,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Get a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to retrieve.\n * @param options - The operation options\n * @returns The pageable list of application/json relationships belonging to the specified digital twin.\n */\n public getRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetRelationshipByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getRelationshipById(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Create or update a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to create.\n * @param relationship - The application/json relationship to be created.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n */\n public upsertRelationship(\n digitalTwinId: string,\n relationshipId: string,\n relationship: Record<string, unknown>,\n options: DigitalTwinsAddRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsAddRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.addRelationship(\n digitalTwinId,\n relationshipId,\n relationship,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Updates the properties of a relationship on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param relationshipId - The Id of the relationship to be updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's relationship.\n * @param options - Extended operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n */\n public updateRelationship(\n digitalTwinId: string,\n relationshipId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsUpdateRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateRelationship(\n digitalTwinId,\n relationshipId,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Delete a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to delete.\n * @param options - The operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is\n\n */\n public deleteRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: DigitalTwinsDeleteRelationshipOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.deleteRelationship(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Retrieve relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listRelationships(\n digitalTwinId: string,\n options?: ListRelationshipsOptions,\n ): PagedAsyncIterableIterator<Record<string, unknown>> {\n return this.client.digitalTwins.listRelationships(digitalTwinId, options);\n }\n\n /**\n * Retrieve all incoming relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listIncomingRelationships(\n digitalTwinId: string,\n options?: ListIncomingRelationshipsOptions,\n ): PagedAsyncIterableIterator<IncomingRelationship> {\n return this.client.digitalTwins.listIncomingRelationships(digitalTwinId, options);\n }\n\n /**\n * Publish telemetry from a digital twin, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishTelemetry(\n digitalTwinId: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendTelemetry(\n digitalTwinId,\n messageId || randomUUID(),\n payload,\n {\n ...updatedOptions,\n telemetrySourceTime: new Date().toISOString(),\n },\n );\n },\n );\n }\n\n /**\n * Publish telemetry from a digital twin's component, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param componentName - The name of the DTDL component.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishComponentTelemetry(\n digitalTwinId: string,\n componentName: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishComponentTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendComponentTelemetry(\n digitalTwinId,\n componentName,\n messageId || randomUUID(),\n payload,\n { ...updatedOptions, telemetrySourceTime: new Date().toISOString() },\n );\n },\n );\n }\n\n /**\n * Get a model, including the model metadata and the model definition.\n *\n * @param modelId - The Id of the model.\n * @param options - Options for this operation\n * @returns The application/json model.\n */\n public getModel(\n modelId: string,\n options: GetModelOptions = {},\n ): Promise<DigitalTwinModelsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getModel\",\n {\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.getById(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get the list of models\n *\n * @param options - Options for listing models.\n * @returns A pageable set of application/json models.\n */\n public listModels(\n options: ListModelsOptions = {},\n ): PagedAsyncIterableIterator<DigitalTwinsModelData> {\n return this.client.digitalTwinModels.list({\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n });\n }\n\n /**\n * Create one or many\n *\n * @param dtdlModels - The set of models to create. Each string corresponds to exactly one model.\n * @param options - The operation options\n * @returns The created application/json models.\n */\n public createModels(\n dtdlModels: Array<Record<string, unknown>>,\n options: OperationOptions = {},\n ): Promise<DigitalTwinModelsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.createModels\",\n {\n ...options,\n models: dtdlModels,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.add(updatedOptions);\n },\n );\n }\n\n /**\n * Decommission a model using a json patch.\n * When a model is decommissioned, new digital twins will no longer be able to be\n * defined by this model. However, existing digital twins may continue to use this model.\n * Once a model is decommissioned, it may not be recommissioned.\n *\n * @param modelId - The Id of the model to decommission.\n * property can be replaced.\n * @param options - The operation options\n\n *\n */\n public decomissionModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n const jsonPatch = [{ op: \"replace\", path: \"/decommissioned\", value: true }];\n\n return tracingClient.withSpan(\n \"DigitalTwinsClient.decomissionModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.update(modelId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a model.\n *\n * @param modelId - The Id of the model to delete.\n * @param options - The operation options\n\n */\n public deleteModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.delete(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get an event route.\n *\n * @param modelId - The Id of the event route.\n * @param options - The operation options\n * @returns The application/json event route.\n */\n public getEventRoute(\n eventRouteId: string,\n options: OperationOptions = {},\n ): Promise<EventRoutesGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.getById(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * List the event routes in a digital twins instance.\n *\n * @param options - Options for listEventRoutes.\n * @returns The application/json event route.\n */\n public listEventRoutes(options?: ListEventRoutesOptions): PagedAsyncIterableIterator<EventRoute> {\n return this.client.eventRoutes.list(options);\n }\n\n /**\n * Create or update an event route.\n *\n * @param eventRouteId - The Id of the event route to create or update.\n * @param endpointId - The id of the endpoint this event route is bound to.\n * @param filter - An expression which describes the events which are routed to the endpoint.\n * @param options - The operation options\n\n */\n public upsertEventRoute(\n eventRouteId: string,\n endpointId: string,\n filter: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertEventRoute\",\n {\n eventRoute: {\n endpointName: endpointId,\n filter,\n },\n ...options,\n },\n async (updatedOptions) => {\n return this.client.eventRoutes.add(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Delete an event route.\n *\n * @param eventRouteId - The Id of the eventRoute to delete.\n * @param options - The operation options\n\n */\n public deleteEventRoute(eventRouteId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.delete(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Deals with the pagination of {@link query}.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n * @param continuationState - An object that indicates the position of the paginated request.\n *\n */\n private async *queryTwinsPage(\n query: string,\n options: QueryTwinsOptions,\n continuationState?: PageSettings,\n ): AsyncIterableIterator<QueryQueryTwinsResponse> {\n let { continuationToken } = continuationState ?? {};\n if (!continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n while (continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query, continuationToken }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n }\n\n /**\n * Deals with the iteration of all the available results of {@link query}.\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n */\n private async *queryTwinsAll(\n query: string,\n options: QueryTwinsOptions,\n ): AsyncIterableIterator<Record<string, unknown>> {\n for await (const page of this.queryTwinsPage(query, options)) {\n if (page.value) {\n yield* page.value;\n }\n }\n }\n\n /**\n * Query for digital twins.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Options for the query operation.\n * @returns The pageable list of query results.\n */\n public queryTwins(\n query: string,\n options: QueryTwinsOptions = {},\n ): PagedAsyncIterableIterator<Record<string, unknown>, QueryQueryTwinsResponse> {\n const iter = this.queryTwinsAll(query, options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.queryTwinsPage(query, options, settings),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"digitalTwinsClient.js","sourceRoot":"","sources":["../../src/digitalTwinsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AASlC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAiC9F,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAerC,MAAM,0BAA0B,GAAG,yCAAyC,CAAC;AAE7E;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAM7B;;;;;;;;;;;;;;;OAeG;IACH,YACE,WAAmB,EACnB,UAA2B,EAC3B,UAAqC,EAAE;QAEvC,MAAM,uBAAuB,mCACxB,OAAO,KACV,cAAc,EAAE;gBACd,MAAM,EAAE,MAAM,CAAC,IAAI;gBACnB,4BAA4B,EAAE,CAAC,iBAAiB,CAAC;aAClD,GACF,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,iBAC/B,QAAQ,EAAE,WAAW,EACrB,UAAU,EACV,gBAAgB,EAAE,0BAA0B,IACzC,uBAAuB,EAC1B,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CACnB,aAAqB,EACrB,UAA4B,EAAE;QAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,mCAAmC,EACnC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QACzE,CAAC,CACF,CAAC;IACJ,CA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ClD,oBAAM,WAAW,CAAA,CAAC;YACpB,CAAC;QACH,CAAC;KAAA;IAED;;;;OAIG;IACY,aAAa,CAC1B,KAAa,EACb,OAA0B;;;;gBAE1B,KAAyB,eAAA,KAAA,cAAA,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA,IAAA,+DAAE,CAAC;oBAAtC,cAAmC;oBAAnC,WAAmC;oBAAjD,MAAM,IAAI,KAAA,CAAA;oBACnB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;wBACf,cAAA,KAAK,CAAC,CAAC,iBAAA,cAAA,IAAI,CAAC,KAAK,CAAA,CAAA,CAAA,CAAC;oBACpB,CAAC;gBACH,CAAC;;;;;;;;;QACH,CAAC;KAAA;IAED;;;;;;OAMG;IACI,UAAU,CACf,KAAa,EACb,UAA6B,EAAE;QAE/B,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEhD,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,EAAE,CAAC,WAAyB,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;SACvF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n OperationOptions,\n InternalClientPipelineOptions,\n CommonClientOptions,\n} from \"@azure/core-client\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { randomUUID } from \"@azure/core-util\";\nimport { AzureDigitalTwinsAPI as GeneratedClient } from \"./generated/azureDigitalTwinsAPI.js\";\nimport type {\n DigitalTwinsGetByIdResponse,\n DigitalTwinsAddOptionalParams,\n DigitalTwinsAddResponse,\n DigitalTwinsUpdateOptionalParams,\n DigitalTwinsUpdateResponse,\n DigitalTwinsDeleteOptionalParams,\n DigitalTwinsGetComponentResponse,\n DigitalTwinsUpdateComponentResponse,\n DigitalTwinsUpdateComponentOptionalParams,\n DigitalTwinsAddRelationshipResponse,\n DigitalTwinsAddRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipOptionalParams,\n DigitalTwinsUpdateRelationshipResponse,\n DigitalTwinsDeleteRelationshipOptionalParams,\n IncomingRelationship,\n DigitalTwinsGetRelationshipByIdResponse,\n DigitalTwinsModelData,\n DigitalTwinModelsGetByIdResponse,\n DigitalTwinModelsAddResponse,\n EventRoutesGetByIdResponse,\n EventRoute,\n QueryQueryTwinsResponse,\n} from \"./generated/models/index.js\";\nimport {\n DigitalTwinModelsGetByIdOptionalParams as GetModelOptions,\n DigitalTwinModelsListOptionalParams as ListModelsOptions,\n QueryQueryTwinsOptionalParams as QueryTwinsOptions,\n EventRoutesListOptionalParams as ListEventRoutesOptions,\n DigitalTwinsListRelationshipsOptionalParams as ListRelationshipsOptions,\n DigitalTwinsListIncomingRelationshipsOptionalParams as ListIncomingRelationshipsOptions,\n} from \"./generated/models/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport { logger } from \"./logger.js\";\nexport {\n GetModelOptions,\n ListModelsOptions,\n QueryTwinsOptions,\n ListEventRoutesOptions,\n ListIncomingRelationshipsOptions,\n ListRelationshipsOptions,\n};\n\n/**\n * Options for the DigitalTwinsClient class\n */\nexport interface DigitalTwinsClientOptions extends CommonClientOptions {}\n\nconst DEFAULT_DIGITALTWINS_SCOPE = \"https://digitaltwins.azure.net/.default\";\n\n/**\n * Client for Azure IoT DigitalTwins API.\n */\nexport class DigitalTwinsClient {\n /**\n * A reference to the auto-generated AzureDigitalTwinsAPI\n */\n private readonly client: GeneratedClient;\n\n /**\n * Creates an instance of AzureDigitalTwinsAPI.\n *\n * Example usage:\n * ```ts snippet:ReadmeSampleCreateClient_Node\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { DigitalTwinsClient } from \"@azure/digital-twins-core\";\n *\n * const url = \"<URL to Azure Digital Twins instance>\";\n * const credential = new DefaultAzureCredential();\n * const serviceClient = new DigitalTwinsClient(url, credential);\n * ```\n * @param endpointUrl - The endpoint URL of the service.\n * @param credential - Used to authenticate requests to the service.\n * @param options - Used to configure the service client.\n */\n constructor(\n endpointUrl: string,\n credential: TokenCredential,\n options: DigitalTwinsClientOptions = {},\n ) {\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\"x-ms-request-id\"],\n },\n };\n\n this.client = new GeneratedClient({\n endpoint: endpointUrl,\n credential,\n credentialScopes: DEFAULT_DIGITALTWINS_SCOPE,\n ...internalPipelineOptions,\n });\n }\n\n /**\n * Get a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param options - The operation options\n * @returns The application/json digital twin.\n */\n public getDigitalTwin(\n digitalTwinId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getById(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Create or update a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to create or update.\n * @param digitalTwinJson - The application/json digital twin to create.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n * @returns The created application/json digital twin.\n */\n public upsertDigitalTwin(\n digitalTwinId: string,\n digitalTwinJson: string,\n options: DigitalTwinsAddOptionalParams = {},\n ): Promise<DigitalTwinsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertDigitalTwin\",\n options,\n async (updatedOptions) => {\n const payload = JSON.parse(digitalTwinJson);\n return this.client.digitalTwins.add(digitalTwinId, payload, updatedOptions);\n },\n );\n }\n\n /**\n * Update a digital twin using a json patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param jsonPatch - An update specification described by JSON Patch. Updates to property values\n * and $model elements may happen in the same request. Operations are limited to add, replace and\n * remove.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateDigitalTwin(\n digitalTwinId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateOptionalParams = {},\n ): Promise<DigitalTwinsUpdateResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.update(digitalTwinId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a digital twin\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public deleteDigitalTwin(\n digitalTwinId: string,\n options: DigitalTwinsDeleteOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteDigitalTwin\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.delete(digitalTwinId, updatedOptions);\n },\n );\n }\n\n /**\n * Get a component on a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being retrieved.\n * @param options - The operation options\n * @returns Json string representation of the component corresponding to the provided componentName.\n */\n public getComponent(\n digitalTwinId: string,\n componentName: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getComponent(digitalTwinId, componentName, updatedOptions);\n },\n );\n }\n\n /**\n * Update properties of a component on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin.\n * @param componentName - The component being updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's component.\n * @param enableUpdate - If true then update of an existing digital twin is enabled.\n * @param options - Extended operation options including\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n\n */\n public updateComponent(\n digitalTwinId: string,\n componentName: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateComponentOptionalParams = {},\n ): Promise<DigitalTwinsUpdateComponentResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateComponent\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateComponent(\n digitalTwinId,\n componentName,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Get a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to retrieve.\n * @param options - The operation options\n * @returns The pageable list of application/json relationships belonging to the specified digital twin.\n */\n public getRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: OperationOptions = {},\n ): Promise<DigitalTwinsGetRelationshipByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.getRelationshipById(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Create or update a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to create.\n * @param relationship - The application/json relationship to be created.\n * @param options - Extended operation options including\n * ifNoneMatch: Only perform the operation if the entity does not already exist.\n */\n public upsertRelationship(\n digitalTwinId: string,\n relationshipId: string,\n relationship: Record<string, unknown>,\n options: DigitalTwinsAddRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsAddRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.addRelationship(\n digitalTwinId,\n relationshipId,\n relationship,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Updates the properties of a relationship on a digital twin using a JSON patch.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param relationshipId - The Id of the relationship to be updated.\n * @param jsonPatch - The application/json-patch+json operations to be performed on the specified digital twin's relationship.\n * @param options - Extended operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.\n */\n public updateRelationship(\n digitalTwinId: string,\n relationshipId: string,\n jsonPatch: Array<Record<string, unknown>>,\n options: DigitalTwinsUpdateRelationshipOptionalParams = {},\n ): Promise<DigitalTwinsUpdateRelationshipResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.updateRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.updateRelationship(\n digitalTwinId,\n relationshipId,\n jsonPatch,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Delete a relationship on a digital twin.\n *\n * @param digitalTwinId - The Id of the source digital twin.\n * @param relationshipId - The Id of the relationship to delete.\n * @param options - The operation options\n * ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is\n\n */\n public deleteRelationship(\n digitalTwinId: string,\n relationshipId: string,\n options: DigitalTwinsDeleteRelationshipOptionalParams = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteRelationship\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.deleteRelationship(\n digitalTwinId,\n relationshipId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Retrieve relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listRelationships(\n digitalTwinId: string,\n options?: ListRelationshipsOptions,\n ): PagedAsyncIterableIterator<Record<string, unknown>> {\n return this.client.digitalTwins.listRelationships(digitalTwinId, options);\n }\n\n /**\n * Retrieve all incoming relationships for a digital twin.\n *\n * @param digitalTwinId - The Id of the digital twin.\n */\n public listIncomingRelationships(\n digitalTwinId: string,\n options?: ListIncomingRelationshipsOptions,\n ): PagedAsyncIterableIterator<IncomingRelationship> {\n return this.client.digitalTwins.listIncomingRelationships(digitalTwinId, options);\n }\n\n /**\n * Publish telemetry from a digital twin, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishTelemetry(\n digitalTwinId: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendTelemetry(\n digitalTwinId,\n messageId || randomUUID(),\n payload,\n {\n ...updatedOptions,\n telemetrySourceTime: new Date().toISOString(),\n },\n );\n },\n );\n }\n\n /**\n * Publish telemetry from a digital twin's component, which is then consumed by one or many destination endpoints (subscribers) defined under.\n *\n * @param digitalTwinId - The Id of the digital twin to delete.\n * @param componentName - The name of the DTDL component.\n * @param payload - The application/json telemetry payload to be sent.\n * @param messageId - The message Id.\n * @param options - The operation options\n\n */\n public publishComponentTelemetry(\n digitalTwinId: string,\n componentName: string,\n payload: Record<string, unknown>,\n messageId: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.publishComponentTelemetry\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwins.sendComponentTelemetry(\n digitalTwinId,\n componentName,\n messageId || randomUUID(),\n payload,\n { ...updatedOptions, telemetrySourceTime: new Date().toISOString() },\n );\n },\n );\n }\n\n /**\n * Get a model, including the model metadata and the model definition.\n *\n * @param modelId - The Id of the model.\n * @param options - Options for this operation\n * @returns The application/json model.\n */\n public getModel(\n modelId: string,\n options: GetModelOptions = {},\n ): Promise<DigitalTwinModelsGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getModel\",\n {\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.getById(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get the list of models\n *\n * @param options - Options for listing models.\n * @returns A pageable set of application/json models.\n */\n public listModels(\n options: ListModelsOptions = {},\n ): PagedAsyncIterableIterator<DigitalTwinsModelData> {\n return this.client.digitalTwinModels.list({\n ...options,\n includeModelDefinition: options?.includeModelDefinition ?? false,\n });\n }\n\n /**\n * Create one or many\n *\n * @param dtdlModels - The set of models to create. Each string corresponds to exactly one model.\n * @param options - The operation options\n * @returns The created application/json models.\n */\n public createModels(\n dtdlModels: Array<Record<string, unknown>>,\n options: OperationOptions = {},\n ): Promise<DigitalTwinModelsAddResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.createModels\",\n {\n ...options,\n models: dtdlModels,\n },\n async (updatedOptions) => {\n return this.client.digitalTwinModels.add(updatedOptions);\n },\n );\n }\n\n /**\n * Decommission a model using a json patch.\n * When a model is decommissioned, new digital twins will no longer be able to be\n * defined by this model. However, existing digital twins may continue to use this model.\n * Once a model is decommissioned, it may not be recommissioned.\n *\n * @param modelId - The Id of the model to decommission.\n * property can be replaced.\n * @param options - The operation options\n\n *\n */\n public decomissionModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n const jsonPatch = [{ op: \"replace\", path: \"/decommissioned\", value: true }];\n\n return tracingClient.withSpan(\n \"DigitalTwinsClient.decomissionModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.update(modelId, jsonPatch, updatedOptions);\n },\n );\n }\n\n /**\n * Delete a model.\n *\n * @param modelId - The Id of the model to delete.\n * @param options - The operation options\n\n */\n public deleteModel(modelId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteModel\",\n options,\n async (updatedOptions) => {\n return this.client.digitalTwinModels.delete(modelId, updatedOptions);\n },\n );\n }\n\n /**\n * Get an event route.\n *\n * @param modelId - The Id of the event route.\n * @param options - The operation options\n * @returns The application/json event route.\n */\n public getEventRoute(\n eventRouteId: string,\n options: OperationOptions = {},\n ): Promise<EventRoutesGetByIdResponse> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.getEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.getById(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * List the event routes in a digital twins instance.\n *\n * @param options - Options for listEventRoutes.\n * @returns The application/json event route.\n */\n public listEventRoutes(options?: ListEventRoutesOptions): PagedAsyncIterableIterator<EventRoute> {\n return this.client.eventRoutes.list(options);\n }\n\n /**\n * Create or update an event route.\n *\n * @param eventRouteId - The Id of the event route to create or update.\n * @param endpointId - The id of the endpoint this event route is bound to.\n * @param filter - An expression which describes the events which are routed to the endpoint.\n * @param options - The operation options\n\n */\n public upsertEventRoute(\n eventRouteId: string,\n endpointId: string,\n filter: string,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.upsertEventRoute\",\n {\n eventRoute: {\n endpointName: endpointId,\n filter,\n },\n ...options,\n },\n async (updatedOptions) => {\n return this.client.eventRoutes.add(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Delete an event route.\n *\n * @param eventRouteId - The Id of the eventRoute to delete.\n * @param options - The operation options\n\n */\n public deleteEventRoute(eventRouteId: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"DigitalTwinsClient.deleteEventRoute\",\n options,\n async (updatedOptions) => {\n return this.client.eventRoutes.delete(eventRouteId, updatedOptions);\n },\n );\n }\n\n /**\n * Deals with the pagination of {@link query}.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n * @param continuationState - An object that indicates the position of the paginated request.\n *\n */\n private async *queryTwinsPage(\n query: string,\n options: QueryTwinsOptions,\n continuationState?: PageSettings,\n ): AsyncIterableIterator<QueryQueryTwinsResponse> {\n let { continuationToken } = continuationState ?? {};\n if (!continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n while (continuationToken) {\n const queryResult = await this.client.query.queryTwins({ query, continuationToken }, options);\n continuationToken = queryResult.continuationToken;\n yield queryResult;\n }\n }\n\n /**\n * Deals with the iteration of all the available results of {@link query}.\n * @param query - The query string, in SQL-like syntax.\n * @param options - Common options for the iterative endpoints.\n */\n private async *queryTwinsAll(\n query: string,\n options: QueryTwinsOptions,\n ): AsyncIterableIterator<Record<string, unknown>> {\n for await (const page of this.queryTwinsPage(query, options)) {\n if (page.value) {\n yield* page.value;\n }\n }\n }\n\n /**\n * Query for digital twins.\n *\n * @param query - The query string, in SQL-like syntax.\n * @param options - Options for the query operation.\n * @returns The pageable list of query results.\n */\n public queryTwins(\n query: string,\n options: QueryTwinsOptions = {},\n ): PagedAsyncIterableIterator<Record<string, unknown>, QueryQueryTwinsResponse> {\n const iter = this.queryTwinsAll(query, options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.queryTwinsPage(query, options, settings),\n };\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/digital-twins-core",
3
- "version": "2.0.0-alpha.20250129.1",
3
+ "version": "2.0.0-alpha.20250130.2",
4
4
  "description": "An isomorphic client library for Azure Digital Twins",
5
5
  "sdk-type": "client",
6
6
  "author": "Microsoft Corporation",
@@ -33,7 +33,7 @@
33
33
  "unit-test": "npm run unit-test:node && npm run unit-test:browser",
34
34
  "unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
35
35
  "unit-test:node": "dev-tool run test:vitest",
36
- "update-snippets": "echo skipped"
36
+ "update-snippets": "dev-tool run update-snippets"
37
37
  },
38
38
  "files": [
39
39
  "dist/",
@@ -60,7 +60,7 @@
60
60
  "@azure/core-auth": "^1.9.0",
61
61
  "@azure/core-client": "^1.9.2",
62
62
  "@azure/core-paging": "^1.6.2",
63
- "@azure/core-rest-pipeline": "^1.18.0",
63
+ "@azure/core-rest-pipeline": "^1.18.2",
64
64
  "@azure/core-tracing": "^1.2.0",
65
65
  "@azure/core-util": "^1.11.0",
66
66
  "@azure/logger": "^1.1.4",
@@ -72,13 +72,13 @@
72
72
  "@azure-tools/test-utils-vitest": ">=1.0.0-alpha <1.0.0-alphb",
73
73
  "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
74
74
  "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
75
- "@azure/identity": "^4.0.1",
75
+ "@azure/identity": "^4.6.0",
76
76
  "@types/node": "^18.0.0",
77
77
  "@vitest/browser": "^3.0.3",
78
78
  "@vitest/coverage-istanbul": "^3.0.3",
79
79
  "dotenv": "^16.0.0",
80
80
  "eslint": "^9.9.0",
81
- "playwright": "^1.49.0",
81
+ "playwright": "^1.50.0",
82
82
  "typescript": "~5.7.2",
83
83
  "vitest": "^3.0.3"
84
84
  },
@@ -118,6 +118,7 @@
118
118
  },
119
119
  "type": "module",
120
120
  "tshy": {
121
+ "project": "./tsconfig.src.json",
121
122
  "exports": {
122
123
  "./package.json": "./package.json",
123
124
  ".": "./src/index.ts"
@@ -130,8 +131,7 @@
130
131
  "browser",
131
132
  "react-native"
132
133
  ],
133
- "selfLink": false,
134
- "project": "./tsconfig.src.json"
134
+ "selfLink": false
135
135
  },
136
136
  "browser": "./dist/browser/index.js",
137
137
  "exports": {
@@ -154,5 +154,6 @@
154
154
  "default": "./dist/commonjs/index.js"
155
155
  }
156
156
  }
157
- }
157
+ },
158
+ "react-native": "./dist/react-native/index.js"
158
159
  }