2014-04-12 13:51:02 -04:00
|
|
|
c = require './../schemas'
|
2014-04-08 22:26:19 -04:00
|
|
|
|
|
|
|
patchables = ['level', 'thang_type', 'level_system', 'level_component', 'article']
|
2014-06-30 22:16:26 -04:00
|
|
|
|
|
|
|
PatchSchema = c.object({title: 'Patch', required: ['target', 'delta', 'commitMessage']}, {
|
|
|
|
delta: {title: 'Delta', type: ['array', 'object']}
|
2014-04-10 16:09:44 -04:00
|
|
|
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}
|
2014-04-08 22:26:19 -04:00
|
|
|
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}
|
2014-04-08 22:26:19 -04:00
|
|
|
})
|
2014-06-27 15:30:31 -04:00
|
|
|
|
2014-08-07 16:03:00 -04:00
|
|
|
wasPending: type: 'boolean'
|
|
|
|
newlyAccepted: type: 'boolean'
|
2014-04-08 22:26:19 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
c.extendBasicProperties(PatchSchema, 'patch')
|
|
|
|
|
|
|
|
module.exports = PatchSchema
|