@iiasa/ixmp4-ts 0.5.0 → 0.7.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.
Files changed (71) hide show
  1. package/dist/cjs/backend.js +7 -4
  2. package/dist/cjs/core/exceptions.js +2 -2
  3. package/dist/cjs/core/iamc/data.js +56 -34
  4. package/dist/cjs/core/iamc/variable.js +10 -0
  5. package/dist/cjs/core/meta.js +15 -5
  6. package/dist/cjs/core/model.js +13 -2
  7. package/dist/cjs/core/region.js +13 -2
  8. package/dist/cjs/core/run.js +17 -6
  9. package/dist/cjs/core/scenario.js +15 -2
  10. package/dist/cjs/core/unit.js +12 -2
  11. package/dist/cjs/core/utils.js +207 -54
  12. package/dist/cjs/data/base.js +29 -7
  13. package/dist/cjs/data/docs.js +2 -2
  14. package/dist/cjs/data/iamc/datapoint.js +18 -11
  15. package/dist/cjs/data/iamc/timeseries.js +12 -12
  16. package/dist/cjs/data/iamc/variable.js +9 -4
  17. package/dist/cjs/data/meta.js +9 -4
  18. package/dist/cjs/data/model.js +9 -4
  19. package/dist/cjs/data/region.js +9 -4
  20. package/dist/cjs/data/run.js +9 -4
  21. package/dist/cjs/data/scenario.js +9 -4
  22. package/dist/cjs/data/unit.js +9 -4
  23. package/dist/cjs/data/utils.js +4 -5
  24. package/dist/cjs/dataframe/dataframe.js +1 -5
  25. package/dist/cjs/dataframe/utils.js +4 -5
  26. package/dist/cjs/index.js +3 -1
  27. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  28. package/dist/esm/backend.js +7 -4
  29. package/dist/esm/core/iamc/data.js +50 -30
  30. package/dist/esm/core/iamc/variable.js +8 -0
  31. package/dist/esm/core/meta.js +8 -0
  32. package/dist/esm/core/model.js +11 -2
  33. package/dist/esm/core/region.js +11 -2
  34. package/dist/esm/core/run.js +11 -2
  35. package/dist/esm/core/scenario.js +13 -2
  36. package/dist/esm/core/unit.js +11 -3
  37. package/dist/esm/core/utils.js +196 -50
  38. package/dist/esm/data/base.js +20 -0
  39. package/dist/esm/data/docs.js +2 -2
  40. package/dist/esm/data/iamc/datapoint.js +5 -0
  41. package/dist/esm/data/iamc/variable.js +3 -0
  42. package/dist/esm/data/meta.js +3 -0
  43. package/dist/esm/data/model.js +3 -0
  44. package/dist/esm/data/region.js +3 -0
  45. package/dist/esm/data/run.js +3 -0
  46. package/dist/esm/data/scenario.js +3 -0
  47. package/dist/esm/data/unit.js +3 -0
  48. package/dist/esm/dataframe/dataframe.js +1 -5
  49. package/dist/esm/index.js +1 -0
  50. package/dist/esm/tsconfig.tsbuildinfo +1 -0
  51. package/dist/types/core/iamc/data.d.ts +33 -5
  52. package/dist/types/core/iamc/variable.d.ts +6 -0
  53. package/dist/types/core/meta.d.ts +6 -0
  54. package/dist/types/core/model.d.ts +9 -2
  55. package/dist/types/core/region.d.ts +7 -1
  56. package/dist/types/core/run.d.ts +7 -1
  57. package/dist/types/core/scenario.d.ts +7 -1
  58. package/dist/types/core/unit.d.ts +7 -1
  59. package/dist/types/core/utils.d.ts +43 -1
  60. package/dist/types/data/base.d.ts +4 -0
  61. package/dist/types/data/iamc/datapoint.d.ts +1 -0
  62. package/dist/types/data/iamc/variable.d.ts +1 -0
  63. package/dist/types/data/meta.d.ts +1 -0
  64. package/dist/types/data/model.d.ts +1 -0
  65. package/dist/types/data/region.d.ts +1 -0
  66. package/dist/types/data/run.d.ts +1 -0
  67. package/dist/types/data/scenario.d.ts +1 -0
  68. package/dist/types/data/unit.d.ts +1 -0
  69. package/dist/types/index.d.ts +2 -1
  70. package/dist/types/tsconfig.types.tsbuildinfo +1 -0
  71. package/package.json +4 -5
