@shaxpir/duiduidui-models 1.8.0 → 1.8.2
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.
|
@@ -37,7 +37,16 @@ export interface DifficultyCondition extends BaseCondition {
|
|
|
37
37
|
min?: number;
|
|
38
38
|
max?: number;
|
|
39
39
|
}
|
|
40
|
-
export
|
|
40
|
+
export interface HasTermCondition extends BaseCondition {
|
|
41
|
+
type: 'has_term';
|
|
42
|
+
value: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface ComponentCondition extends BaseCondition {
|
|
45
|
+
type: 'component';
|
|
46
|
+
components: string[];
|
|
47
|
+
mode: 'any' | 'all';
|
|
48
|
+
}
|
|
49
|
+
export type AnyCondition = TagCondition | GradeCondition | ThetaCondition | TemporalCondition | CountCondition | StarredCondition | DifficultyCondition | HasTermCondition | ComponentCondition;
|
|
41
50
|
export interface ConditionFilters {
|
|
42
51
|
all?: AnyCondition[];
|
|
43
52
|
any?: AnyCondition[];
|
|
@@ -72,6 +81,11 @@ export declare const Condition: {
|
|
|
72
81
|
intermediate: () => DifficultyCondition;
|
|
73
82
|
advanced: () => DifficultyCondition;
|
|
74
83
|
expert: () => DifficultyCondition;
|
|
84
|
+
hasTerm: () => HasTermCondition;
|
|
85
|
+
noTerm: () => HasTermCondition;
|
|
86
|
+
hasComponent: (component: string) => ComponentCondition;
|
|
87
|
+
hasAnyComponent: (components: string[]) => ComponentCondition;
|
|
88
|
+
hasAllComponents: (components: string[]) => ComponentCondition;
|
|
75
89
|
/**
|
|
76
90
|
* Check if starred condition is required (in 'all' section)
|
|
77
91
|
*/
|
package/dist/models/Condition.js
CHANGED
|
@@ -38,6 +38,13 @@ exports.Condition = {
|
|
|
38
38
|
intermediate: () => ({ type: 'difficulty', min: 500, max: 1500 }), // Medium
|
|
39
39
|
advanced: () => ({ type: 'difficulty', min: 1500, max: 3000 }), // Hard
|
|
40
40
|
expert: () => ({ type: 'difficulty', min: 3000 }), // Very hard
|
|
41
|
+
// HasTerm conditions
|
|
42
|
+
hasTerm: () => ({ type: 'has_term', value: true }),
|
|
43
|
+
noTerm: () => ({ type: 'has_term', value: false }),
|
|
44
|
+
// Component conditions
|
|
45
|
+
hasComponent: (component) => ({ type: 'component', components: [component], mode: 'any' }),
|
|
46
|
+
hasAnyComponent: (components) => ({ type: 'component', components, mode: 'any' }),
|
|
47
|
+
hasAllComponents: (components) => ({ type: 'component', components, mode: 'all' }),
|
|
41
48
|
// Helper methods to check if conditions are present in filters
|
|
42
49
|
/**
|
|
43
50
|
* Check if starred condition is required (in 'all' section)
|
|
@@ -129,6 +136,30 @@ exports.Condition = {
|
|
|
129
136
|
if (allGrades.length > 1) {
|
|
130
137
|
errors.push(`Cannot require multiple grades: ${allGrades.join(', ')} - an item can only have one grade`);
|
|
131
138
|
}
|
|
139
|
+
// Check for contradictory has_term conditions
|
|
140
|
+
const requiresTerm = filters.all?.some(c => c.type === 'has_term' && c.value === true);
|
|
141
|
+
const excludesTerm = filters.all?.some(c => c.type === 'has_term' && c.value === false);
|
|
142
|
+
if (requiresTerm && excludesTerm) {
|
|
143
|
+
errors.push('Cannot require both has_term and no_term');
|
|
144
|
+
}
|
|
145
|
+
// Check for implicit term requirements conflicting with no_term
|
|
146
|
+
const termDependentTypes = ['grade', 'theta', 'starred', 'temporal', 'count'];
|
|
147
|
+
const hasTermDependentInAll = filters.all?.some(c => termDependentTypes.includes(c.type));
|
|
148
|
+
const hasTermDependentInAny = filters.any?.some(c => termDependentTypes.includes(c.type));
|
|
149
|
+
if (excludesTerm && hasTermDependentInAll) {
|
|
150
|
+
const conflictingTypes = filters.all
|
|
151
|
+
?.filter(c => termDependentTypes.includes(c.type))
|
|
152
|
+
.map(c => c.type)
|
|
153
|
+
.join(', ');
|
|
154
|
+
errors.push(`Conditions [${conflictingTypes}] require a term record, but has_term is false`);
|
|
155
|
+
}
|
|
156
|
+
if (excludesTerm && hasTermDependentInAny) {
|
|
157
|
+
const conflictingTypes = filters.any
|
|
158
|
+
?.filter(c => termDependentTypes.includes(c.type))
|
|
159
|
+
.map(c => c.type)
|
|
160
|
+
.join(', ');
|
|
161
|
+
errors.push(`Conditions [${conflictingTypes}] in 'any' section require a term record, but has_term is false`);
|
|
162
|
+
}
|
|
132
163
|
return errors;
|
|
133
164
|
},
|
|
134
165
|
// Backward compatibility aliases (deprecated - use requiresStarred/allowsStarred/excludesStarred instead)
|
|
@@ -74,7 +74,7 @@ class SkillLevelModel {
|
|
|
74
74
|
const z = confidence === 0.95 ? 1.96 : confidence === 0.99 ? 2.58 : 1.96;
|
|
75
75
|
return {
|
|
76
76
|
lower: Math.max(0, rating - z * ratingDeviation),
|
|
77
|
-
upper: rating + z * ratingDeviation
|
|
77
|
+
upper: Math.max(0, rating + z * ratingDeviation)
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
/**
|