musora-content-services 2.107.3 → 2.107.4
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/.claude/settings.local.json +16 -0
- package/.coderabbit.yaml +0 -0
- package/.editorconfig +0 -0
- package/.github/pull_request_template.md +0 -0
- package/.github/workflows/conventional-commits.yaml +0 -0
- package/.github/workflows/docs.js.yml +0 -0
- package/.github/workflows/node.js.yml +0 -0
- package/.prettierignore +0 -0
- package/.prettierrc +0 -0
- package/.yarnrc.yml +1 -0
- package/CHANGELOG.md +9 -0
- package/CLAUDE.md +0 -0
- package/README.md +0 -0
- package/babel.config.cjs +0 -0
- package/check_content.js +30 -0
- package/check_content.mjs +32 -0
- package/jest.config.js +0 -0
- package/jsdoc.json +0 -0
- package/package.json +1 -1
- package/src/constants/award-assets.js +0 -0
- package/src/contentMetaData.js +0 -0
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +17 -0
- package/src/infrastructure/http/HttpClient.ts +0 -0
- package/src/infrastructure/http/executors/FetchRequestExecutor.ts +0 -0
- package/src/infrastructure/http/index.ts +0 -0
- package/src/infrastructure/http/interfaces/HeaderProvider.ts +0 -0
- package/src/infrastructure/http/interfaces/HttpError.ts +0 -0
- package/src/infrastructure/http/interfaces/NetworkError.ts +0 -0
- package/src/infrastructure/http/interfaces/RequestExecutor.ts +0 -0
- package/src/infrastructure/http/interfaces/RequestOptions.ts +0 -0
- package/src/infrastructure/http/providers/DefaultHeaderProvider.ts +0 -0
- package/src/lib/ads/monoid.ts +0 -0
- package/src/lib/ads/semigroup.ts +0 -0
- package/src/lib/brands.ts +0 -0
- package/src/lib/lastUpdated.js +0 -0
- package/src/lib/sanity/filter.ts +0 -0
- package/src/lib/sanity/query.ts +0 -0
- package/src/services/api/types.js +0 -0
- package/src/services/api/types.ts +0 -0
- package/src/services/awards/award-callbacks.js +0 -0
- package/src/services/awards/award-query.js +0 -0
- package/src/services/awards/internal/.indexignore +0 -0
- package/src/services/awards/internal/award-definitions.js +0 -0
- package/src/services/awards/internal/award-events.js +0 -0
- package/src/services/awards/internal/award-manager.js +0 -0
- package/src/services/awards/internal/certificate-builder.js +0 -0
- package/src/services/awards/internal/completion-data-generator.js +0 -0
- package/src/services/awards/internal/content-progress-observer.js +0 -0
- package/src/services/awards/internal/image-utils.js +0 -0
- package/src/services/awards/internal/message-generator.js +0 -0
- package/src/services/awards/internal/types.js +0 -0
- package/src/services/awards/types.d.ts +0 -0
- package/src/services/awards/types.js +0 -0
- package/src/services/config.js +0 -0
- package/src/services/content/artist.ts +0 -0
- package/src/services/content/content.ts +0 -0
- package/src/services/content/genre.ts +0 -0
- package/src/services/content/instructor.ts +0 -0
- package/src/services/content-org/content-org.js +0 -0
- package/src/services/content-org/guided-courses.ts +0 -0
- package/src/services/content-org/learning-paths.ts +0 -0
- package/src/services/content-org/playlists-types.js +0 -0
- package/src/services/content-org/playlists.js +0 -0
- package/src/services/content.js +0 -0
- package/src/services/contentAggregator.js +0 -0
- package/src/services/contentLikes.js +0 -0
- package/src/services/contentProgress.js +0 -0
- package/src/services/dataContext.js +0 -0
- package/src/services/dateUtils.js +0 -0
- package/src/services/eventsAPI.js +0 -0
- package/src/services/forums/categories.ts +0 -0
- package/src/services/forums/forums.ts +0 -0
- package/src/services/forums/posts.ts +50 -2
- package/src/services/forums/threads.ts +13 -0
- package/src/services/forums/types.ts +0 -0
- package/src/services/gamification/awards.ts +0 -0
- package/src/services/gamification/gamification.js +0 -0
- package/src/services/imageSRCBuilder.js +0 -0
- package/src/services/imageSRCVerify.js +0 -0
- package/src/services/liveTesting.ts +0 -0
- package/src/services/permissions/PermissionsAdapter.ts +0 -0
- package/src/services/permissions/PermissionsAdapterFactory.ts +0 -0
- package/src/services/permissions/PermissionsV1Adapter.ts +0 -0
- package/src/services/permissions/PermissionsV2Adapter.ts +0 -0
- package/src/services/permissions/README.md +0 -0
- package/src/services/permissions/index.ts +0 -0
- package/src/services/progress-events.js +0 -0
- package/src/services/progress-row/method-card.js +0 -0
- package/src/services/railcontent.js +80 -3
- package/src/services/recommendations.js +0 -0
- package/src/services/reporting/README.md +0 -0
- package/src/services/reporting/reporting.ts +71 -3
- package/src/services/reporting/types.ts +0 -0
- package/src/services/sentry/.indexignore +0 -0
- package/src/services/sentry/index.ts +0 -0
- package/src/services/sync/.indexignore +0 -0
- package/src/services/sync/adapters/factory.ts +0 -0
- package/src/services/sync/adapters/lokijs.ts +0 -0
- package/src/services/sync/adapters/sqlite.ts +0 -0
- package/src/services/sync/concurrency-safety.ts +0 -0
- package/src/services/sync/context/index.ts +0 -0
- package/src/services/sync/context/providers/base.ts +0 -0
- package/src/services/sync/context/providers/connectivity.ts +0 -0
- package/src/services/sync/context/providers/durability.ts +0 -0
- package/src/services/sync/context/providers/index.ts +0 -0
- package/src/services/sync/context/providers/session.ts +0 -0
- package/src/services/sync/context/providers/tabs.ts +0 -0
- package/src/services/sync/context/providers/visibility.ts +0 -0
- package/src/services/sync/database/factory.ts +0 -0
- package/src/services/sync/errors/boundary.ts +0 -0
- package/src/services/sync/errors/index.ts +0 -0
- package/src/services/sync/errors/validators.ts +0 -0
- package/src/services/sync/fetch.ts +0 -0
- package/src/services/sync/index.ts +0 -0
- package/src/services/sync/manager.ts +0 -0
- package/src/services/sync/models/Base.ts +0 -0
- package/src/services/sync/models/ContentLike.ts +0 -0
- package/src/services/sync/models/ContentProgress.ts +0 -0
- package/src/services/sync/models/Practice.ts +0 -0
- package/src/services/sync/models/PracticeDayNote.ts +0 -0
- package/src/services/sync/models/UserAwardProgress.ts +0 -0
- package/src/services/sync/models/index.ts +0 -0
- package/src/services/sync/repositories/base.ts +0 -0
- package/src/services/sync/repositories/content-likes.ts +0 -0
- package/src/services/sync/repositories/content-progress.ts +0 -0
- package/src/services/sync/repositories/index.ts +0 -0
- package/src/services/sync/repositories/practice-day-notes.ts +0 -0
- package/src/services/sync/repositories/practices.ts +0 -0
- package/src/services/sync/repositories/user-award-progress.ts +0 -0
- package/src/services/sync/repository-proxy.ts +0 -0
- package/src/services/sync/resolver.ts +0 -0
- package/src/services/sync/retry.ts +0 -0
- package/src/services/sync/run-scope.ts +0 -0
- package/src/services/sync/schema/index.ts +0 -0
- package/src/services/sync/serializers/index.ts +0 -0
- package/src/services/sync/serializers/model.ts +0 -0
- package/src/services/sync/serializers/raw.ts +0 -0
- package/src/services/sync/store/index.ts +0 -0
- package/src/services/sync/store/push-coalescer.ts +0 -0
- package/src/services/sync/store-configs.ts +0 -0
- package/src/services/sync/strategies/base.ts +0 -0
- package/src/services/sync/strategies/index.ts +0 -0
- package/src/services/sync/strategies/initial.ts +0 -0
- package/src/services/sync/strategies/polling.ts +0 -0
- package/src/services/sync/telemetry/index.ts +0 -0
- package/src/services/sync/telemetry/sampling.ts +0 -0
- package/src/services/sync/utils/event-emitter.ts +0 -0
- package/src/services/sync/utils/index.ts +0 -0
- package/src/services/sync/utils/throttle.ts +0 -0
- package/src/services/sync/utils/timers.ts +0 -0
- package/src/services/types.js +0 -0
- package/src/services/urlBuilder.ts +297 -0
- package/src/services/user/account.ts +0 -0
- package/src/services/user/chat.js +0 -0
- package/src/services/user/interests.js +0 -0
- package/src/services/user/management.js +0 -0
- package/src/services/user/memberships.ts +0 -0
- package/src/services/user/notifications.js +0 -0
- package/src/services/user/onboarding.ts +0 -0
- package/src/services/user/payments.ts +0 -0
- package/src/services/user/permissions.js +0 -0
- package/src/services/user/profile.js +0 -0
- package/src/services/user/sessions.js +0 -0
- package/src/services/user/types.d.ts +0 -0
- package/src/services/user/types.js +0 -0
- package/src/services/user/user-management-system.js +0 -0
- package/src/services/userActivity.js +0 -0
- package/test/HttpClient.test.js +0 -0
- package/test/awards/award-alacarte-observer.test.js +0 -0
- package/test/awards/award-auto-refresh.test.js +0 -0
- package/test/awards/award-calculations.test.js +0 -0
- package/test/awards/award-certificate-display.test.js +0 -0
- package/test/awards/award-collection-edge-cases.test.js +0 -0
- package/test/awards/award-collection-filtering.test.js +0 -0
- package/test/awards/award-completion-flow.test.js +0 -0
- package/test/awards/award-exclusion-handling.test.js +0 -0
- package/test/awards/award-multi-lesson.test.js +0 -0
- package/test/awards/award-observer-integration.test.js +0 -0
- package/test/awards/award-query-messages.test.js +0 -0
- package/test/awards/award-user-collection.test.js +0 -0
- package/test/awards/duplicate-prevention.test.js +0 -0
- package/test/awards/helpers/completion-mock.js +0 -0
- package/test/awards/helpers/index.js +0 -0
- package/test/awards/helpers/mock-setup.js +0 -0
- package/test/awards/helpers/progress-emitter.js +0 -0
- package/test/awards/message-generator.test.js +0 -0
- package/test/content.test.js +0 -0
- package/test/contentLikes.test.js +0 -0
- package/test/contentProgress.test.js +0 -0
- package/test/dataContext.test.js +0 -0
- package/test/forum.test.js +0 -0
- package/test/imageSRCBuilder.test.js +0 -0
- package/test/imageSRCVerify.test.js +0 -0
- package/test/initializeTests.js +0 -0
- package/test/learningPaths.test.js +0 -0
- package/test/lib/__snapshots__/filter.test.ts.snap +0 -0
- package/test/lib/filter.test.ts +0 -0
- package/test/lib/lastUpdated.test.js +0 -0
- package/test/lib/query.test.ts +0 -0
- package/test/live/contentProgressLive.test.js +0 -0
- package/test/live/railcontentLive.test.js +0 -0
- package/test/localStorageMock.js +0 -0
- package/test/log.js +0 -0
- package/test/mockData/award-definitions.js +0 -0
- package/test/mockData/mockData_fetchByRailContentIds_one_content.json +0 -0
- package/test/mockData/mockData_progress_content.json +0 -0
- package/test/mockData/mockData_sanity_progress_content.json +0 -0
- package/test/mockData/mockData_user_practices.json +0 -0
- package/test/notifications.test.js +0 -0
- package/test/progressRows.test.js +0 -0
- package/test/reporting.test.js +132 -0
- package/test/sanityQueryService.test.js +0 -0
- package/test/streakMessage.test.js +0 -0
- package/test/sync/adapter.ts +0 -0
- package/test/sync/initialize-sync-manager.js +0 -0
- package/test/sync/models/award-database-integration.test.js +0 -0
- package/test/user/permissions.test.js +0 -0
- package/test/userActivity.test.js +0 -0
- package/test_owned_navigate.js +74 -0
- package/tools/generate-index.cjs +0 -0
|
@@ -11,6 +11,10 @@ import { HttpClient } from '../../infrastructure/http/HttpClient'
|
|
|
11
11
|
import { globalConfig } from '../config.js'
|
|
12
12
|
import { ReportResponse, ReportableType, IssueTypeMap, ReportIssueOption } from './types'
|
|
13
13
|
import { Brands } from '../../lib/brands'
|
|
14
|
+
import { generateContentUrl, generatePlaylistUrl, generateForumPostUrl, generateCommentUrl } from '../urlBuilder.ts'
|
|
15
|
+
import {fetchByRailContentId} from "../../index";
|
|
16
|
+
import {fetchByRailContentIds} from "../sanity";
|
|
17
|
+
import {addContextToContent} from "../contentAggregator";
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
20
|
* Parameters for submitting a report with type-safe issue values
|
|
@@ -26,6 +30,14 @@ export type ReportParams<T extends ReportableType = ReportableType> = {
|
|
|
26
30
|
details?: string
|
|
27
31
|
/** Brand context (required: drumeo, pianote, guitareo, singeo, playbass) */
|
|
28
32
|
brand: Brands | string
|
|
33
|
+
/** Full URL to the reported content (generated via urlBuilder) */
|
|
34
|
+
contentUrl?: string
|
|
35
|
+
/** Content data for URL generation (only needed if contentUrl not provided) */
|
|
36
|
+
content?: {
|
|
37
|
+
id: number
|
|
38
|
+
type: string
|
|
39
|
+
parentId?: number
|
|
40
|
+
}
|
|
29
41
|
}
|
|
30
42
|
|
|
31
43
|
/**
|
|
@@ -86,12 +98,68 @@ export async function report<T extends ReportableType>(
|
|
|
86
98
|
requestBody.details = params.details
|
|
87
99
|
}
|
|
88
100
|
|
|
89
|
-
|
|
101
|
+
// Generate content_url for reports (relative URL - backend adds domain)
|
|
102
|
+
if (params.type === 'content') {
|
|
103
|
+
// Fetch content and add navigateTo for courses/packs/etc
|
|
104
|
+
const contents = await addContextToContent(
|
|
105
|
+
fetchByRailContentIds,
|
|
106
|
+
[params.id],
|
|
107
|
+
{ addNavigateTo: true }
|
|
108
|
+
)
|
|
109
|
+
const content = contents?.[0]
|
|
110
|
+
|
|
111
|
+
if (content) {
|
|
112
|
+
requestBody.content_url = generateContentUrl({
|
|
113
|
+
id: content.id,
|
|
114
|
+
type: content.type,
|
|
115
|
+
parentId: content.parentId || content.parent_id,
|
|
116
|
+
brand: content.brand,
|
|
117
|
+
navigateTo: content.navigateTo
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
} else if (params.type === 'playlist') {
|
|
121
|
+
requestBody.content_url = generatePlaylistUrl({
|
|
122
|
+
id: params.id
|
|
123
|
+
})
|
|
124
|
+
} else if (params.type === 'forum_post') {
|
|
125
|
+
const { fetchPost } = await import('../forums/posts.ts')
|
|
126
|
+
const post = await fetchPost(params.id, params.brand)
|
|
127
|
+
|
|
128
|
+
if (post?.thread) {
|
|
129
|
+
requestBody.content_url = generateForumPostUrl({
|
|
130
|
+
brand: params.brand,
|
|
131
|
+
thread: {
|
|
132
|
+
category_id: post.thread.category_id,
|
|
133
|
+
id: post.thread.id
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
} else if (params.type === 'comment') {
|
|
138
|
+
const { fetchComment } = await import('../railcontent.js')
|
|
139
|
+
const comment = await fetchComment(params.id)
|
|
140
|
+
|
|
141
|
+
if (comment?.content) {
|
|
142
|
+
const contents = await fetchByRailContentIds([comment.content.id])
|
|
143
|
+
const content = contents?.[0]
|
|
144
|
+
|
|
145
|
+
if (content) {
|
|
146
|
+
requestBody.content_url = generateCommentUrl({
|
|
147
|
+
id: comment.id,
|
|
148
|
+
content: {
|
|
149
|
+
id: content.id,
|
|
150
|
+
type: content.type,
|
|
151
|
+
parentId: content.parentId || content.parent_id,
|
|
152
|
+
brand: params.brand
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return await httpClient.post<ReportResponse>(
|
|
90
160
|
'/api/user-reports/v1/reports',
|
|
91
161
|
requestBody
|
|
92
162
|
)
|
|
93
|
-
|
|
94
|
-
return response
|
|
95
163
|
}
|
|
96
164
|
|
|
97
165
|
/**
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/services/types.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module UrlBuilder
|
|
3
|
+
* @description URL generation for content across Musora platform
|
|
4
|
+
*
|
|
5
|
+
* This is the SINGLE SOURCE OF TRUTH for URL generation.
|
|
6
|
+
* Used by:
|
|
7
|
+
* - musora-platform-frontend (via import)
|
|
8
|
+
* - Mobile apps (via import)
|
|
9
|
+
* - Backend receives these URLs from frontend and stores them in DB
|
|
10
|
+
*
|
|
11
|
+
* Port of: musora-platform-frontend/src/shared/utils/content.utils.ts:generateContentUrl
|
|
12
|
+
* Related: musora-platform-backend/app/Modules/Content/Builders/UrlBuilder.php (deprecated fallback)
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { globalConfig } from './config.js'
|
|
16
|
+
import { Brands } from '../lib/brands.js'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Brand type - accepts enum values or string
|
|
20
|
+
*/
|
|
21
|
+
export type Brand = Brands | string
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Parameters for generating content URLs
|
|
25
|
+
*/
|
|
26
|
+
export interface ContentUrlParams {
|
|
27
|
+
/** Content ID (required) */
|
|
28
|
+
id: number | string
|
|
29
|
+
/** Content type (required) */
|
|
30
|
+
type: string
|
|
31
|
+
/** Parent content ID (optional) */
|
|
32
|
+
parentId?: number
|
|
33
|
+
/** Navigation target (optional) */
|
|
34
|
+
navigateTo?: {
|
|
35
|
+
id: number
|
|
36
|
+
}
|
|
37
|
+
/** Brand (drumeo, pianote, guitareo, singeo, playbass) */
|
|
38
|
+
brand?: Brand
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Forum post object for URL generation
|
|
43
|
+
*/
|
|
44
|
+
export interface ForumPostUrlParams {
|
|
45
|
+
/** Brand (drumeo, pianote, etc) */
|
|
46
|
+
brand: Brand
|
|
47
|
+
/** Thread information */
|
|
48
|
+
thread: {
|
|
49
|
+
/** Thread category ID */
|
|
50
|
+
category_id: number
|
|
51
|
+
/** Thread ID */
|
|
52
|
+
id: number
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Playlist object for URL generation
|
|
58
|
+
*/
|
|
59
|
+
export interface PlaylistUrlParams {
|
|
60
|
+
/** Playlist ID */
|
|
61
|
+
id: number
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Comment object for URL generation
|
|
66
|
+
*/
|
|
67
|
+
export interface CommentUrlParams {
|
|
68
|
+
/** Comment ID */
|
|
69
|
+
id: number
|
|
70
|
+
/** Content information */
|
|
71
|
+
content: {
|
|
72
|
+
/** Content ID */
|
|
73
|
+
id: number
|
|
74
|
+
/** Content type */
|
|
75
|
+
type: string
|
|
76
|
+
/** Parent content ID (optional) */
|
|
77
|
+
parentId?: number
|
|
78
|
+
/** Brand */
|
|
79
|
+
brand: Brand
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Generate a frontend URL for content
|
|
85
|
+
*
|
|
86
|
+
* @param params - Content parameters
|
|
87
|
+
* @returns The generated URL path
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* generateContentUrl({ id: 123, type: 'song', brand: 'drumeo' })
|
|
91
|
+
* // Returns: "/drumeo/songs/transcription/123"
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* generateContentUrl({ id: 456, type: 'course-part', parentId: 789, brand: 'pianote' })
|
|
95
|
+
* // Returns: "/pianote/lessons/course/789/456"
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* generateContentUrl({ id: 123, type: 'pack-bundle', navigateTo: { id: 456 }, brand: 'guitareo' })
|
|
99
|
+
* // Returns: "/guitareo/lessons/pack/123/456"
|
|
100
|
+
*/
|
|
101
|
+
export function generateContentUrl({
|
|
102
|
+
id,
|
|
103
|
+
type,
|
|
104
|
+
parentId,
|
|
105
|
+
navigateTo,
|
|
106
|
+
brand = 'drumeo',
|
|
107
|
+
}: ContentUrlParams): string {
|
|
108
|
+
// Special case: method homepage
|
|
109
|
+
if (type === 'method') {
|
|
110
|
+
return `/${brand}/method`
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Return fallback if required params missing
|
|
114
|
+
if (!id || !type) {
|
|
115
|
+
return '#'
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Special cases that don't follow the standard pattern
|
|
119
|
+
if (type === 'live') {
|
|
120
|
+
return `/${brand}/lessons/${id}/live`
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (type === 'pack') {
|
|
124
|
+
return `/${brand}/lessons/pack/overview/${id}`
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (type === 'pack-bundle') {
|
|
128
|
+
if (navigateTo?.id) {
|
|
129
|
+
return `/${brand}/lessons/pack/${id}/${navigateTo.id}`
|
|
130
|
+
}
|
|
131
|
+
// Fallback to overview if navigateTo is missing
|
|
132
|
+
return `/${brand}/lessons/pack/overview/${id}`
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Helper function to build URL with common parameters
|
|
136
|
+
const buildUrl = (typeSegments: string[]): string => {
|
|
137
|
+
const contentId = navigateTo ? `${id}/${navigateTo.id}` : id
|
|
138
|
+
const parentSegment = parentId ? `/${parentId}` : ''
|
|
139
|
+
return `/${brand}/${typeSegments.join('/')}${parentSegment}/${contentId}`
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Determine page type (songs, method, or lessons)
|
|
143
|
+
const songTypes = [
|
|
144
|
+
'song',
|
|
145
|
+
'song-tutorial',
|
|
146
|
+
'song-tutorial-lesson',
|
|
147
|
+
'transcription',
|
|
148
|
+
'play-along',
|
|
149
|
+
'jam-track',
|
|
150
|
+
]
|
|
151
|
+
|
|
152
|
+
const methodTypes = ['learning-path-v2', 'learning-path-lesson-v2']
|
|
153
|
+
|
|
154
|
+
let pageType: string
|
|
155
|
+
if (songTypes.includes(type)) {
|
|
156
|
+
pageType = 'songs'
|
|
157
|
+
} else if (methodTypes.includes(type)) {
|
|
158
|
+
pageType = 'method'
|
|
159
|
+
} else {
|
|
160
|
+
pageType = 'lessons'
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Content type routing - maps specific types to URL segments
|
|
164
|
+
const contentTypeRoutes: Record<string, string> = {
|
|
165
|
+
// Lesson types
|
|
166
|
+
'course-lesson': 'course',
|
|
167
|
+
'guided-course-lesson': 'course',
|
|
168
|
+
'guided-course': 'course',
|
|
169
|
+
'pack-bundle-lesson': 'pack',
|
|
170
|
+
'documentary-lesson': 'documentary',
|
|
171
|
+
'skill-pack-lesson': 'skill-pack',
|
|
172
|
+
|
|
173
|
+
// Method types
|
|
174
|
+
'learning-path-lesson-v2': 'lesson',
|
|
175
|
+
'learning-path-v2': 'lesson',
|
|
176
|
+
|
|
177
|
+
// Song types
|
|
178
|
+
song: 'transcription',
|
|
179
|
+
'song-tutorial': 'tutorial',
|
|
180
|
+
'song-tutorial-lesson': 'tutorial',
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Use specific route if available, otherwise fall back to type as-is
|
|
184
|
+
const contentTypeSegment = contentTypeRoutes[type] || type
|
|
185
|
+
|
|
186
|
+
return buildUrl([pageType, contentTypeSegment])
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Generate a full URL with domain
|
|
191
|
+
*
|
|
192
|
+
* @param params - Content parameters (same as generateContentUrl)
|
|
193
|
+
* @returns Full URL with domain from globalConfig.frontendUrl
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* generateContentUrlWithDomain({ id: 123, type: 'song' })
|
|
197
|
+
* // Returns: "https://www.musora.com/drumeo/songs/transcription/123"
|
|
198
|
+
*/
|
|
199
|
+
export function generateContentUrlWithDomain(params: ContentUrlParams): string {
|
|
200
|
+
const path = generateContentUrl(params)
|
|
201
|
+
|
|
202
|
+
if (path === '#') {
|
|
203
|
+
return '#'
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return globalConfig.frontendUrl + path
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Generate URL for a forum post
|
|
211
|
+
*
|
|
212
|
+
* @param post - Forum post object
|
|
213
|
+
* @param withDomain - Include domain from globalConfig.frontendUrl
|
|
214
|
+
* @returns Forum post URL
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* generateForumPostUrl({ brand: 'drumeo', thread: { category_id: 12, id: 456 }})
|
|
218
|
+
* // Returns: "/drumeo/forums/threads/12/456"
|
|
219
|
+
*/
|
|
220
|
+
export function generateForumPostUrl(
|
|
221
|
+
post: ForumPostUrlParams,
|
|
222
|
+
withDomain: boolean = false
|
|
223
|
+
): string {
|
|
224
|
+
const path = `/${post.brand}/forums/threads/${post.thread.category_id}/${post.thread.id}`
|
|
225
|
+
|
|
226
|
+
if (withDomain) {
|
|
227
|
+
return globalConfig.frontendUrl + path
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return path
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Generate URL for a user playlist
|
|
235
|
+
*
|
|
236
|
+
* @param playlist - Playlist object
|
|
237
|
+
* @param withDomain - Include domain from globalConfig.frontendUrl
|
|
238
|
+
* @returns Playlist URL
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* generatePlaylistUrl({ id: 123 })
|
|
242
|
+
* // Returns: "/playlists/123"
|
|
243
|
+
*/
|
|
244
|
+
export function generatePlaylistUrl(
|
|
245
|
+
playlist: PlaylistUrlParams,
|
|
246
|
+
withDomain: boolean = false
|
|
247
|
+
): string {
|
|
248
|
+
const path = `/playlists/${playlist.id}`
|
|
249
|
+
|
|
250
|
+
if (withDomain) {
|
|
251
|
+
return globalConfig.frontendUrl + path
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return path
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Generate URL for a comment (content URL with anchor)
|
|
259
|
+
*
|
|
260
|
+
* @param comment - Comment object
|
|
261
|
+
* @param withDomain - Include domain from globalConfig.frontendUrl
|
|
262
|
+
* @returns Comment URL with anchor
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* generateCommentUrl({
|
|
266
|
+
* id: 789,
|
|
267
|
+
* content: { id: 123, type: 'song', brand: 'drumeo' }
|
|
268
|
+
* })
|
|
269
|
+
* // Returns: "/drumeo/songs/transcription/123#comment-789"
|
|
270
|
+
*/
|
|
271
|
+
export function generateCommentUrl(
|
|
272
|
+
comment: CommentUrlParams,
|
|
273
|
+
withDomain: boolean = false
|
|
274
|
+
): string {
|
|
275
|
+
if (!comment.content) {
|
|
276
|
+
return '#'
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const contentUrl = generateContentUrl({
|
|
280
|
+
id: comment.content.id,
|
|
281
|
+
type: comment.content.type,
|
|
282
|
+
parentId: comment.content.parentId,
|
|
283
|
+
brand: comment.content.brand,
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
if (contentUrl === '#') {
|
|
287
|
+
return '#'
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const path = `${contentUrl}#comment-${comment.id}`
|
|
291
|
+
|
|
292
|
+
if (withDomain) {
|
|
293
|
+
return globalConfig.frontendUrl + path
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return path
|
|
297
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/HttpClient.test.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/content.test.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/dataContext.test.js
CHANGED
|
File without changes
|
package/test/forum.test.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/initializeTests.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/lib/filter.test.ts
CHANGED
|
File without changes
|