Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
--i;
break;
}
if (op.op === 'select') {
Object.assign(fullQuery, op.query);
}
}
// add inner joins for Include fields
const schema = this.provider.schema.categories.get(this.category)
.definition;
let hasInclude = false;
for (const key in schema) {
const field = schema[key];
if (extractDecorator(field) === 'Include') {
const cat = field.category;
pgquery.innerJoin(cat, `${this.category}.Id`, `${cat}.Id`);
hasInclude = true;
}
}
if (permissionChecker) {
await permissionChecker(this.category, {
record: fullQuery,
isQuery: true,
});
}
// TODO: use array mode here, to avoid possible name collisions when
// querying from multiple tables at once
try {
cb => {
metaschema.fs
.load(
[
getPathFromCurrentDir('.', 'schemas'),
// TODO add other schemas here
],
{
...options,
context: {
api: {
argon2,
common,
console,
jstp,
provider,
},
},
metatests.test('Fully supports schemas/system', async test => {
let schema;
try {
schema = await metaschema.fs.load(
'test/fixtures/validate',
options,
config
);
} catch (error) {
console.error(error);
test.fail(error);
test.end();
return;
}
test.strictSame(
schema.validate('category', 'Person', {
Id: '12',
FullName: {
FirstName: 'Name',
metatests.test('Unsupported domain class', async test => {
const expectedErrorMessage =
"Unsupported domain class '__UNSUPPORTED_CLASS__' in domain 'Test'";
let schema;
try {
schema = await metaschema.fs.load(
'test/fixtures/unsupported-domain-class',
options,
config
);
} catch (error) {
console.error(error);
test.fail(error);
test.end();
return;
}
test.throws(() => generateDDL(schema), new Error(expectedErrorMessage));
test.end();
});
metatests.test('Fully supports schemas/system', async test => {
let schema;
try {
schema = await metaschema.fs.load(
'test/fixtures/resources',
options,
config
);
} catch (error) {
console.error(error);
test.fail(error);
test.end();
return;
}
test.strictSame(schema.resources.common.get('en'), '{"Id":"Identifier"}');
test.strictSame(schema.resources.domains.get('en'), '{"Id":"Identifier"}');
test.strictSame(
schema.actions.get('PublicAction').resources.get('en'),
'{"Login":"Login"}'
'use strict';
const metaschema = require('metaschema');
const metatests = require('metatests');
const { Uint64 } = require('@metarhia/common');
const { options, config } = require('../lib/metaschema-config/config');
const { ValidationError, MetaschemaError } = metaschema.errors;
metatests.test('Fully supports schemas/system', async test => {
let schema;
try {
schema = await metaschema.fs.load(
'test/fixtures/validate',
options,
config
);
} catch (error) {
console.error(error);
test.fail(error);
test.end();
return;
}
metatests.test('cursor schema', async test => {
const languages = [
{ Id: 1, Name: 'English', Locale: 'en' },
{ Id: 2, Name: 'Ukrainian', Locale: 'uk' },
{ Id: 3, Name: 'Russian', Locale: 'ru' },
];
let schema;
try {
schema = await metaschema.fs.load('schemas/system', options, config);
} catch (err) {
test.fail(err);
test.end();
return;
}
const schemaName = 'Language';
const category = schema.categories.get(schemaName).definition;
const mcLanguages = new MemoryCursor(languages).definition(
category,
schemaName
);
const data = await mcLanguages
.select({ Locale: '> en' })
.order('Name')
async test => {
let schema;
try {
schema = await metaschema.fs.load(
'test/fixtures/resources',
options,
config
);
} catch (error) {
console.error(error);
test.fail(error);
test.end();
return;
}
const provider = new StorageProvider({});
await provider.open({ schema });
test.endAfterSubtests();
metatests.test('pg.ddl.generateLinks unit test', async test => {
let schema;
try {
schema = await metaschema.fs.load(schemasDir, options, config);
} catch (err) {
test.fail(err);
test.end();
return;
}
test.strictSame(
ddl.generateLinks(
[
{
from: 'LocalCategory2',
to: 'LocalCategory1',
name: 'field',
link: schema.categories.get('LocalCategory2').definition.field,
destination: 'LocalCategory1',
},
metatests.test('pg.ddl.generateTable unit test', async test => {
let schema;
try {
schema = await metaschema.fs.load(schemasDir, options, config);
} catch (err) {
test.fail(err);
test.end();
return;
}
test.strictSame(
ddl.generateTable(
'LocalCategory2',
schema.categories.get('LocalCategory2').definition,
'Local',
new Map([['Nomen', 'text']]),
new Map(),
[],
schema.categories
),