musora-content-services 2.108.0 → 2.110.3

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 (34) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/CLAUDE.md +2 -2
  3. package/package.json +1 -1
  4. package/src/contentMetaData.js +0 -5
  5. package/src/contentTypeConfig.js +11 -73
  6. package/src/index.d.ts +0 -20
  7. package/src/index.js +0 -20
  8. package/src/services/content.js +1 -1
  9. package/src/services/contentAggregator.js +1 -4
  10. package/src/services/railcontent.js +0 -163
  11. package/src/services/sanity.js +258 -7
  12. package/src/services/sync/adapters/factory.ts +6 -6
  13. package/src/services/sync/adapters/lokijs.ts +174 -1
  14. package/src/services/sync/context/providers/durability.ts +1 -0
  15. package/src/services/sync/database/factory.ts +12 -5
  16. package/src/services/sync/effects/index.ts +6 -0
  17. package/src/services/sync/effects/logout-warning.ts +47 -0
  18. package/src/services/sync/errors/boundary.ts +4 -6
  19. package/src/services/sync/errors/index.ts +16 -0
  20. package/src/services/sync/fetch.ts +5 -5
  21. package/src/services/sync/manager.ts +80 -40
  22. package/src/services/sync/repositories/base.ts +1 -8
  23. package/src/services/sync/retry.ts +4 -4
  24. package/src/services/sync/store/index.ts +34 -31
  25. package/src/services/sync/store/push-coalescer.ts +3 -3
  26. package/src/services/sync/store-configs.ts +10 -8
  27. package/src/services/sync/telemetry/flood-prevention.ts +27 -0
  28. package/src/services/sync/telemetry/index.ts +71 -9
  29. package/src/services/sync/telemetry/sampling.ts +2 -6
  30. package/src/services/user/types.d.ts +0 -7
  31. package/test/sync/adapter.ts +2 -34
  32. package/test/sync/initialize-sync-manager.js +8 -25
  33. package/.claude/settings.local.json +0 -9
  34. package/src/services/sync/concurrency-safety.ts +0 -4
@@ -1,41 +1,9 @@
1
1
  import adapterFactory from '../../src/services/sync/adapters/factory'
2
2
  import LokiJSAdapter from '../../src/services/sync/adapters/lokijs'
3
- import EventEmitter from '../../src/services/sync/utils/event-emitter'
4
3
 
