Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
# Generate Async API Docs
```
npm install -g @asyncapi/generator
```
```
ag asyncapi_hmi.yaml @asyncapi/html-template -o static/hmi
ag asyncapi_mobile.yaml @asyncapi/html-template -o static/secret_mobile
ag asyncapi_trex.yaml @asyncapi/html-template -o static/trex
```

View File

@@ -0,0 +1,331 @@
asyncapi: 2.0.0
info:
title: HMI Websocket API
version: 1.0.0
description: This serves as the documentation for websocket connections made between the HMI and the gateway.
servers:
local:
url: localhost/secret_mobile
description: local
protocol: wss
development:
url: dev-gw.cloud.fiskerinc.com/secret_mobile
description: dev
protocol: wss
preproduction:
url: gw.cloud.fiskerinc.com/secret_mobile
description: preprod
protocol: wss
production:
url: gw.cec-prd.fiskerinc.com/secret_mobile
description: prod
protocol: wss
production-eu:
url: gw.cec-euprd.fiskerinc.com/secret_mobile
description: prod-eu
protocol: wss
channels:
Verify:
publish:
message:
$ref: '#/components/messages/Verify'
subscribe:
message:
$ref: '#/components/messages/VerifyResponse'
SessionId:
subscribe:
message:
$ref: '#/components/messages/SessionId'
MapDestination:
subscribe:
message:
$ref: '#/components/messages/MapDestinationSource'
MapRoute:
subscribe:
message:
$ref: '#/components/messages/MapRouteSource'
Profiles:
publish:
message:
$ref: '#/components/messages/Profiles'
subscribe:
message:
$ref: '#/components/messages/ProfilesResponse'
ProfileNew:
subscribe:
message:
$ref: '#/components/messages/ProfileNew'
ProfileUpdate:
subscribe:
message:
$ref: '#/components/messages/ProfileUpdate'
ProfileDelete:
subscribe:
message:
$ref: '#/components/messages/ProfileDelete'
SettingsUpdate:
publish:
message:
$ref: '#/components/messages/SettingsUpdate'
subscribe:
message:
$ref: '#/components/messages/SettingsUpdateNotification'
SubscriptionsUpdate:
subscribe:
message:
$ref: '#/components/messages/SubscriptionsUpdate'
UpdateManifest:
subscribe:
message:
$ref: '#/components/messages/UpdateManifest'
UpdateApprove:
publish:
message:
$ref: '#/components/messages/UpdateApprove'
CarUpdate:
subscribe:
message:
$ref: '#/components/messages/CarUpdate'
Error:
subscribe:
message:
$ref: '#/components/messages/Error'
components:
messages:
Verify:
description: Sent by the HMI to authenticate itself with the cloud. Fields vary depending on whether the HMI already has a driver profile.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "verify"
const: verify
data:
$ref: './schema/hmi/TXMessage.json#/$defs/VerifyModel'
VerifyResponse:
description: Received by the HMI after sending Verify.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "verify"
const: verify
data:
$ref: './schema/hmi/RXMessage.json#/$defs/VerifyResponseModel'
SessionId:
description: Provides a session ID unique to the HMI.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "session_id"
const: session_id
data:
$ref: './schema/hmi/RXMessage.json#/$defs/SessionIdModel'
MapDestinationSource:
description: Provides map destination to the HMI sent from mobile.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "map_destination"
const: map_destination
data:
$ref: './schema/hmi/RXMessage.json#/$defs/MapDestinationSourceModel'
MapRouteSource:
description: Provides map route to the HMI sent from mobile.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "map_route"
const: map_route
data:
$ref: './schema/hmi/RXMessage.json#/$defs/MapRouteSourceModel'
Profiles:
description: Prompts the cloud to send down all driver profiles on the car.
payload:
type: object
required:
- handler
properties:
handler:
type: string
description: expects the string "profiles"
const: profiles
ProfilesResponse:
description: Provides an updated version of all driver profiles on the car.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "profiles"
const: profiles
data:
type: array
description: stores data for response
items:
$ref: './schema/hmi/RXMessage.json#/$defs/CarToDriverModel'
ProfileNew:
description: Provides a single driver profile to be added on the car.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "profile_new"
const: profile_new
data:
$ref: './schema/hmi/RXMessage.json#/$defs/CarToDriverModel'
ProfileUpdate:
description: Provides an updated version of a single driver profile on the car.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "profile_update"
const: profile_update
data:
$ref: './schema/hmi/RXMessage.json#/$defs/CarToDriverUpdateModel'
ProfileDelete:
description: Describes the driver profile to remove from HMI.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "profile_delete"
const: profile_delete
data:
$ref: './schema/hmi/RXMessage.json#/$defs/CarToDriverDeleteModel'
SettingsUpdate:
description: Notifies the cloud of a change in settings on the HMI.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "settings_update"
const: settings_update
data:
$ref: './schema/hmi/TXMessage.json#/$defs/SettingsUpdateModel'
SettingsUpdateNotification:
description: Notifies the HMI of a change in settings.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "settings_update"
const: settings_update
data:
$ref: './schema/hmi/RXMessage.json#/$defs/SettingsUpdateModel'
SubscriptionsUpdate:
description: Notifies the HMI of a change in a subscription.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "subscriptions_update"
const: subscriptions_update
data:
$ref: './schema/hmi/RXMessage.json#/$defs/SubscriptionsUpdateModel'
UpdateManifest:
description: Provides a summary of an OTA update event.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "update_manifest"
const: update_manifest
data:
$ref: './schema/hmi/RXMessage.json#/$defs/UpdateManifest'
UpdateApprove:
description: Notifies the cloud that an update has been approved and can be downloaded.
payload:
type: object
required:
- handler
properties:
handler:
type: string
description: expects the string "update_approve"
const: update_approve
CarUpdate:
description: Provides a status update on a specific car update.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "car_update"
const: car_update
data:
$ref: './schema/hmi/RXMessage.json#/$defs/UpdateProgressModel'
Error:
description: Generic error message
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "error"
const: error
data:
$ref: './schema/hmi/RXMessage.json#/$defs/ErrorModel'

