Skip to content

Commit

Permalink
Merge branch 'main' into feature/typescript/models-project
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielrindlaub authored Jul 16, 2024
2 parents cf4e5ab + f2a06d4 commit 02285ce
Show file tree
Hide file tree
Showing 46 changed files with 834 additions and 751 deletions.
94 changes: 47 additions & 47 deletions src/@types/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export type Scalars = {

export type AutomationAction = {
__typename?: 'AutomationAction';
alertRecipients?: Maybe<Array<Maybe<Scalars['String']['output']>>>;
alertRecipients?: Maybe<Array<Scalars['String']['output']>>;
categoryConfig?: Maybe<Scalars['JSONObject']['output']>;
confThreshold?: Maybe<Scalars['Float']['output']>;
mlModel?: Maybe<Scalars['String']['output']>;
type: Scalars['String']['output'];
};

export type AutomationActionInput = {
alertRecipients?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
alertRecipients?: InputMaybe<Array<Scalars['String']['input']>>;
categoryConfig?: InputMaybe<Scalars['JSONObject']['input']>;
confThreshold?: InputMaybe<Scalars['Float']['input']>;
mlModel?: InputMaybe<Scalars['String']['input']>;
Expand Down Expand Up @@ -64,7 +64,7 @@ export type Batch = {
_id: Scalars['String']['output'];
created?: Maybe<Scalars['Date']['output']>;
dead?: Maybe<Scalars['Int']['output']>;
errors?: Maybe<Array<Maybe<BatchError>>>;
errors?: Maybe<Array<BatchError>>;
imageErrors?: Maybe<Scalars['Int']['output']>;
ingestionComplete?: Maybe<Scalars['Date']['output']>;
originalFile?: Maybe<Scalars['String']['output']>;
Expand Down Expand Up @@ -94,7 +94,7 @@ export type BatchPayload = {

export type BatchesConnection = {
__typename?: 'BatchesConnection';
batches: Array<Maybe<Batch>>;
batches: Array<Batch>;
pageInfo?: Maybe<PageInfo>;
};

Expand Down Expand Up @@ -170,7 +170,7 @@ export type CreateInternalLabelInput = {
};

export type CreateInternalLabelsInput = {
labels: Array<InputMaybe<CreateInternalLabelInput>>;
labels: Array<CreateInternalLabelInput>;
};

export type CreateLabelInput = {
Expand All @@ -186,7 +186,7 @@ export type CreateLabelInput = {
};

export type CreateLabelsInput = {
labels: Array<InputMaybe<CreateLabelInput>>;
labels: Array<CreateLabelInput>;
};

export type CreateObjectInput = {
Expand All @@ -195,7 +195,7 @@ export type CreateObjectInput = {
};

export type CreateObjectsInput = {
objects: Array<InputMaybe<CreateObjectInput>>;
objects: Array<CreateObjectInput>;
};

export type CreateProjectInput = {
Expand All @@ -221,7 +221,7 @@ export type CreateUploadPayload = {
batch: Scalars['String']['output'];
multipartUploadId?: Maybe<Scalars['String']['output']>;
url?: Maybe<Scalars['String']['output']>;
urls?: Maybe<Array<Maybe<Scalars['String']['output']>>>;
urls?: Maybe<Array<Scalars['String']['output']>>;
user: Scalars['String']['output'];
};

Expand Down Expand Up @@ -263,7 +263,7 @@ export type DeleteLabelInput = {
};

export type DeleteLabelsInput = {
labels: Array<InputMaybe<DeleteLabelInput>>;
labels: Array<DeleteLabelInput>;
};

export type DeleteObjectInput = {
Expand All @@ -272,7 +272,7 @@ export type DeleteObjectInput = {
};

export type DeleteObjectsInput = {
objects: Array<InputMaybe<DeleteObjectInput>>;
objects: Array<DeleteObjectInput>;
};

export type DeleteProjectLabelInput = {
Expand Down Expand Up @@ -344,7 +344,7 @@ export type ExportStatusInput = {
export type ExportStatusPayload = {
__typename?: 'ExportStatusPayload';
count?: Maybe<Scalars['Int']['output']>;
error?: Maybe<Array<Maybe<ExportError>>>;
error?: Maybe<Array<ExportError>>;
meta?: Maybe<Scalars['JSONObject']['output']>;
status: Scalars['String']['output'];
url?: Maybe<Scalars['String']['output']>;
Expand All @@ -354,12 +354,12 @@ export type Filters = {
__typename?: 'Filters';
addedEnd?: Maybe<Scalars['Date']['output']>;
addedStart?: Maybe<Scalars['Date']['output']>;
cameras?: Maybe<Array<Maybe<Scalars['String']['output']>>>;
cameras?: Maybe<Array<Scalars['String']['output']>>;
createdEnd?: Maybe<Scalars['Date']['output']>;
createdStart?: Maybe<Scalars['Date']['output']>;
custom?: Maybe<Scalars['String']['output']>;
deployments?: Maybe<Array<Maybe<Scalars['String']['output']>>>;
labels?: Maybe<Array<Maybe<Scalars['String']['output']>>>;
deployments?: Maybe<Array<Scalars['String']['output']>>;
labels?: Maybe<Array<Scalars['String']['output']>>;
notReviewed?: Maybe<Scalars['Boolean']['output']>;
reviewed?: Maybe<Scalars['Boolean']['output']>;
};
Expand All @@ -372,7 +372,7 @@ export type FiltersInput = {
createdStart?: InputMaybe<Scalars['Date']['input']>;
custom?: InputMaybe<Scalars['String']['input']>;
deployments?: InputMaybe<Array<Scalars['String']['input']>>;
labels?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
labels?: InputMaybe<Array<Scalars['String']['input']>>;
reviewed?: InputMaybe<Scalars['Boolean']['input']>;
};

Expand All @@ -387,11 +387,11 @@ export type Image = {
batchId?: Maybe<Scalars['String']['output']>;
bucket: Scalars['String']['output'];
cameraId: Scalars['String']['output'];
comments?: Maybe<Array<Maybe<ImageComment>>>;
comments?: Maybe<Array<ImageComment>>;
dateAdded: Scalars['Date']['output'];
dateTimeOriginal: Scalars['Date']['output'];
deploymentId: Scalars['ID']['output'];
errors?: Maybe<Array<Maybe<ImageError>>>;
errors?: Maybe<Array<ImageError>>;
fileTypeExtension: Scalars['String']['output'];
imageBytes?: Maybe<Scalars['Int']['output']>;
imageHeight?: Maybe<Scalars['Int']['output']>;
Expand All @@ -400,7 +400,7 @@ export type Image = {
make: Scalars['String']['output'];
mimeType?: Maybe<Scalars['String']['output']>;
model?: Maybe<Scalars['String']['output']>;
objects?: Maybe<Array<Maybe<Object>>>;
objects?: Maybe<Array<Object>>;
originalFileName?: Maybe<Scalars['String']['output']>;
path?: Maybe<Scalars['String']['output']>;
projectId: Scalars['String']['output'];
Expand All @@ -414,7 +414,7 @@ export type ImageAttempt = {
_id: Scalars['ID']['output'];
batch?: Maybe<Scalars['String']['output']>;
created: Scalars['Date']['output'];
errors?: Maybe<Array<Maybe<ImageError>>>;
errors?: Maybe<Array<ImageError>>;
metadata?: Maybe<ImageMetadata>;
projectId: Scalars['String']['output'];
};
Expand All @@ -429,7 +429,7 @@ export type ImageComment = {

export type ImageCommentsPayload = {
__typename?: 'ImageCommentsPayload';
comments?: Maybe<Array<Maybe<ImageComment>>>;
comments?: Maybe<Array<ImageComment>>;
};

export type ImageError = {
Expand All @@ -444,7 +444,7 @@ export type ImageError = {

export type ImageErrorsConnection = {
__typename?: 'ImageErrorsConnection';
errors: Array<Maybe<ImageError>>;
errors: Array<ImageError>;
pageInfo?: Maybe<PageInfo>;
};

Expand Down Expand Up @@ -474,7 +474,7 @@ export type ImageMetadata = {

export type ImagesConnection = {
__typename?: 'ImagesConnection';
images: Array<Maybe<Image>>;
images: Array<Image>;
pageInfo?: Maybe<PageInfo>;
};

Expand Down Expand Up @@ -504,7 +504,7 @@ export type LabelDiffsInput = {

export type LabelList = {
__typename?: 'LabelList';
categories?: Maybe<Array<Maybe<Scalars['String']['output']>>>;
categories?: Maybe<Array<Scalars['String']['output']>>;
};

export type LabelUpdate = {
Expand Down Expand Up @@ -532,7 +532,7 @@ export type LocationInput = {
export type MlModel = {
__typename?: 'MLModel';
_id: Scalars['String']['output'];
categories?: Maybe<Array<Maybe<Categories>>>;
categories?: Maybe<Array<Categories>>;
defaultConfThreshold?: Maybe<Scalars['Float']['output']>;
description?: Maybe<Scalars['String']['output']>;
version: Scalars['String']['output'];
Expand Down Expand Up @@ -768,7 +768,7 @@ export type Object = {
__typename?: 'Object';
_id: Scalars['ID']['output'];
bbox?: Maybe<Array<Scalars['Float']['output']>>;
labels?: Maybe<Array<Maybe<Label>>>;
labels?: Maybe<Array<Label>>;
locked: Scalars['Boolean']['output'];
};

Expand All @@ -780,7 +780,7 @@ export type ObjectDiffsInput = {
export type ObjectInput = {
_id: Scalars['ID']['input'];
bbox?: InputMaybe<Array<Scalars['Float']['input']>>;
labels?: InputMaybe<Array<InputMaybe<CreateLabelInput>>>;
labels?: InputMaybe<Array<CreateLabelInput>>;
locked: Scalars['Boolean']['input'];
};

Expand Down Expand Up @@ -812,11 +812,11 @@ export type PointInput = {
export type Project = {
__typename?: 'Project';
_id: Scalars['String']['output'];
automationRules?: Maybe<Array<Maybe<AutomationRule>>>;
availableMLModels?: Maybe<Array<Maybe<Scalars['String']['output']>>>;
cameraConfigs?: Maybe<Array<Maybe<CameraConfig>>>;
automationRules?: Maybe<Array<AutomationRule>>;
availableMLModels?: Maybe<Array<Scalars['String']['output']>>;
cameraConfigs?: Maybe<Array<CameraConfig>>;
description?: Maybe<Scalars['String']['output']>;
labels?: Maybe<Array<Maybe<ProjectLabel>>>;
labels?: Maybe<Array<ProjectLabel>>;
name: Scalars['String']['output'];
timezone: Scalars['String']['output'];
views: Array<View>;
Expand Down Expand Up @@ -857,13 +857,13 @@ export type Query = {
images?: Maybe<ImagesConnection>;
imagesCount?: Maybe<ImagesCount>;
labels?: Maybe<LabelList>;
mlModels?: Maybe<Array<Maybe<MlModel>>>;
projects?: Maybe<Array<Maybe<Project>>>;
mlModels?: Maybe<Array<MlModel>>;
projects?: Maybe<Array<Project>>;
stats?: Maybe<Task>;
task?: Maybe<Task>;
tasks?: Maybe<TasksPayload>;
users?: Maybe<UsersPayload>;
wirelessCameras?: Maybe<Array<Maybe<WirelessCamera>>>;
wirelessCameras?: Maybe<Array<WirelessCamera>>;
};


Expand Down Expand Up @@ -1015,12 +1015,12 @@ export type RegisterCameraInput = {
export type RegisterCameraPayload = {
__typename?: 'RegisterCameraPayload';
project?: Maybe<Project>;
wirelessCameras?: Maybe<Array<Maybe<WirelessCamera>>>;
wirelessCameras?: Maybe<Array<WirelessCamera>>;
};

export type StandardErrorPayload = {
__typename?: 'StandardErrorPayload';
errors?: Maybe<Array<Maybe<Scalars['String']['output']>>>;
errors?: Maybe<Array<Scalars['String']['output']>>;
isOk?: Maybe<Scalars['Boolean']['output']>;
};

Expand All @@ -1047,7 +1047,7 @@ export type Task = {

export type TasksPayload = {
__typename?: 'TasksPayload';
tasks: Array<Maybe<Task>>;
tasks: Array<Task>;
};

export type UnregisterCameraInput = {
Expand All @@ -1057,7 +1057,7 @@ export type UnregisterCameraInput = {
export type UnregisterCameraPayload = {
__typename?: 'UnregisterCameraPayload';
project?: Maybe<Project>;
wirelessCameras?: Maybe<Array<Maybe<WirelessCamera>>>;
wirelessCameras?: Maybe<Array<WirelessCamera>>;
};

export type UpdateAutomationRulesInput = {
Expand All @@ -1066,7 +1066,7 @@ export type UpdateAutomationRulesInput = {

export type UpdateAutomationRulesPayload = {
__typename?: 'UpdateAutomationRulesPayload';
automationRules?: Maybe<Array<Maybe<AutomationRule>>>;
automationRules?: Maybe<Array<AutomationRule>>;
};

export type UpdateBatchInput = {
Expand Down Expand Up @@ -1094,11 +1094,11 @@ export type UpdateImageCommentInput = {
};

export type UpdateLabelsInput = {
updates: Array<InputMaybe<LabelUpdate>>;
updates: Array<LabelUpdate>;
};

export type UpdateObjectsInput = {
updates: Array<InputMaybe<ObjectUpdate>>;
updates: Array<ObjectUpdate>;
};

export type UpdateProjectInput = {
Expand Down Expand Up @@ -1130,12 +1130,12 @@ export type UpdateViewPayload = {

export type User = {
__typename?: 'User';
created: Scalars['String']['output'];
email: Scalars['String']['output'];
enabled: Scalars['Boolean']['output'];
roles: Array<Maybe<UserRole>>;
status: Scalars['String']['output'];
updated: Scalars['String']['output'];
created?: Maybe<Scalars['Date']['output']>;
email?: Maybe<Scalars['String']['output']>;
enabled?: Maybe<Scalars['Boolean']['output']>;
roles: Array<UserRole>;
status?: Maybe<Scalars['String']['output']>;
updated?: Maybe<Scalars['Date']['output']>;
username: Scalars['String']['output'];
};

Expand All @@ -1147,7 +1147,7 @@ export enum UserRole {

export type UsersPayload = {
__typename?: 'UsersPayload';
users: Array<Maybe<User>>;
users: Array<User>;
};

export type Validation = {
Expand Down
3 changes: 3 additions & 0 deletions src/@types/mongodb-query-parser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module 'mongodb-query-parser' {
export const isFilterValid = (filter: string) => boolean;
}
2 changes: 1 addition & 1 deletion src/api/db/models/Batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Batch, { BatchSchema } from '../schemas/Batch.js';
import mongoose from 'mongoose';
import BatchError, { BatchErrorSchema } from '../schemas/BatchError.js';
import retry from 'async-retry';
import { BaseAuthedModel, GenericResponse, MethodParams, roleCheck } from './utils-model.js';
import { BaseAuthedModel, GenericResponse, MethodParams, roleCheck } from './utils.js';
import { ImageErrorModel } from './ImageError.js';
import { Context } from '../../handler.js';

Expand Down
2 changes: 1 addition & 1 deletion src/api/db/models/BatchError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import GraphQLError, { InternalServerError } from '../../errors.js';
import { WRITE_IMAGES_ROLES } from '../../auth/roles.js';
import BatchError, { BatchErrorSchema } from '../schemas/BatchError.js';
import retry from 'async-retry';
import { BaseAuthedModel, GenericResponse, MethodParams, roleCheck } from './utils-model.js';
import { BaseAuthedModel, GenericResponse, MethodParams, roleCheck } from './utils.js';

/**
* BatchErrors are errors that are generated when an uploaded Zip fails
Expand Down
7 changes: 3 additions & 4 deletions src/api/db/models/Camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import GraphQLError, { InternalServerError, CameraRegistrationError } from '../.
import WirelessCamera, { WirelessCameraSchema } from '../schemas/WirelessCamera.js';
import retry from 'async-retry';
import { WRITE_CAMERA_REGISTRATION_ROLES } from '../../auth/roles.js';
import { hasRole, idMatch } from './utils.js';
import { ProjectModel } from './Project.js';
import { BaseAuthedModel, MethodParams } from './utils-model.js';
import { BaseAuthedModel, MethodParams, roleCheck, idMatch } from './utils.js';
import { Context } from '../../handler.js';
import type * as gql from '../../../@types/graphql.js';
import { ProjectSchema } from '../schemas/Project.js';
Expand Down Expand Up @@ -234,12 +233,12 @@ export default class AuthedCameraModel extends BaseAuthedModel {
return await CameraModel.createWirelessCamera(...args);
}

@hasRole(WRITE_CAMERA_REGISTRATION_ROLES)
@roleCheck(WRITE_CAMERA_REGISTRATION_ROLES)
async registerCamera(...args: MethodParams<typeof CameraModel.registerCamera>) {
return await CameraModel.registerCamera(...args);
}

@hasRole(WRITE_CAMERA_REGISTRATION_ROLES)
@roleCheck(WRITE_CAMERA_REGISTRATION_ROLES)
async unregisterCamera(...args: MethodParams<typeof CameraModel.unregisterCamera>) {
return await CameraModel.unregisterCamera(...args);
}
Expand Down
Loading

0 comments on commit 02285ce

Please sign in to comment.