@valentine-efagene/qshelter-common 2.0.121 → 2.0.123

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.
@@ -34,3 +34,41 @@ export interface CompoundCondition {
34
34
  * A step condition can be either a simple condition or a compound condition.
35
35
  */
36
36
  export type StepCondition = SimpleCondition | CompoundCondition;
37
+ /**
38
+ * A single scoring rule that defines a condition and its associated score.
39
+ * Used in QuestionnairePlanQuestion.scoringRules to score answers.
40
+ *
41
+ * Example:
42
+ * ```typescript
43
+ * // Score 100 if age <= 55
44
+ * { operator: ConditionOperator.LESS_THAN_OR_EQUAL, value: 55, score: 100 }
45
+ *
46
+ * // Score 80 if income >= 2000000
47
+ * { operator: ConditionOperator.GREATER_THAN_OR_EQUAL, value: 2000000, score: 80 }
48
+ * ```
49
+ */
50
+ export interface ScoringRule {
51
+ /** The comparison operator for the condition */
52
+ operator: ConditionOperator;
53
+ /** The value to compare against */
54
+ value: number;
55
+ /** The score to assign if the condition is met */
56
+ score: number;
57
+ }
58
+ /**
59
+ * Array of scoring rules evaluated in order.
60
+ * First matching rule's score is used.
61
+ * Rules should be ordered from most to least restrictive.
62
+ *
63
+ * Example:
64
+ * ```typescript
65
+ * // Income scoring: first match wins
66
+ * [
67
+ * { operator: ConditionOperator.GREATER_THAN_OR_EQUAL, value: 3000000, score: 100 },
68
+ * { operator: ConditionOperator.GREATER_THAN_OR_EQUAL, value: 2000000, score: 80 },
69
+ * { operator: ConditionOperator.GREATER_THAN_OR_EQUAL, value: 1000000, score: 50 },
70
+ * { operator: ConditionOperator.LESS_THAN, value: 1000000, score: 0 },
71
+ * ]
72
+ * ```
73
+ */
74
+ export type ScoringRules = ScoringRule[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valentine-efagene/qshelter-common",
3
- "version": "2.0.121",
3
+ "version": "2.0.123",
4
4
  "description": "Shared database schemas and utilities for QShelter services",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -0,0 +1,8 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to alter the column `category` on the `questionnaire_plan_questions` table. The data in that column could be lost. The data in that column will be cast from `VarChar(191)` to `Enum(EnumId(11))`.
5
+
6
+ */
7
+ -- AlterTable
8
+ ALTER TABLE `questionnaire_plan_questions` MODIFY `category` ENUM('ELIGIBILITY', 'EMPLOYMENT', 'INCOME', 'AFFORDABILITY', 'EXPENSES', 'APPLICATION_TYPE', 'PERSONAL', 'PREFERENCES', 'PROPERTY', 'CREDIT', 'ASSETS', 'CUSTOM') NULL;