diff --git a/dataconnect/connector/connector.yaml b/dataconnect/connector/connector.yaml new file mode 100644 index 00000000..a3273b3f --- /dev/null +++ b/dataconnect/connector/connector.yaml @@ -0,0 +1,8 @@ +connectorId: krow-connector +generate: + javascriptSdk: + - outputDir: ../../frontend-web/src/dataconnect-generated + package: "@dataconnect/generated" + packageJsonDir: ../../frontend-web + react: true + angular: false diff --git a/dataconnect/connector/event/mutations.gql b/dataconnect/connector/event/mutations.gql new file mode 100644 index 00000000..a5a4aa22 --- /dev/null +++ b/dataconnect/connector/event/mutations.gql @@ -0,0 +1,29 @@ +mutation CreateEvent( + $eventName: String!, + $isRecurring: Boolean!, + $recurrenceType: RecurrenceType, + $businessId: UUID!, + $vendorId: UUID, + $status: EventStatus!, + $date: Timestamp!, + $shifts: String, + $total: Float, + $requested: Int, + $assignedStaff: String +) @auth(level: USER) { + event_insert( + data: { + eventName: $eventName + isRecurring: $isRecurring + recurrenceType: $recurrenceType + businessId: $businessId + vendorId: $vendorId + status: $status + date: $date + shifts: $shifts + total: $total + requested: $requested + assignedStaff: $assignedStaff + } + ) +} \ No newline at end of file diff --git a/dataconnect/connector/event/queries.gql b/dataconnect/connector/event/queries.gql new file mode 100644 index 00000000..1c7103d5 --- /dev/null +++ b/dataconnect/connector/event/queries.gql @@ -0,0 +1,14 @@ +query listEvents @auth(level: USER) { + events { + id + eventName + status + date + isRecurring + recurrenceType + businessId + vendorId + total + requested + } +} \ No newline at end of file diff --git a/dataconnect/dataconnect.yaml b/dataconnect/dataconnect.yaml index 881c9248..39e01fdb 100644 --- a/dataconnect/dataconnect.yaml +++ b/dataconnect/dataconnect.yaml @@ -1,13 +1,13 @@ specVersion: "v1" -serviceId: "krow-workforce" +serviceId: "krow-workforce-db" location: "us-central1" schema: source: "./schema" datasource: postgresql: - database: "fdcdb" + database: "krow_db" cloudSql: - instanceId: "krow-workforce-fdc" + instanceId: "krow-sql" # schemaValidation: "STRICT" # STRICT mode makes Postgres schema match Data Connect exactly. # schemaValidation: "COMPATIBLE" # COMPATIBLE mode makes Postgres schema compatible with Data Connect. -connectorDirs: ["./example"] +connectorDirs: ["./connector"] diff --git a/dataconnect/schema/schema.gql b/dataconnect/example/schema.gql similarity index 100% rename from dataconnect/schema/schema.gql rename to dataconnect/example/schema.gql diff --git a/dataconnect/schema/event.gql b/dataconnect/schema/event.gql new file mode 100644 index 00000000..4a7b2392 --- /dev/null +++ b/dataconnect/schema/event.gql @@ -0,0 +1,38 @@ + +enum EventStatus { + DRAFT + ACTIVE + PENDING + ASSIGNED + CONFIRMED + COMPLETED + CANCELED +} + +enum RecurrenceType { + SINGLE + DATE_RANGE + SCATTER +} + +type Event @table(name: "events") { + + id: UUID! @default(expr: "uuidV4()") + eventName: String! + isRecurring: Boolean! + recurrenceType: RecurrenceType + businessId: UUID! + vendorId: UUID + status: EventStatus! + date: Timestamp! + shifts: String @col(dataType: "jsonb") + total: Float + requested: Int + assignedStaff: String @col(dataType: "jsonb") + createdDate: Timestamp @default(expr: "request.time") + updatedDate: Timestamp @default(expr: "request.time") + createdBy: String + +} + + diff --git a/firebase/dataconnect/schema/event.gpl b/firebase/dataconnect/schema/event.gpl new file mode 100644 index 00000000..fed066c4 --- /dev/null +++ b/firebase/dataconnect/schema/event.gpl @@ -0,0 +1,62 @@ +scalar UUID +scalar Timestamp +scalar JSON + +enum EventStatus { + DRAFT + ACTIVE + PENDING + ASSIGNED + CONFIRMED + COMPLETED + CANCELED +} + +enum RecurrenceType { + SINGLE + DATE_RANGE + SCATTER +} + +type Event @table(name: "events") { + + id: UUID! @col(name: "id", primaryKey: true) @default(expr: "uuidV4()") + eventName: String! + isRecurring: Boolean! + recurrenceType: RecurrenceType + businessId: UUID! + vendorId: UUID + status: EventStatus! + date: Timestamp! + shifts: JSON @col(dataType: "jsonb") + total: Float + requested: Int + assignedStaff: JSON @col(dataType: "jsonb") + createdDate: Timestamp @default(expr: "now()") + updatedDate: Timestamp @updateAt + createdBy: String + +} + +input CreateEventInput { + eventName: String! + isRecurring: Boolean! + recurrenceType: RecurrenceType + businessId: UUID! + vendorId: UUID + status: EventStatus! + date: Timestamp! + shifts: JSON + total: Float + requested: Int + assignedStaff: JSON +} + +type Mutation { + createEvent(input: CreateEventInput!): Event @auth +} + +type Query { + listEvents: [Event!] @auth +} +