meadow-integration 1.0.20 → 1.0.21
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/example-applications/mapping-demo/.quackage.json +10 -0
- package/example-applications/mapping-demo/README.md +99 -0
- package/example-applications/mapping-demo/data/books-sample.csv +21 -0
- package/example-applications/mapping-demo/generate-build-config.js +44 -0
- package/example-applications/mapping-demo/mappings/books-to-book.json +14 -0
- package/example-applications/mapping-demo/package.json +14 -0
- package/example-applications/mapping-demo/server.js +814 -0
- package/example-applications/mapping-demo/source/MappingDemoApp.js +52 -0
- package/example-applications/mapping-demo/source/views/MappingDemoEditorView.js +186 -0
- package/example-applications/mapping-demo/web/index.html +892 -0
- package/example-applications/mapping-demo/web/mapping-demo-editor.js +3195 -0
- package/example-applications/mapping-demo/web/mapping-demo-editor.js.map +1 -0
- package/example-applications/mapping-demo/web/mapping-demo-editor.min.js +2 -0
- package/example-applications/mapping-demo/web/mapping-demo-editor.min.js.map +1 -0
- package/example-applications/mapping-demo/web/pict.min.js +12 -0
- package/package.json +8 -4
- package/source/Meadow-Integration-Browser.js +31 -0
- package/source/Meadow-Integration.js +16 -1
- package/source/services/certainty/Service-CertaintyAccumulator.js +402 -0
- package/source/services/clone/Meadow-Service-Sync-Entity-Initial.js +16 -3
- package/source/services/clone/Meadow-Service-Sync-Entity-Ongoing.js +15 -2
- package/source/services/clone/Meadow-Service-Sync.js +21 -0
- package/source/views/MappingEditor-SchemaUtils.js +71 -0
- package/source/views/PictView-MeadowMappingEditor.js +1299 -0
- package/source/views/flow-cards/FlowCard-MappingSource.js +50 -0
- package/source/views/flow-cards/FlowCard-MappingTarget.js +49 -0
- package/source/views/flow-cards/FlowCard-SolverExpression.js +78 -0
- package/source/views/flow-cards/FlowCard-TemplateExpression.js +77 -0
- package/test/Meadow-Integration-CloneDeleteSync_test.js +809 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"GulpfileConfiguration": {
|
|
3
|
+
"EntrypointInputSourceFile": "{~Data:AppData.CWD~}/source/MappingDemoApp.js",
|
|
4
|
+
"LibraryObjectName": "MappingDemoApplication",
|
|
5
|
+
"LibraryOutputFolder": "{~Data:AppData.CWD~}/web/",
|
|
6
|
+
"LibraryUniminifiedFileName": "mapping-demo-editor.js",
|
|
7
|
+
"LibraryMinifiedFileName": "mapping-demo-editor.min.js",
|
|
8
|
+
"BrowserifyIgnore": []
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Mapping Demo
|
|
2
|
+
|
|
3
|
+
A self-contained example application that demonstrates the full
|
|
4
|
+
`meadow-integration` data pipeline:
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
CSV file → Parse → Map → TabularTransform → Comprehension → IntegrationAdapter → Meadow DB
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## What it demonstrates
|
|
11
|
+
|
|
12
|
+
| Stage | Component | Description |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| Parse | CSV reader | Reads `data/books-sample.csv` into raw record objects |
|
|
15
|
+
| Map | Mapping JSON | Declares how CSV columns become entity fields via Pict templates |
|
|
16
|
+
| Transform | `TabularTransform` | Applies the mapping to every record, produces a GUID-keyed comprehension |
|
|
17
|
+
| Load | `IntegrationAdapter` | Upserts comprehension records into a Meadow REST API (idempotent) |
|
|
18
|
+
| Verify | `meadow-endpoints` | Reads records back through the auto-generated Book REST API |
|
|
19
|
+
|
|
20
|
+
The demo uses an **in-memory SQLite database** so nothing is written to disk.
|
|
21
|
+
|
|
22
|
+
## Running
|
|
23
|
+
|
|
24
|
+
From the `meadow-integration` module root, install dependencies once:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm install
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Then start the demo server:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
cd example-applications/mapping-demo
|
|
34
|
+
node server.js
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Open **http://localhost:8092/** in your browser and click through each pipeline step.
|
|
38
|
+
|
|
39
|
+
## Endpoints
|
|
40
|
+
|
|
41
|
+
| Method | Path | Description |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| `GET` | `/` | Pipeline demo web UI |
|
|
44
|
+
| `GET` | `/1.0/Demo/Status` | Server status and endpoint list |
|
|
45
|
+
| `GET` | `/1.0/Demo/SampleData` | Raw parsed CSV records |
|
|
46
|
+
| `GET` | `/1.0/Demo/Mapping` | Current mapping configuration |
|
|
47
|
+
| `POST` | `/1.0/Demo/Transform` | Run mapping → comprehension |
|
|
48
|
+
| `POST` | `/1.0/Demo/Load` | Push comprehension via IntegrationAdapter |
|
|
49
|
+
| `GET` | `/1.0/Demo/Books` | Read loaded books from database |
|
|
50
|
+
| `GET` | `/1.0/Books/0/20` | Meadow-Endpoints live Book list |
|
|
51
|
+
| `GET` | `/1.0/Books/Count` | Record count |
|
|
52
|
+
|
|
53
|
+
## Sample data
|
|
54
|
+
|
|
55
|
+
`data/books-sample.csv` contains 20 well-known books with these columns:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
id, title, original_publication_year, isbn, language_code
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Mapping configuration
|
|
62
|
+
|
|
63
|
+
`mappings/books-to-book.json` maps the CSV columns to the `Book` entity
|
|
64
|
+
(from the retold-harness bookstore schema):
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"Entity": "Book",
|
|
69
|
+
"GUIDTemplate": "DemoBook-{~D:Record.id~}",
|
|
70
|
+
"Mappings": {
|
|
71
|
+
"Title": "{~D:Record.title~}",
|
|
72
|
+
"Language": "{~D:Record.language_code~}",
|
|
73
|
+
"PublicationYear": "{~D:Record.original_publication_year~}",
|
|
74
|
+
"ISBN": "{~D:Record.isbn~}",
|
|
75
|
+
"Genre": "Classic",
|
|
76
|
+
"Type": "Fiction",
|
|
77
|
+
"ImageURL": ""
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The `GUIDTemplate` uses `Record.id` from the source CSV to generate a stable
|
|
83
|
+
external GUID (`DemoBook-1`, `DemoBook-2`, …). The `IntegrationAdapter`
|
|
84
|
+
tracks these in a `GUIDMap` so repeat loads are safe upserts.
|
|
85
|
+
|
|
86
|
+
## Architecture
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
server.js
|
|
90
|
+
├── SQLite (in-memory) ← meadow-connection-sqlite
|
|
91
|
+
├── Meadow DAL (Book entity) ← meadow + inline schema
|
|
92
|
+
├── meadow-endpoints (Book) ← auto-generates /1.0/Book(s) REST routes
|
|
93
|
+
├── Demo pipeline endpoints ← /1.0/Demo/*
|
|
94
|
+
│ ├── TabularTransform ← parse + map = comprehension
|
|
95
|
+
│ └── IntegrationAdapter ← comprehension → upsert via REST
|
|
96
|
+
└── Static web UI ← web/index.html
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
All components run on a single Orator (Restify) server at port 8092.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
id,title,original_publication_year,isbn,language_code
|
|
2
|
+
1,The Hunger Games,2008,439023483,eng
|
|
3
|
+
2,Harry Potter and the Sorcerers Stone,1997,439554934,eng
|
|
4
|
+
3,Twilight,2005,316015849,en-US
|
|
5
|
+
4,To Kill a Mockingbird,1960,61120081,eng
|
|
6
|
+
5,The Great Gatsby,1925,743273567,eng
|
|
7
|
+
6,The Fault in Our Stars,2012,525478817,eng
|
|
8
|
+
7,The Hobbit,1937,547928227,eng
|
|
9
|
+
8,The Hitchhikers Guide to the Galaxy,1979,345391802,eng
|
|
10
|
+
9,Pride and Prejudice,1813,679783261,eng
|
|
11
|
+
10,Brave New World,1932,60929871,eng
|
|
12
|
+
11,1984,1949,451524934,eng
|
|
13
|
+
12,One Hundred Years of Solitude,1967,060883287,spa
|
|
14
|
+
13,Animal Farm,1945,452284244,eng
|
|
15
|
+
14,Fahrenheit 451,1953,1451673319,eng
|
|
16
|
+
15,The Catcher in the Rye,1951,316769177,eng
|
|
17
|
+
16,Lord of the Flies,1954,571056865,eng
|
|
18
|
+
17,Dune,1965,441013597,eng
|
|
19
|
+
18,A Brief History of Time,1988,553380163,eng
|
|
20
|
+
19,Don Quixote,1605,60934344,spa
|
|
21
|
+
20,Crime and Punishment,1866,14044913,rus
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copies pict.min.js from node_modules into web/ so the server can serve it.
|
|
5
|
+
* The quackage build config comes from .quackage.json — no manual generation needed.
|
|
6
|
+
*
|
|
7
|
+
* Run automatically via `npm run build` before starting the demo.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const libPath = require('path');
|
|
11
|
+
const libFS = require('fs');
|
|
12
|
+
|
|
13
|
+
// ── Copy pict.min.js from node_modules into web/ ──────────────────────────────
|
|
14
|
+
|
|
15
|
+
const tmpPictDistCandidates =
|
|
16
|
+
[
|
|
17
|
+
libPath.resolve(__dirname, 'node_modules/pict/dist/pict.min.js'),
|
|
18
|
+
libPath.resolve(__dirname, '../../node_modules/pict/dist/pict.min.js')
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
let tmpPictMinSrc = null;
|
|
22
|
+
for (let i = 0; i < tmpPictDistCandidates.length; i++)
|
|
23
|
+
{
|
|
24
|
+
if (libFS.existsSync(tmpPictDistCandidates[i]))
|
|
25
|
+
{
|
|
26
|
+
tmpPictMinSrc = tmpPictDistCandidates[i];
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (tmpPictMinSrc)
|
|
32
|
+
{
|
|
33
|
+
const tmpWebDir = libPath.resolve(__dirname, 'web');
|
|
34
|
+
if (!libFS.existsSync(tmpWebDir))
|
|
35
|
+
{
|
|
36
|
+
libFS.mkdirSync(tmpWebDir, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
libFS.copyFileSync(tmpPictMinSrc, libPath.join(tmpWebDir, 'pict.min.js'));
|
|
39
|
+
console.log('Copied pict.min.js to web/');
|
|
40
|
+
}
|
|
41
|
+
else
|
|
42
|
+
{
|
|
43
|
+
console.warn('WARNING: Could not find pict/dist/pict.min.js — run npm install in meadow-integration first.');
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Entity": "Book",
|
|
3
|
+
"GUIDTemplate": "DemoBook-{~D:Record.id~}",
|
|
4
|
+
"Mappings":
|
|
5
|
+
{
|
|
6
|
+
"Title": "{~D:Record.title~}",
|
|
7
|
+
"Language": "{~D:Record.language_code~}",
|
|
8
|
+
"PublicationYear": "{~D:Record.original_publication_year~}",
|
|
9
|
+
"ISBN": "{~D:Record.isbn~}",
|
|
10
|
+
"Genre": "Classic",
|
|
11
|
+
"Type": "Fiction",
|
|
12
|
+
"ImageURL": ""
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mapping-demo",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Meadow-Integration pipeline demo: parse → map → visual map → comprehension → load",
|
|
5
|
+
"main": "server.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node server.js",
|
|
8
|
+
"build": "node generate-build-config.js && ../../node_modules/.bin/quack build",
|
|
9
|
+
"demo": "npm run build && node server.js"
|
|
10
|
+
},
|
|
11
|
+
"author": "steven velozo <steven@velozo.com>",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"dependencies": {}
|
|
14
|
+
}
|