heartraite 1.0.196 → 1.0.198

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.
@@ -4,6 +4,33 @@ type QuestionId = string;
4
4
  type CategoryId = string;
5
5
  type ScoreAmount = number;
6
6
  export type Score = Record<QuestionId, ScoreAmount>;
7
+ /**
8
+ * Per-category edit USAGE bookkeeping for post-completion CA edits, persisted on
9
+ * the CA doc. Written by the backend on each category edit. (The frontend gates
10
+ * editing off the derived `editAvailability.canEdit`, NOT off `editCount` — the
11
+ * policy lives backend-side; see `CategoryEditAvailability`.)
12
+ */
13
+ export type CategoryEditMeta = {
14
+ /** How many times this category has been edited (post-completion). */
15
+ editCount: number;
16
+ /** ISO timestamp of the most recent edit. */
17
+ lastEditedAt: string;
18
+ };
19
+ /**
20
+ * Backend-DERIVED per-category edit availability, returned on CA responses (not
21
+ * persisted). The frontend renders `canEdit` directly and never computes the
22
+ * policy itself — so count-based, time-based, premium, or backoffice-override
23
+ * logic can change server-side and take effect in the app WITHOUT a release.
24
+ */
25
+ export type CategoryEditAvailability = {
26
+ /** Whether the user may edit this category right now. */
27
+ canEdit: boolean;
28
+ /**
29
+ * When a locked category becomes editable again (ISO) — for time-based /
30
+ * cooldown policies. Absent for count-based locks or when `canEdit` is true.
31
+ */
32
+ availableAt?: string;
33
+ };
7
34
  export type CA = {
8
35
  created: string;
9
36
  userId: string;
@@ -12,6 +39,16 @@ export type CA = {
12
39
  categoryEvaluations: Record<CategoryId, CategoryEvaluation>;
13
40
  lastUpdated?: string;
14
41
  firstAnsweredAt?: string;
42
+ /**
43
+ * Per-category edit counters (categoryId -> meta). Absent until a category has
44
+ * been edited post-completion. Backend-owned usage data.
45
+ */
46
+ editMeta?: Record<CategoryId, CategoryEditMeta>;
47
+ /**
48
+ * Backend-derived per-category edit availability (categoryId -> availability),
49
+ * populated on CA responses. Frontend reads `canEdit` to gate the edit UI.
50
+ */
51
+ editAvailability?: Record<CategoryId, CategoryEditAvailability>;
15
52
  };
16
53
  export type Personality = {
17
54
  [PersonalityTrait.OPENNESS]: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heartraite",
3
- "version": "1.0.196",
3
+ "version": "1.0.198",
4
4
  "description": "Heartraite npm package for common functionality",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -7,6 +7,35 @@ type ScoreAmount = number;
7
7
 
8
8
  export type Score = Record<QuestionId, ScoreAmount>;
9
9
 
10
+ /**
11
+ * Per-category edit USAGE bookkeeping for post-completion CA edits, persisted on
12
+ * the CA doc. Written by the backend on each category edit. (The frontend gates
13
+ * editing off the derived `editAvailability.canEdit`, NOT off `editCount` — the
14
+ * policy lives backend-side; see `CategoryEditAvailability`.)
15
+ */
16
+ export type CategoryEditMeta = {
17
+ /** How many times this category has been edited (post-completion). */
18
+ editCount: number;
19
+ /** ISO timestamp of the most recent edit. */
20
+ lastEditedAt: string;
21
+ };
22
+
23
+ /**
24
+ * Backend-DERIVED per-category edit availability, returned on CA responses (not
25
+ * persisted). The frontend renders `canEdit` directly and never computes the
26
+ * policy itself — so count-based, time-based, premium, or backoffice-override
27
+ * logic can change server-side and take effect in the app WITHOUT a release.
28
+ */
29
+ export type CategoryEditAvailability = {
30
+ /** Whether the user may edit this category right now. */
31
+ canEdit: boolean;
32
+ /**
33
+ * When a locked category becomes editable again (ISO) — for time-based /
34
+ * cooldown policies. Absent for count-based locks or when `canEdit` is true.
35
+ */
36
+ availableAt?: string;
37
+ };
38
+
10
39
  export type CA = {
11
40
  created: string;
12
41
  userId: string;
@@ -15,6 +44,16 @@ export type CA = {
15
44
  categoryEvaluations: Record<CategoryId, CategoryEvaluation>;
16
45
  lastUpdated?: string;
17
46
  firstAnsweredAt?: string;
47
+ /**
48
+ * Per-category edit counters (categoryId -> meta). Absent until a category has
49
+ * been edited post-completion. Backend-owned usage data.
50
+ */
51
+ editMeta?: Record<CategoryId, CategoryEditMeta>;
52
+ /**
53
+ * Backend-derived per-category edit availability (categoryId -> availability),
54
+ * populated on CA responses. Frontend reads `canEdit` to gate the edit UI.
55
+ */
56
+ editAvailability?: Record<CategoryId, CategoryEditAvailability>;
18
57
  };
19
58
 
20
59
  export type Personality = {