meadow-integration 1.0.4 → 1.0.6
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 → _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 +13 -10
- 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 +367 -0
- package/source/services/clone/Meadow-Service-Sync-Entity-Ongoing.js +457 -0
- package/source/services/clone/Meadow-Service-Sync.js +142 -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,111 @@
|
|
|
1
|
+
# csvcheck
|
|
2
|
+
|
|
3
|
+
Analyze a CSV file and produce column-level statistics. This is typically the first step when working with a new data set, helping you understand the structure, column names, and data characteristics before writing mapping files.
|
|
4
|
+
|
|
5
|
+
**Aliases:** `csv_c`, `csv_check`
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
mdwint csvcheck <file> [options]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Arguments
|
|
14
|
+
|
|
15
|
+
| Argument | Required | Description |
|
|
16
|
+
|----------|----------|-------------|
|
|
17
|
+
| `<file>` | Yes | Path to the CSV file to analyze |
|
|
18
|
+
|
|
19
|
+
## Options
|
|
20
|
+
|
|
21
|
+
| Option | Description | Default |
|
|
22
|
+
|--------|-------------|---------|
|
|
23
|
+
| `-f, --file <filepath>` | Alternate way to specify the CSV file path | -- |
|
|
24
|
+
| `-o, --output <filepath>` | Output file path for the statistics JSON | `./CSV-Stats-<filename>.json` |
|
|
25
|
+
| `-r, --records` | Include all parsed records in the output statistics object | `false` |
|
|
26
|
+
| `-q, --quotedelimiter <char>` | The quote delimiter character for CSV parsing | `"` |
|
|
27
|
+
|
|
28
|
+
## Output Format
|
|
29
|
+
|
|
30
|
+
The command writes a JSON file containing the following structure:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"RowCount": 100,
|
|
35
|
+
"ColumnCount": 8,
|
|
36
|
+
"Headers": ["id", "name", "email", "age", "city", "state", "zip", "joined"],
|
|
37
|
+
"FirstRow": { "id": "1", "name": "Alice Smith", "..." : "..." },
|
|
38
|
+
"LastRow": { "id": "100", "name": "Bob Jones", "..." : "..." },
|
|
39
|
+
"ColumnStatistics": {
|
|
40
|
+
"id": { "Count": 100, "EmptyCount": 0, "NumericCount": 100, "FirstValue": "1", "LastValue": "100" },
|
|
41
|
+
"name": { "Count": 100, "EmptyCount": 2, "NumericCount": 0, "FirstValue": "Alice Smith", "LastValue": "Bob Jones" }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
| Field | Description |
|
|
47
|
+
|-------|-------------|
|
|
48
|
+
| `RowCount` | Total number of data rows (excluding header) |
|
|
49
|
+
| `ColumnCount` | Number of columns detected |
|
|
50
|
+
| `Headers` | Array of column header names |
|
|
51
|
+
| `FirstRow` | The first data record as a key-value object |
|
|
52
|
+
| `LastRow` | The last data record as a key-value object |
|
|
53
|
+
| `ColumnStatistics` | Per-column statistics including count, empty count, numeric count, first value, and last value |
|
|
54
|
+
|
|
55
|
+
When the `-r` flag is used, an additional `Records` property is included containing every parsed row.
|
|
56
|
+
|
|
57
|
+
## Console Output
|
|
58
|
+
|
|
59
|
+
In addition to writing the statistics file, the command prints a summary to the console:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
Parsing CSV file [./data/books.csv]...
|
|
63
|
+
...CSV parser completed, examined 100 rows of data.
|
|
64
|
+
...Found 8 columns in the CSV file.
|
|
65
|
+
...Writing statistics to file [./CSV-Stats-books.csv.json]...
|
|
66
|
+
...Statistics written.
|
|
67
|
+
Summary: 100 rows, 8 columns in [./data/books.csv].
|
|
68
|
+
Headers: id, name, email, age, city, state, zip, joined
|
|
69
|
+
First Row: {"id":"1","name":"Alice Smith",...}
|
|
70
|
+
Last Row: {"id":"100","name":"Bob Jones",...}
|
|
71
|
+
Column Statistics:
|
|
72
|
+
-> [id]: {"Count":100,"EmptyCount":0,"NumericCount":100,...}
|
|
73
|
+
-> [name]: {"Count":100,"EmptyCount":2,"NumericCount":0,...}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Examples
|
|
77
|
+
|
|
78
|
+
### Basic CSV analysis
|
|
79
|
+
|
|
80
|
+
```shell
|
|
81
|
+
mdwint csvcheck ./data/books.csv
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Writes statistics to `./CSV-Stats-books.csv.json`.
|
|
85
|
+
|
|
86
|
+
### Specify an output file
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
mdwint csvcheck ./data/books.csv -o ./output/book-stats.json
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Include all records in the output
|
|
93
|
+
|
|
94
|
+
```shell
|
|
95
|
+
mdwint csvcheck ./data/users.csv -r -o ./output/user-stats-full.json
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This is useful for debugging or when you want to inspect the fully parsed data alongside the statistics.
|
|
99
|
+
|
|
100
|
+
### Using the alias
|
|
101
|
+
|
|
102
|
+
```shell
|
|
103
|
+
mdwint csv_check ./data/products.csv -o product-stats.json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Tips
|
|
107
|
+
|
|
108
|
+
- Run `csvcheck` before writing a mapping file. The `Headers` array in the output tells you the exact column names to reference in your `{~D:Record.<column>~}` templates.
|
|
109
|
+
- The `ColumnStatistics` can help identify which columns contain numeric data, which have empty values, and which might be good candidates for GUID generation.
|
|
110
|
+
- Use the `-r` flag sparingly on large files, as it embeds every record in the output JSON.
|
|
111
|
+
- If your CSV uses a non-standard quote character, pass it with `-q`. For example, `-q "'"` for single-quoted fields.
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# csvtransform
|
|
2
|
+
|
|
3
|
+
Transform a CSV file into a Comprehension JSON file. This is the primary command for converting tabular data into the Meadow Comprehension format. It supports implicit mapping (auto-detected from column headers), explicit mapping files, and command-line configuration options.
|
|
4
|
+
|
|
5
|
+
**Aliases:** `csv_t`, `csv_transform`
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
mdwint csvtransform <file> [options]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Arguments
|
|
14
|
+
|
|
15
|
+
| Argument | Required | Description |
|
|
16
|
+
|----------|----------|-------------|
|
|
17
|
+
| `<file>` | Yes | Path to the CSV 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_column>~}` |
|
|
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 | `./CSV-Comprehension-<filename>.json` |
|
|
30
|
+
| `-x, --extended` | Output full operation state, not just the Comprehension | `false` |
|
|
31
|
+
| `-q, --quotedelimiter <char>` | Quote delimiter character for CSV parsing | `"` |
|
|
32
|
+
|
|
33
|
+
## Configuration Priority
|
|
34
|
+
|
|
35
|
+
When running a transform, three layers of configuration are merged. Each layer overrides the previous:
|
|
36
|
+
|
|
37
|
+
1. **Implicit** -- Auto-detected from the first CSV row. The entity name is derived from the filename, and a 1:1 column mapping is generated.
|
|
38
|
+
2. **Explicit** -- Loaded from a mapping file via `-m`. See [Mapping Files](../mapping-files.md) for the full specification.
|
|
39
|
+
3. **User** -- Command-line options (`-e`, `-n`, `-g`, `-c`). These always take highest priority.
|
|
40
|
+
|
|
41
|
+
## Output Format
|
|
42
|
+
|
|
43
|
+
The standard output is a Comprehension JSON object:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"Book": {
|
|
48
|
+
"Book_1": {
|
|
49
|
+
"GUIDBook": "Book_1",
|
|
50
|
+
"Title": "The Hunger Games",
|
|
51
|
+
"Language": "eng",
|
|
52
|
+
"ISBN": "0439023483"
|
|
53
|
+
},
|
|
54
|
+
"Book_2": {
|
|
55
|
+
"GUIDBook": "Book_2",
|
|
56
|
+
"Title": "Harry Potter",
|
|
57
|
+
"Language": "eng",
|
|
58
|
+
"ISBN": "0439554934"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
When the `-x` flag is used, the output includes the full operation state with configuration details, implicit/explicit configurations, and parsed row counts.
|
|
65
|
+
|
|
66
|
+
## Examples
|
|
67
|
+
|
|
68
|
+
### Implicit transform (auto-detect everything)
|
|
69
|
+
|
|
70
|
+
```shell
|
|
71
|
+
mdwint csvtransform ./data/books.csv -o books.json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The entity name, GUID template, and column mappings are all auto-detected from the filename and CSV headers.
|
|
75
|
+
|
|
76
|
+
### Transform with CLI options
|
|
77
|
+
|
|
78
|
+
```shell
|
|
79
|
+
mdwint csvtransform ./data/books.csv \
|
|
80
|
+
-e Book \
|
|
81
|
+
-n GUIDBook \
|
|
82
|
+
-g "Book_{~D:Record.id~}" \
|
|
83
|
+
-o books.json
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Transform with inline column mappings
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
mdwint csvtransform ./data/books.csv \
|
|
90
|
+
-e Book \
|
|
91
|
+
-g "Book_{~D:Record.id~}" \
|
|
92
|
+
-c "Title={~D:Record.title~},Language={~D:Record.language_code~},ISBN={~D:Record.isbn~}" \
|
|
93
|
+
-o books.json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Transform with a mapping file
|
|
97
|
+
|
|
98
|
+
```shell
|
|
99
|
+
mdwint csvtransform ./data/books.csv \
|
|
100
|
+
-m mapping_Book.json \
|
|
101
|
+
-o books.json
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Where `mapping_Book.json` contains:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"Entity": "Book",
|
|
109
|
+
"GUIDTemplate": "Book_{~D:Record.id~}",
|
|
110
|
+
"Mappings": {
|
|
111
|
+
"Title": "{~D:Record.title~}",
|
|
112
|
+
"Language": "{~D:Record.language_code~}",
|
|
113
|
+
"ISBN": "{~D:Record.isbn~}"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Merge into an existing Comprehension
|
|
119
|
+
|
|
120
|
+
```shell
|
|
121
|
+
# First pass: create Book entities
|
|
122
|
+
mdwint csvtransform ./data/books.csv \
|
|
123
|
+
-m mapping_Book.json \
|
|
124
|
+
-o store.json
|
|
125
|
+
|
|
126
|
+
# Second pass: add Author entities to the same file
|
|
127
|
+
mdwint csvtransform ./data/books.csv \
|
|
128
|
+
-m mapping_Author.json \
|
|
129
|
+
-i store.json \
|
|
130
|
+
-o store.json
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Extended output for debugging
|
|
134
|
+
|
|
135
|
+
```shell
|
|
136
|
+
mdwint csvtransform ./data/books.csv \
|
|
137
|
+
-m mapping_Book.json \
|
|
138
|
+
-x \
|
|
139
|
+
-o debug-output.json
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Custom quote delimiter
|
|
143
|
+
|
|
144
|
+
```shell
|
|
145
|
+
mdwint csvtransform ./data/pipe-quoted.csv \
|
|
146
|
+
-m mapping.json \
|
|
147
|
+
-q "'" \
|
|
148
|
+
-o output.json
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Tips
|
|
152
|
+
|
|
153
|
+
- Use `csvcheck` first to inspect your CSV and get the exact column header names for your mapping templates.
|
|
154
|
+
- When building multi-entity Comprehensions from a single CSV, use the `-i` flag on subsequent passes to merge entities into one file.
|
|
155
|
+
- Inline column mappings (`-c`) do not support commas or equal signs within template values. Use a mapping file (`-m`) for complex mappings.
|
|
156
|
+
- Duplicate GUIDs within the same transform run are merged automatically, with later values overwriting earlier ones.
|
|
157
|
+
- The `-x` flag is useful for debugging mapping issues. It outputs the full operation state including which configuration layer was used.
|
|
158
|
+
|
|
159
|
+
## Notes
|
|
160
|
+
|
|
161
|
+
- If no output file is specified, the default is `./CSV-Comprehension-<filename>.json`.
|
|
162
|
+
- If no incoming comprehension file is specified, the default path is checked; if it exists, it is loaded and merged into.
|
|
163
|
+
- The command uses streaming line-by-line parsing, so it can handle large CSV files without loading the entire file into memory.
|
|
164
|
+
|
|
165
|
+
## See Also
|
|
166
|
+
|
|
167
|
+
- [Mapping Files](../mapping-files.md) -- Full mapping file specification
|
|
168
|
+
- [Comprehensions](../comprehensions.md) -- Core data structure documentation
|
|
169
|
+
- [tsvtransform](tsvtransform.md) -- Same command for tab-delimited files
|
|
170
|
+
- [jsonarraytransform](jsonarraytransform.md) -- Same command for JSON array files
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# data-clone
|
|
2
|
+
|
|
3
|
+
Clone data from a Meadow API source to a local MySQL or MSSQL database. This command connects to a Meadow REST API server, reads entity data according to an extended schema definition, and writes it into a local relational database. It supports both initial full clones and ongoing incremental synchronization.
|
|
4
|
+
|
|
5
|
+
**Aliases:** `clone`, `sync`
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
mdwint data-clone [options]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Options
|
|
14
|
+
|
|
15
|
+
### API Connection
|
|
16
|
+
|
|
17
|
+
| Option | Description | Default |
|
|
18
|
+
|--------|-------------|---------|
|
|
19
|
+
| `-a, --api_server <url>` | Source Meadow API server URL | -- |
|
|
20
|
+
| `-u, --api_username <username>` | API authentication username | -- |
|
|
21
|
+
| `-p, --api_password <password>` | API authentication password | -- |
|
|
22
|
+
|
|
23
|
+
### Database Connection
|
|
24
|
+
|
|
25
|
+
| Option | Description | Default |
|
|
26
|
+
|--------|-------------|---------|
|
|
27
|
+
| `-d, --db_provider <provider>` | Database provider: `MySQL` or `MSSQL` | `MySQL` |
|
|
28
|
+
| `-dh, --db_host <host>` | Database server hostname or IP address | -- |
|
|
29
|
+
| `-dp, --db_port <port>` | Database server port | Provider default (3306 for MySQL, 1433 for MSSQL) |
|
|
30
|
+
| `-du, --db_username <username>` | Database authentication username | -- |
|
|
31
|
+
| `-dw, --db_password <password>` | Database authentication password | -- |
|
|
32
|
+
| `-dn, --db_name <name>` | Target database name | -- |
|
|
33
|
+
|
|
34
|
+
### Schema and Sync
|
|
35
|
+
|
|
36
|
+
| Option | Description | Default |
|
|
37
|
+
|--------|-------------|---------|
|
|
38
|
+
| `-sp, --schema_path <path>` | Path to a Meadow extended schema JSON file defining the entities and fields to clone | -- |
|
|
39
|
+
| `-s, --sync_mode <mode>` | Synchronization mode: `Initial` for a full clone, `Ongoing` for incremental updates | `Initial` |
|
|
40
|
+
| `-w, --post_run_delay <minutes>` | Minutes to wait after a sync run completes before exiting (or re-running in ongoing mode) | `0` |
|
|
41
|
+
|
|
42
|
+
## Configuration File
|
|
43
|
+
|
|
44
|
+
Instead of passing all options on the command line, you can create a `.meadow.config.json` file in your working directory. The command reads this file automatically and merges its values with any CLI flags provided (CLI flags take precedence).
|
|
45
|
+
|
|
46
|
+
### MySQL Configuration
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"api_server": "https://api.example.com",
|
|
51
|
+
"api_username": "integration-user",
|
|
52
|
+
"api_password": "secret-token",
|
|
53
|
+
|
|
54
|
+
"db_provider": "MySQL",
|
|
55
|
+
"db_host": "localhost",
|
|
56
|
+
"db_port": 3306,
|
|
57
|
+
"db_username": "root",
|
|
58
|
+
"db_password": "mysql-password",
|
|
59
|
+
"db_name": "meadow_clone",
|
|
60
|
+
|
|
61
|
+
"schema_path": "./schema/extended-schema.json",
|
|
62
|
+
"sync_mode": "Initial",
|
|
63
|
+
"post_run_delay": 0
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### MSSQL Configuration
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"api_server": "https://api.example.com",
|
|
72
|
+
"api_username": "integration-user",
|
|
73
|
+
"api_password": "secret-token",
|
|
74
|
+
|
|
75
|
+
"db_provider": "MSSQL",
|
|
76
|
+
"db_host": "sql-server.local",
|
|
77
|
+
"db_port": 1433,
|
|
78
|
+
"db_username": "sa",
|
|
79
|
+
"db_password": "mssql-password",
|
|
80
|
+
"db_name": "MeadowClone",
|
|
81
|
+
|
|
82
|
+
"schema_path": "./schema/extended-schema.json",
|
|
83
|
+
"sync_mode": "Initial"
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### With Entity List
|
|
88
|
+
|
|
89
|
+
You can scope the clone to specific entities by including an `entities` array in the configuration:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"api_server": "https://api.example.com",
|
|
94
|
+
"api_username": "integration-user",
|
|
95
|
+
"api_password": "secret-token",
|
|
96
|
+
|
|
97
|
+
"db_provider": "MySQL",
|
|
98
|
+
"db_host": "localhost",
|
|
99
|
+
"db_port": 3306,
|
|
100
|
+
"db_username": "root",
|
|
101
|
+
"db_password": "mysql-password",
|
|
102
|
+
"db_name": "meadow_clone",
|
|
103
|
+
|
|
104
|
+
"schema_path": "./schema/extended-schema.json",
|
|
105
|
+
"sync_mode": "Initial",
|
|
106
|
+
|
|
107
|
+
"entities": ["Book", "Author", "BookAuthorJoin"]
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Ongoing Sync with Delay
|
|
112
|
+
|
|
113
|
+
For continuous synchronization, set the sync mode to `Ongoing` and configure a delay between runs:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"api_server": "https://api.example.com",
|
|
118
|
+
"api_username": "integration-user",
|
|
119
|
+
"api_password": "secret-token",
|
|
120
|
+
|
|
121
|
+
"db_provider": "MySQL",
|
|
122
|
+
"db_host": "localhost",
|
|
123
|
+
"db_port": 3306,
|
|
124
|
+
"db_username": "root",
|
|
125
|
+
"db_password": "mysql-password",
|
|
126
|
+
"db_name": "meadow_sync",
|
|
127
|
+
|
|
128
|
+
"schema_path": "./schema/extended-schema.json",
|
|
129
|
+
"sync_mode": "Ongoing",
|
|
130
|
+
"post_run_delay": 15
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
This configuration waits 15 minutes between each sync cycle.
|
|
135
|
+
|
|
136
|
+
### Minimal Configuration
|
|
137
|
+
|
|
138
|
+
If you are using environment variables or default values for most settings, a minimal config might look like:
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"api_server": "https://api.example.com",
|
|
143
|
+
"api_username": "admin",
|
|
144
|
+
"api_password": "password",
|
|
145
|
+
|
|
146
|
+
"db_provider": "MySQL",
|
|
147
|
+
"db_host": "localhost",
|
|
148
|
+
"db_name": "local_clone",
|
|
149
|
+
|
|
150
|
+
"schema_path": "./schema.json"
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Sync Modes
|
|
155
|
+
|
|
156
|
+
### Initial
|
|
157
|
+
|
|
158
|
+
Performs a full clone of all entity data from the API source. The target database tables are created (or recreated) based on the schema definition, and all records are fetched and inserted.
|
|
159
|
+
|
|
160
|
+
Use this mode when:
|
|
161
|
+
- Setting up a new local database for the first time
|
|
162
|
+
- You need a complete refresh of all data
|
|
163
|
+
- The schema has changed and tables need to be rebuilt
|
|
164
|
+
|
|
165
|
+
### Ongoing
|
|
166
|
+
|
|
167
|
+
Performs incremental synchronization, fetching only records that have been created or modified since the last sync. This mode is much faster than a full clone for large datasets.
|
|
168
|
+
|
|
169
|
+
Use this mode when:
|
|
170
|
+
- You have already performed an initial clone
|
|
171
|
+
- You want to keep the local database up to date with the API source
|
|
172
|
+
- You are running the clone as a scheduled or continuous process
|
|
173
|
+
|
|
174
|
+
## Examples
|
|
175
|
+
|
|
176
|
+
### Full clone with CLI flags
|
|
177
|
+
|
|
178
|
+
```shell
|
|
179
|
+
mdwint data-clone \
|
|
180
|
+
-a https://api.example.com \
|
|
181
|
+
-u admin \
|
|
182
|
+
-p secret123 \
|
|
183
|
+
-d MySQL \
|
|
184
|
+
-dh localhost \
|
|
185
|
+
-dp 3306 \
|
|
186
|
+
-du root \
|
|
187
|
+
-dw rootpass \
|
|
188
|
+
-dn meadow_clone \
|
|
189
|
+
-sp ./schema/extended-schema.json \
|
|
190
|
+
-s Initial
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Clone using a config file
|
|
194
|
+
|
|
195
|
+
```shell
|
|
196
|
+
# With .meadow.config.json in the current directory:
|
|
197
|
+
mdwint data-clone
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Override config file values with CLI flags
|
|
201
|
+
|
|
202
|
+
```shell
|
|
203
|
+
# Use config file for most settings, override the sync mode
|
|
204
|
+
mdwint data-clone -s Ongoing -w 10
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Clone to MSSQL
|
|
208
|
+
|
|
209
|
+
```shell
|
|
210
|
+
mdwint data-clone \
|
|
211
|
+
-a https://api.example.com \
|
|
212
|
+
-u admin \
|
|
213
|
+
-p secret123 \
|
|
214
|
+
-d MSSQL \
|
|
215
|
+
-dh sql-server.local \
|
|
216
|
+
-dp 1433 \
|
|
217
|
+
-du sa \
|
|
218
|
+
-dw sapassword \
|
|
219
|
+
-dn MeadowClone \
|
|
220
|
+
-sp ./schema.json
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Ongoing sync with delay
|
|
224
|
+
|
|
225
|
+
```shell
|
|
226
|
+
mdwint data-clone \
|
|
227
|
+
-a https://api.example.com \
|
|
228
|
+
-u admin \
|
|
229
|
+
-p secret123 \
|
|
230
|
+
-d MySQL \
|
|
231
|
+
-dh localhost \
|
|
232
|
+
-dn meadow_sync \
|
|
233
|
+
-sp ./schema.json \
|
|
234
|
+
-s Ongoing \
|
|
235
|
+
-w 15
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
This runs a sync, waits 15 minutes, then repeats.
|
|
239
|
+
|
|
240
|
+
### Using aliases
|
|
241
|
+
|
|
242
|
+
```shell
|
|
243
|
+
mdwint clone -a https://api.example.com -sp ./schema.json
|
|
244
|
+
mdwint sync -s Ongoing -w 5
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Schema File
|
|
248
|
+
|
|
249
|
+
The `--schema_path` option points to a Meadow extended schema JSON file. This file defines the entities and their fields that should be cloned. The schema determines:
|
|
250
|
+
|
|
251
|
+
- Which entities to fetch from the API
|
|
252
|
+
- What database tables and columns to create
|
|
253
|
+
- Field types and constraints for the local database
|
|
254
|
+
|
|
255
|
+
Refer to the Meadow [Schema](../vocabulary/Schema.md) documentation for the schema file format.
|
|
256
|
+
|
|
257
|
+
## Tips
|
|
258
|
+
|
|
259
|
+
- Always run an `Initial` sync before switching to `Ongoing` mode. The ongoing mode expects the database tables and baseline data to already exist.
|
|
260
|
+
- Use the `.meadow.config.json` file for settings you reuse across runs. Use CLI flags for one-off overrides (e.g., switching between Initial and Ongoing mode).
|
|
261
|
+
- For production deployments, avoid putting passwords directly in the config file. Use environment variables or a secrets manager.
|
|
262
|
+
- The `post_run_delay` option is useful for running the clone as a long-lived process that keeps data in sync. Set it to `0` for a single run that exits after completion.
|
|
263
|
+
- When scoping to specific entities via the `entities` array in the config file, ensure that any entity dependencies (e.g., join tables referencing parent entities) are also included.
|
|
264
|
+
|
|
265
|
+
## Notes
|
|
266
|
+
|
|
267
|
+
- The database must already exist before running the clone. The command creates tables but does not create the database itself.
|
|
268
|
+
- The command requires the `meadow-connection-mysql` or `meadow-connection-mssql` packages, which are included as dependencies of `meadow-integration`.
|
|
269
|
+
- The API server must be a Meadow server with REST endpoints for the entities defined in the schema.
|
|
270
|
+
- Configuration file values and CLI flags are merged, with CLI flags taking precedence.
|
|
271
|
+
|
|
272
|
+
## See Also
|
|
273
|
+
|
|
274
|
+
- [load_comprehension](load-comprehension.md) -- Push local Comprehension data to a Meadow API
|
|
275
|
+
- [serve](serve.md) -- Start a local Meadow Integration REST API server
|
|
276
|
+
- [Schema](../vocabulary/Schema.md) -- Meadow schema file format
|
|
277
|
+
- [Integration Adapter](../integration-adapter.md) -- Programmatic data integration
|