diff --git a/examples/sample-check-bundle/src/inputs.ts b/examples/sample-check-bundle/src/inputs.ts index 87c5eb3f..f028c640 100644 --- a/examples/sample-check-bundle/src/inputs.ts +++ b/examples/sample-check-bundle/src/inputs.ts @@ -1,11 +1,11 @@ // Copyright (c) 2022 Climate Interactive / New Venture Fund -import type { InputId, InputVar, VarId } from '@sdeverywhere/check-core' +import type { InputAliasName, InputGroupName, InputId, InputVar, VarId } from '@sdeverywhere/check-core' export interface Inputs { inputVars: Map - inputGroups: Map - inputAliases: Map + inputGroups: Map + inputAliases: Map } /** @@ -13,7 +13,7 @@ export interface Inputs { */ export function getInputs(modelVersion: number): Inputs { const inputVars: Map = new Map() - const inputAliases: Map = new Map() + const inputAliases: Map = new Map() // TODO: Typically you would return the actual list of model inputs (for // example, the list used to configure an SDEverywhere-generated model), @@ -58,7 +58,7 @@ export function getInputs(modelVersion: number): Inputs { } // Configure input groups - const inputGroups: Map = new Map([ + const inputGroups: Map = new Map([ ['All Inputs', [...inputVars.values()]], // ['Input Group 1', [inputVars.get('_input_a'), inputVars.get('_input_b')]], ['Input Group 1', [inputVars.get('_input_a')]], diff --git a/examples/sample-check-bundle/src/outputs.ts b/examples/sample-check-bundle/src/outputs.ts index cdb213d3..f86d4259 100644 --- a/examples/sample-check-bundle/src/outputs.ts +++ b/examples/sample-check-bundle/src/outputs.ts @@ -1,11 +1,12 @@ // Copyright (c) 2022 Climate Interactive / New Venture Fund +import type { DatasetGroupName } from '@sdeverywhere/check-core' import type { DatasetKey, ImplVar, OutputVar, RelatedItem, VarId } from '@sdeverywhere/check-core' export interface Outputs { outputVars: Map implVars: Map - datasetGroups: Map + datasetGroups: Map } /** @@ -99,7 +100,7 @@ export function getOutputs(modelVersion: number): Outputs { const keysForVarsWithSource = (sourceName?: string) => { return [...outputVars.entries()].filter(e => e[1].sourceName === sourceName).map(([k]) => k) } - const datasetGroups: Map = new Map([ + const datasetGroups: Map = new Map([ ['All Outputs', keysForVarsWithSource(undefined)], ['Basic Outputs', [keyForVarWithName('Output X'), keyForVarWithName('Output Y'), keyForVarWithName('Output Z')]], ['Static', keysForVarsWithSource('StaticData')] diff --git a/packages/check-core/src/bundle/bundle-types.ts b/packages/check-core/src/bundle/bundle-types.ts index fdf7784b..2a8743e8 100644 --- a/packages/check-core/src/bundle/bundle-types.ts +++ b/packages/check-core/src/bundle/bundle-types.ts @@ -6,6 +6,15 @@ import type { DatasetKey, VarId } from '../_shared/types' import type { ImplVar, InputVar, OutputVar } from './var-types' +/** The human-readable name for a group of inputs. */ +export type InputGroupName = string + +/** The alias name for an input. */ +export type InputAliasName = string + +/** The human-readable name for a group of dataset. */ +export type DatasetGroupName = string + /** * Includes the properties needed to display a legend item in the UI. */ @@ -28,6 +37,7 @@ export interface LinkItem { content: string } +/** The identifier for a bundle-specific graph. */ export type BundleGraphId = string /** @@ -93,11 +103,11 @@ export interface ModelSpec { /** The map of all variables (both internal and exported) in this version of the model. */ implVars: Map /** The custom input variable aliases defined for this model. */ - inputAliases?: Map + inputAliases?: Map /** The custom input variable groups defined for this model. */ - inputGroups?: Map + inputGroups?: Map /** The custom dataset (output variable) groups defined for this model. */ - datasetGroups?: Map + datasetGroups?: Map /** The start time (year) for the model. */ startTime?: number /** The end time (year) for the model. */ diff --git a/packages/check-core/src/check/check-dataset.spec.ts b/packages/check-core/src/check/check-dataset.spec.ts index 7d2acf2d..2cf92c48 100644 --- a/packages/check-core/src/check/check-dataset.spec.ts +++ b/packages/check-core/src/check/check-dataset.spec.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest' import type { DatasetKey } from '../_shared/types' -import type { ModelSpec } from '../bundle/bundle-types' +import type { DatasetGroupName, ModelSpec } from '../bundle/bundle-types' import type { ImplVar, OutputVar } from '../bundle/var-types' import { expandDatasets } from './check-dataset' import type { CheckDatasetSpec } from './check-spec' @@ -39,7 +39,7 @@ describe('expandDatasets', () => { implVar('V6') ]) - const datasetGroups: Map = new Map([ + const datasetGroups: Map = new Map([ ['output group 0', []], ['output group 1', ['Model_unknown_dataset']], ['output group 2', ['Model_v1', 'Model_v6']], diff --git a/packages/check-core/src/check/check-scenario.spec.ts b/packages/check-core/src/check/check-scenario.spec.ts index 9beae524..88329866 100644 --- a/packages/check-core/src/check/check-scenario.spec.ts +++ b/packages/check-core/src/check/check-scenario.spec.ts @@ -4,7 +4,7 @@ import { describe, expect, it } from 'vitest' import { inputSettingsSpec, positionSetting, valueSetting } from '../_shared/scenario-specs' import type { VarId } from '../_shared/types' -import type { ModelSpec } from '../bundle/bundle-types' +import type { InputGroupName, ModelSpec } from '../bundle/bundle-types' import type { InputVar } from '../bundle/var-types' import { expandScenarios } from './check-scenario' import type { CheckScenarioSpec } from './check-spec' @@ -17,7 +17,7 @@ describe('expandScenarios', () => { const i2 = inputVars.get('_i2') const i3 = inputVars.get('_i3') - const inputGroups: Map = new Map([ + const inputGroups: Map = new Map([ ['input group 1', [i1, i2]], ['Input Group 2', [i2, i3]], ['input group 3', []] diff --git a/packages/check-core/src/comparison/config/resolve/comparison-resolver.spec.ts b/packages/check-core/src/comparison/config/resolve/comparison-resolver.spec.ts index b8dadc1f..d8534969 100644 --- a/packages/check-core/src/comparison/config/resolve/comparison-resolver.spec.ts +++ b/packages/check-core/src/comparison/config/resolve/comparison-resolver.spec.ts @@ -4,7 +4,7 @@ import { describe, expect, it } from 'vitest' import { inputAtPositionSpec as atPosSpec, inputAtValueSpec as atValSpec } from '../../../_shared/scenario-specs' import type { VarId } from '../../../_shared/types' -import type { ModelSpec } from '../../../bundle/bundle-types' +import type { InputAliasName, ModelSpec } from '../../../bundle/bundle-types' import { ModelInputs } from '../../../bundle/model-inputs' import type { InputId, InputVar } from '../../../bundle/var-types' @@ -76,7 +76,7 @@ function mockModelSpec(kind: 'L' | 'R'): ModelSpec { } // Add aliases by slider name - const inputAliases: Map = new Map() + const inputAliases: Map = new Map() inputAliases.set('S1', '_ivara') inputAliases.set('S2', kind === 'L' ? '_ivarb' : '_ivarb_renamed') inputAliases.set('S3', kind === 'L' ? '_ivarc' : '_ivard') diff --git a/packages/check-core/src/index.ts b/packages/check-core/src/index.ts index 97be1876..be144b11 100644 --- a/packages/check-core/src/index.ts +++ b/packages/check-core/src/index.ts @@ -20,6 +20,9 @@ export type { BundleGraphSpec, BundleGraphView, BundleModel, + DatasetGroupName, + InputAliasName, + InputGroupName, LegendItem, LinkItem, LoadedBundle,