heartraite 1.0.197 → 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.
@@ -5,9 +5,10 @@ type CategoryId = string;
5
5
  type ScoreAmount = number;
6
6
  export type Score = Record<QuestionId, ScoreAmount>;
7
7
  /**
8
- * Per-category edit bookkeeping for post-completion CA edits. Written by the
9
- * backend on each category edit; read by the frontend to render per-category
10
- * edit availability ("can update once" vs "already updated"). Shared shape.
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`.)
11
12
  */
12
13
  export type CategoryEditMeta = {
13
14
  /** How many times this category has been edited (post-completion). */
@@ -15,6 +16,21 @@ export type CategoryEditMeta = {
15
16
  /** ISO timestamp of the most recent edit. */
16
17
  lastEditedAt: string;
17
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
+ };
18
34
  export type CA = {
19
35
  created: string;
20
36
  userId: string;
@@ -25,9 +41,14 @@ export type CA = {
25
41
  firstAnsweredAt?: string;
26
42
  /**
27
43
  * Per-category edit counters (categoryId -> meta). Absent until a category has
28
- * been edited post-completion. Backend-owned; frontend reads for availability.
44
+ * been edited post-completion. Backend-owned usage data.
29
45
  */
30
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>;
31
52
  };
32
53
  export type Personality = {
33
54
  [PersonalityTrait.OPENNESS]: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heartraite",
3
- "version": "1.0.197",
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",
@@ -8,9 +8,10 @@ type ScoreAmount = number;
8
8
  export type Score = Record<QuestionId, ScoreAmount>;
9
9
 
10
10
  /**
11
- * Per-category edit bookkeeping for post-completion CA edits. Written by the
12
- * backend on each category edit; read by the frontend to render per-category
13
- * edit availability ("can update once" vs "already updated"). Shared shape.
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`.)
14
15
  */
15
16
  export type CategoryEditMeta = {
16
17
  /** How many times this category has been edited (post-completion). */
@@ -19,6 +20,22 @@ export type CategoryEditMeta = {
19
20
  lastEditedAt: string;
20
21
  };
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
+
22
39
  export type CA = {
23
40
  created: string;
24
41
  userId: string;
@@ -29,9 +46,14 @@ export type CA = {
29
46
  firstAnsweredAt?: string;
30
47
  /**
31
48
  * Per-category edit counters (categoryId -> meta). Absent until a category has
32
- * been edited post-completion. Backend-owned; frontend reads for availability.
49
+ * been edited post-completion. Backend-owned usage data.
33
50
  */
34
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>;
35
57
  };
36
58
 
37
59
  export type Personality = {