Skip to content

web-backend


Class: TypedModelController

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:35

Controller for typed model CRUD and metadata endpoints. Manages Internal/External Hazards, Full Scope, and Internal Events models.

Constructors

Constructor

new TypedModelController(typedModelService): TypedModelController

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:41

Construct controller with typed model service dependency.

Parameters

typedModelService

TypedModelService

Service handling typed model CRUD and queries

Returns

TypedModelController

Methods

addNestedToExternalHazard()

addNestedToExternalHazard(body): Promise<TypedModelJSON>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:327

updates external hazards model

Parameters

body

modelId number, nestedId number, and a nestedType camelCase string

modelId

number

nestedId

number

nestedType

string

Returns

Promise<TypedModelJSON>

promise with udpated model


addNestedToFullScope()

addNestedToFullScope(body): Promise<TypedModelJSON>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:339

updates full scope model

Parameters

body

modelId number, nestedId number, and a nestedType camelCase string

modelId

number

nestedId

number

nestedType

string

Returns

Promise<TypedModelJSON>

promise with udpated model


addNestedToInternalEvent()

addNestedToInternalEvent(body): Promise<TypedModelJSON>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:303

updates internal events model

Parameters

body

modelId number, nestedId number, and a nestedType camelCase string

modelId

number

nestedId

number

nestedType

string

Returns

Promise<TypedModelJSON>

promise with udpated model


addNestedToInternalHazard()

addNestedToInternalHazard(body): Promise<TypedModelJSON>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:315

updates internal hazards model

Parameters

body

modelId number, nestedId number, and a nestedType camelCase string

modelId

number

nestedId

number

nestedType

string

Returns

Promise<TypedModelJSON>

promise with udpated model


createExternalHazard()

createExternalHazard(externalHazardsModel): Promise<TypedModel>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:80

Parameters

externalHazardsModel

Partial<ExternalHazards>

takes in an externalHazardsModel with all fields, and a dummy id

Returns

Promise<TypedModel>

promise of an externalHazardsModel


createFullScope()

createFullScope(fullScopeModel): Promise<TypedModel>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:90

Parameters

fullScopeModel

Partial<FullScope>

takes in a fullScopeModel with a dummy id

Returns

Promise<TypedModel>

a promise of fullScopeModel


createInternalEvent()

createInternalEvent(internalEventsModel): Promise<TypedModel>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:60

Parameters

internalEventsModel

Partial<InternalEvents>

takes in an internal events model that needs to be added to the database with a dummy id

Returns

Promise<TypedModel>

a promise of internalEventsModel


createInternalHazard()

createInternalHazard(internalHazardsModel): Promise<TypedModel>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:70

Parameters

internalHazardsModel

Partial<InternalHazards>

takes in an internalHazardsModel with all fields but a dummy id

Returns

Promise<TypedModel>

a promise with an internalHazardsModel


deleteExternalHazard()

deleteExternalHazard(req, modelId): Promise<ExternalHazardsModel>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:268

Parameters

req

any

Express request (user context)

modelId

string

id of the model to be deleted

Returns

Promise<ExternalHazardsModel>

the deleted model in a promise


deleteFullScope()

deleteFullScope(req, modelId): Promise<FullScopeModel>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:291

Delete a Full Scope model by id.

Parameters

req

any

Express request (provides user id)

modelId

string

id of the model to delete

Returns

Promise<FullScopeModel>

the deleted model


deleteInternalEvent()

deleteInternalEvent(req, modelId): Promise<InternalEventsModel>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:257

Parameters

req

any

Express request (user context)

modelId

string

id of the model to be deleted

Returns

Promise<InternalEventsModel>

the deleted model in a promise


deleteInternalHazard()

deleteInternalHazard(req, modelId): Promise<InternalHazardsModel>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:279

Parameters

req

any

Express request (user context)

modelId

string

id of the model to be deleted

Returns

Promise<InternalHazardsModel>

the deleted model in a promise


deleteNestedFromExternalHazard()

deleteNestedFromExternalHazard(id, body): Promise<TypedModelJSON>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:385

Remove a nested model relation from an External Hazards model.

Parameters

id

string

External Hazards model identifier

body

Object containing nestedId and nestedType to remove

nestedId

number

nestedType

string

Returns

Promise<TypedModelJSON>

Updated model JSON


deleteNestedFromFullScope()

deleteNestedFromFullScope(id, body): Promise<TypedModelJSON>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:400

