forked from Sofie-Automation/sofie-core
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreactiveContentCache.ts
More file actions
69 lines (62 loc) · 2.45 KB
/
reactiveContentCache.ts
File metadata and controls
69 lines (62 loc) · 2.45 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part'
import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
import { ReactiveCacheCollection } from '../lib/ReactiveCacheCollection'
import { literal } from '@sofie-automation/corelib/dist/lib'
import { MongoFieldSpecifierOnesStrict } from '@sofie-automation/corelib/dist/mongo'
import { Rundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
import { PartInstance } from '@sofie-automation/meteor-lib/dist/collections/PartInstances'
export type RundownFields = '_id' | 'playlistId' | 'source'
export const rundownFieldSpecifier = literal<MongoFieldSpecifierOnesStrict<Pick<Rundown, RundownFields>>>({
_id: 1,
playlistId: 1,
source: 1,
})
export type SegmentFields = '_id' | '_rank' | 'rundownId' | 'name' | 'notes' | 'orphaned'
export const segmentFieldSpecifier = literal<MongoFieldSpecifierOnesStrict<Pick<DBSegment, SegmentFields>>>({
_id: 1,
_rank: 1,
rundownId: 1,
name: 1,
notes: 1,
orphaned: 1,
})
export type PartFields = '_id' | '_rank' | 'segmentId' | 'rundownId' | 'notes' | 'title' | 'invalid' | 'invalidReason'
export const partFieldSpecifier = literal<MongoFieldSpecifierOnesStrict<Pick<DBPart, PartFields>>>({
_id: 1,
_rank: 1,
segmentId: 1,
rundownId: 1,
notes: 1,
title: 1,
invalid: 1,
invalidReason: 1,
})
export type PartInstanceFields = '_id' | 'segmentId' | 'rundownId' | 'orphaned' | 'reset' | 'part' | 'invalidReason'
export const partInstanceFieldSpecifier = literal<
MongoFieldSpecifierOnesStrict<Pick<PartInstance, PartInstanceFields>>
>({
_id: 1,
segmentId: 1,
rundownId: 1,
orphaned: 1,
reset: 1,
invalidReason: 1,
// @ts-expect-error Deep not supported
'part._id': 1,
'part.title': 1,
})
export interface ContentCache {
Rundowns: ReactiveCacheCollection<Pick<Rundown, RundownFields>>
Segments: ReactiveCacheCollection<Pick<DBSegment, SegmentFields>>
Parts: ReactiveCacheCollection<Pick<DBPart, PartFields>>
PartInstances: ReactiveCacheCollection<Pick<PartInstance, PartInstanceFields>>
}
export function createReactiveContentCache(): ContentCache {
const cache: ContentCache = {
Rundowns: new ReactiveCacheCollection<Pick<Rundown, RundownFields>>('rundowns'),
Segments: new ReactiveCacheCollection<Pick<DBSegment, SegmentFields>>('segments'),
Parts: new ReactiveCacheCollection<Pick<DBPart, PartFields>>('parts'),
PartInstances: new ReactiveCacheCollection<Pick<PartInstance, PartInstanceFields>>('partInstances'),
}
return cache
}