View File

@@ -0,0 +1,447 @@
asyncapi: 2.0.0
info:
title: Mobile Websocket API
version: 1.0.0
description: This serves as the documentation for websocket connections made between the mobile app and the gateway.
servers:
local:
url: localhost/secret_mobile
description: local
protocol: wss
development:
url: dev-gw.cloud.fiskerinc.com/secret_mobile
description: dev
protocol: wss
preproduction:
url: gw.cloud.fiskerinc.com/secret_mobile
description: preprod
protocol: wss
production:
url: gw.cec-prd.fiskerinc.com/secret_mobile
description: prod
protocol: wss
production-eu:
url: gw.cec-euprd.fiskerinc.com/secret_mobile
description: prod-eu
protocol: wss
channels:
Verify:
publish:
message:
$ref: '#/components/messages/Verify'
subscribe:
message:
$ref: '#/components/messages/VerifyResponse'
DigitalTwin:
publish:
message:
$ref: '#/components/messages/DigitalTwinRequest'
subscribe:
message:
$ref: '#/components/messages/DigitalTwin'
MapDestination:
publish:
message:
$ref: '#/components/messages/MapDestinationRequest'
MapRoute:
publish:
message:
$ref: '#/components/messages/MapRouteRequest'
Profiles:
publish:
message:
$ref: '#/components/messages/Profiles'
subscribe:
message:
$ref: '#/components/messages/ProfilesResponse'
StoreInventory:
publish:
message:
$ref: '#/components/messages/StoreInventory'
subscribe:
message:
$ref: '#/components/messages/StoreInventoryResponse'
StoreInventoryError:
subscribe:
message:
$ref: '#/components/messages/StoreInventoryError'
StorePurchase:
publish:
message:
$ref: '#/components/messages/StorePurchase'
StorePurchaseError:
subscribe:
message:
$ref: '#/components/messages/StorePurchaseError'
SettingsUpdate:
publish:
message:
$ref: '#/components/messages/SettingsUpdate'
subscribe:
message:
$ref: '#/components/messages/SettingsUpdateNotification'
SubscriptionsUpdate:
subscribe:
message:
$ref: '#/components/messages/SubscriptionsUpdate'
Updates:
publish:
message:
$ref: '#/components/messages/UpdatesGet'
subscribe:
message:
$ref: '#/components/messages/Updates'
UpdateApprove:
publish:
message:
$ref: '#/components/messages/UpdateApprove'
CarUpdate:
subscribe:
message:
$ref: '#/components/messages/CarUpdate'
CarLocations:
publish:
message:
$ref: '#/components/messages/CarLocationsRequest'
subscribe:
message:
$ref: '#/components/messages/CarLocations'
Error:
subscribe:
message:
$ref: '#/components/messages/Error'
components:
messages:
Verify:
description: Sent by mobile to authenticate with the cloud.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "verify"
const: verify
data:
$ref: './schema/mobile/TXMessage.json#/$defs/VerifyModel'
VerifyResponse:
description: Recieved by mobile after authenticating.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "verify"
const: verify
data:
$ref: './schema/mobile/RXMessage.json#/$defs/VerifyResponseModel'
MapDestinationRequest:
description: Sends map destination to the cloud for the HMI.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "map_destination"
const: map_destination
data:
$ref: './schema/mobile/TXMessage.json#/$defs/MapDestinationRequestModel'
MapRouteRequest:
description: Sends map route to the cloud for the HMI.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "map_route"
const: map_route
data:
$ref: './schema/mobile/TXMessage.json#/$defs/MapRouteRequestModel'
DigitalTwinRequest:
description: Sent by mobile to retrieve digital twin data for specified VIN.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "digital_twin"
data:
$ref: './schema/mobile/TXMessage.json#/$defs/DigitalTwinRequestModel'
DigitalTwin:
description: Sent to mobile of digital twin data for specified VIN.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "digital_twin"
data:
$ref: './schema/mobile/RXMessage.json#/$defs/DigitalTwinModel'
Profiles:
description: Prompts the cloud to send down all profiles on all cars for the user.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "profiles"
const: profiles
ProfilesResponse:
description: Provides an updated version of all profiles on all cars for the user.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "profiles"
const: profiles
data:
type: array
description: an array of ProfileModels
items:
$ref: './schema/mobile/RXMessage.json#/$defs/ProfileModel'
StoreInventory:
description: Sent by mobile to ask the cloud for store inventory.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "store_inventory"
const: store_inventory
StoreInventoryResponse:
description: Recieved by mobile after asking the cloud for store inventory.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "store_inventory"
const: store_inventory
data:
type: array
description: an array of StoreInventoryModels
items:
$ref: './schema/mobile/RXMessage.json#/$defs/StoreInventoryModel'
StoreInventoryError:
description: Received by mobile if there is an error retrieving store inventory.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "store_inventory_error"
const: store_inventory_error
data:
$ref: './schema/mobile/RXMessage.json#/$defs/ErrorModel'
StorePurchase:
description: Notifies the cloud of a subscription purchase from mobile.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "store_purchase"
const: store_purchase
data:
$ref: './schema/mobile/TXMessage.json#/$defs/StorePurchaseModel'
StorePurchaseError:
description: Received by mobile if there is an error purchasing a subscription.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "store_purchase_error"
const: store_purchase_error
data:
$ref: './schema/mobile/RXMessage.json#/$defs/ErrorModel'
SettingsUpdate:
description: Notifies the cloud of a setting change from mobile.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "settings_update"
const: settings_update
data:
$ref: './schema/mobile/TXMessage.json#/$defs/SettingsUpdateModel'
SettingsUpdateNotification:
description: Notifies the mobile of a change in settings.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "settings_update"
const: settings_update
data:
$ref: './schema/mobile/RXMessage.json#/$defs/SettingsUpdateModel'
SubscriptionsUpdate:
description: Notifies the mobile of a succesful change in a subscription.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "subscriptions_update"
const: subscriptions_update
data:
$ref: './schema/mobile/RXMessage.json#/$defs/SubscriptionsUpdateModel'
UpdatesGet:
description: Sent by mobile to recieve a summary of all available OTA updates.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "updates_get"
const: updates_get
data:
$ref: './schema/mobile/TXMessage.json#/$defs/GetUpdatesModel'
Updates:
description: Received by mobile as a summary of all available OTA updates.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "updates"
const: updates
data:
type: array
description: stores data for response
items:
$ref: './schema/mobile/RXMessage.json#/$defs/UpdateManifest'
UpdateApprove:
description: Sent by mobile to grant approval to download and install an OTA update.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "update_approve"
const: update_approve
CarUpdate:
description: Provides a status update on a specific car update.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "car_update"
const: car_update
data:
$ref: './schema/mobile/RXMessage.json#/$defs/UpdateProgressModel'
CarLocationsRequest:
description: Provides a status update on a specific car update.
payload:
type: object
required:
- handler
properties:
handler:
type: string
description: expects the string "car_locations"
const: car_locations
CarLocations:
description: Provides a status update on a specific car update.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "car_locations"
const: car_locations
data:
type: array
description: provides car locations with their respective VIN
$ref: './schema/mobile/RXMessage.json#/$defs/CarLocationModel'
Error:
description: Generic error message
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "error"
const: error
data:
$ref: './schema/mobile/RXMessage.json#/$defs/ErrorModel'

