meadow-integration 1.0.1 → 1.0.4

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 (52) hide show
  1. package/CONTRIBUTING.md +50 -0
  2. package/README.md +223 -7
  3. package/docs/README.md +107 -7
  4. package/docs/_sidebar.md +38 -0
  5. package/docs/_topbar.md +7 -0
  6. package/docs/cli-reference.md +242 -0
  7. package/docs/comprehensions.md +98 -0
  8. package/docs/cover.md +11 -0
  9. package/docs/css/docuserve.css +73 -0
  10. package/docs/examples-walkthrough.md +138 -0
  11. package/docs/index.html +37 -20
  12. package/docs/integration-adapter.md +109 -0
  13. package/docs/mapping-files.md +140 -0
  14. package/docs/programmatic-api.md +173 -0
  15. package/docs/rest-api-reference.md +731 -0
  16. package/docs/retold-catalog.json +153 -0
  17. package/docs/retold-keyword-index.json +4828 -0
  18. package/examples/Example-001-CSV-Check.sh +29 -0
  19. package/examples/Example-002-CSV-Transform-Implicit.sh +31 -0
  20. package/examples/Example-003-CSV-Transform-CLI-Options.sh +39 -0
  21. package/examples/Example-004-CSV-Transform-Mapping-File.sh +41 -0
  22. package/examples/Example-005-Multi-Entity-Bookstore.sh +60 -0
  23. package/examples/Example-006-Multi-CSV-Intersect.sh +74 -0
  24. package/examples/Example-007-Comprehension-To-Array.sh +41 -0
  25. package/examples/Example-008-Comprehension-To-CSV.sh +51 -0
  26. package/examples/Example-009-JSON-Array-Transform.sh +46 -0
  27. package/examples/Example-010-Programmatic-API.js +138 -0
  28. package/examples/README.md +44 -0
  29. package/examples/output/.gitignore +2 -0
  30. package/package.json +7 -4
  31. package/source/Meadow-Integration.js +3 -1
  32. package/source/cli/Meadow-Integration-CLI-Program.js +4 -1
  33. package/source/cli/commands/Meadow-Integration-Command-ObjectArrayToCSV.js +49 -32
  34. package/source/cli/commands/Meadow-Integration-Command-Serve.js +51 -0
  35. package/source/restserver/Meadow-Integration-Server-Endpoints.js +83 -0
  36. package/source/restserver/Meadow-Integration-Server.js +86 -0
  37. package/source/restserver/endpoints/Endpoint-CSVCheck.js +91 -0
  38. package/source/restserver/endpoints/Endpoint-CSVTransform.js +189 -0
  39. package/source/restserver/endpoints/Endpoint-ComprehensionArray.js +121 -0
  40. package/source/restserver/endpoints/Endpoint-ComprehensionIntersect.js +166 -0
  41. package/source/restserver/endpoints/Endpoint-ComprehensionPush.js +209 -0
  42. package/source/restserver/endpoints/Endpoint-EntityFromTabularFolder.js +252 -0
  43. package/source/restserver/endpoints/Endpoint-JSONArrayTransform.js +238 -0
  44. package/source/restserver/endpoints/Endpoint-ObjectArrayToCSV.js +231 -0
  45. package/source/restserver/endpoints/Endpoint-TSVCheck.js +93 -0
  46. package/source/restserver/endpoints/Endpoint-TSVTransform.js +191 -0
  47. package/test/Meadow-Integration-Server_test.js +1170 -0
  48. package/test/data/test-comprehension-secondary.json +8 -0
  49. package/test/data/test-comprehension.json +8 -0
  50. package/test/data/test-small.csv +6 -0
  51. package/test/data/test-small.json +7 -0
  52. package/test/data/test-small.tsv +6 -0
