@iiasa/ixmp4-ts 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. package/dist/cjs/backend.js +2 -25
  2. package/dist/cjs/core/iamc/data.js +73 -9
  3. package/dist/cjs/core/meta.js +21 -3
  4. package/dist/cjs/core/platform.js +2 -2
  5. package/dist/cjs/core/run.js +1 -1
  6. package/dist/cjs/data/base.js +96 -46
  7. package/dist/cjs/data/docs.js +1 -4
  8. package/dist/cjs/data/iamc/datapoint.js +15 -22
  9. package/dist/cjs/data/iamc/timeseries.js +12 -9
  10. package/dist/cjs/data/iamc/variable.js +5 -6
  11. package/dist/cjs/data/meta.js +4 -8
  12. package/dist/cjs/data/model.js +5 -6
  13. package/dist/cjs/data/region.js +5 -6
  14. package/dist/cjs/data/run.js +5 -9
  15. package/dist/cjs/data/scenario.js +6 -7
  16. package/dist/cjs/data/unit.js +5 -6
  17. package/dist/esm/backend.js +1 -1
  18. package/dist/esm/core/iamc/data.js +61 -8
  19. package/dist/esm/core/meta.js +9 -3
  20. package/dist/esm/core/platform.js +2 -2
  21. package/dist/esm/core/run.js +2 -2
  22. package/dist/esm/data/base.js +69 -45
  23. package/dist/esm/data/docs.js +1 -4
  24. package/dist/esm/data/iamc/datapoint.js +11 -11
  25. package/dist/esm/data/iamc/timeseries.js +12 -9
  26. package/dist/esm/data/iamc/variable.js +5 -6
  27. package/dist/esm/data/meta.js +4 -8
  28. package/dist/esm/data/model.js +5 -6
  29. package/dist/esm/data/region.js +5 -6
  30. package/dist/esm/data/run.js +5 -9
  31. package/dist/esm/data/scenario.js +6 -7
  32. package/dist/esm/data/unit.js +5 -6
  33. package/dist/types/core/iamc/data.d.ts +28 -4
  34. package/dist/types/core/iamc/variable.d.ts +1 -1
  35. package/dist/types/core/meta.d.ts +5 -3
  36. package/dist/types/core/platform.d.ts +2 -2
  37. package/dist/types/core/run.d.ts +2 -2
  38. package/dist/types/data/base.d.ts +28 -6
  39. package/dist/types/data/docs.d.ts +0 -2
  40. package/dist/types/data/iamc/datapoint.d.ts +6 -7
  41. package/dist/types/data/iamc/timeseries.d.ts +9 -5
  42. package/dist/types/data/iamc/variable.d.ts +2 -3
  43. package/dist/types/data/meta.d.ts +2 -5
  44. package/dist/types/data/model.d.ts +2 -3
  45. package/dist/types/data/region.d.ts +2 -3
  46. package/dist/types/data/run.d.ts +2 -5
  47. package/dist/types/data/scenario.d.ts +2 -3
  48. package/dist/types/data/unit.d.ts +2 -3
  49. package/dist/types/index.d.ts +1 -2
  50. package/node_modules/danfojs/package.json +0 -1
  51. package/package.json +11 -3
  52. package/dist/cjs/core/iamc/repository.js +0 -73
  53. package/dist/esm/core/iamc/repository.js +0 -51
  54. package/dist/types/core/iamc/repository.d.ts +0 -30
@@ -14,18 +14,18 @@ const base_1 = require("./base");
14
14
  const docs_1 = require("./docs");
15
15
  class RegionRepository extends base_1.BaseRepository {
16
16
  constructor(client) {
17
- super(client, RegionRepository.prefix, RegionRepository.enumerationMethod);
17
+ super(client);
18
18
  this.docs = new docs_1.DocsRepository(client, 'docs/regions/');
19
19
  }
20
- list(f = {}) {
20
+ list(filter = {}) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
- const Regions = yield this._list(f);
22
+ const Regions = yield this._list({ filter });
23
23
  return Regions;
24
24
  });