View File

@@ -0,0 +1,212 @@
asyncapi: 2.0.0
info:
title: T-Rex Websocket API
version: 1.0.1
description: This serves as the documentation for websocket connections made between the T-Rex and the gateway.
servers:
local:
url: localhost/session
description: local
protocol: wss
development:
url: dev-sec-gw.cloud.fiskerinc.com/session
description: dev
protocol: wss
stage:
url: stg-sec-gw.cloud.fiskerinc.com/session
description: stage
protocol: wss
preproduction:
url: sec-gw.cloud.fiskerinc.com/session
description: preprod
protocol: wss
production:
url: sec-gw.cec-prd.fiskerinc.com/session
description: prod
protocol: wss
production-eu:
url: sec-gw.cec-euprd.fiskerinc.com/session
description: prod-eu
protocol: wss
channels:
config:
subscribe:
message:
$ref: '#/components/messages/config'
filekeys:
subscribe:
message:
$ref: '#/components/messages/filekeys'
remote_command:
subscribe:
message:
$ref: '#/components/messages/remote_command'
update_manifest:
subscribe:
message:
$ref: '#/components/messages/update_manifest'
canbus(pub):
publish:
message:
$ref: '#/components/messages/canbus(pub)'
car_state:
publish:
message:
$ref: '#/components/messages/car_state'
car_update_status:
publish:
message:
$ref: '#/components/messages/car_update_status'
get_filekeys:
publish:
message:
$ref: '#/components/messages/get_filekeys'
error:
publish:
message:
$ref: '#/components/messages/error(pub)'
subscribe:
message:
$ref: '#/components/messages/error(sub)'
components:
messages:
config:
description: Message containing configuration information. Passed down upon connection to gateway.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
const: config
data:
$ref: './schema/trex/RXMessage.json#/$defs/Config'
filekeys:
description: A message containing file keys for OTA update flow. Triggered by publishing 'get_filekeys' message.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
const: filekeys
data:
$ref: './schema/trex/RXMessage.json#/$defs/FileKeyResponse'
remote_command:
description: A message containing remote car command
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
const: remote_command
data:
$ref: './schema/trex/RXMessage.json#/$defs/RemoteCommand'
update_manifest:
description: Manifest describing an OTA update.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
const: update_manifest
data:
$ref: './schema/trex/RXMessage.json#/$defs/UpdateManifest'
canbus(pub):
description: CAN message batch.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
const: canbus
data:
type: array
items:
$ref: './schema/trex/TXMessage.json#/$defs/CanFrame'
car_state:
description: Current car state, describes ECU versions etc.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
const: car_state
data:
$ref: './schema/trex/TXMessage.json#/$defs/CarStateUpdate'
car_update_status:
description: Update status for an OTA update.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
const: car_update_status
data:
$ref: './schema/trex/TXMessage.json#/$defs/CarUpdateProgress'
get_filekeys:
description: Request file keys to decrypt OTA update.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
const: get_filekeys
data:
$ref: './schema/trex/TXMessage.json#/$defs/FileKeysRequest'
error(pub):
description: Report an error.
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
const: error
data:
$ref: './schema/trex/TXMessage.json#/$defs/Error'
error(sub):
description: Generic error message
payload:
type: object
required:
- handler
- data
properties:
handler:
type: string
description: expects the string "error"
const: error
data:
$ref: './schema/trex/RXMessage.json#/$defs/ErrorModel'

