heartraite 1.0.194 → 1.0.195
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/dist/types/dq.types.d.ts
CHANGED
|
@@ -109,6 +109,24 @@ export interface GetQuestionResponse {
|
|
|
109
109
|
quotaResetsAt?: string;
|
|
110
110
|
/** Number of questions remaining for today */
|
|
111
111
|
questionsRemainingToday: number;
|
|
112
|
+
/**
|
|
113
|
+
* True when the user has answered every question currently in the
|
|
114
|
+
* DQ pool. Distinct from `quotaExhausted` (the daily 3/day cap):
|
|
115
|
+
*
|
|
116
|
+
* - `quotaExhausted: true` → user used today's 3 — come back tomorrow.
|
|
117
|
+
* - `allQuestionsCompleted: true` → user has cleared the entire pool;
|
|
118
|
+
* no more questions exist until new ones
|
|
119
|
+
* are added. Tomorrow's quota reset won't
|
|
120
|
+
* bring new questions.
|
|
121
|
+
*
|
|
122
|
+
* Optional for backward compatibility — older clients that don't
|
|
123
|
+
* read this field will continue inferring "no question available"
|
|
124
|
+
* from `question: null && !quotaExhausted`, but they'll show the
|
|
125
|
+
* generic "come back tomorrow" message which is misleading in this
|
|
126
|
+
* state. New clients should render a dedicated "all caught up"
|
|
127
|
+
* surface when this is `true`.
|
|
128
|
+
*/
|
|
129
|
+
allQuestionsCompleted?: boolean;
|
|
112
130
|
/** User's discovery progress (streaks, counts) */
|
|
113
131
|
progress?: DiscoveryProgress;
|
|
114
132
|
}
|
|
@@ -4,9 +4,9 @@ exports.calculateAgeFromDateString = calculateAgeFromDateString;
|
|
|
4
4
|
function calculateAgeFromDateString(isoDateString) {
|
|
5
5
|
const birthDate = new Date(isoDateString);
|
|
6
6
|
const today = new Date();
|
|
7
|
-
const ageDiff = today.
|
|
8
|
-
const hasBirthdayPassed = today.
|
|
9
|
-
(today.
|
|
10
|
-
today.
|
|
7
|
+
const ageDiff = today.getUTCFullYear() - birthDate.getUTCFullYear();
|
|
8
|
+
const hasBirthdayPassed = today.getUTCMonth() > birthDate.getUTCMonth() ||
|
|
9
|
+
(today.getUTCMonth() === birthDate.getUTCMonth() &&
|
|
10
|
+
today.getUTCDate() >= birthDate.getUTCDate());
|
|
11
11
|
return hasBirthdayPassed ? ageDiff : ageDiff - 1;
|
|
12
12
|
}
|
package/package.json
CHANGED
package/src/types/dq.types.ts
CHANGED
|
@@ -149,6 +149,25 @@ export interface GetQuestionResponse {
|
|
|
149
149
|
/** Number of questions remaining for today */
|
|
150
150
|
questionsRemainingToday: number;
|
|
151
151
|
|
|
152
|
+
/**
|
|
153
|
+
* True when the user has answered every question currently in the
|
|
154
|
+
* DQ pool. Distinct from `quotaExhausted` (the daily 3/day cap):
|
|
155
|
+
*
|
|
156
|
+
* - `quotaExhausted: true` → user used today's 3 — come back tomorrow.
|
|
157
|
+
* - `allQuestionsCompleted: true` → user has cleared the entire pool;
|
|
158
|
+
* no more questions exist until new ones
|
|
159
|
+
* are added. Tomorrow's quota reset won't
|
|
160
|
+
* bring new questions.
|
|
161
|
+
*
|
|
162
|
+
* Optional for backward compatibility — older clients that don't
|
|
163
|
+
* read this field will continue inferring "no question available"
|
|
164
|
+
* from `question: null && !quotaExhausted`, but they'll show the
|
|
165
|
+
* generic "come back tomorrow" message which is misleading in this
|
|
166
|
+
* state. New clients should render a dedicated "all caught up"
|
|
167
|
+
* surface when this is `true`.
|
|
168
|
+
*/
|
|
169
|
+
allQuestionsCompleted?: boolean;
|
|
170
|
+
|
|
152
171
|
/** User's discovery progress (streaks, counts) */
|
|
153
172
|
progress?: DiscoveryProgress;
|
|
154
173
|
}
|
|
@@ -2,11 +2,11 @@ export function calculateAgeFromDateString(isoDateString: string): number {
|
|
|
2
2
|
const birthDate = new Date(isoDateString);
|
|
3
3
|
const today = new Date();
|
|
4
4
|
|
|
5
|
-
const ageDiff = today.
|
|
5
|
+
const ageDiff = today.getUTCFullYear() - birthDate.getUTCFullYear();
|
|
6
6
|
const hasBirthdayPassed =
|
|
7
|
-
today.
|
|
8
|
-
(today.
|
|
9
|
-
today.
|
|
7
|
+
today.getUTCMonth() > birthDate.getUTCMonth() ||
|
|
8
|
+
(today.getUTCMonth() === birthDate.getUTCMonth() &&
|
|
9
|
+
today.getUTCDate() >= birthDate.getUTCDate());
|
|
10
10
|
|
|
11
11
|
return hasBirthdayPassed ? ageDiff : ageDiff - 1;
|
|
12
12
|
}
|