-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: master
Are you sure you want to change the base?
Add context support #427
Conversation
5710c76
to
475a40a
Compare
475a40a
to
817820e
Compare
context: 'context', | ||
}; | ||
|
||
const dataTypes = ['domain', 'category', 'context']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const dataTypes = ['domain', 'category', 'context']; | |
const dataTypes = Object.keys(propToTypes); |
817820e
to
5189dce
Compare
5189dce
to
34f6a54
Compare
const { options, config } = require('../lib/metaschema-config/config'); | ||
|
||
const { MetaschemaError, SchemaValidationError } = metaschema.errors; | ||
|
There was a problem hiding this comment.
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.
lib/metaschema-config/context.js
Outdated
|
||
const addContext = (context, ms) => { | ||
const errors = []; | ||
const duplicateContext = ms.context.size > 0; |
There was a problem hiding this comment.
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
.
lib/metaschema-config/utils.js
Outdated
@@ -6,34 +6,23 @@ const { | |||
extractDecorator, | |||
} = require('metaschema'); | |||
|
|||
const propToTypes = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const propToTypes = { |
WDYT?
lib/metaschema-config/utils.js
Outdated
context: 'context', | ||
}; | ||
|
||
const dataTypes = Object.keys(propToTypes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const dataTypes = Object.keys(propToTypes); | |
const dataTypes = ['domain', 'category', 'context']; |
lib/metaschema-config/utils.js
Outdated
for (const type of dataTypes) { | ||
const value = field[type]; | ||
if (value) { | ||
const def = ms[propToTypes[type]].get(value); |
There was a problem hiding this comment.
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);
lib/metaschema-config/utils.js
Outdated
}; | ||
|
||
const dataTypes = Object.keys(propToTypes); | ||
const getDefinition = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const getDefinition = { | |
const getDefinition = type => schema => type === 'category' ? schema.definition : schema; |
There was a problem hiding this comment.
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
lib/metaschema-config/utils.js
Outdated
new SchemaValidationError('unresolved', `${source}.${key}`, info) | ||
); | ||
} else { | ||
field.definition = getDefinition[type](def); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
field.definition = getDefinition[type](def); | |
field.definition = getDefinition(type)(def); |
f4907a4
to
73fd562
Compare
73fd562
to
a09ffac
Compare
No description provided.