Remove a nested model relation from a Full Scope model.

Parameters

id

string

Full Scope model identifier

body

Object containing nestedId and nestedType to remove

nestedId

number

nestedType

string

Returns

Promise<TypedModelJSON>

Updated model JSON


deleteNestedFromInternalEvent()

deleteNestedFromInternalEvent(id, body): Promise<TypedModelJSON>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:355

Remove a nested model relation from an Internal Events model.

Parameters

id

string

Internal Events model identifier

body

Object containing nestedId and nestedType to remove

nestedId

string | number

nestedType

string

Returns

Promise<TypedModelJSON>

Updated model JSON


deleteNestedFromInternalHazard()

deleteNestedFromInternalHazard(id, body): Promise<TypedModelJSON>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:370

Remove a nested model relation from an Internal Hazards model.

Parameters

id

string

Internal Hazards model identifier

body

Object containing nestedId and nestedType to remove

nestedId

number

nestedType

string

Returns

Promise<TypedModelJSON>

Updated model JSON


getExternalHazard()

getExternalHazard(req, modelId): Promise<ExternalHazards>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:233

gets a single external hazard

Parameters

req

any

Express request (user context)

modelId

string

id of the model to be returned

Returns

Promise<ExternalHazards>

the external hazard the user has with the modelId


getExternalHazards()

getExternalHazards(req): Promise<ExternalHazards[]>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:188

Parameters

req

any

the request providing the user id

Returns

Promise<ExternalHazards[]>

a list of the internal hazards moodels the user is on


getFullScope()

getFullScope(req, modelId): Promise<FullScope>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:244

gets a single full scope

Parameters

req

any

Express request (user context)

modelId

string

id of the model to be returned

Returns

Promise<FullScope>

the full scope the user has with the modelId


getFullScopes()

getFullScopes(req): Promise<FullScope[]>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:198

Parameters

req

any

the request providing the user id

Returns

Promise<FullScope[]>

a list of the full scope models the user is on


getInternalEvent()

getInternalEvent(req, modelId): Promise<InternalEvents>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:211

gets a single internal event

Parameters

req

any

Express request (user context)

modelId

string

id of the model to be returned

Returns

Promise<InternalEvents>

the internal event the user has with the modelId


getInternalEvents()

getInternalEvents(req): Promise<InternalEvents[]>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:168

Parameters

req

any

the request providing the user id

Returns

Promise<InternalEvents[]>

a list of the internal hazards moodels the user is on


getInternalHazard()

getInternalHazard(req, modelId): Promise<InternalHazards>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:222

gets a single internal hazard

Parameters

req

any

Express request (user context)

modelId

string

id of the model to be returned

Returns

Promise<InternalHazards>

the internal hazard the user has with the modelId


getInternalHazards()

getInternalHazards(req): Promise<InternalHazards[]>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:178

Parameters

req

any

the request providing the user id

Returns

Promise<InternalHazards[]>

a list of the internal hazards moodels the user is on


patchExternalHazard()

patchExternalHazard(req, modelId, model): Promise<ExternalHazards>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:136

updates and replaces a single

Parameters

req

any

Express request (user context)

modelId

string

id of the model to be returned

model

Partial<ExternalHazards>

partial model payload to patch

Returns

Promise<ExternalHazards>

the external hazard the user has with the modelId


patchFullScope()

patchFullScope(req, modelId, model): Promise<FullScope>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:152

gets a single full scope

Parameters

req

any

Express request (user context)

modelId

string

id of the model to be returned

model

Partial<FullScope>

partial model payload to patch

Returns

Promise<FullScope>

the full scope the user has with the modelId


patchInternalEvent()

patchInternalEvent(req, modelId, model): Promise<InternalEvents>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:104

gets a single internal event

Parameters

req

any

Express request (user context)

modelId

string

id of the model to be returned

model

Partial<InternalEvents>

partial model payload to patch

Returns

Promise<InternalEvents>

the internal event the user has with the modelId


patchInternalHazard()

patchInternalHazard(req, modelId, model): Promise<InternalHazards>

Defined in: packages/web-backend/src/typedModel/typedModel.controller.ts:120

gets a single internal hazard

Parameters

req

any

Express request (user context)

modelId

string

id of the model to be returned

model

Partial<InternalHazards>

partial model payload to patch

Returns

Promise<InternalHazards>

the internal hazard the user has with the modelId