https://github.com/bcgsc/pori_graphkb_schema
Shared package between the API and GUI for GraphKB which holds the schema definitions and schema-related functions
https://github.com/bcgsc/pori_graphkb_schema
genomics graphdb knowledge-base personalized-medicine pori
Last synced: about 1 year ago
JSON representation
Shared package between the API and GUI for GraphKB which holds the schema definitions and schema-related functions
- Host: GitHub
- URL: https://github.com/bcgsc/pori_graphkb_schema
- Owner: bcgsc
- License: gpl-3.0
- Created: 2020-12-17T19:22:43.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2024-09-06T22:43:33.000Z (almost 2 years ago)
- Last Synced: 2025-04-15T16:35:22.231Z (about 1 year ago)
- Topics: genomics, graphdb, knowledge-base, personalized-medicine, pori
- Language: TypeScript
- Homepage: https://bcgsc.github.io/pori
- Size: 1.08 MB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GraphKB Schema
[](https://codecov.io/gh/bcgsc/pori_graphkb_schema)  [](https://badge.fury.io/js/%40bcgsc-pori%2Fgraphkb-schema)  [](https://doi.org/10.5281/zenodo.5730411)
This repository is part of the [platform for oncogenomic reporting and interpretation](https://github.com/bcgsc/pori).
This is the package which defines the schema logic used to create the database, build the API and GUI.
It is a dependency of both the API and GUI and uses the parser package.
This is where all database constraints and swagger metadata associated with a particular database
model is defined

## Deployment
This package is installed on our local npm server. To install simply add to your package.json as you
would with any other package and supply the registry argument to npm install
## Getting Started (For Developers)
Install the dependencies
```bash
npm install
```
Then run the tests
```bash
npm run test
```
## Using with OrientJS
To avoid requiring orientjs in this package, the RID class is defaulted to the builtin String class.
It is expected that if you want your RID strings cast to RID objects (orientjs.RID or orientjs.RecordID
for orientjs 3.X.X) that you will patch this after import. For example
```javascript
const {RID} = require('orientjs');
const {constants, schema} = require('@bcgsc-pori/graphkb-schema');
const {PERMISSIONS} = constants;
constants.RID = RID; // IMPORTANT: Without this all castToRID will do is convert to a string
```
## Migrating from v3 to v4
To facilitate more reuseable typing schemes ClassModel and Property classes have been removed and now are simply objects. All interactions with these models should go through the schema class instead of interacting directly with the model and property objects. Return types are given only when they differ.
| v3 (ClassModel methods) | v4 equivalent (SchemaDefinition methods) | Notes |
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
| `properties` | `getProperties(modelName: string)` | |
| `required` | `requiredProperties(modelName: string)` | |
| `optional` | `optionalProperties(modelName: string)` | |
| `getActiveProperties()` | `activeProperties(modelName: string)` | |
| `inherits` | `ancestors(modelName: string)` | |
| `subclasses: ClassModel[]` | `children(modelName: string): string[]` | |
| `descendantTree(boolean): ClassModel[]` | `descendants(modelName: string, opt: { excludeAbstract?: boolean, includeSelf?: boolean }): string[]` | must be called with includeSelf=true to match v3 edition |
| `queryProperties: Property[]` | `queryableProperties(modelName: string): PropertyDefinition[]` | |
| `inheritsProperty(propName: string)` | `inheritsProperty(modelName: string, propName: string)` | |
| `toJSON` | N/A | |
| `formatRecord(record: GraphRecord, opt = {})` | `formatRecord(modelName: string, record: GraphRecord, opt = {})` | |