Skip to content

Commit

Permalink
Merge pull request #484 from swrlab/dev/saerdnaer-patch-1
Browse files Browse the repository at this point in the history
saerdnaer/patch-1
  • Loading branch information
rafaelmaeuer authored Apr 19, 2023
2 parents 7bf6485 + b3df835 commit 33369ee
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 80 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.5.1] - 2023-04-04

- feat: add `references` to external broadcast series and shows

## [1.5.0] - 2023-03-14

- fix: stop logging requests on dev
Expand Down
16 changes: 14 additions & 2 deletions docs/TYPES.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ If a live element is starting. This can be an moderation by an anchor, interview

## `news`

This indicates the beginning of the news in general or a new news item. Get as detailed as possible. The `contributors` field can be used to include details of the `author`. `media` may be used to supply additional elements.
This indicates the beginning of the news in general or a new news item. Get as detailed as possible. The `contributors` field should be used to include details of the `author`. `media` may be used to supply additional elements. `show` references the correspoding broadcast series / grouping.

```json
{
Expand All @@ -87,7 +87,19 @@ This indicates the beginning of the news in general or a new news item. Get as d
}
],
"playlistItemId": "BCS1:cd052498-da90-4308-85d3-046cb15c6840",
"externalId": "TBD",
"externalId": "crid://swr.de/av/406d20f0-d9b8-431f-9e36-e2fa2cf263a5",
"references": [
{
"type": "Show",
"externalId": "crid://swr.de/1234567",
"alternateIds": ["https://normdb.ivz.cn.ard.de/sendereihe/427", "urn:ard:show:027708befb6bfe14", "brid://br.de/broadcastSeries/1235"]
},
{
"type": "Article",
"title": "Kommerzielle US-Raumfahrt - Die neue Weltraumökonomie",
"url": "https://www.deutschlandfunkkultur.de/kommerzielle-us-raumfahrt-die-neue-weltraumoekonomie-100.html"
}
]
}
```
Expand Down
62 changes: 59 additions & 3 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"name": "European Union Public License 1.2",
"url": "https://spdx.org/licenses/EUPL-1.2.html"
},
"version": "1.5.0"
"version": "1.5.1"
},
"externalDocs": {
"description": "ARD-Eventhub Documentation",
Expand Down Expand Up @@ -654,7 +654,7 @@
"components": {
"requestBodies": {
"eventV1RadioTrack": {
"description": "New event to be distributed to subscribers. \n \nThe Eventhub format validation expects only a subset of these variables as minimum set. All other fields are technically optional, but **highly encouraged** to be included, so a best-possible metadata exchange is possible. \nThe subset is defined in the list of required fields of Schemas `eventV1PostBody`, resulting in this body: \n```json\n{\n \"type\": \"music\",\n \"start\": \"2020-01-19T06:00:00+01:00\",\n \"title\": \"Song name\",\n \"services\": [ { ... } ],\n \"playlistItemId\": \"swr3-5678\"\n}\n```\nRequired fields not specified in the Schema, will cause your request to fail. \n \nThe `id` is inserted by Eventhub as string-formatted number, but might be a true string in the future, do not expect this string to remain numbers only!\n",
"description": "New event to be distributed to subscribers.\nThe Eventhub format validation expects only a subset of these variables as minimum set. All other fields are technically optional, but **highly encouraged** to be included, so a best-possible metadata exchange is possible.\nThe subset is defined in the list of required fields of Schemas `eventV1PostBody`, resulting in this body:\n```json\n{\n \"type\": \"music\",\n \"start\": \"2020-01-19T06:00:00+01:00\",\n \"title\": \"Song name\",\n \"services\": [ { ... } ],\n \"playlistItemId\": \"swr3-5678\"\n}\n```\nRequired fields not specified in the Schema, will cause your request to fail.\nThe `id` is inserted by Eventhub as string-formatted number, but might be a true string in the future, do not expect this string to remain numbers only!\n",
"content": {
"application/json": {
"schema": {
Expand All @@ -667,7 +667,7 @@
},
"responses": {
"eventV1RadioTrack": {
"description": "Event created \n \n*Note:* The first request of an event for an externalId that is not registered yet, will return the status `failed: 1`. This indicates that a new topic for the externalId has been created, and the request needs to be repeated:\n```json\n\"statuses\": {\n \"published\": 0,\n \"blocked\": 0,\n \"failed\": 1\n}\n```\nIf the request returns the status `blocked: 1`, it indicates that you are not allowed to publish events under the given publisherId.\n",
"description": "Event created\n*Note:* The first request of an event for an externalId that is not registered yet, will return the status `failed: 1`. This indicates that a new topic for the externalId has been created, and the request needs to be repeated:\n```json\n\"statuses\": {\n \"published\": 0,\n \"blocked\": 0,\n \"failed\": 1\n}\n```\nIf the request returns the status `blocked: 1`, it indicates that you are not allowed to publish events under the given publisherId.\n",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -872,6 +872,49 @@
}
}
},
"reference": {
"type": "object",
"additionalProperties": false,
"required": ["type", "externalId"],
"properties": {
"type": {
"type": "string",
"enum": [
"Episode",
"Section",
"Publication",
"Broadcast",
"Show",
"Season",
"Article"
]
},
"id": {
"type": "string",
"pattern": "^urn:ard:[a-z0-9-]+:[a-z0-9-]+$",
"example": "urn:ard:show:49267f7d67be180d"
},
"externalId": {
"type": "string",
"example": "crid://swr.de/123450",
"pattern": "^(c|b)rid://.+$"
},
"title": {
"type": "string"
},
"url": {
"type": "string",
"format": "uri"
},
"alternateIds": {
"type": "array",
"items": {
"type": "string",
"example": "https://normdb.ivz.cn.ard.de/sendereihe/427"
}
}
}
},
"eventV1PostBody": {
"additionalProperties": false,
"required": ["type", "start", "title", "services", "playlistItemId"],
Expand Down Expand Up @@ -992,6 +1035,19 @@
]
}
},
"references": {
"type": "array",
"description": "related external entities",
"nullable": true,
"items": {
"minItems": 0,
"allOf": [
{
"$ref": "#/components/schemas/reference"
}
]
}
},
"playlistItemId": {
"type": "string",
"description": "Unique identifier (within a publisher) to connect next and playing items if needed",
Expand Down
46 changes: 45 additions & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ info:
license:
name: European Union Public License 1.2
url: "https://spdx.org/licenses/EUPL-1.2.html"
version: 1.5.0
version: 1.5.1
externalDocs:
description: ARD-Eventhub Documentation
url: "https://swrlab.github.io/ard-eventhub/"
Expand Down Expand Up @@ -621,6 +621,42 @@ components:
description: Globally unique identifier, created by Eventhub
example: "urn:ard:permanent-livestream:49267f7d67be180d"

reference:
type: object
additionalProperties: false
required:
- type
- externalId
properties:
type:
type: string
enum:
- Episode
- Section
- Publication
- Broadcast
- Show
- Season
- Article
id:
type: string
pattern: ^urn:ard:[a-z0-9-]+:[a-z0-9-]+$
example: urn:ard:show:49267f7d67be180d
externalId:
type: string
example: crid://swr.de/123450
pattern: ^(c|b)rid://.+$
title:
type: string
url:
type: string
format: uri
alternateIds:
type: array
items:
type: string
example: https://normdb.ivz.cn.ard.de/sendereihe/427

eventV1PostBody:
additionalProperties: false
required:
Expand Down Expand Up @@ -729,6 +765,14 @@ components:
minItems: 1
allOf:
- $ref: "#/components/schemas/services"
references:
type: array
description: related external entities
nullable: true
items:
minItems: 0
allOf:
- $ref: "#/components/schemas/reference"
playlistItemId:
type: string
description: >-
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ard-eventhub",
"version": "1.5.0",
"version": "1.5.1",
"description": "ARD system to distribute real-time (live) metadata for primarily radio broadcasts.",
"main": "./src/ingest/index.js",
"engines": {
Expand Down Expand Up @@ -29,16 +29,16 @@
"author": "SWR Audio Lab <[email protected]>",
"license": "EUPL-1.2",
"dependencies": {
"@google-cloud/datastore": "^7.4.0",
"@google-cloud/pubsub": "^3.4.1",
"@google-cloud/secret-manager": "^4.2.1",
"@google-cloud/datastore": "7.5.1",
"@google-cloud/pubsub": "3.5.0",
"@google-cloud/secret-manager": "4.2.2",
"@swrlab/utils": "1.1.2",
"compression": "1.7.4",
"dd-trace": "3.15.0",
"dd-trace": "3.17.1",
"dotenv": "16.0.3",
"express": "4.18.2",
"express-openapi-validator": "5.0.3",
"firebase-admin": "11.5.0",
"firebase-admin": "11.7.0",
"google-auth-library": "8.7.0",
"jsonwebtoken": "9.0.0",
"luxon": "3.3.0",
Expand All @@ -53,13 +53,13 @@
"chai": "^4.3.7",
"chai-http": "^4.3.0",
"docsify-cli": "^4.4.4",
"eslint": "^8.36.0",
"eslint": "^8.38.0",
"eslint-plugin-chai-friendly": "^0.7.2",
"license-compliance": "^1.2.5",
"mocha": "^10.2.0",
"nodemon": "^2.0.22",
"prettier": "^2.8.7",
"typescript": "^5.0.2"
"typescript": "^5.0.4"
},
"resolutions": {
"ansi-regex": "^5.0.1",
Expand Down
31 changes: 30 additions & 1 deletion test/ingest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,24 @@ const event = {
publisherId: '282310',
},
],
playlistItemId: 'unit-test-playlist',
playlistItemId: 'unit-test-id-in-playlist-567',
references: [
{
type: 'Show',
externalId: 'crid://swr.de/my-show/1234567',
alternateIds: [
'https://normdb.ivz.cn.ard.de/sendereihe/427',
'urn:ard:show:027708befb6bfe14',
'brid://br.de/broadcastSeries/1235',
],
},
{
type: 'Article',
externalId: 'crid://dlf.de/article/1234567',
title: 'Kommerzielle US-Raumfahrt - Die neue Weltraumökonomie',
url: 'https://www.deutschlandfunkkultur.de/kommerzielle-us-raumfahrt-die-neue-weltraumoekonomie-100.html',
},
],
}

describe(`POST ${eventPath}`, () => {
Expand Down Expand Up @@ -214,6 +231,18 @@ describe(`POST ${eventPath}`, () => {
done()
})
})

it('publish a new event with invalid externalId in references', (done) => {
event.references[1].externalId = null
chai.request(server)
.post(eventPath)
.set('Authorization', `Bearer ${accessToken}`)
.send(event)
.end((err, res) => {
testResponse(res, 400)
done()
})
})
})

/*
Expand Down
Loading

0 comments on commit 33369ee

Please sign in to comment.