Skip to content

Commit

Permalink
FR-233 remove device stream implementation (#436)
Browse files Browse the repository at this point in the history
* remove device stream implementation

* update stream mutation added

* add migration
  • Loading branch information
soson authored Jun 21, 2024
1 parent 4d88523 commit 1fdf473
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "stream" ADD COLUMN "blueprint_id" TEXT;

-- AddForeignKey
ALTER TABLE "stream" ADD CONSTRAINT "stream_blueprint_id_fkey" FOREIGN KEY ("blueprint_id") REFERENCES "device_blueprint"("id") ON DELETE SET NULL ON UPDATE CASCADE;
19 changes: 11 additions & 8 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,24 @@ model blueprint {
tenantId String @map("tenant_id")
template String
device device[]
stream stream[]
@@unique([name, tenantId], name: "udx_device_blueprint_name_tenant_id")
@@index([tenantId], map: "idx_device_blueprint_tenant_id")
@@map("device_blueprint")
}

model stream {
id String @id @default(uuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
deviceName String @map("device_name")
streamName String @map("stream_name")
streamParameters Json? @map("stream_parameters")
tenantId String @map("tenant_id")
device device @relation(fields: [deviceName, tenantId], references: [name, tenantId])
id String @id @default(uuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
deviceName String @map("device_name")
streamName String @map("stream_name")
streamParameters Json? @map("stream_parameters")
tenantId String @map("tenant_id")
device device @relation(fields: [deviceName, tenantId], references: [name, tenantId])
blueprintId String? @map("blueprint_id")
blueprint blueprint? @relation(fields: [blueprintId], references: [id])
@@unique([deviceName, streamName, tenantId], name: "udx_device_name_stream_name_id")
}
Expand Down
20 changes: 20 additions & 0 deletions src/schema/api.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type AddSnapshotPayload {
}

input AddStreamInput {
blueprintId: String
deviceName: String!
streamName: String!
streamParameters: String
Expand Down Expand Up @@ -229,6 +230,10 @@ type DeleteSnapshotPayload {
snapshot: Snapshot
}

type DeleteStreamPayload {
stream: Stream
}

type Device implements Node {
address: String
blueprint: Blueprint
Expand Down Expand Up @@ -434,6 +439,7 @@ type Mutation {
deleteDevice(id: String!): DeleteDevicePayload!
deleteLabel(id: String!): DeleteLabelPayload!
deleteSnapshot(input: DeleteSnapshotInput!): DeleteSnapshotPayload
deleteStream(id: String!): DeleteStreamPayload!
importCSV(input: CSVImportInput!): CSVImport
installDevice(id: String!): InstallDevicePayload!
reconnectKafka: IsOkResponse
Expand All @@ -445,6 +451,7 @@ type Mutation {
updateDataStore(deviceId: String!, input: UpdateDataStoreInput!, transactionId: String!): UpdateDataStorePayload!
updateDevice(id: String!, input: UpdateDeviceInput!): UpdateDevicePayload!
updateGraphNodeCoordinates(input: UpdateGraphNodeCoordinatesInput!): UpdateGraphNodeCoordinatesPayload!
updateStream(id: String!, input: UpdateStreamInput!): UpdateStreamPayload!
}

type NetInterface {
Expand Down Expand Up @@ -638,11 +645,13 @@ enum SortStreamBy {
}

type Stream implements Node {
blueprint: Blueprint
createdAt: String!
deviceName: String!
id: ID!
isActive: Boolean!
streamName: String!
streamParameters: String
updatedAt: String!
}

Expand Down Expand Up @@ -797,6 +806,17 @@ type UpdateGraphNodeCoordinatesPayload {
deviceNames: [String!]!
}

input UpdateStreamInput {
blueprintId: String
deviceName: String!
streamName: String!
streamParameters: String
}

type UpdateStreamPayload {
stream: Stream
}

"""
The `Upload` scalar type represents a file upload.
"""
Expand Down
49 changes: 49 additions & 0 deletions src/schema/nexus-typegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface NexusGenInputs {
};
AddStreamInput: {
// input type
blueprintId?: string | null; // String
deviceName: string; // String!
streamName: string; // String!
streamParameters?: string | null; // String
Expand Down Expand Up @@ -175,6 +176,13 @@ export interface NexusGenInputs {
coordinates: NexusGenInputs['GraphNodeCoordinatesInput'][]; // [GraphNodeCoordinatesInput!]!
layer?: NexusGenEnums['TopologyLayer'] | null; // TopologyLayer
};
UpdateStreamInput: {
// input type
blueprintId?: string | null; // String
deviceName: string; // String!
streamName: string; // String!
streamParameters?: string | null; // String
};
}

export interface NexusGenEnums {
Expand Down Expand Up @@ -325,6 +333,10 @@ export interface NexusGenObjects {
// root type
snapshot?: NexusGenRootTypes['Snapshot'] | null; // Snapshot
};
DeleteStreamPayload: {
// root type
stream?: NexusGenRootTypes['Stream'] | null; // Stream
};
Device: SourceTypes.Device;
DeviceConnection: {
// root type
Expand Down Expand Up @@ -657,6 +669,10 @@ export interface NexusGenObjects {
// root type
deviceNames: string[]; // [String!]!
};
UpdateStreamPayload: {
// root type
stream?: NexusGenRootTypes['Stream'] | null; // Stream
};
Zone: SourceTypes.Zone;
ZoneEdge: {
// root type
Expand Down Expand Up @@ -834,6 +850,10 @@ export interface NexusGenFieldTypes {
// field return type
snapshot: NexusGenRootTypes['Snapshot'] | null; // Snapshot
};
DeleteStreamPayload: {
// field return type
stream: NexusGenRootTypes['Stream'] | null; // Stream
};
Device: {
// field return type
address: string | null; // String
Expand Down Expand Up @@ -985,6 +1005,7 @@ export interface NexusGenFieldTypes {
deleteDevice: NexusGenRootTypes['DeleteDevicePayload']; // DeleteDevicePayload!
deleteLabel: NexusGenRootTypes['DeleteLabelPayload']; // DeleteLabelPayload!
deleteSnapshot: NexusGenRootTypes['DeleteSnapshotPayload'] | null; // DeleteSnapshotPayload
deleteStream: NexusGenRootTypes['DeleteStreamPayload']; // DeleteStreamPayload!
importCSV: NexusGenRootTypes['CSVImport'] | null; // CSVImport
installDevice: NexusGenRootTypes['InstallDevicePayload']; // InstallDevicePayload!
reconnectKafka: NexusGenRootTypes['IsOkResponse'] | null; // IsOkResponse
Expand All @@ -996,6 +1017,7 @@ export interface NexusGenFieldTypes {
updateDataStore: NexusGenRootTypes['UpdateDataStorePayload']; // UpdateDataStorePayload!
updateDevice: NexusGenRootTypes['UpdateDevicePayload']; // UpdateDevicePayload!
updateGraphNodeCoordinates: NexusGenRootTypes['UpdateGraphNodeCoordinatesPayload']; // UpdateGraphNodeCoordinatesPayload!
updateStream: NexusGenRootTypes['UpdateStreamPayload']; // UpdateStreamPayload!
};
NetInterface: {
// field return type
Expand Down Expand Up @@ -1155,11 +1177,13 @@ export interface NexusGenFieldTypes {
};
Stream: {
// field return type
blueprint: NexusGenRootTypes['Blueprint'] | null; // Blueprint
createdAt: string; // String!
deviceName: string; // String!
id: string; // ID!
isActive: boolean; // Boolean!
streamName: string; // String!
streamParameters: string | null; // String
updatedAt: string; // String!
};
StreamConnection: {
Expand Down Expand Up @@ -1271,6 +1295,10 @@ export interface NexusGenFieldTypes {
// field return type
deviceNames: string[]; // [String!]!
};
UpdateStreamPayload: {
// field return type
stream: NexusGenRootTypes['Stream'] | null; // Stream
};
Zone: {
// field return type
createdAt: string; // String!
Expand Down Expand Up @@ -1448,6 +1476,10 @@ export interface NexusGenFieldTypeNames {
// field return type name
snapshot: 'Snapshot';
};
DeleteStreamPayload: {
// field return type name
stream: 'Stream';
};
Device: {
// field return type name
address: 'String';
Expand Down Expand Up @@ -1599,6 +1631,7 @@ export interface NexusGenFieldTypeNames {
deleteDevice: 'DeleteDevicePayload';
deleteLabel: 'DeleteLabelPayload';
deleteSnapshot: 'DeleteSnapshotPayload';
deleteStream: 'DeleteStreamPayload';
importCSV: 'CSVImport';
installDevice: 'InstallDevicePayload';
reconnectKafka: 'IsOkResponse';
Expand All @@ -1610,6 +1643,7 @@ export interface NexusGenFieldTypeNames {
updateDataStore: 'UpdateDataStorePayload';
updateDevice: 'UpdateDevicePayload';
updateGraphNodeCoordinates: 'UpdateGraphNodeCoordinatesPayload';
updateStream: 'UpdateStreamPayload';
};
NetInterface: {
// field return type name
Expand Down Expand Up @@ -1769,11 +1803,13 @@ export interface NexusGenFieldTypeNames {
};
Stream: {
// field return type name
blueprint: 'Blueprint';
createdAt: 'String';
deviceName: 'String';
id: 'ID';
isActive: 'Boolean';
streamName: 'String';
streamParameters: 'String';
updatedAt: 'String';
};
StreamConnection: {
Expand Down Expand Up @@ -1885,6 +1921,10 @@ export interface NexusGenFieldTypeNames {
// field return type name
deviceNames: 'String';
};
UpdateStreamPayload: {
// field return type name
stream: 'Stream';
};
Zone: {
// field return type name
createdAt: 'String';
Expand Down Expand Up @@ -2008,6 +2048,10 @@ export interface NexusGenArgTypes {
// args
input: NexusGenInputs['DeleteSnapshotInput']; // DeleteSnapshotInput!
};
deleteStream: {
// args
id: string; // String!
};
importCSV: {
// args
input: NexusGenInputs['CSVImportInput']; // CSVImportInput!
Expand Down Expand Up @@ -2054,6 +2098,11 @@ export interface NexusGenArgTypes {
// args
input: NexusGenInputs['UpdateGraphNodeCoordinatesInput']; // UpdateGraphNodeCoordinatesInput!
};
updateStream: {
// args
id: string; // String!
input: NexusGenInputs['UpdateStreamInput']; // UpdateStreamInput!
};
};
Query: {
blueprints: {
Expand Down
Loading

0 comments on commit 1fdf473

Please sign in to comment.