@iiasa/ixmp4-ts 0.1.1 → 0.1.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/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
package/dist/esm/data/unit.js
CHANGED
@@ -2,10 +2,9 @@ import { BaseRepository } from './base';
|
|
2
2
|
import { DocsRepository } from './docs';
|
3
3
|
class UnitRepository extends BaseRepository {
|
4
4
|
static prefix = 'units/';
|
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/units/');
|
10
9
|
}
|
11
10
|
async create(name) {
|
@@ -17,11 +16,11 @@ class UnitRepository extends BaseRepository {
|
|
17
16
|
async get(name) {
|
18
17
|
return (await this._get({ name }));
|
19
18
|
}
|
20
|
-
async list(
|
21
|
-
return (await this._list(
|
19
|
+
async list(filter = {}) {
|
20
|
+
return (await this._list({ filter }));
|
22
21
|
}
|
23
|
-
async tabulate(
|
24
|
-
return await this._tabulate(
|
22
|
+
async tabulate(filter = {}) {
|
23
|
+
return await this._tabulate({ filter });
|
25
24
|
}
|
26
25
|
}
|
27
26
|
export { UnitRepository };
|
@@ -10,6 +10,7 @@ import { UnitFilter as BaseUnitFilter } from '../../data/unit';
|
|
10
10
|
import { RunFilter as BaseRunFilter } from '../../data/run';
|
11
11
|
import { ScenarioFilter as BaseScenarioFilter } from '../../data/scenario';
|
12
12
|
import { IamcDataFilter as BaseIamcDataFilter } from '../../data/iamc/datapoint';
|
13
|
+
import { VariableRepository } from './variable';
|
13
14
|
/**
|
14
15
|
* Represents a filter for tabulating IAMC format data.
|
15
16
|
*/
|
@@ -25,16 +26,16 @@ type IamcDataFilter = BaseIamcDataFilter & {
|
|
25
26
|
};
|
26
27
|
};
|
27
28
|
/**
|
28
|
-
* Represents
|
29
|
+
* Represents IAMC format data for a specific Run.
|
29
30
|
*/
|
30
|
-
declare class
|
31
|
+
declare class RunIamcData extends BaseFacade {
|
31
32
|
/**
|
32
33
|
* The run associated with the IAMC data.
|
33
34
|
*/
|
34
35
|
run: RunModel;
|
35
36
|
private repository;
|
36
37
|
/**
|
37
|
-
* Constructs a new instance of the
|
38
|
+
* Constructs a new instance of the RunIamcData class.
|
38
39
|
* @param backend The backend instance.
|
39
40
|
* @param run The run associated with the IAMC data.
|
40
41
|
*/
|
@@ -60,5 +61,28 @@ declare class IamcData extends BaseFacade {
|
|
60
61
|
tabulate(filter?: IamcDataFilter): Promise<dfd.DataFrame>;
|
61
62
|
private contractParameters;
|
62
63
|
}
|
63
|
-
|
64
|
+
/**
|
65
|
+
* Represents IAMC format data for a specific a modling platform.
|
66
|
+
*/
|
67
|
+
declare class PlatformIamcData extends BaseFacade {
|
68
|
+
/**
|
69
|
+
* Repository for managing IAMC variables.
|
70
|
+
*/
|
71
|
+
variables: VariableRepository;
|
72
|
+
/**
|
73
|
+
* Constructs a new instance of the PlatformIamcData class.
|
74
|
+
* @param backend The backend instance used for data retrieval.
|
75
|
+
*/
|
76
|
+
constructor(backend: Backend);
|
77
|
+
/**
|
78
|
+
* Tabulates IAMC data with optional filtering.
|
79
|
+
* @param filter Optional. Filter for retrieving IAMC data.
|
80
|
+
* @param filter.joinRuns Optional. Whether to join runs or not, defaults to true.
|
81
|
+
* @returns A Promise that resolves to a dfd.DataFrame containing the tabulated data.
|
82
|
+
*/
|
83
|
+
tabulate({ joinRuns, ...filter }?: {
|
84
|
+
joinRuns?: boolean;
|
85
|
+
} & IamcDataFilter): Promise<dfd.DataFrame>;
|
86
|
+
}
|
87
|
+
export { RunIamcData, PlatformIamcData };
|
64
88
|
export type { IamcDataFilter };
|
@@ -8,7 +8,7 @@ import { UnitFilter as BaseUnitFilter } from '../../data/unit';
|
|
8
8
|
import { RunFilter as BaseRunFilter } from '../../data/run';
|
9
9
|
import { ScenarioFilter as BaseScenarioFilter } from '../../data/scenario';
|
10
10
|
/**
|
11
|
-
* Represents a filter for listing and tabulating
|
11
|
+
* Represents a filter for listing and tabulating variables.
|
12
12
|
*/
|
13
13
|
type VariableFilter = BaseVariableFilter & {
|
14
14
|
region?: BaseRegionFilter;
|
@@ -14,7 +14,6 @@ type MetaIndicatorFilter = BaseMetaIndicatorFilter & {
|
|
14
14
|
scenario?: BaseScenarioFilter;
|
15
15
|
model?: BaseModelFilter;
|
16
16
|
};
|
17
|
-
joinRunIndex?: boolean;
|
18
17
|
};
|
19
18
|
/**
|
20
19
|
* Repository for accessing run meta indicators.
|
@@ -22,10 +21,13 @@ type MetaIndicatorFilter = BaseMetaIndicatorFilter & {
|
|
22
21
|
declare class MetaIndicatorRepository extends BaseFacade {
|
23
22
|
/**
|
24
23
|
* Tabulates meta indicators based on the provided filter.
|
25
|
-
* @param filter The filter to apply to the meta indicators.
|
24
|
+
* @param filter Optional. The filter to apply to the meta indicators.
|
25
|
+
* @param joinRunIndex Optional. Whether to join the run index to the tabulated data, defaults to true.
|
26
26
|
* @returns A promise that resolves to a dfd.DataFrame containing the tabulated meta indicators.
|
27
27
|
*/
|
28
|
-
tabulate(filter?:
|
28
|
+
tabulate({ joinRunIndex, ...filter }?: {
|
29
|
+
joinRunIndex?: boolean;
|
30
|
+
} & MetaIndicatorFilter): Promise<dfd.DataFrame>;
|
29
31
|
}
|
30
32
|
/**
|
31
33
|
* Repository for accessing meta indicators of a specific run.
|
@@ -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
|
/**
|
@@ -21,7 +21,7 @@ import { UnitRepository } from './unit';
|
|
21
21
|
*/
|
22
22
|
declare class Platform {
|
23
23
|
runs: RunRepository;
|
24
|
-
iamc:
|
24
|
+
iamc: PlatformIamcData;
|
25
25
|
scenarios: ScenarioRepository;
|
26
26
|
models: ModelRepository;
|
27
27
|
meta: MetaIndicatorRepository;
|
package/dist/types/core/run.d.ts
CHANGED
@@ -4,7 +4,7 @@ import { Run as RunModel } from '../data/run';
|
|
4
4
|
import { Model } from '../data/model';
|
5
5
|
import { Scenario } from '../data/scenario';
|
6
6
|
import { BaseFacade, BaseModelFacade } from './base';
|
7
|
-
import {
|
7
|
+
import { RunIamcData } from './iamc/data';
|
8
8
|
import { RunMetaIndicatorRepository } from './meta';
|
9
9
|
import { ModelFilter as BaseModelFilter } from '../data/model';
|
10
10
|
import { RunFilter as BaseRunFilter } from '../data/run';
|
@@ -27,7 +27,7 @@ declare class Run extends BaseModelFacade<RunModel> {
|
|
27
27
|
/**
|
28
28
|
* The IAMC data associated with the run.
|
29
29
|
*/
|
30
|
-
iamc:
|
30
|
+
iamc: RunIamcData;
|
31
31
|
/**
|
32
32
|
* Creates a new Run instance.
|
33
33
|
* @param backend The backend instance.
|
@@ -6,23 +6,45 @@ type BaseModel = {
|
|
6
6
|
type PlainObject = {
|
7
7
|
[k: string]: any;
|
8
8
|
};
|
9
|
+
type Page = {
|
10
|
+
results: any[];
|
11
|
+
pagination: {
|
12
|
+
limit: number;
|
13
|
+
offset: number;
|
14
|
+
};
|
15
|
+
total: number;
|
16
|
+
};
|
9
17
|
declare class BaseRepository {
|
10
18
|
private client;
|
11
19
|
prefix: string;
|
12
20
|
enumerationMethod: string;
|
13
|
-
constructor(client: AxiosInstance, prefix
|
14
|
-
_request(url: string, method: string, params?: object,
|
21
|
+
constructor(client: AxiosInstance, prefix?: string);
|
22
|
+
_request(url: string, method: string, params?: object, body?: any): Promise<any>;
|
15
23
|
_get(filter: object): Promise<any>;
|
16
24
|
_getById(id: number): Promise<any>;
|
17
25
|
_post(data?: any, url?: string): Promise<any>;
|
18
26
|
_patch(params?: object, data?: any): Promise<any>;
|
19
27
|
_delete(id: number): Promise<void>;
|
20
|
-
|
21
|
-
|
22
|
-
|
28
|
+
/**
|
29
|
+
* Convenience method for requests to the enumeration endpoint.
|
30
|
+
*/
|
31
|
+
_requestEnumeration(params?: object, body?: object, table?: boolean): Promise<any>;
|
32
|
+
/**
|
33
|
+
* Convenience method for paginated requests to the enumeration endpoint.
|
34
|
+
*
|
35
|
+
* @returns A list of lists of results.
|
36
|
+
*/
|
37
|
+
_handlePagination(page: Page, table: boolean, params: object, body: object): Promise<any[]>;
|
38
|
+
_list({ filter, params, }: {
|
39
|
+
filter?: object;
|
40
|
+
params?: object;
|
41
|
+
}): Promise<any[]>;
|
42
|
+
_tabulate({ filter, params, }: {
|
43
|
+
filter?: object;
|
44
|
+
params?: object;
|
45
|
+
}): Promise<dfd.DataFrame>;
|
23
46
|
_bulkUpsert(df: dfd.DataFrame, params?: object): Promise<void>;
|
24
47
|
_bulkDelete(df: dfd.DataFrame, params?: object): Promise<void>;
|
25
|
-
private static requestInfo;
|
26
48
|
private static throwRemoteException;
|
27
49
|
}
|
28
50
|
export { BaseRepository };
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
2
1
|
import { BaseModel, BaseRepository } from './base';
|
3
2
|
type Docs = BaseModel & {
|
4
3
|
description: string;
|
@@ -6,7 +5,6 @@ type Docs = BaseModel & {
|
|
6
5
|
};
|
7
6
|
declare class DocsRepository extends BaseRepository {
|
8
7
|
static enumerationMethod: string;
|
9
|
-
constructor(client: AxiosInstance, prefix: string);
|
10
8
|
get(dimensionId: number): Promise<Docs>;
|
11
9
|
set(dimensionId: number, description: string): Promise<Docs>;
|
12
10
|
list(dimensionId?: number): Promise<Docs[]>;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import * as dfd from 'danfojs';
|
2
|
-
import { AxiosInstance } from 'axios';
|
3
2
|
import { BaseModel, BaseRepository, PlainObject } from '../base';
|
4
3
|
import { Lookup } from '../filters';
|
5
4
|
type DataPoint = BaseModel & {
|
@@ -21,15 +20,15 @@ type IamcDataFilter = Lookup<{
|
|
21
20
|
}>;
|
22
21
|
declare class DataPointRepository extends BaseRepository {
|
23
22
|
static prefix: string;
|
24
|
-
|
25
|
-
constructor(client: AxiosInstance);
|
26
|
-
list({ joinParameters, ...filter }?: {
|
23
|
+
list({ joinParameters, filter, }?: {
|
27
24
|
joinParameters?: boolean;
|
28
|
-
|
29
|
-
|
25
|
+
filter: PlainObject;
|
26
|
+
}): Promise<DataPoint[]>;
|
27
|
+
tabulate({ joinParameters, joinRuns, filter, }?: {
|
30
28
|
joinParameters?: boolean;
|
31
29
|
joinRuns?: boolean;
|
32
|
-
|
30
|
+
filter: PlainObject;
|
31
|
+
}): Promise<dfd.DataFrame>;
|
33
32
|
bulkUpsert(df: dfd.DataFrame): Promise<void>;
|
34
33
|
bulkDelete(df: dfd.DataFrame): Promise<void>;
|
35
34
|
}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import * as dfd from 'danfojs';
|
2
|
-
import {
|
3
|
-
import { BaseModel, BaseRepository } from '../base';
|
2
|
+
import { BaseModel, BaseRepository, PlainObject } from '../base';
|
4
3
|
type TimeSeries = BaseModel & {
|
5
4
|
id: number;
|
6
5
|
run__id: number;
|
@@ -9,13 +8,18 @@ type TimeSeries = BaseModel & {
|
|
9
8
|
type Mapping<K extends string | number | symbol = any, T = any> = Record<K, T>;
|
10
9
|
declare class TimeSeriesRepository extends BaseRepository {
|
11
10
|
static prefix: string;
|
12
|
-
constructor(client: AxiosInstance);
|
13
11
|
create(runId: number, parameters: Mapping): Promise<TimeSeries>;
|
14
12
|
get(runId: number, parameters: Mapping): Promise<TimeSeries>;
|
15
13
|
getById(id: number): Promise<TimeSeries>;
|
16
14
|
getOrCreate(runId: number, parameters: Mapping): Promise<TimeSeries>;
|
17
|
-
list(
|
18
|
-
|
15
|
+
list({ joinParameters, filter, }?: {
|
16
|
+
joinParameters?: boolean;
|
17
|
+
filter: PlainObject;
|
18
|
+
}): Promise<TimeSeries[]>;
|
19
|
+
tabulate({ joinParameters, filter, }?: {
|
20
|
+
joinParameters?: boolean;
|
21
|
+
filter: PlainObject;
|
22
|
+
}): Promise<dfd.DataFrame>;
|
19
23
|
bulkUpsert(df: dfd.DataFrame, createRelated?: boolean): Promise<void>;
|
20
24
|
}
|
21
25
|
export { TimeSeriesRepository };
|
@@ -14,11 +14,10 @@ type VariableFilter = Lookup<{
|
|
14
14
|
}>;
|
15
15
|
declare class VariableRepository extends BaseRepository {
|
16
16
|
static prefix: string;
|
17
|
-
static enumerationMethod: string;
|
18
17
|
docs: DocsRepository;
|
19
18
|
constructor(client: AxiosInstance);
|
20
|
-
list(
|
21
|
-
tabulate(
|
19
|
+
list(filter?: PlainObject): Promise<Variable[]>;
|
20
|
+
tabulate(filter?: PlainObject): Promise<dfd.DataFrame>;
|
22
21
|
create(name: string): Promise<Variable>;
|
23
22
|
get(name: string): Promise<Variable>;
|
24
23
|
}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import * as dfd from 'danfojs';
|
2
|
-
import { AxiosInstance } from 'axios';
|
3
2
|
import { BaseModel, BaseRepository, PlainObject } from './base';
|
4
3
|
import { RunFilter } from './run';
|
5
4
|
import { Lookup } from './filters';
|
@@ -28,10 +27,8 @@ type MetaIndicatorFilter = Lookup<{
|
|
28
27
|
}>;
|
29
28
|
declare class MetaIndicatorRepository extends BaseRepository {
|
30
29
|
static prefix: string;
|
31
|
-
|
32
|
-
|
33
|
-
list(f?: PlainObject): Promise<MetaIndicator[]>;
|
34
|
-
tabulate(f?: PlainObject): Promise<dfd.DataFrame>;
|
30
|
+
list(filter?: PlainObject): Promise<MetaIndicator[]>;
|
31
|
+
tabulate(filter?: PlainObject, joinRunIndex?: boolean): Promise<dfd.DataFrame>;
|
35
32
|
create(run__id: number, key: string, value: string | number | boolean): Promise<MetaIndicator>;
|
36
33
|
get(runId: number, key: string): Promise<MetaIndicator>;
|
37
34
|
delete(id: number): Promise<void>;
|
@@ -14,11 +14,10 @@ type ModelFilter = Lookup<{
|
|
14
14
|
}>;
|
15
15
|
declare class ModelRepository extends BaseRepository {
|
16
16
|
static prefix: string;
|
17
|
-
static enumerationMethod: string;
|
18
17
|
docs: DocsRepository;
|
19
18
|
constructor(client: AxiosInstance);
|
20
|
-
list(
|
21
|
-
tabulate(
|
19
|
+
list(filter?: PlainObject): Promise<Model[]>;
|
20
|
+
tabulate(filter?: PlainObject): Promise<dfd.DataFrame>;
|
22
21
|
create(name: string): Promise<Model>;
|
23
22
|
get(name: string): Promise<Model>;
|
24
23
|
}
|
@@ -16,11 +16,10 @@ type RegionFilter = Lookup<{
|
|
16
16
|
}>;
|
17
17
|
declare class RegionRepository extends BaseRepository {
|
18
18
|
static prefix: string;
|
19
|
-
static enumerationMethod: string;
|
20
19
|
docs: DocsRepository;
|
21
20
|
constructor(client: AxiosInstance);
|
22
|
-
list(
|
23
|
-
tabulate(
|
21
|
+
list(filter?: PlainObject): Promise<Region[]>;
|
22
|
+
tabulate(filter?: PlainObject): Promise<dfd.DataFrame>;
|
24
23
|
create(name: string, hierarchy: string): Promise<Region>;
|
25
24
|
get(name: string): Promise<Region>;
|
26
25
|
delete(id: number): Promise<void>;
|
package/dist/types/data/run.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import * as dfd from 'danfojs';
|
2
|
-
import { AxiosInstance } from 'axios';
|
3
2
|
import { BaseModel, BaseRepository, PlainObject } from './base';
|
4
3
|
import { Scenario } from './scenario';
|
5
4
|
import { Model } from './model';
|
@@ -20,10 +19,8 @@ type RunFilter = Lookup<{
|
|
20
19
|
}>;
|
21
20
|
declare class RunRepository extends BaseRepository {
|
22
21
|
static prefix: string;
|
23
|
-
|
24
|
-
|
25
|
-
list(f?: PlainObject): Promise<Run[]>;
|
26
|
-
tabulate(f?: PlainObject): Promise<dfd.DataFrame>;
|
22
|
+
list(filter?: PlainObject): Promise<Run[]>;
|
23
|
+
tabulate(filter?: PlainObject): Promise<dfd.DataFrame>;
|
27
24
|
create(modelName: string, scenarioName: string): Promise<Run>;
|
28
25
|
get(modelName: string, scenarioName: string, version: number): Promise<Run>;
|
29
26
|
getDefaultVersion(modelName: string, scenarioName: string): Promise<Run>;
|
@@ -14,11 +14,10 @@ type ScenarioFilter = Lookup<{
|
|
14
14
|
}>;
|
15
15
|
declare class ScenarioRepository extends BaseRepository {
|
16
16
|
static prefix: string;
|
17
|
-
static enumerationMethod: string;
|
18
17
|
docs: DocsRepository;
|
19
18
|
constructor(client: AxiosInstance);
|
20
|
-
list(
|
21
|
-
tabulate(
|
19
|
+
list(filter?: PlainObject): Promise<Scenario[]>;
|
20
|
+
tabulate(filter?: PlainObject): Promise<dfd.DataFrame>;
|
22
21
|
create(name: string): Promise<Scenario>;
|
23
22
|
get(name: string): Promise<Scenario>;
|
24
23
|
}
|
@@ -14,14 +14,13 @@ type UnitFilter = Lookup<{
|
|
14
14
|
}>;
|
15
15
|
declare class UnitRepository extends BaseRepository {
|
16
16
|
static prefix: string;
|
17
|
-
static enumerationMethod: string;
|
18
17
|
docs: DocsRepository;
|
19
18
|
constructor(client: AxiosInstance);
|
20
19
|
create(name: string): Promise<Unit>;
|
21
20
|
delete(id: number): Promise<void>;
|
22
21
|
get(name: string): Promise<Unit>;
|
23
|
-
list(
|
24
|
-
tabulate(
|
22
|
+
list(filter?: PlainObject): Promise<Unit[]>;
|
23
|
+
tabulate(filter?: PlainObject): Promise<dfd.DataFrame>;
|
25
24
|
}
|
26
25
|
export { UnitRepository };
|
27
26
|
export type { UnitFilter, Unit };
|
package/dist/types/index.d.ts
CHANGED
@@ -4,8 +4,7 @@ export type { Run, RunRepository, RunFilter } from './core/run';
|
|
4
4
|
export type { Scenario, ScenarioRepository, ScenarioFilter, } from './core/scenario';
|
5
5
|
export type { Model, ModelRepository, ModelFilter } from './core/model';
|
6
6
|
export type { Region, RegionRepository, RegionFilter } from './core/region';
|
7
|
-
export type {
|
8
|
-
export type { IamcRepository } from './core/iamc/repository';
|
7
|
+
export type { RunIamcData, PlatformIamcData, IamcDataFilter, } from './core/iamc/data';
|
9
8
|
export type { Variable, VariableRepository, VariableFilter, } from './core/iamc/variable';
|
10
9
|
export type { Unit, UnitRepository, UnitFilter } from './core/unit';
|
11
10
|
export type { MetaIndicatorRepository, MetaIndicatorFilter } from './core/meta';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@iiasa/ixmp4-ts",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.2",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "typescript client for ixmp4, a data warehouse for scenario analysis",
|
6
6
|
"repository": {
|
@@ -29,12 +29,19 @@
|
|
29
29
|
"email": "wolschlager@iiasa.ac.at"
|
30
30
|
}
|
31
31
|
],
|
32
|
+
"main": "./dist/cjs/index.js",
|
33
|
+
"module": "./dist/esm/index.js",
|
32
34
|
"types": "./dist/types/index.d.ts",
|
33
35
|
"exports": {
|
34
36
|
".": {
|
35
|
-
"
|
36
|
-
|
37
|
-
|
37
|
+
"import": {
|
38
|
+
"types": "./dist/types/index.d.ts",
|
39
|
+
"default": "./dist/esm/index.js"
|
40
|
+
},
|
41
|
+
"require": {
|
42
|
+
"types": "./dist/types/index.d.ts",
|
43
|
+
"default": "./dist/cjs/index.js"
|
44
|
+
},
|
38
45
|
"default": "./dist/cjs/index.js"
|
39
46
|
}
|
40
47
|
},
|
@@ -1,73 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
12
|
-
var t = {};
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
14
|
-
t[p] = s[p];
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
18
|
-
t[p[i]] = s[p[i]];
|
19
|
-
}
|
20
|
-
return t;
|
21
|
-
};
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
23
|
-
exports.IamcRepository = void 0;
|
24
|
-
const base_1 = require("../base");
|
25
|
-
const variable_1 = require("./variable");
|
26
|
-
/**
|
27
|
-
* Represents a repository for IAMC (Integrated Assessment Modeling Consortium) data.
|
28
|
-
* Provides methods for tabulating IAMC data.
|
29
|
-
*/
|
30
|
-
class IamcRepository extends base_1.BaseFacade {
|
31
|
-
/**
|
32
|
-
* Constructs a new instance of the IamcRepository class.
|
33
|
-
* @param backend The backend instance used for data retrieval.
|
34
|
-
*/
|
35
|
-
constructor(backend) {
|
36
|
-
super(backend);
|
37
|
-
this.variables = new variable_1.VariableRepository(this.backend);
|
38
|
-
}
|
39
|
-
/**
|
40
|
-
* Tabulates IAMC data with optional filtering.
|
41
|
-
* @param filter Optional. Filter for retrieving IAMC data.
|
42
|
-
* @param filter.joinRuns Optional. Whether to join runs or not, defaults to true.
|
43
|
-
* @returns A Promise that resolves to a dfd.DataFrame containing the tabulated data.
|
44
|
-
*/
|
45
|
-
tabulate(_a = {
|
46
|
-
joinRuns: true,
|
47
|
-
}) {
|
48
|
-
var { joinRuns = true } = _a, filter = __rest(_a, ["joinRuns"]);
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
50
|
-
if (filter === undefined) {
|
51
|
-
filter = {};
|
52
|
-
}
|
53
|
-
// return only default runs unless a run-filter is provided
|
54
|
-
if (!Object.hasOwn(filter, 'run')) {
|
55
|
-
filter['run'] = { defaultOnly: true };
|
56
|
-
}
|
57
|
-
filter['joinRuns'] = joinRuns;
|
58
|
-
filter['joinParameters'] = true;
|
59
|
-
let df = yield this.backend.iamc.datapoints.tabulate(filter);
|
60
|
-
df = df.dropNa({ axis: 1 });
|
61
|
-
if (df.columns.includes('time_series__id')) {
|
62
|
-
df = df.drop({ columns: ['time_series__id'] });
|
63
|
-
}
|
64
|
-
if (df.columns.includes('unit')) {
|
65
|
-
// 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)
|
66
|
-
df = df.replace('dimensionless', ' ', { columns: ['unit'] });
|
67
|
-
console.warn(`Unit name "dimensionless" has been replaced with ' ', this will be rejected by ixmp4.`);
|
68
|
-
}
|
69
|
-
return df;
|
70
|
-
});
|
71
|
-
}
|
72
|
-
}
|
73
|
-
exports.IamcRepository = IamcRepository;
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import { BaseFacade } from '../base';
|
2
|
-
import { VariableRepository } from './variable';
|
3
|
-
/**
|
4
|
-
* Represents a repository for IAMC (Integrated Assessment Modeling Consortium) data.
|
5
|
-
* Provides methods for tabulating IAMC data.
|
6
|
-
*/
|
7
|
-
class IamcRepository extends BaseFacade {
|
8
|
-
/**
|
9
|
-
* Repository for managing IAMC variables.
|
10
|
-
*/
|
11
|
-
variables;
|
12
|
-
/**
|
13
|
-
* Constructs a new instance of the IamcRepository class.
|
14
|
-
* @param backend The backend instance used for data retrieval.
|
15
|
-
*/
|
16
|
-
constructor(backend) {
|
17
|
-
super(backend);
|
18
|
-
this.variables = new VariableRepository(this.backend);
|
19
|
-
}
|
20
|
-
/**
|
21
|
-
* Tabulates IAMC data with optional filtering.
|
22
|
-
* @param filter Optional. Filter for retrieving IAMC data.
|
23
|
-
* @param filter.joinRuns Optional. Whether to join runs or not, defaults to true.
|
24
|
-
* @returns A Promise that resolves to a dfd.DataFrame containing the tabulated data.
|
25
|
-
*/
|
26
|
-
async tabulate({ joinRuns = true, ...filter } = {
|
27
|
-
joinRuns: true,
|
28
|
-
}) {
|
29
|
-
if (filter === undefined) {
|
30
|
-
filter = {};
|
31
|
-
}
|
32
|
-
// return only default runs unless a run-filter is provided
|
33
|
-
if (!Object.hasOwn(filter, 'run')) {
|
34
|
-
filter['run'] = { defaultOnly: true };
|
35
|
-
}
|
36
|
-
filter['joinRuns'] = joinRuns;
|
37
|
-
filter['joinParameters'] = true;
|
38
|
-
let df = await this.backend.iamc.datapoints.tabulate(filter);
|
39
|
-
df = df.dropNa({ axis: 1 });
|
40
|
-
if (df.columns.includes('time_series__id')) {
|
41
|
-
df = df.drop({ columns: ['time_series__id'] });
|
42
|
-
}
|
43
|
-
if (df.columns.includes('unit')) {
|
44
|
-
// 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)
|
45
|
-
df = df.replace('dimensionless', ' ', { columns: ['unit'] });
|
46
|
-
console.warn(`Unit name "dimensionless" has been replaced with ' ', this will be rejected by ixmp4.`);
|
47
|
-
}
|
48
|
-
return df;
|
49
|
-
}
|
50
|
-
}
|
51
|
-
export { IamcRepository };
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import * as dfd from 'danfojs';
|
2
|
-
import { Backend } from '../../backend';
|
3
|
-
import { BaseFacade } from '../base';
|
4
|
-
import { VariableRepository } from './variable';
|
5
|
-
import { IamcDataFilter } from './data';
|
6
|
-
/**
|
7
|
-
* Represents a repository for IAMC (Integrated Assessment Modeling Consortium) data.
|
8
|
-
* Provides methods for tabulating IAMC data.
|
9
|
-
*/
|
10
|
-
declare class IamcRepository extends BaseFacade {
|
11
|
-
/**
|
12
|
-
* Repository for managing IAMC variables.
|
13
|
-
*/
|
14
|
-
variables: VariableRepository;
|
15
|
-
/**
|
16
|
-
* Constructs a new instance of the IamcRepository class.
|
17
|
-
* @param backend The backend instance used for data retrieval.
|
18
|
-
*/
|
19
|
-
constructor(backend: Backend);
|
20
|
-
/**
|
21
|
-
* Tabulates IAMC data with optional filtering.
|
22
|
-
* @param filter Optional. Filter for retrieving IAMC data.
|
23
|
-
* @param filter.joinRuns Optional. Whether to join runs or not, defaults to true.
|
24
|
-
* @returns A Promise that resolves to a dfd.DataFrame containing the tabulated data.
|
25
|
-
*/
|
26
|
-
tabulate({ joinRuns, ...filter }?: {
|
27
|
-
joinRuns?: boolean;
|
28
|
-
} & IamcDataFilter): Promise<dfd.DataFrame>;
|
29
|
-
}
|
30
|
-
export { IamcRepository };
|