Refactoring defaults in schemas.
This commit is contained in:
parent
0721b49216
commit
78a4000e34
5 changed files with 14 additions and 27 deletions
|
@ -16,7 +16,7 @@ systems = [
|
||||||
PropertyDocumentationSchema = c.object {
|
PropertyDocumentationSchema = c.object {
|
||||||
title: 'Property Documentation'
|
title: 'Property Documentation'
|
||||||
description: 'Documentation entry for a property this Component will add to its Thang which other Components might want to also use.'
|
description: 'Documentation entry for a property this Component will add to its Thang which other Components might want to also use.'
|
||||||
'default':
|
default:
|
||||||
name: 'foo'
|
name: 'foo'
|
||||||
type: 'object'
|
type: 'object'
|
||||||
description: 'The `foo` property can satisfy all the #{spriteName}\'s foobar needs. Use it wisely.'
|
description: 'The `foo` property can satisfy all the #{spriteName}\'s foobar needs. Use it wisely.'
|
||||||
|
@ -88,9 +88,6 @@ PropertyDocumentationSchema = c.object {
|
||||||
DependencySchema = c.object {
|
DependencySchema = c.object {
|
||||||
title: 'Component Dependency'
|
title: 'Component Dependency'
|
||||||
description: 'A Component upon which this Component depends.'
|
description: 'A Component upon which this Component depends.'
|
||||||
'default':
|
|
||||||
#original: ?
|
|
||||||
majorVersion: 0
|
|
||||||
required: ['original', 'majorVersion']
|
required: ['original', 'majorVersion']
|
||||||
format: 'latest-version-reference'
|
format: 'latest-version-reference'
|
||||||
links: [{rel: 'db', href: '/db/level.component/{(original)}/version/{(majorVersion)}'}]
|
links: [{rel: 'db', href: '/db/level.component/{(original)}/version/{(majorVersion)}'}]
|
||||||
|
@ -114,6 +111,7 @@ LevelComponentSchema = c.object {
|
||||||
codeLanguage: 'coffeescript'
|
codeLanguage: 'coffeescript'
|
||||||
dependencies: [] # TODO: should depend on something by default
|
dependencies: [] # TODO: should depend on something by default
|
||||||
propertyDocumentation: []
|
propertyDocumentation: []
|
||||||
|
configSchema: {}
|
||||||
}
|
}
|
||||||
c.extendNamedProperties LevelComponentSchema # let's have the name be the first property
|
c.extendNamedProperties LevelComponentSchema # let's have the name be the first property
|
||||||
LevelComponentSchema.properties.name.pattern = c.classNamePattern
|
LevelComponentSchema.properties.name.pattern = c.classNamePattern
|
||||||
|
@ -123,13 +121,11 @@ _.extend LevelComponentSchema.properties,
|
||||||
description: 'The short name of the System this Component belongs to, like \"ai\".'
|
description: 'The short name of the System this Component belongs to, like \"ai\".'
|
||||||
type: 'string'
|
type: 'string'
|
||||||
'enum': systems
|
'enum': systems
|
||||||
'default': 'ai'
|
|
||||||
description:
|
description:
|
||||||
title: 'Description'
|
title: 'Description'
|
||||||
description: 'A short explanation of what this Component does.'
|
description: 'A short explanation of what this Component does.'
|
||||||
type: 'string'
|
type: 'string'
|
||||||
maxLength: 2000
|
maxLength: 2000
|
||||||
'default': 'This Component makes the Thang attack itself.'
|
|
||||||
codeLanguage:
|
codeLanguage:
|
||||||
type: 'string'
|
type: 'string'
|
||||||
title: 'Language'
|
title: 'Language'
|
||||||
|
@ -138,7 +134,6 @@ _.extend LevelComponentSchema.properties,
|
||||||
code:
|
code:
|
||||||
title: 'Code'
|
title: 'Code'
|
||||||
description: 'The code for this Component, as a CoffeeScript class. TODO: add link to documentation for how to write these.'
|
description: 'The code for this Component, as a CoffeeScript class. TODO: add link to documentation for how to write these.'
|
||||||
'default': attackSelfCode
|
|
||||||
type: 'string'
|
type: 'string'
|
||||||
format: 'coffee'
|
format: 'coffee'
|
||||||
js:
|
js:
|
||||||
|
@ -146,14 +141,13 @@ _.extend LevelComponentSchema.properties,
|
||||||
description: 'The transpiled JavaScript code for this Component'
|
description: 'The transpiled JavaScript code for this Component'
|
||||||
type: 'string'
|
type: 'string'
|
||||||
format: 'hidden'
|
format: 'hidden'
|
||||||
dependencies: c.array {title: 'Dependencies', description: 'An array of Components upon which this Component depends.', 'default': [], uniqueItems: true}, DependencySchema
|
dependencies: c.array {title: 'Dependencies', description: 'An array of Components upon which this Component depends.', uniqueItems: true}, DependencySchema
|
||||||
propertyDocumentation: c.array {title: 'Property Documentation', description: 'An array of documentation entries for each notable property this Component will add to its Thang which other Components might want to also use.', 'default': []}, PropertyDocumentationSchema
|
propertyDocumentation: c.array {title: 'Property Documentation', description: 'An array of documentation entries for each notable property this Component will add to its Thang which other Components might want to also use.'}, PropertyDocumentationSchema
|
||||||
configSchema: _.extend metaschema, {title: 'Configuration Schema', description: 'A schema for validating the arguments that can be passed to this Component as configuration.', default: {type: 'object', additionalProperties: false}}
|
configSchema: _.extend metaschema, {title: 'Configuration Schema', description: 'A schema for validating the arguments that can be passed to this Component as configuration.', default: {type: 'object', additionalProperties: false}}
|
||||||
official:
|
official:
|
||||||
type: 'boolean'
|
type: 'boolean'
|
||||||
title: 'Official'
|
title: 'Official'
|
||||||
description: 'Whether this is an official CodeCombat Component.'
|
description: 'Whether this is an official CodeCombat Component.'
|
||||||
'default': false
|
|
||||||
|
|
||||||
c.extendBasicProperties LevelComponentSchema, 'level.component'
|
c.extendBasicProperties LevelComponentSchema, 'level.component'
|
||||||
c.extendSearchableProperties LevelComponentSchema
|
c.extendSearchableProperties LevelComponentSchema
|
||||||
|
|
|
@ -2,7 +2,7 @@ c = require './../schemas'
|
||||||
|
|
||||||
LevelFeedbackLevelSchema = c.object {required: ['original', 'majorVersion']}, {
|
LevelFeedbackLevelSchema = c.object {required: ['original', 'majorVersion']}, {
|
||||||
original: c.objectId({})
|
original: c.objectId({})
|
||||||
majorVersion: {type: 'integer', minimum: 0, default: 0}}
|
majorVersion: {type: 'integer', minimum: 0 }}
|
||||||
|
|
||||||
LevelFeedbackSchema = c.object {
|
LevelFeedbackSchema = c.object {
|
||||||
title: 'Feedback'
|
title: 'Feedback'
|
||||||
|
|
|
@ -18,11 +18,14 @@ LevelSessionLevelSchema = c.object {required: ['original', 'majorVersion'], link
|
||||||
majorVersion:
|
majorVersion:
|
||||||
type: 'integer'
|
type: 'integer'
|
||||||
minimum: 0
|
minimum: 0
|
||||||
default: 0
|
|
||||||
|
|
||||||
LevelSessionSchema = c.object
|
LevelSessionSchema = c.object
|
||||||
title: 'Session'
|
title: 'Session'
|
||||||
description: 'A single session for a given level.'
|
description: 'A single session for a given level.'
|
||||||
|
default:
|
||||||
|
codeLanguage: 'javascript'
|
||||||
|
submittedCodeLanguage: 'javascript'
|
||||||
|
playtime: 0
|
||||||
|
|
||||||
_.extend LevelSessionSchema.properties,
|
_.extend LevelSessionSchema.properties,
|
||||||
# denormalization
|
# denormalization
|
||||||
|
@ -123,12 +126,10 @@ _.extend LevelSessionSchema.properties,
|
||||||
|
|
||||||
codeLanguage:
|
codeLanguage:
|
||||||
type: 'string'
|
type: 'string'
|
||||||
default: 'javascript'
|
|
||||||
|
|
||||||
playtime:
|
playtime:
|
||||||
type: 'number'
|
type: 'number'
|
||||||
title: 'Playtime'
|
title: 'Playtime'
|
||||||
default: 0
|
|
||||||
description: 'The total playtime on this session'
|
description: 'The total playtime on this session'
|
||||||
|
|
||||||
teamSpells:
|
teamSpells:
|
||||||
|
@ -167,7 +168,6 @@ _.extend LevelSessionSchema.properties,
|
||||||
|
|
||||||
submittedCodeLanguage:
|
submittedCodeLanguage:
|
||||||
type: 'string'
|
type: 'string'
|
||||||
default: 'javascript'
|
|
||||||
|
|
||||||
transpiledCode:
|
transpiledCode:
|
||||||
type: 'object'
|
type: 'object'
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Jitter extends System
|
||||||
PropertyDocumentationSchema = c.object {
|
PropertyDocumentationSchema = c.object {
|
||||||
title: 'Property Documentation'
|
title: 'Property Documentation'
|
||||||
description: 'Documentation entry for a property this System will add to its Thang which other Systems might want to also use.'
|
description: 'Documentation entry for a property this System will add to its Thang which other Systems might want to also use.'
|
||||||
'default':
|
default:
|
||||||
name: 'foo'
|
name: 'foo'
|
||||||
type: 'object'
|
type: 'object'
|
||||||
description: 'This System provides a "foo" property to satisfy all one\'s foobar needs. Use it wisely.'
|
description: 'This System provides a "foo" property to satisfy all one\'s foobar needs. Use it wisely.'
|
||||||
|
@ -36,9 +36,6 @@ PropertyDocumentationSchema = c.object {
|
||||||
DependencySchema = c.object {
|
DependencySchema = c.object {
|
||||||
title: 'System Dependency'
|
title: 'System Dependency'
|
||||||
description: 'A System upon which this System depends.'
|
description: 'A System upon which this System depends.'
|
||||||
'default':
|
|
||||||
#original: ?
|
|
||||||
majorVersion: 0
|
|
||||||
required: ['original', 'majorVersion']
|
required: ['original', 'majorVersion']
|
||||||
format: 'latest-version-reference'
|
format: 'latest-version-reference'
|
||||||
links: [{rel: 'db', href: '/db/level.system/{(original)}/version/{(majorVersion)}'}]
|
links: [{rel: 'db', href: '/db/level.system/{(original)}/version/{(majorVersion)}'}]
|
||||||
|
@ -54,7 +51,7 @@ LevelSystemSchema = c.object {
|
||||||
title: 'System'
|
title: 'System'
|
||||||
description: 'A System which can affect Level behavior.'
|
description: 'A System which can affect Level behavior.'
|
||||||
required: ['name', 'description', 'code', 'dependencies', 'propertyDocumentation', 'codeLanguage']
|
required: ['name', 'description', 'code', 'dependencies', 'propertyDocumentation', 'codeLanguage']
|
||||||
'default':
|
default:
|
||||||
name: 'JitterSystem'
|
name: 'JitterSystem'
|
||||||
description: 'This System makes all idle, movable Thangs jitter around.'
|
description: 'This System makes all idle, movable Thangs jitter around.'
|
||||||
code: jitterSystemCode
|
code: jitterSystemCode
|
||||||
|
@ -70,7 +67,6 @@ _.extend LevelSystemSchema.properties,
|
||||||
description: 'A short explanation of what this System does.'
|
description: 'A short explanation of what this System does.'
|
||||||
type: 'string'
|
type: 'string'
|
||||||
maxLength: 2000
|
maxLength: 2000
|
||||||
'default': 'This System doesn\'t do anything yet.'
|
|
||||||
codeLanguage:
|
codeLanguage:
|
||||||
type: 'string'
|
type: 'string'
|
||||||
title: 'Language'
|
title: 'Language'
|
||||||
|
@ -79,7 +75,6 @@ _.extend LevelSystemSchema.properties,
|
||||||
code:
|
code:
|
||||||
title: 'Code'
|
title: 'Code'
|
||||||
description: 'The code for this System, as a CoffeeScript class. TODO: add link to documentation for how to write these.'
|
description: 'The code for this System, as a CoffeeScript class. TODO: add link to documentation for how to write these.'
|
||||||
'default': jitterSystemCode
|
|
||||||
type: 'string'
|
type: 'string'
|
||||||
format: 'coffee'
|
format: 'coffee'
|
||||||
js:
|
js:
|
||||||
|
@ -87,14 +82,13 @@ _.extend LevelSystemSchema.properties,
|
||||||
description: 'The transpiled JavaScript code for this System'
|
description: 'The transpiled JavaScript code for this System'
|
||||||
type: 'string'
|
type: 'string'
|
||||||
format: 'hidden'
|
format: 'hidden'
|
||||||
dependencies: c.array {title: 'Dependencies', description: 'An array of Systems upon which this System depends.', 'default': [], uniqueItems: true}, DependencySchema
|
dependencies: c.array {title: 'Dependencies', description: 'An array of Systems upon which this System depends.', uniqueItems: true}, DependencySchema
|
||||||
propertyDocumentation: c.array {title: 'Property Documentation', description: 'An array of documentation entries for each notable property this System will add to its Level which other Systems might want to also use.', 'default': []}, PropertyDocumentationSchema
|
propertyDocumentation: c.array {title: 'Property Documentation', description: 'An array of documentation entries for each notable property this System will add to its Level which other Systems might want to also use.'}, PropertyDocumentationSchema
|
||||||
configSchema: _.extend metaschema, {title: 'Configuration Schema', description: 'A schema for validating the arguments that can be passed to this System as configuration.', default: {type: 'object', additionalProperties: false}}
|
configSchema: _.extend metaschema, {title: 'Configuration Schema', description: 'A schema for validating the arguments that can be passed to this System as configuration.', default: {type: 'object', additionalProperties: false}}
|
||||||
official:
|
official:
|
||||||
type: 'boolean'
|
type: 'boolean'
|
||||||
title: 'Official'
|
title: 'Official'
|
||||||
description: 'Whether this is an official CodeCombat System.'
|
description: 'Whether this is an official CodeCombat System.'
|
||||||
'default': false
|
|
||||||
|
|
||||||
c.extendBasicProperties LevelSystemSchema, 'level.system'
|
c.extendBasicProperties LevelSystemSchema, 'level.system'
|
||||||
c.extendSearchableProperties LevelSystemSchema
|
c.extendSearchableProperties LevelSystemSchema
|
||||||
|
|
|
@ -5,7 +5,7 @@ module.exports = ThangComponentSchema = c.object {
|
||||||
description: 'Configuration for a Component that this Thang uses.'
|
description: 'Configuration for a Component that this Thang uses.'
|
||||||
format: 'component-reference'
|
format: 'component-reference'
|
||||||
required: ['original', 'majorVersion']
|
required: ['original', 'majorVersion']
|
||||||
'default':
|
default:
|
||||||
majorVersion: 0
|
majorVersion: 0
|
||||||
config: {}
|
config: {}
|
||||||
links: [{rel: 'db', href: '/db/level.component/{(original)}/version/{(majorVersion)}'}]
|
links: [{rel: 'db', href: '/db/level.component/{(original)}/version/{(majorVersion)}'}]
|
||||||
|
@ -17,5 +17,4 @@ module.exports = ThangComponentSchema = c.object {
|
||||||
description: 'Which major version of the Component is being used.'
|
description: 'Which major version of the Component is being used.'
|
||||||
type: 'integer'
|
type: 'integer'
|
||||||
minimum: 0
|
minimum: 0
|
||||||
default: 0
|
|
||||||
format: 'hidden'
|
format: 'hidden'
|
||||||
|
|
Reference in a new issue