https://github.com/eclipsesource/json-reconcile
Typescript library for diffing and merging JSON models
https://github.com/eclipsesource/json-reconcile
Last synced: 10 months ago
JSON representation
Typescript library for diffing and merging JSON models
- Host: GitHub
- URL: https://github.com/eclipsesource/json-reconcile
- Owner: eclipsesource
- License: mit
- Created: 2025-01-23T12:19:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-14T14:31:26.000Z (over 1 year ago)
- Last Synced: 2025-03-14T15:40:44.816Z (over 1 year ago)
- Language: TypeScript
- Size: 278 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-reconcile [](https://github.com/eclipsesource/.github/blob/main/repository-classification.md) [](https://github.com/eclipsesource/.github/blob/main/repository-classification.md)
Typescript library for diffing and merging JSON models
## Purpose
- easy-to-use conflict management
- comparison and merging functionality in a general way
- platform-independent REST API that can handle model conflicts in JSON format
- 2-way and 3-way merge supported
- state of the merging progress is saved and handled with session cookies
## Examples
### update update conflict
#### Request
```json
POST /dicome/compare
Content-Type: application/json
{
"original": {
"package": {
"id": "scml",
"classes": [
{
"id": "xyz",
"name": "Smart City"
}
]
}
},
"left": {
"package": {
"id": "scml",
"classes": [
{
"id": "xyz",
"name": "SmartCity"
}
]
}
},
"right": {
"package": {
"id": "scml",
"classes": [
{
"id": "xyz",
"name": "Smart_City"
}
]
}
}
}
```
## Usage
### API Description
```bash
POST /dicome/compare
```
initial endpoint, if request header not set then new session is created (set cookie header for all following requests)
**Request Header:** optional current session - session cookie
**Request Body:** model left, model right (and original)
**Response:** diffmodel
```bash
GET /dicome/model/left
```
**Request Header:** current session - session cookie
**Request Body:** -
**Response:** left model
```bash
GET /dicome/model/right
```
**Request Header:** current session - session cookie
**Request Body:** -
**Response:** right model
```bash
GET /dicome/model/diff
```
**Request Header:** current session - session cookie
**Request Body:** -
**Response:** diff model
```bash
PUT /dicome/apply/[ltr | rtl]
```
**Request Header:** current session - session cookie
**Parameter:** ltr (left to right) or rtl (right to left)
**Request Body:** list of 1-n changes to apply
**Response:** JSON patch (if technically possible) of diff model and left/right
```bash
PUT /dicome/accept
```
for conflicts, if this is a left change then right automatically rejected and vis a versa
**Request Header:** current session - session cookie
**Request Body:** list of 1-n changes to apply
**Response:** JSON patch (if technically possible) of diff model and left/right
```bash
PUT /dicome/reject
```
for conflicts, if this is a left change then right automatically acctepted and vis a versa
**Request Header:** current session - session cookie
**Request Body:** list of 1-n changes to reject
**Response:** JSON patch (if technically possible) of diff model and left/right
```bash
DELETE /dicome/session
```
triggers cleanup (remove models)
**Request Header:** current session - session cookie
**Request Body:** -
**Response:** 200 OK
## Build & Run
``` npx tsc ``` or ``` npm run build ```
and then
``` node dist/src/api/testRunner.js ```
## Run Tests with ECMAScript Modules
from package.json command:
``` npm run test ```
from console:
``` NODE_OPTIONS="$NODE_OPTIONS --experimental-vm-modules" npx jest ```