musora-content-services 2.160.5 → 2.161.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [2.161.2](https://github.com/railroadmedia/musora-content-services/compare/v2.161.1...v2.161.2) (2026-05-27)
6
+
7
+ ### [2.161.1](https://github.com/railroadmedia/musora-content-services/compare/v2.161.0...v2.161.1) (2026-05-27)
8
+
9
+ ## [2.161.0](https://github.com/railroadmedia/musora-content-services/compare/v2.160.5...v2.161.0) (2026-05-27)
10
+
11
+
12
+ ### Features
13
+
14
+ * **BEHLTP-106:** membership data upgrade ([#973](https://github.com/railroadmedia/musora-content-services/issues/973)) ([e1e0611](https://github.com/railroadmedia/musora-content-services/commit/e1e0611c13bdf4be920eb28cca1f15f912930d24))
15
+
5
16
  ### [2.160.5](https://github.com/railroadmedia/musora-content-services/compare/v2.160.4...v2.160.5) (2026-05-22)
6
17
 
7
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "2.160.5",
3
+ "version": "2.161.2",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -28,7 +28,7 @@ export interface InviteResponse {
28
28
  email?: string
29
29
  }
30
30
 
31
- export interface UsersMultiAccountResponse {
31
+ export interface UsersDataForMultiUserAccount {
32
32
  user_id: number
33
33
  active_multi_user_account: MultiUserAccountResponse
34
34
  last_cancelled_multi_user_account: MultiUserAccountResponse
@@ -42,13 +42,15 @@ export interface MultiUserAccountResponse {
42
42
  product_name: string
43
43
  is_active: boolean
44
44
  primary_user: User
45
- total_seats: number
46
45
  end_time: string
47
46
  is_primary_account_holder: boolean
47
+ membership_level: 'plus' | 'basic'
48
+ is_lifetime_addon: boolean
48
49
  // The following fields are not included for public or subaccount users
49
- active_invited_emails?: InviteResponse[]
50
+ active_invites?: InviteResponse[]
50
51
  available_seats?: number
51
- available_invites?: InviteResponse[]
52
+ available_invites?: number
53
+ total_seats?: number
52
54
  active_subs?: User[]
53
55
  show_welcome?: boolean
54
56
  }
@@ -83,12 +85,12 @@ export async function createAccount(params: CreateAccountParams): Promise<MultiU
83
85
  * Fetches multi-user account details for a specific user.
84
86
  *
85
87
  * @param {number} userId - The ID of the user to fetch account details for.
86
- * @returns {Promise<UsersMultiAccountResponse>} - A promise that resolves to the account details.
88
+ * @returns {Promise<UsersDataForMultiUserAccount>} - A promise that resolves to the account details.
87
89
  * @throws {HttpError} - If the HTTP request fails.
88
90
  */
89
- export async function fetchUsersMultiAccountDetails(userId: number): Promise<UsersMultiAccountResponse> {
91
+ export async function fetchUsersMultiAccountDetails(userId: number): Promise<UsersDataForMultiUserAccount> {
90
92
  const httpClient = new HttpClient(globalConfig.baseUrl)
91
- return httpClient.get<UsersMultiAccountResponse>(`${baseUrl}/${userId}/details`)
93
+ return httpClient.get<UsersDataForMultiUserAccount>(`${baseUrl}/${userId}/details`)
92
94
  }
93
95
 
94
96
 
@@ -4,22 +4,27 @@
4
4
  import './types.js'
5
5
  import { HttpClient } from '../../infrastructure/http/HttpClient'
6
6
  import { globalConfig } from '../config'
7
+ import { MultiUserAccountResponse } from "../multi-user-accounts/multi-user-accounts";
7
8
 
8
9
  const baseUrl = `/api/user-memberships`
10
+ // Magic stringed to MembershipController.php
11
+ const multiUserAccountFeatureFlag = 'multi_user_account_feature_flag'
9
12
 
10
- /**
11
- * Represents a user membership object
12
- */
13
- export interface Membership {
14
- id: number
15
- user_id: number
16
- membership_type: string
17
- start_date: string
18
- expiration_date: string | null
19
- status: string
20
- created_at: string
21
- updated_at: string
22
- [key: string]: any
13
+ // Active Purchased Subscription Data
14
+ export interface MembershipData {
15
+ type: string
16
+ name: string
17
+ expiration_date: string
18
+ is_in_trial: boolean
19
+ trial_duration: string
20
+ never_expires: boolean
21
+ }
22
+
23
+ export interface UserMembershipResponse {
24
+ user_membership_data: MembershipData[]
25
+ can_upgrade_membership: boolean // pre multiUserAccount data
26
+ sub_account_data: MultiUserAccountResponse // post multiUserAccount data
27
+ upgrade_options: UpgradeOption[] // post multiuser account data
23
28
  }
24
29
 
25
30
  /**
@@ -32,15 +37,28 @@ export interface RechargeTokens {
32
37
  storefront_access_token: string
33
38
  }
34
39
 
35
- /**
36
- * Represents the response from subscription upgrade
37
- */
38
40
  export interface UpgradeSubscriptionResponse {
39
41
  action: 'instant_upgrade' | 'shopify'
40
42
  message?: string
41
43
  url?: string
42
44
  }
43
45
 
46
+ export interface UpgradeProduct {
47
+ id: number
48
+ name: string
49
+ sku: string
50
+ price: number
51
+ monthly_price: number
52
+ includes_trial: boolean
53
+ }
54
+
55
+ export interface UpgradeOption {
56
+ annual_savings: number
57
+ lowest_monthly_cost: number
58
+ products: UpgradeProduct[] // annual + monthly products, or solely annual product with the same configuration information
59
+ }
60
+
61
+
44
62
  /**
45
63
  * Represents the response when user should create an account (no entitlements or user not found)
46
64
  */
@@ -93,21 +111,9 @@ export type RestorePurchasesResponse =
93
111
  | RestorePurchasesSuccessResponse
94
112
  | RestorePurchasesSetupAccountResponse
95
113
 
96
- /**
97
- * Fetches the authenticated user's memberships from the API.
98
- *
99
- * @returns {Promise<Array<Membership>>} - A promise that resolves to an array of membership objects.
100
- *
101
- * @throws {Error} - Throws an error if the request fails.
102
- *
103
- * @example
104
- * fetchMemberships()
105
- * .then(memberships => console.log(memberships))
106
- * .catch(error => console.error(error));
107
- */
108
- export async function fetchMemberships(): Promise<Membership[]> {
114
+ export async function fetchMemberships(): Promise<UserMembershipResponse> {
109
115
  const httpClient = new HttpClient(globalConfig.baseUrl)
110
- return httpClient.get<Membership[]>(`${baseUrl}/v1`)
116
+ return httpClient.get<UserMembershipResponse>(`${baseUrl}/v1`)
111
117
  }
112
118
 
113
119
  /**
@@ -134,6 +140,8 @@ export async function fetchRechargeTokens(): Promise<RechargeTokens> {
134
140
  /**
135
141
  * Upgrades the user's subscription or provides a prefilled add-to-cart URL.
136
142
  *
143
+ * @param {boolean} featureFlag - MultiUserAccount feature Flag - default false
144
+ *
137
145
  * @returns {Promise<UpgradeSubscriptionResponse>} A promise that resolves to an object containing either:
138
146
  * - {string} action - The action performed (e.g., 'instant_upgrade').
139
147
  * - {string} message - Success message if the subscription was upgraded immediately.
@@ -148,9 +156,10 @@ export async function fetchRechargeTokens(): Promise<RechargeTokens> {
148
156
  * .then(response => console.log(response))
149
157
  * .catch(error => console.error(error));
150
158
  */
151
- export async function upgradeSubscription(): Promise<UpgradeSubscriptionResponse> {
159
+ export async function upgradeSubscription(featureFlag = false): Promise<UpgradeSubscriptionResponse> {
160
+ let featureFlagValue = featureFlag ? 1 : 0
152
161
  const httpClient = new HttpClient(globalConfig.baseUrl)
153
- return httpClient.get<UpgradeSubscriptionResponse>(`${baseUrl}/v1/update-subscription`)
162
+ return httpClient.get<UpgradeSubscriptionResponse>(`${baseUrl}/v1/update-subscription?${multiUserAccountFeatureFlag}=${featureFlagValue}`)
154
163
  }
155
164
 
156
165
  /**
@@ -231,6 +240,8 @@ export async function restorePurchases(
231
240
  * Get the upgrade price from Basic to Plus membership.
232
241
  * Returns the price based on the user's subscription interval.
233
242
  *
243
+ * @param {boolean} featureFlag - MultiUserAccount feature Flag - default false
244
+ *
234
245
  * For monthly subscribers: Returns the monthly upgrade cost (difference between Plus and Base monthly prices, ~$5/month)
235
246
  * For yearly subscribers: Returns the monthly equivalent upgrade cost ($3.33/month from $40/year)
236
247
  * For lifetime subscribers: Returns the annual upgrade cost for songs add-on ($40/year)
@@ -254,9 +265,10 @@ export async function restorePurchases(
254
265
  * console.error('Failed to fetch upgrade price:', error)
255
266
  * })
256
267
  */
257
- export async function getUpgradePrice() {
268
+ export async function getUpgradePrice(featureFlag = false) {
269
+ let featureFlagValue = featureFlag ? 1 : 0
258
270
  const httpClient = new HttpClient(globalConfig.baseUrl)
259
- return httpClient.get(`${baseUrl}/v1/upgrade-price`)
271
+ return httpClient.get(`${baseUrl}/v1/upgrade-price?${multiUserAccountFeatureFlag}=${featureFlagValue}`)
260
272
  }
261
273
 
262
274
  /**
@@ -1,23 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(npx jest *)",
5
- "Bash(npx tsc *)",
6
- "Skill(counselors)",
7
- "Bash(counselors ls *)",
8
- "Bash(counselors groups *)",
9
- "Bash(counselors run *)",
10
- "Bash(npm test *)",
11
- "Bash(gh pr *)",
12
- "Bash(gh api *)",
13
- "Bash(mkdir -p /tmp/pr-review-v2)",
14
- "Read(//tmp/pr-review-v2/**)",
15
- "Bash(cat /home/alesevero/railenvironment/applications/musora-content-services/AGENTS.md)",
16
- "Bash(echo \"no AGENTS.md\")",
17
- "Bash(echo \"exit=$?\")",
18
- "Bash(git checkout *)",
19
- "Skill(pr)",
20
- "Skill(create-decision)"
21
- ]
22
- }
23
- }