-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #390 from vlad-markin/hotfix/manifestschema-for-ba…
…ckend Hotfix/manifestschema for backend
- Loading branch information
Showing
6 changed files
with
257 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {BaseEntities} from '../../global/entities/entities.mjs'; | ||
import queries from '../../global/jsonata/queries.mjs'; | ||
import driver from '../../global/jsonata/driver.mjs'; | ||
import yaml from 'yaml'; | ||
import {loadFromAssets} from '../storage/cache.mjs'; | ||
|
||
class BackendEntities extends BaseEntities { | ||
|
||
// Подключает мастер-схему для подсказок и валидации метамодели | ||
getMasterSchema() { | ||
return yaml.parse(loadFromAssets('master-schema.yaml')); | ||
} | ||
async queryEntitiesJSONSchema(manifest) { | ||
const query = queries.makeQuery(queries.QUERIES[queries.IDS.JSONSCEMA_ENTITIES]); | ||
let result = null; | ||
try { | ||
result = await driver | ||
.expression(query) | ||
.evaluate(manifest); | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.error(e); | ||
throw e; | ||
} | ||
return result; | ||
} | ||
} | ||
|
||
|
||
// Регистрирует кастомные сущности | ||
export default function(manifest) { | ||
const entities = new BackendEntities(); | ||
entities.registerEntities(entities); | ||
entities.setManifest(manifest); | ||
void entities.reloadSchema(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.