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

refactor: improve api schema #2156

Merged
merged 37 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3b4a79e
Update api-schema.yaml
suhailkakar Apr 29, 2024
41132ef
add userId to components
suhailkakar Apr 29, 2024
957a045
Update api-schema.yaml
suhailkakar Apr 29, 2024
f619066
add null support to issues component
suhailkakar Apr 30, 2024
c00b23c
add kind and userId to session component
suhailkakar Apr 30, 2024
232c22b
add userId to multistream component
suhailkakar Apr 30, 2024
e1fa6a5
make error optional
suhailkakar Apr 30, 2024
65975d3
remove required params from response
suhailkakar Apr 30, 2024
ffba83c
add webhook request body
suhailkakar Apr 30, 2024
1484c40
temp: add type ignore
suhailkakar Apr 30, 2024
a28546e
Update webhook.ts
suhailkakar Apr 30, 2024
10c719b
Update api-schema.yaml
suhailkakar Apr 30, 2024
35d7e0e
Update [id].tsx
suhailkakar Apr 30, 2024
026ed84
final fixes/improvments
suhailkakar May 1, 2024
9d8c42a
for schemas
suhailkakar May 1, 2024
239193d
update webhook payload
suhailkakar May 1, 2024
5129331
Merge commit 'e59ea2791906162b1eb1d309d37adeb01ec88083' into sk/schem…
0xcadams May 14, 2024
f18100b
fix: recordings playback IDs can be null
0xcadams May 14, 2024
db46d77
fix: schema validation
0xcadams May 14, 2024
60d9270
fix: schema default
0xcadams May 14, 2024
fc49743
fix: added null for profiles
0xcadams May 14, 2024
9d5beaf
Merge commit 'f01c4572da84cbee8c106b3d560214b6fe7be0be' into sk/schem…
0xcadams May 14, 2024
8eb2d38
fix: compile schemas
0xcadams May 14, 2024
ea0ab89
fix: change asset responses to 201
0xcadams May 15, 2024
2e87688
fix: change to nullable create/patch stream
0xcadams May 15, 2024
ee2cbf3
feat: added nullable to asset profiles field
0xcadams May 15, 2024
792704d
Merge commit 'ee2cbf3f33b6d01bd42998981d04119e5123090d' into sk/schem…
0xcadams May 15, 2024
c19abe3
fix: merge latest
0xcadams May 15, 2024
66b2ef2
fix: added back 200 response for create asset
0xcadams May 15, 2024
3f544b1
api: Handle null profiles appropriately
victorges May 15, 2024
0fd5380
Merge commit '3f544b16921d31d51b86dce8e7a8c27d540f9713' into sk/schem…
0xcadams May 15, 2024
063df12
Merge commit 'd1936e9ef6f04e9bfcd00bb10b6eb821efe5e0b3' into sk/schem…
0xcadams May 15, 2024
89f5251
api/schema: Add breakdownBy[] to /data/usage docs
victorges May 16, 2024
e86b1d6
api: Delete the deprecated (now broken) /import API
victorges May 16, 2024
2679555
api/schema: Address PR comments
victorges May 16, 2024
9306dae
api/schema: Fix schemas of upload APIs
victorges May 16, 2024
9efd51a
fix: isMobile oneof
0xcadams May 16, 2024
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
114 changes: 78 additions & 36 deletions packages/api/src/schema/api-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@ components:
name:
type: string
example: test_webhook
kind:
type: string
example: webhook
suhailkakar marked this conversation as resolved.
Show resolved Hide resolved
readOnly: true
deprecated: true
userId:
type: string
suhailkakar marked this conversation as resolved.
Show resolved Hide resolved
readOnly: true
deprecated: true
projectId:
type: string
description: The ID of the project
Expand Down Expand Up @@ -452,6 +461,7 @@ components:
kind:
type: string
example: stream
deprecated: true
creatorId:
$ref: "#/components/schemas/creator-id"
userTags:
Expand Down Expand Up @@ -548,18 +558,14 @@ components:
example:
Authorization: "Bearer 123"
isMobile:
type:
- boolean
victorges marked this conversation as resolved.
Show resolved Hide resolved
- integer
type: integer
enum:
- false
- true
- 0
- 1
- 2
description: |-
If true, the stream will be pulled from a mobile source.
default: false
default: 0
location:
type: object
description: |-
Expand Down Expand Up @@ -591,7 +597,9 @@ components:
playbackPolicy:
$ref: "#/components/schemas/playback-policy"
profiles:
type: array
type:
- array
- "null"
default:
- name: 240p0
fps: 0
Expand Down Expand Up @@ -651,7 +659,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:
Expand Down Expand Up @@ -735,21 +745,25 @@ components:
type: boolean
description: Indicates whether the stream is currently live or not.
is_healthy:
type: boolean
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
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
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: |
Expand Down Expand Up @@ -801,6 +815,15 @@ components:
type: string
readOnly: true
example: de7818e7-610a-4057-8f6f-b785dc1e6f88
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
Expand Down Expand Up @@ -889,8 +912,6 @@ components:
items:
$ref: "#/components/schemas/ffmpeg-profile"
error:
required:
- errors
type: object
properties:
errors:
Expand All @@ -913,6 +934,11 @@ components:
example: 09F8B46C-61A0-4254-9875-F71F4C605BC7
name:
type: string
userId:
type: string
readOnly: true
example: 66E2161C-7670-4D05-B71D-DA2D6979556F
deprecated: true
url:
type: string
writeOnly: true
Expand Down Expand Up @@ -958,6 +984,11 @@ components:
description: >-
The playback ID to use with the Playback Info endpoint to retrieve
playback URLs.
userId:
type: string
readOnly: true
example: 66E2161C-7670-4D05-B71D-DA2D6979556F
deprecated: true
staticMp4:
type: boolean
writeOnly: true
Expand Down Expand Up @@ -1327,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:
Expand Down Expand Up @@ -2096,6 +2129,11 @@ components:
type: string
description: Name of the signing key
example: key1
userId:
type: string
readOnly: true
example: 78df0075-b5f3-4683-a618-1086faca35dc
deprecated: true
createdAt:
readOnly: true
type: number
Expand Down Expand Up @@ -2226,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
Expand Down Expand Up @@ -2259,17 +2299,12 @@ components:
type: object
description: |
An individual metric about usage of a user.
required:
- UserID
- CreatorID
- DeliveryUsageMins
- TotalUsageMins
- StorageUsageMins
suhailkakar marked this conversation as resolved.
Show resolved Hide resolved
properties:
UserID:
type: string
description: The user ID associated with the metric
example: 1bde4o2i6xycudoy