View File

@@ -0,0 +1 @@
../../3rdparty/common/schema

View File

@@ -0,0 +1,159 @@
components:
schemas:
CarToDriverModel:
type: object
properties:
user:
type: object
properties:
given_name:
type: string
description: first name associated with the user
family_name:
type: string
description: last name associated with the user
email:
type: string
description: email associated with the user
phone:
type: string
description: phone number associated with the user
driver_id:
type: string
description: a unique ID linking the user to the car
role:
type: string
description: the role of the user in the car
settings:
type: string
description: settings associated with the user on the car
UpdateManifest:
type: object
properties:
name:
type: string
description: name of the update
version:
type: string
description: version of the update
description:
type: string
description: description of the update
release_notes:
type: string
description: release notes for the updates
ecu_updates:
type: array
description: the ECU updates that comprise the car update
items:
$ref: "shared.yaml#/components/schemas/EcuUpdate"
car_update_id:
type: string
format: time
description: ID of the car update
created:
type: string
format: time
description: when this update manifest was created
updated:
type: string
format: time
description: when this update manifest was last updated
EcuUpdate:
type: object
properties:
update_file_id:
type: string
description: ID of the update file
manifest_id:
type: integer
description: ID of the manifest
name:
type: string
description: name of the ECU update
part_number:
type: string
description: part number to be updated
update_version:
type: string
description: version of the ECU update
filename:
type: string
description: name of the ECU update file
update_url:
type: string
description: URL to download the ECU update file from
update_size:
type: integer
description: size of the ECU update in bytes
created:
type: string
description: when the ECU update file was created
updated:
type: string
description: when the ECU update file was last updated
UpdateProgressModel:
type: object
properties:
car_update_id:
type: integer
description: ID of the update associated with this progress message
ecu:
type: string
description: ecu currently being updated
file_current:
type: integer
description: downloaded amount of file in bytes
file_total:
type: integer
description: total download amout of file in bytes
package_current:
type: integer
description: downloaded amount of package in bytes
package_total:
type: integer
description: total download amount of package in bytes
installed:
type: integer
description: number of packages installed
total_files:
type: integer
description: number of packages to be installed in update
msg:
type: integer
description: message of the update
enum:
- download_start
- downloading
- download_complete
- download_error
- install_start
- installing
- install_complete
- install_error
err:
type: integer
description: optional error code associated with the update
CarCommand:
type: object
properties:
car_command_locks:
$ref: "#/components/schemas/CarCommandLocks"
CarCommandLocks:
type: object
properties:
left_front:
type: string
description: command for the left front lock
right_front:
type: string
description: command for the right front lock
left_rear:
type: string
description: command for the left rear lock
right_rear:
type: string
description: command for the right rear lock
trunk:
type: string
description: command for the trunk