Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(LSG): add buckets topic #1370

Open
wants to merge 5 commits into
base: release53
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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
83 changes: 39 additions & 44 deletions meteor/server/publications/buckets.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
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'
import { MongoQuery } from '@sofie-automation/corelib/dist/mongo'
import { BucketAdLib } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibPiece'
import { BucketAdLibAction } from '@sofie-automation/corelib/dist/dataModel/BucketAdLibAction'

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#L9-L11

Added lines #L9 - L11 were not covered by tests

meteorPublish(
MeteorPubSub.buckets,
CorelibPubSub.buckets,

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

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L14

Added line #L14 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 @@ -20,68 +22,61 @@
fields: {},
}

return Buckets.findWithCursor(
bucketId
? {
_id: bucketId,
studioId,
}
: {
studioId,
},
modifier
)
const selector: MongoQuery<Bucket> = {
studioId,
}
if (bucketId) selector._id = bucketId

return Buckets.findWithCursor(selector, modifier)

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

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L25-L30

Added lines #L25 - L30 were not covered by tests
}
)

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

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(studioId, String)
check(bucketId, String)
check(bucketId, Match.Maybe(String))

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

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L38

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

triggerWriteAccessBecauseNoCheckNecessary()

return BucketAdLibs.findWithCursor(
{
studioId: studioId,
bucketId: bucketId,
showStyleVariantId: {
$in: [null, ...showStyleVariantIds], // null = valid for all variants
},
const selector: MongoQuery<BucketAdLib> = {
studioId: studioId,
showStyleVariantId: {
$in: [null, ...showStyleVariantIds], // null = valid for all variants
},
}
if (bucketId) selector.bucketId = bucketId

return BucketAdLibs.findWithCursor(selector, {
fields: {
ingestInfo: 0, // This is a large blob, and is not of interest to the UI

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

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L43-L53

Added lines #L43 - L53 were not covered by tests
},
{
fields: {
ingestInfo: 0, // This is a large blob, and is not of interest to the UI
},
}
)
})

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

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L55

Added line #L55 was not covered by tests
}
)

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

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

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L61

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

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

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L63

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

triggerWriteAccessBecauseNoCheckNecessary()

return BucketAdLibActions.findWithCursor(
{
studioId: studioId,
bucketId: bucketId,
showStyleVariantId: {
$in: [null, ...showStyleVariantIds], // null = valid for all variants
},
const selector: MongoQuery<BucketAdLibAction> = {
studioId: studioId,
showStyleVariantId: {
$in: [null, ...showStyleVariantIds], // null = valid for all variants
},
}
if (bucketId) selector.bucketId = bucketId

return BucketAdLibActions.findWithCursor(selector, {
fields: {
ingestInfo: 0, // This is a large blob, and is not of interest to the UI

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

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L68-L78

Added lines #L68 - L78 were not covered by tests
},
{
fields: {
ingestInfo: 0, // This is a large blob, and is not of interest to the UI
},
}
)
})

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

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/buckets.ts#L80

Added line #L80 was not covered by tests
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably let this be? This refers to historical information anyway, so will not align with the rest of documentation.

- [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
6 changes: 6 additions & 0 deletions packages/live-status-gateway/api/asyncapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ channels:
- $ref: '#/components/messages/activePieces'
- $ref: '#/components/messages/segments'
- $ref: '#/components/messages/adLibs'
- $ref: '#/components/messages/buckets'
components:
messages:
ping:
Expand Down Expand Up @@ -124,3 +125,8 @@ components:
description: AdLibs in active Playlist
payload:
$ref: './schemas/adLibs.yaml#/$defs/adLibs'
buckets:
name: buckets
description: Buckets in Studio
payload:
$ref: './schemas/buckets.yaml#/$defs/buckets'
39 changes: 39 additions & 0 deletions packages/live-status-gateway/api/schemas/buckets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
title: Buckets
description: Buckets schema for websocket subscriptions
$defs:
buckets:
type: object
properties:
event:
type: string
const: buckets
buckets:
description: Buckets available in the Studio
type: array
items:
$ref: '#/$defs/bucket'
required: [event, buckets]
additionalProperties: false
examples:
- event: buckets
buckets:
$ref: '#/$defs/bucket/examples'
bucket:
type: object
properties:
id:
description: Unique id of the bucket
type: string
name:
description: The user defined bucket name
type: string
adLibs:
description: The AdLibs in this bucket
type: array
items:
$ref: './adLibs.yaml#/$defs/adLib'
examples:
- id: 'C6K_yIMuGFUk8X_L9A9_jRT6aq4_'
name: My Bucket
adLibs:
$ref: './adLibs.yaml#/$defs/adLib/examples'
Loading
Loading