1
1
import { FindOptions } from '@sofie-automation/meteor-lib/dist/collections/lib'
2
2
import { meteorPublish } from './lib/lib'
3
- import { MeteorPubSub } from '@sofie-automation/meteor-lib/dist/api/pubsub'
4
- import { Bucket } from '@sofie-automation/meteor-lib/dist/collections/Buckets'
3
+ import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'
5
4
import { BucketAdLibActions , BucketAdLibs , Buckets } from '../collections'
6
5
import { check , Match } from 'meteor/check'
7
6
import { StudioId , BucketId , ShowStyleVariantId } from '@sofie-automation/corelib/dist/dataModel/Ids'
8
7
import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
9
8
import { triggerWriteAccessBecauseNoCheckNecessary } from '../security/securityVerify'
9
+ import { MongoQuery } from '@sofie-automation/corelib/dist/mongo'
10
+ import { BucketAdLib } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibPiece'
11
+ import { BucketAdLibAction } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibAction'
10
12
11
13
meteorPublish (
12
- MeteorPubSub . buckets ,
14
+ CorelibPubSub . buckets ,
13
15
async function ( studioId : StudioId , bucketId : BucketId | null , _token : string | undefined ) {
14
16
check ( studioId , String )
15
17
check ( bucketId , Match . Maybe ( String ) )
@@ -20,68 +22,61 @@ meteorPublish(
20
22
fields : { } ,
21
23
}
22
24
23
- return Buckets . findWithCursor (
24
- bucketId
25
- ? {
26
- _id : bucketId ,
27
- studioId,
28
- }
29
- : {
30
- studioId,
31
- } ,
32
- modifier
33
- )
25
+ const selector : MongoQuery < Bucket > = {
26
+ studioId,
27
+ }
28
+ if ( bucketId ) selector . _id = bucketId
29
+
30
+ return Buckets . findWithCursor ( selector , modifier )
34
31
}
35
32
)
36
33
37
34
meteorPublish (
38
35
CorelibPubSub . bucketAdLibPieces ,
39
- async function ( studioId : StudioId , bucketId : BucketId , showStyleVariantIds : ShowStyleVariantId [ ] ) {
36
+ async function ( studioId : StudioId , bucketId : BucketId | null , showStyleVariantIds : ShowStyleVariantId [ ] ) {
40
37
check ( studioId , String )
41
- check ( bucketId , String )
38
+ check ( bucketId , Match . Maybe ( String ) )
42
39
check ( showStyleVariantIds , Array )
43
40
44
41
triggerWriteAccessBecauseNoCheckNecessary ( )
45
42
46
- return BucketAdLibs . findWithCursor (
47
- {
48
- studioId : studioId ,
49
- bucketId : bucketId ,
50
- showStyleVariantId : {
51
- $in : [ null , ...showStyleVariantIds ] , // null = valid for all variants
52
- } ,
43
+ const selector : MongoQuery < BucketAdLib > = {
44
+ studioId : studioId ,
45
+ showStyleVariantId : {
46
+ $in : [ null , ...showStyleVariantIds ] , // null = valid for all variants
47
+ } ,
48
+ }
49
+ if ( bucketId ) selector . bucketId = bucketId
50
+
51
+ return BucketAdLibs . findWithCursor ( selector , {
52
+ fields : {
53
+ ingestInfo : 0 , // This is a large blob, and is not of interest to the UI
53
54
} ,
54
- {
55
- fields : {
56
- ingestInfo : 0 , // This is a large blob, and is not of interest to the UI
57
- } ,
58
- }
59
- )
55
+ } )
60
56
}
61
57
)
62
58
63
59
meteorPublish (
64
60
CorelibPubSub . bucketAdLibActions ,
65
- async function ( studioId : StudioId , bucketId : BucketId , showStyleVariantIds : ShowStyleVariantId [ ] ) {
61
+ async function ( studioId : StudioId , bucketId : BucketId | null , showStyleVariantIds : ShowStyleVariantId [ ] ) {
66
62
check ( studioId , String )
67
- check ( bucketId , String )
63
+ check ( bucketId , Match . Maybe ( String ) )
68
64
check ( showStyleVariantIds , Array )
69
65
70
66
triggerWriteAccessBecauseNoCheckNecessary ( )
71
67
72
- return BucketAdLibActions . findWithCursor (
73
- {
74
- studioId : studioId ,
75
- bucketId : bucketId ,
76
- showStyleVariantId : {
77
- $in : [ null , ...showStyleVariantIds ] , // null = valid for all variants
78
- } ,
68
+ const selector : MongoQuery < BucketAdLibAction > = {
69
+ studioId : studioId ,
70
+ showStyleVariantId : {
71
+ $in : [ null , ...showStyleVariantIds ] , // null = valid for all variants
72
+ } ,
73
+ }
74
+ if ( bucketId ) selector . bucketId = bucketId
75
+
76
+ return BucketAdLibActions . findWithCursor ( selector , {
77
+ fields : {
78
+ ingestInfo : 0 , // This is a large blob, and is not of interest to the UI
79
79
} ,
80
- {
81
- fields : {
82
- ingestInfo : 0 , // This is a large blob, and is not of interest to the UI
83
- } ,
84
- }
85
- )
80
+ } )
86
81
}
87
82
)
0 commit comments