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.
Files changed (140) hide show
  1. package/.agent/decisions/2026-07-20-mu2-1724-songs-lessons-counts.md +33 -0
  2. package/.agent/decisions/2026-07-20-query-builder-tostring.md +37 -0
  3. package/.idea/codeStyles/Project.xml +61 -0
  4. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/musora-content-services.iml +8 -0
  7. package/.idea/php.xml +19 -0
  8. package/.idea/prettier.xml +6 -0
  9. package/.idea/vcs.xml +7 -0
  10. package/.yarn/install-state.gz +0 -0
  11. package/CHANGELOG.md +10 -0
  12. package/package.json +2 -1
  13. package/src/contentTypeConfig.js +1 -0
  14. package/src/lib/sanity/query.ts +5 -0
  15. package/src/services/config.js +15 -0
  16. package/src/services/content/artist.ts +1 -3
  17. package/src/services/content/counts.ts +47 -0
  18. package/src/services/content/genre.ts +1 -3
  19. package/src/services/content/instructor.ts +1 -3
  20. package/src/services/multi-user-accounts/multi-user-accounts.ts +1 -0
  21. package/src/services/userActivity.js +2 -0
  22. package/src/version-info.js +1 -0
  23. package/.claude/settings.local.json +0 -53
  24. package/test/initializeTests.js +0 -60
  25. package/test/integration/awards/award-exclusion-handling.test.ts +0 -275
  26. package/test/integration/awards/internal/image-utils.test.ts +0 -86
  27. package/test/integration/content-progress/__mocks__/mocks.ts +0 -104
  28. package/test/integration/content-progress/contentProgress.test.ts +0 -335
  29. package/test/integration/content-progress/e2eOfflineProgress.test.ts +0 -352
  30. package/test/integration/content-progress/e2eProgress.test.ts +0 -612
  31. package/test/integration/content-progress/getters.test.ts +0 -334
  32. package/test/integration/content-progress/helpers.test.ts +0 -263
  33. package/test/integration/content-progress/offlineContentProgress.test.ts +0 -226
  34. package/test/integration/forums.test.ts +0 -209
  35. package/test/integration/infrastructure/FetchRequestExecutor.test.ts +0 -88
  36. package/test/integration/initializeTestDB.ts +0 -80
  37. package/test/integration/learning-paths.test.ts +0 -854
  38. package/test/integration/notifications.test.ts +0 -178
  39. package/test/integration/progress-row/content-card.test.ts +0 -283
  40. package/test/integration/sync/adapters/idb-errors.test.ts +0 -144
  41. package/test/integration/sync/adapters/sqlite-errors.test.ts +0 -173
  42. package/test/integration/sync/fetch.test.ts +0 -224
  43. package/test/integration/sync/repositories/content-likes.test.ts +0 -99
  44. package/test/integration/sync/repositories/practices.test.ts +0 -179
  45. package/test/integration/sync/repositories/progress.test.ts +0 -245
  46. package/test/integration/sync/repositories/user-award-progress.static.test.ts +0 -68
  47. package/test/integration/sync/repositories/user-award-progress.test.ts +0 -387
  48. package/test/integration/sync/store/cross-user-protection.test.ts +0 -217
  49. package/test/integration/sync/store/store-idb.test.ts +0 -180
  50. package/test/integration/sync/store/store.test.ts +0 -361
  51. package/test/integration/user/permissions.test.js +0 -20
  52. package/test/integration/userActivity.test.ts +0 -102
  53. package/test/live/README.md +0 -29
  54. package/test/live/content.test.js +0 -116
  55. package/test/localStorageMock.js +0 -21
  56. package/test/log.js +0 -5
  57. package/test/mockData/award-definitions.js +0 -171
  58. package/test/mockData/mockData_fetchByRailContentIds_one_content.json +0 -35
  59. package/test/mockData/mockData_progress_content.json +0 -182
  60. package/test/mockData/mockData_sanity_progress_content.json +0 -1451
  61. package/test/mockData/mockData_user_practices.json +0 -9
  62. package/test/setupConsole.js +0 -6
  63. package/test/setupNetworkGuard.js +0 -3
  64. package/test/setupTimers.js +0 -13
  65. package/test/unit/HttpClient.test.ts +0 -267
  66. package/test/unit/awards/award-alacarte-observer.test.ts +0 -199
  67. package/test/unit/awards/award-auto-refresh.test.ts +0 -84
  68. package/test/unit/awards/award-calculations.test.ts +0 -34
  69. package/test/unit/awards/award-callbacks.test.ts +0 -144
  70. package/test/unit/awards/award-certificate-display.test.ts +0 -330
  71. package/test/unit/awards/award-collection-edge-cases.test.ts +0 -212
  72. package/test/unit/awards/award-collection-filtering.test.ts +0 -287
  73. package/test/unit/awards/award-completion-flow.test.ts +0 -306
  74. package/test/unit/awards/award-multi-lesson.test.ts +0 -243
  75. package/test/unit/awards/award-observer-integration.test.ts +0 -327
  76. package/test/unit/awards/award-query-messages.test.ts +0 -448
  77. package/test/unit/awards/award-user-collection.test.ts +0 -416
  78. package/test/unit/awards/duplicate-prevention.test.ts +0 -120
  79. package/test/unit/awards/helpers/completion-mock.ts +0 -56
  80. package/test/unit/awards/helpers/index.ts +0 -3
  81. package/test/unit/awards/helpers/mock-setup.ts +0 -79
  82. package/test/unit/awards/helpers/progress-emitter.ts +0 -45
  83. package/test/unit/awards/message-generator.test.ts +0 -162
  84. package/test/unit/content-progress/bubbleTrickle.test.ts +0 -322
  85. package/test/unit/content-progress/helpers.test.ts +0 -329
  86. package/test/unit/content-progress/navigateTo.test.ts +0 -392
  87. package/test/unit/contentLikes.test.ts +0 -62
  88. package/test/unit/contentMetaData.test.ts +0 -58
  89. package/test/unit/dataContext.test.ts +0 -38
  90. package/test/unit/dateUtils.test.ts +0 -188
  91. package/test/unit/endScreen.test.js +0 -712
  92. package/test/unit/eventsAPI.test.ts +0 -159
  93. package/test/unit/imageSRCBuilder.test.ts +0 -37
  94. package/test/unit/imageSRCVerify.test.ts +0 -155
  95. package/test/unit/infrastructure/DefaultHeaderProvider.test.ts +0 -39
  96. package/test/unit/infrastructure/sanity/ContentClient.test.ts +0 -168
  97. package/test/unit/infrastructure/sanity/DefaultConfigProvider.test.ts +0 -93
  98. package/test/unit/infrastructure/sanity/FetchQueryExecutor.test.ts +0 -174
  99. package/test/unit/infrastructure/sanity/SanityClient.test.ts +0 -140
  100. package/test/unit/lib/__snapshots__/filter.test.ts.snap +0 -5
  101. package/test/unit/lib/filter.test.ts +0 -1154
  102. package/test/unit/lib/lastUpdated.test.ts +0 -21
  103. package/test/unit/lib/query.test.ts +0 -1469
  104. package/test/unit/lib/sanity/decorators/base.test.ts +0 -368
  105. package/test/unit/lib/sanity/decorators/navigate-to.test.ts +0 -361
  106. package/test/unit/lib/sanity/decorators/need-access.test.ts +0 -89
  107. package/test/unit/lib/sanity/decorators/need-lifetime-upgrade.test.ts +0 -85
  108. package/test/unit/lib/sanity/decorators/page-type.test.ts +0 -81
  109. package/test/unit/playerSettings.test.ts +0 -73
  110. package/test/unit/progress-row/content-card.test.ts +0 -314
  111. package/test/unit/progress-row/playlist-card.test.ts +0 -104
  112. package/test/unit/progressRows.test.ts +0 -243
  113. package/test/unit/recommendations.test.js +0 -47
  114. package/test/unit/sanityQueryService.test.ts +0 -200
  115. package/test/unit/search.test.ts +0 -44
  116. package/test/unit/sentry.test.ts +0 -62
  117. package/test/unit/services/progress-internal/bubble.test.ts +0 -279
  118. package/test/unit/services/progress.test.ts +0 -396
  119. package/test/unit/streakMessage.test.ts +0 -251
  120. package/test/unit/sync/context.test.ts +0 -51
  121. package/test/unit/sync/effects/logout-warning.test.ts +0 -158
  122. package/test/unit/sync/effects/push-failure-notification.test.ts +0 -196
  123. package/test/unit/sync/errors/sync-errors.test.ts +0 -106
  124. package/test/unit/sync/errors/validators.test.ts +0 -61
  125. package/test/unit/sync/helpers/TestModel.ts +0 -44
  126. package/test/unit/sync/helpers/index.ts +0 -172
  127. package/test/unit/sync/manager.test.ts +0 -303
  128. package/test/unit/sync/models/user-award-progress.test.ts +0 -82
  129. package/test/unit/sync/resolver.test.ts +0 -229
  130. package/test/unit/sync/retry.test.ts +0 -314
  131. package/test/unit/sync/run-scope.test.ts +0 -23
  132. package/test/unit/sync/stale-record-cleanup.test.ts +0 -107
  133. package/test/unit/sync/store/push-coalescer.test.ts +0 -156
  134. package/test/unit/sync/store-configs.test.ts +0 -37
  135. package/test/unit/sync/telemetry/sync-telemetry.test.ts +0 -118
  136. package/test/unit/sync/utils/event-emitter.test.ts +0 -64
  137. package/test/unit/sync/utils/throttle.test.ts +0 -245
  138. package/test/unit/url-builder.test.ts +0 -72
  139. package/test/unit/user/account.test.ts +0 -66
  140. package/test/unit/user/permissions.test.js +0 -191
