@01-edu/shared 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/attrs-defs.js +1 -1
- package/definitions-checker.js +11 -3
- package/object-structure.ts +60 -0
- package/onboarding.js +0 -14
- package/package.json +3 -2
- package/toolbox.js +0 -43
package/attrs-defs.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
numTime,
|
|
9
9
|
} from './event-utils.js'
|
|
10
10
|
import { flatGraphContents, getCoreOfSattelite, limitations } from './graph.js'
|
|
11
|
-
import { onboardingTypes } from './
|
|
11
|
+
import { onboardingTypes } from './object-structure.ts'
|
|
12
12
|
import { getObjectFromRelativePath } from './path.js'
|
|
13
13
|
import { gamesScoring } from './score.js'
|
|
14
14
|
import { hasRequiredSkills, skillsSet } from './skill-definitions.js'
|
package/definitions-checker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { attributes, relationAttributes } from './attrs.js'
|
|
2
|
-
import { childTypes, objectTypes } from './
|
|
2
|
+
import { childTypes, objectTypes } from './object-structure.ts'
|
|
3
3
|
|
|
4
4
|
const normalize = str =>
|
|
5
5
|
str
|
|
@@ -9,14 +9,22 @@ const normalize = str =>
|
|
|
9
9
|
.replaceAll(' ', '-')
|
|
10
10
|
|
|
11
11
|
const assertDef = def => {
|
|
12
|
-
const {
|
|
13
|
-
|
|
12
|
+
const {
|
|
13
|
+
type,
|
|
14
|
+
name,
|
|
15
|
+
attrs,
|
|
16
|
+
children: _children,
|
|
17
|
+
childrenAttrs,
|
|
18
|
+
referencePath: _referencePath,
|
|
19
|
+
...rest
|
|
20
|
+
} = def
|
|
14
21
|
const [extra] = Object.keys(rest)
|
|
15
22
|
if (extra) {
|
|
16
23
|
throw Error(
|
|
17
24
|
`Unexpected property ${extra}, did you mean to define an attribute ?`,
|
|
18
25
|
)
|
|
19
26
|
}
|
|
27
|
+
if (type === 'campus') throw Error(`Campuses can't be defined in definitions`)
|
|
20
28
|
if (!objectTypes.has(type)) throw Error(`Invalid type property`)
|
|
21
29
|
if (!name || typeof name !== 'string') throw Error(`Invalid name property`)
|
|
22
30
|
if (!attrs || typeof attrs !== 'object' || Array.isArray(attrs)) {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export const onboardingTypes = new Set([
|
|
2
|
+
'onboarding',
|
|
3
|
+
'piscine-registration',
|
|
4
|
+
'interview',
|
|
5
|
+
'games',
|
|
6
|
+
'administration',
|
|
7
|
+
'module-registration',
|
|
8
|
+
'form-step',
|
|
9
|
+
'sign-step',
|
|
10
|
+
'upload-step',
|
|
11
|
+
'contact-validation-step',
|
|
12
|
+
'avatar-step',
|
|
13
|
+
] as const)
|
|
14
|
+
|
|
15
|
+
type Extract<T> = [T] extends [Set<infer V>] ? V : never
|
|
16
|
+
|
|
17
|
+
export const objectTypes = new Set([
|
|
18
|
+
'module',
|
|
19
|
+
'piscine',
|
|
20
|
+
'exam',
|
|
21
|
+
'raid',
|
|
22
|
+
'quest',
|
|
23
|
+
'exercise',
|
|
24
|
+
'project',
|
|
25
|
+
'signup',
|
|
26
|
+
'campus',
|
|
27
|
+
...onboardingTypes,
|
|
28
|
+
] as const)
|
|
29
|
+
|
|
30
|
+
export type ObjectType = Extract<typeof objectTypes>
|
|
31
|
+
export const childTypes = {
|
|
32
|
+
campus: ['signup', 'onboarding', 'piscine', 'module'],
|
|
33
|
+
signup: [
|
|
34
|
+
'form-step',
|
|
35
|
+
'sign-step',
|
|
36
|
+
'upload-step',
|
|
37
|
+
'contact-validation-step',
|
|
38
|
+
'avatar-step',
|
|
39
|
+
],
|
|
40
|
+
onboarding: [
|
|
41
|
+
'games',
|
|
42
|
+
'administration',
|
|
43
|
+
'interview',
|
|
44
|
+
'piscine-registration',
|
|
45
|
+
'module-registration',
|
|
46
|
+
],
|
|
47
|
+
administration: [
|
|
48
|
+
'form-step',
|
|
49
|
+
'sign-step',
|
|
50
|
+
'upload-step',
|
|
51
|
+
'contact-validation-step',
|
|
52
|
+
'avatar-step',
|
|
53
|
+
],
|
|
54
|
+
piscine: ['quest', 'exam', 'raid', 'project'],
|
|
55
|
+
exam: ['exercise'],
|
|
56
|
+
quest: ['exercise'],
|
|
57
|
+
module: ['project', 'piscine', 'exam'],
|
|
58
|
+
} as const satisfies Partial<Record<ObjectType, ObjectType[]>>
|
|
59
|
+
|
|
60
|
+
export type ChildTypes = typeof childTypes
|
package/onboarding.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
export const onboardingTypes = new Set([
|
|
2
|
-
'onboarding',
|
|
3
|
-
'piscine-registration',
|
|
4
|
-
'interview',
|
|
5
|
-
'games',
|
|
6
|
-
'administration',
|
|
7
|
-
'module-registration',
|
|
8
|
-
'form-step',
|
|
9
|
-
'sign-step',
|
|
10
|
-
'upload-step',
|
|
11
|
-
'contact-validation-step',
|
|
12
|
-
'avatar-step',
|
|
13
|
-
])
|
|
14
|
-
|
|
15
1
|
export const prevValidated = (key, object) => {
|
|
16
2
|
const { prev } = (
|
|
17
3
|
object.parent.type !== 'onboarding' ? object : object.parent
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@01-edu/shared",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"./programming-languages.js",
|
|
20
20
|
"./score.js",
|
|
21
21
|
"./skill-definitions.js",
|
|
22
|
-
"./toolbox.js"
|
|
22
|
+
"./toolbox.js",
|
|
23
|
+
"./object-structure.ts"
|
|
23
24
|
],
|
|
24
25
|
"license": "Fair",
|
|
25
26
|
"bin": {
|
package/toolbox.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isFinished } from './event-utils.js'
|
|
2
|
-
import { onboardingTypes } from './onboarding.js'
|
|
3
2
|
|
|
4
3
|
const keyCodes = {
|
|
5
4
|
13: ({ save, value, event, allowLineBreak }) => {
|
|
@@ -11,48 +10,6 @@ const keyCodes = {
|
|
|
11
10
|
event.metaKey || event.ctrlKey ? save(value) : false, // cmd+s
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
export const contentObjects = new Set([
|
|
15
|
-
'module',
|
|
16
|
-
'piscine',
|
|
17
|
-
'exam',
|
|
18
|
-
'raid',
|
|
19
|
-
'quest',
|
|
20
|
-
'exercise',
|
|
21
|
-
'project',
|
|
22
|
-
'signup',
|
|
23
|
-
])
|
|
24
|
-
|
|
25
|
-
export const objectTypes = new Set([...contentObjects, ...onboardingTypes])
|
|
26
|
-
|
|
27
|
-
export const childTypes = {
|
|
28
|
-
campus: ['signup', 'onboarding', 'piscine', 'module'],
|
|
29
|
-
signup: [
|
|
30
|
-
'form-step',
|
|
31
|
-
'sign-step',
|
|
32
|
-
'upload-step',
|
|
33
|
-
'contact-validation-step',
|
|
34
|
-
'avatar-step',
|
|
35
|
-
],
|
|
36
|
-
onboarding: [
|
|
37
|
-
'games',
|
|
38
|
-
'administration',
|
|
39
|
-
'interview',
|
|
40
|
-
'piscine-registration',
|
|
41
|
-
'module-registration',
|
|
42
|
-
],
|
|
43
|
-
administration: [
|
|
44
|
-
'form-step',
|
|
45
|
-
'sign-step',
|
|
46
|
-
'upload-step',
|
|
47
|
-
'contact-validation-step',
|
|
48
|
-
'avatar-step',
|
|
49
|
-
],
|
|
50
|
-
piscine: ['quest', 'exam', 'raid', 'project'],
|
|
51
|
-
exam: ['exercise'],
|
|
52
|
-
quest: ['exercise'],
|
|
53
|
-
module: ['project', 'piscine', 'exam'],
|
|
54
|
-
}
|
|
55
|
-
|
|
56
13
|
export const handleKeyDownEvent = args => {
|
|
57
14
|
const handler = keyCodes[args.event.keyCode]
|
|
58
15
|
|