Skip to content

Commit

Permalink
feat(EAV-487): add buckets topic to LSG
Browse files Browse the repository at this point in the history
currently only featuring adLibs and actions valid for all variants (showStyleVariantId === null)
  • Loading branch information
ianshade committed Jan 28, 2025
1 parent 3252531 commit b8c2709
Show file tree
Hide file tree
Showing 26 changed files with 419 additions and 45 deletions.
2 changes: 1 addition & 1 deletion meteor/server/api/buckets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as _ from 'underscore'
import { Meteor } from 'meteor/meteor'
import { Bucket } from '@sofie-automation/meteor-lib/dist/collections/Buckets'
import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'
import { getRandomId, getRandomString, literal } from '../lib/tempLib'
import { BucketAdLib } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibPiece'
import { AdLibAction, AdLibActionCommon } from '@sofie-automation/corelib/dist/dataModel/AdlibAction'
Expand Down
2 changes: 1 addition & 1 deletion meteor/server/api/rest/v1/typeConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import {
DEFAULT_MINIMUM_TAKE_SPAN,
DEFAULT_FALLBACK_PART_DURATION,
} from '@sofie-automation/shared-lib/dist/core/constants'
import { Bucket } from '@sofie-automation/meteor-lib/dist/collections/Buckets'
import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'

Check warning on line 55 in meteor/server/api/rest/v1/typeConversion.ts

View check run for this annotation

Codecov / codecov/patch

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

Added line #L55 was not covered by tests
import { ForceQuickLoopAutoNext } from '@sofie-automation/shared-lib/dist/core/model/StudioSettings'

