Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for LionWeb 2024.1 #98

Merged
merged 37 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6d7fced
Add lionweb version, make some strings (like table names) constants
joswarmer Dec 28, 2024
021a7bc
Add repository admin in server
joswarmer Dec 29, 2024
dd033d5
remove logs
joswarmer Dec 29, 2024
11227a2
remove commented logs
joswarmer Dec 29, 2024
7504499
Ensure repositories has a context
joswarmer Dec 29, 2024
99d64ac
remove commented logs, changed
joswarmer Dec 29, 2024
c9de792
Ensure repositories has a context
joswarmer Dec 29, 2024
5f4ab44
Merge remote-tracking branch 'origin/lionweb-2024.1' into lionweb-2024.1
joswarmer Dec 29, 2024
cfac433
Take LionWeb version into account for all repositories.
joswarmer Jan 3, 2025
4a602d2
Version 0.2.0 => 0.3.0
joswarmer Jan 6, 2025
0ce02ce
Add validation of lionweb version to all requests that have a chunk a…
joswarmer Jan 6, 2025
dcd36a8
return in memory repositories for listRepositories request.
joswarmer Jan 6, 2025
f80112f
Code cleanup
joswarmer Jan 6, 2025
d88c1a0
Fix error
joswarmer Jan 6, 2025
862e2a8
review comments
joswarmer Jan 6, 2025
c031fdc
Formatting sources.
joswarmer Jan 7, 2025
a1aeb0c
fix createRepository
ftomassetti Jan 12, 2025
2f07c99
add DBAdmpinApiWorker.tx
ftomassetti Jan 12, 2025
adca66d
improve logging
ftomassetti Jan 12, 2025
19762ae
Fix deletion of schema
ftomassetti Jan 12, 2025
f932e4d
Wip
ftomassetti Jan 12, 2025
0673096
Ensure we read the repository store when starting the repository in r…
ftomassetti Jan 12, 2025
cbf5875
Ensure to serialize the chunk using the right version
ftomassetti Jan 13, 2025
de38c2a
Update dependencies to have no vulnerabilities
joswarmer Jan 13, 2025
cca9dc2
Update dependencies to have no vulnerabilities
joswarmer Jan 13, 2025
5df0044
Linting
ftomassetti Jan 13, 2025
714e796
Adding DBAdminApiWorker.addRepositoryToTable
ftomassetti Jan 13, 2025
fd3aa35
Adding DBAdminApiWorker.addRepositoryToTable
ftomassetti Jan 13, 2025
1815b79
perform setup before run, when running tests
ftomassetti Jan 13, 2025
7e55df9
Update configuration.md
ftomassetti Jan 13, 2025
d286a47
review comments
joswarmer Jan 13, 2025
4ee45de
Merge branch 'lionweb-2024.1' into bugfix/repoinit
joswarmer Jan 13, 2025
8afbd03
Fix incorrect imports
joswarmer Jan 13, 2025
a0a7516
Merge branch 'lionweb-2024.1' into bugfix/repoinit
joswarmer Jan 13, 2025
c40dd0d
Fix merge errors
joswarmer Jan 13, 2025
9563835
Review comment
joswarmer Jan 13, 2025
7c6dfa1
Fix use of repository and schema names
joswarmer Jan 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 3 additions & 2 deletions packages/additionalapi/src/database/ImportLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,14 @@ export async function storeNodes(client: PoolClient, repositoryData: RepositoryD
}
}

async function storeNodesThroughFlatBuffers(client: PoolClient, repositoryData: RepositoryData, dbConnection: DbConnection, bulkImport: FBBulkImport, repositoryName: string)
async function storeNodesThroughFlatBuffers(client: PoolClient, repositoryData: RepositoryData, dbConnection: DbConnection, bulkImport: FBBulkImport)
ftomassetti marked this conversation as resolved.
Show resolved Hide resolved
: Promise<MetaPointersTracker> {
// We obtain all the indexes for all the MetaPointers we need. We will then use such indexes in successive calls
// to pipeInputIntoQueryStream, etc.
const metaPointersTracker = new MetaPointersTracker(repositoryData);
await populateThroughFlatBuffers(metaPointersTracker, bulkImport, repositoryData, dbConnection);

const repositoryName = repositoryData.repository.repository_name
await pipeInputIntoQueryStream(client,`COPY "${repositoryName}".lionweb_nodes(id,classifier,annotations,parent) FROM STDIN`,
prepareInputStreamNodesFlatBuffers(bulkImport, metaPointersTracker), "nodes insertion");
await pipeInputIntoQueryStream(client,`COPY "${repositoryName}".lionweb_containments(containment,children,node_id) FROM STDIN`,
Expand Down Expand Up @@ -338,7 +339,7 @@ export async function performImportFromFlatBuffers(client: PoolClient, dbConnect
}

// Add all the new nodes
const metaPointersTracker = await storeNodesThroughFlatBuffers(client, repositoryData, dbConnection, bulkImport, repositoryData.repository)
const metaPointersTracker = await storeNodesThroughFlatBuffers(client, repositoryData, dbConnection, bulkImport)

// Attach the root of the new nodes to existing containers
for (let i = 0; i < bulkImport.attachPointsLength(); i++) {
Expand Down
14 changes: 7 additions & 7 deletions packages/bulkapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lionweb/repository-bulkapi",
"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",
"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",
"@types/source-map-support": "0.5.10",
"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",
"fs-extra": "11.1.1",
"nodemon": "3.0.1",
"pg": "8.11.3",
Expand Down
Loading