* feat: use legacy flag chore: reorder challenges fix: linter revert: server change feat: unblock new editor fix: proper order fix: 0-based order fix: broke the order feat: move tribute certification to its own block feat: split the old projects block into 4 fix: put all blocks in order chore: add intro text refactor: use block, not blockName in query fix: project progress indicator * fix: reorder new challenges/certs * fix: reorder legacy challenges * fix: reintroduce legacy certs * feat: add showNewCurriculum flag to env * chore: forgot sample.env * feat: use feature flag for display * fix: rename meta + dirs to match new blocks * fix: add new blocks to help-category-map * fix: update completion-modal for new GQL schema * test: duplicate title/id errors -> warnings * fix: update completion-modal to new GQL schema Mk2 * chore: re-order metas (again) * fix: revert super-block-intro changes The intro needs to show both legacy and new content. We need to decide which pages are created, rather than than what a page shows when rendered. * feat: move upcoming curriculum into own superblock * fix: handle one certification with two superBlocks * fix: remove duplicated intros * fix: remove duplicate projects from /settings * fix: drop 'two' from Responsive Web Design Two * chore: rename slug suffix from two to v2 * feat: control display of new curriculum * feat: control project paths shown on /settings * fix: use new project order for /settings This does mean that /settings will change before the release, but I don't think it's serious. All the projects are there, just not in the legacy order. * fix: claim/show cert button * chore: remove isLegacy Since we have legacy superblocks, we don't currently need individual blocks to be legacy * test: fix utils.test * fix: verifyCanClaim needs certification If Shaun removes the cert claim cards, maybe we can remove this entirely * fix: add hasEditableBoundaries flags where needed * chore: remove isUpcomingChange * chore: v2 -> 22 Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
125 lines
3.8 KiB
JavaScript
125 lines
3.8 KiB
JavaScript
const Joi = require('joi');
|
|
Joi.objectId = require('joi-objectid')(Joi);
|
|
|
|
const { challengeTypes } = require('../../client/utils/challenge-types');
|
|
|
|
const slugRE = new RegExp('^[a-z0-9-]+$');
|
|
|
|
const fileJoi = Joi.object().keys({
|
|
fileKey: Joi.string(),
|
|
ext: Joi.string(),
|
|
name: Joi.string(),
|
|
editableRegionBoundaries: [Joi.array().items(Joi.number())],
|
|
path: Joi.string(),
|
|
error: Joi.valid(null),
|
|
head: Joi.string().allow(''),
|
|
tail: Joi.string().allow(''),
|
|
seed: Joi.string().allow(''),
|
|
contents: Joi.string().allow(''),
|
|
id: Joi.string().allow(''),
|
|
history: [Joi.array().items(Joi.string().allow('')), Joi.string().allow('')]
|
|
});
|
|
|
|
const schema = Joi.object()
|
|
.keys({
|
|
block: Joi.string().regex(slugRE),
|
|
blockId: Joi.objectId(),
|
|
challengeOrder: Joi.number(),
|
|
removeComments: Joi.bool(),
|
|
certification: Joi.string().regex(slugRE),
|
|
challengeType: Joi.number().min(0).max(12).required(),
|
|
checksum: Joi.number(),
|
|
// __commentCounts is only used to test the comment replacement
|
|
__commentCounts: Joi.object(),
|
|
// TODO: require this only for normal challenges, not certs
|
|
dashedName: Joi.string().regex(slugRE),
|
|
description: Joi.when('challengeType', {
|
|
is: [challengeTypes.step, challengeTypes.video, challengeTypes.codeally],
|
|
then: Joi.string().allow(''),
|
|
otherwise: Joi.string().required()
|
|
}),
|
|
challengeFiles: Joi.array().items(fileJoi),
|
|
guideUrl: Joi.string().uri({ scheme: 'https' }),
|
|
hasEditableBoundaries: Joi.boolean(),
|
|
helpCategory: Joi.valid(
|
|
'JavaScript',
|
|
'HTML-CSS',
|
|
'Python',
|
|
'Relational Databases'
|
|
),
|
|
videoUrl: Joi.string().allow(''),
|
|
forumTopicId: Joi.number(),
|
|
id: Joi.objectId().required(),
|
|
instructions: Joi.string().allow(''),
|
|
isComingSoon: Joi.bool(),
|
|
isLocked: Joi.bool(),
|
|
isPrivate: Joi.bool(),
|
|
notes: Joi.string().allow(''),
|
|
order: Joi.number(),
|
|
// video challenges only:
|
|
videoId: Joi.when('challengeType', {
|
|
is: challengeTypes.video,
|
|
then: Joi.string().required()
|
|
}),
|
|
videoLocaleIds: Joi.when('challengeType', {
|
|
is: challengeTypes.video,
|
|
then: Joi.object().keys({
|
|
espanol: Joi.string(),
|
|
italian: Joi.string(),
|
|
portuguese: Joi.string()
|
|
})
|
|
}),
|
|
bilibiliIds: Joi.when('challengeType', {
|
|
is: challengeTypes.video,
|
|
then: Joi.object().keys({
|
|
aid: Joi.number().required(),
|
|
bvid: Joi.string().required(),
|
|
cid: Joi.number().required()
|
|
})
|
|
}),
|
|
question: Joi.object().keys({
|
|
text: Joi.string().required(),
|
|
answers: Joi.array().items(Joi.string()).required(),
|
|
solution: Joi.number().required()
|
|
}),
|
|
required: Joi.array().items(
|
|
Joi.object().keys({
|
|
link: Joi.string(),
|
|
raw: Joi.bool(),
|
|
src: Joi.string(),
|
|
crossDomain: Joi.bool()
|
|
})
|
|
),
|
|
solutions: Joi.array().items(Joi.array().items(fileJoi)),
|
|
superBlock: Joi.string().regex(slugRE),
|
|
superOrder: Joi.number(),
|
|
suborder: Joi.number(),
|
|
tests: Joi.array().items(
|
|
// public challenges
|
|
Joi.object().keys({
|
|
id: Joi.string().allow(''),
|
|
text: Joi.string().required(),
|
|
testString: Joi.string().allow('').required()
|
|
}),
|
|
// our tests used in certification verification
|
|
Joi.object().keys({
|
|
id: Joi.string().required(),
|
|
title: Joi.string().required()
|
|
})
|
|
),
|
|
template: Joi.string().allow(''),
|
|
time: Joi.string().allow(''),
|
|
title: Joi.string().required(),
|
|
translationPending: Joi.bool().required(),
|
|
url: Joi.when('challengeType', {
|
|
is: challengeTypes.codeally,
|
|
then: Joi.string().required()
|
|
}),
|
|
usesMultifileEditor: Joi.boolean()
|
|
})
|
|
.xor('helpCategory', 'isPrivate');
|
|
|
|
exports.challengeSchemaValidator = () => {
|
|
return challenge => schema.validate(challenge);
|
|
};
|