@shaxpir/duiduidui-models 1.37.2 → 1.37.3

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.
@@ -68,6 +68,18 @@ export declare class Billing extends Content {
68
68
  isActive(): boolean;
69
69
  isTrialing(): boolean;
70
70
  isLifetimeFree(): boolean;
71
+ /**
72
+ * Client-side belt-and-suspenders check: returns true if the billing doc
73
+ * has an expires_at in the past, regardless of what subscription_status says.
74
+ * This catches the window between actual expiry and the server sweep updating the status.
75
+ */
76
+ isExpiredLocally(): boolean;
77
+ /**
78
+ * Returns the number of days remaining until expiry as a float, or null if no expiry is set.
79
+ * Returns 0 if already expired. The float value allows granular display
80
+ * (e.g., hours/minutes remaining on the last day).
81
+ */
82
+ daysRemaining(): number | null;
71
83
  /**
72
84
  * Check whether the user has an active (non-expired) grant for the given feature flag.
73
85
  */
@@ -86,6 +86,29 @@ class Billing extends Content_1.Content {
86
86
  isLifetimeFree() {
87
87
  return this.subscriptionSource === 'lifetime_free';
88
88
  }
89
+ /**
90
+ * Client-side belt-and-suspenders check: returns true if the billing doc
91
+ * has an expires_at in the past, regardless of what subscription_status says.
92
+ * This catches the window between actual expiry and the server sweep updating the status.
93
+ */
94
+ isExpiredLocally() {
95
+ const expiresAt = this.expiresAt;
96
+ if (!expiresAt)
97
+ return false;
98
+ const now = shaxpir_common_1.ClockService.getClock().utc();
99
+ return shaxpir_common_1.Time.isDateTimeBefore(expiresAt, now);
100
+ }
101
+ /**
102
+ * Returns the number of days remaining until expiry as a float, or null if no expiry is set.
103
+ * Returns 0 if already expired. The float value allows granular display
104
+ * (e.g., hours/minutes remaining on the last day).
105
+ */
106
+ daysRemaining() {
107
+ const expiresAt = this.expiresAt;
108
+ if (!expiresAt)
109
+ return null;
110
+ return Math.max(0, shaxpir_common_1.Time.timeUntil(expiresAt, 'day'));
111
+ }
89
112
  /**
90
113
  * Check whether the user has an active (non-expired) grant for the given feature flag.
91
114
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.37.2",
3
+ "version": "1.37.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"