/*
Expand Down
2 changes: 1 addition & 1 deletion meteor/server/api/userActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { MOSDeviceActions } from './ingest/mosDevice/actions'
import { MethodContextAPI } from './methodContext'
import { ServerClientAPI } from './client'
import { triggerWriteAccessBecauseNoCheckNecessary } from '../security/securityVerify'
import { Bucket } from '@sofie-automation/meteor-lib/dist/collections/Buckets'
import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'
import { BucketsAPI } from './buckets'
import { BucketAdLib } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibPiece'
import { AdLibActionCommon } from '@sofie-automation/corelib/dist/dataModel/AdlibAction'
Expand Down
2 changes: 1 addition & 1 deletion meteor/server/collections/bucket.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BucketAdLibAction } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibAction'
import { BucketAdLib } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibPiece'
import { CollectionName } from '@sofie-automation/corelib/dist/dataModel/Collections'
import { Bucket } from '@sofie-automation/meteor-lib/dist/collections/Buckets'
import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'
import { createAsyncOnlyMongoCollection } from './collection'
import { registerIndex } from './indices'

Expand Down
25 changes: 10 additions & 15 deletions meteor/server/publications/buckets.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { FindOptions } from '@sofie-automation/meteor-lib/dist/collections/lib'
import { meteorPublish } from './lib/lib'
import { MeteorPubSub } from '@sofie-automation/meteor-lib/dist/api/pubsub'
import { Bucket } from '@sofie-automation/meteor-lib/dist/collections/Buckets'
import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'

Check warning on line 3 in meteor/server/publications/buckets.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L3

Added line #L3 was not covered by tests
import { BucketAdLibActions, BucketAdLibs, Buckets } from '../collections'
import { check, Match } from 'meteor/check'
import { StudioId, BucketId, ShowStyleVariantId } from '@sofie-automation/corelib/dist/dataModel/Ids'
import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
import { triggerWriteAccessBecauseNoCheckNecessary } from '../security/securityVerify'

meteorPublish(
MeteorPubSub.buckets,
CorelibPubSub.buckets,

Check warning on line 11 in meteor/server/publications/buckets.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L11

Added line #L11 was not covered by tests
async function (studioId: StudioId, bucketId: BucketId | null, _token: string | undefined) {
check(studioId, String)
check(bucketId, Match.Maybe(String))
Expand All @@ -21,32 +20,28 @@ meteorPublish(
}

return Buckets.findWithCursor(
bucketId
? {
_id: bucketId,
studioId,
}
: {
studioId,
},
{
_id: bucketId ?? undefined,
studioId,
},

Check warning on line 26 in meteor/server/publications/buckets.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L23-L26

Added lines #L23 - L26 were not covered by tests
modifier
)
}
)

meteorPublish(
CorelibPubSub.bucketAdLibPieces,
async function (studioId: StudioId, bucketId: BucketId, showStyleVariantIds: ShowStyleVariantId[]) {
async function (studioId: StudioId, bucketId: BucketId | null, showStyleVariantIds: ShowStyleVariantId[]) {

Check warning on line 34 in meteor/server/publications/buckets.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L34

Added line #L34 was not covered by tests
check(studioId, String)
check(bucketId, String)
check(bucketId, Match.Maybe(String))

Check warning on line 36 in meteor/server/publications/buckets.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L36

Added line #L36 was not covered by tests
check(showStyleVariantIds, Array)

triggerWriteAccessBecauseNoCheckNecessary()

return BucketAdLibs.findWithCursor(
{
studioId: studioId,
bucketId: bucketId,
bucketId: bucketId ?? undefined,

Check warning on line 44 in meteor/server/publications/buckets.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L44

Added line #L44 was not covered by tests
showStyleVariantId: {
$in: [null, ...showStyleVariantIds], // null = valid for all variants
},
Expand All @@ -62,7 +57,7 @@ meteorPublish(

meteorPublish(
CorelibPubSub.bucketAdLibActions,
async function (studioId: StudioId, bucketId: BucketId, showStyleVariantIds: ShowStyleVariantId[]) {
async function (studioId: StudioId, bucketId: BucketId | null, showStyleVariantIds: ShowStyleVariantId[]) {

Check warning on line 60 in meteor/server/publications/buckets.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L60

Added line #L60 was not covered by tests
check(studioId, String)
check(bucketId, String)
check(showStyleVariantIds, Array)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
SetupObserversResult,
} from '../../../lib/customPublication'
import { BucketContentCache, createReactiveContentCache } from './bucketContentCache'
import { Bucket } from '@sofie-automation/meteor-lib/dist/collections/Buckets'
import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'

Check warning on line 24 in meteor/server/publications/pieceContentStatusUI/bucket/publication.ts

View check run for this annotation

Codecov / codecov/patch

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

Added line #L24 was not covered by tests
import {
addItemsWithDependenciesChangesToChangedSet,
fetchStudio,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BucketId, StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
import { BucketId, StudioId } from './Ids'

/**
* A Bucket is an container for AdLib pieces that do not come from a MOS gateway and are
Expand Down
15 changes: 11 additions & 4 deletions packages/corelib/src/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
} from '@sofie-automation/shared-lib/dist/core/model/Ids'
import { BlueprintId, BucketId, RundownPlaylistActivationId, SegmentId, ShowStyleVariantId } from './dataModel/Ids'
import { PackageInfoDB } from './dataModel/PackageInfos'
import { Bucket } from './dataModel/Bucket'

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

/**
* Fetch all bucket adlib pieces for the specified Studio and Bucket.
* Fetch either all buckets for the given Studio, or the Bucket specified.
*/
buckets = 'buckets',
/**
* Fetch all bucket adlib pieces for the specified Studio and Bucket (or all buckets in a Studio).
* The result will be limited to ones valid to the ShowStyleVariants specified, as well as ones marked as valid in any ShowStyleVariant
*/
bucketAdLibPieces = 'bucketAdLibPieces',
/**
* Fetch all bucket adlib action for the specified Studio and Bucket.
* Fetch all bucket adlib action for the specified Studio and Bucket (or all buckets in a Studio).
* The result will be limited to ones valid to the ShowStyleVariants specified, as well as ones marked as valid in any ShowStyleVariant
*/
bucketAdLibActions = 'bucketAdLibActions',
Expand Down Expand Up @@ -297,14 +302,15 @@ export interface CorelibPubSubTypes {
token?: string
) => CollectionName.Studios
[CorelibPubSub.timelineDatastore]: (studioId: StudioId, token?: string) => CollectionName.TimelineDatastore
[CorelibPubSub.buckets]: (studioId: StudioId, bucketId: BucketId | null, token?: string) => CollectionName.Buckets
[CorelibPubSub.bucketAdLibPieces]: (
studioId: StudioId,
bucketId: BucketId,
bucketId: BucketId | null,
showStyleVariantIds: ShowStyleVariantId[]
) => CollectionName.BucketAdLibPieces
[CorelibPubSub.bucketAdLibActions]: (
studioId: StudioId,
bucketId: BucketId,
bucketId: BucketId | null,
showStyleVariantIds: ShowStyleVariantId[]
) => CollectionName.BucketAdLibActions
[CorelibPubSub.expectedPackages]: (studioIds: StudioId[], token?: string) => CollectionName.ExpectedPackages
Expand All @@ -323,6 +329,7 @@ export type CorelibPubSubCollections = {
[CollectionName.AdLibActions]: AdLibAction
[CollectionName.AdLibPieces]: AdLibPiece
[CollectionName.Blueprints]: Blueprint
[CollectionName.Buckets]: Bucket
[CollectionName.BucketAdLibActions]: BucketAdLibAction
[CollectionName.BucketAdLibPieces]: BucketAdLib
[CollectionName.ExpectedMediaItems]: ExpectedMediaItem
Expand Down
2 changes: 1 addition & 1 deletion packages/documentation/docs/for-developers/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Currently, there is not a very clearly defined flow for modifying these document
This includes:

- [Blueprints](https://github.com/nrkno/sofie-core/blob/master/packages/corelib/src/dataModel/Blueprint.ts)
- [Buckets](https://github.com/nrkno/sofie-core/blob/master/meteor/lib/collections/Buckets.ts)
- [Buckets](https://github.com/nrkno/sofie-core/blob/master/packages/corelib/src/dataModel/Bucket.ts)
- [CoreSystem](https://github.com/nrkno/sofie-core/blob/master/meteor/lib/collections/CoreSystem.ts)
- [Evaluations](https://github.com/nrkno/sofie-core/blob/master/meteor/lib/collections/Evaluations.ts)
- [ExternalMessageQueue](https://github.com/nrkno/sofie-core/blob/master/packages/corelib/src/dataModel/ExternalMessageQueue.ts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Currently, there is not a very clearly defined flow for modifying these document
This includes:

- [Blueprints](https://github.com/nrkno/sofie-core/blob/master/packages/corelib/src/dataModel/Blueprint.ts)
- [Buckets](https://github.com/nrkno/sofie-core/blob/master/meteor/lib/collections/Buckets.ts)
- [Buckets](https://github.com/nrkno/sofie-core/blob/master/packages/corelib/src/dataModel/Bucket.ts)
- [CoreSystem](https://github.com/nrkno/sofie-core/blob/master/meteor/lib/collections/CoreSystem.ts)
- [Evaluations](https://github.com/nrkno/sofie-core/blob/master/meteor/lib/collections/Evaluations.ts)
- [ExternalMessageQueue](https://github.com/nrkno/sofie-core/blob/master/packages/corelib/src/dataModel/ExternalMessageQueue.ts)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Logger } from 'winston'
import { CoreHandler } from '../coreHandler'
import { Collection, PublicationCollection } from '../wsHandler'
import { CollectionName } from '@sofie-automation/corelib/dist/dataModel/Collections'
import { BucketAdLibAction } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibAction'
import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
import { CollectionHandlers } from '../liveStatusServer'

export class BucketAdLibActionsHandler
extends PublicationCollection<
BucketAdLibAction[],
CorelibPubSub.bucketAdLibActions,
CollectionName.BucketAdLibActions
>
implements Collection<BucketAdLibAction[]>
{
constructor(logger: Logger, coreHandler: CoreHandler) {
super(CollectionName.BucketAdLibActions, CorelibPubSub.bucketAdLibActions, logger, coreHandler)
}

changed(): void {
const collection = this.getCollectionOrFail()
this._collectionData = collection.find(undefined)
this.notify(this._collectionData)
}

init(handlers: CollectionHandlers): void {
super.init(handlers)
this.setupSubscription(this._studioId, null, []) // This only matches adLibs avilable to all variants
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Logger } from 'winston'
import { CoreHandler } from '../coreHandler'
import { Collection, PublicationCollection } from '../wsHandler'
import { CollectionName } from '@sofie-automation/corelib/dist/dataModel/Collections'
import { BucketAdLib } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibPiece'
import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
import { CollectionHandlers } from '../liveStatusServer'

export class BucketAdLibsHandler
extends PublicationCollection<BucketAdLib[], CorelibPubSub.bucketAdLibPieces, CollectionName.BucketAdLibPieces>
implements Collection<BucketAdLib[]>
{
constructor(logger: Logger, coreHandler: CoreHandler) {
super(CollectionName.BucketAdLibPieces, CorelibPubSub.bucketAdLibPieces, logger, coreHandler)
}

changed(): void {
const collection = this.getCollectionOrFail()
this._collectionData = collection.find(undefined)
this.notify(this._collectionData)
}

init(handlers: CollectionHandlers): void {
super.init(handlers)
this.setupSubscription(this._studioId, null, []) // This only matches adLibs avilable to all variants
}
}
27 changes: 27 additions & 0 deletions packages/live-status-gateway/src/collections/bucketsHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Logger } from 'winston'
import { CoreHandler } from '../coreHandler'
import { Collection, PublicationCollection } from '../wsHandler'
import { CollectionName } from '@sofie-automation/corelib/dist/dataModel/Collections'
import { Bucket } from '@sofie-automation/corelib/dist/dataModel/Bucket'
import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
import { CollectionHandlers } from '../liveStatusServer'

export class BucketsHandler
extends PublicationCollection<Bucket[], CorelibPubSub.buckets, CollectionName.Buckets>
implements Collection<Bucket[]>
{
constructor(logger: Logger, coreHandler: CoreHandler) {
super(CollectionName.Buckets, CorelibPubSub.buckets, logger, coreHandler)
}

changed(): void {
const collection = this.getCollectionOrFail()
this._collectionData = collection.find(undefined)
this.notify(this._collectionData)
}

init(handlers: CollectionHandlers): void {
super.init(handlers)
this.setupSubscription(this._studioId, null)
}
}
12 changes: 12 additions & 0 deletions packages/live-status-gateway/src/liveStatusServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import { PartsHandler } from './collections/partsHandler'
import { PieceInstancesHandler } from './collections/pieceInstancesHandler'
import { AdLibsTopic } from './topics/adLibsTopic'
import { ActivePiecesTopic } from './topics/activePiecesTopic'
import { BucketsHandler } from './collections/bucketsHandler'
import { BucketAdLibsHandler } from './collections/bucketAdLibsHandler'
import { BucketAdLibActionsHandler } from './collections/bucketAdLibActionsHandler'

export interface CollectionHandlers {
studioHandler: StudioHandler
Expand All @@ -40,6 +43,9 @@ export interface CollectionHandlers {
adLibsHandler: AdLibsHandler
globalAdLibActionsHandler: GlobalAdLibActionsHandler
globalAdLibsHandler: GlobalAdLibsHandler
bucketsHandler: BucketsHandler
bucketAdLibsHandler: BucketAdLibsHandler
bucketAdLibActionsHandler: BucketAdLibActionsHandler
}

export class LiveStatusServer {
Expand Down Expand Up @@ -72,6 +78,9 @@ export class LiveStatusServer {
const adLibsHandler = new AdLibsHandler(this._logger, this._coreHandler)
const globalAdLibActionsHandler = new GlobalAdLibActionsHandler(this._logger, this._coreHandler)
const globalAdLibsHandler = new GlobalAdLibsHandler(this._logger, this._coreHandler)
const bucketsHandler = new BucketsHandler(this._logger, this._coreHandler)
const bucketAdLibsHandler = new BucketAdLibsHandler(this._logger, this._coreHandler)
const bucketAdLibActionsHandler = new BucketAdLibActionsHandler(this._logger, this._coreHandler)

const handlers: CollectionHandlers = {
studioHandler,
Expand All @@ -89,6 +98,9 @@ export class LiveStatusServer {
adLibsHandler,
globalAdLibActionsHandler,
globalAdLibsHandler,
bucketsHandler,
bucketAdLibsHandler,
bucketAdLibActionsHandler,
}

for (const handlerName in handlers) {
Expand Down
Loading

0 comments on commit b8c2709

Please sign in to comment.