@sdeverywhere/cli 0.7.45 → 0.7.46

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 (2) hide show
  1. package/README.md +37 -9
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This package contains the `sde` command line interface for the [SDEverywhere](https://github.com/climateinteractive/SDEverywhere) suite of tools.
4
4
 
5
- SDEverywhere can be used to translate System Dynamics models from Vensim to C and WebAssembly.
5
+ SDEverywhere can be used to translate System Dynamics models from Vensim or Stella format to JavaScript, C, and WebAssembly.
6
6
 
7
7
  For more details on the full suite of tools and libraries provided in SDEverywhere, refer to the top-level [README](https://github.com/climateinteractive/SDEverywhere) in the SDEverywhere repository.
8
8
 
@@ -46,10 +46,10 @@ Use `sde -h` to see a list of all commands.
46
46
 
47
47
  Use `sde {command}` to see options for a command.
48
48
 
49
- It is usually easiest to run these commands from the directory where the `.mdl` file is located.
49
+ It is usually easiest to run these commands from the directory where the model file (for example, a Vensim `.mdl` file or a Stella `.stmx` file) is located.
50
50
  The `{model}` placeholder can be the model filename, for instance `arrays.mdl`, or simply the model name `arrays`.
51
51
 
52
- If you are not running from the model directory, you can give a full pathname to locate the `.mdl` file anywhere on the system.
52
+ If you are not running from the model directory, you can give a full pathname to locate the model file anywhere on the system.
53
53
 
54
54
  By default, SDEverywhere will create a `build` directory in your model directory to hold the generated code and the compiled model.
55
55
  If you run the model, it will also create an `output` directory by default.
@@ -70,9 +70,9 @@ sde generate --genc --spec {model}_spec.json {model}
70
70
  #### Start a local development builder/server
71
71
 
72
72
  The `sde dev` command is great for local development of a web application.
73
- It will start a builder process that rebuilds your app and runs QA checks against your model any time you save changes to your `mdl` file.
74
- You can leave the builder running while developing your model in Vensim.
75
- The app and model-check tabs in your browser will refresh automatically whenever you save changes in Vensim or make edits to your application code.
73
+ It will start a builder process that rebuilds your app and runs QA checks against your model any time you save changes to your model file.
74
+ You can leave the builder running while developing your model in Vensim or Stella.
75
+ The app and model-check tabs in your browser will refresh automatically whenever you save changes in your modeling tool or make edits to your application code.
76
76
 
77
77
  See [`examples/hello-world`](https://github.com/climateinteractive/SDEverywhere/tree/main/examples/hello-world) for a simple example of an `sde.config.js` file.
78
78
  You can also follow the [Quick Start](https://github.com/climateinteractive/SDEverywhere/tree/main/examples/sir#quick-start) instructions for `examples/sir`, which will generate a more complete example of an `sde.config.js` file.
@@ -176,8 +176,9 @@ sde which
176
176
 
177
177
  _NOTE:_ The following sections refer to "model specification files" (or "spec files" as a shorthand).
178
178
  These JSON spec files are generally used by the lower-level `sde` commands, such as `sde generate`.
179
- We are gradually adding support for a more flexible configuration file format (`sde.config.js`) that works with newer commands such as `sde dev` and `sde bundle`.
180
- We hope to unify these configuration file formats soon to eliminate any confusion about which file format can be used with which command (see related issue [#327](https://github.com/climateinteractive/SDEverywhere/issues/327)).
179
+ The higher-level `sde dev` and `sde bundle` commands use a more flexible configuration file format (`sde.config.js`) that also allows for defining plugins.
180
+ The two formats share the same property definitions where they overlap, so most of the properties documented below are also available in the `modelSpec` section of an `sde.config.js` file.
181
+ The exception is the input and output variables: a spec file takes plain variable names in `inputVarNames` and `outputVarNames`, whereas an `sde.config.js` file uses higher-level `inputs` and `outputs` properties that also accept objects carrying additional information about each variable.
181
182
 
182
183
  #### Specify input and output variables
183
184
 
@@ -198,6 +199,14 @@ Be sure to include `Time` first among the output variables.
198
199
 
199
200
  #### Specify external data sources
200
201
 
202
+ Add a `datFiles` section to the spec file to have SDEverywhere read data for exogenous data variables from one or more Vensim `dat` files.
203
+ Each entry can either be a plain file name, or an object that maps a variable name prefix to a file name.
204
+ There are examples in the `extdata` and `getdata` sample models.
205
+
206
+ ```json
207
+ "datFiles": ["data.dat", { "prefix ": "other.dat" }]
208
+ ```
209
+
201
210
  Add a `directData` section to the spec file to have SDEverywhere read data from an Excel file into lookups with a variable name prefix.
202
211
  There is an example in the `directdata` sample model.
203
212
 
@@ -207,6 +216,25 @@ There is an example in the `directdata` sample model.
207
216
  }
208
217
  ```
209
218
 
219
+ #### Supported spec file properties
220
+
221
+ The full set of supported properties is defined by the [`ModelSpec`](https://github.com/climateinteractive/SDEverywhere/blob/main/packages/compile/src/_shared/model-spec.js) type in the `@sdeverywhere/compile` package, which is the authoritative reference.
222
+ The table below is a summary.
223
+
224
+ | Property | Type | Description |
225
+ | ------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
226
+ | `inputVarNames` | `string[]` | The input variables, using the names as they appear in the modeling tool. |
227
+ | `outputVarNames` | `string[]` | The output variables, using the names as they appear in the modeling tool. It is customary to list `Time` first. |
228
+ | `datFiles` | `(string \| object)[]` | The `dat` files that provide data for exogenous data variables, resolved relative to the model directory. |
229
+ | `directData` | `object` | Maps the data tag used in a `GET DIRECT {DATA,CONSTANTS,LOOKUPS}` call (for example, `?data`) to an `xlsx` file name. |
230
+ | `dimensionFamilies` | `object` | Maps a dimension name to its family name, for cases where the family cannot be inferred from the model alone. |
231
+ | `specialSeparationDims` | `object` | Maps a variable identifier to the dimension(s) on which that variable should be separated, which can be used to break a cycle. |
232
+ | `separateAllVarsWithDims` | `(string \| string[])[]` | The dimensions for which all variables should be separated, as an alternative to listing each variable in `specialSeparationDims`. |
233
+ | `bundleListing` | `boolean` | Whether to bundle a model listing with the generated model so that the `runtime` package can resolve variables by name or identifier. |
234
+ | `customConstants` | `boolean \| string[]` | Whether (or which) constants can be overridden at runtime using `setConstant`. |
235
+ | `customLookups` | `boolean \| string[]` | Whether (or which) lookups can be overridden at runtime using `setLookup`. |
236
+ | `customOutputs` | `boolean \| string[]` | Whether (or which) variables can be captured at runtime using `storeOutput`. |
237
+
210
238
  #### Generating, compiling, running, and testing the C code
211
239
 
212
240
  To generate C code using the `--spec` argument, enter the following command:
@@ -238,7 +266,7 @@ There is a `setInputs` implementation in the generated code that gets called at
238
266
  It takes a string with serialized input values and sets variable values from it.
239
267
  The serialization format depends on the needs of your application.
240
268
  You can replace `setInputs` if you want to use a different serialization form.
241
- The input variables are listed in the `inputVars` section of the spec file.
269
+ The input variables are listed in the `inputVarNames` section of the spec file.
242
270
  Look at the `arrays` model for an example.
243
271
 
244
272
  The generated format minimizes the amount of data on the wire for web applications.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdeverywhere/cli",
3
- "version": "0.7.45",
3
+ "version": "0.7.46",
4
4
  "description": "Contains the `sde` command line interface for the SDEverywhere tool suite.",
5
5
  "type": "module",
6
6
  "files": [
@@ -11,8 +11,8 @@
11
11
  "sde": "src/main.js"
12
12
  },
13
13
  "dependencies": {
14
- "@sdeverywhere/build": "^0.3.14",
15
- "@sdeverywhere/compile": "^0.7.32",
14
+ "@sdeverywhere/build": "^0.3.15",
15
+ "@sdeverywhere/compile": "^0.7.33",
16
16
  "byline": "^5.0.0",
17
17
  "ramda": "^0.27.0",
18
18
  "shelljs": "^0.10.0",