@@ -0,0 +1,50 @@
1
+ # Contributing to Retold
2
+
3
+ We welcome contributions to Retold and its modules. This guide covers the expectations and process for contributing.
4
+
5
+ ## Code of Conduct
6
+
7
+ The Retold community values **empathy**, **equity**, **kindness**, and **thoughtfulness**. We expect all participants to treat each other with respect, assume good intent, and engage constructively. These values apply to all interactions: pull requests, issues, discussions, and code review.
8
+
9
+ ## How to Contribute
10
+
11
+ ### Pull Requests
12
+
13
+ Pull requests are the preferred method for contributing changes. To submit one:
14
+
15
+ 1. Fork the module repository you want to change
16
+ 2. Create a branch for your work
17
+ 3. Make your changes, following the code style of the module you are editing
18
+ 4. Ensure your changes have test coverage (see below)
19
+ 5. Open a pull request against the module's main branch
20
+
21
+ **Submitting a pull request does not guarantee it will be accepted.** Maintainers review contributions for fit, quality, and alignment with the project's direction. A PR may be declined, or you may be asked to revise it. This is normal and not a reflection on the quality of your effort.
22
+
23
+ ### Reporting Issues
24
+
25
+ If you find a bug or have a feature suggestion, open an issue on the relevant module's repository. Include enough detail to reproduce the problem or understand the proposal.
26
+
27
+ ## Test Coverage
28
+
29
+ Every commit must include test coverage for the changes it introduces. Retold modules use Mocha in TDD style. Before submitting:
30
+
31
+ - **Write tests** for any new functionality or bug fixes
32
+ - **Run the existing test suite** with `npm test` and confirm all tests pass
33
+ - **Check coverage** with `npm run coverage` if the module supports it
34
+
35
+ Pull requests that break existing tests or lack coverage for new code will not be merged.
36
+
37
+ ## Code Style
38
+
39
+ Follow the conventions of the module you are working in. The general Retold style is:
40
+
41
+ - **Tabs** for indentation, never spaces
42
+ - **Plain JavaScript** only (no TypeScript)
43
+ - **Allman-style braces** (opening brace on its own line)
44
+ - **Variable naming:** `pVariable` for parameters, `tmpVariable` for temporaries, `libSomething` for imports
45
+
46
+ When in doubt, match what the surrounding code does.
47
+
48
+ ## Repository Structure
49
+
50
+ Each module is its own git repository. The [retold](https://github.com/stevenvelozo/retold) repository tracks module organization but does not contain module source code. Direct your pull request to the specific module repository where your change belongs.
package/README.md CHANGED
@@ -1,15 +1,231 @@
1
1
  # Meadow Integration
2
2
 
3
- A suite of tools for managing data into a centralized non-specific schema format.
3
+ A suite of tools for managing data into a centralized non-specific schema format called a **Comprehension**.
4
4
 
5
- These tools are built to be usable from the command-line, as a web service, or within your own codebase. This code repository presents these behaviors both as a suite of externally usable fable services, a command-line utility to leverage them and a set of web service behaviors.
5
+ These tools are built to be usable from the command-line, as a web service, or within your own codebase. This module presents these behaviors both as a suite of externally usable fable services, a command-line utility to leverage them and a set of web service behaviors.
6
6
 
7
- ## CSV Stuff
7
+ ## What is a Comprehension?
8
8
 
9
- So you like the CSV format? So does this utility.
9
+ A Comprehension is a JSON object that stores entity records keyed by their GUID. It acts as an intermediate format for integrating records from external systems (CSV, TSV, JSON) into Meadow entities.
10
10
 
11
- You can try out what it can do to provide stats on CSVs by running the following from the repository root:
11
+ ```json
12
+ {
13
+ "Book": {
14
+ "Book_1": { "GUIDBook": "Book_1", "Title": "The Hunger Games", "Language": "eng" },
15
+ "Book_2": { "GUIDBook": "Book_2", "Title": "Harry Potter", "Language": "eng" }
16
+ }
17
+ }
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```shell
23
+ npm install
24
+ ```
25
+
26
+ ### Analyze a CSV
27
+
28
+ ```shell
29
+ npm start -- csvcheck ./docs/examples/data/books.csv -o stats.json
30
+ ```
31
+
32
+ ### Transform a CSV into a Comprehension
33
+
34
+ ```shell
35
+ npm start -- csvtransform ./docs/examples/data/books.csv \
36
+ -e "Book" -n "GUIDBook" -g "Book_{~D:Record.id~}" \
37
+ -o books.json
38
+ ```
39
+
40
+ ### Use a Mapping File
41
+
42
+ ```shell
43
+ npm start -- csvtransform ./docs/examples/data/books.csv \
44
+ -m ./docs/examples/bookstore/mapping_books_Book.json \
45
+ -o books.json
46
+ ```
47
+
48
+ ### Merge Multiple Data Sources
49
+
50
+ ```shell
51
+ npm start -- comprehensionintersect Set1.json -i Set2.json -e "MyEntity" -o merged.json
52
+ ```
53
+
54
+ ## CLI Commands
55
+
56
+ | Command | Description |
57
+ |---------|-------------|
58
+ | `csvcheck` | Analyze a CSV file for statistics |
59
+ | `csvtransform` | Transform a CSV into a comprehension |
60
+ | `tsvtransform` | Transform a TSV into a comprehension |
61
+ | `jsonarraytransform` | Transform a JSON array into a comprehension |
62
+ | `comprehensionintersect` | Merge two comprehension files |
63
+ | `comprehensionarray` | Convert object comprehension to array |
64
+ | `objectarraytocsv` | Export a JSON array to CSV |
65
+ | `load_comprehension` | Push a comprehension to Meadow REST APIs |
66
+ | `serve` | Start the REST API server |
67
+
68
+ ## REST API Server
69
+
70
+ Start the integration server to access all commands as HTTP endpoints:
71
+
72
+ ```shell
73
+ npm start -- serve
74
+ npm start -- serve -p 3000
75
+ ```
76
+
77
+ Then call any endpoint with `curl` or your HTTP client of choice:
78
+
79
+ ```shell
80
+ # Analyze a CSV
81
+ curl -X POST http://localhost:8086/1.0/CSV/Check \
82
+ -H "Content-Type: application/json" \
83
+ -d '{ "File": "/absolute/path/to/books.csv" }'
84
+
85
+ # Transform records in-memory (no file needed)
86
+ curl -X POST http://localhost:8086/1.0/JSONArray/TransformRecords \
87
+ -H "Content-Type: application/json" \
88
+ -d '{
89
+ "Records": [
90
+ { "id": "1", "title": "The Hunger Games", "isbn": "439023483" },
91
+ { "id": "2", "title": "Harry Potter", "isbn": "439554934" }
92
+ ],
93
+ "Entity": "Book",
94
+ "GUIDTemplate": "Book_{~D:Record.id~}",
95
+ "Mappings": { "Title": "{~D:Record.title~}", "ISBN": "{~D:Record.isbn~}" }
96
+ }'
97
+
98
+ # Merge two comprehensions
99
+ curl -X POST http://localhost:8086/1.0/Comprehension/Intersect \
100
+ -H "Content-Type: application/json" \
101
+ -d '{
102
+ "PrimaryComprehension": { "Book": { "Book_1": { "GUIDBook": "Book_1", "Title": "The Hunger Games" } } },
103
+ "SecondaryComprehension": { "Book": { "Book_1": { "GUIDBook": "Book_1", "Rating": "4.3" } } }
104
+ }'
105
+ ```
106
+
107
+ See [REST API Reference](docs/rest-api-reference.md) for full endpoint documentation with sample request bodies for every operation.
108
+
109
+ ## Examples
110
+
111
+ The `examples/` folder contains 10 runnable scripts demonstrating all major features:
12
112
 
13
113
  ```shell