@@ -1,188 +0,0 @@
1
- import {
2
- isSameDate,
3
- convertToTimeZone,
4
- getMonday,
5
- getWeekNumber,
6
- isNextDay,
7
- getTimeRemainingUntilLocal,
8
- getToday,
9
- } from '../../src/services/dateUtils.js'
10
-
11
- const mockTimezone = (tz: string): void => {
12
- const RealDateTimeFormat = Intl.DateTimeFormat
13
- jest.spyOn(Intl, 'DateTimeFormat').mockImplementation((...args) => {
14
- const instance = new RealDateTimeFormat(...args)
15
- return {
16
- format: instance.format.bind(instance),
17
- formatToParts: instance.formatToParts.bind(instance),
18
- resolvedOptions: () => ({ ...instance.resolvedOptions(), timeZone: tz }),
19
- } as unknown as Intl.DateTimeFormat
20
- })
21
- }
22
-
23
- describe('isSameDate', () => {
24
- afterEach(() => {
25
- jest.restoreAllMocks()
26
- })
27
-
28
- describe('basic comparisons', () => {
29
- test('returns true for identical YYYY-MM-DD strings', () => {
30
- expect(isSameDate('2024-01-07', '2024-01-07')).toBe(true)
31
- })
32
-
33
- test('returns false for different YYYY-MM-DD strings', () => {
34
- expect(isSameDate('2024-01-07', '2024-01-08')).toBe(false)
35
- })
36
-
37
- test('returns true for two ISO strings at different times on the same local day', () => {
38
- expect(isSameDate('2024-01-07T08:00:00', '2024-01-07T23:00:00')).toBe(true)
39
- })
40
- })
41
-
42
- describe('UTC offset edge cases', () => {
43
- test('matches a local ISO string with a bare date string in UTC-6 at 6pm (the reported bug)', () => {
44
- mockTimezone('America/Chicago') // UTC-6 in January
45
- // 6pm Sunday local in UTC-6 = midnight UTC Monday — the old dayjs("YYYY-MM-DD") parsed
46
- // bare dates as UTC midnight, resolving to 6pm Saturday locally and failing the match.
47
- expect(isSameDate('2024-01-07T18:00:00-06:00', '2024-01-07')).toBe(true)
48
- })
49
-
50
- test('matches a UTC midnight string to the correct prior local date in UTC-6', () => {
51
- mockTimezone('America/Chicago') // UTC-6 in January
52
- // 2024-01-08T00:00:00Z is the same instant as 2024-01-07T18:00:00-06:00 (Sunday 6pm local)
53
- expect(isSameDate('2024-01-08T00:00:00Z', '2024-01-07')).toBe(true)
54
- })
55
-
56
- test('returns false when UTC midnight maps to the next local day in UTC-6', () => {
57
- mockTimezone('America/Chicago')
58
- // 2024-01-08T00:00:00Z = Sunday 6pm local (Jan 7), not Jan 8 locally
59
- expect(isSameDate('2024-01-08T00:00:00Z', '2024-01-08')).toBe(false)
60
- })
61
-
62
- test('matches correctly in a positive UTC offset timezone (UTC+10)', () => {
63
- mockTimezone('Australia/Sydney') // UTC+10 in January (AEST, no DST)
64
- // 6pm Sunday local in UTC+10 = 8am Sunday UTC — no day boundary issue
65
- expect(isSameDate('2024-01-07T18:00:00+10:00', '2024-01-07')).toBe(true)
66
- })
67
-
68
- test('returns false for genuinely different local dates regardless of timezone', () => {
69
- mockTimezone('America/Chicago')
70
- expect(isSameDate('2024-01-07T18:00:00-06:00', '2024-01-08')).toBe(false)
71
- })
72
- })
73
- })
74
-
75
- describe('convertToTimeZone', () => {
76
- test('returns YYYY-MM-DD string in the target timezone', () => {
77
- expect(convertToTimeZone('2024-01-07T12:00:00Z', 'America/Chicago')).toBe('2024-01-07')
78
- })
79
-
80
- test('returns the prior calendar date when UTC midnight crosses a day boundary in UTC-6', () => {
81
- // 2024-01-08T00:00:00Z = Jan 7 18:00 in Chicago
82
- expect(convertToTimeZone('2024-01-08T00:00:00Z', 'America/Chicago')).toBe('2024-01-07')
83
- })
84
-
85
- test('returns the next calendar date when UTC afternoon crosses a day boundary in UTC+9', () => {
86
- // 2024-01-07T16:00:00Z = Jan 8 01:00 in Tokyo (UTC+9)
87
- expect(convertToTimeZone('2024-01-07T16:00:00Z', 'Asia/Tokyo')).toBe('2024-01-08')
88
- })
89
- })
90
-
91
- describe('getMonday', () => {
92
- test('returns Monday of the same week for a Wednesday', () => {
93
- // 2024-01-10 is a Wednesday; Monday of that week is Jan 8
94
- expect(getMonday('2024-01-10', 'UTC').format('YYYY-MM-DD')).toBe('2024-01-08')
95
- })
96
-
97
- test('returns the same date when the input is already a Monday', () => {
98
- expect(getMonday('2024-01-08', 'UTC').format('YYYY-MM-DD')).toBe('2024-01-08')
99
- })
100
-
101
- test('returns the prior Monday for a Sunday (ISO weeks start on Monday)', () => {
102
- // 2024-01-07 is a Sunday; the ISO Monday of that week is Jan 1
103
- expect(getMonday('2024-01-07', 'UTC').format('YYYY-MM-DD')).toBe('2024-01-01')
104
- })
105
- })
106
-
107
- describe('getWeekNumber', () => {
108
- test('returns 1 for the first ISO week of the year', () => {
109
- expect(getWeekNumber('2024-01-01')).toBe(1)
110
- })
111
-
112
- test('returns 2 for the second ISO week', () => {
113
- // 2024-01-08 is the first day of week 2
114
- expect(getWeekNumber('2024-01-08')).toBe(2)
115
- })
116
- })
117
-
118
- describe('isNextDay', () => {
119
- test('returns true when date2 is exactly one day after date1', () => {
120
- expect(isNextDay('2024-01-07', '2024-01-08')).toBe(true)
121
- })
122
-
123
- test('returns false for the same date', () => {
124
- expect(isNextDay('2024-01-07', '2024-01-07')).toBe(false)
125
- })
126
-
127
- test('returns false when date2 is two days after date1', () => {
128
- expect(isNextDay('2024-01-07', '2024-01-09')).toBe(false)
129
- })
130
-
131
- test('returns false when date2 is before date1', () => {
132
- expect(isNextDay('2024-01-08', '2024-01-07')).toBe(false)
133
- })
134
- })
135
-
136
- describe('getTimeRemainingUntilLocal', () => {
137
- beforeEach(() => {
138
- jest.useFakeTimers()
139
- jest.setSystemTime(new Date('2024-01-07T12:00:00Z'))
140
- })
141
-
142
- afterEach(() => {
143
- jest.useRealTimers()
144
- })
145
-
146
- test('returns formatted HH:MM:SS for a future target', () => {
147
- // 1 hour 30 minutes 45 seconds in the future
148
- expect(getTimeRemainingUntilLocal('2024-01-07T13:30:45Z')).toBe('01:30:45')
149
- })
150
-
151
- test('returns formatted string with zero-padded single-digit values', () => {
152
- expect(getTimeRemainingUntilLocal('2024-01-07T12:05:09Z')).toBe('00:05:09')
153
- })
154
-
155
- test('returns "00:00:00" for a past target', () => {
156
- expect(getTimeRemainingUntilLocal('2024-01-07T11:00:00Z')).toBe('00:00:00')
157
- })
158
-
159
- test('returns "00:00:00" for an invalid date string', () => {
160
- expect(getTimeRemainingUntilLocal('not-a-date')).toBe('00:00:00')
161
- })
162
-
163
- test('returns object with totalSeconds and formatted when withTotalSeconds is true', () => {
164
- // 1 hour 30 minutes 45 seconds = 5445 seconds
165
- expect(getTimeRemainingUntilLocal('2024-01-07T13:30:45Z', { withTotalSeconds: true })).toEqual({
166
- totalSeconds: 5445,
167
- formatted: '01:30:45',
168
- })
169
- })
170
-
171
- test('handles targets more than 24 hours away', () => {
172
- expect(getTimeRemainingUntilLocal('2024-01-08T14:00:00Z')).toBe('26:00:00')
173
- })
174
- })
175
-
176
- describe('getToday', () => {
177
- afterEach(() => {
178
- jest.restoreAllMocks()
179
- jest.useRealTimers()
180
- })
181
-
182
- test('returns start of today in the local timezone', () => {
183
- jest.useFakeTimers()
184
- jest.setSystemTime(new Date('2024-01-08T00:00:00Z'))
185
- mockTimezone('America/Chicago') // UTC-6: Jan 8 00:00 UTC = Jan 7 18:00 Chicago
186
- expect(getToday().format('YYYY-MM-DD')).toBe('2024-01-07')
187
- })
188
- })