@@ -32,16 +32,21 @@ class UnitRepository extends base_1.BaseRepository {
32
32
  return (yield this._get({ name }));
33
33
  });
34
34
  }
35
- list(filter = {}) {
36
- return __awaiter(this, void 0, void 0, function* () {
35
+ list() {
36
+ return __awaiter(this, arguments, void 0, function* (filter = {}) {
37
37
  return (yield this._list({ filter }));
38
38
  });
39
39
  }
40
- tabulate(filter = {}) {
41
- return __awaiter(this, void 0, void 0, function* () {
40
+ tabulate() {
41
+ return __awaiter(this, arguments, void 0, function* (filter = {}) {
42
42
  return yield this._tabulate({ filter });
43
43
  });
44
44
  }
45
+ count() {
46
+ return __awaiter(this, arguments, void 0, function* (filter = {}) {
47
+ return yield this._count({ filter });
48
+ });
49
+ }
45
50
  }
46
51
  exports.UnitRepository = UnitRepository;
47
52
  UnitRepository.prefix = 'units/';
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsonToDf = exports.dfToJson = exports.convertStringToSnakeCase = exports.convertToSnakeCase = void 0;
3
+ exports.convertToSnakeCase = convertToSnakeCase;
4
+ exports.convertStringToSnakeCase = convertStringToSnakeCase;
5
+ exports.dfToJson = dfToJson;
6
+ exports.jsonToDf = jsonToDf;
4
7
  const dataframe_1 = require("../dataframe");
5
8
  function convertStringToSnakeCase(name) {
6
9
  return name.replaceAll(/([A-Z_])/g, '_$1').toLowerCase();
7
10
  }
8
- exports.convertStringToSnakeCase = convertStringToSnakeCase;
9
11
  function convertToSnakeCase(obj) {
10
12
  const snakeCaseObj = {};
11
13
  for (const [key, value] of Object.entries(obj)) {
@@ -18,7 +20,6 @@ function convertToSnakeCase(obj) {
18
20
  }
19
21
  return snakeCaseObj;
20
22
  }
21
- exports.convertToSnakeCase = convertToSnakeCase;
22
23
  function dfToJson(df) {
23
24
  return {
24
25
  index: df.index,
@@ -44,7 +45,6 @@ function dfToJson(df) {
44
45
  data: df.values,
45
46
  };
46
47
  }
47
- exports.dfToJson = dfToJson;
48
48
  function jsonToDf(json) {
49
49
  return new dataframe_1.DataFrame(json.data, {
50
50
  index: json.index,
@@ -67,4 +67,3 @@ function jsonToDf(json) {
67
67
  }),
68
68
  });
69
69
  }
70
- exports.jsonToDf = jsonToDf;
@@ -191,11 +191,7 @@ class DataFrame {
191
191
  values = options.rows.map((i) => values[i]);
192
192
  index = options.rows.map((i) => index[i]);
193
193
  }
194
- return new DataFrame(values, {
195
- index,
196
- columns,
197
- dtypes,
198
- });
194
+ return new DataFrame(values, { index, columns, dtypes });
199
195
  }
200
196
  /**
201
197
  * Returns the value at the specified index and column.
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.merge = exports.toCsv = exports.toJson = exports.concat = void 0;
3
+ exports.concat = concat;
4
+ exports.toJson = toJson;
5
+ exports.toCsv = toCsv;
6
+ exports.merge = merge;
4
7
  const dataframe_1 = require("./dataframe");
5
8
  /**
6
9
  * Concatenates multiple DataFrames along a specified axis.
@@ -18,7 +21,6 @@ function concat(options) {
18
21
  else
19
22
  throw new Error('Invalid value for axis parameter');
20
23
  }
21
- exports.concat = concat;
22
24
  /**
23
25
  * Converts a DataFrame to a JSON object.
24
26
  *
@@ -33,7 +35,6 @@ function toJson(df) {
33
35
  data: df.values,
34
36
  };
35
37
  }
36
- exports.toJson = toJson;
37
38
  /**
38
39
  * Converts a DataFrame to a CSV string.
39
40
  *
@@ -63,7 +64,6 @@ function toCsv(options) {
63
64
  });
64
65
  return header + rows.join('\n');
65
66
  }
66
- exports.toCsv = toCsv;
67
67
  /**
68
68
  * Merges two DataFrames based on specified columns.
69
69
  *
@@ -190,7 +190,6 @@ function merge(options) {
190
190
  dtypes,
191
191
  });
192
192
  }
193
- exports.merge = merge;
194
193
  /* PRIVATE */
195
194
  function concatRows(dataFrames, addMissingColumns) {
196
195
  if (!arraysEqual(...dataFrames.map((df) => df.columns))) {
package/dist/cjs/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidIndex = exports.InvalidColumn = exports.DataFrameError = exports.merge = exports.toCsv = exports.toJson = exports.concat = exports.DType = exports.DataFrame = exports.InvalidCredentials = exports.BadFilterArguments = exports.InvalidRunMeta = exports.NoDefaultRunVersion = exports.SchemaError = exports.OperationNotSupported = exports.DeletionPrevented = exports.NotUnique = exports.NotFound = exports.Forbidden = exports.InvalidToken = exports.MissingToken = exports.PlatformNotUnique = exports.PlatformNotFound = exports.UnknownApiError = exports.ManagerApiError = exports.ImproperlyConfigured = exports.BadRequest = exports.InconsistentIamcType = exports.ProgrammingError = exports.IxmpError = exports.Platform = void 0;
3
+ exports.InvalidIndex = exports.InvalidColumn = exports.DataFrameError = exports.merge = exports.toCsv = exports.toJson = exports.concat = exports.DType = exports.DataFrame = exports.InvalidCredentials = exports.BadFilterArguments = exports.InvalidRunMeta = exports.NoDefaultRunVersion = exports.SchemaError = exports.OperationNotSupported = exports.DeletionPrevented = exports.NotUnique = exports.NotFound = exports.Forbidden = exports.InvalidToken = exports.MissingToken = exports.PlatformNotUnique = exports.PlatformNotFound = exports.UnknownApiError = exports.ManagerApiError = exports.ImproperlyConfigured = exports.BadRequest = exports.InconsistentIamcType = exports.ProgrammingError = exports.IxmpError = exports.DataPointType = exports.Platform = void 0;
4
4
  var platform_1 = require("./core/platform");
5
5
  Object.defineProperty(exports, "Platform", { enumerable: true, get: function () { return platform_1.Platform; } });
6
+ var datapoint_1 = require("./data/iamc/datapoint");
7
+ Object.defineProperty(exports, "DataPointType", { enumerable: true, get: function () { return datapoint_1.DataPointType; } });
6
8
  var exceptions_1 = require("./core/exceptions");
7
9
  Object.defineProperty(exports, "IxmpError", { enumerable: true, get: function () { return exceptions_1.IxmpError; } });
8
10
  Object.defineProperty(exports, "ProgrammingError", { enumerable: true, get: function () { return exceptions_1.ProgrammingError; } });
@@ -0,0 +1 @@
1
+ {"root":["../../src/backend.ts","../../src/index.ts","../../src/core/base.ts","../../src/core/exceptions.ts","../../src/core/meta.ts","../../src/core/model.ts","../../src/core/platform.ts","../../src/core/region.ts","../../src/core/run.ts","../../src/core/scenario.ts","../../src/core/unit.ts","../../src/core/utils.ts","../../src/core/iamc/data.ts","../../src/core/iamc/variable.ts","../../src/data/base.ts","../../src/data/docs.ts","../../src/data/filters.ts","../../src/data/info.ts","../../src/data/meta.ts","../../src/data/model.ts","../../src/data/region.ts","../../src/data/run.ts","../../src/data/scenario.ts","../../src/data/unit.ts","../../src/data/utils.ts","../../src/data/iamc/datapoint.ts","../../src/data/iamc/index.ts","../../src/data/iamc/timeseries.ts","../../src/data/iamc/variable.ts","../../src/dataframe/dataframe.ts","../../src/dataframe/exceptions.ts","../../src/dataframe/index.ts","../../src/dataframe/utils.ts"],"version":"5.9.2"}
@@ -64,23 +64,26 @@ class Backend {
64
64
  client.interceptors.response.use((value) => {
65
65
  return value;
66
66
  }, async (err) => {
67
- if (err.response &&
67
+ const originalRequest = err.config;
68
+ if (!originalRequest._retry &&
69
+ err.response &&
68
70
  ((err.response.status === 401 &&
69
71
  err.response.data.error_name === 'invalid_token') ||
70
72
  (err.response.status === 403 &&
71
73
  err.response.data.error_name === 'forbidden' &&
72
74
  auth.accessToken === null))) {
75
+ originalRequest._retry = true;
73
76
  return await auth
74
77
  .refreshOrObtainAccessToken()
75
78
  .then(() => {
76
79
  return client.request(err.config);
77
80
  })
78
- .catch(() => {
79
- throw new Error('Failed to retrieve or refresh token');
81
+ .catch((error) => {
82
+ return Promise.reject(error);
80
83
  });
81
84
  }
82
85
  else {
83
- throw err;
86
+ return Promise.reject(err);
84
87
  }
85
88
  });
86
89
  }
@@ -1,6 +1,7 @@
1
1
  import { merge } from '../../dataframe';
2
2
  import { BaseFacade } from '../base';
3
- import { dfToDimensionless, substitudeType, toIamcWide } from '../utils';
3
+ import { DataPointType } from '../../data/iamc/datapoint';
4
+ import { dfToDimensionless, substitudeType, toIamcWide, splitDataFrameByType, standardizeIamcDf, } from '../utils';
4
5
  import { VariableRepository } from './variable';
5
6
  /**
6
7
  * Represents IAMC format data for a specific Run.
@@ -48,15 +49,9 @@ class RunIamcData extends BaseFacade {
48
49
  df = df.dropColumns(['unit', 'variable', 'region']);
49
50
  await this.backend.iamc.datapoints.bulkDelete(df);
50
51
  }
51
- /**
52
- * Tabulates IAMC format timeseries data with optional filtering.
53
- * @param filter Optional. Filter for tabulating IAMC format timeseries data.
54
- * @param wide Optional. Whether to return the data in IAMC wide format or not, defaults to false.
55
- * @returns A DataFrame representing the tabulated data.
56
- * @throws An error if illegal filters are applied.
57
- */
58
- async tabulate({ wide = false, ...filter } = {
52
+ async tabulate({ wide = false, splitByType = false, ...filter } = {
59
53
  wide: false,
54
+ splitByType: false,
60
55
  }) {
61
56
  if (filter !== undefined && filter !== null) {
62
57
  // these filters do not make sense when applied from a Run
@@ -67,12 +62,14 @@ class RunIamcData extends BaseFacade {
67
62
  throw new Error(`Illegal filter for 'iamc.tabulate()': ${illegalFilter}`);
68
63
  }
69
64
  }
70
- return await this.repository.tabulate({
65
+ const df = await this.repository.tabulate({
66
+ ...filter,
71
67
  run: { id: this.run.id, defaultOnly: false },
72
68
  joinRuns: false,
73
69
  wide,
74
- ...filter,
70
+ splitByType,
75
71
  });
72
+ return df;
76
73
  }
77
74
  async contractParameters(df) {
78
75
  let timeseriesDf = df
@@ -116,17 +113,7 @@ class PlatformIamcData extends BaseFacade {
116
113
  super(backend);
117
114
  this.variables = new VariableRepository(this.backend);
118
115
  }
119
- /**
120
- * Tabulates IAMC data with optional filtering.
121
- * @param filter Optional. Filter for retrieving IAMC data.
122
- * @param joinRuns Optional. Whether to join runs or not, defaults to true.
123
- * @param wide Optional. Whether to return the data in IAMC wide format or not, defaults to false.
124
- * @returns A Promise that resolves to a DataFrame containing the tabulated data.
125
- */
126
- async tabulate({ joinRuns = true, wide = false, ...filter } = {
127
- joinRuns: true,
128
- wide: false,
129
- }) {
116
+ async tabulate({ joinRuns = true, wide = false, splitByType = false, ...filter } = { joinRuns: true, wide: false, splitByType: false }) {
130
117
  if (filter === undefined) {
131
118
  filter = {};
132
119
  }
@@ -135,19 +122,52 @@ class PlatformIamcData extends BaseFacade {
135
122
  filter['run'] = { defaultOnly: true };
136
123
  }
137
124
  const joinParameters = true;
138
- let df = await this.backend.iamc.datapoints.tabulate({
125
+ let df = (await this.backend.iamc.datapoints.tabulate({
139
126
  joinRuns,
140
127
  joinParameters,
141
128
  filter,
142
- });
143
- // df = df.dropNa({ axis: 1 });
144
- if (df.columns.includes('time_series__id')) {
145
- df = df.dropColumns(['time_series__id']);
129
+ }));
130
+ if (splitByType) {
131
+ const splitDfs = splitDataFrameByType(df);
132
+ const typeMapping = {
133
+ annual: DataPointType.ANNUAL,
134
+ categorical: DataPointType.CATEGORICAL,
135
+ datetime: DataPointType.DATETIME,
136
+ };
137
+ const presentTypes = [];
138
+ Object.entries(typeMapping).forEach(([key, type]) => {
139
+ const typedKey = key;
140
+ if (splitDfs[typedKey]) {
141
+ presentTypes.push(type);
142
+ if (wide) {
143
+ splitDfs[typedKey] = toIamcWide(splitDfs[typedKey]);
144
+ }
145
+ splitDfs[typedKey] = standardizeIamcDf(splitDfs[typedKey]);
146
+ }
147
+ });
148
+ return { presentTypes, ...splitDfs };
146
149
  }
147
- if (df.columns.includes('unit')) {
148
- df = df.replaceValue('dimensionless', ' ', 'unit');
150
+ else {
151
+ if (wide) {
152
+ df = toIamcWide(df);
153
+ }
154
+ return standardizeIamcDf(df);
155
+ }
156
+ }
157
+ /**
158
+ * Counts IAMC datapoints with optional filtering.
159
+ * @param filter Optional. Filter for counting IAMC datapoints.
160
+ * @returns A promise that resolves to the count of datapoints.
161
+ */
162
+ async count(filter) {
163
+ if (filter === undefined) {
164
+ filter = {};
165
+ }
166
+ // return only default runs unless a run-filter is provided
167
+ if (!Object.hasOwn(filter, 'run')) {
168
+ filter['run'] = { defaultOnly: true };
149
169
  }
150
- return wide ? toIamcWide(df) : df;
170
+ return this.backend.iamc.datapoints.count(filter);
151
171
  }
152
172
  }
153
173
  export { RunIamcData, PlatformIamcData };
@@ -109,5 +109,13 @@ class VariableRepository extends BaseFacade {
109
109
  async tabulate(filter) {
110
110
  return this.backend.iamc.variables.tabulate(filter);
111
111
  }
112
+ /**
113
+ * Counts Variables with optional filtering.
114
+ * @param filter Optional. Filter for counting Variables.
115
+ * @returns A Promise that resolves to the count of Variables.
116
+ */
117
+ async count(filter) {
118
+ return this.backend.iamc.variables.count(filter);
119
+ }
112
120
  }
113
121
  export { Variable, VariableRepository };
@@ -18,6 +18,14 @@ class MetaIndicatorRepository extends BaseFacade {
18
18
  }
19
19
  return await this.backend.meta.tabulate(filter, joinRunIndex);
20
20
  }
21
+ /**
22
+ * Counts meta indicators with optional filtering.
23
+ * @param filter Optional. Filter for counting meta indicators.
24
+ * @returns A promise that resolves to the count of meta indicators.
25
+ */
26
+ async count(filter) {
27
+ return this.backend.meta.count(filter || {});
28
+ }
21
29
  }
22
30
  /**
23
31
  * Repository for accessing meta indicators of a specific run.
@@ -1,4 +1,5 @@
1
1
  import { BaseFacade, BaseModelFacade } from './base';
2
+ import { withIamcDefault } from './utils';
2
3
  /**
3
4
  * Represents a model in the assessment modeling system.
4
5
  */
@@ -96,7 +97,7 @@ class ModelRepository extends BaseFacade {
96
97
  * @returns A promise that resolves to an array of models.
97
98
  */
98
99
  async list(filter) {
99
- const models = await this.backend.models.list(filter);
100
+ const models = await this.backend.models.list(withIamcDefault(filter));
100
101
  return models.map((model) => {
101
102
  return new Model(this.backend, model);
102
103
  });
@@ -107,7 +108,15 @@ class ModelRepository extends BaseFacade {
107
108
  * @returns A promise that resolves to the tabulated result.
108
109
  */
109
110
  async tabulate(filter) {
110
- return this.backend.models.tabulate(filter);
111
+ return this.backend.models.tabulate(withIamcDefault(filter));
112
+ }
113
+ /**
114
+ * Counts models with optional filtering.
115
+ * @param filter Optional. Filter for counting models.
116
+ * @returns A promise that resolves to the count of models.
117
+ */
118
+ async count(filter) {
119
+ return this.backend.models.count(withIamcDefault(filter));
111
120
  }
112
121
  }
113
122
  export { Model, ModelRepository };
@@ -1,4 +1,5 @@
1
1
  import { BaseFacade, BaseModelFacade } from './base';
2
+ import { withIamcDefault } from './utils';
2
3
  /**
3
4
  * Represents a unit in the system.
4
5
  */
@@ -126,7 +127,7 @@ class RegionRepository extends BaseFacade {
126
127
  * @returns A promise that resolves to an array of regions.
127
128
  */
128
129
  async list(filter) {
129
- return this.backend.regions.list(filter).then((models) => {
130
+ return this.backend.regions.list(withIamcDefault(filter)).then((models) => {
130
131
  return models.map((model) => new Region(this.backend, model));
131
132
  });
132
133
  }
@@ -136,7 +137,15 @@ class RegionRepository extends BaseFacade {
136
137
  * @returns A promise that resolves to a DataFrame containing the tabulated regions.
137
138
  */
138
139
  async tabulate(filter) {
139
- return this.backend.regions.tabulate(filter);
140
+ return this.backend.regions.tabulate(withIamcDefault(filter));
141
+ }
142
+ /**
143
+ * Counts regions with optional filtering.
144
+ * @param filter Optional. Filter for counting regions.
145
+ * @returns A promise that resolves to the count of regions.
146
+ */
147
+ async count(filter) {
148
+ return this.backend.regions.count(withIamcDefault(filter));
140
149
  }
141
150
  }
142
151
  export { Region as Region, RegionRepository };
@@ -1,6 +1,7 @@
1
1
  import { BaseFacade, BaseModelFacade } from './base';
2
2
  import { RunIamcData } from './iamc/data';
3
3
  import { RunMetaIndicatorRepository } from './meta';
4
+ import { withIamcDefault } from './utils';
4
5
  /**
5
6
  * Represents a Modeling Run.
6
7
  */
@@ -135,7 +136,7 @@ class RunRepository extends BaseFacade {
135
136
  if (filter.defaultOnly === undefined) {
136
137
  filter.defaultOnly = true;
137
138
  }
138
- const runs = await this.backend.runs.list(filter);
139
+ const runs = await this.backend.runs.list(withIamcDefault(filter));
139
140
  const runPromises = runs.map(async (run) => {
140
141
  return new Run(this.backend, run);
141
142
  });
@@ -150,7 +151,7 @@ class RunRepository extends BaseFacade {
150
151
  if (filter.defaultOnly === undefined) {
151
152
  filter.defaultOnly = true;
152
153
  }
153
- const df = await this.backend.runs.tabulate(filter);
154
+ const df = await this.backend.runs.tabulate(withIamcDefault(filter));
154
155
  const models = await this.backend.models.list();
155
156
  const scenarios = await this.backend.scenarios.list();
156
157
  const modelNames = df.columnValues('model__id').map((id) => {
@@ -166,5 +167,13 @@ class RunRepository extends BaseFacade {
166
167
  columns: ['id', 'model', 'scenario', 'version', 'is_default'],
167
168
  });
168
169
  }
170
+ /**
171
+ * Counts runs with optional filtering.
172
+ * @param filter Optional. Filter for counting runs.
173
+ * @returns A promise that resolves to the count of runs.
174
+ */
175
+ async count(filter = {}) {
176
+ return this.backend.runs.count(withIamcDefault(filter));
177
+ }
169
178
  }
170
179
  export { Run, RunRepository };
@@ -1,4 +1,5 @@
1
1
  import { BaseFacade, BaseModelFacade } from './base';
2
+ import { withIamcDefault } from './utils';
2
3
  /**
3
4
  * Represents a Modeling Scenario.
4
5
  */
@@ -103,7 +104,9 @@ class ScenarioRepository extends BaseFacade {
103
104
  * @returns A Promise that resolves to an array of Scenarios.
104
105
  */
105
106
  async list(filter) {
106
- return this.backend.scenarios.list(filter).then((models) => {
107
+ return this.backend.scenarios
108
+ .list(withIamcDefault(filter))
109
+ .then((models) => {
107
110
  return models.map((model) => new Scenario(this.backend, model));
108
111
  });
109
112
  }
@@ -113,7 +116,15 @@ class ScenarioRepository extends BaseFacade {
113
116
  * @returns A Promise that resolves to a DataFrame containing the tabulated data.
114
117
  */
115
118
  async tabulate(filter) {
116
- return this.backend.scenarios.tabulate(filter);
119
+ return this.backend.scenarios.tabulate(withIamcDefault(filter));
120
+ }
121
+ /**
122
+ * Counts scenarios with optional filtering.
123
+ * @param filter Optional. Filter for counting scenarios.
124
+ * @returns A promise that resolves to the count of scenarios.
125
+ */
126
+ async count(filter) {
127
+ return this.backend.scenarios.count(withIamcDefault(filter));
117
128
  }
118
129
  }
119
130
  export { Scenario, ScenarioRepository };
@@ -1,5 +1,5 @@
1
1
  import { BaseFacade, BaseModelFacade } from './base';
2
- import { unitToDimensionless } from './utils';
2
+ import { withIamcDefault, unitToDimensionless } from './utils';
3
3
  /**
4
4
  * Represents a unit in the system.
5
5
  */
@@ -139,7 +139,7 @@ class UnitRepository extends BaseFacade {
139
139
  * @returns A promise that resolves with an array of Unit objects.
140
140
  */
141
141
  async list(filter) {
142
- return this.backend.units.list(filter).then((models) => {
142
+ return this.backend.units.list(withIamcDefault(filter)).then((models) => {
143
143
  return models.map((model) => new Unit(this.backend, model));
144
144
  });
145
145
  }
@@ -149,7 +149,15 @@ class UnitRepository extends BaseFacade {
149
149
  * @returns A promise that resolves with a DataFrame object.
150
150
  */
151
151
  async tabulate(filter) {
152
- return this.backend.units.tabulate(filter);
152
+ return this.backend.units.tabulate(withIamcDefault(filter));
153
+ }
154
+ /**
155
+ * Counts units with optional filtering.
156
+ * @param filter Optional. Filter for counting units.
157
+ * @returns A promise that resolves to the count of units.
158
+ */
159
+ async count(filter) {
160
+ return this.backend.units.count(withIamcDefault(filter));
153
161
  }
154
162
  }
155
163
  export { Unit, UnitRepository };