11import { FindOptions } from '@sofie-automation/meteor-lib/dist/collections/lib'
22import { 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'
54import { BucketAdLibActions , BucketAdLibs , Buckets } from '../collections'
65import { check , Match } from 'meteor/check'
76import { StudioId , BucketId , ShowStyleVariantId } from '@sofie-automation/corelib/dist/dataModel/Ids'
87import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
98import { 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'
1012
1113meteorPublish (
12- MeteorPubSub . buckets ,
14+ CorelibPubSub . buckets ,
1315 async function ( studioId : StudioId , bucketId : BucketId | null , _token : string | undefined ) {
1416 check ( studioId , String )
1517 check ( bucketId , Match . Maybe ( String ) )
@@ -20,68 +22,61 @@ meteorPublish(
2022 fields : { } ,
2123 }
2224
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 )
3431 }
3532)
3633
3734meteorPublish (
3835 CorelibPubSub . bucketAdLibPieces ,
39- async function ( studioId : StudioId , bucketId : BucketId , showStyleVariantIds : ShowStyleVariantId [ ] ) {
36+ async function ( studioId : StudioId , bucketId : BucketId | null , showStyleVariantIds : ShowStyleVariantId [ ] ) {
4037 check ( studioId , String )
41- check ( bucketId , String )
38+ check ( bucketId , Match . Maybe ( String ) )
4239 check ( showStyleVariantIds , Array )
4340
4441 triggerWriteAccessBecauseNoCheckNecessary ( )
4542
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
5354 } ,
54- {
55- fields : {
56- ingestInfo : 0 , // This is a large blob, and is not of interest to the UI
57- } ,
58- }
59- )
55+ } )
6056 }
6157)
6258
6359meteorPublish (
6460 CorelibPubSub . bucketAdLibActions ,
65- async function ( studioId : StudioId , bucketId : BucketId , showStyleVariantIds : ShowStyleVariantId [ ] ) {
61+ async function ( studioId : StudioId , bucketId : BucketId | null , showStyleVariantIds : ShowStyleVariantId [ ] ) {
6662 check ( studioId , String )
67- check ( bucketId , String )
63+ check ( bucketId , Match . Maybe ( String ) )
6864 check ( showStyleVariantIds , Array )
6965
7066 triggerWriteAccessBecauseNoCheckNecessary ( )
7167
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
7979 } ,
80- {
81- fields : {
82- ingestInfo : 0 , // This is a large blob, and is not of interest to the UI
83- } ,
84- }
85- )
80+ } )
8681 }
8782)
0 commit comments