From 3b4a79ee19432eb4e675ce12fb75c7e4e6d3dd65 Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Mon, 29 Apr 2024 10:56:27 +0530 Subject: [PATCH 01/32] Update api-schema.yaml --- packages/api/src/schema/api-schema.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 236d0e1c37..f6624ce19c 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -715,6 +715,7 @@ components: description: Indicates whether the stream is currently live or not. is_healthy: type: boolean + nullable: true description: Indicates whether the stream is healthy or not. issues: type: string From 41132ef769daa2db4053e28fe43d2295fc1cc3cb Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Mon, 29 Apr 2024 11:22:11 +0530 Subject: [PATCH 02/32] add userId to components --- packages/api/src/schema/api-schema.yaml | 12 +++++++++++- packages/api/src/schema/db-schema.yaml | 8 -------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index f6624ce19c..2bcee72961 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -176,6 +176,11 @@ components: name: type: string example: test_webhook + kind: + type: string + example: webhook + userId: + type: string createdAt: type: number readOnly: true @@ -217,7 +222,6 @@ components: example: "https://my-service.com/webhook" sharedSecret: type: string - writeOnly: true description: shared secret used to sign the webhook payload example: my-secret streamId: @@ -933,6 +937,9 @@ components: description: >- The playback ID to use with the Playback Info endpoint to retrieve playback URLs. + userId: + type: string + example: 66E2161C-7670-4D05-B71D-DA2D6979556F staticMp4: type: boolean writeOnly: true @@ -2062,6 +2069,9 @@ components: type: string description: Name of the signing key example: key1 + userId: + type: string + example: 78df0075-b5f3-4683-a618-1086faca35dc createdAt: readOnly: true type: number diff --git a/packages/api/src/schema/db-schema.yaml b/packages/api/src/schema/db-schema.yaml index a192dcc0b8..0cea15823d 100644 --- a/packages/api/src/schema/db-schema.yaml +++ b/packages/api/src/schema/db-schema.yaml @@ -587,12 +587,9 @@ components: table: webhook properties: kind: - type: string - example: webhook readOnly: true userId: readOnly: true - type: string index: true events: index: true @@ -938,9 +935,6 @@ components: userId: readOnly: true index: true - type: string - example: 66E2161C-7670-4D05-B71D-DA2D6979556F - description: owner of the asset source: oneOf: - properties: @@ -1318,8 +1312,6 @@ components: userId: readOnly: true index: true - type: string - example: 78df0075-b5f3-4683-a618-1086faca35dc deleted: type: boolean default: false From 957a04557e25684e3f845d1f05894ca45e0122cc Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Mon, 29 Apr 2024 20:37:03 +0530 Subject: [PATCH 03/32] Update api-schema.yaml --- packages/api/src/schema/api-schema.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 2bcee72961..48a948bf9e 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -723,12 +723,14 @@ components: description: Indicates whether the stream is healthy or not. issues: type: string + nullable: true description: | Raw issues affecting the stream as described by Mist, if any. We don't expose those to the end-user, showing only human_issues instead. human_issues: type: array + nullable: true description: | A string array of human-readable errors describing issues affecting the stream, if any. @@ -2940,7 +2942,7 @@ paths: content: application/json: schema: - type: array + type: object items: $ref: "#/components/schemas/multistream-target" x-speakeasy-name-override: data From f619066006b59d0b2e4c2023ed338cb2ecf69586 Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Tue, 30 Apr 2024 11:57:42 +0530 Subject: [PATCH 04/32] add null support to issues component --- packages/api/src/schema/api-schema.yaml | 29 ++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 48a948bf9e..7ff810103b 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -718,24 +718,23 @@ components: type: boolean description: Indicates whether the stream is currently live or not. is_healthy: - type: boolean - nullable: true - description: Indicates whether the stream is healthy or not. + oneOf: + - type: 'null' + - type: 'boolean' + description: "Indicates whether the stream is healthy or not." issues: - type: string - nullable: true + oneOf: + - type: 'null' + - type: 'string' description: | - Raw issues affecting the stream as described by Mist, if any. We - don't expose those to the end-user, showing only human_issues - instead. + "Raw issues affecting the stream as described by Mist, if any. We don't expose those to the end-user, showing only human_issues instead." human_issues: - type: array - nullable: true - description: | - A string array of human-readable errors describing issues affecting - the stream, if any. - items: - type: string + oneOf: + - type: 'null' + - type: 'array' + items: + type: 'string' + description: "A string array of human-readable errors describing issues affecting the stream, if any." tracks: type: object description: | From c00b23ca85ed1dc704d601400f416fa19760f9f1 Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Tue, 30 Apr 2024 12:05:29 +0530 Subject: [PATCH 05/32] add kind and userId to session component --- packages/api/src/schema/api-schema.yaml | 6 ++++++ packages/api/src/schema/db-schema.yaml | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 7ff810103b..a28f8d530e 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -786,6 +786,12 @@ components: type: string readOnly: true example: de7818e7-610a-4057-8f6f-b785dc1e6f88 + kind: + type: string + example: stream + userId: + type: string + example: 66E2161C-7670-4D05-B71D-DA2D6979556F name: type: string example: test_session diff --git a/packages/api/src/schema/db-schema.yaml b/packages/api/src/schema/db-schema.yaml index 0cea15823d..84e0b27d38 100644 --- a/packages/api/src/schema/db-schema.yaml +++ b/packages/api/src/schema/db-schema.yaml @@ -887,15 +887,11 @@ components: table: session properties: kind: - type: string - example: stream readOnly: true version: type: string description: Version of the session object userId: - type: string - example: 66E2161C-7670-4D05-B71D-DA2D6979556F index: true lastSeen: index: true From 232c22b4b1f95cda18282a44700109f2b65a539c Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Tue, 30 Apr 2024 18:21:32 +0530 Subject: [PATCH 06/32] add userId to multistream component --- packages/api/src/schema/api-schema.yaml | 3 +++ packages/api/src/schema/db-schema.yaml | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index a28f8d530e..281d6bc38c 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -899,6 +899,9 @@ components: example: 09F8B46C-61A0-4254-9875-F71F4C605BC7 name: type: string + userId: + type: string + example: 66E2161C-7670-4D05-B71D-DA2D6979556F url: type: string writeOnly: true diff --git a/packages/api/src/schema/db-schema.yaml b/packages/api/src/schema/db-schema.yaml index 84e0b27d38..2a41c01b17 100644 --- a/packages/api/src/schema/db-schema.yaml +++ b/packages/api/src/schema/db-schema.yaml @@ -917,8 +917,6 @@ components: table: multistream_target properties: userId: - type: string - example: 66E2161C-7670-4D05-B71D-DA2D6979556F readOnly: true index: true asset: From e1fa6a5d51f64c2ecfc76353a9103476bb28768c Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Tue, 30 Apr 2024 18:41:37 +0530 Subject: [PATCH 07/32] make error optional --- packages/api/src/schema/api-schema.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 281d6bc38c..40efbb9300 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -875,8 +875,6 @@ components: items: $ref: "#/components/schemas/ffmpeg-profile" error: - required: - - errors type: object properties: errors: From 65975d394168187d45815a2310366653fdf7cf96 Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Tue, 30 Apr 2024 20:02:11 +0530 Subject: [PATCH 08/32] remove required params from response --- packages/api/src/schema/api-schema.yaml | 27 +++++++++---------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 40efbb9300..f380bc5f0e 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -719,22 +719,24 @@ components: description: Indicates whether the stream is currently live or not. is_healthy: oneOf: - - type: 'null' - - type: 'boolean' + - type: "null" + - type: "boolean" description: "Indicates whether the stream is healthy or not." issues: oneOf: - - type: 'null' - - type: 'string' + - type: "null" + - type: "string" description: | "Raw issues affecting the stream as described by Mist, if any. We don't expose those to the end-user, showing only human_issues instead." human_issues: oneOf: - - type: 'null' - - type: 'array' + - type: "null" + - type: "array" items: - type: 'string' - description: "A string array of human-readable errors describing issues affecting the stream, if any." + type: "string" + description: + "A string array of human-readable errors describing issues affecting + the stream, if any." tracks: type: object description: | @@ -2239,12 +2241,6 @@ components: type: object description: | An individual metric about usage of a user. - required: - - UserID - - CreatorID - - DeliveryUsageMins - - TotalUsageMins - - StorageUsageMins properties: UserID: type: string @@ -4173,9 +4169,6 @@ paths: description: | A simplified metric object about aggregate viewership of an asset. Either playbackId or dStorageUrl will be set. - required: - - viewCount - - playtimeMins properties: playbackId: $ref: >- From ffba83c7270a373225ec39caf71eecc6c8a35330 Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Tue, 30 Apr 2024 20:37:20 +0530 Subject: [PATCH 09/32] add webhook request body --- packages/api/src/schema/api-schema.yaml | 26 +++++++++++++++++++++++++ packages/api/src/schema/db-schema.yaml | 14 ------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index f380bc5f0e..e5878f9e00 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -162,6 +162,20 @@ components: - VP8 - VP9 example: H.264 + webhook-payload: + type: object + additionalProperties: false + properties: + name: + $ref: "#/components/schemas/webhook/properties/name" + url: + $ref: "#/components/schemas/webhook/properties/url" + events: + $ref: "#/components/schemas/webhook/properties/events" + sharedSecret: + $ref: "#/components/schemas/webhook/properties/sharedSecret" + streamId: + $ref: "#/components/schemas/webhook/properties/streamId" webhook: type: object required: @@ -3054,6 +3068,12 @@ paths: To create a new webhook, you need to make an API call with the events you want to listen for and the URL that will be called when those events occur. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/webhook-payload" responses: "200": description: Success @@ -3107,6 +3127,12 @@ paths: operationId: updateWebhook tags: - webhook + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/webhook-payload" responses: "200": description: Success diff --git a/packages/api/src/schema/db-schema.yaml b/packages/api/src/schema/db-schema.yaml index 2a41c01b17..2ac81d420f 100644 --- a/packages/api/src/schema/db-schema.yaml +++ b/packages/api/src/schema/db-schema.yaml @@ -1066,20 +1066,6 @@ components: type: number description: Timestamp (in milliseconds) at which the stream started. example: 1587667174725 - webhook-patch-payload: - type: object - additionalProperties: false - properties: - name: - $ref: "#/components/schemas/webhook/properties/name" - url: - $ref: "#/components/schemas/webhook/properties/url" - events: - $ref: "#/components/schemas/webhook/properties/events" - sharedSecret: - $ref: "#/components/schemas/webhook/properties/sharedSecret" - streamId: - $ref: "#/components/schemas/webhook/properties/streamId" ipfs-file-info: properties: cid: From 1484c40628fb7a654072b5e1d92e993678c30c59 Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Tue, 30 Apr 2024 21:10:25 +0530 Subject: [PATCH 10/32] temp: add type ignore --- packages/www/pages/app/stream/[id].tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/www/pages/app/stream/[id].tsx b/packages/www/pages/app/stream/[id].tsx index 6b6cb68f48..7a6ba5a60f 100644 --- a/packages/www/pages/app/stream/[id].tsx +++ b/packages/www/pages/app/stream/[id].tsx @@ -258,7 +258,10 @@ const ID = () => { } else if ("errors" in info) { throw new Error(info.errors.toString()); } + + // @ts-ignore setStream(info.stream); + // @ts-ignore setStreamOwner(info.user); } catch (err) { console.error(err); // todo: surface this From a28546ed84554ad4b000057f3db0352c33552a75 Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Tue, 30 Apr 2024 21:13:27 +0530 Subject: [PATCH 11/32] Update webhook.ts --- packages/api/src/controllers/webhook.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/src/controllers/webhook.ts b/packages/api/src/controllers/webhook.ts index f39f6e7fa6..0730a48853 100644 --- a/packages/api/src/controllers/webhook.ts +++ b/packages/api/src/controllers/webhook.ts @@ -197,7 +197,7 @@ app.put("/:id", authorizer({}), validatePost("webhook"), async (req, res) => { app.patch( "/:id", authorizer({}), - validatePost("webhook-patch-payload"), + validatePost("webhook-payload"), async (req, res) => { const webhook = await db.webhook.get(req.params.id); From 10c719b4f5ecc01288cd867b130316799e7415d7 Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Tue, 30 Apr 2024 22:04:13 +0530 Subject: [PATCH 12/32] Update api-schema.yaml --- packages/api/src/schema/api-schema.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index e5878f9e00..956358b8d3 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -236,6 +236,7 @@ components: example: "https://my-service.com/webhook" sharedSecret: type: string + writeOnly: true description: shared secret used to sign the webhook payload example: my-secret streamId: @@ -2958,9 +2959,7 @@ paths: content: application/json: schema: - type: object - items: - $ref: "#/components/schemas/multistream-target" + $ref: "#/components/schemas/multistream-target" x-speakeasy-name-override: data default: description: Error From 35d7e0e3265ef414446525ed14b749d79c0f0b55 Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Tue, 30 Apr 2024 22:06:20 +0530 Subject: [PATCH 13/32] Update [id].tsx --- packages/www/pages/app/stream/[id].tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/www/pages/app/stream/[id].tsx b/packages/www/pages/app/stream/[id].tsx index 7a6ba5a60f..8420249558 100644 --- a/packages/www/pages/app/stream/[id].tsx +++ b/packages/www/pages/app/stream/[id].tsx @@ -259,10 +259,8 @@ const ID = () => { throw new Error(info.errors.toString()); } - // @ts-ignore - setStream(info.stream); - // @ts-ignore - setStreamOwner(info.user); + setStream(info.stream as Stream); + setStreamOwner(info.user as User); } catch (err) { console.error(err); // todo: surface this } From 026ed848ea170feff1cf09811572e8ad5af8bc40 Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Wed, 1 May 2024 08:20:19 +0530 Subject: [PATCH 14/32] final fixes/improvments --- packages/api/src/controllers/webhook.ts | 71 +++++++++++++++---------- packages/api/src/schema/api-schema.yaml | 17 ++++++ packages/api/src/schema/db-schema.yaml | 8 +-- 3 files changed, 60 insertions(+), 36 deletions(-) diff --git a/packages/api/src/controllers/webhook.ts b/packages/api/src/controllers/webhook.ts index 0730a48853..ba39a68b10 100644 --- a/packages/api/src/controllers/webhook.ts +++ b/packages/api/src/controllers/webhook.ts @@ -143,18 +143,23 @@ app.get("/subscribed/:event", authorizer({}), async (req, res) => { return res.json(data); }); -app.post("/", authorizer({}), validatePost("webhook"), async (req, res) => { - const id = uuid(); - const doc = validateWebhookPayload(id, req.user.id, Date.now(), req.body); - try { - await req.store.create(doc); - } catch (e) { - console.error(e); - throw e; +app.post( + "/", + authorizer({}), + validatePost("webhook-payload"), + async (req, res) => { + const id = uuid(); + const doc = validateWebhookPayload(id, req.user.id, Date.now(), req.body); + try { + await req.store.create(doc); + } catch (e) { + console.error(e); + throw e; + } + res.status(201); + res.json(doc); } - res.status(201); - res.json(doc); -}); +); app.get("/:id", authorizer({}), async (req, res) => { // get a specific webhook @@ -173,26 +178,34 @@ app.get("/:id", authorizer({}), async (req, res) => { res.json(webhook); }); -app.put("/:id", authorizer({}), validatePost("webhook"), async (req, res) => { - // modify a specific webhook - const webhook = await req.store.get(`webhook/${req.body.id}`); - if ((webhook.userId !== req.user.id || webhook.deleted) && !req.user.admin) { - // do not reveal that webhooks exists - res.status(404); - return res.json({ errors: ["not found"] }); - } +app.put( + "/:id", + authorizer({}), + validatePost("webhook-payload"), + async (req, res) => { + // modify a specific webhook + const webhook = await req.store.get(`webhook/${req.body.id}`); + if ( + (webhook.userId !== req.user.id || webhook.deleted) && + !req.user.admin + ) { + // do not reveal that webhooks exists + res.status(404); + return res.json({ errors: ["not found"] }); + } - const { id, userId, createdAt } = webhook; - const doc = validateWebhookPayload(id, userId, createdAt, req.body); - try { - await req.store.replace(doc); - } catch (e) { - console.error(e); - throw e; + const { id, userId, createdAt } = webhook; + const doc = validateWebhookPayload(id, userId, createdAt, req.body); + try { + await req.store.replace(doc); + } catch (e) { + console.error(e); + throw e; + } + res.status(200); + res.json({ id: req.body.id }); } - res.status(200); - res.json({ id: req.body.id }); -}); +); app.patch( "/:id", diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 956358b8d3..ac4a163102 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -193,8 +193,12 @@ components: kind: type: string example: webhook + readOnly: true + deprecated: true userId: type: string + readOnly: true + deprecated: true createdAt: type: number readOnly: true @@ -467,6 +471,7 @@ components: kind: type: string example: stream + deprecated: true creatorId: $ref: "#/components/schemas/creator-id" userTags: @@ -649,7 +654,9 @@ components: Timestamp (in milliseconds) when the stream was last terminated userId: type: string + readOnly: true example: "we7818e7-610a-4057-8f6f-b785dc1e6f88" + deprecated: true renditions: type: object new-stream-payload: @@ -806,9 +813,12 @@ components: kind: type: string example: stream + deprecated: true userId: type: string + readOnly: true example: 66E2161C-7670-4D05-B71D-DA2D6979556F + deprecated: true name: type: string example: test_session @@ -916,7 +926,9 @@ components: type: string userId: type: string + readOnly: true example: 66E2161C-7670-4D05-B71D-DA2D6979556F + deprecated: true url: type: string writeOnly: true @@ -964,7 +976,9 @@ components: playback URLs. userId: type: string + readOnly: true example: 66E2161C-7670-4D05-B71D-DA2D6979556F + deprecated: true staticMp4: type: boolean writeOnly: true @@ -2096,7 +2110,9 @@ components: example: key1 userId: type: string + readOnly: true example: 78df0075-b5f3-4683-a618-1086faca35dc + deprecated: true createdAt: readOnly: true type: number @@ -2261,6 +2277,7 @@ components: type: string description: The user ID associated with the metric example: 1bde4o2i6xycudoy + CreatorID: type: string description: The creator ID associated with the metric diff --git a/packages/api/src/schema/db-schema.yaml b/packages/api/src/schema/db-schema.yaml index 2ac81d420f..7fba8c785d 100644 --- a/packages/api/src/schema/db-schema.yaml +++ b/packages/api/src/schema/db-schema.yaml @@ -586,10 +586,7 @@ components: webhook: table: webhook properties: - kind: - readOnly: true - userId: - readOnly: true + userId: index: true events: index: true @@ -917,7 +914,6 @@ components: table: multistream_target properties: userId: - readOnly: true index: true asset: table: asset @@ -927,7 +923,6 @@ components: playbackId: index: true userId: - readOnly: true index: true source: oneOf: @@ -1290,7 +1285,6 @@ components: id: index: true userId: - readOnly: true index: true deleted: type: boolean From 9d8c42a82c4356087b3e72256918acb37d1f792c Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Wed, 1 May 2024 08:24:01 +0530 Subject: [PATCH 15/32] for schemas --- packages/api/src/schema/api-schema.yaml | 2 +- packages/api/src/schema/db-schema.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index ac4a163102..b6a5afe54f 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -2277,7 +2277,7 @@ components: type: string description: The user ID associated with the metric example: 1bde4o2i6xycudoy - + CreatorID: type: string description: The creator ID associated with the metric diff --git a/packages/api/src/schema/db-schema.yaml b/packages/api/src/schema/db-schema.yaml index 7fba8c785d..8f28e0d175 100644 --- a/packages/api/src/schema/db-schema.yaml +++ b/packages/api/src/schema/db-schema.yaml @@ -586,7 +586,7 @@ components: webhook: table: webhook properties: - userId: + userId: index: true events: index: true From 239193db19717ac700cebc5de84b82939e0de239 Mon Sep 17 00:00:00 2001 From: Suhail Kakar Date: Wed, 1 May 2024 08:51:20 +0530 Subject: [PATCH 16/32] update webhook payload --- packages/api/src/controllers/webhook.ts | 73 ++++++++++--------------- packages/api/src/schema/api-schema.yaml | 18 +----- packages/api/src/schema/db-schema.yaml | 15 +++++ 3 files changed, 47 insertions(+), 59 deletions(-) diff --git a/packages/api/src/controllers/webhook.ts b/packages/api/src/controllers/webhook.ts index ba39a68b10..f39f6e7fa6 100644 --- a/packages/api/src/controllers/webhook.ts +++ b/packages/api/src/controllers/webhook.ts @@ -143,23 +143,18 @@ app.get("/subscribed/:event", authorizer({}), async (req, res) => { return res.json(data); }); -app.post( - "/", - authorizer({}), - validatePost("webhook-payload"), - async (req, res) => { - const id = uuid(); - const doc = validateWebhookPayload(id, req.user.id, Date.now(), req.body); - try { - await req.store.create(doc); - } catch (e) { - console.error(e); - throw e; - } - res.status(201); - res.json(doc); +app.post("/", authorizer({}), validatePost("webhook"), async (req, res) => { + const id = uuid(); + const doc = validateWebhookPayload(id, req.user.id, Date.now(), req.body); + try { + await req.store.create(doc); + } catch (e) { + console.error(e); + throw e; } -); + res.status(201); + res.json(doc); +}); app.get("/:id", authorizer({}), async (req, res) => { // get a specific webhook @@ -178,39 +173,31 @@ app.get("/:id", authorizer({}), async (req, res) => { res.json(webhook); }); -app.put( - "/:id", - authorizer({}), - validatePost("webhook-payload"), - async (req, res) => { - // modify a specific webhook - const webhook = await req.store.get(`webhook/${req.body.id}`); - if ( - (webhook.userId !== req.user.id || webhook.deleted) && - !req.user.admin - ) { - // do not reveal that webhooks exists - res.status(404); - return res.json({ errors: ["not found"] }); - } +app.put("/:id", authorizer({}), validatePost("webhook"), async (req, res) => { + // modify a specific webhook + const webhook = await req.store.get(`webhook/${req.body.id}`); + if ((webhook.userId !== req.user.id || webhook.deleted) && !req.user.admin) { + // do not reveal that webhooks exists + res.status(404); + return res.json({ errors: ["not found"] }); + } - const { id, userId, createdAt } = webhook; - const doc = validateWebhookPayload(id, userId, createdAt, req.body); - try { - await req.store.replace(doc); - } catch (e) { - console.error(e); - throw e; - } - res.status(200); - res.json({ id: req.body.id }); + const { id, userId, createdAt } = webhook; + const doc = validateWebhookPayload(id, userId, createdAt, req.body); + try { + await req.store.replace(doc); + } catch (e) { + console.error(e); + throw e; } -); + res.status(200); + res.json({ id: req.body.id }); +}); app.patch( "/:id", authorizer({}), - validatePost("webhook-payload"), + validatePost("webhook-patch-payload"), async (req, res) => { const webhook = await db.webhook.get(req.params.id); diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index b6a5afe54f..a69c37ab4b 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -162,20 +162,6 @@ components: - VP8 - VP9 example: H.264 - webhook-payload: - type: object - additionalProperties: false - properties: - name: - $ref: "#/components/schemas/webhook/properties/name" - url: - $ref: "#/components/schemas/webhook/properties/url" - events: - $ref: "#/components/schemas/webhook/properties/events" - sharedSecret: - $ref: "#/components/schemas/webhook/properties/sharedSecret" - streamId: - $ref: "#/components/schemas/webhook/properties/streamId" webhook: type: object required: @@ -3089,7 +3075,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/webhook-payload" + $ref: "#/components/schemas/webhook" responses: "200": description: Success @@ -3148,7 +3134,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/webhook-payload" + $ref: "#/components/schemas/webhook" responses: "200": description: Success diff --git a/packages/api/src/schema/db-schema.yaml b/packages/api/src/schema/db-schema.yaml index 8f28e0d175..d1c3f781fd 100644 --- a/packages/api/src/schema/db-schema.yaml +++ b/packages/api/src/schema/db-schema.yaml @@ -1360,3 +1360,18 @@ components: example: 09F8B46C-61A0-4254-9875-F71F4C605BC7 catalystPipelineStrategy: $ref: "#/components/schemas/task/properties/params/properties/upload/properties/catalystPipelineStrategy" + webhook-patch-payload: + type: object + additionalProperties: false + properties: + name: + $ref: "#/components/schemas/webhook/properties/name" + url: + $ref: "#/components/schemas/webhook/properties/url" + events: + $ref: "#/components/schemas/webhook/properties/events" + sharedSecret: + $ref: "#/components/schemas/webhook/properties/sharedSecret" + streamId: + $ref: "#/components/schemas/webhook/properties/streamId" + \ No newline at end of file From f18100b4a22b0ef910bf94a3469eeb835f7fa48f Mon Sep 17 00:00:00 2001 From: Chase Adams Date: Tue, 14 May 2024 09:31:51 -0700 Subject: [PATCH 17/32] fix: recordings playback IDs can be null --- packages/api/src/schema/api-schema.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 4e5d2aef7c..aa197b5f5e 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -2264,7 +2264,9 @@ components: type: number example: 200000 playback-policy: - type: object + type: + - object + - "null" description: Whether the playback policy for a asset or stream is public or signed additionalProperties: false From db46d7751bb39105f6d165f10efd7339b01fb45d Mon Sep 17 00:00:00 2001 From: Chase Adams Date: Tue, 14 May 2024 09:35:15 -0700 Subject: [PATCH 18/32] fix: schema validation --- packages/api/src/schema/api-schema.yaml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index aa197b5f5e..1b62900f91 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -558,12 +558,8 @@ components: example: Authorization: "Bearer 123" isMobile: - type: - - boolean - - integer + type: integer enum: - - false - - true - 0 - 1 - 2 @@ -2447,7 +2443,7 @@ components: - source properties: live: - type: number + type: integer enum: - 0 - 1 From 60d92703ff75fe53a6ead61cd0f9672256bf24d6 Mon Sep 17 00:00:00 2001 From: Chase Adams Date: Tue, 14 May 2024 09:39:59 -0700 Subject: [PATCH 19/32] fix: schema default --- packages/api/src/schema/api-schema.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 1b62900f91..051f7d1200 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -565,7 +565,7 @@ components: - 2 description: |- If true, the stream will be pulled from a mobile source. - default: false + default: 0 location: type: object description: |- From fc497435bf332235ac039e970c714131cd60a011 Mon Sep 17 00:00:00 2001 From: Chase Adams Date: Tue, 14 May 2024 10:05:03 -0700 Subject: [PATCH 20/32] fix: added null for profiles --- packages/api/src/schema/api-schema.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 051f7d1200..73789155ba 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -597,7 +597,9 @@ components: playbackPolicy: $ref: "#/components/schemas/playback-policy" profiles: - type: array + type: + - array + - "null" default: - name: 240p0 fps: 0 @@ -1356,7 +1358,9 @@ components: type: boolean description: Decides if the output video should include C2PA signature profiles: - type: array + type: + - array + - "null" items: $ref: "#/components/schemas/transcode-profile" targetSegmentSizeSecs: From 8eb2d38ba5efeb0c05605e48946d64b3f8965dcc Mon Sep 17 00:00:00 2001 From: Chase Adams Date: Tue, 14 May 2024 10:52:03 -0700 Subject: [PATCH 21/32] fix: compile schemas --- packages/api/src/compile-schemas.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/api/src/compile-schemas.js b/packages/api/src/compile-schemas.js index 7fab22088c..74425a271e 100644 --- a/packages/api/src/compile-schemas.js +++ b/packages/api/src/compile-schemas.js @@ -72,16 +72,26 @@ const data = _.merge({}, apiData, dbData); const indexPath = path.resolve(validatorDir, "index.js"); write(indexPath, indexStr); - const typeDefinition = `export type InputCreatorId = + const creatorIdTypeDefinition = `export type InputCreatorId = | { type: "unverified"; value: string; } | string;`; + const playbackPolicyTypeDefinition = "export type PlaybackPolicy1 = null;"; + const playbackPolicy2TypeDefinition = + "export type PlaybackPolicy2 = PlaybackPolicy | PlaybackPolicy1;"; + let typeStr = types.join("\n\n"); - const cleanedTypeStr = typeStr.split(typeDefinition).join(""); - typeStr = `${cleanedTypeStr.trim()}\n\n${typeDefinition}`; + const cleanedTypeStr = typeStr + .split(creatorIdTypeDefinition) + .join("") + .split(playbackPolicyTypeDefinition) + .join("") + .split(playbackPolicy2TypeDefinition) + .join(""); + typeStr = `${cleanedTypeStr.trim()}\n\n${creatorIdTypeDefinition}\n\n${playbackPolicyTypeDefinition}\n\n${playbackPolicy2TypeDefinition}`; const typePath = path.resolve(schemaDir, "types.d.ts"); write(typePath, typeStr); From ea0ab89950386a9757f5b72512a7d60082181ec3 Mon Sep 17 00:00:00 2001 From: Chase Adams Date: Wed, 15 May 2024 08:34:18 -0700 Subject: [PATCH 22/32] fix: change asset responses to 201 --- packages/api/src/schema/api-schema.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 0a0057288c..1e33475640 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -3397,7 +3397,7 @@ paths: schema: $ref: "#/components/schemas/new-asset-payload" responses: - "200": + "201": description: Success content: application/json: @@ -3457,7 +3457,7 @@ paths: schema: $ref: "#/components/schemas/new-asset-from-url-payload" responses: - "200": + "201": description: Success content: application/json: From 2e87688c2ae34490e98cef9b11c1000867cafcf0 Mon Sep 17 00:00:00 2001 From: Chase Adams Date: Wed, 15 May 2024 09:47:23 -0700 Subject: [PATCH 23/32] fix: change to nullable create/patch stream --- packages/api/src/schema/api-schema.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index cc2cf0db12..11c45428b5 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -661,7 +661,11 @@ components: playbackPolicy: $ref: "#/components/schemas/playback-policy" profiles: - $ref: "#/components/schemas/stream/properties/profiles" + type: + - array + - "null" + items: + $ref: "#/components/schemas/ffmpeg-profile" record: $ref: "#/components/schemas/stream/properties/record" multistream: @@ -695,7 +699,11 @@ components: playbackPolicy: $ref: "#/components/schemas/playback-policy" profiles: - $ref: "#/components/schemas/stream/properties/profiles" + type: + - array + - "null" + items: + $ref: "#/components/schemas/ffmpeg-profile" userTags: $ref: "#/components/schemas/stream/properties/userTags" target-add-payload: From ee2cbf3f33b6d01bd42998981d04119e5123090d Mon Sep 17 00:00:00 2001 From: Chase Adams Date: Wed, 15 May 2024 09:52:48 -0700 Subject: [PATCH 24/32] feat: added nullable to asset profiles field --- packages/api/src/schema/api-schema.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 11c45428b5..fd512dbc97 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -1314,7 +1314,9 @@ components: type: boolean description: Decides if the output video should include C2PA signature profiles: - type: array + type: + - array + - "null" items: $ref: "#/components/schemas/transcode-profile" targetSegmentSizeSecs: From c19abe3adc6d72c10f33770ab638e75d0c799268 Mon Sep 17 00:00:00 2001 From: Chase Adams Date: Wed, 15 May 2024 09:55:30 -0700 Subject: [PATCH 25/32] fix: merge latest --- packages/api/src/schema/api-schema.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 432b9de5c0..f51bc08449 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -593,9 +593,7 @@ components: playbackPolicy: $ref: "#/components/schemas/playback-policy" profiles: - type: - - array - - "null" + type: array default: - name: 240p0 fps: 0 From 66b2ef22668ad80354dcdc68050ee20eaa2ce56c Mon Sep 17 00:00:00 2001 From: Chase Adams Date: Wed, 15 May 2024 10:01:16 -0700 Subject: [PATCH 26/32] fix: added back 200 response for create asset --- packages/api/src/schema/api-schema.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index f51bc08449..b79c9fdc27 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -3463,6 +3463,26 @@ paths: schema: $ref: "#/components/schemas/new-asset-from-url-payload" responses: + "200": + description: Import in progress + content: + application/json: + schema: + type: object + additionalProperties: false + required: + - asset + - task + properties: + asset: + $ref: "#/components/schemas/asset" + task: + type: object + properties: + id: + type: string + example: 34d7618e-fd42-4798-acf5-19504616a11e + x-speakeasy-name-override: data "201": description: Success content: From 3f544b16921d31d51b86dce8e7a8c27d540f9713 Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Wed, 15 May 2024 18:07:32 +0100 Subject: [PATCH 27/32] api: Handle null profiles appropriately --- packages/api/src/controllers/asset.ts | 5 +++-- packages/api/src/controllers/stream.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/api/src/controllers/asset.ts b/packages/api/src/controllers/asset.ts index 178baac525..edc1b16b1f 100644 --- a/packages/api/src/controllers/asset.ts +++ b/packages/api/src/controllers/asset.ts @@ -862,7 +862,7 @@ const uploadWithUrlHandler: RequestHandler = async (req, res) => { "vod-thumbs-off", req.user?.id )), - profiles, + ...(profiles ? { profiles } : null), // avoid serializing null profiles on the task, targetSegmentSizeSecs, }, }, @@ -897,7 +897,7 @@ app.post( let playbackId = await generateUniquePlaybackId(id); const { vodObjectStoreId, jwtSecret, jwtAudience } = req.config; - const { encryption, c2pa } = req.body as NewAssetPayload; + const { encryption, c2pa, profiles } = req.body as NewAssetPayload; if (encryption) { if (encryption.encryptedKey) { if (!isValidBase64(encryption.encryptedKey)) { @@ -944,6 +944,7 @@ app.post( catalystPipelineStrategy: catalystPipelineStrategy(req), encryption, c2pa, + ...(profiles ? { profiles } : null), // avoid serializing null profiles on the task }, }, null, diff --git a/packages/api/src/controllers/stream.ts b/packages/api/src/controllers/stream.ts index ff3a0c3a10..c871b7d3c6 100644 --- a/packages/api/src/controllers/stream.ts +++ b/packages/api/src/controllers/stream.ts @@ -1358,8 +1358,8 @@ async function handleCreateStream(req: Request, payload: NewStreamPayload) { } let doc: DBStream = { - profiles: req.config.defaultStreamProfiles, ...payload, + profiles: payload.profiles || req.config.defaultStreamProfiles, kind: "stream", userId: req.user.id, creatorId: mapInputCreatorId(payload.creatorId), From 89f52511889168d26f9f917d3bce071f8bba7c63 Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Thu, 16 May 2024 14:03:39 +0100 Subject: [PATCH 28/32] api/schema: Add breakdownBy[] to /data/usage docs --- packages/api/src/schema/api-schema.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index b79c9fdc27..847089a6cd 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -4295,6 +4295,17 @@ paths: The creator ID to filter the query results schema: type: string + - name: "breakdownBy[]" + in: query + description: | + The list of fields to break down the query results. Currently the + only supported breakdown is by `creatorId`. + schema: + type: array + items: + type: string + enum: + - creatorId responses: "200": description: A Usage Metric object From e86b1d695a9537accbf0b93fb4c8b7f5285924cf Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Thu, 16 May 2024 14:06:06 +0100 Subject: [PATCH 29/32] api: Delete the deprecated (now broken) /import API Everyone should be using /upload/url now --- packages/api/src/controllers/asset.ts | 145 +++++++++++++------------- 1 file changed, 71 insertions(+), 74 deletions(-) diff --git a/packages/api/src/controllers/asset.ts b/packages/api/src/controllers/asset.ts index edc1b16b1f..82fb5017cd 100644 --- a/packages/api/src/controllers/asset.ts +++ b/packages/api/src/controllers/asset.ts @@ -804,88 +804,85 @@ app.post( } ); -const uploadWithUrlHandler: RequestHandler = async (req, res) => { - let { url, encryption, c2pa, profiles, targetSegmentSizeSecs } = - req.body as NewAssetFromUrlPayload; - if (!url) { - return res.status(422).json({ - errors: [`Must provide a "url" field for the asset contents`], - }); - } - if (encryption) { - if (encryption.encryptedKey) { - if (!isValidBase64(encryption.encryptedKey)) { - return res.status(422).json({ - errors: [`"encryptedKey" must be valid base64`], - }); +app.post( + "/upload/url", + authorizer({}), + validatePost("new-asset-from-url-payload"), + async (req, res) => { + let { url, encryption, c2pa, profiles, targetSegmentSizeSecs } = + req.body as NewAssetFromUrlPayload; + if (!url) { + return res.status(422).json({ + errors: [`Must provide a "url" field for the asset contents`], + }); + } + if (encryption) { + if (encryption.encryptedKey) { + if (!isValidBase64(encryption.encryptedKey)) { + return res.status(422).json({ + errors: [`"encryptedKey" must be valid base64`], + }); + } } } - } - const id = uuid(); - const playbackId = await generateUniquePlaybackId(id); - const newAsset = await validateAssetPayload(req, id, playbackId, Date.now(), { - type: "url", - url, - encryption: assetEncryptionWithoutKey(encryption), - }); - const dupAsset = await db.asset.findDuplicateUrlUpload( - url, - req.user.id, - req.project?.id - ); - if (dupAsset) { - const [task] = await db.task.find({ outputAssetId: dupAsset.id }); - if (!task.length) { - console.error("Found asset with no task", dupAsset); - // proceed as a regular new asset - } else { - // return the existing asset and task, as if created now, with a slightly - // different status code (200, not 201). Should be transparent to clients. - res.status(200).json({ asset: dupAsset, task: { id: task[0].id } }); - return; + const id = uuid(); + const playbackId = await generateUniquePlaybackId(id); + const newAsset = await validateAssetPayload( + req, + id, + playbackId, + Date.now(), + { + type: "url", + url, + encryption: assetEncryptionWithoutKey(encryption), + } + ); + const dupAsset = await db.asset.findDuplicateUrlUpload( + url, + req.user.id, + req.project?.id + ); + if (dupAsset) { + const [task] = await db.task.find({ outputAssetId: dupAsset.id }); + if (!task.length) { + console.error("Found asset with no task", dupAsset); + // proceed as a regular new asset + } else { + // return the existing asset and task, as if created now, with a slightly + // different status code (200, not 201). Should be transparent to clients. + res.status(200).json({ asset: dupAsset, task: { id: task[0].id } }); + return; + } } - } - await ensureQueueCapacity(req.config, req.user.id); + await ensureQueueCapacity(req.config, req.user.id); - const asset = await createAsset(newAsset, req.queue); - const task = await req.taskScheduler.createAndScheduleTask( - "upload", - { - upload: { - url, - c2pa, - catalystPipelineStrategy: catalystPipelineStrategy(req), - encryption, - thumbnails: !(await isExperimentSubject( - "vod-thumbs-off", - req.user?.id - )), - ...(profiles ? { profiles } : null), // avoid serializing null profiles on the task, - targetSegmentSizeSecs, + const asset = await createAsset(newAsset, req.queue); + const task = await req.taskScheduler.createAndScheduleTask( + "upload", + { + upload: { + url, + c2pa, + catalystPipelineStrategy: catalystPipelineStrategy(req), + encryption, + thumbnails: !(await isExperimentSubject( + "vod-thumbs-off", + req.user?.id + )), + ...(profiles ? { profiles } : null), // avoid serializing null profiles on the task, + targetSegmentSizeSecs, + }, }, - }, - undefined, - asset - ); - - res.status(201); - res.json({ asset, task: { id: task.id } }); -}; + undefined, + asset + ); -app.post( - "/upload/url", - authorizer({}), - validatePost("new-asset-from-url-payload"), - uploadWithUrlHandler -); -// TODO: Remove this at some point. Registered only for backward compatibility. -app.post( - "/import", - authorizer({}), - validatePost("new-asset-payload"), - uploadWithUrlHandler + res.status(201); + res.json({ asset, task: { id: task.id } }); + } ); app.post( From 26795558b1cd3e0bec5355bb6d16ac431822a057 Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Thu, 16 May 2024 14:07:13 +0100 Subject: [PATCH 30/32] api/schema: Address PR comments --- packages/api/src/schema/api-schema.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 847089a6cd..0196ab0405 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -3464,7 +3464,7 @@ paths: $ref: "#/components/schemas/new-asset-from-url-payload" responses: "200": - description: Import in progress + description: Upload in progress content: application/json: schema: @@ -3478,6 +3478,8 @@ paths: $ref: "#/components/schemas/asset" task: type: object + required: + - id properties: id: type: string From 9306dae5875cfceaebc462c2944c2815d0c035d5 Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Thu, 16 May 2024 14:21:29 +0100 Subject: [PATCH 31/32] api/schema: Fix schemas of upload APIs --- packages/api/src/schema/api-schema.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 0196ab0405..47e4548f6c 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -3403,7 +3403,7 @@ paths: schema: $ref: "#/components/schemas/new-asset-payload" responses: - "201": + "200": description: Success content: application/json: @@ -3438,6 +3438,9 @@ paths: $ref: "#/components/schemas/asset" task: type: object + required: + - id + additionalProperties: false properties: id: type: string @@ -3480,13 +3483,14 @@ paths: type: object required: - id + additionalProperties: false properties: id: type: string example: 34d7618e-fd42-4798-acf5-19504616a11e x-speakeasy-name-override: data "201": - description: Success + description: Upload started content: application/json: schema: @@ -3500,6 +3504,9 @@ paths: $ref: "#/components/schemas/asset" task: type: object + required: + - id + additionalProperties: false properties: id: type: string From 9efd51a5819fe04d5577c5d72889a4467e4c35d8 Mon Sep 17 00:00:00 2001 From: Chase Adams Date: Thu, 16 May 2024 09:58:43 -0700 Subject: [PATCH 32/32] fix: isMobile oneof --- packages/api/src/schema/api-schema.yaml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 47e4548f6c..f9dceb565e 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -554,13 +554,19 @@ components: example: Authorization: "Bearer 123" isMobile: - type: integer - enum: - - 0 - - 1 - - 2 + oneOf: + - type: integer + enum: + - 0 + - 1 + - 2 + description: |- + 0: not mobile, 1: mobile screen share, 2: mobile camera. + - type: boolean + description: |- + If true, the stream will be pulled from a mobile source. description: |- - If true, the stream will be pulled from a mobile source. + Indicates whether the stream will be pulled from a mobile source. default: 0 location: type: object