diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f19326..cdad9b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.9.2] - 2024-10-28 + +- feat: stop storing the message in the datastore + ## [1.9.1] - 2024-09-04 - chore: apply linter suggestions diff --git a/bun.lockb b/bun.lockb index 8121344..e617c62 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/openapi.json b/openapi.json index 8f01d64..3f0ef75 100644 --- a/openapi.json +++ b/openapi.json @@ -11,7 +11,7 @@ "name": "European Union Public License 1.2", "url": "https://spdx.org/licenses/EUPL-1.2.html" }, - "version": "1.9.0" + "version": "1.9.2" }, "externalDocs": { "description": "ARD Eventhub Documentation", @@ -879,15 +879,7 @@ "properties": { "type": { "type": "string", - "enum": [ - "Episode", - "Section", - "Publication", - "Broadcast", - "Show", - "Season", - "Article" - ] + "enum": ["Episode", "Section", "Publication", "Broadcast", "Show", "Season", "Article"] }, "id": { "type": "string", @@ -925,25 +917,13 @@ "type": "string", "description": "If set, it needs to match the URL event parameter", "example": "de.ard.eventhub.v1.radio.track.playing", - "enum": [ - "de.ard.eventhub.v1.radio.track.playing", - "de.ard.eventhub.v1.radio.track.next" - ] + "enum": ["de.ard.eventhub.v1.radio.track.playing", "de.ard.eventhub.v1.radio.track.next"] }, "type": { "type": "string", "description": "The type of the element that triggered this event. See additional file in docs for details.", "example": "music", - "enum": [ - "audio", - "commercial", - "jingle", - "live", - "music", - "news", - "traffic", - "weather" - ] + "enum": ["audio", "commercial", "jingle", "live", "music", "news", "traffic", "weather"] }, "start": { "type": "string", diff --git a/openapi.yaml b/openapi.yaml index fffd25c..193de46 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -9,8 +9,8 @@ info: email: lab@swr.de license: name: European Union Public License 1.2 - url: "https://spdx.org/licenses/EUPL-1.2.html" - version: 1.9.0 + url: 'https://spdx.org/licenses/EUPL-1.2.html' + version: 1.9.2 externalDocs: description: ARD Eventhub Documentation url: https://swrlab.github.io/ard-eventhub/ @@ -47,24 +47,24 @@ paths: type: string example: my-password responses: - "200": + '200': description: Authentication successful content: application/json: schema: - $ref: "#/components/schemas/authResponse" - "400": + $ref: '#/components/schemas/authResponse' + '400': description: Bad Request (invalid input) content: application/json: schema: - $ref: "#/components/schemas/errorBadRequest" - "500": + $ref: '#/components/schemas/errorBadRequest' + '500': description: Internal server error content: application/json: schema: - $ref: "#/components/schemas/errorInternalServerError" + $ref: '#/components/schemas/errorInternalServerError' /auth/refresh: post: tags: @@ -82,24 +82,24 @@ paths: type: string example: abcXYZ... responses: - "200": + '200': description: Authentication successful content: application/json: schema: - $ref: "#/components/schemas/authResponse" - "400": + $ref: '#/components/schemas/authResponse' + '400': description: Bad Request (invalid input) content: application/json: schema: - $ref: "#/components/schemas/errorBadRequest" - "500": + $ref: '#/components/schemas/errorBadRequest' + '500': description: Internal server error content: application/json: schema: - $ref: "#/components/schemas/errorInternalServerError" + $ref: '#/components/schemas/errorInternalServerError' /auth/reset: post: tags: @@ -116,21 +116,21 @@ paths: type: string example: my-email@example.com responses: - "200": + '200': description: Request successful content: {} - "400": + '400': description: Bad Request (invalid input) content: application/json: schema: - $ref: "#/components/schemas/errorBadRequest" - "500": + $ref: '#/components/schemas/errorBadRequest' + '500': description: Internal server error content: application/json: schema: - $ref: "#/components/schemas/errorInternalServerError" + $ref: '#/components/schemas/errorInternalServerError' /events/de.ard.eventhub.v1.radio.track.next: post: tags: @@ -140,34 +140,34 @@ paths: security: - bearerAuth: [] requestBody: - $ref: "#/components/requestBodies/eventV1RadioTrack" + $ref: '#/components/requestBodies/eventV1RadioTrack' responses: - "201": - $ref: "#/components/responses/eventV1RadioTrack" - "400": + '201': + $ref: '#/components/responses/eventV1RadioTrack' + '400': description: Bad Request (invalid input) content: application/json: schema: - $ref: "#/components/schemas/errorBadRequest" - "401": + $ref: '#/components/schemas/errorBadRequest' + '401': description: Missing authentication content: application/json: schema: - $ref: "#/components/schemas/errorUnauthorized" - "403": + $ref: '#/components/schemas/errorUnauthorized' + '403': description: Invalid authorization content: application/json: schema: - $ref: "#/components/schemas/errorForbidden" - "500": + $ref: '#/components/schemas/errorForbidden' + '500': description: Internal server error content: application/json: schema: - $ref: "#/components/schemas/errorInternalServerError" + $ref: '#/components/schemas/errorInternalServerError' /events/de.ard.eventhub.v1.radio.track.playing: post: tags: @@ -177,34 +177,34 @@ paths: security: - bearerAuth: [] requestBody: - $ref: "#/components/requestBodies/eventV1RadioTrack" + $ref: '#/components/requestBodies/eventV1RadioTrack' responses: - "201": - $ref: "#/components/responses/eventV1RadioTrack" - "400": + '201': + $ref: '#/components/responses/eventV1RadioTrack' + '400': description: Bad Request (invalid input) content: application/json: schema: - $ref: "#/components/schemas/errorBadRequest" - "401": + $ref: '#/components/schemas/errorBadRequest' + '401': description: Missing authentication content: application/json: schema: - $ref: "#/components/schemas/errorUnauthorized" - "403": + $ref: '#/components/schemas/errorUnauthorized' + '403': description: Invalid authorization content: application/json: schema: - $ref: "#/components/schemas/errorForbidden" - "500": + $ref: '#/components/schemas/errorForbidden' + '500': description: Internal server error content: application/json: schema: - $ref: "#/components/schemas/errorInternalServerError" + $ref: '#/components/schemas/errorInternalServerError' /subscriptions: get: tags: @@ -214,30 +214,30 @@ paths: security: - bearerAuth: [] responses: - "200": + '200': description: Subscriptions found content: application/json: schema: - $ref: "#/components/schemas/subscriptionsList" - "401": + $ref: '#/components/schemas/subscriptionsList' + '401': description: Missing authentication content: application/json: schema: - $ref: "#/components/schemas/errorUnauthorized" - "403": + $ref: '#/components/schemas/errorUnauthorized' + '403': description: Invalid authorization content: application/json: schema: - $ref: "#/components/schemas/errorForbidden" - "500": + $ref: '#/components/schemas/errorForbidden' + '500': description: Internal server error content: application/json: schema: - $ref: "#/components/schemas/errorInternalServerError" + $ref: '#/components/schemas/errorInternalServerError' post: tags: - subscriptions @@ -250,45 +250,45 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/subscriptionPost" + $ref: '#/components/schemas/subscriptionPost' required: true responses: - "201": + '201': description: Subscription created content: application/json: schema: - $ref: "#/components/schemas/subscriptionResponse" - "400": + $ref: '#/components/schemas/subscriptionResponse' + '400': description: Bad Request (invalid input) content: application/json: schema: - $ref: "#/components/schemas/errorBadRequest" - "401": + $ref: '#/components/schemas/errorBadRequest' + '401': description: Missing authentication content: application/json: schema: - $ref: "#/components/schemas/errorUnauthorized" - "403": + $ref: '#/components/schemas/errorUnauthorized' + '403': description: Invalid authorization content: application/json: schema: - $ref: "#/components/schemas/errorForbidden" - "404": + $ref: '#/components/schemas/errorForbidden' + '404': description: Topic for subscription not found content: application/json: schema: - $ref: "#/components/schemas/errorNotFound" - "500": + $ref: '#/components/schemas/errorNotFound' + '500': description: Internal server error content: application/json: schema: - $ref: "#/components/schemas/errorInternalServerError" + $ref: '#/components/schemas/errorInternalServerError' /subscriptions/{name}: get: tags: @@ -300,45 +300,45 @@ paths: parameters: - name: name in: path - description: "`name` of the desired subscription" + description: '`name` of the desired subscription' required: true style: simple explode: false schema: type: string responses: - "200": + '200': description: Subscription found content: application/json: schema: type: array items: - $ref: "#/components/schemas/subscriptionResponse" - "401": + $ref: '#/components/schemas/subscriptionResponse' + '401': description: Missing authentication content: application/json: schema: - $ref: "#/components/schemas/errorUnauthorized" - "403": + $ref: '#/components/schemas/errorUnauthorized' + '403': description: Invalid authorization content: application/json: schema: - $ref: "#/components/schemas/errorForbidden" - "404": + $ref: '#/components/schemas/errorForbidden' + '404': description: Subscription not found content: application/json: schema: - $ref: "#/components/schemas/errorNotFound" - "500": + $ref: '#/components/schemas/errorNotFound' + '500': description: Internal server error content: application/json: schema: - $ref: "#/components/schemas/errorInternalServerError" + $ref: '#/components/schemas/errorInternalServerError' delete: tags: - subscriptions @@ -349,43 +349,43 @@ paths: parameters: - name: name in: path - description: "`name` of the desired subscription" + description: '`name` of the desired subscription' required: true style: simple explode: false schema: type: string responses: - "200": + '200': description: Subscription deleted content: application/json: schema: - $ref: "#/components/schemas/subscriptionDeleted" - "401": + $ref: '#/components/schemas/subscriptionDeleted' + '401': description: Missing authentication content: application/json: schema: - $ref: "#/components/schemas/errorUnauthorized" - "403": + $ref: '#/components/schemas/errorUnauthorized' + '403': description: Invalid authorization content: application/json: schema: - $ref: "#/components/schemas/errorForbidden" - "404": + $ref: '#/components/schemas/errorForbidden' + '404': description: Subscription not found content: application/json: schema: - $ref: "#/components/schemas/errorNotFound" - "500": + $ref: '#/components/schemas/errorNotFound' + '500': description: Internal server error content: application/json: schema: - $ref: "#/components/schemas/errorInternalServerError" + $ref: '#/components/schemas/errorInternalServerError' /topics: get: tags: @@ -395,18 +395,18 @@ paths: security: - bearerAuth: [] responses: - "200": + '200': description: Topics found content: application/json: schema: - $ref: "#/components/schemas/topicResponse" - "500": + $ref: '#/components/schemas/topicResponse' + '500': description: Internal server error content: application/json: schema: - $ref: "#/components/schemas/errorInternalServerError" + $ref: '#/components/schemas/errorInternalServerError' components: requestBodies: eventV1RadioTrack: @@ -442,7 +442,7 @@ components: content: application/json: schema: - $ref: "#/components/schemas/eventV1PostBody" + $ref: '#/components/schemas/eventV1PostBody' required: true responses: eventV1RadioTrack: @@ -469,7 +469,7 @@ components: content: application/json: schema: - $ref: "#/components/schemas/eventV1ResBody" + $ref: '#/components/schemas/eventV1ResBody' securitySchemes: bearerAuth: type: http @@ -487,7 +487,7 @@ components: type: string description: ISO8601 compliant timestamp for the token expiry format: iso8601-timestamp - example: "2020-01-19T06:00:00+01:00" + example: '2020-01-19T06:00:00+01:00' token: type: string description: ready to use token for API queries @@ -616,7 +616,7 @@ components: When no Core ID is provided, the External ID will be converted by Eventhub. - example: "248000" + example: '248000' id: type: string description: Globally unique identifier, created by Eventhub @@ -695,7 +695,7 @@ components: type: string description: ISO8601 compliant timestamp format: iso8601-timestamp - example: "2020-01-19T06:00:00+01:00" + example: '2020-01-19T06:00:00+01:00' length: type: number format: float @@ -750,7 +750,7 @@ components: example: Person id: type: string - example: "1641010" + example: '1641010' isni: type: string description: ISNI ID if available @@ -771,7 +771,7 @@ components: items: minItems: 1 allOf: - - $ref: "#/components/schemas/services" + - $ref: '#/components/schemas/services' references: type: array description: related external entities @@ -779,7 +779,7 @@ components: items: minItems: 0 allOf: - - $ref: "#/components/schemas/reference" + - $ref: '#/components/schemas/reference' playlistItemId: type: string description: >- @@ -867,7 +867,7 @@ components: ID gets 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! - example: "1234567890" + example: '1234567890' eventV1ResBody: type: object properties: @@ -884,7 +884,7 @@ components: type: integer example: 0 event: - $ref: "#/components/schemas/eventV1PostBody" + $ref: '#/components/schemas/eventV1PostBody' trace: type: string example: null @@ -925,7 +925,7 @@ components: type: array items: allOf: - - $ref: "#/components/schemas/subscriptionResponse" + - $ref: '#/components/schemas/subscriptionResponse' subscriptionResponse: type: object properties: @@ -1016,7 +1016,7 @@ components: properties: id: type: string - example: "1234567890" + example: '1234567890' creator-slug: type: string example: ard-eventhub-swr @@ -1028,7 +1028,7 @@ components: example: prod created: type: string - example: "2021-03-25" + example: '2021-03-25' institution-slug: type: string example: sudwestrundfunk diff --git a/package.json b/package.json index 03e5087..effb96b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ard-eventhub", - "version": "1.9.1", + "version": "1.9.2", "description": "ARD system to distribute real-time (live) metadata for primarily radio broadcasts.", "main": "./src/ingest/index.js", "engines": { @@ -28,25 +28,25 @@ "license": "EUPL-1.2", "dependencies": { "@google-cloud/datastore": "^9.1.0", - "@google-cloud/pubsub": "^4.7.0", + "@google-cloud/pubsub": "^4.8.0", "@google-cloud/secret-manager": "^5.6.0", - "@swrlab/utils": "^2.0.1-beta", + "@swrlab/utils": "^2.0.2", "compression": "^1.7.4", - "dd-trace": "^5.22.0", - "express": "^4.19.2", + "dd-trace": "^5.24.0", + "express": "^4.21.1", "express-openapi-validator": "^5.3.4", - "firebase-admin": "^12.4.0", + "firebase-admin": "^12.7.0", "google-auth-library": "^9.14.1", "jsonwebtoken": "^9.0.2", "luxon": "^3.5.0", "slug": "^9.1.0", "swagger-ui-express": "^5.0.1", "ulid": "^2.3.0", - "winston": "^3.14.2" + "winston": "^3.15.0" }, "devDependencies": { "@biomejs/biome": "^1.8.3", - "@swrlab/style-guide": "^1.0.1", + "@swrlab/style-guide": "^1.0.2", "chai": "^4.5.0", "chai-http": "^4.4.0", "docsify-cli": "^4.4.4", diff --git a/src/ingest/events/post.js b/src/ingest/events/post.js index 9a2836f..b052385 100644 --- a/src/ingest/events/post.js +++ b/src/ingest/events/post.js @@ -7,9 +7,9 @@ // load node utils const { DateTime } = require('luxon') +const ULID = require('ulid') // load eventhub utils -const datastore = require('../../utils/datastore') const { createNewTopic, processServices } = require('../../utils/events') const logger = require('../../utils/logger') const pubsub = require('../../utils/pubsub') @@ -84,9 +84,8 @@ module.exports = async (req, res) => { message.services.map((service) => processServices(service, req)) ) - // save message to datastore - const savedMessage = await datastore.save(message, 'events') - message.id = savedMessage.id.toString() + // generate unique Id from the institution id and a random ULID + message.id = `${req.user.institutionId}-${ULID.ulid()}` // collect unknown topics from returning errors const newServices = []