heartraite 1.0.174 → 1.0.176

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.
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Discovery Questions (DQ) - Client-Facing Types
3
+ *
4
+ * IMPORTANT: Only types needed by the frontend should be here.
5
+ * Internal backend details (psychometrics, scoring, etc.) belong in backend only.
6
+ */
7
+ import { Locale } from "../enum/localization.enum";
8
+ /**
9
+ * DQ locale codes for question content
10
+ * Currently supports Swedish and Danish
11
+ */
12
+ export type DQLocaleCode = "sv" | "da";
13
+ export type QuestionType = "scale" | "multiple_choice" | "multi_select" | "ranking";
14
+ /**
15
+ * Localized text content
16
+ */
17
+ export type LocalizedString = Record<DQLocaleCode, string>;
18
+ /**
19
+ * Configuration for scale-type questions (slider UI)
20
+ */
21
+ export interface ScaleConfig {
22
+ min: number;
23
+ max: number;
24
+ step: number;
25
+ minLabel: string;
26
+ maxLabel: string;
27
+ midLabel?: string;
28
+ }
29
+ /**
30
+ * Option for multiple choice or multi-select questions
31
+ */
32
+ export interface QuestionOption {
33
+ optionId: string;
34
+ text: string;
35
+ imageUrl?: string;
36
+ displayOrder: number;
37
+ }
38
+ /**
39
+ * Item for ranking questions
40
+ */
41
+ export interface RankingItem {
42
+ itemId: string;
43
+ text: string;
44
+ }
45
+ /**
46
+ * Configuration for ranking-type questions
47
+ */
48
+ export interface RankingConfig {
49
+ items: RankingItem[];
50
+ requiredRankCount: number;
51
+ }
52
+ /**
53
+ * Configuration for open-ended text questions
54
+ */
55
+ export interface OpenEndedConfig {
56
+ maxLength: number;
57
+ minLength: number;
58
+ placeholder: string;
59
+ }
60
+ /**
61
+ * Question data sent to client
62
+ * Contains only what's needed to render the UI
63
+ */
64
+ export interface DQQuestion {
65
+ questionId: string;
66
+ sequencePosition: number;
67
+ title: string;
68
+ description?: string;
69
+ reflectionPrompt?: string;
70
+ type: QuestionType;
71
+ scaleConfig?: ScaleConfig;
72
+ options?: QuestionOption[];
73
+ rankingConfig?: RankingConfig;
74
+ openEndedConfig?: OpenEndedConfig;
75
+ }
76
+ /**
77
+ * Request for POST /dq/get-question endpoint
78
+ */
79
+ export interface GetQuestionRequest {
80
+ /** User's preferred locale for question content (optional, defaults to sv_SE) */
81
+ locale?: Locale;
82
+ }
83
+ /**
84
+ * User's discovery progress (streaks, counts, etc.)
85
+ */
86
+ export interface DiscoveryProgress {
87
+ /** Current consecutive days streak */
88
+ currentStreak: number;
89
+ /** Longest streak ever achieved */
90
+ longestStreak: number;
91
+ /** Total questions answered (not skipped) */
92
+ answeredCount: number;
93
+ /** Total questions skipped */
94
+ skippedCount: number;
95
+ /** ISO timestamp of last answered question (null if never answered) */
96
+ lastAnsweredAt: string | null;
97
+ }
98
+ /**
99
+ * Response for POST /dq/get-question endpoint
100
+ * Provides question data along with quota information
101
+ */
102
+ export interface GetQuestionResponse {
103
+ /** The question to display, or null if quota exhausted or no more questions */
104
+ question: DQQuestion | null;
105
+ /** Whether the user has exhausted their daily quota */
106
+ quotaExhausted: boolean;
107
+ /** ISO timestamp when quota resets (next midnight UTC), only present when quota exhausted */
108
+ quotaResetsAt?: string;
109
+ /** Number of questions remaining for today */
110
+ questionsRemainingToday: number;
111
+ /** User's discovery progress (streaks, counts) */
112
+ progress?: DiscoveryProgress;
113
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * Discovery Questions (DQ) - Client-Facing Types
4
+ *
5
+ * IMPORTANT: Only types needed by the frontend should be here.
6
+ * Internal backend details (psychometrics, scoring, etc.) belong in backend only.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,6 +2,7 @@ export * from "./am.types";
2
2
  export * from "./assessment.types";
3
3
  export * from "./ca.types";
4
4
  export * from "./cloud-function-types";
5
+ export * from "./dq.types";
5
6
  export * from "./error.types";
6
7
  export * from "./event.types";
7
8
  export * from "./feedback.types";
@@ -18,6 +18,7 @@ __exportStar(require("./am.types"), exports);
18
18
  __exportStar(require("./assessment.types"), exports);
19
19
  __exportStar(require("./ca.types"), exports);
20
20
  __exportStar(require("./cloud-function-types"), exports);
21
+ __exportStar(require("./dq.types"), exports);
21
22
  __exportStar(require("./error.types"), exports);
22
23
  __exportStar(require("./event.types"), exports);
23
24
  __exportStar(require("./feedback.types"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heartraite",
3
- "version": "1.0.174",
3
+ "version": "1.0.176",
4
4
  "description": "Heartraite npm package for common functionality",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Discovery Questions (DQ) - Client-Facing Types
3
+ *
4
+ * IMPORTANT: Only types needed by the frontend should be here.
5
+ * Internal backend details (psychometrics, scoring, etc.) belong in backend only.
6
+ */
7
+
8
+ import { Locale } from "../enum/localization.enum";
9
+
10
+ // ========== BASIC TYPES ==========
11
+
12
+ /**
13
+ * DQ locale codes for question content
14
+ * Currently supports Swedish and Danish
15
+ */
16
+ export type DQLocaleCode = "sv" | "da";
17
+
18
+ export type QuestionType =
19
+ | "scale"
20
+ | "multiple_choice"
21
+ | "multi_select"
22
+ | "ranking";
23
+
24
+ /**
25
+ * Localized text content
26
+ */
27
+ export type LocalizedString = Record<DQLocaleCode, string>;
28
+
29
+ // ========== UI CONFIGURATION TYPES ==========
30
+
31
+ /**
32
+ * Configuration for scale-type questions (slider UI)
33
+ */
34
+ export interface ScaleConfig {
35
+ min: number;
36
+ max: number;
37
+ step: number;
38
+ minLabel: string;
39
+ maxLabel: string;
40
+ midLabel?: string;
41
+ }
42
+
43
+ /**
44
+ * Option for multiple choice or multi-select questions
45
+ */
46
+ export interface QuestionOption {
47
+ optionId: string;
48
+ text: string;
49
+ imageUrl?: string;
50
+ displayOrder: number;
51
+ }
52
+
53
+ /**
54
+ * Item for ranking questions
55
+ */
56
+ export interface RankingItem {
57
+ itemId: string;
58
+ text: string;
59
+ }
60
+
61
+ /**
62
+ * Configuration for ranking-type questions
63
+ */
64
+ export interface RankingConfig {
65
+ items: RankingItem[];
66
+ requiredRankCount: number;
67
+ }
68
+
69
+ /**
70
+ * Configuration for open-ended text questions
71
+ */
72
+ export interface OpenEndedConfig {
73
+ maxLength: number;
74
+ minLength: number;
75
+ placeholder: string;
76
+ }
77
+
78
+ // ========== CLIENT QUESTION TYPE ==========
79
+
80
+ /**
81
+ * Question data sent to client
82
+ * Contains only what's needed to render the UI
83
+ */
84
+ export interface DQQuestion {
85
+ // Identity
86
+ questionId: string;
87
+ sequencePosition: number;
88
+
89
+ // Content (localized strings already selected by backend based on user's locale)
90
+ title: string;
91
+ description?: string;
92
+ reflectionPrompt?: string;
93
+
94
+ // UI Configuration (only one populated based on type)
95
+ type: QuestionType;
96
+ scaleConfig?: ScaleConfig;
97
+ options?: QuestionOption[];
98
+ rankingConfig?: RankingConfig;
99
+ openEndedConfig?: OpenEndedConfig;
100
+ }
101
+
102
+ // ========== API REQUEST TYPES ==========
103
+
104
+ /**
105
+ * Request for POST /dq/get-question endpoint
106
+ */
107
+ export interface GetQuestionRequest {
108
+ /** User's preferred locale for question content (optional, defaults to sv_SE) */
109
+ locale?: Locale;
110
+ }
111
+
112
+ // ========== API RESPONSE TYPES ==========
113
+
114
+ /**
115
+ * User's discovery progress (streaks, counts, etc.)
116
+ */
117
+ export interface DiscoveryProgress {
118
+ /** Current consecutive days streak */
119
+ currentStreak: number;
120
+
121
+ /** Longest streak ever achieved */
122
+ longestStreak: number;
123
+
124
+ /** Total questions answered (not skipped) */
125
+ answeredCount: number;
126
+
127
+ /** Total questions skipped */
128
+ skippedCount: number;
129
+
130
+ /** ISO timestamp of last answered question (null if never answered) */
131
+ lastAnsweredAt: string | null;
132
+ }
133
+
134
+ /**
135
+ * Response for POST /dq/get-question endpoint
136
+ * Provides question data along with quota information
137
+ */
138
+ export interface GetQuestionResponse {
139
+ /** The question to display, or null if quota exhausted or no more questions */
140
+ question: DQQuestion | null;
141
+
142
+ /** Whether the user has exhausted their daily quota */
143
+ quotaExhausted: boolean;
144
+
145
+ /** ISO timestamp when quota resets (next midnight UTC), only present when quota exhausted */
146
+ quotaResetsAt?: string;
147
+
148
+ /** Number of questions remaining for today */
149
+ questionsRemainingToday: number;
150
+
151
+ /** User's discovery progress (streaks, counts) */
152
+ progress?: DiscoveryProgress;
153
+ }
@@ -2,6 +2,7 @@ export * from "./am.types";
2
2
  export * from "./assessment.types";
3
3
  export * from "./ca.types";
4
4
  export * from "./cloud-function-types";
5
+ export * from "./dq.types";
5
6
  export * from "./error.types";
6
7
  export * from "./event.types";
7
8
  export * from "./feedback.types";