Skip to content

Commit ea7439c

Browse files
authored
Merge pull request #1370 from tv2norge-collab/contribute/EAV-487
feat(LSG): add buckets topic
2 parents cbed799 + 3e74c66 commit ea7439c

File tree

29 files changed

+527
-74
lines changed

29 files changed

+527
-74
lines changed

meteor/server/api/buckets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as _ from 'underscore'
22
import { Meteor } from 'meteor/meteor'
3-
import { Bucket } from '@sofie-automation/meteor-lib/dist/collections/Buckets'
3+
import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'
44
import { getRandomId, getRandomString, literal } from '../lib/tempLib'
55
import { BucketAdLib } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibPiece'
66
import { AdLibAction, AdLibActionCommon } from '@sofie-automation/corelib/dist/dataModel/AdlibAction'

meteor/server/api/rest/v1/typeConversion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import {
5454
DEFAULT_MINIMUM_TAKE_SPAN,
5555
DEFAULT_FALLBACK_PART_DURATION,
5656
} from '@sofie-automation/shared-lib/dist/core/constants'
57-
import { Bucket } from '@sofie-automation/meteor-lib/dist/collections/Buckets'
57+
import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'
5858
import { ForceQuickLoopAutoNext } from '@sofie-automation/shared-lib/dist/core/model/StudioSettings'
5959
import { PlaylistSnapshotOptions, SystemSnapshotOptions } from '@sofie-automation/meteor-lib/dist/api/shapshot'
6060

meteor/server/api/userActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { MOSDeviceActions } from './ingest/mosDevice/actions'
1515
import { MethodContextAPI } from './methodContext'
1616
import { ServerClientAPI } from './client'
1717
import { triggerWriteAccessBecauseNoCheckNecessary } from '../security/securityVerify'
18-
import { Bucket } from '@sofie-automation/meteor-lib/dist/collections/Buckets'
18+
import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'
1919
import { BucketsAPI } from './buckets'
2020
import { BucketAdLib } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibPiece'
2121
import { AdLibActionCommon } from '@sofie-automation/corelib/dist/dataModel/AdlibAction'

meteor/server/collections/bucket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BucketAdLibAction } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibAction'
22
import { BucketAdLib } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibPiece'
33
import { CollectionName } from '@sofie-automation/corelib/dist/dataModel/Collections'
4-
import { Bucket } from '@sofie-automation/meteor-lib/dist/collections/Buckets'
4+
import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'
55
import { createAsyncOnlyMongoCollection } from './collection'
66
import { registerIndex } from './indices'
77

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { FindOptions } from '@sofie-automation/meteor-lib/dist/collections/lib'
22
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'
54
import { BucketAdLibActions, BucketAdLibs, Buckets } from '../collections'
65
import { check, Match } from 'meteor/check'
76
import { StudioId, BucketId, ShowStyleVariantId } from '@sofie-automation/corelib/dist/dataModel/Ids'
87
import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
98
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'
1012

