Skip to content

Commit

Permalink
Merge pull request #98 from LionWeb-io/lionweb-2024.1
Browse files Browse the repository at this point in the history
Add support for LionWeb 2024.1
  • Loading branch information
joswarmer authored Jan 16, 2025
2 parents 722af7e + 7c6dfa1 commit cbf8e0c
Show file tree
Hide file tree
Showing 63 changed files with 1,562 additions and 988 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:

- name: start server and run tests (one step, else server will be down when tests start)
run: |
npm run -w @lionweb/repository-server dev-setup
npm run -w @lionweb/repository-server dev-run &
sleep 6
npm run test
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 160,
"tabWidth": 4,
"semi": false
}
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# lionweb-repository
Reference implementation of LionWeb repository

## Changes in Version 0.3.0

- Support for LionWeb 2024.1
- Removed `init` request from dbAdmin
- Request `createRepository` in dbAdmin has additional **mandatory** parameter `lionWebVersion`
- All tests and applications need to add this parameter
- The server config section for creating repositories also has this additional field
- All requests fail if the LionWeb version of the chunk is not the same LionWeb version as the repository.
-

## Postgres
The database used for storage of models is Postgres,
the easiest way to set up Postgres is through Docker.
Expand Down
8 changes: 5 additions & 3 deletions configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ Below is the server-config.json with all default values
"name": "default",
//
// Values are "always" | "never" | "if-not-exists"
create: "if-not-exists"
"create": "if-not-exists",
// Whether the repository should keep the history
"history": false
"history": false,
// Values can be: "2023.1" | "2024.1"
"lionWebVersion": "2024.1"
}
]
},
Expand All @@ -58,7 +60,7 @@ Below is the server-config.json with all default values
// The username used to connect to the Postgres server
"user": "postgres",
// The name of the admin database
maintenanceDb: "postgres" ,
"maintenanceDb": "postgres" ,
// The name of the Postgres database to be used within the Postgres server.
"db": "lionweb",
// The password used to connect to the Postgres server
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lionweb/repository",
"version": "0.2.0",
"version": "0.3.0",
"private": true,
"license": "Apache-2.0",
"repository": {
Expand All @@ -25,16 +25,16 @@
},
"devDependencies": {
"@types/chai": "4.3.11",
"@types/mocha": "10.0.1",
"@types/mocha": "10.0.10",
"@types/pg": "^8.11.6",
"@typescript-eslint/eslint-plugin": "6.13.2",
"@typescript-eslint/parser": "6.13.2",
"chai": "4.3.10",
"changesets": "1.0.2",
"@changesets/cli": "2.27.1",
"@changesets/cli": "2.27.11",
"@changesets/config": "3.0.0",
"eslint": "8.56.0",
"mocha": "10.2.0",
"mocha": "11.0.1",
"prettier": "3.1.0",
"ts-node": "10.9.2",
"ts-protoc-gen": "^0.15.0",
Expand Down
14 changes: 7 additions & 7 deletions packages/additionalapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lionweb/repository-additionalapi",
"version": "0.2.0",
"version": "0.3.0",
"private": false,
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -27,23 +27,23 @@
"@typescript-eslint/eslint-plugin": "6.13.2",
"@typescript-eslint/parser": "6.13.2",
"@types/chai": "4.3.11",
"@types/mocha": "10.0.1",
"@types/mocha": "10.0.10",
"eslint": "8.56.0",
"chai": "4.3.10",
"mocha": "10.2.0",
"mocha": "11.0.1",
"ts-node": "10.9.2",
"ts-proto": "^1.181.1",
"typescript": "5.2.2"
},
"dependencies": {
"@lionweb/repository-common": "0.2.0",
"@lionweb/repository-dbadmin": "0.2.0",
"@lionweb/repository-common": "0.3.0",
"@lionweb/repository-dbadmin": "0.3.0",
"@lionweb/validation": "0.6.2",
"@types/express": "4.17.21",
"body-parser": "1.20.2",
"body-parser": "2.0.2",
"cors": "2.8.5",
"dotenv": "16.3.1",
"express": "4.18.2",
"express": "4.21.2",
"flatbuffers": "^24.3.25",
"fs-extra": "11.1.1",
"nodemon": "3.0.1",
Expand Down
49 changes: 24 additions & 25 deletions packages/additionalapi/src/controllers/AdditionalApi.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { getRepositoryData } from "@lionweb/repository-dbadmin";
import { Request, Response } from "express"
import { AdditionalApiContext } from "../main.js"
import {
dbLogger,
getIntegerParam, getRepositoryParameter, getStringParam,
getIntegerParam,
HttpClientErrors,
HttpSuccessCodes, isParameterError,
lionwebResponse, ParameterError,
RepositoryData
lionwebResponse
} from "@lionweb/repository-common"
import {PBBulkImport, PBMetaPointer} from "../proto/index.js";
import {BulkImport} from "../database/index.js";
Expand Down Expand Up @@ -57,42 +57,41 @@ export class AdditionalApiImpl implements AdditionalApi {
})
return
}
const clientId = getStringParam(request, "clientId", "Dummy")
if (isParameterError(clientId)) {
const repositoryData = getRepositoryData(request)
if (isParameterError(repositoryData)) {
lionwebResponse(response, HttpClientErrors.BadRequest, {
success: false,
messages: [(clientId as ParameterError).error]
messages: [repositoryData.error]
})
return
}
const repositoryData: RepositoryData = { clientId: clientId, repository: getRepositoryParameter(request) }
const depthLimit = getIntegerParam(request, "depthLimit", Number.MAX_SAFE_INTEGER)
if (isParameterError(depthLimit)) {
lionwebResponse(response, HttpClientErrors.PreconditionFailed, {
success: false,
messages: [depthLimit.error]
})
} else {
dbLogger.info("API.getNodeTree is " + idList)
const result = await this.context.additionalApiWorker.getNodeTree(repositoryData, idList, depthLimit)
lionwebResponse(response, HttpSuccessCodes.Ok, {
success: true,
messages: [],
data: result.queryResult
})
const depthLimit = getIntegerParam(request, "depthLimit", Number.MAX_SAFE_INTEGER)
if (isParameterError(depthLimit)) {
lionwebResponse(response, HttpClientErrors.PreconditionFailed, {
success: false,
messages: [depthLimit.error]
})
} else {
dbLogger.info("API.getNodeTree is " + idList)
const result = await this.context.additionalApiWorker.getNodeTree(repositoryData, idList, depthLimit)
lionwebResponse(response, HttpSuccessCodes.Ok, {
success: true,
messages: [],
data: result.queryResult
})
}
}
}

bulkImport = async (request: Request, response: Response): Promise<void> => {
const clientId = getStringParam(request, "clientId", "Dummy")
if (isParameterError(clientId)) {
const repositoryData = getRepositoryData(request, "Dummy")
if (isParameterError(repositoryData)) {
lionwebResponse(response, HttpClientErrors.BadRequest, {
success: false,
messages: [(clientId as ParameterError).error]
messages: [repositoryData.error]
})
return
}
const repositoryData: RepositoryData = { clientId: clientId, repository: getRepositoryParameter(request) }
if (request.is(JSON_CONTENT_TYPE)) {
const result = await this.context.additionalApiWorker.bulkImport(repositoryData, request.body)
lionwebResponse(response, HttpSuccessCodes.Ok, {
Expand Down
Loading

0 comments on commit cbf8e0c

Please sign in to comment.