meadow-integration 1.0.5 → 1.0.7
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/.dockerignore +11 -0
- package/Docker-Build.sh +2 -0
- package/Docker-Compose.sh +2 -0
- package/Docker-Push.sh +2 -0
- package/Docker-Tag.sh +2 -0
- package/Dockerfile +28 -0
- package/Dockerfile_LUXURYCode +23 -0
- package/README.md +139 -25
- package/docker-compose.yml +16 -0
- package/docs/README.md +65 -18
- package/docs/_cover.md +3 -2
- package/docs/_sidebar.md +52 -7
- package/docs/_topbar.md +2 -0
- package/docs/api/clone-rest-client.md +278 -0
- package/docs/api/connection-manager.md +179 -0
- package/docs/api/guid-map.md +234 -0
- package/docs/api/integration-adapter.md +283 -0
- package/docs/api/operation.md +241 -0
- package/docs/api/sync-entity-initial.md +227 -0
- package/docs/api/sync-entity-ongoing.md +244 -0
- package/docs/api/sync.md +213 -0
- package/docs/api/tabular-check.md +213 -0
- package/docs/api/tabular-transform.md +316 -0
- package/docs/architecture.md +423 -0
- package/docs/cli/comprehensionarray.md +111 -0
- package/docs/cli/comprehensionintersect.md +132 -0
- package/docs/cli/csvcheck.md +111 -0
- package/docs/cli/csvtransform.md +170 -0
- package/docs/cli/data-clone.md +277 -0
- package/docs/cli/jsonarraytransform.md +166 -0
- package/docs/cli/load-comprehension.md +129 -0
- package/docs/cli/objectarraytocsv.md +159 -0
- package/docs/cli/overview.md +96 -0
- package/docs/cli/serve.md +102 -0
- package/docs/cli/tsvtransform.md +144 -0
- package/docs/data-clone/configuration.md +357 -0
- package/docs/data-clone/connection-manager.md +206 -0
- package/docs/data-clone/docker.md +290 -0
- package/docs/data-clone/overview.md +173 -0
- package/docs/data-clone/sync-modes.md +186 -0
- package/docs/implementation-reference.md +311 -0
- package/docs/overview.md +156 -0
- package/docs/quickstart.md +233 -0
- package/docs/rest/comprehension-push.md +209 -0
- package/docs/rest/comprehension.md +506 -0
- package/docs/rest/csv.md +255 -0
- package/docs/rest/entity-generation.md +158 -0
- package/docs/rest/json-array.md +243 -0
- package/docs/rest/overview.md +120 -0
- package/docs/rest/status.md +63 -0
- package/docs/rest/tsv.md +241 -0
- package/docs/retold-catalog.json +93 -3
- package/docs/retold-keyword-index.json +23683 -1901
- package/package.json +6 -3
- package/scripts/run.sh +18 -0
- package/source/Meadow-Integration.js +15 -1
- package/source/cli/Default-Meadow-Integration-Configuration.json +37 -2
- package/source/cli/Meadow-Integration-CLI-Program.js +4 -1
- package/source/cli/commands/Meadow-Integration-Command-DataClone.js +284 -0
- package/source/services/clone/Meadow-Service-ConnectionManager.js +251 -0
- package/source/services/clone/Meadow-Service-Operation.js +196 -0
- package/source/services/clone/Meadow-Service-RestClient.js +364 -0
- package/source/services/clone/Meadow-Service-Sync-Entity-Initial.js +502 -0
- package/source/services/clone/Meadow-Service-Sync-Entity-Ongoing.js +592 -0
- package/source/services/clone/Meadow-Service-Sync.js +154 -0
- /package/docs/examples/bookstore/{mapping_books_Author.json → mapping_books_author.json} +0 -0
- /package/docs/examples/bookstore/{mapping_books_Book.json → mapping_books_book.json} +0 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# jsonarraytransform
|
|
2
|
+
|
|
3
|
+
Transform a JSON array file into a Comprehension JSON file. This command provides the same mapping and configuration capabilities as [csvtransform](csvtransform.md), but reads from a JSON array instead of a CSV file.
|
|
4
|
+
|
|
5
|
+
**Aliases:** `jsonarray_t`, `jsonarray_transform`
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
mdwint jsonarraytransform <file> [options]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Arguments
|
|
14
|
+
|
|
15
|
+
| Argument | Required | Description |
|
|
16
|
+
|----------|----------|-------------|
|
|
17
|
+
| `<file>` | Yes | Path to the JSON array file to transform |
|
|
18
|
+
|
|
19
|
+
## Options
|
|
20
|
+
|
|
21
|
+
| Option | Description | Default |
|
|
22
|
+
|--------|-------------|---------|
|
|
23
|
+
| `-e, --entity <name>` | Entity name in the Comprehension | Auto-detected from filename |
|
|
24
|
+
| `-n, --guidname <name>` | Name of the GUID column in the generated Comprehension | `GUID<Entity>` |
|
|
25
|
+
| `-g, --guidtemplate <template>` | Pict template for generating the entity GUID | `GUID-<Entity>-{~Data:Record.<first_key>~}` |
|
|
26
|
+
| `-c, --columns <mappings>` | Inline column mappings in `Key={~D:col~}` format | Auto-detected 1:1 mapping |
|
|
27
|
+
| `-m, --mappingfile <path>` | Path to a JSON mapping file | -- |
|
|
28
|
+
| `-i, --incoming <path>` | Existing Comprehension file to merge into | -- |
|
|
29
|
+
| `-o, --output <path>` | Output file path | `./JSON-Comprehension-<filename>.json` |
|
|
30
|
+
| `-x, --extended` | Output full operation state, not just the Comprehension | `false` |
|
|
31
|
+
|
|
32
|
+
## Input Format
|
|
33
|
+
|
|
34
|
+
The input file must contain a valid JSON array of objects:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
[
|
|
38
|
+
{ "id": 1, "title": "The Hunger Games", "author": "Suzanne Collins" },
|
|
39
|
+
{ "id": 2, "title": "Harry Potter", "author": "J.K. Rowling" },
|
|
40
|
+
{ "id": 3, "title": "To Kill a Mockingbird", "author": "Harper Lee" }
|
|
41
|
+
]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The command validates that:
|
|
45
|
+
- The file contains valid JSON
|
|
46
|
+
- The parsed value is an array
|
|
47
|
+
- The array contains at least one record
|
|
48
|
+
|
|
49
|
+
## Configuration Priority
|
|
50
|
+
|
|
51
|
+
The same three-layer configuration priority applies as with `csvtransform`:
|
|
52
|
+
|
|
53
|
+
1. **Implicit** -- Auto-detected from the first record's keys
|
|
54
|
+
2. **Explicit** -- Loaded from a mapping file via `-m`
|
|
55
|
+
3. **User** -- Command-line options (`-e`, `-n`, `-g`, `-c`)
|
|
56
|
+
|
|
57
|
+
Each layer overrides the previous.
|
|
58
|
+
|
|
59
|
+
## Output Format
|
|
60
|
+
|
|
61
|
+
The output is a standard Comprehension JSON object:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"Book": {
|
|
66
|
+
"Book_1": {
|
|
67
|
+
"GUIDBook": "Book_1",
|
|
68
|
+
"Title": "The Hunger Games",
|
|
69
|
+
"Author": "Suzanne Collins"
|
|
70
|
+
},
|
|
71
|
+
"Book_2": {
|
|
72
|
+
"GUIDBook": "Book_2",
|
|
73
|
+
"Title": "Harry Potter",
|
|
74
|
+
"Author": "J.K. Rowling"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Examples
|
|
81
|
+
|
|
82
|
+
### Transform with a mapping file
|
|
83
|
+
|
|
84
|
+
```shell
|
|
85
|
+
mdwint jsonarraytransform ./data/books-array.json \
|
|
86
|
+
-m mapping_Book.json \
|
|
87
|
+
-o books-comprehension.json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Transform with CLI options
|
|
91
|
+
|
|
92
|
+
```shell
|
|
93
|
+
mdwint jsonarraytransform ./data/books-array.json \
|
|
94
|
+
-e Book \
|
|
95
|
+
-n GUIDBook \
|
|
96
|
+
-g "Book_{~D:Record.id~}" \
|
|
97
|
+
-o books.json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Implicit transform
|
|
101
|
+
|
|
102
|
+
```shell
|
|
103
|
+
mdwint jsonarraytransform ./data/books-array.json -o books.json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Entity name, GUID template, and mappings are all auto-detected from the filename and the keys of the first record in the array.
|
|
107
|
+
|
|
108
|
+
### Merge into an existing Comprehension
|
|
109
|
+
|
|
110
|
+
```shell
|
|
111
|
+
mdwint jsonarraytransform ./data/authors.json \
|
|
112
|
+
-m mapping_Author.json \
|
|
113
|
+
-i existing-store.json \
|
|
114
|
+
-o existing-store.json
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Inline column mappings
|
|
118
|
+
|
|
119
|
+
```shell
|
|
120
|
+
mdwint jsonarraytransform ./data/books-array.json \
|
|
121
|
+
-e Book \
|
|
122
|
+
-g "Book_{~D:Record.id~}" \
|
|
123
|
+
-c "Title={~D:Record.title~},Author={~D:Record.author~}" \
|
|
124
|
+
-o books.json
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Extended output for debugging
|
|
128
|
+
|
|
129
|
+
```shell
|
|
130
|
+
mdwint jsonarraytransform ./data/books-array.json \
|
|
131
|
+
-m mapping_Book.json \
|
|
132
|
+
-x \
|
|
133
|
+
-o debug-output.json
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Round-trip workflow: CSV to JSON array to Comprehension
|
|
137
|
+
|
|
138
|
+
```shell
|
|
139
|
+
# 1. Transform CSV to a Comprehension
|
|
140
|
+
mdwint csvtransform ./data/books.csv -e Book -o books-object.json
|
|
141
|
+
|
|
142
|
+
# 2. Convert to array format
|
|
143
|
+
mdwint comprehensionarray books-object.json -e Book -o books-array.json
|
|
144
|
+
|
|
145
|
+
# 3. Re-transform from JSON array with a different mapping
|
|
146
|
+
mdwint jsonarraytransform books-array.json -m new-mapping.json -o remapped.json
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Tips
|
|
150
|
+
|
|
151
|
+
- This command loads the entire JSON file into memory at once, unlike `csvtransform` which streams line by line. For very large datasets, consider converting to CSV first.
|
|
152
|
+
- The input file must be a JSON array at the top level (starting with `[`). If your data is nested inside an object, extract the array first.
|
|
153
|
+
- All features available in `csvtransform` work here, including Solvers, `MultipleGUIDUniqueness`, and mapping files.
|
|
154
|
+
- The default output filename uses a `JSON-Comprehension-` prefix rather than `CSV-Comprehension-`.
|
|
155
|
+
|
|
156
|
+
## Notes
|
|
157
|
+
|
|
158
|
+
- Unlike `csvtransform` and `tsvtransform`, this command does not have a `-q` (quotedelimiter) option since JSON parsing handles quoting natively.
|
|
159
|
+
- The command processes records synchronously (not streamed), so memory usage is proportional to file size.
|
|
160
|
+
|
|
161
|
+
## See Also
|
|
162
|
+
|
|
163
|
+
- [csvtransform](csvtransform.md) -- CSV equivalent
|
|
164
|
+
- [tsvtransform](tsvtransform.md) -- TSV equivalent
|
|
165
|
+
- [comprehensionarray](comprehensionarray.md) -- Convert Comprehension objects to arrays
|
|
166
|
+
- [Mapping Files](../mapping-files.md) -- Full mapping file specification
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# load_comprehension
|
|
2
|
+
|
|
3
|
+
Push a Comprehension JSON file to Meadow REST APIs via the Integration Adapter. This command automatically creates an Integration Adapter for each entity found in the Comprehension and performs upsert operations against the configured Meadow server endpoints.
|
|
4
|
+
|
|
5
|
+
**Aliases:** `load`, `push`
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
mdwint load_comprehension <comprehension_file> [options]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Arguments
|
|
14
|
+
|
|
15
|
+
| Argument | Required | Description |
|
|
16
|
+
|----------|----------|-------------|
|
|
17
|
+
| `<comprehension_file>` | Yes | Path to the Comprehension JSON file to push |
|
|
18
|
+
|
|
19
|
+
## Options
|
|
20
|
+
|
|
21
|
+
| Option | Description | Default |
|
|
22
|
+
|--------|-------------|---------|
|
|
23
|
+
| `-p, --prefix <guid_prefix>` | GUID prefix applied to the entire Comprehension push. Used to namespace records within the Integration Adapter's set management. | -- |
|
|
24
|
+
| `-e, --entityguidprefix <prefix>` | GUID prefix applied per entity. Useful for distinguishing records from different import batches. | -- |
|
|
25
|
+
|
|
26
|
+
## How It Works
|
|
27
|
+
|
|
28
|
+
1. The Comprehension file is loaded from disk.
|
|
29
|
+
2. For each entity key in the Comprehension (e.g., `Book`, `Author`, `BookAuthorJoin`), an Integration Adapter is instantiated.
|
|
30
|
+
3. Each Integration Adapter is configured with the entity name and optional GUID prefixes.
|
|
31
|
+
4. All records for each entity are added to the adapter's source record set.
|
|
32
|
+
5. The adapter's `integrateRecords` method is called, which marshals each record and pushes it to the Meadow REST API via upsert (create or update).
|
|
33
|
+
|
|
34
|
+
The push operation uses the `SimpleMarshal` and `ForceMarshal` modes, meaning records are pushed as-is without complex field transformation.
|
|
35
|
+
|
|
36
|
+
## Prerequisites
|
|
37
|
+
|
|
38
|
+
The Meadow server must be running and accessible. The server URL and credentials are configured through the Fable settings (typically via a `meadow-integration-config.json` or environment variables).
|
|
39
|
+
|
|
40
|
+
## Examples
|
|
41
|
+
|
|
42
|
+
### Basic push
|
|
43
|
+
|
|
44
|
+
```shell
|
|
45
|
+
mdwint load_comprehension ./bookstore-comprehension.json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Pushes all entities (Book, Author, BookAuthorJoin, etc.) found in the Comprehension to the configured Meadow API.
|
|
49
|
+
|
|
50
|
+
### Push with a GUID prefix
|
|
51
|
+
|
|
52
|
+
```shell
|
|
53
|
+
mdwint load_comprehension ./bookstore-comprehension.json -p "Import-2024-Q1"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The prefix is applied to the Integration Adapter's set GUID marshal prefix, helping to namespace this import batch.
|
|
57
|
+
|
|
58
|
+
### Push with entity GUID prefix
|
|
59
|
+
|
|
60
|
+
```shell
|
|
61
|
+
mdwint load_comprehension ./bookstore-comprehension.json \
|
|
62
|
+
-e "BookstoreDemo"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Push with both prefixes
|
|
66
|
+
|
|
67
|
+
```shell
|
|
68
|
+
mdwint push ./bookstore-comprehension.json \
|
|
69
|
+
-p "Import-2024" \
|
|
70
|
+
-e "Demo"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Using the alias
|
|
74
|
+
|
|
75
|
+
```shell
|
|
76
|
+
mdwint push ./data/comprehension.json
|
|
77
|
+
mdwint load ./data/comprehension.json
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Full workflow: CSV to API
|
|
81
|
+
|
|
82
|
+
```shell
|
|
83
|
+
# 1. Transform CSV to Comprehension
|
|
84
|
+
mdwint csvtransform ./data/books.csv \
|
|
85
|
+
-m mapping_Book.json \
|
|
86
|
+
-o bookstore.json
|
|
87
|
+
|
|
88
|
+
# 2. Add Author entities
|
|
89
|
+
mdwint csvtransform ./data/books.csv \
|
|
90
|
+
-m mapping_Author.json \
|
|
91
|
+
-i bookstore.json \
|
|
92
|
+
-o bookstore.json
|
|
93
|
+
|
|
94
|
+
# 3. Push to Meadow API
|
|
95
|
+
mdwint load_comprehension ./bookstore.json -p "BookImport-001"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Console Output
|
|
99
|
+
|
|
100
|
+
The command logs progress throughout the push operation:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
Pushing comprehension file [./bookstore.json] to the Meadow Endpoints APIs.
|
|
104
|
+
Initializing and configuring data integration adapters...
|
|
105
|
+
Loading Comprehension File...
|
|
106
|
+
Wiring up Integration Adapters...
|
|
107
|
+
Finished importing comprehension file.
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Errors during the push (e.g., network failures, API errors) are logged with details.
|
|
111
|
+
|
|
112
|
+
## Tips
|
|
113
|
+
|
|
114
|
+
- Ensure the Meadow server is running and reachable before running this command.
|
|
115
|
+
- The command processes entities sequentially using an anticipation chain. Large Comprehensions with many entities will take proportionally longer.
|
|
116
|
+
- The GUID prefix options are useful when running multiple import batches against the same Meadow server, helping to identify and manage records from different sources.
|
|
117
|
+
- The entity abbreviation for the Integration Adapter is automatically derived from the capital letters of the entity name (e.g., `BookAuthorJoin` becomes `BAJ`).
|
|
118
|
+
|
|
119
|
+
## Notes
|
|
120
|
+
|
|
121
|
+
- This command requires a configured Meadow server. Without proper server configuration, the adapters will fail to connect.
|
|
122
|
+
- The `SimpleMarshal` mode means records are pushed with their field values as-is. No additional field transformation or validation is performed beyond what the Meadow API enforces.
|
|
123
|
+
- The command does not call back on completion of the server process -- it waits for all integration operations to finish before exiting.
|
|
124
|
+
|
|
125
|
+
## See Also
|
|
126
|
+
|
|
127
|
+
- [Integration Adapter](../integration-adapter.md) -- Detailed adapter configuration and behavior
|
|
128
|
+
- [data-clone](data-clone.md) -- Clone data from a Meadow API to a local database
|
|
129
|
+
- [Comprehensions](../comprehensions.md) -- Core data structure documentation
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# objectarraytocsv
|
|
2
|
+
|
|
3
|
+
Convert a JSON array of objects or an entity Comprehension into a CSV file. Nested objects are automatically flattened using dot notation. This command is useful for exporting data to spreadsheets, sharing with tools that expect CSV input, or round-tripping data through the integration pipeline.
|
|
4
|
+
|
|
5
|
+
**Aliases:** `object_array_to_csv`, `array_to_csv`
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
mdwint objectarraytocsv <file> [options]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Arguments
|
|
14
|
+
|
|
15
|
+
| Argument | Required | Description |
|
|
16
|
+
|----------|----------|-------------|
|
|
17
|
+
| `<file>` | Yes | Path to the JSON file containing the data to export |
|
|
18
|
+
|
|
19
|
+
## Options
|
|
20
|
+
|
|
21
|
+
| Option | Description | Default |
|
|
22
|
+
|--------|-------------|---------|
|
|
23
|
+
| `-e, --entity <name>` | Entity key to extract from a Comprehension object. Omit if the file is a plain JSON array. | `false` (expects array) |
|
|
24
|
+
| `-o, --output <path>` | Output CSV file path | `./Flattened-Object-<filename>.csv` or `./Flattened-Object-<filename>-Entity-<entity>.csv` |
|
|
25
|
+
|
|
26
|
+
## Input Formats
|
|
27
|
+
|
|
28
|
+
The command accepts several input formats:
|
|
29
|
+
|
|
30
|
+
### Plain JSON Array
|
|
31
|
+
|
|
32
|
+
A top-level array of objects (no `-e` flag needed):
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
[
|
|
36
|
+
{ "id": 1, "name": "Alice", "email": "alice@example.com" },
|
|
37
|
+
{ "id": 2, "name": "Bob", "email": "bob@example.com" }
|
|
38
|
+
]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Comprehension with Entity Flag
|
|
42
|
+
|
|
43
|
+
An object-keyed Comprehension, where you specify which entity to extract with `-e`:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"User": {
|
|
48
|
+
"User_1": { "GUIDUser": "User_1", "Name": "Alice" },
|
|
49
|
+
"User_2": { "GUIDUser": "User_2", "Name": "Bob" }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Single-Entity Comprehension (Auto-Detected)
|
|
55
|
+
|
|
56
|
+
If the input file is an object with a single key whose value is an object (not an array), the entity is auto-detected:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"Book": {
|
|
61
|
+
"Book_1": { "Title": "The Hunger Games" },
|
|
62
|
+
"Book_2": { "Title": "Harry Potter" }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Output Format
|
|
68
|
+
|
|
69
|
+
The output is a standard CSV file with:
|
|
70
|
+
|
|
71
|
+
- A header row containing all unique field names across all records, sorted alphabetically
|
|
72
|
+
- One data row per record
|
|
73
|
+
- Nested objects flattened with dot notation (e.g., `address.city`, `address.zip`)
|
|
74
|
+
- Values containing commas, double quotes, or newlines are properly escaped
|
|
75
|
+
|
|
76
|
+
Example output:
|
|
77
|
+
|
|
78
|
+
```csv
|
|
79
|
+
GUIDBook,ISBN,Language,Title
|
|
80
|
+
Book_1,0439023483,eng,The Hunger Games
|
|
81
|
+
Book_2,0439554934,eng,Harry Potter
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Examples
|
|
85
|
+
|
|
86
|
+
### Export a plain JSON array to CSV
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
mdwint objectarraytocsv ./data/books-array.json -o books.csv
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Export from a Comprehension with entity flag
|
|
93
|
+
|
|
94
|
+
```shell
|
|
95
|
+
mdwint objectarraytocsv ./store.json -e Book -o books.csv
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Auto-detect single entity
|
|
99
|
+
|
|
100
|
+
```shell
|
|
101
|
+
mdwint objectarraytocsv ./single-entity-comprehension.json -o export.csv
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Using the alias
|
|
105
|
+
|
|
106
|
+
```shell
|
|
107
|
+
mdwint array_to_csv ./data.json -o export.csv
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Full pipeline: CSV to Comprehension and back to CSV
|
|
111
|
+
|
|
112
|
+
```shell
|
|
113
|
+
# 1. Transform CSV to Comprehension
|
|
114
|
+
mdwint csvtransform ./raw-books.csv -m mapping_Book.json -o books.json
|
|
115
|
+
|
|
116
|
+
# 2. Convert Comprehension to array
|
|
117
|
+
mdwint comprehensionarray ./books.json -e Book -o books-array.json
|
|
118
|
+
|
|
119
|
+
# 3. Export array to CSV
|
|
120
|
+
mdwint objectarraytocsv ./books-array.json -o books-export.csv
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Export with nested objects
|
|
124
|
+
|
|
125
|
+
Given input:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
[
|
|
129
|
+
{ "name": "Alice", "address": { "city": "Seattle", "state": "WA" } },
|
|
130
|
+
{ "name": "Bob", "address": { "city": "Portland", "state": "OR" } }
|
|
131
|
+
]
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The output CSV will have flattened column headers:
|
|
135
|
+
|
|
136
|
+
```csv
|
|
137
|
+
address.city,address.state,name
|
|
138
|
+
Seattle,WA,Alice
|
|
139
|
+
Portland,OR,Bob
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Tips
|
|
143
|
+
|
|
144
|
+
- If your Comprehension has multiple entity keys and you do not specify `-e`, the command will error and list the available entity keys. Always use `-e` for multi-entity Comprehensions.
|
|
145
|
+
- Column headers in the CSV are sorted alphabetically. This means the column order may differ from the original data or Comprehension.
|
|
146
|
+
- For Comprehensions in object format (not array format), use `comprehensionarray` first to convert to an array, then pipe to this command. Alternatively, pass the Comprehension directly with `-e` to extract the entity.
|
|
147
|
+
- The command handles `null` and `undefined` values by outputting empty strings in the CSV.
|
|
148
|
+
|
|
149
|
+
## Notes
|
|
150
|
+
|
|
151
|
+
- Arrays within records are serialized as their string representation in the CSV output.
|
|
152
|
+
- The output file uses streaming writes, making it efficient for large datasets.
|
|
153
|
+
- If no records are found in the input, the command will error.
|
|
154
|
+
|
|
155
|
+
## See Also
|
|
156
|
+
|
|
157
|
+
- [comprehensionarray](comprehensionarray.md) -- Convert object Comprehension to array format
|
|
158
|
+
- [csvtransform](csvtransform.md) -- Transform CSV files into Comprehensions
|
|
159
|
+
- [Comprehensions](../comprehensions.md) -- Data structure documentation
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# CLI Overview
|
|
2
|
+
|
|
3
|
+
The `meadow-integration` CLI provides commands for transforming, analyzing, merging, and loading tabular data into the Meadow ecosystem. It is available as the `mdwint` binary when installed globally, or can be run directly with `npx`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
# Global install
|
|
9
|
+
npm install -g meadow-integration
|
|
10
|
+
|
|
11
|
+
# Or run directly with npx
|
|
12
|
+
npx meadow-integration [command] [options]
|
|
13
|
+
|
|
14
|
+
# Or from within the repository
|
|
15
|
+
npm start -- [command] [options]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Commands
|
|
19
|
+
|
|
20
|
+
| Command | Aliases | Description |
|
|
21
|
+
|---------|---------|-------------|
|
|
22
|
+
| [csvcheck](csvcheck.md) | `csv_c`, `csv_check` | Analyze a CSV file and produce column-level statistics |
|
|
23
|
+
| [csvtransform](csvtransform.md) | `csv_t`, `csv_transform` | Transform a CSV file into a Comprehension JSON file |
|
|
24
|
+
| [tsvtransform](tsvtransform.md) | `tsv_t`, `tsv_transform` | Transform a TSV file into a Comprehension JSON file |
|
|
25
|
+
| [jsonarraytransform](jsonarraytransform.md) | `jsonarray_t`, `jsonarray_transform` | Transform a JSON array file into a Comprehension |
|
|
26
|
+
| [comprehensionintersect](comprehensionintersect.md) | `intersect` | Merge two Comprehension JSON files together |
|
|
27
|
+
| [comprehensionarray](comprehensionarray.md) | `comprehension_to_array`, `array` | Convert an object-keyed Comprehension into a JSON array |
|
|
28
|
+
| [objectarraytocsv](objectarraytocsv.md) | `object_array_to_csv`, `array_to_csv` | Convert a JSON array or Comprehension to CSV format |
|
|
29
|
+
| [load_comprehension](load-comprehension.md) | `load`, `push` | Push a Comprehension to Meadow REST APIs |
|
|
30
|
+
| [data-clone](data-clone.md) | `clone`, `sync` | Clone data from a Meadow API source to a local database |
|
|
31
|
+
| [serve](serve.md) | `server`, `rest` | Start the Meadow Integration REST API server |
|
|
32
|
+
|
|
33
|
+
## Typical Workflows
|
|
34
|
+
|
|
35
|
+
### Analyze and Transform CSV Data
|
|
36
|
+
|
|
37
|
+
```shell
|
|
38
|
+
# 1. Inspect the CSV structure
|
|
39
|
+
mdwint csvcheck data.csv -o stats.json
|
|
40
|
+
|
|
41
|
+
# 2. Transform to a Comprehension
|
|
42
|
+
mdwint csvtransform data.csv -m mapping.json -o comprehension.json
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Build a Multi-Entity Comprehension
|
|
46
|
+
|
|
47
|
+
```shell
|
|
48
|
+
# 1. Create the first entity
|
|
49
|
+
mdwint csvtransform data.csv -m mapping_Book.json -o store.json
|
|
50
|
+
|
|
51
|
+
# 2. Add another entity to the same file
|
|
52
|
+
mdwint csvtransform data.csv -m mapping_Author.json -i store.json -o store.json
|
|
53
|
+
|
|
54
|
+
# 3. Add join records
|
|
55
|
+
mdwint csvtransform data.csv -m mapping_Join.json -i store.json -o store.json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Merge Data from Multiple Sources
|
|
59
|
+
|
|
60
|
+
```shell
|
|
61
|
+
# 1. Transform each source file
|
|
62
|
+
mdwint csvtransform source_a.csv -e Item -o set_a.json
|
|
63
|
+
mdwint csvtransform source_b.csv -e Item -o set_b.json
|
|
64
|
+
|
|
65
|
+
# 2. Merge by matching GUIDs
|
|
66
|
+
mdwint comprehensionintersect set_a.json -i set_b.json -e Item -o merged.json
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Export Comprehension to CSV
|
|
70
|
+
|
|
71
|
+
```shell
|
|
72
|
+
# 1. Convert from object to array format
|
|
73
|
+
mdwint comprehensionarray comprehension.json -e MyEntity -o array.json
|
|
74
|
+
|
|
75
|
+
# 2. Export array to CSV
|
|
76
|
+
mdwint objectarraytocsv array.json -o export.csv
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Push Data to a Meadow Server
|
|
80
|
+
|
|
81
|
+
```shell
|
|
82
|
+
mdwint load_comprehension comprehension.json -p "Import-2024"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Clone API Data to a Local Database
|
|
86
|
+
|
|
87
|
+
```shell
|
|
88
|
+
mdwint data-clone -a https://api.example.com -d MySQL -dh localhost -dn mydb
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Related Documentation
|
|
92
|
+
|
|
93
|
+
- [Comprehensions](../comprehensions.md) -- Core data structure concepts
|
|
94
|
+
- [Mapping Files](../mapping-files.md) -- Detailed mapping file reference
|
|
95
|
+
- [REST API Reference](../rest-api-reference.md) -- Server endpoint documentation
|
|
96
|
+
- [Integration Adapter](../integration-adapter.md) -- Programmatic push/pull operations
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# serve
|
|
2
|
+
|
|
3
|
+
Start the Meadow Integration REST API server. This provides HTTP endpoints for performing CSV checks, CSV transforms, comprehension operations, and other integration tasks programmatically over a network.
|
|
4
|
+
|
|
5
|
+
**Aliases:** `server`, `rest`
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
mdwint serve [options]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Options
|
|
14
|
+
|
|
15
|
+
| Option | Description | Default |
|
|
16
|
+
|--------|-------------|---------|
|
|
17
|
+
| `-p, --port <port>` | Port number for the server to listen on | `8086` |
|
|
18
|
+
|
|
19
|
+
## Environment Variables
|
|
20
|
+
|
|
21
|
+
| Variable | Description |
|
|
22
|
+
|----------|-------------|
|
|
23
|
+
| `MEADOW_INTEGRATION_PORT` | Override the default port. Takes precedence over the default but is overridden by the `-p` CLI flag. |
|
|
24
|
+
|
|
25
|
+
## Port Resolution Priority
|
|
26
|
+
|
|
27
|
+
The port is resolved in the following order (highest priority first):
|
|
28
|
+
|
|
29
|
+
1. `-p` CLI flag
|
|
30
|
+
2. `MEADOW_INTEGRATION_PORT` environment variable
|
|
31
|
+
3. Default value: `8086`
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
### Start on the default port
|
|
36
|
+
|
|
37
|
+
```shell
|
|
38
|
+
mdwint serve
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Starts the server on port 8086.
|
|
42
|
+
|
|
43
|
+
### Start on a custom port
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
mdwint serve -p 3000
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Using an environment variable
|
|
50
|
+
|
|
51
|
+
```shell
|
|
52
|
+
MEADOW_INTEGRATION_PORT=9090 mdwint serve
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Using the alias
|
|
56
|
+
|
|
57
|
+
```shell
|
|
58
|
+
mdwint server -p 3000
|
|
59
|
+
mdwint rest -p 3000
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Run in the background
|
|
63
|
+
|
|
64
|
+
```shell
|
|
65
|
+
mdwint serve -p 8086 &
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Console Output
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Starting Meadow Integration REST server on port 8086...
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The server process stays alive after starting. It does not exit on its own -- use `Ctrl+C` or send a termination signal to stop it.
|
|
75
|
+
|
|
76
|
+
## API Endpoints
|
|
77
|
+
|
|
78
|
+
Once the server is running, the REST API endpoints are available for HTTP requests. See the [REST API Reference](../rest-api-reference.md) for full endpoint documentation.
|
|
79
|
+
|
|
80
|
+
The server exposes endpoints for the same operations available via the CLI:
|
|
81
|
+
|
|
82
|
+
- CSV check
|
|
83
|
+
- CSV transform
|
|
84
|
+
- Comprehension array conversion
|
|
85
|
+
- Comprehension intersection
|
|
86
|
+
- Object array to CSV conversion
|
|
87
|
+
|
|
88
|
+
## Tips
|
|
89
|
+
|
|
90
|
+
- The server is built on Orator (Restify). It supports standard HTTP methods and JSON request/response bodies.
|
|
91
|
+
- For production deployments, consider running the server behind a reverse proxy (e.g., nginx) and using process management (e.g., PM2, systemd, or Ultravisor).
|
|
92
|
+
- The server does not implement authentication by default. If exposing it beyond localhost, add appropriate network-level access controls.
|
|
93
|
+
|
|
94
|
+
## Notes
|
|
95
|
+
|
|
96
|
+
- The server process intentionally does not call back after starting, keeping the Node.js process alive indefinitely.
|
|
97
|
+
- If the server fails to start (e.g., port already in use), an error is logged and the process exits.
|
|
98
|
+
|
|
99
|
+
## See Also
|
|
100
|
+
|
|
101
|
+
- [REST API Reference](../rest-api-reference.md) -- Full endpoint documentation
|
|
102
|
+
- [Programmatic API](../programmatic-api.md) -- Using meadow-integration as a library
|