@iiasa/ixmp4-ts 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/core/iamc/data.js +73 -9
- package/dist/cjs/core/meta.js +21 -3
- package/dist/cjs/core/platform.js +2 -2
- package/dist/cjs/core/run.js +1 -1
- package/dist/cjs/data/base.js +96 -46
- package/dist/cjs/data/docs.js +1 -4
- package/dist/cjs/data/iamc/datapoint.js +15 -22
- package/dist/cjs/data/iamc/timeseries.js +12 -9
- package/dist/cjs/data/iamc/variable.js +5 -6
- package/dist/cjs/data/meta.js +4 -8
- package/dist/cjs/data/model.js +5 -6
- package/dist/cjs/data/region.js +5 -6
- package/dist/cjs/data/run.js +5 -9
- package/dist/cjs/data/scenario.js +6 -7
- package/dist/cjs/data/unit.js +5 -6
- package/dist/esm/core/iamc/data.js +61 -8
- package/dist/esm/core/meta.js +9 -3
- package/dist/esm/core/platform.js +2 -2
- package/dist/esm/core/run.js +2 -2
- package/dist/esm/data/base.js +69 -45
- package/dist/esm/data/docs.js +1 -4
- package/dist/esm/data/iamc/datapoint.js +11 -11
- package/dist/esm/data/iamc/timeseries.js +12 -9
- package/dist/esm/data/iamc/variable.js +5 -6
- package/dist/esm/data/meta.js +4 -8
- package/dist/esm/data/model.js +5 -6
- package/dist/esm/data/region.js +5 -6
- package/dist/esm/data/run.js +5 -9
- package/dist/esm/data/scenario.js +6 -7
- package/dist/esm/data/unit.js +5 -6
- package/dist/types/core/iamc/data.d.ts +28 -4
- package/dist/types/core/iamc/variable.d.ts +1 -1
- package/dist/types/core/meta.d.ts +5 -3
- package/dist/types/core/platform.d.ts +2 -2
- package/dist/types/core/run.d.ts +2 -2
- package/dist/types/data/base.d.ts +28 -6
- package/dist/types/data/docs.d.ts +0 -2
- package/dist/types/data/iamc/datapoint.d.ts +6 -7
- package/dist/types/data/iamc/timeseries.d.ts +9 -5
- package/dist/types/data/iamc/variable.d.ts +2 -3
- package/dist/types/data/meta.d.ts +2 -5
- package/dist/types/data/model.d.ts +2 -3
- package/dist/types/data/region.d.ts +2 -3
- package/dist/types/data/run.d.ts +2 -5
- package/dist/types/data/scenario.d.ts +2 -3
- package/dist/types/data/unit.d.ts +2 -3
- package/dist/types/index.d.ts +1 -2
- package/package.json +11 -4
- package/dist/cjs/core/iamc/repository.js +0 -73
- package/dist/esm/core/iamc/repository.js +0 -51
- package/dist/types/core/iamc/repository.d.ts +0 -30
@@ -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
|
17
|
+
super(client);
|
18
18
|
this.docs = new docs_1.DocsRepository(client, 'docs/scenarios/');
|
19
19
|
}
|
20
|
-
list(
|
20
|
+
list(filter = {}) {
|
21
21
|
return __awaiter(this, void 0, void 0, function* () {
|
22
|
-
return (yield this._list(
|
22
|
+
return (yield this._list({ filter }));
|
23
23
|
});
|
24
24
|
}
|
25
|
-
tabulate(
|
25
|
+
tabulate(filter = {}) {
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
27
|
-
return yield this._tabulate(
|
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
|
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';
|
package/dist/cjs/data/unit.js
CHANGED
@@ -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
|
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(
|
35
|
+
list(filter = {}) {
|
36
36
|
return __awaiter(this, void 0, void 0, function* () {
|
37
|
-
return (yield this._list(
|
37
|
+
return (yield this._list({ filter }));
|
38
38
|
});
|
39
39
|
}
|
40
|
-
tabulate(
|
40
|
+
tabulate(filter = {}) {
|
41
41
|
return __awaiter(this, void 0, void 0, function* () {
|
42
|
-
return yield this._tabulate(
|
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,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
|
6
|
+
* Represents IAMC format data for a specific Run.
|
7
7
|
*/
|
8
|
-
class
|
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
|
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
|
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(
|
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
|
-
|
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 };
|
package/dist/esm/core/meta.js
CHANGED
@@ -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
|
-
|
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 {
|
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
|
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);
|
package/dist/esm/core/run.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { BaseFacade, BaseModelFacade } from './base';
|
2
|
-
import {
|
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
|
23
|
+
this.iamc = new RunIamcData(this.backend, this.dataModel);
|
24
24
|
this.meta = new RunMetaIndicatorRepository(this.backend, this.dataModel);
|
25
25
|
}
|
26
26
|
/**
|
package/dist/esm/data/base.js
CHANGED
@@ -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
|
9
|
+
constructor(client, prefix) {
|
9
10
|
this.client = client;
|
10
|
-
|
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
|
-
|
13
|
-
this.enumerationMethod = enumerationMethod ?? '
|
16
|
+
// @ts-ignore
|
17
|
+
this.enumerationMethod = this.constructor.enumerationMethod ?? 'PATCH';
|
14
18
|
}
|
15
|
-
async _request(url, method, params,
|
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 (
|
22
|
-
config.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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
63
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
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
|
-
|
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
|
-
|
82
|
-
|
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
|
-
|
85
|
-
data
|
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
|
-
|
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' ||
|
package/dist/esm/data/docs.js
CHANGED
@@ -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
|
-
|
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
|
-
|
19
|
-
|
15
|
+
filter,
|
16
|
+
params: { joinParameters },
|
20
17
|
}));
|
21
18
|
}
|
22
|
-
async tabulate({ joinParameters = false, joinRuns = false,
|
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
|
-
|
28
|
-
|
29
|
-
|
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(
|
33
|
+
async list({ joinParameters = false, filter = {}, } = {
|
34
|
+
joinParameters: false,
|
35
|
+
filter: {},
|
36
|
+
}) {
|
37
37
|
return (await this._list({
|
38
|
-
|
39
|
-
joinParameters,
|
38
|
+
filter,
|
39
|
+
params: { joinParameters },
|
40
40
|
}));
|
41
41
|
}
|
42
|
-
async tabulate(
|
42
|
+
async tabulate({ joinParameters = false, filter = {}, } = {
|
43
|
+
joinParameters: false,
|
44
|
+
filter: {},
|
45
|
+
}) {
|
43
46
|
return await this._tabulate({
|
44
|
-
|
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
|
7
|
+
super(client);
|
9
8
|
this.docs = new DocsRepository(client, 'docs/iamc/variables/');
|
10
9
|
}
|
11
|
-
async list(
|
12
|
-
return await this._list(
|
10
|
+
async list(filter = {}) {
|
11
|
+
return await this._list({ filter });
|
13
12
|
}
|
14
|
-
async tabulate(
|
15
|
-
return await this._tabulate(
|
13
|
+
async tabulate(filter = {}) {
|
14
|
+
return await this._tabulate({ filter });
|
16
15
|
}
|
17
16
|
async create(name) {
|
18
17
|
return await this._post({ name });
|
package/dist/esm/data/meta.js
CHANGED
@@ -8,15 +8,11 @@ var MetaIndicatorType;
|
|
8
8
|
})(MetaIndicatorType || (MetaIndicatorType = {}));
|
9
9
|
class MetaIndicatorRepository extends BaseRepository {
|
10
10
|
static prefix = 'meta/';
|
11
|
-
|
12
|
-
|
13
|
-
super(client, MetaIndicatorRepository.prefix, MetaIndicatorRepository.enumerationMethod);
|
11
|
+
async list(filter = {}) {
|
12
|
+
return await this._list(filter);
|
14
13
|
}
|
15
|
-
async
|
16
|
-
return await this.
|
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({
|
package/dist/esm/data/model.js
CHANGED
@@ -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
|
7
|
+
super(client);
|
9
8
|
this.docs = new DocsRepository(client, 'docs/models/');
|
10
9
|
}
|
11
|
-
async list(
|
12
|
-
return await this._list(
|
10
|
+
async list(filter = {}) {
|
11
|
+
return await this._list({ filter });
|
13
12
|
}
|
14
|
-
async tabulate(
|
15
|
-
return await this._tabulate(
|
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 });
|
package/dist/esm/data/region.js
CHANGED
@@ -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
|
7
|
+
super(client);
|
9
8
|
this.docs = new DocsRepository(client, 'docs/regions/');
|
10
9
|
}
|
11
|
-
async list(
|
12
|
-
const Regions = await this._list(
|
10
|
+
async list(filter = {}) {
|
11
|
+
const Regions = await this._list({ filter });
|
13
12
|
return Regions;
|
14
13
|
}
|
15
|
-
async tabulate(
|
16
|
-
return await this._tabulate(
|
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({
|
package/dist/esm/data/run.js
CHANGED
@@ -2,15 +2,11 @@ import { BaseRepository } from './base';
|
|
2
2
|
import { NotFound } from '../core/exceptions';
|
3
3
|
class RunRepository extends BaseRepository {
|
4
4
|
static prefix = 'runs/';
|
5
|
-
|
6
|
-
|
7
|
-
super(client, RunRepository.prefix, RunRepository.enumerationMethod);
|
5
|
+
async list(filter = {}) {
|
6
|
+
return await this._list({ filter });
|
8
7
|
}
|
9
|
-
async
|
10
|
-
return await this.
|
11
|
-
}
|
12
|
-
async tabulate(f = {}) {
|
13
|
-
return await this._tabulate(f);
|
8
|
+
async tabulate(filter = {}) {
|
9
|
+
return await this._tabulate({ filter });
|
14
10
|
}
|
15
11
|
async create(modelName, scenarioName) {
|
16
12
|
const res = await this._post({
|
@@ -34,7 +30,7 @@ class RunRepository extends BaseRepository {
|
|
34
30
|
scenario: { name: scenarioName },
|
35
31
|
isDefault: true,
|
36
32
|
};
|
37
|
-
const list = await this._list(filter);
|
33
|
+
const list = await this._list({ filter });
|
38
34
|
if (list.length !== 1) {
|
39
35
|
throw new NotFound({ message: 'Run has no default version.' });
|
40
36
|
}
|
@@ -2,20 +2,19 @@ import { BaseRepository } from './base';
|
|
2
2
|
import { DocsRepository } from './docs';
|
3
3
|
class ScenarioRepository extends BaseRepository {
|
4
4
|
static prefix = 'scenarios/';
|
5
|
-
static enumerationMethod = 'PATCH';
|
6
5
|
docs;
|
7
6
|
constructor(client) {
|
8
|
-
super(client
|
7
|
+
super(client);
|
9
8
|
this.docs = new DocsRepository(client, 'docs/scenarios/');
|
10
9
|
}
|
11
|
-
async list(
|
12
|
-
return (await this._list(
|
10
|
+
async list(filter = {}) {
|
11
|
+
return (await this._list({ filter }));
|
13
12
|
}
|
14
|
-
async tabulate(
|
15
|
-
return await this._tabulate(
|
13
|
+
async tabulate(filter = {}) {
|
14
|
+
return await this._tabulate({ filter });
|
16
15
|
}
|
17
16
|
async create(name) {
|
18
|
-
return (await this._post({ name
|
17
|
+
return (await this._post({ name }));
|
19
18
|
}
|
20
19
|
async get(name) {
|
21
20
|
return (await this._get({ name }));
|