1113
meteorPublish(
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

3734
meteorPublish(
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

6359
meteorPublish(
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
)

meteor/server/publications/pieceContentStatusUI/bucket/publication.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
SetupObserversResult,
2323
} from '../../../lib/customPublication'
2424
import { BucketContentCache, createReactiveContentCache } from './bucketContentCache'
25-
import { Bucket } from '@sofie-automation/meteor-lib/dist/collections/Buckets'
25+
import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'
2626
import {
2727
addItemsWithDependenciesChangesToChangedSet,
2828
fetchStudio,

packages/meteor-lib/src/collections/Buckets.ts renamed to packages/corelib/src/dataModel/Bucket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BucketId, StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
1+
import { BucketId, StudioId } from './Ids'
22

33
/**
44
* A Bucket is an container for AdLib pieces that do not come from a MOS gateway and are

packages/corelib/src/pubsub.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
} from '@sofie-automation/shared-lib/dist/core/model/Ids'
3838
import { BlueprintId, BucketId, RundownPlaylistActivationId, SegmentId, ShowStyleVariantId } from './dataModel/Ids'
3939
import { PackageInfoDB } from './dataModel/PackageInfos'
40+
import { Bucket } from './dataModel/Bucket'
4041

4142
/**
4243
* Ids of possible DDP subscriptions for any the UI and gateways accessing the Rundown & RundownPlaylist model.
@@ -135,12 +136,16 @@ export enum CorelibPubSub {
135136
packageContainerStatuses = 'packageContainerStatuses',
136137

137138
/**
138-
* Fetch all bucket adlib pieces for the specified Studio and Bucket.
139+
* Fetch either all buckets for the given Studio, or the Bucket specified.
140+
*/
141+
buckets = 'buckets',
142+
/**
143+
* Fetch all bucket adlib pieces for the specified Studio and Bucket (or all buckets in a Studio).
139144
* The result will be limited to ones valid to the ShowStyleVariants specified, as well as ones marked as valid in any ShowStyleVariant
140145
*/
141146
bucketAdLibPieces = 'bucketAdLibPieces',
142147
/**
143-
* Fetch all bucket adlib action for the specified Studio and Bucket.
148+
* Fetch all bucket adlib action for the specified Studio and Bucket (or all buckets in a Studio).
144149
* The result will be limited to ones valid to the ShowStyleVariants specified, as well as ones marked as valid in any ShowStyleVariant
145150
*/
146151
bucketAdLibActions = 'bucketAdLibActions',
@@ -297,14 +302,15 @@ export interface CorelibPubSubTypes {
297302
token?: string
298303
) => CollectionName.Studios
299304
[CorelibPubSub.timelineDatastore]: (studioId: StudioId, token?: string) => CollectionName.TimelineDatastore
305+
[CorelibPubSub.buckets]: (studioId: StudioId, bucketId: BucketId | null, token?: string) => CollectionName.Buckets
300306
[CorelibPubSub.bucketAdLibPieces]: (
301307
studioId: StudioId,
302-
bucketId: BucketId,
308+
bucketId: BucketId | null,
303309
showStyleVariantIds: ShowStyleVariantId[]
304310
) => CollectionName.BucketAdLibPieces
305311
[CorelibPubSub.bucketAdLibActions]: (
306312
studioId: StudioId,
307-
bucketId: BucketId,
313+
bucketId: BucketId | null,
308314
showStyleVariantIds: ShowStyleVariantId[]
309315
) => CollectionName.BucketAdLibActions
310316
[CorelibPubSub.expectedPackages]: (studioIds: StudioId[], token?: string) => CollectionName.ExpectedPackages
@@ -323,6 +329,7 @@ export type CorelibPubSubCollections = {
323329
[CollectionName.AdLibActions]: AdLibAction
324330
[CollectionName.AdLibPieces]: AdLibPiece
325331
[CollectionName.Blueprints]: Blueprint
332+
[CollectionName.Buckets]: Bucket
326333
[CollectionName.BucketAdLibActions]: BucketAdLibAction
327334
[CollectionName.BucketAdLibPieces]: BucketAdLib
328335
[CollectionName.ExpectedMediaItems]: ExpectedMediaItem

packages/documentation/docs/for-developers/data-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Currently, there is not a very clearly defined flow for modifying these document
2424
This includes:
2525

2626
- [Blueprints](https://github.com/nrkno/sofie-core/blob/master/packages/corelib/src/dataModel/Blueprint.ts)
27-
- [Buckets](https://github.com/nrkno/sofie-core/blob/master/meteor/lib/collections/Buckets.ts)
27+
- [Buckets](https://github.com/nrkno/sofie-core/blob/master/packages/corelib/src/dataModel/Bucket.ts)
2828
- [CoreSystem](https://github.com/nrkno/sofie-core/blob/master/meteor/lib/collections/CoreSystem.ts)
2929
- [Evaluations](https://github.com/nrkno/sofie-core/blob/master/meteor/lib/collections/Evaluations.ts)
3030
- [ExternalMessageQueue](https://github.com/nrkno/sofie-core/blob/master/packages/corelib/src/dataModel/ExternalMessageQueue.ts)

packages/documentation/versioned_docs/version-1.50.0/for-developers/data-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Currently, there is not a very clearly defined flow for modifying these document
2424
This includes:
2525

2626
- [Blueprints](https://github.com/nrkno/sofie-core/blob/master/packages/corelib/src/dataModel/Blueprint.ts)
27-
- [Buckets](https://github.com/nrkno/sofie-core/blob/master/meteor/lib/collections/Buckets.ts)
27+
- [Buckets](https://github.com/nrkno/sofie-core/blob/master/packages/corelib/src/dataModel/Bucket.ts)
2828
- [CoreSystem](https://github.com/nrkno/sofie-core/blob/master/meteor/lib/collections/CoreSystem.ts)
2929
- [Evaluations](https://github.com/nrkno/sofie-core/blob/master/meteor/lib/collections/Evaluations.ts)
3030
- [ExternalMessageQueue](https://github.com/nrkno/sofie-core/blob/master/packages/corelib/src/dataModel/ExternalMessageQueue.ts)

0 commit comments

Comments
 (0)