industrial-model 0.11.3 → 0.12.0
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/README.md +17 -0
- package/dist/calculator/index.cjs +892 -0
- package/dist/calculator/index.cjs.map +1 -0
- package/dist/calculator/index.d.cts +250 -0
- package/dist/calculator/index.d.ts +250 -0
- package/dist/calculator/index.js +879 -0
- package/dist/calculator/index.js.map +1 -0
- package/dist/cli/index.cjs +121 -150
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cognite-core/index.cjs +45 -14
- package/dist/cognite-core/index.cjs.map +1 -1
- package/dist/cognite-core/index.d.cts +1 -1
- package/dist/cognite-core/index.d.ts +1 -1
- package/dist/cognite-core/index.js +45 -14
- package/dist/cognite-core/index.js.map +1 -1
- package/dist/index.cjs +44 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +44 -14
- package/dist/index.js.map +1 -1
- package/dist/{types-69DRhgww.d.cts → types-CFkHwXW6.d.cts} +362 -1
- package/dist/{types-69DRhgww.d.ts → types-CFkHwXW6.d.ts} +362 -1
- package/package.json +18 -2
|
@@ -10,6 +10,7 @@ var CogniteSdkAdapter = class {
|
|
|
10
10
|
constructor(client) {
|
|
11
11
|
this.client = client;
|
|
12
12
|
}
|
|
13
|
+
client;
|
|
13
14
|
async retrieveDataModels(ids, options) {
|
|
14
15
|
const response = await this.client.dataModels.retrieve(ids, options);
|
|
15
16
|
return {
|
|
@@ -530,6 +531,7 @@ var QueryValidator = class {
|
|
|
530
531
|
constructor(viewMapper) {
|
|
531
532
|
this.viewMapper = viewMapper;
|
|
532
533
|
}
|
|
534
|
+
viewMapper;
|
|
533
535
|
async validate(options, rootView) {
|
|
534
536
|
const errors = [];
|
|
535
537
|
errors.push(...this.validateOptionsShape(options, rootView));
|
|
@@ -699,6 +701,7 @@ function isEmptyObject(value) {
|
|
|
699
701
|
return value != null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0;
|
|
700
702
|
}
|
|
701
703
|
var AggregateValidator = class {
|
|
704
|
+
queryValidator;
|
|
702
705
|
constructor(viewMapper) {
|
|
703
706
|
this.queryValidator = new QueryValidator(viewMapper);
|
|
704
707
|
}
|
|
@@ -906,6 +909,7 @@ var QueryResultValidator = class {
|
|
|
906
909
|
constructor(viewMapper) {
|
|
907
910
|
this.viewMapper = viewMapper;
|
|
908
911
|
}
|
|
912
|
+
viewMapper;
|
|
909
913
|
async parseItems(rootViewExternalId, items, select) {
|
|
910
914
|
const rootView = await this.viewMapper.getView(rootViewExternalId);
|
|
911
915
|
const schema = await this.buildResultSchema(rootView, MAX_DEPENDENCY_DEPTH, select);
|
|
@@ -1067,6 +1071,8 @@ var FilterMapper = class {
|
|
|
1067
1071
|
this.viewMapper = viewMapper;
|
|
1068
1072
|
this.cognite = cognite;
|
|
1069
1073
|
}
|
|
1074
|
+
viewMapper;
|
|
1075
|
+
cognite;
|
|
1070
1076
|
async map(input, rootView) {
|
|
1071
1077
|
const result = [];
|
|
1072
1078
|
const searchQueries = {};
|
|
@@ -1211,6 +1217,9 @@ var AggregateMapper = class {
|
|
|
1211
1217
|
this.filterMapper = new FilterMapper(viewMapper, cognite);
|
|
1212
1218
|
this.validator = new AggregateValidator(viewMapper);
|
|
1213
1219
|
}
|
|
1220
|
+
viewMapper;
|
|
1221
|
+
filterMapper;
|
|
1222
|
+
validator;
|
|
1214
1223
|
async map(options) {
|
|
1215
1224
|
const { viewExternalId, filters, groupBy, aggregate } = options;
|
|
1216
1225
|
const rootView = await this.viewMapper.getView(viewExternalId);
|
|
@@ -1288,8 +1297,9 @@ var CHUNK_SIZE = 100;
|
|
|
1288
1297
|
var DatapointsMapper = class {
|
|
1289
1298
|
constructor(cognite) {
|
|
1290
1299
|
this.cognite = cognite;
|
|
1291
|
-
this.validator = new DatapointsValidator();
|
|
1292
1300
|
}
|
|
1301
|
+
cognite;
|
|
1302
|
+
validator = new DatapointsValidator();
|
|
1293
1303
|
async retrieve(options) {
|
|
1294
1304
|
this.validator.validateRetrieve(options);
|
|
1295
1305
|
const cogniteOptions = this.toCogniteOptions(options);
|
|
@@ -1410,6 +1420,7 @@ var FilesMapper = class {
|
|
|
1410
1420
|
constructor(cognite) {
|
|
1411
1421
|
this.cognite = cognite;
|
|
1412
1422
|
}
|
|
1423
|
+
cognite;
|
|
1413
1424
|
async upload(fileInfo, content) {
|
|
1414
1425
|
const { space, externalId, ...rest } = fileInfo;
|
|
1415
1426
|
const result = await this.cognite.uploadFile(
|
|
@@ -1481,6 +1492,10 @@ var QueryMapper = class {
|
|
|
1481
1492
|
this.sortMapper = new SortMapper();
|
|
1482
1493
|
this.validator = new QueryValidator(viewMapper);
|
|
1483
1494
|
}
|
|
1495
|
+
viewMapper;
|
|
1496
|
+
filterMapper;
|
|
1497
|
+
sortMapper;
|
|
1498
|
+
validator;
|
|
1484
1499
|
async map(options) {
|
|
1485
1500
|
const {
|
|
1486
1501
|
viewExternalId,
|
|
@@ -1632,6 +1647,7 @@ var QueryResultMapper = class {
|
|
|
1632
1647
|
constructor(viewMapper) {
|
|
1633
1648
|
this.viewMapper = viewMapper;
|
|
1634
1649
|
}
|
|
1650
|
+
viewMapper;
|
|
1635
1651
|
async mapNodes(rootNode, queryResult) {
|
|
1636
1652
|
if (!(rootNode in queryResult)) {
|
|
1637
1653
|
throw new Error(`"${rootNode}" is not available in the query result`);
|
|
@@ -1791,8 +1807,10 @@ var UpsertMapper = class {
|
|
|
1791
1807
|
constructor(viewMapper, cognite) {
|
|
1792
1808
|
this.viewMapper = viewMapper;
|
|
1793
1809
|
this.cognite = cognite;
|
|
1794
|
-
this.validator = new UpsertValidator();
|
|
1795
1810
|
}
|
|
1811
|
+
viewMapper;
|
|
1812
|
+
cognite;
|
|
1813
|
+
validator = new UpsertValidator();
|
|
1796
1814
|
async map(options) {
|
|
1797
1815
|
const rootView = await this.viewMapper.getView(options.viewExternalId);
|
|
1798
1816
|
this.validator.validate(options, rootView);
|
|
@@ -1999,8 +2017,10 @@ var ViewMapper = class {
|
|
|
1999
2017
|
constructor(cognite, dataModelId) {
|
|
2000
2018
|
this.cognite = cognite;
|
|
2001
2019
|
this.dataModelId = dataModelId;
|
|
2002
|
-
this.cachePromise = null;
|
|
2003
2020
|
}
|
|
2021
|
+
cognite;
|
|
2022
|
+
dataModelId;
|
|
2023
|
+
cachePromise = null;
|
|
2004
2024
|
async getView(externalId) {
|
|
2005
2025
|
const views = await this.loadViews();
|
|
2006
2026
|
const view = views.get(externalId);
|
|
@@ -2082,18 +2102,18 @@ function collectPropertyRefs(property) {
|
|
|
2082
2102
|
// src/client.ts
|
|
2083
2103
|
var APPLY_ITEM_LIMIT = 1e3;
|
|
2084
2104
|
var IndustrialModelClient = class {
|
|
2105
|
+
cognite;
|
|
2106
|
+
queryMapper;
|
|
2107
|
+
aggregateMapper;
|
|
2108
|
+
upsertMapper;
|
|
2109
|
+
aggregateResultMapper;
|
|
2110
|
+
resultMapper;
|
|
2111
|
+
datapointsMapper;
|
|
2112
|
+
filesMapper;
|
|
2113
|
+
deleteValidator = new DeleteValidator();
|
|
2114
|
+
resultValidator;
|
|
2115
|
+
validateResults;
|
|
2085
2116
|
constructor(client, dataModelId, options = {}) {
|
|
2086
|
-
this.deleteValidator = new DeleteValidator();
|
|
2087
|
-
this.files = {
|
|
2088
|
-
upload: (fileInfo, content) => this.filesMapper.upload(fileInfo, content),
|
|
2089
|
-
getDownloadUrls: (nodeIds) => this.filesMapper.getDownloadUrls(nodeIds)
|
|
2090
|
-
};
|
|
2091
|
-
this.datapoints = {
|
|
2092
|
-
retrieve: (options) => this.datapointsMapper.retrieve(options),
|
|
2093
|
-
latest: (options) => this.datapointsMapper.retrieveLatest(options),
|
|
2094
|
-
insert: (items) => this.datapointsMapper.insert(items),
|
|
2095
|
-
delete: (ranges) => this.datapointsMapper.delete(ranges)
|
|
2096
|
-
};
|
|
2097
2117
|
const cognite = createCogniteAdapter(client);
|
|
2098
2118
|
this.cognite = cognite;
|
|
2099
2119
|
const viewMapper = new ViewMapper(cognite, dataModelId);
|
|
@@ -2119,6 +2139,16 @@ var IndustrialModelClient = class {
|
|
|
2119
2139
|
const execute = (options) => this.upsertInternal(options);
|
|
2120
2140
|
return execute;
|
|
2121
2141
|
}
|
|
2142
|
+
files = {
|
|
2143
|
+
upload: (fileInfo, content) => this.filesMapper.upload(fileInfo, content),
|
|
2144
|
+
getDownloadUrls: (nodeIds) => this.filesMapper.getDownloadUrls(nodeIds)
|
|
2145
|
+
};
|
|
2146
|
+
datapoints = {
|
|
2147
|
+
retrieve: (options) => this.datapointsMapper.retrieve(options),
|
|
2148
|
+
latest: (options) => this.datapointsMapper.retrieveLatest(options),
|
|
2149
|
+
insert: (items) => this.datapointsMapper.insert(items),
|
|
2150
|
+
delete: (ranges) => this.datapointsMapper.delete(ranges)
|
|
2151
|
+
};
|
|
2122
2152
|
async delete(items) {
|
|
2123
2153
|
this.deleteValidator.validateItems(items);
|
|
2124
2154
|
const deleteItems = items.map((item) => ({
|
|
@@ -2226,6 +2256,7 @@ var COGNITE_CORE_DATA_MODEL = {
|
|
|
2226
2256
|
version: "v1"
|
|
2227
2257
|
};
|
|
2228
2258
|
var CogniteCoreClient = class {
|
|
2259
|
+
model;
|
|
2229
2260
|
constructor(client, options = {}) {
|
|
2230
2261
|
this.model = new IndustrialModelClient(client, COGNITE_CORE_DATA_MODEL, options);
|
|
2231
2262
|
}
|