industrial-model 0.12.0 → 0.12.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.
@@ -35,8 +35,9 @@ var CogniteSdkAdapter = class {
35
35
  };
36
36
  }
37
37
  async searchInstances(request) {
38
- const search = this.client.instances.search;
39
- const response = await search(request);
38
+ const response = await this.client.instances.search(
39
+ request
40
+ );
40
41
  return {
41
42
  items: response.items
42
43
  };
@@ -50,11 +51,24 @@ var CogniteSdkAdapter = class {
50
51
  };
51
52
  }
52
53
  async applyInstances(request) {
53
- const apply = this.client.instances.apply;
54
- const response = await apply(request);
55
- return {
56
- items: response.items
57
- };
54
+ const { items, delete: deleteItems = [], replace } = request;
55
+ const results = [];
56
+ if (deleteItems.length > 0) {
57
+ const deleteResponse = await this.client.instances.delete(
58
+ deleteItems
59
+ );
60
+ results.push(
61
+ ...deleteResponse.items ?? []
62
+ );
63
+ }
64
+ if (items.length > 0) {
65
+ const response = await this.client.instances.upsert({
66
+ items,
67
+ ...replace === true ? { replace: true } : {}
68
+ });
69
+ results.push(...response.items);
70
+ }
71
+ return { items: results };
58
72
  }
59
73
  async retrieveDatapoints(options) {
60
74
  const { items, ...rest } = options;