5
- export default function syncStoreAdapter(userId: string, bus: SyncAdapterEventBus) {
4
+ export default function syncStoreAdapter(userId: string) {
6
5
  return adapterFactory(LokiJSAdapter, `user:${userId}`, {
7
6
  useWebWorker: false,
8
- useIncrementalIndexedDB: true,
9
- extraLokiOptions: {
10
- autosave: true,
11
- autosaveInterval: 300, // increase for better performance at cost of potential data loss on tab close/crash
12
- },
13
- onQuotaExceededError: () => {
14
- // Browser ran out of disk space or possibly in incognito mode
15
- // called ONLY at startup
16
- // ideal place to trigger banner (?) to user when also offline?
17
- // (so that the non-customizable browser default onbeforeunload confirmation (in offline-unload-warning.ts) has context and makes sense)
18
- bus.emit('quotaExceededError')
19
- },
20
- onSetUpError: () => {
21
- // TODO - Database failed to load -- offer the user to reload the app or log out
22
- },
23
- extraIncrementalIDBOptions: {
24
- lazyCollections: ['content_like'],
25
- onDidOverwrite: () => {
26
- // Called when this adapter is forced to overwrite contents of IndexedDB.
27
- // This happens if there's another open tab of the same app that's making changes.
28
- // this scenario is handled-ish in `idb-clobber-avoidance`
29
- },
30
- onversionchange: () => {
31
- // no-op
32
- // indexeddb was deleted in another browser tab (user logged out), so we must make sure we delete
33
- // in-memory db in this tab as well,
34
- // but we rely on sync manager setup/teardown to `unsafeResetDatabase` and redirect for this,
35
- // though reloading the page might be useful as well
36
- },
37
- },
7
+ useIncrementalIndexedDB: true
38
8
  })
39
9
  }
40
-
41
- export class SyncAdapterEventBus extends EventEmitter<{ quotaExceededError: [] }> {}
@@ -1,16 +1,6 @@
1
1
  import { SyncManager, SyncContext } from '../../src/services/sync/index'
2
- import {
3
- BaseSessionProvider,
4
- BaseConnectivityProvider,
5
- BaseDurabilityProvider,
6
- BaseTabsProvider,
7
- BaseVisibilityProvider,
8
- } from '../../src/services/sync/context/providers/'
9
- import adapterFactory from '../../src/services/sync/adapters/factory'
10
- import LokiJSAdapter from '../../src/services/sync/adapters/lokijs'
11
- import EventEmitter from '../../src/services/sync/utils/event-emitter'
12
- import { InitialStrategy, PollingStrategy } from '../../src/services/sync/strategies/index'
13
- import { SyncTelemetry, SentryLike } from '../../src/services/sync/telemetry/index'
2
+ import { InitialStrategy } from '../../src/services/sync/strategies/index'
3
+ import { SyncTelemetry, SeverityLevel, SentryLike } from '../../src/services/sync/telemetry/index'
14
4
  import {
15
5
  ContentLike,
16
6
  ContentProgress,
@@ -19,7 +9,7 @@ import {
19
9
  } from '../../src/services/sync/models/index'
20
10
  import syncDatabaseFactory from '../../src/services/sync/database/factory'
21
11
 
22
- import syncAdapter, { SyncAdapterEventBus } from './adapter'
12
+ import syncAdapter from './adapter'
23
13
 
24
14
  export function initializeSyncManager(userId) {
25
15
  if (SyncManager.getInstanceOrNull()) {
@@ -45,10 +35,9 @@ export function initializeSyncManager(userId) {
45
35
  },
46
36
  }
47
37
 
48
- SyncTelemetry.setInstance(new SyncTelemetry(userId, { Sentry: dummySentry }))
38
+ SyncTelemetry.setInstance(new SyncTelemetry(userId, { Sentry: dummySentry, level: SeverityLevel.WARNING, pretty: false }))
49
39
 
50
- const adapterBus = new SyncAdapterEventBus()
51
- const adapter = syncAdapter(userId, adapterBus)
40
+ const adapter = syncAdapter(userId)
52
41
  const db = syncDatabaseFactory(adapter)
53
42
 
54
43
  const context = new SyncContext({
@@ -88,16 +77,10 @@ export function initializeSyncManager(userId) {
88
77
  const manager = new SyncManager(context, db)
89
78
 
90
79
  const initialStrategy = manager.createStrategy(InitialStrategy)
91
- const aggressivePollingStrategy = manager.createStrategy(PollingStrategy, 3600_000)
92
-
93
- manager.syncStoresWithStrategies(
94
- manager.storesForModels([ContentLike, ContentProgress, Practice, PracticeDayNote]),
95
- [initialStrategy, aggressivePollingStrategy]
96
- )
97
80
 
98
- manager.protectStores(
99
- manager.storesForModels([ContentLike, ContentProgress, Practice, PracticeDayNote]),
100
- []
81
+ manager.registerStrategies(
82
+ [ContentLike, ContentProgress, Practice, PracticeDayNote],
83
+ [initialStrategy]
101
84
  )
102
85
 
103
86
  SyncManager.assignAndSetupInstance(manager)
@@ -1,9 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(rg:*)",
5
- "Bash(npm run lint:*)"
6
- ],
7
- "deny": []
8
- }
9
- }
@@ -1,4 +0,0 @@
1
- import type SyncContext from "./context"
2
- import type SyncStore from "./store"
3
-
4
- export type SyncConcurrencySafetyMechanism = (context: SyncContext, stores: SyncStore[]) => () => void