Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
achou11 committed Jul 26, 2023
1 parent 3a99751 commit 2daf8d2
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ Module and CLI to generate fake data for Mapeo

## Installation

_TODO_
_This module is not published yet, so the following instructions do not actually work yet_

```sh
npm install @mapeo/mock-data
```

## Usage

Expand Down Expand Up @@ -37,10 +41,10 @@ example output:

Generates JSON-formatted Mapeo data based on [`@mapeo/schema`](https://github.com/digidem/mapeo-schema/).

- _required_ `--schema (-s)`: specifies the schema to generate data for. Use the `list-mapeo-schemas` command to learn which ones are available.
- _optional_ `--version (-v)`: specifies the schema version to use for `--schema`. Uses latest version by default.
- _optional_ `--count (-c)`: specifies the number of entries to generate. Uses `1` by default.
- _optional_ `--output (-o)`: specifies a path relative to the current working directory to write the generated data to. Logs to stdout by default.
- `--schema, -s`: specifies the schema to generate data for. Use the `list-mapeo-schemas` command to learn which ones are available.
- `--version, -v`: (_optional_) specifies the schema version to use for `--schema`. Uses latest version by default.
- `--count, -c`: (_optional_) specifies the number of entries to generate. Uses `1` by default.
- `--output, -o`: (_optional_) specifies a path relative to the current working directory to write the generated data to. Logs to stdout by default.

```sh
# Generate data for the specified schema
Expand All @@ -58,4 +62,30 @@ npx generate-mapeo-data --schema observation --output observations.json

### Programmatic API

_TODO_
#### `mapeoMockData.generate`

`(schemaName: string, opts?: { version?: string, count?: number }) => Array<SchemaData>`

Returns mocked data for the specified `schemaName`, where `SchemaData` adheres to the schema definition associated with `schemaName`. Accepts the following `opts`:

- `version`: specify the schema version to use
- `count`: specify the number of records to generate

#### `mapeoMockData.listSchemas`

`() => { [name: string]: Array<string> }`

Returns the available schemas to generate from and the corresponding versions that are available for each. Example value may look like this:

```js
{
coreOwnership: ["v1"],
device: ["v1"],
field: ["v1"],
filter: ["v1"],
observation: ["v4", "v5"],
preset: ["v1"],
project: ["v1"],
role: ["v1"]
}
```

0 comments on commit 2daf8d2

Please sign in to comment.