musora-content-services 2.106.1 → 2.107.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/.claude/settings.local.json +19 -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/CHANGELOG.md +17 -0
- package/CLAUDE.md +0 -0
- package/README.md +0 -0
- package/babel.config.cjs +0 -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/index.d.ts +2 -4
- package/src/index.js +2 -4
- package/src/infrastructure/http/HttpClient.ts +4 -3
- 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/brands.ts +0 -0
- package/src/lib/lastUpdated.js +0 -0
- package/src/services/api/types.js +0 -0
- package/src/services/api/types.ts +0 -0
- package/src/services/awards/internal/.indexignore +0 -0
- package/src/services/awards/internal/award-events.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/config.js +0 -0
- package/src/services/content/content.ts +0 -0
- package/src/services/content-org/content-org.js +0 -0
- package/src/services/content-org/guided-courses.ts +1 -1
- package/src/services/content-org/learning-paths.ts +1 -1
- package/src/services/content-org/playlists-types.js +0 -0
- package/src/services/content-org/playlists.js +1 -1
- package/src/services/contentLikes.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/posts.ts +0 -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/README.md +0 -0
- package/src/services/permissions/index.ts +0 -0
- package/src/services/recommendations.js +1 -1
- package/src/services/reporting/README.md +0 -0
- package/src/services/reporting/reporting.ts +0 -0
- package/src/services/reporting/types.ts +0 -0
- package/src/services/sanity.js +4 -4
- 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/index.ts +0 -0
- package/src/services/sync/models/Base.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/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/repository-proxy.ts +0 -0
- package/src/services/sync/resolver.ts +0 -0
- package/src/services/sync/run-scope.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/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/user/account.ts +0 -0
- package/src/services/user/chat.js +1 -1
- package/src/services/user/interests.js +1 -1
- package/src/services/user/management.js +1 -1
- package/src/services/user/notifications.js +1 -1
- package/src/services/user/payments.ts +0 -0
- package/src/services/user/permissions.js +0 -0
- package/src/services/user/profile.js +1 -1
- package/src/services/user/sessions.js +25 -33
- package/src/services/user/types.js +6 -0
- package/src/services/user/user-management-system.js +0 -0
- package/src/services/userActivity.js +29 -10
- 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-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/lib/lastUpdated.test.js +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/streakMessage.test.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/tools/generate-index.cjs +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(find:*)",
|
|
5
|
+
"Bash(docker exec:*)",
|
|
6
|
+
"Bash(npm test:*)",
|
|
7
|
+
"WebSearch",
|
|
8
|
+
"WebFetch(domain:watermelondb.dev)",
|
|
9
|
+
"WebFetch(domain:github.com)",
|
|
10
|
+
"Bash(git checkout:*)",
|
|
11
|
+
"Bash(npm run doc:*)",
|
|
12
|
+
"Bash(cat:*)",
|
|
13
|
+
"Bash(tr:*)",
|
|
14
|
+
"Bash(npm run build-index:*)"
|
|
15
|
+
],
|
|
16
|
+
"deny": [],
|
|
17
|
+
"ask": []
|
|
18
|
+
}
|
|
19
|
+
}
|
package/.coderabbit.yaml
CHANGED
|
File without changes
|
package/.editorconfig
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/.prettierignore
CHANGED
|
File without changes
|
package/.prettierrc
CHANGED
|
File without changes
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
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.107.2](https://github.com/railroadmedia/musora-content-services/compare/v2.107.1...v2.107.2) (2025-12-19)
|
|
6
|
+
|
|
7
|
+
### [2.107.1](https://github.com/railroadmedia/musora-content-services/compare/v2.107.0...v2.107.1) (2025-12-19)
|
|
8
|
+
|
|
9
|
+
## [2.107.0](https://github.com/railroadmedia/musora-content-services/compare/v2.105.0...v2.107.0) (2025-12-19)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* Add some validators prior to writing to watermelon ([#663](https://github.com/railroadmedia/musora-content-services/issues/663)) ([9eeedac](https://github.com/railroadmedia/musora-content-services/commit/9eeedac5a3cf8b4eedd091fcb8252ffd5bae6c85))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* 401 authentication errors for mobile app by reading token lazily from globalConfig at request time instead of at HttpClient instantiation ([99204b3](https://github.com/railroadmedia/musora-content-services/commit/99204b317c806ef8bec6f0846059c82fc7f3b585))
|
|
20
|
+
* Restricted access in recent activities ([7013794](https://github.com/railroadmedia/musora-content-services/commit/7013794f235f350eb30833bf0680bb7bb851af10))
|
|
21
|
+
|
|
5
22
|
### [2.106.1](https://github.com/railroadmedia/musora-content-services/compare/v2.106.0...v2.106.1) (2025-12-18)
|
|
6
23
|
|
|
7
24
|
## [2.106.0](https://github.com/railroadmedia/musora-content-services/compare/v2.105.0...v2.106.0) (2025-12-18)
|
package/CLAUDE.md
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/babel.config.cjs
CHANGED
|
File without changes
|
package/jest.config.js
CHANGED
|
File without changes
|
package/jsdoc.json
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
File without changes
|
package/src/contentMetaData.js
CHANGED
|
File without changes
|
package/src/index.d.ts
CHANGED
|
@@ -396,9 +396,8 @@ import {
|
|
|
396
396
|
} from './services/user/profile.js';
|
|
397
397
|
|
|
398
398
|
import {
|
|
399
|
-
|
|
399
|
+
generateAuthSessionUrl,
|
|
400
400
|
login,
|
|
401
|
-
loginWithAuthKey,
|
|
402
401
|
logout
|
|
403
402
|
} from './services/user/sessions.js';
|
|
404
403
|
|
|
@@ -580,13 +579,13 @@ declare module 'musora-content-services' {
|
|
|
580
579
|
fetchUserPractices,
|
|
581
580
|
findIncompleteLesson,
|
|
582
581
|
followThread,
|
|
582
|
+
generateAuthSessionUrl,
|
|
583
583
|
getActiveDiscussions,
|
|
584
584
|
getActivePath,
|
|
585
585
|
getAllCompleted,
|
|
586
586
|
getAllCompletedByIds,
|
|
587
587
|
getAllStarted,
|
|
588
588
|
getAllStartedOrCompleted,
|
|
589
|
-
getAuthKey,
|
|
590
589
|
getAwardStatistics,
|
|
591
590
|
getCompletedAwards,
|
|
592
591
|
getContentAwards,
|
|
@@ -650,7 +649,6 @@ declare module 'musora-content-services' {
|
|
|
650
649
|
likePost,
|
|
651
650
|
lockThread,
|
|
652
651
|
login,
|
|
653
|
-
loginWithAuthKey,
|
|
654
652
|
logout,
|
|
655
653
|
mapContentToParent,
|
|
656
654
|
markAllNotificationsAsRead,
|
package/src/index.js
CHANGED
|
@@ -400,9 +400,8 @@ import {
|
|
|
400
400
|
} from './services/user/profile.js';
|
|
401
401
|
|
|
402
402
|
import {
|
|
403
|
-
|
|
403
|
+
generateAuthSessionUrl,
|
|
404
404
|
login,
|
|
405
|
-
loginWithAuthKey,
|
|
406
405
|
logout
|
|
407
406
|
} from './services/user/sessions.js';
|
|
408
407
|
|
|
@@ -579,13 +578,13 @@ export {
|
|
|
579
578
|
fetchUserPractices,
|
|
580
579
|
findIncompleteLesson,
|
|
581
580
|
followThread,
|
|
581
|
+
generateAuthSessionUrl,
|
|
582
582
|
getActiveDiscussions,
|
|
583
583
|
getActivePath,
|
|
584
584
|
getAllCompleted,
|
|
585
585
|
getAllCompletedByIds,
|
|
586
586
|
getAllStarted,
|
|
587
587
|
getAllStartedOrCompleted,
|
|
588
|
-
getAuthKey,
|
|
589
588
|
getAwardStatistics,
|
|
590
589
|
getCompletedAwards,
|
|
591
590
|
getContentAwards,
|
|
@@ -649,7 +648,6 @@ export {
|
|
|
649
648
|
likePost,
|
|
650
649
|
lockThread,
|
|
651
650
|
login,
|
|
652
|
-
loginWithAuthKey,
|
|
653
651
|
logout,
|
|
654
652
|
mapContentToParent,
|
|
655
653
|
markAllNotificationsAsRead,
|
|
@@ -74,9 +74,10 @@ export class HttpClient {
|
|
|
74
74
|
headers['Data-Version'] = dataVersion
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
// Add auth token if available
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
// Add auth token if available (check both instance token and global config)
|
|
78
|
+
const token = this.token || globalConfig?.sessionConfig?.token || null
|
|
79
|
+
if (token) {
|
|
80
|
+
headers['Authorization'] = `Bearer ${token}`
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
return headers
|
|
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/lib/brands.ts
CHANGED
|
File without changes
|
package/src/lib/lastUpdated.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
|
package/src/services/config.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module GuidedCourses
|
|
3
3
|
*/
|
|
4
|
-
import { GET, POST } from '../../infrastructure/http/HttpClient.
|
|
4
|
+
import { GET, POST } from '../../infrastructure/http/HttpClient.ts'
|
|
5
5
|
import { contentStatusStarted, getProgressState } from '../contentProgress.js'
|
|
6
6
|
import './playlists-types.js'
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module LearningPaths
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { GET, POST } from '../../infrastructure/http/HttpClient.
|
|
5
|
+
import { GET, POST } from '../../infrastructure/http/HttpClient.ts'
|
|
6
6
|
import { fetchByRailContentId, fetchByRailContentIds, fetchMethodV2Structure } from '../sanity.js'
|
|
7
7
|
import { addContextToLearningPaths } from '../contentAggregator.js'
|
|
8
8
|
import {
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Playlists
|
|
3
3
|
*/
|
|
4
|
-
import { GET, POST, PUT, DELETE } from '../../infrastructure/http/HttpClient.
|
|
4
|
+
import { GET, POST, PUT, DELETE } from '../../infrastructure/http/HttpClient.ts'
|
|
5
5
|
import { getNavigateToForPlaylists } from '../contentAggregator.js'
|
|
6
6
|
import './playlists-types.js'
|
|
7
7
|
|
|
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
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { globalConfig } from './config.js'
|
|
6
|
-
import { GET, HttpClient } from '../infrastructure/http/HttpClient.
|
|
6
|
+
import { GET, HttpClient } from '../infrastructure/http/HttpClient.ts'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Exported functions that are excluded from index generation.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/services/sanity.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from '../contentTypeConfig.js'
|
|
25
25
|
import { fetchSimilarItems } from './recommendations.js'
|
|
26
26
|
import { processMetadata } from '../contentMetaData.js'
|
|
27
|
-
import { GET } from '../infrastructure/http/HttpClient.
|
|
27
|
+
import { GET } from '../infrastructure/http/HttpClient.ts'
|
|
28
28
|
|
|
29
29
|
import { globalConfig } from './config.js'
|
|
30
30
|
|
|
@@ -457,7 +457,8 @@ export async function fetchByRailContentIds(
|
|
|
457
457
|
ids,
|
|
458
458
|
contentType = undefined,
|
|
459
459
|
brand = undefined,
|
|
460
|
-
includePermissionsAndStatusFilter = false
|
|
460
|
+
includePermissionsAndStatusFilter = false,
|
|
461
|
+
filterOptions = {}
|
|
461
462
|
) {
|
|
462
463
|
if (!ids?.length) {
|
|
463
464
|
return []
|
|
@@ -471,7 +472,7 @@ export async function fetchByRailContentIds(
|
|
|
471
472
|
const fields = await getFieldsForContentTypeWithFilteredChildren(contentType, true)
|
|
472
473
|
const baseFilter = `railcontent_id in [${idsString}]${brandFilter}`
|
|
473
474
|
const finalFilter = includePermissionsAndStatusFilter
|
|
474
|
-
? await new FilterBuilder(baseFilter).buildFilter()
|
|
475
|
+
? await new FilterBuilder(baseFilter, filterOptions).buildFilter()
|
|
475
476
|
: baseFilter
|
|
476
477
|
const query = `*[
|
|
477
478
|
${finalFilter}
|
|
@@ -509,7 +510,6 @@ export async function fetchByRailContentIds(
|
|
|
509
510
|
|
|
510
511
|
// Sort results to match the order of the input IDs
|
|
511
512
|
const sortedResults = results?.sort(sortFuction) ?? null
|
|
512
|
-
|
|
513
513
|
return sortedResults
|
|
514
514
|
}
|
|
515
515
|
|
|
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
|
|
File without changes
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module Interests
|
|
3
3
|
*/
|
|
4
4
|
import { globalConfig } from '../config.js'
|
|
5
|
-
import { GET, POST, DELETE } from '../../infrastructure/http/HttpClient.
|
|
5
|
+
import { GET, POST, DELETE } from '../../infrastructure/http/HttpClient.ts'
|
|
6
6
|
import './types.js'
|
|
7
7
|
|
|
8
8
|
const baseUrl = `/api/user-management-system`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module UserManagement
|
|
3
3
|
*/
|
|
4
|
-
import { GET, POST, PUT, DELETE } from '../../infrastructure/http/HttpClient.
|
|
4
|
+
import { GET, POST, PUT, DELETE } from '../../infrastructure/http/HttpClient.ts'
|
|
5
5
|
import { globalConfig } from '../config.js'
|
|
6
6
|
import './types.js'
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module UserNotifications
|
|
3
3
|
*/
|
|
4
|
-
import { GET, PUT, DELETE } from '../../infrastructure/http/HttpClient.
|
|
4
|
+
import { GET, PUT, DELETE } from '../../infrastructure/http/HttpClient.ts'
|
|
5
5
|
import eventsAPI from '../eventsAPI.js'
|
|
6
6
|
import './types.js'
|
|
7
7
|
import {globalConfig} from "../config";
|
|
File without changes
|
|
File without changes
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module UserProfile
|
|
3
3
|
*/
|
|
4
4
|
import { globalConfig } from '../config.js'
|
|
5
|
-
import { GET, DELETE } from '../../infrastructure/http/HttpClient.
|
|
5
|
+
import { GET, DELETE } from '../../infrastructure/http/HttpClient.ts'
|
|
6
6
|
import { calculateLongestStreaks } from '../userActivity.js'
|
|
7
7
|
import './types.js'
|
|
8
8
|
|
|
@@ -98,50 +98,42 @@ export async function logout() {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
* @param {
|
|
102
|
-
* @
|
|
101
|
+
* @param {number} userId
|
|
102
|
+
* @param {string} redirectTo
|
|
103
|
+
* @returns {Promise<string>}
|
|
103
104
|
*
|
|
104
105
|
* @example
|
|
105
|
-
*
|
|
106
|
-
* .then(response => {
|
|
107
|
-
* const authKey = response.data
|
|
108
|
-
* const webViewUrl = `https://app.musora.com/page?user_id=${userId}&auth_key=${authKey}`
|
|
109
|
-
* })
|
|
110
|
-
* .catch(error => console.error(error));
|
|
106
|
+
* const authUrl = await generateAuthSessionUrl(592656, 'https://app.musora.com/drumeo')
|
|
111
107
|
*/
|
|
112
|
-
export async function
|
|
108
|
+
export async function generateAuthSessionUrl(userId, redirectTo) {
|
|
113
109
|
const baseUrl = `${globalConfig.baseUrl}/api/user-management-system`
|
|
114
|
-
const url = brand ? `${baseUrl}/v1/auth-key?brand=${brand}` : `${baseUrl}/v1/auth-key`
|
|
115
110
|
|
|
116
|
-
const
|
|
111
|
+
const headers = {
|
|
112
|
+
'Content-Type': 'application/json',
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (globalConfig.isMA) {
|
|
116
|
+
headers.Authorization = `Bearer ${globalConfig.sessionConfig.authToken}`
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const response = await fetch(`${baseUrl}/v1/auth-key`, {
|
|
117
120
|
method: 'GET',
|
|
118
|
-
headers
|
|
119
|
-
|
|
120
|
-
'Content-Type': 'application/json',
|
|
121
|
-
},
|
|
121
|
+
headers,
|
|
122
|
+
credentials: globalConfig.isMA ? undefined : 'include',
|
|
122
123
|
})
|
|
123
124
|
|
|
124
125
|
if (!response.ok) {
|
|
125
|
-
throw new Error(`Failed to
|
|
126
|
+
throw new Error(`Failed to generate auth key: ${response.status}`)
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
const authKeyResponse = await response.json()
|
|
130
|
+
const authKey = authKeyResponse.data || authKeyResponse.auth_key
|
|
130
131
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
headers: {
|
|
136
|
-
'Content-Type': 'application/json',
|
|
137
|
-
Authorization: null,
|
|
138
|
-
},
|
|
139
|
-
body: JSON.stringify({
|
|
140
|
-
user_id: userId,
|
|
141
|
-
auth_key: authKey,
|
|
142
|
-
device_name: deviceName,
|
|
143
|
-
device_token: deviceToken,
|
|
144
|
-
platform: platform,
|
|
145
|
-
}),
|
|
132
|
+
const params = new URLSearchParams({
|
|
133
|
+
user_id: userId.toString(),
|
|
134
|
+
auth_key: authKey,
|
|
135
|
+
redirect_to: redirectTo,
|
|
146
136
|
})
|
|
137
|
+
|
|
138
|
+
return `${baseUrl}/v1/sessions/auth-key?${params.toString()}`
|
|
147
139
|
}
|
|
File without changes
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
fetchUserPracticeNotes,
|
|
9
9
|
fetchRecentUserActivities,
|
|
10
10
|
} from './railcontent'
|
|
11
|
-
import { GET, POST, PUT, DELETE } from '../infrastructure/http/HttpClient.
|
|
11
|
+
import { GET, POST, PUT, DELETE } from '../infrastructure/http/HttpClient.ts'
|
|
12
12
|
import { DataContext, UserActivityVersionKey } from './dataContext.js'
|
|
13
13
|
import {
|
|
14
14
|
fetchByRailContentId,
|
|
@@ -539,14 +539,26 @@ export async function getPracticeNotes(date) {
|
|
|
539
539
|
export async function getRecentActivity({ page = 1, limit = 5, tabName = null } = {}) {
|
|
540
540
|
const recentActivityData = await fetchRecentUserActivities({ page, limit, tabName })
|
|
541
541
|
const contentIds = recentActivityData.data.map((p) => p.contentId).filter((id) => id !== null)
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
542
|
+
|
|
543
|
+
const contents = await addContextToContent(
|
|
544
|
+
fetchByRailContentIds,
|
|
545
|
+
contentIds,
|
|
546
|
+
'progress-tracker',
|
|
547
|
+
undefined,
|
|
548
|
+
true,
|
|
549
|
+
{ bypassPermissions: true },
|
|
550
|
+
{
|
|
551
|
+
addNavigateTo: true,
|
|
552
|
+
addNextLesson: true,
|
|
553
|
+
}
|
|
554
|
+
)
|
|
555
|
+
|
|
546
556
|
recentActivityData.data = recentActivityData.data.map((practice) => {
|
|
547
557
|
const content = contents?.find((c) => c.id === practice.contentId) || {}
|
|
548
558
|
return {
|
|
549
559
|
...practice,
|
|
560
|
+
thumbnail: content.thumbnail,
|
|
561
|
+
title: content.title,
|
|
550
562
|
parent_id: content.parent_id || null,
|
|
551
563
|
navigateTo: content.navigateTo,
|
|
552
564
|
}
|
|
@@ -796,10 +808,18 @@ export async function calculateLongestStreaks(userId = globalConfig.sessionConfi
|
|
|
796
808
|
|
|
797
809
|
async function formatPracticeMeta(practices = []) {
|
|
798
810
|
const contentIds = practices.map((p) => p.content_id).filter((id) => id !== null)
|
|
799
|
-
const contents = await addContextToContent(
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
811
|
+
const contents = await addContextToContent(
|
|
812
|
+
fetchByRailContentIds,
|
|
813
|
+
contentIds,
|
|
814
|
+
'progress-tracker',
|
|
815
|
+
undefined,
|
|
816
|
+
true,
|
|
817
|
+
{ bypassPermissions: true },
|
|
818
|
+
{
|
|
819
|
+
addNavigateTo: true,
|
|
820
|
+
addNextLesson: true,
|
|
821
|
+
}
|
|
822
|
+
)
|
|
803
823
|
|
|
804
824
|
return practices.map((practice) => {
|
|
805
825
|
const content =
|
|
@@ -1111,7 +1131,6 @@ async function processContentItem(content) {
|
|
|
1111
1131
|
ctaText = 'Revisit Show'
|
|
1112
1132
|
}
|
|
1113
1133
|
}
|
|
1114
|
-
console.log('Progress Timestamp', content.progressTimestamp)
|
|
1115
1134
|
return {
|
|
1116
1135
|
id: content.id,
|
|
1117
1136
|
progressType: 'content',
|
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
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/localStorageMock.js
CHANGED
|
File without changes
|
package/test/log.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
|
package/tools/generate-index.cjs
CHANGED
|
File without changes
|