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