From 0d12d3731a8c7666e46dc2a091f82d5f89abc1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Fri, 14 Nov 2025 17:52:00 -0500 Subject: [PATCH 1/4] event schema --- firebase/dataconnect/schema/event.gpl | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 firebase/dataconnect/schema/event.gpl diff --git a/firebase/dataconnect/schema/event.gpl b/firebase/dataconnect/schema/event.gpl new file mode 100644 index 00000000..718d852e --- /dev/null +++ b/firebase/dataconnect/schema/event.gpl @@ -0,0 +1,40 @@ +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: "uuid_generate_v4()") + eventName: String! @col(name: "event_name") + isRecurring: Boolean! @col(name: "is_recurring") + recurrenceType: RecurrenceType @col(name: "recurrence_type") + businessId: UUID! @col(name: "business_id") + vendorId: UUID @col(name: "vendor_id") + status: EventStatus! @col(name: "status") + date: Timestamp @col(name: "date") + shifts: JSON @col(name: "shifts", dataType: "jsonb") + total: Float @col(name: "total") + requested: Int @col(name: "requested") + assignedStaff: JSON @col(name: "assigned_staff", dataType: "jsonb") + createdDate: Timestamp @col(name: "created_date") @default(expr: "now()") + updatedDate: Timestamp @col(name: "updated_date") @default(expr: "now()") + createdBy: String @col(name: "created_by") + +} + From d510c5bc8506c298359a99669917b45c2c992796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Fri, 14 Nov 2025 18:34:53 -0500 Subject: [PATCH 2/4] adding mutation to event and deleting extra info --- firebase/dataconnect/schema/event.gpl | 52 +++++++++++++++++++-------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/firebase/dataconnect/schema/event.gpl b/firebase/dataconnect/schema/event.gpl index 718d852e..fed066c4 100644 --- a/firebase/dataconnect/schema/event.gpl +++ b/firebase/dataconnect/schema/event.gpl @@ -20,21 +20,43 @@ enum RecurrenceType { type Event @table(name: "events") { - id: UUID! @col(name: "id", primaryKey: true) @default(expr: "uuid_generate_v4()") - eventName: String! @col(name: "event_name") - isRecurring: Boolean! @col(name: "is_recurring") - recurrenceType: RecurrenceType @col(name: "recurrence_type") - businessId: UUID! @col(name: "business_id") - vendorId: UUID @col(name: "vendor_id") - status: EventStatus! @col(name: "status") - date: Timestamp @col(name: "date") - shifts: JSON @col(name: "shifts", dataType: "jsonb") - total: Float @col(name: "total") - requested: Int @col(name: "requested") - assignedStaff: JSON @col(name: "assigned_staff", dataType: "jsonb") - createdDate: Timestamp @col(name: "created_date") @default(expr: "now()") - updatedDate: Timestamp @col(name: "updated_date") @default(expr: "now()") - createdBy: String @col(name: "created_by") + 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 +} + From 28b50f81a4202b1b0bc69a5bfcd3344398266377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:24:03 -0500 Subject: [PATCH 3/4] moving event.gql to dataconnect new folder --- dataconnect/connector/dataconnect.yaml | 13 ++++ dataconnect/dataconnect.yaml | 2 +- dataconnect/{schema => example}/schema.gql | 0 dataconnect/schema/event.gql | 74 ++++++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 dataconnect/connector/dataconnect.yaml rename dataconnect/{schema => example}/schema.gql (100%) create mode 100644 dataconnect/schema/event.gql diff --git a/dataconnect/connector/dataconnect.yaml b/dataconnect/connector/dataconnect.yaml new file mode 100644 index 00000000..881c9248 --- /dev/null +++ b/dataconnect/connector/dataconnect.yaml @@ -0,0 +1,13 @@ +specVersion: "v1" +serviceId: "krow-workforce" +location: "us-central1" +schema: + source: "./schema" + datasource: + postgresql: + database: "fdcdb" + cloudSql: + instanceId: "krow-workforce-fdc" + # schemaValidation: "STRICT" # STRICT mode makes Postgres schema match Data Connect exactly. + # schemaValidation: "COMPATIBLE" # COMPATIBLE mode makes Postgres schema compatible with Data Connect. +connectorDirs: ["./example"] diff --git a/dataconnect/dataconnect.yaml b/dataconnect/dataconnect.yaml index 881c9248..42790982 100644 --- a/dataconnect/dataconnect.yaml +++ b/dataconnect/dataconnect.yaml @@ -10,4 +10,4 @@ schema: instanceId: "krow-workforce-fdc" # 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..bcb3cdc2 --- /dev/null +++ b/dataconnect/schema/event.gql @@ -0,0 +1,74 @@ +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! @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 @updatedAt + 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 +} + +query listEvents @auth(level: USER) { + events { + id + eventName + status + date + isRecurring + recurrenceType + businessId + vendorId + total + requested + } +} + +mutation createEvent($input: CreateEventInput!) @auth(level: USER) { + event_insert(data: $input) { + id + } +} From b3ff3f14edbfc4f2afed3fbbb3e61ce2c72ee740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Mon, 17 Nov 2025 19:53:58 -0500 Subject: [PATCH 4/4] best way to create schema with gql --- dataconnect/connector/connector.yaml | 8 +++++ dataconnect/connector/dataconnect.yaml | 13 ------- dataconnect/connector/event/mutations.gql | 29 +++++++++++++++ dataconnect/connector/event/queries.gql | 14 ++++++++ dataconnect/dataconnect.yaml | 6 ++-- dataconnect/schema/event.gql | 44 +++-------------------- 6 files changed, 58 insertions(+), 56 deletions(-) create mode 100644 dataconnect/connector/connector.yaml delete mode 100644 dataconnect/connector/dataconnect.yaml create mode 100644 dataconnect/connector/event/mutations.gql create mode 100644 dataconnect/connector/event/queries.gql 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/dataconnect.yaml b/dataconnect/connector/dataconnect.yaml deleted file mode 100644 index 881c9248..00000000 --- a/dataconnect/connector/dataconnect.yaml +++ /dev/null @@ -1,13 +0,0 @@ -specVersion: "v1" -serviceId: "krow-workforce" -location: "us-central1" -schema: - source: "./schema" - datasource: - postgresql: - database: "fdcdb" - cloudSql: - instanceId: "krow-workforce-fdc" - # schemaValidation: "STRICT" # STRICT mode makes Postgres schema match Data Connect exactly. - # schemaValidation: "COMPATIBLE" # COMPATIBLE mode makes Postgres schema compatible with Data Connect. -connectorDirs: ["./example"] 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 42790982..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: ["./connector"] diff --git a/dataconnect/schema/event.gql b/dataconnect/schema/event.gql index bcb3cdc2..4a7b2392 100644 --- a/dataconnect/schema/event.gql +++ b/dataconnect/schema/event.gql @@ -1,6 +1,3 @@ -scalar UUID -scalar Timestamp -scalar JSON enum EventStatus { DRAFT @@ -28,47 +25,14 @@ type Event @table(name: "events") { vendorId: UUID status: EventStatus! date: Timestamp! - shifts: JSON @col(dataType: "jsonb") + shifts: String @col(dataType: "jsonb") total: Float requested: Int - assignedStaff: JSON @col(dataType: "jsonb") - createdDate: Timestamp @default(expr: "now()") - updatedDate: Timestamp @updatedAt + assignedStaff: String @col(dataType: "jsonb") + createdDate: Timestamp @default(expr: "request.time") + updatedDate: Timestamp @default(expr: "request.time") 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 -} -query listEvents @auth(level: USER) { - events { - id - eventName - status - date - isRecurring - recurrenceType - businessId - vendorId - total - requested - } -} - -mutation createEvent($input: CreateEventInput!) @auth(level: USER) { - event_insert(data: $input) { - id - } -}