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 context support #427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add context support #427

wants to merge 1 commit into from

Conversation

o-rumiantsev
Copy link
Member

No description provided.

@o-rumiantsev o-rumiantsev requested a review from nechaido May 24, 2019 06:26
@o-rumiantsev o-rumiantsev self-assigned this May 24, 2019
@o-rumiantsev o-rumiantsev force-pushed the add-context-support branch 3 times, most recently from 5710c76 to 475a40a Compare May 24, 2019 06:41
@nechaido nechaido requested a review from lundibundi May 24, 2019 08:09
@o-rumiantsev o-rumiantsev force-pushed the add-context-support branch from 475a40a to 817820e Compare May 24, 2019 08:18
lib/metaschema-config/context.js Outdated Show resolved Hide resolved
lib/metaschema-config/context.js Outdated Show resolved Hide resolved
context: 'context',
};

const dataTypes = ['domain', 'category', 'context'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const dataTypes = ['domain', 'category', 'context'];
const dataTypes = Object.keys(propToTypes);

const { options, config } = require('../lib/metaschema-config/config');

const { MetaschemaError, SchemaValidationError } = metaschema.errors;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a positive test, to ensure that it is possible to use context args in actions.

@o-rumiantsev o-rumiantsev requested a review from nechaido June 14, 2019 16:12

const addContext = (context, ms) => {
const errors = [];
const duplicateContext = ms.context.size > 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this is not a suitable variable name. Maybe something like isContextDuplicate or isContextExist.

@@ -6,34 +6,23 @@ const {
extractDecorator,
} = require('metaschema');

const propToTypes = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const propToTypes = {

WDYT?

context: 'context',
};

const dataTypes = Object.keys(propToTypes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const dataTypes = Object.keys(propToTypes);
const dataTypes = ['domain', 'category', 'context'];

for (const type of dataTypes) {
const value = field[type];
if (value) {
const def = ms[propToTypes[type]].get(value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type === 'domain' ? 'domains' : type;
const def = ms[type].get(value);

};

const dataTypes = Object.keys(propToTypes);
const getDefinition = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const getDefinition = {
const getDefinition = type => schema => type === 'category' ? schema.definition : schema;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think, it is better to write like this:

const getDefinition = (type, schema) => type === 'category' ? schema.definition : schema

new SchemaValidationError('unresolved', `${source}.${key}`, info)
);
} else {
field.definition = getDefinition[type](def);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
field.definition = getDefinition[type](def);
field.definition = getDefinition(type)(def);

@o-rumiantsev o-rumiantsev force-pushed the add-context-support branch from f4907a4 to 73fd562 Compare June 26, 2019 06:28
@o-rumiantsev o-rumiantsev force-pushed the add-context-support branch from 73fd562 to a09ffac Compare June 27, 2019 11:57
@ivan-tymoshenko ivan-tymoshenko removed their request for review January 19, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants