codecombat/app/schemas/models/patch.coffee

32 lines
1.2 KiB
CoffeeScript
Raw Normal View History

c = require './../schemas'
patchables = ['level', 'thang_type', 'level_system', 'level_component', 'article', 'achievement', 'campaign']
2014-06-30 22:16:26 -04:00
PatchSchema = c.object({title: 'Patch', required: ['target', 'delta', 'commitMessage']}, {
delta: {title: 'Delta', type: ['array', 'object']}
commitMessage: c.shortString({maxLength: 500, minLength: 1})
2014-06-30 22:16:26 -04:00
creator: c.objectId(links: [{rel: 'extra', href: '/db/user/{($)}'}])
2014-08-15 13:35:35 -04:00
acceptor: c.objectId(links: [{rel: 'extra', href: '/db/user/{($)}'}])
2014-06-30 22:16:26 -04:00
created: c.date({title: 'Created', readOnly: true})
status: {enum: ['pending', 'accepted', 'rejected', 'withdrawn']}
target: c.object({title: 'Target', required: ['collection', 'id']}, {
collection: {enum: patchables}
id: c.objectId(title: 'Target ID') # search by this if not versioned
# if target is versioned, want to know that info too
original: c.objectId(title: 'Target Original') # search by this if versioned
version:
properties:
2014-06-30 22:16:26 -04:00
major: {type: 'number', minimum: 0}
minor: {type: 'number', minimum: 0}
})
wasPending: type: 'boolean'
newlyAccepted: type: 'boolean'
})
c.extendBasicProperties(PatchSchema, 'patch')
module.exports = PatchSchema