CreatorID:
type: string
description: The creator ID associated with the metric
Expand Down Expand Up @@ -2412,7 +2447,7 @@ components:
- source
properties:
live:
type: number
type: integer
enum:
- 0
- 1
Expand Down Expand Up @@ -2968,9 +3003,7 @@ paths:
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/multistream-target"
$ref: "#/components/schemas/multistream-target"
x-speakeasy-name-override: data
default:
description: Error
Expand Down Expand Up @@ -3078,6 +3111,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"
responses:
"200":
description: Success
Expand Down Expand Up @@ -3131,6 +3170,12 @@ paths:
operationId: updateWebhook
tags:
- webhook
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/webhook"
responses:
"200":
description: Success
Expand Down Expand Up @@ -4193,9 +4238,6 @@ paths:
description: |
A simplified metric object about aggregate viewership of an
asset. Either playbackId or dStorageUrl will be set.
required:
- viewCount
- playtimeMins
suhailkakar marked this conversation as resolved.
Show resolved Hide resolved
properties:
playbackId:
$ref: >-
Expand Down
48 changes: 14 additions & 34 deletions packages/api/src/schema/db-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,7 @@ components:
webhook:
table: webhook
properties:
kind:
type: string
example: webhook
readOnly: true
userId:
readOnly: true
type: string
index: true
projectId:
type: string
Expand Down Expand Up @@ -894,15 +888,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
Expand All @@ -928,9 +918,6 @@ components:
table: multistream_target
properties:
userId:
type: string
example: 66E2161C-7670-4D05-B71D-DA2D6979556F
readOnly: true
index: true
asset:
table: asset
Expand All @@ -940,11 +927,7 @@ components:
playbackId:
index: true
userId:
readOnly: true
index: true
type: string
example: 66E2161C-7670-4D05-B71D-DA2D6979556F
description: owner of the asset
source:
oneOf:
- properties:
Expand Down Expand Up @@ -1076,20 +1059,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:
Expand Down Expand Up @@ -1314,10 +1283,7 @@ components:
id:
index: true
userId:
readOnly: true
index: true
type: string
example: 78df0075-b5f3-4683-a618-1086faca35dc
deleted:
type: boolean
default: false
Expand Down Expand Up @@ -1396,3 +1362,17 @@ 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"
5 changes: 3 additions & 2 deletions packages/www/pages/app/stream/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ const ID = () => {
} else if ("errors" in info) {
throw new Error(info.errors.toString());
}
setStream(info.stream);
setStreamOwner(info.user);

setStream(info.stream as Stream);
setStreamOwner(info.user as User);
} catch (err) {
console.error(err); // todo: surface this
}
Expand Down
Loading