14
- npm start -- csvcheck ./documentation/examples/data/housing_costs_Neighborhoods_-8848403750169343217.csv
15
- ```
114
+ cd examples
115
+
116
+ # Analyze CSV structure
117
+ ./Example-001-CSV-Check.sh
118
+
119
+ # Transform with auto-detection
120
+ ./Example-002-CSV-Transform-Implicit.sh
121
+
122
+ # Transform with CLI options
123
+ ./Example-003-CSV-Transform-CLI-Options.sh
124
+
125
+ # Transform with mapping file
126
+ ./Example-004-CSV-Transform-Mapping-File.sh
127
+
128
+ # Multi-entity bookstore (Book, Author, BookAuthorJoin)
129
+ ./Example-005-Multi-Entity-Bookstore.sh
130
+
131
+ # Merge three Seattle neighborhood CSVs
132
+ ./Example-006-Multi-CSV-Intersect.sh
133
+
134
+ # Convert comprehension to array
135
+ ./Example-007-Comprehension-To-Array.sh
136
+
137
+ # Export comprehension to CSV
138
+ ./Example-008-Comprehension-To-CSV.sh
139
+
140
+ # Transform from JSON array
141
+ ./Example-009-JSON-Array-Transform.sh
142
+
143
+ # Programmatic API usage
144
+ node Example-010-Programmatic-API.js
145
+ ```
146
+
147
+ ## Mapping Files
148
+
149
+ Mapping files define how source columns become comprehension fields:
150
+
151
+ ```json
152
+ {
153
+ "Entity": "Book",
154
+ "GUIDTemplate": "Book_{~D:Record.id~}",
155
+ "Mappings": {
156
+ "Title": "{~D:Record.title~}",
157
+ "Language": "{~D:Record.language_code~}",
158
+ "ISBN": "{~D:Record.isbn~}",
159
+ "Genre": "Unknown"
160
+ }
161
+ }
162
+ ```
163
+
164
+ For multi-record generation (e.g. splitting comma-separated authors), use Solvers:
165
+
166
+ ```json
167
+ {
168
+ "Entity": "Author",
169
+ "MultipleGUIDUniqueness": true,
170
+ "Solvers": ["NewRecordsGUIDUniqueness = STRINGGETSEGMENTS(IncomingRecord.authors,\",\")"],
171
+ "GUIDTemplate": "Author_{~PascalCaseIdentifier:Record._GUIDUniqueness~}",
172
+ "Mappings": {
173
+ "Name": "{~D:Record._GUIDUniqueness~}"
174
+ }
175
+ }
176
+ ```
177
+
178
+ ## Architecture
179
+
180
+ ```
181
+ External Data (CSV / TSV / JSON)
182
+ |
183
+ v
184
+ TabularTransform Service -- column mapping via Pict templates
185
+ |
186
+ v
187
+ Comprehension Object -- entity records keyed by GUID
188
+ |
189
+ v
190
+ Integration Adapter -- marshal to Meadow schema
191
+ |
192
+ v
193
+ GUID Map -- track external <-> Meadow IDs
194
+ |
195
+ v
196
+ Meadow REST API -- batch upsert / single upsert
197
+ ```
198
+
199
+ ## Documentation
200
+
201
+ Full documentation is available at `docs/index.html` (powered by pict-docuserve):
202
+
203
+ - [CLI Reference](docs/cli-reference.md)
204
+ - [REST API Reference](docs/rest-api-reference.md)
205
+ - [Mapping Files](docs/mapping-files.md)
206
+ - [Comprehensions](docs/comprehensions.md)
207
+ - [Programmatic API](docs/programmatic-api.md)
208
+ - [Integration Adapter](docs/integration-adapter.md)
209
+ - [Examples Walkthrough](docs/examples-walkthrough.md)
210
+ - [Vocabulary](docs/vocabulary/)
211
+
212
+ ## Testing
213
+
214
+ ```shell
215
+ npm test
216
+ ```
217
+
218
+ ## Related Packages
219
+
220
+ - [meadow](https://github.com/stevenvelozo/meadow) - Data access and ORM
221
+ - [meadow-endpoints](https://github.com/stevenvelozo/meadow-endpoints) - Auto-generated REST endpoints
222
+ - [orator](https://github.com/stevenvelozo/orator) - API server abstraction
223
+ - [fable](https://github.com/stevenvelozo/fable) - Application services framework
224
+
225
+ ## License
226
+
227
+ MIT
228
+
229
+ ## Contributing
230
+
231
+ Pull requests are welcome. For details on our code of conduct, contribution process, and testing requirements, see the [Retold Contributing Guide](https://github.com/stevenvelozo/retold/blob/main/docs/contributing.md).
package/docs/README.md CHANGED
@@ -1,15 +1,115 @@
1
1
  # Meadow Integration
2
2
 
3
- A suite of tools for managing data into a centralized non-specific schema format.
3
+ A suite of tools for managing data into a centralized non-specific schema format called a **Comprehension**.
4
4
 
5
- These tools are built to be usable from the command-line, as a web service, or within your own codebase. This code repository presents these behaviors both as a suite of externally usable fable services, a command-line utility to leverage them and a set of web service behaviors.
5
+ These tools are built to be usable from the command-line, as a web service, or within your own codebase. This module presents these behaviors both as a suite of externally usable fable services, a command-line utility to leverage them and a set of web service behaviors.
6
6
 
7
- ## CSV Stuff
7
+ ## What is a Comprehension?
8
8
 
9
- So you like the CSV format? So does this utility.
9
+ A **Comprehension** is a JSON object that stores entity records keyed by their GUID. It acts as an intermediate data format for integrating records from external systems (CSV, TSV, JSON) into Meadow entities.
10
10
 
11
- You can try out what it can do to provide stats on CSVs by running the following from the repository root:
11
+ ```json
12
+ {
13
+ "Book": {
14
+ "Book_1": { "GUIDBook": "Book_1", "Title": "The Hunger Games", "Language": "eng" },
15
+ "Book_2": { "GUIDBook": "Book_2", "Title": "Harry Potter", "Language": "eng" }
16
+ },
17
+ "Author": {
18
+ "Author_SuzanneCollins": { "GUIDAuthor": "Author_SuzanneCollins", "Name": "Suzanne Collins" }
19
+ }
20
+ }
21
+ ```
22
+
23
+ A single comprehension can hold multiple entity types, making it easy to model related data from the same source.
24
+
25
+ ## Installation
26
+
27
+ ```shell
28
+ npm install meadow-integration
29
+ ```
30
+
31
+ Or for CLI usage:
32
+
33
+ ```shell
34
+ npx meadow-integration --help
35
+ ```
36
+
37
+ ## Quick Start
38
+
39
+ ### 1. Analyze a CSV file
40
+
41
+ ```shell
42
+ npx meadow-integration csvcheck ./my-data.csv -o stats.json
43
+ ```
44
+
45
+ This produces a JSON file with row/column counts, headers, and per-column statistics.
46
+
47
+ ### 2. Transform a CSV into a Comprehension
48
+
49
+ ```shell
50
+ npx meadow-integration csvtransform ./my-data.csv \
51
+ -e "MyEntity" \
52
+ -n "GUIDMyEntity" \
53
+ -g "MyEntity_{~D:Record.id~}" \
54
+ -o my-comprehension.json
55
+ ```
56
+
57
+ ### 3. Use a Mapping File for precise control
58
+
59
+ ```json
60
+ {
61
+ "Entity": "Book",
62
+ "GUIDTemplate": "Book_{~D:Record.id~}",
63
+ "Mappings": {
64
+ "Title": "{~D:Record.title~}",
65
+ "Language": "{~D:Record.language_code~}",
66
+ "ISBN": "{~D:Record.isbn~}"
67
+ }
68
+ }
69
+ ```
70
+
71
+ ```shell
72
+ npx meadow-integration csvtransform ./books.csv -m mapping.json -o books.json
73
+ ```
74
+
75
+ ### 4. Merge multiple comprehensions
12
76
 
13
77
  ```shell
14
- npm start -- csvcheck ./documentation/examples/data/housing_costs_Neighborhoods_-8848403750169343217.csv
15
- ```
78
+ npx meadow-integration comprehensionintersect Set1.json -i Set2.json -e "MyEntity" -o merged.json
79
+ ```
80
+
81
+ ## Architecture
82
+
83
+ ```
84
+ External Data (CSV / TSV / JSON)
85
+ |
86
+ v
87
+ TabularTransform Service
88
+ (column mapping via Pict templates)
89
+ |
90
+ v
91
+ Comprehension Object
92
+ (Entity records keyed by GUID)
93
+ |
94
+ v
95
+ Integration Adapter
96
+ (marshal to Meadow schema)
97
+ |
98
+ v
99
+ GUID Map
100
+ (track external <-> Meadow IDs)
101
+ |
102
+ v
103
+ Meadow REST API
104
+ (batch upsert / single upsert)
105
+ ```
106
+
107
+ ## Next Steps
108
+
109
+ - [CLI Reference](cli-reference.md) -- All commands and their options
110
+ - [REST API Reference](rest-api-reference.md) -- All REST endpoints with curl examples
111
+ - [Mapping Files](mapping-files.md) -- How to write column mapping configurations
112
+ - [Comprehensions](comprehensions.md) -- The comprehension data format in detail
113
+ - [Programmatic API](programmatic-api.md) -- Using services directly in your code
114
+ - [Integration Adapter](integration-adapter.md) -- Pushing data to Meadow REST APIs
115
+ - [Examples](examples-walkthrough.md) -- Walkthrough of all runnable examples
@@ -0,0 +1,38 @@
1
+ - Getting Started
2
+
3
+ - [Introduction](/)
4
+ - [Quick Start](README.md)
5
+
6
+ - Concepts
7
+
8
+ - [Comprehensions](comprehensions.md)
9
+ - [Mapping Files](mapping-files.md)
10
+
11
+ - Reference
12
+
13
+ - [CLI Reference](cli-reference.md)
14
+ - [REST API Reference](rest-api-reference.md)
15
+ - [Programmatic API](programmatic-api.md)
16
+ - [Integration Adapter](integration-adapter.md)
17
+
18
+ - Examples
19
+
20
+ - [Examples Walkthrough](examples-walkthrough.md)
21
+ - [Bookstore Example](examples/bookstore/BookData.md)
22
+ - [Seattle Multi-Set](examples/multi_set_integration/multi_set_step_by_step.md)
23
+
24
+ - Vocabulary
25
+
26
+ - [Comprehension](vocabulary/Comprehension.md)
27
+ - [Entity](vocabulary/Entity.md)
28
+ - [GUID](vocabulary/GUID.md)
29
+ - [Schema](vocabulary/Schema.md)
30
+ - [Set](vocabulary/Set.md)
31
+ - [Source](vocabulary/Source.md)
32
+ - [Column](vocabulary/Column.md)
33
+ - [Record](vocabulary/Record.md)
34
+ - [Format](vocabulary/Format.md)
35
+ - [Join](vocabulary/Join.md)
36
+ - [Snapshot](vocabulary/Snapshot.md)
37
+ - [Version](vocabulary/Version.md)
38
+ - [Confidence](vocabulary/Confidence.md)
@@ -0,0 +1,7 @@
1
+ # Meadow Integration
2
+
3
+ - [Overview](README.md)
4
+ - [CLI Reference](cli-reference.md)
5
+ - [API Reference](programmatic-api.md)
6
+ - [Examples](examples-walkthrough.md)
7
+ - [GitHub](https://github.com/stevenvelozo/meadow-integration)
@@ -0,0 +1,242 @@
1
+ # CLI Reference
2
+
3
+ The `meadow-integration` CLI (also available as `mdwint` when installed globally) provides commands for transforming, analyzing, and merging tabular data.
4
+
5
+ ## Global Usage
6
+
7
+ ```shell
8
+ npx meadow-integration [command] [options]
9
+
10
+ # Or from the repository:
11
+ npm start -- [command] [options]
12
+ ```
13
+
14
+ ---
15
+
16
+ ## csvcheck
17
+
18
+ Analyze a CSV file and produce column-level statistics.
19
+
20
+ ```shell
21
+ npx meadow-integration csvcheck <file> [options]
22
+ ```
23
+
24
+ **Arguments:**
25
+ | Argument | Description |
26
+ |----------|-------------|
27
+ | `<file>` | Path to the CSV file to analyze |
28
+
29
+ **Options:**
30
+ | Option | Description |
31
+ |--------|-------------|
32
+ | `-f, --file <filepath>` | Alternate way to specify the CSV file |
33
+ | `-o, --output <filepath>` | Output file path. Default: `./CSV-Stats-[filename].json` |
34
+ | `-r, --records` | Include all parsed records in the output |
35
+
36
+ **Output:** A JSON file containing:
37
+ - `RowCount` / `ColumnCount` -- Number of data rows and columns
38
+ - `Headers` -- Array of column names
39
+ - `FirstRow` / `LastRow` -- The first and last records
40
+ - `ColumnStatistics` -- Per-column: Count, EmptyCount, NumericCount, FirstValue, LastValue
41
+
42
+ **Example:**
43
+ ```shell
44
+ npx meadow-integration csvcheck ./data/books.csv -o book-stats.json
45
+ ```
46
+
47
+ ---
48
+
49
+ ## csvtransform
50
+
51
+ Transform a CSV file into a Comprehension JSON file.
52
+
53
+ ```shell
54
+ npx meadow-integration csvtransform <file> [options]
55
+ ```
56
+
57
+ **Arguments:**
58
+ | Argument | Description |
59
+ |----------|-------------|
60
+ | `<file>` | Path to the CSV file to transform |
61
+
62
+ **Options:**
63
+ | Option | Description |
64
+ |--------|-------------|
65
+ | `-e, --entity <name>` | Entity name in the comprehension |
66
+ | `-n, --guidname <name>` | GUID column name (e.g. `GUIDBook`) |
67
+ | `-g, --guidtemplate <template>` | Pict template for GUID values (e.g. `Book_{~D:Record.id~}`) |
68
+ | `-c, --columns <mappings>` | Inline column mappings: `Col1={~D:col1~},Col2={~D:col2~}` |
69
+ | `-m, --mappingfile <path>` | Path to a JSON mapping file |
70
+ | `-i, --incoming <path>` | Existing comprehension file to merge into |
71
+ | `-o, --output <path>` | Output file path |
72
+ | `-x, --extended` | Output full operation state, not just the comprehension |
73
+ | `-q, --quotedelimiter <char>` | Quote delimiter character (default: `"`) |
74
+
75
+ **Priority of configuration:**
76
+ 1. Implicit -- auto-detected from the first CSV row
77
+ 2. Explicit -- loaded from a mapping file (`-m`)
78
+ 3. User -- command-line options (`-e`, `-g`, `-c`, etc.)
79
+
80
+ Each layer overrides the previous.
81
+
82
+ **Example:**
83
+ ```shell
84
+ # With CLI options
85
+ npx meadow-integration csvtransform ./books.csv \
86
+ -e Book -n GUIDBook -g "Book_{~D:Record.id~}" \
87
+ -o books.json
88
+
89
+ # With mapping file
90
+ npx meadow-integration csvtransform ./books.csv \
91
+ -m mapping_Book.json -o books.json
92
+
93
+ # Merging into existing comprehension
94
+ npx meadow-integration csvtransform ./books.csv \
95
+ -m mapping_Author.json \
96
+ -i books.json -o books.json
97
+ ```
98
+
99
+ ---
100
+
101
+ ## tsvtransform
102
+
103
+ Transform a TSV file into a Comprehension. Same interface as `csvtransform` but uses tab delimiters.
104
+
105
+ ```shell
106
+ npx meadow-integration tsvtransform <file> [options]
107
+ ```
108
+
109
+ All options are the same as `csvtransform`. The delimiter is automatically set to tab (`\t`).
110
+
111
+ ---
112
+
113
+ ## jsonarraytransform
114
+
115
+ Transform a JSON array file into a Comprehension.
116
+
117
+ ```shell
118
+ npx meadow-integration jsonarraytransform <file> [options]
119
+ ```
120
+
121
+ All options are the same as `csvtransform`. The input file must contain a valid JSON array.
122
+
123
+ ---
124
+
125
+ ## comprehensionintersect
126
+
127
+ Merge two Comprehension files together. Records with the same GUID are merged (later values overwrite earlier ones).
128
+
129
+ ```shell
130
+ npx meadow-integration comprehensionintersect <primary_file> [options]
131
+ ```
132
+
133
+ **Options:**
134
+ | Option | Description |
135
+ |--------|-------------|
136
+ | `-i, --intersect <path>` | Secondary comprehension file to merge |
137
+ | `-e, --entity <name>` | Entity name to merge (auto-detected if omitted) |
138
+ | `-o, --output <path>` | Output file path |
139
+
140
+ **Example:**
141
+ ```shell
142
+ npx meadow-integration comprehensionintersect Set1.json \
143
+ -i Set2.json -e Document -o merged.json
144
+ ```
145
+
146
+ ---
147
+
148
+ ## comprehensionarray
149
+
150
+ Convert an object-keyed Comprehension into a JSON array.
151
+
152
+ ```shell
153
+ npx meadow-integration comprehensionarray <file> [options]
154
+ ```
155
+
156
+ **Options:**
157
+ | Option | Description |
158
+ |--------|-------------|
159
+ | `-e, --entity <name>` | Entity to extract (auto-detected if omitted) |
160
+ | `-o, --output <path>` | Output file path |
161
+
162
+ **Example:**
163
+ ```shell
164
+ npx meadow-integration comprehensionarray books.json -e Book -o books-array.json
165
+ ```
166
+
167
+ ---
168
+
169
+ ## objectarraytocsv
170
+
171
+ Convert a JSON array or entity comprehension to CSV format.
172
+
173
+ ```shell
174
+ npx meadow-integration objectarraytocsv <file> [options]
175
+ ```
176
+
177
+ **Options:**
178
+ | Option | Description |
179
+ |--------|-------------|
180
+ | `-e, --entity <name>` | Entity key to extract from the file (optional; expects a plain array if omitted) |
181
+ | `-o, --output <path>` | Output CSV file path |
182
+
183
+ Nested objects are flattened using dot notation (e.g. `address.city`).
184
+
185
+ ---
186
+
187
+ ## load_comprehension
188
+
189
+ Push a Comprehension to Meadow REST APIs via the Integration Adapter.
190
+
191
+ ```shell
192
+ npx meadow-integration load_comprehension <file> [options]
193
+ ```
194
+
195
+ **Options:**
196
+ | Option | Description |
197
+ |--------|-------------|
198
+ | `-p, --prefix <prefix>` | GUID prefix for the push |
199
+ | `-e, --entityguidprefix <prefix>` | Per-entity GUID prefix |
200
+
201
+ This command automatically creates Integration Adapters for each entity in the comprehension and pushes records via upsert operations to the configured Meadow server.
202
+
203
+ ---
204
+
205
+ ## entitycomprehensionsfromtabularfolders
206
+
207
+ Generate entity comprehensions from a folder of tabular data files.
208
+
209
+ ```shell
210
+ npx meadow-integration entitycomprehensionsfromtabularfolders <folder> [options]
211
+ ```
212
+
213
+ **Options:**
214
+ | Option | Description |
215
+ |--------|-------------|
216
+ | `-e, --entity <name>` | Force all files to a specific entity |
217
+ | `-m, --mapping <path>` | Mapping hints file |
218
+ | `-o, --output <path>` | Output file path |
219
+
220
+ ---
221
+
222
+ ## serve
223
+
224
+ Start the Meadow Integration REST API server. See [REST API Reference](rest-api-reference.md) for full endpoint documentation.
225
+
226
+ ```shell
227
+ npx meadow-integration serve [options]
228
+ ```
229
+
230
+ **Aliases:** `server`, `rest`
231
+
232
+ **Options:**
233
+ | Option | Description |
234
+ |--------|-------------|
235
+ | `-p, --port <port>` | Port to listen on (default: `8086`) |
236
+
237
+ The `MEADOW_INTEGRATION_PORT` environment variable is also respected.
238
+
239
+ **Example:**
240
+ ```shell
241
+ npx meadow-integration serve -p 3000
242
+ ```