forked from Sofie-Automation/sofie-core
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontentCache.ts
More file actions
52 lines (44 loc) · 2.07 KB
/
contentCache.ts
File metadata and controls
52 lines (44 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { ReactiveCacheCollection } from '../../lib/ReactiveCacheCollection'
import { literal } from '@sofie-automation/corelib/dist/lib'
import { MongoFieldSpecifierOnesStrict } from '@sofie-automation/corelib/dist/mongo'
import { ExpectedPackageDB } from '@sofie-automation/corelib/dist/dataModel/ExpectedPackages'
import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist/RundownPlaylist'
import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance'
export type RundownPlaylistCompact = Pick<
DBRundownPlaylist,
'_id' | 'activationId' | 'currentPartInfo' | 'nextPartInfo'
>
export const rundownPlaylistFieldSpecifier = literal<MongoFieldSpecifierOnesStrict<RundownPlaylistCompact>>({
_id: 1,
activationId: 1,
currentPartInfo: 1, // So that it invalidates when the current changes
nextPartInfo: 1, // So that it invalidates when the next changes
})
export type PieceInstanceCompact = Pick<
PieceInstance,
'_id' | 'rundownId' | 'partInstanceId' | 'neededExpectedPackageIds'
>
export const pieceInstanceFieldsSpecifier = literal<MongoFieldSpecifierOnesStrict<PieceInstanceCompact>>({
_id: 1,
rundownId: 1,
partInstanceId: 1,
neededExpectedPackageIds: 1,
})
export type ExpectedPackageDBCompact = Pick<ExpectedPackageDB, '_id' | 'package'>
export const expectedPackageDBFieldsSpecifier = literal<MongoFieldSpecifierOnesStrict<ExpectedPackageDB>>({
_id: 1,
package: 1,
})
export interface ExpectedPackagesContentCache {
ExpectedPackages: ReactiveCacheCollection<ExpectedPackageDBCompact>
RundownPlaylists: ReactiveCacheCollection<RundownPlaylistCompact>
PieceInstances: ReactiveCacheCollection<PieceInstanceCompact>
}
export function createReactiveContentCache(): ExpectedPackagesContentCache {
const cache: ExpectedPackagesContentCache = {
ExpectedPackages: new ReactiveCacheCollection<ExpectedPackageDBCompact>('expectedPackages'),
RundownPlaylists: new ReactiveCacheCollection<RundownPlaylistCompact>('rundownPlaylists'),
PieceInstances: new ReactiveCacheCollection<PieceInstanceCompact>('pieceInstances'),
}
return cache
}