Add upload mutations

This commit is contained in:
Ivan Malison 2024-02-03 03:34:57 -07:00
parent 0f6b2b5245
commit 582cf4fe75
6 changed files with 3593 additions and 0 deletions

13
codegen.yml Normal file
View File

@ -0,0 +1,13 @@
overwrite: true
schema: "src/schema.gql"
documents: "src/**/*.gql"
generates:
src/generated/graphql.tsx:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-apollo"
config:
withHooks: true
withHOC: false
withComponent: false

15
package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "railbird-gql",
"version": "1.0.0",
"main": "index.js",
"repository": "ssh://gitea@dev.railbird.ai:1123/railbird/railbird-gql.git",
"author": "Ivan Malison <IvanMalison@gmail.com>",
"license": "MIT",
"dependencies": {
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/typescript": "^4.0.1",
"@graphql-codegen/typescript-operations": "^4.0.1",
"@graphql-codegen/typescript-react-apollo": "^4.2.0",
"graphql": "^16.8.1"
}
}

500
src/generated/graphql.tsx Normal file
View File

@ -0,0 +1,500 @@
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
const defaultOptions = {} as const;
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: { input: string; output: string; }
String: { input: string; output: string; }
Boolean: { input: boolean; output: boolean; }
Int: { input: number; output: number; }
Float: { input: number; output: number; }
/** Date with time (isoformat) */
DateTime: { input: any; output: any; }
/** Decimal (fixed-point) */
Decimal: { input: any; output: any; }
};
export type AggregateResultGql = {
__typename?: 'AggregateResultGQL';
featureBuckets: Array<BucketGql>;
targetMetrics: Array<TargetMetricGql>;
};
export type AndFilter = {
filters: Array<FilterInput>;
};
export type BankFeaturesGql = {
__typename?: 'BankFeaturesGQL';
bankAngle: Scalars['Float']['output'];
distance: Scalars['Float']['output'];
wallsHit: Array<WallTypeEnum>;
};
export type BucketGql = {
__typename?: 'BucketGQL';
lowerBound: Scalars['Float']['output'];
rangeKey: Scalars['String']['output'];
};
export type BucketInputGql = {
lowerBound: Scalars['Float']['input'];
rangeKey: Scalars['String']['input'];
};
export type BucketSetGql = {
__typename?: 'BucketSetGQL';
buckets: Array<BucketGql>;
feature: Scalars['String']['output'];
keyName: Scalars['String']['output'];
};
export type BucketSetInputGql = {
buckets: Array<BucketInputGql>;
feature: Scalars['String']['input'];
};
export type CreateBucketSetInput = {
buckets: Array<BucketInputGql>;
feature: Scalars['String']['input'];
keyName: Scalars['String']['input'];
};
export type CreateUploadStreamReturn = {
__typename?: 'CreateUploadStreamReturn';
videoId: Scalars['Int']['output'];
};
export type CueBallSpeedInput = {
value: RangeFilter;
};
export type CueObjectAngleInput = {
value: RangeFilter;
};
export type CueObjectDistanceInput = {
value: RangeFilter;
};
export type CueObjectFeaturesGql = {
__typename?: 'CueObjectFeaturesGQL';
cueBallSpeed?: Maybe<Scalars['Float']['output']>;
cueObjectAngle?: Maybe<Scalars['Float']['output']>;
cueObjectDistance?: Maybe<Scalars['Float']['output']>;
shotDirection?: Maybe<ShotDirectionEnum>;
};
export enum DeviceTypeEnum {
Android = 'ANDROID',
Browser = 'BROWSER',
Ios = 'IOS'
}
export type EnumFilter = {
equals?: InputMaybe<Scalars['String']['input']>;
};
export type FilterInput = {
andFilters?: InputMaybe<AndFilter>;
cueBallSpeed?: InputMaybe<CueBallSpeedInput>;
cueObjectAngle?: InputMaybe<CueObjectAngleInput>;
cueObjectDistance?: InputMaybe<CueObjectDistanceInput>;
intendedPocketType?: InputMaybe<IntendedPocketTypeInput>;
orFilters?: InputMaybe<OrFilter>;
shotDirection?: InputMaybe<ShotDirectionInput>;
targetPocketDistance?: InputMaybe<TargetPocketDistanceInput>;
};
export type GetUploadLinkReturn = {
__typename?: 'GetUploadLinkReturn';
linksRequested: Scalars['Int']['output'];
uploadUrl: Scalars['String']['output'];
uploadsCompleted: Scalars['Int']['output'];
};
export type IntendedPocketTypeInput = {
value: EnumFilter;
};
export type Mutation = {
__typename?: 'Mutation';
createBucketSet: BucketSetGql;
createUploadStream: CreateUploadStreamReturn;
getUploadLink: GetUploadLinkReturn;
processVideoSource: ProcessVideoSourceReturn;
terminateUploadStream: Scalars['Boolean']['output'];
};
export type MutationCreateBucketSetArgs = {
params: CreateBucketSetInput;
};
export type MutationCreateUploadStreamArgs = {
uploadMetadata?: InputMaybe<UploadMetadataInput>;
videoName?: InputMaybe<Scalars['String']['input']>;
};
export type MutationGetUploadLinkArgs = {
chunkIndex: Scalars['Int']['input'];
videoId: Scalars['Int']['input'];
};
export type MutationProcessVideoSourceArgs = {
input: ProcessVideoSourceInput;
};
export type MutationTerminateUploadStreamArgs = {
videoId: Scalars['Int']['input'];
};
export type OrFilter = {
filters: Array<FilterInput>;
};
export enum PocketEnum {
Corner = 'CORNER',
Side = 'SIDE'
}
export type PocketingIntentionFeaturesGql = {
__typename?: 'PocketingIntentionFeaturesGQL';
intendedPocketType?: Maybe<PocketEnum>;
make?: Maybe<Scalars['Boolean']['output']>;
targetPocketDistance?: Maybe<Scalars['Float']['output']>;
};
export type ProcessVideoSourceInput = {
val: Scalars['Int']['input'];
};
export type ProcessVideoSourceReturn = {
__typename?: 'ProcessVideoSourceReturn';
val: Scalars['Int']['output'];
};
export type Query = {
__typename?: 'Query';
getAggregateShots: Array<AggregateResultGql>;
getBucketSet?: Maybe<BucketSetGql>;
getShots: Array<ShotGql>;
getUser?: Maybe<UserGql>;
getVideo: VideoGql;
};
export type QueryGetAggregateShotsArgs = {
bucketSets: Array<BucketSetInputGql>;
};
export type QueryGetBucketSetArgs = {
keyName: Scalars['String']['input'];
};
export type QueryGetShotsArgs = {
filterInput?: InputMaybe<FilterInput>;
};
export type QueryGetUserArgs = {
userId: Scalars['Int']['input'];
};
export type QueryGetVideoArgs = {
videoId: Scalars['Int']['input'];
};
export type RangeFilter = {
greaterThanEqualTo?: InputMaybe<Scalars['Float']['input']>;
lessThan?: InputMaybe<Scalars['Float']['input']>;
};
export enum ShotDirectionEnum {
Left = 'LEFT',
Right = 'RIGHT',
Straight = 'STRAIGHT'
}
export type ShotDirectionInput = {
value: EnumFilter;
};
export type ShotFeaturesGql = {
__typename?: 'ShotFeaturesGQL';
bank?: Maybe<BankFeaturesGql>;
cueBallSpeed?: Maybe<Scalars['Float']['output']>;
cueObjectAngle?: Maybe<Scalars['Float']['output']>;
cueObjectDistance?: Maybe<Scalars['Float']['output']>;
intendedPocket?: Maybe<PocketEnum>;
shotDirection?: Maybe<ShotDirectionEnum>;
targetPocketDistance?: Maybe<Scalars['Float']['output']>;
};
export type ShotGql = {
__typename?: 'ShotGQL';
createdAt?: Maybe<Scalars['DateTime']['output']>;
cueObjectFeatures?: Maybe<CueObjectFeaturesGql>;
endFrame?: Maybe<Scalars['Int']['output']>;
features?: Maybe<ShotFeaturesGql>;
id?: Maybe<Scalars['Int']['output']>;
pocketingIntentionFeatures?: Maybe<PocketingIntentionFeaturesGql>;
startFrame?: Maybe<Scalars['Int']['output']>;
updatedAt?: Maybe<Scalars['DateTime']['output']>;
videoId?: Maybe<Scalars['Int']['output']>;
};
export type TargetFloatFeatureGql = {
__typename?: 'TargetFloatFeatureGQL';
average?: Maybe<Scalars['Float']['output']>;
featureName: Scalars['String']['output'];
median?: Maybe<Scalars['Float']['output']>;
};
export type TargetMetricGql = {
__typename?: 'TargetMetricGQL';
count?: Maybe<Scalars['Int']['output']>;
floatFeature?: Maybe<TargetFloatFeatureGql>;
makePercentage?: Maybe<Scalars['Float']['output']>;
};
export type TargetPocketDistanceInput = {
value: RangeFilter;
};
export type UploadMetadataInput = {
appVersion?: InputMaybe<Scalars['String']['input']>;
browserName?: InputMaybe<Scalars['String']['input']>;
browserVersion?: InputMaybe<Scalars['String']['input']>;
deviceType?: InputMaybe<DeviceTypeEnum>;
ipAddress?: InputMaybe<Scalars['String']['input']>;
locale?: InputMaybe<Scalars['String']['input']>;
networkType?: InputMaybe<Scalars['String']['input']>;
osVersion?: InputMaybe<Scalars['String']['input']>;
timezone?: InputMaybe<Scalars['String']['input']>;
};
export type UploadStreamGql = {
__typename?: 'UploadStreamGQL';
createdAt: Scalars['DateTime']['output'];
id: Scalars['ID']['output'];
isCompleted: Scalars['Boolean']['output'];
linksRequested: Scalars['Int']['output'];
updatedAt: Scalars['DateTime']['output'];
uploadMetadata: UploadStreamMetadata;
uploadsCompleted: Scalars['Int']['output'];
};
export type UploadStreamMetadata = {
__typename?: 'UploadStreamMetadata';
appVersion?: Maybe<Scalars['String']['output']>;
browserName?: Maybe<Scalars['String']['output']>;
browserVersion?: Maybe<Scalars['String']['output']>;
deviceType?: Maybe<DeviceTypeEnum>;
ipAddress?: Maybe<Scalars['String']['output']>;
locale?: Maybe<Scalars['String']['output']>;
networkType?: Maybe<Scalars['String']['output']>;
osVersion?: Maybe<Scalars['String']['output']>;
timezone?: Maybe<Scalars['String']['output']>;
};
export type UserGql = {
__typename?: 'UserGQL';
createdAt?: Maybe<Scalars['DateTime']['output']>;
id: Scalars['Int']['output'];
statistics: UserStatisticsGql;
updatedAt?: Maybe<Scalars['DateTime']['output']>;
username: Scalars['String']['output'];
};
export type UserStatisticsGql = {
__typename?: 'UserStatisticsGQL';
averageTimeBetweenShots: Scalars['Decimal']['output'];
makePercentage: Scalars['Decimal']['output'];
medianRun?: Maybe<Scalars['Decimal']['output']>;
timeSpentPlaying: Scalars['Decimal']['output'];
totalShots: Scalars['Int']['output'];
totalShotsMade: Scalars['Int']['output'];
};
export type VideoGql = {
__typename?: 'VideoGQL';
averageTimeBetweenShots?: Maybe<Scalars['Decimal']['output']>;
createdAt: Scalars['DateTime']['output'];
elapsedTime: Scalars['Decimal']['output'];
endTime: Scalars['DateTime']['output'];
framesPerSecond: Scalars['Int']['output'];
id: Scalars['Int']['output'];
makePercentage: Scalars['Decimal']['output'];
medianRun: Scalars['Decimal']['output'];
shots: Array<ShotGql>;
startTime: Scalars['DateTime']['output'];
stream?: Maybe<UploadStreamGql>;
totalFrames: Scalars['Int']['output'];
totalShots: Scalars['Int']['output'];
totalShotsMade: Scalars['Int']['output'];
updatedAt: Scalars['DateTime']['output'];
};
export enum WallTypeEnum {
Long = 'LONG',
Short = 'SHORT'
}
export type CreateUploadStreamMutationVariables = Exact<{
videoName: Scalars['String']['input'];
deviceType?: InputMaybe<DeviceTypeEnum>;
osVersion?: InputMaybe<Scalars['String']['input']>;
appVersion?: InputMaybe<Scalars['String']['input']>;
browserName?: InputMaybe<Scalars['String']['input']>;
browserVersion?: InputMaybe<Scalars['String']['input']>;
locale?: InputMaybe<Scalars['String']['input']>;
timezone?: InputMaybe<Scalars['String']['input']>;
networkType?: InputMaybe<Scalars['String']['input']>;
ipAddress?: InputMaybe<Scalars['String']['input']>;
}>;
export type CreateUploadStreamMutation = { __typename?: 'Mutation', createUploadStream: { __typename?: 'CreateUploadStreamReturn', videoId: number } };
export type GetUploadLinkMutationVariables = Exact<{
videoId: Scalars['Int']['input'];
chunkIndex: Scalars['Int']['input'];
}>;
export type GetUploadLinkMutation = { __typename?: 'Mutation', getUploadLink: { __typename?: 'GetUploadLinkReturn', uploadUrl: string, linksRequested: number } };
export type TerminateUploadStreamMutationVariables = Exact<{
videoId: Scalars['Int']['input'];
}>;
export type TerminateUploadStreamMutation = { __typename?: 'Mutation', terminateUploadStream: boolean };
export const CreateUploadStreamDocument = gql`
mutation CreateUploadStream($videoName: String!, $deviceType: DeviceTypeEnum, $osVersion: String, $appVersion: String, $browserName: String, $browserVersion: String, $locale: String, $timezone: String, $networkType: String, $ipAddress: String) {
createUploadStream(
videoName: $videoName
uploadMetadata: {deviceType: $deviceType, osVersion: $osVersion, appVersion: $appVersion, browserName: $browserName, browserVersion: $browserVersion, locale: $locale, timezone: $timezone, networkType: $networkType, ipAddress: $ipAddress}
) {
videoId
}
}
`;
export type CreateUploadStreamMutationFn = Apollo.MutationFunction<CreateUploadStreamMutation, CreateUploadStreamMutationVariables>;
/**
* __useCreateUploadStreamMutation__
*
* To run a mutation, you first call `useCreateUploadStreamMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useCreateUploadStreamMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [createUploadStreamMutation, { data, loading, error }] = useCreateUploadStreamMutation({
* variables: {
* videoName: // value for 'videoName'
* deviceType: // value for 'deviceType'
* osVersion: // value for 'osVersion'
* appVersion: // value for 'appVersion'
* browserName: // value for 'browserName'
* browserVersion: // value for 'browserVersion'
* locale: // value for 'locale'
* timezone: // value for 'timezone'
* networkType: // value for 'networkType'
* ipAddress: // value for 'ipAddress'
* },
* });
*/
export function useCreateUploadStreamMutation(baseOptions?: Apollo.MutationHookOptions<CreateUploadStreamMutation, CreateUploadStreamMutationVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useMutation<CreateUploadStreamMutation, CreateUploadStreamMutationVariables>(CreateUploadStreamDocument, options);
}
export type CreateUploadStreamMutationHookResult = ReturnType<typeof useCreateUploadStreamMutation>;
export type CreateUploadStreamMutationResult = Apollo.MutationResult<CreateUploadStreamMutation>;
export type CreateUploadStreamMutationOptions = Apollo.BaseMutationOptions<CreateUploadStreamMutation, CreateUploadStreamMutationVariables>;
export const GetUploadLinkDocument = gql`
mutation GetUploadLink($videoId: Int!, $chunkIndex: Int!) {
getUploadLink(videoId: $videoId, chunkIndex: $chunkIndex) {
uploadUrl
linksRequested
}
}
`;
export type GetUploadLinkMutationFn = Apollo.MutationFunction<GetUploadLinkMutation, GetUploadLinkMutationVariables>;
/**
* __useGetUploadLinkMutation__
*
* To run a mutation, you first call `useGetUploadLinkMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useGetUploadLinkMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [getUploadLinkMutation, { data, loading, error }] = useGetUploadLinkMutation({
* variables: {
* videoId: // value for 'videoId'
* chunkIndex: // value for 'chunkIndex'
* },
* });
*/
export function useGetUploadLinkMutation(baseOptions?: Apollo.MutationHookOptions<GetUploadLinkMutation, GetUploadLinkMutationVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useMutation<GetUploadLinkMutation, GetUploadLinkMutationVariables>(GetUploadLinkDocument, options);
}
export type GetUploadLinkMutationHookResult = ReturnType<typeof useGetUploadLinkMutation>;
export type GetUploadLinkMutationResult = Apollo.MutationResult<GetUploadLinkMutation>;
export type GetUploadLinkMutationOptions = Apollo.BaseMutationOptions<GetUploadLinkMutation, GetUploadLinkMutationVariables>;
export const TerminateUploadStreamDocument = gql`
mutation TerminateUploadStream($videoId: Int!) {
terminateUploadStream(videoId: $videoId)
}
`;
export type TerminateUploadStreamMutationFn = Apollo.MutationFunction<TerminateUploadStreamMutation, TerminateUploadStreamMutationVariables>;
/**
* __useTerminateUploadStreamMutation__
*
* To run a mutation, you first call `useTerminateUploadStreamMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useTerminateUploadStreamMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [terminateUploadStreamMutation, { data, loading, error }] = useTerminateUploadStreamMutation({
* variables: {
* videoId: // value for 'videoId'
* },
* });
*/
export function useTerminateUploadStreamMutation(baseOptions?: Apollo.MutationHookOptions<TerminateUploadStreamMutation, TerminateUploadStreamMutationVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useMutation<TerminateUploadStreamMutation, TerminateUploadStreamMutationVariables>(TerminateUploadStreamDocument, options);
}
export type TerminateUploadStreamMutationHookResult = ReturnType<typeof useTerminateUploadStreamMutation>;
export type TerminateUploadStreamMutationResult = Apollo.MutationResult<TerminateUploadStreamMutation>;
export type TerminateUploadStreamMutationOptions = Apollo.BaseMutationOptions<TerminateUploadStreamMutation, TerminateUploadStreamMutationVariables>;

View File

@ -0,0 +1,40 @@
mutation CreateUploadStream(
$videoName: String!,
$deviceType: DeviceTypeEnum,
$osVersion: String,
$appVersion: String,
$browserName: String,
$browserVersion: String,
$locale: String,
$timezone: String,
$networkType: String,
$ipAddress: String
) {
createUploadStream(
videoName: $videoName
uploadMetadata: {
deviceType: $deviceType
osVersion: $osVersion
appVersion: $appVersion
browserName: $browserName
browserVersion: $browserVersion
locale: $locale
timezone: $timezone
networkType: $networkType
ipAddress: $ipAddress
}
) {
videoId
}
}
mutation GetUploadLink($videoId: Int!, $chunkIndex: Int!) {
getUploadLink(videoId: $videoId, chunkIndex: $chunkIndex) {
uploadUrl
linksRequested
}
}
mutation TerminateUploadStream($videoId: Int!) {
terminateUploadStream(videoId: $videoId)
}

3025
yarn.lock Normal file

File diff suppressed because it is too large Load Diff