musora-content-services 2.167.2 → 2.167.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/.agent/decisions/2026-07-20-mu2-1724-songs-lessons-counts.md +33 -0
- package/.agent/decisions/2026-07-20-query-builder-tostring.md +37 -0
- package/.idea/codeStyles/Project.xml +61 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/modules.xml +8 -0
- package/.idea/musora-content-services.iml +8 -0
- package/.idea/php.xml +19 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +7 -0
- package/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +10 -0
- package/package.json +2 -1
- package/src/contentTypeConfig.js +1 -0
- package/src/lib/sanity/query.ts +5 -0
- package/src/services/config.js +15 -0
- package/src/services/content/artist.ts +1 -3
- package/src/services/content/counts.ts +47 -0
- package/src/services/content/genre.ts +1 -3
- package/src/services/content/instructor.ts +1 -3
- package/src/services/multi-user-accounts/multi-user-accounts.ts +1 -0
- package/src/services/userActivity.js +2 -0
- package/src/version-info.js +1 -0
- package/.claude/settings.local.json +0 -53
- package/test/initializeTests.js +0 -60
- package/test/integration/awards/award-exclusion-handling.test.ts +0 -275
- package/test/integration/awards/internal/image-utils.test.ts +0 -86
- package/test/integration/content-progress/__mocks__/mocks.ts +0 -104
- package/test/integration/content-progress/contentProgress.test.ts +0 -335
- package/test/integration/content-progress/e2eOfflineProgress.test.ts +0 -352
- package/test/integration/content-progress/e2eProgress.test.ts +0 -612
- package/test/integration/content-progress/getters.test.ts +0 -334
- package/test/integration/content-progress/helpers.test.ts +0 -263
- package/test/integration/content-progress/offlineContentProgress.test.ts +0 -226
- package/test/integration/forums.test.ts +0 -209
- package/test/integration/infrastructure/FetchRequestExecutor.test.ts +0 -88
- package/test/integration/initializeTestDB.ts +0 -80
- package/test/integration/learning-paths.test.ts +0 -854
- package/test/integration/notifications.test.ts +0 -178
- package/test/integration/progress-row/content-card.test.ts +0 -283
- package/test/integration/sync/adapters/idb-errors.test.ts +0 -144
- package/test/integration/sync/adapters/sqlite-errors.test.ts +0 -173
- package/test/integration/sync/fetch.test.ts +0 -224
- package/test/integration/sync/repositories/content-likes.test.ts +0 -99
- package/test/integration/sync/repositories/practices.test.ts +0 -179
- package/test/integration/sync/repositories/progress.test.ts +0 -245
- package/test/integration/sync/repositories/user-award-progress.static.test.ts +0 -68
- package/test/integration/sync/repositories/user-award-progress.test.ts +0 -387
- package/test/integration/sync/store/cross-user-protection.test.ts +0 -217
- package/test/integration/sync/store/store-idb.test.ts +0 -180
- package/test/integration/sync/store/store.test.ts +0 -361
- package/test/integration/user/permissions.test.js +0 -20
- package/test/integration/userActivity.test.ts +0 -102
- package/test/live/README.md +0 -29
- package/test/live/content.test.js +0 -116
- package/test/localStorageMock.js +0 -21
- package/test/log.js +0 -5
- package/test/mockData/award-definitions.js +0 -171
- package/test/mockData/mockData_fetchByRailContentIds_one_content.json +0 -35
- package/test/mockData/mockData_progress_content.json +0 -182
- package/test/mockData/mockData_sanity_progress_content.json +0 -1451
- package/test/mockData/mockData_user_practices.json +0 -9
- package/test/setupConsole.js +0 -6
- package/test/setupNetworkGuard.js +0 -3
- package/test/setupTimers.js +0 -13
- package/test/unit/HttpClient.test.ts +0 -267
- package/test/unit/awards/award-alacarte-observer.test.ts +0 -199
- package/test/unit/awards/award-auto-refresh.test.ts +0 -84
- package/test/unit/awards/award-calculations.test.ts +0 -34
- package/test/unit/awards/award-callbacks.test.ts +0 -144
- package/test/unit/awards/award-certificate-display.test.ts +0 -330
- package/test/unit/awards/award-collection-edge-cases.test.ts +0 -212
- package/test/unit/awards/award-collection-filtering.test.ts +0 -287
- package/test/unit/awards/award-completion-flow.test.ts +0 -306
- package/test/unit/awards/award-multi-lesson.test.ts +0 -243
- package/test/unit/awards/award-observer-integration.test.ts +0 -327
- package/test/unit/awards/award-query-messages.test.ts +0 -448
- package/test/unit/awards/award-user-collection.test.ts +0 -416
- package/test/unit/awards/duplicate-prevention.test.ts +0 -120
- package/test/unit/awards/helpers/completion-mock.ts +0 -56
- package/test/unit/awards/helpers/index.ts +0 -3
- package/test/unit/awards/helpers/mock-setup.ts +0 -79
- package/test/unit/awards/helpers/progress-emitter.ts +0 -45
- package/test/unit/awards/message-generator.test.ts +0 -162
- package/test/unit/content-progress/bubbleTrickle.test.ts +0 -322
- package/test/unit/content-progress/helpers.test.ts +0 -329
- package/test/unit/content-progress/navigateTo.test.ts +0 -392
- package/test/unit/contentLikes.test.ts +0 -62
- package/test/unit/contentMetaData.test.ts +0 -58
- package/test/unit/dataContext.test.ts +0 -38
- package/test/unit/dateUtils.test.ts +0 -188
- package/test/unit/endScreen.test.js +0 -712
- package/test/unit/eventsAPI.test.ts +0 -159
- package/test/unit/imageSRCBuilder.test.ts +0 -37
- package/test/unit/imageSRCVerify.test.ts +0 -155
- package/test/unit/infrastructure/DefaultHeaderProvider.test.ts +0 -39
- package/test/unit/infrastructure/sanity/ContentClient.test.ts +0 -168
- package/test/unit/infrastructure/sanity/DefaultConfigProvider.test.ts +0 -93
- package/test/unit/infrastructure/sanity/FetchQueryExecutor.test.ts +0 -174
- package/test/unit/infrastructure/sanity/SanityClient.test.ts +0 -140
- package/test/unit/lib/__snapshots__/filter.test.ts.snap +0 -5
- package/test/unit/lib/filter.test.ts +0 -1154
- package/test/unit/lib/lastUpdated.test.ts +0 -21
- package/test/unit/lib/query.test.ts +0 -1469
- package/test/unit/lib/sanity/decorators/base.test.ts +0 -368
- package/test/unit/lib/sanity/decorators/navigate-to.test.ts +0 -361
- package/test/unit/lib/sanity/decorators/need-access.test.ts +0 -89
- package/test/unit/lib/sanity/decorators/need-lifetime-upgrade.test.ts +0 -85
- package/test/unit/lib/sanity/decorators/page-type.test.ts +0 -81
- package/test/unit/playerSettings.test.ts +0 -73
- package/test/unit/progress-row/content-card.test.ts +0 -314
- package/test/unit/progress-row/playlist-card.test.ts +0 -104
- package/test/unit/progressRows.test.ts +0 -243
- package/test/unit/recommendations.test.js +0 -47
- package/test/unit/sanityQueryService.test.ts +0 -200
- package/test/unit/search.test.ts +0 -44
- package/test/unit/sentry.test.ts +0 -62
- package/test/unit/services/progress-internal/bubble.test.ts +0 -279
- package/test/unit/services/progress.test.ts +0 -396
- package/test/unit/streakMessage.test.ts +0 -251
- package/test/unit/sync/context.test.ts +0 -51
- package/test/unit/sync/effects/logout-warning.test.ts +0 -158
- package/test/unit/sync/effects/push-failure-notification.test.ts +0 -196
- package/test/unit/sync/errors/sync-errors.test.ts +0 -106
- package/test/unit/sync/errors/validators.test.ts +0 -61
- package/test/unit/sync/helpers/TestModel.ts +0 -44
- package/test/unit/sync/helpers/index.ts +0 -172
- package/test/unit/sync/manager.test.ts +0 -303
- package/test/unit/sync/models/user-award-progress.test.ts +0 -82
- package/test/unit/sync/resolver.test.ts +0 -229
- package/test/unit/sync/retry.test.ts +0 -314
- package/test/unit/sync/run-scope.test.ts +0 -23
- package/test/unit/sync/stale-record-cleanup.test.ts +0 -107
- package/test/unit/sync/store/push-coalescer.test.ts +0 -156
- package/test/unit/sync/store-configs.test.ts +0 -37
- package/test/unit/sync/telemetry/sync-telemetry.test.ts +0 -118
- package/test/unit/sync/utils/event-emitter.test.ts +0 -64
- package/test/unit/sync/utils/throttle.test.ts +0 -245
- package/test/unit/url-builder.test.ts +0 -72
- package/test/unit/user/account.test.ts +0 -66
- package/test/unit/user/permissions.test.js +0 -191
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
date: 2026-07-20
|
|
3
|
+
branch: chore/MU2-1724-songs-lessons-counts
|
|
4
|
+
pr: https://github.com/railroadmedia/musora-content-services/pull/1012
|
|
5
|
+
status: open
|
|
6
|
+
tags: [[chore]]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Song and lesson counts query
|
|
10
|
+
|
|
11
|
+
## Context
|
|
12
|
+
Needed a way to get the total number of songs vs. individual playable lessons in Sanity, globally or scoped to a brand. Content types don't map 1:1 onto "song" vs "lesson" — songs include `song`, `play-along`, `jam-track`, `song-tutorial-lesson` per `SONG_TYPES` in `contentTypeConfig.js`, and a "lesson" is any published, top-level (no `parent_type` / empty `parent_content_reference`) document with a `railcontent_id`, regardless of `_type`. The final filter definitions came out of a discussion with teammates, converging on `status == 'published' && defined(railcontent_id)` plus the parent-less check for lessons.
|
|
13
|
+
|
|
14
|
+
## Decision
|
|
15
|
+
Added `fetchSongAndLessonCounts(brand?)` in `src/services/content/counts.ts`, returning `{ songs, lessons, total }`.
|
|
16
|
+
- Filter logic built with the `Filters` helper (`src/lib/sanity/filter.ts`) and `query()` builder (`src/lib/sanity/query.ts`) instead of hand-interpolated GROQ strings, for consistency with `artist.ts`/`genre.ts`/`instructor.ts`.
|
|
17
|
+
- Query executed via `SanityClient.executeQuery` (`src/infrastructure/sanity/SanityClient.ts`) rather than the legacy `fetchSanity` in `sanity.js` — `executeQuery` returns the raw object result directly, which fits an object-shaped `{songs, lessons}` GROQ query better than `fetchSanity`'s array-oriented `isList` handling.
|
|
18
|
+
- `total` is computed in application code (`songs + lessons`) after the query resolves, not inside GROQ, keeping the query itself to two independent counts.
|
|
19
|
+
- Kept `content.ts` as a types-only file (its original purpose) — the new function and its `SongAndLessonCounts` interface live in the new `counts.ts` file instead, matching the one-file-per-concern convention in `src/services/content/`.
|
|
20
|
+
|
|
21
|
+
## Alternatives Considered
|
|
22
|
+
- Hand-built GROQ query with `${brand}` string interpolation (the version worked out iteratively with the Sanity MCP) — rejected in favor of the `Filters`/`query` builder for composability and to match existing code style.
|
|
23
|
+
- A fluent `.then().then()` chain for the `total` calculation — tried during review, rejected as unnecessary indirection versus a plain `await` + object literal; reverted to match house style (`artist.ts`, `sanity.js` use plain `await` throughout).
|
|
24
|
+
- Putting the function directly in `content.ts` — rejected once it became clear that file is types-only elsewhere in the codebase; moved to a dedicated `counts.ts`.
|
|
25
|
+
|
|
26
|
+
## Process Notes
|
|
27
|
+
- `course` vs `course-lesson`: `course` is the parent course entity, `course-lesson` is the individual playable video inside it — easy to conflate when first scoping "lesson" types.
|
|
28
|
+
- Lesson types span several groupings in `contentTypeConfig.js` (`individualLessonsTypes`, `entertainmentLessonTypes`, `skill-pack-lesson`, `guided-course-lesson`, `pack-bundle-lesson`, live/student archive types) — rather than enumerate all `_type` values, the final query avoids the type-list entirely and instead filters on the structural "no parent" condition, which is more robust to new content types being added later.
|
|
29
|
+
- `pack-bundle-lesson` appears in `SINGLE_PARENT_TYPES` but nowhere else in `contentTypeConfig.js` — possibly legacy/unused; not specifically verified against the live Sanity schema.
|
|
30
|
+
|
|
31
|
+
## Consequences
|
|
32
|
+
- New public function `fetchSongAndLessonCounts` exported from `src/services/content/counts.ts`; needs `npm run build-index` to surface in the generated package index/types.
|
|
33
|
+
- Introduces the first consumer of `SanityClient.executeQuery` outside `src/infrastructure/sanity/` — establishes a pattern for future count/aggregate-style queries to use the client class over `fetchSanity`.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
date: 2026-07-20
|
|
3
|
+
branch: chore/query-builder-tostring
|
|
4
|
+
pr: https://github.com/railroadmedia/musora-content-services/pull/1013
|
|
5
|
+
status: open
|
|
6
|
+
tags: [[chore]]
|
|
7
|
+
related: [[2026-07-20-mu2-1724-songs-lessons-counts]]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# QueryBuilder toString()
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
`fetchSongAndLessonCounts` (added in `chore/MU2-1724-songs-lessons-counts`) interpolates `query().and(filter)` builders directly into a GROQ template literal, e.g. `` count(${query().and(songsFilter).build()}) ``. The trailing `.build()` at each interpolation site is boilerplate — the same pattern repeats in `artist.ts`, `genre.ts`, and `instructor.ts` wherever a builder's output lands inside a template literal.
|
|
14
|
+
|
|
15
|
+
## Decision
|
|
16
|
+
Added `toString(): string` to `QueryBuilder` (`src/lib/sanity/query.ts`), implemented as `return builder.build()`. JS automatically calls `toString()` during string coercion — template literals, `+` concat, `String(x)` — so a builder can now be interpolated directly: `` count(${query().and(filter)}) ``. This mirrors PHP's `Stringable` interface / Java's `toString()` override.
|
|
17
|
+
|
|
18
|
+
Swept the existing call sites to drop the now-redundant `.build()`:
|
|
19
|
+
- `counts.ts`: both `count(${...})` interpolations.
|
|
20
|
+
- `artist.ts`, `genre.ts`, `instructor.ts`: the `data`/`total` variables that are built once and interpolated later into a `q` template literal.
|
|
21
|
+
|
|
22
|
+
Left `.build()` in place at the one call shape that isn't string interpolation: `fetchArtistBySlug`/`fetchGenreBySlug`/`fetchInstructorBySlug` build `q` and pass it directly as `fetchSanity(q, ...)`'s first argument. Runtime-wise this would also work fine without `.build()` (`encodeURIComponent` inside `fetchSanity` coerces via `ToString` too), but keeping the explicit call there reads clearer for a variable that's a function argument rather than a string-interpolation target.
|
|
23
|
+
|
|
24
|
+
`.build()` itself was not removed or deprecated — this is purely additive, both call styles remain valid.
|
|
25
|
+
|
|
26
|
+
## Alternatives Considered
|
|
27
|
+
- Removing `.build()` everywhere unconditionally, including the `fetchArtistBySlug`-style direct-argument calls — rejected to keep those call sites' typing/intent explicit (a `q` meant to be "the query string" reads oddly as a `QueryBuilder` object until it's coerced at the call boundary).
|
|
28
|
+
- `Symbol.toPrimitive` instead of plain `toString()` — unnecessary; nothing here needs numeric coercion, and plain `toString()` fully covers the template-literal/`String()`/concat cases that matter.
|
|
29
|
+
|
|
30
|
+
## Process Notes
|
|
31
|
+
- Caveat surfaced during review: `JSON.stringify(builder)` does NOT trigger `toString()` — it serializes the object's own enumerable properties instead. Anywhere a builder might end up inside `JSON.stringify`, this would silently produce the wrong output. Not currently a problem (no such call site exists), but worth remembering if a future call site does this.
|
|
32
|
+
- Equality checks (`===`) never coerce, so comparing two builders directly still won't compare their query strings.
|
|
33
|
+
- This PR is stacked on `chore/MU2-1724-songs-lessons-counts` (PR #1012, unmerged) rather than targeting `main` directly, since it builds on that branch's `counts.ts`. PR base should be retargeted to `main` once #1012 merges.
|
|
34
|
+
|
|
35
|
+
## Consequences
|
|
36
|
+
- `QueryBuilder` consumers can now interpolate a builder directly into a template literal without remembering to call `.build()` — reduces boilerplate at future call sites.
|
|
37
|
+
- No behavior change: verified via the full test suite (70 suites) after the sweep, plus an intentional break-and-revert of both `toString()` and the `counts.ts` total-summation logic to confirm the new tests actually catch regressions.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<component name="ProjectCodeStyleConfiguration">
|
|
2
|
+
<code_scheme name="Project" version="173">
|
|
3
|
+
<HTMLCodeStyleSettings>
|
|
4
|
+
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
|
5
|
+
</HTMLCodeStyleSettings>
|
|
6
|
+
<JSCodeStyleSettings version="0">
|
|
7
|
+
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
|
|
8
|
+
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
9
|
+
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
10
|
+
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
11
|
+
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
12
|
+
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
|
13
|
+
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
14
|
+
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
15
|
+
</JSCodeStyleSettings>
|
|
16
|
+
<TypeScriptCodeStyleSettings version="0">
|
|
17
|
+
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
|
|
18
|
+
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
19
|
+
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
20
|
+
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
21
|
+
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
22
|
+
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
|
23
|
+
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
24
|
+
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
25
|
+
</TypeScriptCodeStyleSettings>
|
|
26
|
+
<VueCodeStyleSettings>
|
|
27
|
+
<option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
|
|
28
|
+
<option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
|
|
29
|
+
</VueCodeStyleSettings>
|
|
30
|
+
<codeStyleSettings language="HTML">
|
|
31
|
+
<option name="SOFT_MARGINS" value="100" />
|
|
32
|
+
<indentOptions>
|
|
33
|
+
<option name="INDENT_SIZE" value="2" />
|
|
34
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
35
|
+
<option name="TAB_SIZE" value="2" />
|
|
36
|
+
</indentOptions>
|
|
37
|
+
</codeStyleSettings>
|
|
38
|
+
<codeStyleSettings language="JavaScript">
|
|
39
|
+
<option name="SOFT_MARGINS" value="100" />
|
|
40
|
+
<indentOptions>
|
|
41
|
+
<option name="INDENT_SIZE" value="2" />
|
|
42
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
43
|
+
<option name="TAB_SIZE" value="2" />
|
|
44
|
+
</indentOptions>
|
|
45
|
+
</codeStyleSettings>
|
|
46
|
+
<codeStyleSettings language="TypeScript">
|
|
47
|
+
<option name="SOFT_MARGINS" value="100" />
|
|
48
|
+
<indentOptions>
|
|
49
|
+
<option name="INDENT_SIZE" value="2" />
|
|
50
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
51
|
+
<option name="TAB_SIZE" value="2" />
|
|
52
|
+
</indentOptions>
|
|
53
|
+
</codeStyleSettings>
|
|
54
|
+
<codeStyleSettings language="Vue">
|
|
55
|
+
<option name="SOFT_MARGINS" value="100" />
|
|
56
|
+
<indentOptions>
|
|
57
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
58
|
+
</indentOptions>
|
|
59
|
+
</codeStyleSettings>
|
|
60
|
+
</code_scheme>
|
|
61
|
+
</component>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/musora-content-services.iml" filepath="$PROJECT_DIR$/.idea/musora-content-services.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="inheritedJdk" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
</module>
|
package/.idea/php.xml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="MessDetectorOptionsConfiguration">
|
|
4
|
+
<option name="transferred" value="true" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="PHPCSFixerOptionsConfiguration">
|
|
7
|
+
<option name="transferred" value="true" />
|
|
8
|
+
</component>
|
|
9
|
+
<component name="PHPCodeSnifferOptionsConfiguration">
|
|
10
|
+
<option name="highlightLevel" value="WARNING" />
|
|
11
|
+
<option name="transferred" value="true" />
|
|
12
|
+
</component>
|
|
13
|
+
<component name="PhpStanOptionsConfiguration">
|
|
14
|
+
<option name="transferred" value="true" />
|
|
15
|
+
</component>
|
|
16
|
+
<component name="PsalmOptionsConfiguration">
|
|
17
|
+
<option name="transferred" value="true" />
|
|
18
|
+
</component>
|
|
19
|
+
</project>
|
package/.idea/vcs.xml
ADDED
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
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.167.4](https://github.com/railroadmedia/musora-content-services/compare/v2.167.3...v2.167.4) (2026-07-22)
|
|
6
|
+
|
|
7
|
+
### [2.167.3](https://github.com/railroadmedia/musora-content-services/compare/v2.167.2...v2.167.3) (2026-07-22)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* add gen-version script ([#1015](https://github.com/railroadmedia/musora-content-services/issues/1015)) ([c047e38](https://github.com/railroadmedia/musora-content-services/commit/c047e38f5a20d34dc9a69e2eb3cf3f31861aa8f1))
|
|
13
|
+
* **BR-819:** add learning path id for learning path intro in recent a… ([#1008](https://github.com/railroadmedia/musora-content-services/issues/1008)) ([267423f](https://github.com/railroadmedia/musora-content-services/commit/267423f525ee12824acfe45e771fd2271d566ed6))
|
|
14
|
+
|
|
5
15
|
### [2.167.2](https://github.com/railroadmedia/musora-content-services/compare/v2.167.1...v2.167.2) (2026-07-17)
|
|
6
16
|
|
|
7
17
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "musora-content-services",
|
|
3
|
-
"version": "2.167.
|
|
3
|
+
"version": "2.167.4",
|
|
4
4
|
"description": "A package for Musoras content services ",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
+
"prepare": "node scripts/gen-version.cjs",
|
|
8
9
|
"build-index": "node tools/generate-index.cjs",
|
|
9
10
|
"release": "standard-version",
|
|
10
11
|
"doc": "jsdoc -c jsdoc.json --verbose",
|
package/src/contentTypeConfig.js
CHANGED
|
@@ -433,6 +433,7 @@ export let contentTypeConfig = {
|
|
|
433
433
|
`"badge" : ${contentAwardField}.badge.asset->url`,
|
|
434
434
|
`"badge_rear" : ${contentAwardField}.badge_rear.asset->url`,
|
|
435
435
|
`"badge_logo" : ${contentAwardField}.logo.asset->url`,
|
|
436
|
+
'"learning_path_id": *[_type == "learning-path-v2" && references(^._id)][0].railcontent_id',
|
|
436
437
|
],
|
|
437
438
|
includeChildFields: true,
|
|
438
439
|
},
|
package/src/lib/sanity/query.ts
CHANGED
|
@@ -32,6 +32,7 @@ export interface QueryBuilder {
|
|
|
32
32
|
dereference(): QueryBuilder
|
|
33
33
|
postFilter(expr: string): QueryBuilder
|
|
34
34
|
build(): string
|
|
35
|
+
toString(): string
|
|
35
36
|
|
|
36
37
|
_state(): QueryBuilderState
|
|
37
38
|
}
|
|
@@ -148,6 +149,10 @@ export const query = (selector?: string): QueryBuilder => {
|
|
|
148
149
|
`.trim()
|
|
149
150
|
},
|
|
150
151
|
|
|
152
|
+
toString() {
|
|
153
|
+
return builder.build()
|
|
154
|
+
},
|
|
155
|
+
|
|
151
156
|
_state() {
|
|
152
157
|
return state
|
|
153
158
|
},
|
package/src/services/config.js
CHANGED
|
@@ -72,6 +72,21 @@ const excludeFromGeneratedIndex = []
|
|
|
72
72
|
* appEnv: 'local'
|
|
73
73
|
* });
|
|
74
74
|
*/
|
|
75
|
+
export async function getMCSVersion() {
|
|
76
|
+
try {
|
|
77
|
+
const { MCS_VERSION } = await import('../version-info.js')
|
|
78
|
+
return MCS_VERSION
|
|
79
|
+
} catch {
|
|
80
|
+
return null
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (process.env.NODE_ENV === 'development') {
|
|
85
|
+
getMCSVersion().then(v => v && console.log('[MCS] last tagged version:', v))
|
|
86
|
+
} else {
|
|
87
|
+
getMCSVersion().then(v => v && console.log('[MCS] version:', v))
|
|
88
|
+
}
|
|
89
|
+
|
|
75
90
|
export function initializeService(config) {
|
|
76
91
|
globalConfig.sanityConfig = config.sanityConfig
|
|
77
92
|
globalConfig.railcontentConfig = config.railcontentConfig
|
|
@@ -50,7 +50,6 @@ export async function fetchArtists(
|
|
|
50
50
|
`"lesson_count": ${await f.lessonCount(brand)}`
|
|
51
51
|
)
|
|
52
52
|
.postFilter(postFilter)
|
|
53
|
-
.build()
|
|
54
53
|
|
|
55
54
|
const q = `{
|
|
56
55
|
"data": ${data},
|
|
@@ -152,9 +151,8 @@ export async function fetchArtistLessons(
|
|
|
152
151
|
.order(sort)
|
|
153
152
|
.slice(offset, limit)
|
|
154
153
|
.select((await getFieldsForContentTypeWithFilteredChildren(contentType, true)) as string)
|
|
155
|
-
.build()
|
|
156
154
|
|
|
157
|
-
const total = query().and(restrictions)
|
|
155
|
+
const total = query().and(restrictions)
|
|
158
156
|
|
|
159
157
|
const q = `{
|
|
160
158
|
"data": ${data},
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SONG_TYPES } from '../../contentTypeConfig.js'
|
|
2
|
+
import { SanityClient } from '../../infrastructure/sanity/SanityClient'
|
|
3
|
+
import { Brands } from '../../lib/brands'
|
|
4
|
+
import { Filters as f } from '../../lib/sanity/filter'
|
|
5
|
+
import { query } from '../../lib/sanity/query'
|
|
6
|
+
|
|
7
|
+
const sanityClient = new SanityClient()
|
|
8
|
+
|
|
9
|
+
export interface SongAndLessonCounts {
|
|
10
|
+
songs: number
|
|
11
|
+
lessons: number
|
|
12
|
+
total: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {Brands|string} [brand] - Filters by brand; omit for a global count.
|
|
17
|
+
* @returns {Promise<SongAndLessonCounts>}
|
|
18
|
+
*/
|
|
19
|
+
export async function fetchSongAndLessonCounts(
|
|
20
|
+
brand?: Brands | string
|
|
21
|
+
): Promise<SongAndLessonCounts> {
|
|
22
|
+
const songsFilter = await f.combineAsync(
|
|
23
|
+
f.typeIn(SONG_TYPES),
|
|
24
|
+
f.statusIn(['published']),
|
|
25
|
+
f.defined('railcontent_id'),
|
|
26
|
+
brand ? f.brand(brand) : f.empty
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const lessonsFilter = await f.combineAsync(
|
|
30
|
+
f.defined('railcontent_id'),
|
|
31
|
+
f.statusIn(['published']),
|
|
32
|
+
f.combineOr(f.notDefined('parent_type'), 'count(parent_content_reference) == 0'),
|
|
33
|
+
brand ? f.brand(brand) : f.empty
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
const q = `{
|
|
37
|
+
"songs": count(${query().and(songsFilter)}),
|
|
38
|
+
"lessons": count(${query().and(lessonsFilter)})
|
|
39
|
+
}`
|
|
40
|
+
|
|
41
|
+
const counts = (await sanityClient.executeQuery<Omit<SongAndLessonCounts, 'total'>>(q)) ?? {
|
|
42
|
+
songs: 0,
|
|
43
|
+
lessons: 0,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { ...counts, total: counts.songs + counts.lessons }
|
|
47
|
+
}
|
|
@@ -50,7 +50,6 @@ export async function fetchGenres(
|
|
|
50
50
|
`"lesson_count": ${await f.lessonCount(brand)}`
|
|
51
51
|
)
|
|
52
52
|
.postFilter(postFilter)
|
|
53
|
-
.build()
|
|
54
53
|
|
|
55
54
|
const q = `{
|
|
56
55
|
"data": ${data},
|
|
@@ -151,9 +150,8 @@ export async function fetchGenreLessons(
|
|
|
151
150
|
.order(sort)
|
|
152
151
|
.slice(offset, limit)
|
|
153
152
|
.select((await getFieldsForContentTypeWithFilteredChildren(contentType, true)) as string)
|
|
154
|
-
.build()
|
|
155
153
|
|
|
156
|
-
const total = query().and(restrictions)
|
|
154
|
+
const total = query().and(restrictions)
|
|
157
155
|
|
|
158
156
|
const q = `{
|
|
159
157
|
"data": ${data},
|
|
@@ -51,7 +51,6 @@ export async function fetchInstructors(
|
|
|
51
51
|
`"lesson_count": ${await f.lessonCount(brand)}`
|
|
52
52
|
)
|
|
53
53
|
.postFilter(postFilter)
|
|
54
|
-
.build()
|
|
55
54
|
|
|
56
55
|
const q = `{
|
|
57
56
|
"data": ${data},
|
|
@@ -151,9 +150,8 @@ export async function fetchInstructorLessons(
|
|
|
151
150
|
.order(sort)
|
|
152
151
|
.slice(offset, limit)
|
|
153
152
|
.select((await getFieldsForContentTypeWithFilteredChildren(contentType, true)) as string)
|
|
154
|
-
.build()
|
|
155
153
|
|
|
156
|
-
const total = query().and(restrictions)
|
|
154
|
+
const total = query().and(restrictions)
|
|
157
155
|
|
|
158
156
|
const q = `{
|
|
159
157
|
"data": ${data},
|
|
@@ -25,6 +25,7 @@ export interface InviteResponse {
|
|
|
25
25
|
is_user_part_of_existing_mua: boolean
|
|
26
26
|
primary_user_name: string
|
|
27
27
|
product_name: string
|
|
28
|
+
tier_key: string
|
|
28
29
|
// These fields leak user information and are excluded entirely for the public endpoint
|
|
29
30
|
existing_user_details?: User
|
|
30
31
|
email?: string
|
|
@@ -526,6 +526,7 @@ export async function getRecentActivity({ page = 1, limit = 5, tabName = null }
|
|
|
526
526
|
thumbnail: content.thumbnail || null,
|
|
527
527
|
title: content.title || practice.title,
|
|
528
528
|
parent_id: content.parent_id || null,
|
|
529
|
+
learningPathId: content.learning_path_id || null,
|
|
529
530
|
navigateTo: content.navigateTo || null,
|
|
530
531
|
sanityType: content.type || null,
|
|
531
532
|
artist_name: content.artist_name || null,
|
|
@@ -820,6 +821,7 @@ async function formatPracticeMeta(practices = []) {
|
|
|
820
821
|
sanity_type: content?.type || null,
|
|
821
822
|
content_slug: content?.slug || null,
|
|
822
823
|
parent_id: content?.parent_id || null,
|
|
824
|
+
learningPathId: content?.learning_path_id || null,
|
|
823
825
|
navigateTo: content?.navigateTo || null,
|
|
824
826
|
artist_name: content?.artist_name || null,
|
|
825
827
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MCS_VERSION = '2.167.4'
|
|
@@ -1,53 +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
|
-
"mcp__github__pull_request_read",
|
|
22
|
-
"mcp__github__push_files",
|
|
23
|
-
"Bash(git push *)",
|
|
24
|
-
"mcp__github__create_pull_request",
|
|
25
|
-
"mcp__github__search_pull_requests",
|
|
26
|
-
"Bash(git commit *)",
|
|
27
|
-
"Bash(git add *)",
|
|
28
|
-
"mcp__github__list_pull_requests"
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
"model": "sonnet",
|
|
32
|
-
"enabledMcpjsonServers": [
|
|
33
|
-
"atlassian",
|
|
34
|
-
"figma",
|
|
35
|
-
"google-workspace",
|
|
36
|
-
"snowflake",
|
|
37
|
-
"aws",
|
|
38
|
-
"hex",
|
|
39
|
-
"sanity",
|
|
40
|
-
"mysql",
|
|
41
|
-
"slack",
|
|
42
|
-
"langfuse",
|
|
43
|
-
"chrome-devtools",
|
|
44
|
-
"railway",
|
|
45
|
-
"github",
|
|
46
|
-
"asana"
|
|
47
|
-
],
|
|
48
|
-
"disabledMcpjsonServers": [
|
|
49
|
-
"nightwatch",
|
|
50
|
-
"1password"
|
|
51
|
-
],
|
|
52
|
-
"effortLevel": "medium"
|
|
53
|
-
}
|
package/test/initializeTests.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { globalConfig, initializeService } from '../src'
|
|
2
|
-
import { LocalStorageMock } from './localStorageMock'
|
|
3
|
-
const railContentModule = require('../src/services/railcontent.js')
|
|
4
|
-
const awardDefsModule = require('../src/services/awards/internal/award-definitions.js')
|
|
5
|
-
let token = null
|
|
6
|
-
let userId = process.env.RAILCONTENT_USER_ID ?? null
|
|
7
|
-
|
|
8
|
-
export async function initializeTestService(useLive = false, isAdmin = false) {
|
|
9
|
-
let token, userId
|
|
10
|
-
if (useLive && !token && process.env.RAILCONTENT_BASE_URL) {
|
|
11
|
-
const baseUrl = `${process.env.RAILCONTENT_BASE_URL}/api/user-management-system`
|
|
12
|
-
const response = await fetch(`${baseUrl}/v1/sessions`, {
|
|
13
|
-
method: 'POST',
|
|
14
|
-
headers: {
|
|
15
|
-
'X-Client-Platform': 'mobile',
|
|
16
|
-
'Content-Type': 'application/json',
|
|
17
|
-
Authorization: null,
|
|
18
|
-
},
|
|
19
|
-
body: JSON.stringify({
|
|
20
|
-
email: process.env.RAILCONTENT_EMAIL,
|
|
21
|
-
password: process.env.RAILCONTENT_PASSWORD,
|
|
22
|
-
device_name: 'test',
|
|
23
|
-
device_token: '',
|
|
24
|
-
platform: '',
|
|
25
|
-
}),
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
let data = await response.json() // Parse the JSON body
|
|
29
|
-
token = data['token']
|
|
30
|
-
userId = data['user']['id']
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const config = {
|
|
34
|
-
sanityConfig: {
|
|
35
|
-
token: process.env.SANITY_API_TOKEN,
|
|
36
|
-
projectId: process.env.SANITY_PROJECT_ID,
|
|
37
|
-
dataset: process.env.SANITY_DATASET,
|
|
38
|
-
useCachedAPI: process.env.SANITY_USE_CACHED_API === 'true' || true,
|
|
39
|
-
version: '2021-06-07',
|
|
40
|
-
debug: process.env.DEBUG === 'true' || false,
|
|
41
|
-
useDummyRailContentMethods: true,
|
|
42
|
-
},
|
|
43
|
-
railcontentConfig: {
|
|
44
|
-
baseUrl: process.env.RAILCONTENT_BASE_URL || 'https://test.musora.com',
|
|
45
|
-
token: token,
|
|
46
|
-
userId: userId,
|
|
47
|
-
authToken: token,
|
|
48
|
-
},
|
|
49
|
-
sessionConfig: { token: token, userId: userId, authToken: token },
|
|
50
|
-
baseUrl: process.env.RAILCONTENT_BASE_URL,
|
|
51
|
-
localStorage: new LocalStorageMock(),
|
|
52
|
-
isMA: true,
|
|
53
|
-
}
|
|
54
|
-
jest.spyOn(awardDefsModule.awardDefinitions, 'initialize').mockResolvedValue()
|
|
55
|
-
initializeService(config)
|
|
56
|
-
// Mock user permissions
|
|
57
|
-
let permissionsMock = jest.spyOn(railContentModule, 'fetchUserPermissionsData')
|
|
58
|
-
let permissionsData = { permissions: [108, 91, 92], isAdmin: isAdmin }
|
|
59
|
-
permissionsMock.mockImplementation(() => permissionsData)
|
|
60
|
-
}
|