25
25
  }
26
- tabulate(f = {}) {
26
+ tabulate(filter = {}) {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
- return yield this._tabulate(f);
28
+ return yield this._tabulate({ filter });
29
29
  });
30
30
  }
31
31
  create(name, hierarchy) {
@@ -50,4 +50,3 @@ class RegionRepository extends base_1.BaseRepository {
50
50
  }
51
51
  exports.RegionRepository = RegionRepository;
52
52
  RegionRepository.prefix = 'regions/';
53
- RegionRepository.enumerationMethod = 'PATCH';
@@ -13,17 +13,14 @@ exports.RunRepository = void 0;
13
13
  const base_1 = require("./base");
14
14
  const exceptions_1 = require("../core/exceptions");
15
15
  class RunRepository extends base_1.BaseRepository {
16
- constructor(client) {
17
- super(client, RunRepository.prefix, RunRepository.enumerationMethod);
18
- }
19
- list(f = {}) {
16
+ list(filter = {}) {
20
17
  return __awaiter(this, void 0, void 0, function* () {
21
- return yield this._list(f);
18
+ return yield this._list({ filter });
22
19
  });
23
20
  }
24
- tabulate(f = {}) {
21
+ tabulate(filter = {}) {
25
22
  return __awaiter(this, void 0, void 0, function* () {
26
- return yield this._tabulate(f);
23
+ return yield this._tabulate({ filter });
27
24
  });
28
25
  }
29
26
  create(modelName, scenarioName) {
@@ -53,7 +50,7 @@ class RunRepository extends base_1.BaseRepository {
53
50
  scenario: { name: scenarioName },
54
51
  isDefault: true,
55
52
  };
56
- const list = yield this._list(filter);
53
+ const list = yield this._list({ filter });
57
54
  if (list.length !== 1) {
58
55
  throw new exceptions_1.NotFound({ message: 'Run has no default version.' });
59
56
  }
@@ -73,4 +70,3 @@ class RunRepository extends base_1.BaseRepository {
73
70
  }
74
71
  exports.RunRepository = RunRepository;
75
72
  RunRepository.prefix = 'runs/';
76
- RunRepository.enumerationMethod = 'PATCH';
@@ -14,22 +14,22 @@ const base_1 = require("./base");
14
14
  const docs_1 = require("./docs");
15
15
  class ScenarioRepository extends base_1.BaseRepository {
16
16
  constructor(client) {
17
- super(client, ScenarioRepository.prefix, ScenarioRepository.enumerationMethod);
17
+ super(client);
18
18
  this.docs = new docs_1.DocsRepository(client, 'docs/scenarios/');
19
19
  }
20
- list(f = {}) {
20
+ list(filter = {}) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
- return (yield this._list(f));
22
+ return (yield this._list({ filter }));
23
23
  });
24
24
  }
25
- tabulate(f = {}) {
25
+ tabulate(filter = {}) {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
- return yield this._tabulate(f);
27
+ return yield this._tabulate({ filter });
28
28
  });
29
29
  }
30
30
  create(name) {
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
- return (yield this._post({ name: name }));
32
+ return (yield this._post({ name }));
33
33
  });
34
34
  }
35
35
  get(name) {
@@ -40,4 +40,3 @@ class ScenarioRepository extends base_1.BaseRepository {
40
40
  }
41
41
  exports.ScenarioRepository = ScenarioRepository;
42
42
  ScenarioRepository.prefix = 'scenarios/';
43
- ScenarioRepository.enumerationMethod = 'PATCH';
@@ -14,7 +14,7 @@ const base_1 = require("./base");
14
14
  const docs_1 = require("./docs");
15
15
  class UnitRepository extends base_1.BaseRepository {
16
16
  constructor(client) {
17
- super(client, UnitRepository.prefix, UnitRepository.enumerationMethod);
17
+ super(client);
18
18
  this.docs = new docs_1.DocsRepository(client, 'docs/units/');
19
19
  }
20
20
  create(name) {
@@ -32,17 +32,16 @@ class UnitRepository extends base_1.BaseRepository {
32
32
  return (yield this._get({ name }));
33
33
  });
34
34
  }
35
- list(f = {}) {
35
+ list(filter = {}) {
36
36
  return __awaiter(this, void 0, void 0, function* () {
37
- return (yield this._list(f));
37
+ return (yield this._list({ filter }));
38
38
  });
39
39
  }
40
- tabulate(f = {}) {
40
+ tabulate(filter = {}) {
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
- return yield this._tabulate(f);
42
+ return yield this._tabulate({ filter });
43
43
  });
44
44
  }
45
45
  }
46
46
  exports.UnitRepository = UnitRepository;
47
47
  UnitRepository.prefix = 'units/';
48
- UnitRepository.enumerationMethod = 'PATCH';
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import * as qs from 'qs';
2
+ import qs from 'qs';
3
3
  import { RunRepository } from './data/run';
4
4
  import { DataPointRepository } from './data/iamc/datapoint';
5
5
  import { ModelRepository } from './data/model';
@@ -1,25 +1,25 @@
1
1
  import * as dfd from 'danfojs';
2
2
  import { BaseFacade } from '../base';
3
- import { IamcRepository } from './repository';
4
3
  import { dfToDimensionless, substitudeType } from '../utils';
4
+ import { VariableRepository } from './variable';
5
5
  /**
6
- * Represents a IAMC format data.
6
+ * Represents IAMC format data for a specific Run.
7
7
  */
8
- class IamcData extends BaseFacade {
8
+ class RunIamcData extends BaseFacade {
9
9
  /**
10
10
  * The run associated with the IAMC data.
11
11
  */
12
12
  run;
13
13
  repository;
14
14
  /**
15
- * Constructs a new instance of the IamcData class.
15
+ * Constructs a new instance of the RunIamcData class.
16
16
  * @param backend The backend instance.
17
17
  * @param run The run associated with the IAMC data.
18
18
  */
19
19
  constructor(backend, run) {
20
20
  super(backend);
21
21
  this.run = run;
22
- this.repository = new IamcRepository(this.backend);
22
+ this.repository = new PlatformIamcData(this.backend);
23
23
  }
24
24
  /**
25
25
  * Adds timeseries data in IAMC format.
@@ -69,7 +69,7 @@ class IamcData extends BaseFacade {
69
69
  }
70
70
  }
71
71
  return await this.repository.tabulate({
72
- run: { id: this.run.id },
72
+ run: { id: this.run.id, defaultOnly: false },
73
73
  joinRuns: false,
74
74
  ...filter,
75
75
  });
@@ -80,7 +80,10 @@ class IamcData extends BaseFacade {
80
80
  .agg({ run__id: 'min' })
81
81
  .loc({ columns: ['region', 'variable', 'unit', 'run__id'] });
82
82
  await this.backend.iamc.timeseries.bulkUpsert(timeseriesDf, true);
83
- timeseriesDf = await this.backend.iamc.timeseries.tabulate(this.run.id, true);
83
+ timeseriesDf = await this.backend.iamc.timeseries.tabulate({
84
+ filter: { run: { id: this.run.id, defaultOnly: false } },
85
+ joinParameters: true,
86
+ });
84
87
  timeseriesDf = timeseriesDf.rename({ id: 'time_series__id' });
85
88
  // mimick pandas merge suffix option by manually renaming overlapping columns
86
89
  df.columns
@@ -96,4 +99,54 @@ class IamcData extends BaseFacade {
96
99
  });
97
100
  }
98
101
  }
99
- export { IamcData };
102
+ /**
103
+ * Represents IAMC format data for a specific a modling platform.
104
+ */
105
+ class PlatformIamcData extends BaseFacade {
106
+ /**
107
+ * Repository for managing IAMC variables.
108
+ */
109
+ variables;
110
+ /**
111
+ * Constructs a new instance of the PlatformIamcData class.
112
+ * @param backend The backend instance used for data retrieval.
113
+ */
114
+ constructor(backend) {
115
+ super(backend);
116
+ this.variables = new VariableRepository(this.backend);
117
+ }
118
+ /**
119
+ * Tabulates IAMC data with optional filtering.
120
+ * @param filter Optional. Filter for retrieving IAMC data.
121
+ * @param filter.joinRuns Optional. Whether to join runs or not, defaults to true.
122
+ * @returns A Promise that resolves to a dfd.DataFrame containing the tabulated data.
123
+ */
124
+ async tabulate({ joinRuns = true, ...filter } = {
125
+ joinRuns: true,
126
+ }) {
127
+ if (filter === undefined) {
128
+ filter = {};
129
+ }
130
+ // return only default runs unless a run-filter is provided
131
+ if (!Object.hasOwn(filter, 'run')) {
132
+ filter['run'] = { defaultOnly: true };
133
+ }
134
+ const joinParameters = true;
135
+ let df = await this.backend.iamc.datapoints.tabulate({
136
+ joinRuns,
137
+ joinParameters,
138
+ filter,
139
+ });
140
+ df = df.dropNa({ axis: 1 });
141
+ if (df.columns.includes('time_series__id')) {
142
+ df = df.drop({ columns: ['time_series__id'] });
143
+ }
144
+ if (df.columns.includes('unit')) {
145
+ // TODO report bug to danfojs: df.replace('oldValue', '', { columns: ['column_name'] }) throws: Params Error: Must specify param 'newValue' to replace with (probably newValue is cast to boolean and emty string is falsy)
146
+ df = df.replace('dimensionless', ' ', { columns: ['unit'] });
147
+ console.warn(`Unit name "dimensionless" has been replaced with ' ', this will be rejected by ixmp4.`);
148
+ }
149
+ return df;
150
+ }
151
+ }
152
+ export { RunIamcData, PlatformIamcData };
@@ -6,11 +6,17 @@ import { BaseFacade } from './base';
6
6
  class MetaIndicatorRepository extends BaseFacade {
7
7
  /**
8
8
  * Tabulates meta indicators based on the provided filter.
9
- * @param filter The filter to apply to the meta indicators.
9
+ * @param filter Optional. The filter to apply to the meta indicators.
10
+ * @param joinRunIndex Optional. Whether to join the run index to the tabulated data, defaults to true.
10
11
  * @returns A promise that resolves to a dfd.DataFrame containing the tabulated meta indicators.
11
12
  */
12
- async tabulate(filter) {
13
- return (await this.backend.meta.tabulate(filter)).drop({
13
+ async tabulate({ joinRunIndex = true, ...filter } = {
14
+ joinRunIndex: true,
15
+ }) {
16
+ if (filter === undefined) {
17
+ filter = {};
18
+ }
19
+ return (await this.backend.meta.tabulate(filter, joinRunIndex)).drop({
14
20
  columns: ['id', 'type'],
15
21
  });
16
22
  }
@@ -3,7 +3,7 @@ import { RunRepository } from './run';
3
3
  import { ScenarioRepository } from './scenario';
4
4
  import { MetaIndicatorRepository } from './meta';
5
5
  import { ModelRepository } from './model';
6
- import { IamcRepository } from './iamc/repository';
6
+ import { PlatformIamcData } from './iamc/data';
7
7
  import { RegionRepository } from './region';
8
8
  import { UnitRepository } from './unit';
9
9
  /**
@@ -35,7 +35,7 @@ class Platform {
35
35
  constructor(backend) {
36
36
  this.backend = backend;
37
37
  this.runs = new RunRepository(backend);
38
- this.iamc = new IamcRepository(backend);
38
+ this.iamc = new PlatformIamcData(backend);
39
39
  this.scenarios = new ScenarioRepository(backend);
40
40
  this.models = new ModelRepository(backend);
41
41
  this.meta = new MetaIndicatorRepository(backend);
@@ -1,5 +1,5 @@
1
1
  import { BaseFacade, BaseModelFacade } from './base';
2
- import { IamcData } from './iamc/data';
2
+ import { RunIamcData } from './iamc/data';
3
3
  import { RunMetaIndicatorRepository } from './meta';
4
4
  /**
5
5
  * Represents a Modeling Run.
@@ -20,7 +20,7 @@ class Run extends BaseModelFacade {
20
20
  */
21
21
  constructor(backend, model) {
22
22
  super(backend, model);
23
- this.iamc = new IamcData(this.backend, this.dataModel);
23
+ this.iamc = new RunIamcData(this.backend, this.dataModel);
24
24
  this.meta = new RunMetaIndicatorRepository(this.backend, this.dataModel);
25
25
  }
26
26
  /**
@@ -1,3 +1,4 @@
1
+ import * as dfd from 'danfojs';
1
2
  import { NotFound, UnknownApiError, createError } from '../core/exceptions';
2
3
  import { convertToSnakeCase, dfToJson, jsonToDf } from './utils';
3
4
  class BaseRepository {
@@ -5,21 +6,24 @@ class BaseRepository {
5
6
  // prefix must end with a slash
6
7
  prefix;
7
8
  enumerationMethod;
8
- constructor(client, prefix, enumerationMethod) {
9
+ constructor(client, prefix) {
9
10
  this.client = client;
10
- if (!prefix)
11
+ // use static porperties of extending classes via this.constructor
12
+ // @ts-ignore
13
+ this.prefix = prefix ?? this.constructor.prefix;
14
+ if (!this.prefix)
11
15
  throw new TypeError('Cannot instantiate repository without URL prefix.');
12
- this.prefix = prefix;
13
- this.enumerationMethod = enumerationMethod ?? 'GET';
16
+ // @ts-ignore
17
+ this.enumerationMethod = this.constructor.enumerationMethod ?? 'PATCH';
14
18
  }
15
- async _request(url, method, params, data) {
19
+ async _request(url, method, params, body) {
16
20
  const config = {};
17
21
  config.url = url;
18
22
  config.method = method;
19
23
  if (params !== undefined)
20
24
  config.params = params;
21
- if (data !== undefined)
22
- config.data = data;
25
+ if (body !== undefined)
26
+ config.data = body;
23
27
  try {
24
28
  const res = await this.client.request(config);
25
29
  return res.data;
@@ -29,7 +33,7 @@ class BaseRepository {
29
33
  }
30
34
  }
31
35
  async _get(filter) {
32
- const list = await this._list(filter);
36
+ const list = await this._list({ filter });
33
37
  if (list.length !== 1) {
34
38
  throw new NotFound({
35
39
  messsage: `Expected exactly one result, got ${list.length} instead.`,
@@ -51,49 +55,72 @@ class BaseRepository {
51
55
  const url = `${this.prefix}${id}`;
52
56
  return await this._request(url, 'DELETE');
53
57
  }
54
- async _enumerate(filter, table = false) {
55
- let params = {};
56
- let data = undefined;
57
- filter = convertToSnakeCase(filter);
58
- if (Object.hasOwn(filter, 'join_parameters')) {
59
- params['join_parameters'] = filter['join_parameters'];
60
- delete filter['join_parameters'];
58
+ /**
59
+ * Convenience method for requests to the enumeration endpoint.
60
+ */
61
+ async _requestEnumeration(params = {}, body = {}, table = false) {
62
+ params = convertToSnakeCase(params);
63
+ if (body !== undefined && Object.keys(body).length === 0) {
64
+ body = undefined;
61
65
  }
62
- if (Object.hasOwn(filter, 'join_runs')) {
63
- params['join_runs'] = filter['join_runs'];
64
- delete filter['join_runs'];
65
- }
66
- if (Object.hasOwn(filter, 'join_run_index')) {
67
- params['join_run_index'] = filter['join_run_index'];
68
- delete filter['join_run_index'];
69
- }
70
- if (table) {
71
- params['table'] = true;
66
+ else {
67
+ body = convertToSnakeCase(body);
72
68
  }
73
- if (this.enumerationMethod === 'GET') {
74
- for (const [key, value] of Object.entries(filter)) {
75
- params[key] = value;
76
- }
69
+ const res = await this._request(this.prefix, this.enumerationMethod, { ...params, table }, body);
70
+ return res;
71
+ }
72
+ /**
73
+ * Convenience method for paginated requests to the enumeration endpoint.
74
+ *
75
+ * @returns A list of lists of results.
76
+ */
77
+ async _handlePagination(page, table, params, body) {
78
+ const total = page.total;
79
+ const pagination = page.pagination;
80
+ const offset = pagination?.offset;
81
+ const limit = pagination?.limit;
82
+ if (total <= offset + limit) {
83
+ return [page.results];
77
84
  }
78
85
  else {
79
- data = filter;
86
+ const newParams = { limit, offset: offset + limit };
87
+ params = { ...params, ...newParams };
88
+ const nextData = await this._requestEnumeration(params, body, table);
89
+ const pages = await this._handlePagination(nextData, table, params, body);
90
+ return [page.results, ...pages];
80
91
  }
81
- if (Object.keys(params).length === 0) {
82
- params = undefined;
92
+ }
93
+ async _list({ filter, params, }) {
94
+ const data = await this._requestEnumeration(params, filter, false);
95
+ const pagination = data.pagination;
96
+ if (pagination !== undefined) {
97
+ const pages = await this._handlePagination(data, false, params, filter);
98
+ return pages.flatMap((page) => page);
83
99
  }
84
- if (data !== undefined && Object.keys(data).length === 0) {
85
- data = undefined;
100
+ else {
101
+ return data;
86
102
  }
87
- const res = await this._request(this.prefix, this.enumerationMethod, params, data);
88
- return res;
89
- }
90
- async _list(filter) {
91
- return await this._enumerate(filter);
92
103
  }
93
- async _tabulate(filter) {
94
- const jdf = await this._enumerate(filter, true);
104
+ async _tabulate({ filter, params, }) {
95
105
  // TODO: test what happens if we get a number that cannot be represented as float32 (or int32)
96
- return jsonToDf(jdf);
106
+ const data = await this._requestEnumeration(params, filter, true);
107
+ const pagination = data.pagination;
108
+ if (pagination !== undefined) {
109
+ const pages = await this._handlePagination(data, true, params, filter);
110
+ // return a single dataframe if there is only one page, since dfd.concat() does not handle that properly
111
+ if (pages.length === 1) {
112
+ return jsonToDf(pages[0]);
113
+ }
114
+ else {
115
+ const dfList = pages
116
+ .map((page) => jsonToDf(page))
117
+ .filter((df) => df.length !== undefined);
118
+ return dfd.concat({ dfList: dfList, axis: 0 });
119
+ }
120
+ }
121
+ else {
122
+ return jsonToDf(data);
123
+ }
97
124
  }
98
125
  async _bulkUpsert(df, params) {
99
126
  return await this._request(`${this.prefix}bulk/`, 'POST', params, dfToJson(df));
@@ -101,9 +128,6 @@ class BaseRepository {
101
128
  async _bulkDelete(df, params) {
102
129
  return await this._request(`${this.prefix}bulk/`, 'PATCH', params, dfToJson(df));
103
130
  }
104
- static requestInfo(config) {
105
- return `path:${config.url} method:${config.method}; params:${JSON.stringify(config.params)}; data:${JSON.stringify(config.data)};`;
106
- }
107
131
  static throwRemoteException(res, statusCode) {
108
132
  const json = res?.data;
109
133
  if (typeof json !== 'object' ||
@@ -1,9 +1,6 @@
1
1
  import { BaseRepository } from './base';
2
2
  class DocsRepository extends BaseRepository {
3
3
  static enumerationMethod = 'GET';
4
- constructor(client, prefix) {
5
- super(client, prefix, DocsRepository.enumerationMethod);
6
- }
7
4
  async get(dimensionId) {
8
5
  return await this._get({ dimension_id: dimensionId });
9
6
  }
@@ -14,7 +11,7 @@ class DocsRepository extends BaseRepository {
14
11
  }));
15
12
  }
16
13
  async list(dimensionId) {
17
- return await this._list({ dimension_id: dimensionId });
14
+ return await this._list({ filter: { dimension_id: dimensionId } });
18
15
  }
19
16
  async delete(dimensionId) {
20
17
  await this._delete(dimensionId);
@@ -7,26 +7,26 @@ var DataPointType;
7
7
  })(DataPointType || (DataPointType = {}));
8
8
  class DataPointRepository extends BaseRepository {
9
9
  static prefix = 'iamc/datapoints/';
10
- static enumerationMethod = 'PATCH';
11
- constructor(client) {
12
- super(client, DataPointRepository.prefix, DataPointRepository.enumerationMethod);
13
- }
14
- async list({ joinParameters = false, ...filter } = {
10
+ async list({ joinParameters = false, filter = {}, } = {
15
11
  joinParameters: false,
12
+ filter: {},
16
13
  }) {
17
14
  return (await this._list({
18
- joinParameters,
19
- ...filter,
15
+ filter,
16
+ params: { joinParameters },
20
17
  }));
21
18
  }
22
- async tabulate({ joinParameters = false, joinRuns = false, ...filter } = {
19
+ async tabulate({ joinParameters = false, joinRuns = false, filter = {}, } = {
23
20
  joinParameters: false,
24
21
  joinRuns: false,
22
+ filter: {},
25
23
  }) {
26
24
  return await this._tabulate({
27
- joinParameters,
28
- joinRuns,
29
- ...filter,
25
+ filter,
26
+ params: {
27
+ joinParameters,
28
+ joinRuns,
29
+ },
30
30
  });
31
31
  }
32
32
  async bulkUpsert(df) {
@@ -2,9 +2,6 @@ import { BaseRepository } from '../base';
2
2
  import { NotFound } from '../../core/exceptions';
3
3
  class TimeSeriesRepository extends BaseRepository {
4
4
  static prefix = 'iamc/timeseries/';
5
- constructor(client) {
6
- super(client, TimeSeriesRepository.prefix);
7
- }
8
5
  async create(runId, parameters) {
9
6
  return (await this._post({
10
7
  run_id: runId,
@@ -33,16 +30,22 @@ class TimeSeriesRepository extends BaseRepository {
33
30
  }
34
31
  }
35
32
  }
36
- async list(runIds = [], joinParameters = false) {
33
+ async list({ joinParameters = false, filter = {}, } = {
34
+ joinParameters: false,
35
+ filter: {},
36
+ }) {
37
37
  return (await this._list({
38
- runIds,
39
- joinParameters,
38
+ filter,
39
+ params: { joinParameters },
40
40
  }));
41
41
  }
42
- async tabulate(runIds = [], joinParameters = false) {
42
+ async tabulate({ joinParameters = false, filter = {}, } = {
43
+ joinParameters: false,
44
+ filter: {},
45
+ }) {
43
46
  return await this._tabulate({
44
- runIds,
45
- joinParameters,
47
+ filter,
48
+ params: { joinParameters },
46
49
  });
47
50
  }
48
51
  async bulkUpsert(df, createRelated = false) {
@@ -2,17 +2,16 @@ import { BaseRepository } from '../base';
2
2
  import { DocsRepository } from '../docs';
3
3
  class VariableRepository extends BaseRepository {
4
4
  static prefix = 'iamc/variables/';
5
- static enumerationMethod = 'PATCH';
6
5
  docs;
7
6
  constructor(client) {
8
- super(client, VariableRepository.prefix, VariableRepository.enumerationMethod);
7
+ super(client);
9
8
  this.docs = new DocsRepository(client, 'docs/iamc/variables/');
10
9
  }
11
- async list(f = {}) {
12
- return await this._list(f);
10
+ async list(filter = {}) {
11
+ return await this._list({ filter });
13
12
  }
14
- async tabulate(f = {}) {
15
- return await this._tabulate(f);
13
+ async tabulate(filter = {}) {
14
+ return await this._tabulate({ filter });
16
15
  }
17
16
  async create(name) {
18
17
  return await this._post({ name });
@@ -8,15 +8,11 @@ var MetaIndicatorType;
8
8
  })(MetaIndicatorType || (MetaIndicatorType = {}));
9
9
  class MetaIndicatorRepository extends BaseRepository {
10
10
  static prefix = 'meta/';
11
- static enumerationMethod = 'PATCH';
12
- constructor(client) {
13
- super(client, MetaIndicatorRepository.prefix, MetaIndicatorRepository.enumerationMethod);
11
+ async list(filter = {}) {
12
+ return await this._list(filter);
14
13
  }
15
- async list(f = {}) {
16
- return await this._list(f);
17
- }
18
- async tabulate(f = {}) {
19
- return await this._tabulate(f);
14
+ async tabulate(filter = {}, joinRunIndex) {
15
+ return await this._tabulate({ filter, params: { joinRunIndex } });
20
16
  }
21
17
  async create(run__id, key, value) {
22
18
  const res = await this._post({
@@ -2,17 +2,16 @@ import { BaseRepository } from './base';
2
2
  import { DocsRepository } from './docs';
3
3
  class ModelRepository extends BaseRepository {
4
4
  static prefix = 'models/';
5
- static enumerationMethod = 'PATCH';
6
5
  docs;
7
6
  constructor(client) {
8
- super(client, ModelRepository.prefix, ModelRepository.enumerationMethod);
7
+ super(client);
9
8
  this.docs = new DocsRepository(client, 'docs/models/');
10
9
  }
11
- async list(f = {}) {
12
- return await this._list(f);
10
+ async list(filter = {}) {
11
+ return await this._list({ filter });
13
12
  }
14
- async tabulate(f = {}) {
15
- return await this._tabulate(f);
13
+ async tabulate(filter = {}) {
14
+ return await this._tabulate({ filter });
16
15
  }
17
16
  async create(name) {
18
17
  const res = await this._post({ name });
@@ -2,18 +2,17 @@ import { BaseRepository } from './base';
2
2
  import { DocsRepository } from './docs';
3
3
  class RegionRepository extends BaseRepository {
4
4
  static prefix = 'regions/';
5
- static enumerationMethod = 'PATCH';
6
5
  docs;
7
6
  constructor(client) {
8
- super(client, RegionRepository.prefix, RegionRepository.enumerationMethod);
7
+ super(client);
9
8
  this.docs = new DocsRepository(client, 'docs/regions/');
10
9
  }
11
- async list(f = {}) {
12
- const Regions = await this._list(f);
10
+ async list(filter = {}) {
11
+ const Regions = await this._list({ filter });
13
12
  return Regions;
14
13
  }
15
- async tabulate(f = {}) {
16
- return await this._tabulate(f);
14
+ async tabulate(filter = {}) {
15
+ return await this._tabulate({ filter });
17
16
  }
18
17
  async create(name, hierarchy) {
19
18
  const res = await this._post({