From 2c130a413a0610f8824d9e51243b4e5830588dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Tue, 25 Nov 2025 11:58:03 -0500 Subject: [PATCH 1/3] new event schema with full crud --- dataconnect/connector/event/mutations.gql | 135 +++++++++++++++++++++- dataconnect/connector/event/queries.gql | 135 +++++++++++++++++++++- dataconnect/schema/event.gql | 34 +++++- 3 files changed, 299 insertions(+), 5 deletions(-) diff --git a/dataconnect/connector/event/mutations.gql b/dataconnect/connector/event/mutations.gql index a5a4aa22..8f1e048f 100644 --- a/dataconnect/connector/event/mutations.gql +++ b/dataconnect/connector/event/mutations.gql @@ -1,29 +1,160 @@ mutation CreateEvent( $eventName: String!, - $isRecurring: Boolean!, + $isRapid: Boolean, + $isRecurring: Boolean, + $isMultiDay: Boolean, $recurrenceType: RecurrenceType, + $recurrenceStartDate: Timestamp, + $recurrenceEndDate: Timestamp, + $scatterDates: String, + $multiDayStartDate: Timestamp, + $multiDayEndDate: Timestamp, + $bufferTimeBefore: Float, + $bufferTimeAfter: Float, + $conflictDetectionEnabled: Boolean, + $detectedConflicts: String, $businessId: UUID!, + $businessName: String, $vendorId: UUID, + $vendorName: String, + $hub: String, + $eventLocation: String, + $contractType: ContractType, + $poReference: String, $status: EventStatus!, $date: Timestamp!, $shifts: String, + $addons: String, $total: Float, + $clientName: String, + $clientEmail: String, + $clientPhone: String, + $invoiceId: UUID, + $notes: String, $requested: Int, $assignedStaff: String ) @auth(level: USER) { event_insert( data: { eventName: $eventName + isRapid: $isRapid isRecurring: $isRecurring + isMultiDay: $isMultiDay recurrenceType: $recurrenceType + recurrenceStartDate: $recurrenceStartDate + recurrenceEndDate: $recurrenceEndDate + scatterDates: $scatterDates + multiDayStartDate: $multiDayStartDate + multiDayEndDate: $multiDayEndDate + bufferTimeBefore: $bufferTimeBefore + bufferTimeAfter: $bufferTimeAfter + conflictDetectionEnabled: $conflictDetectionEnabled + detectedConflicts: $detectedConflicts businessId: $businessId + businessName: $businessName vendorId: $vendorId + vendorName: $vendorName + hub: $hub + eventLocation: $eventLocation + contractType: $contractType + poReference: $poReference status: $status date: $date shifts: $shifts + addons: $addons total: $total + clientName: $clientName + clientEmail: $clientEmail + clientPhone: $clientPhone + invoiceId: $invoiceId + notes: $notes requested: $requested assignedStaff: $assignedStaff } ) -} \ No newline at end of file +} + + +mutation UpdateEvent( + $id: UUID!, + $eventName: String, + $isRapid: Boolean, + $isRecurring: Boolean, + $isMultiDay: Boolean, + $recurrenceType: RecurrenceType, + $recurrenceStartDate: Timestamp, + $recurrenceEndDate: Timestamp, + $scatterDates: String, + $multiDayStartDate: Timestamp, + $multiDayEndDate: Timestamp, + $bufferTimeBefore: Float, + $bufferTimeAfter: Float, + $conflictDetectionEnabled: Boolean, + $detectedConflicts: String, + $businessId: UUID, + $businessName: String, + $vendorId: UUID, + $vendorName: String, + $hub: String, + $eventLocation: String, + $contractType: ContractType, + $poReference: String, + $status: EventStatus, + $date: Timestamp, + $shifts: String, + $addons: String, + $total: Float, + $clientName: String, + $clientEmail: String, + $clientPhone: String, + $invoiceId: UUID, + $notes: String, + $requested: Int, + $assignedStaff: String +) @auth(level: USER) { + event_update( + id: $id, + data: { + eventName: $eventName + isRapid: $isRapid + isRecurring: $isRecurring + isMultiDay: $isMultiDay + recurrenceType: $recurrenceType + recurrenceStartDate: $recurrenceStartDate + recurrenceEndDate: $recurrenceEndDate + scatterDates: $scatterDates + multiDayStartDate: $multiDayStartDate + multiDayEndDate: $multiDayEndDate + bufferTimeBefore: $bufferTimeBefore + bufferTimeAfter: $bufferTimeAfter + conflictDetectionEnabled: $conflictDetectionEnabled + detectedConflicts: $detectedConflicts + businessId: $businessId + businessName: $businessName + vendorId: $vendorId + vendorName: $vendorName + hub: $hub + eventLocation: $eventLocation + contractType: $contractType + poReference: $poReference + status: $status + date: $date + shifts: $shifts + addons: $addons + total: $total + clientName: $clientName + clientEmail: $clientEmail + clientPhone: $clientPhone + invoiceId: $invoiceId + notes: $notes + requested: $requested + assignedStaff: $assignedStaff + } + ) +} + +mutation DeleteEvent( + $id: UUID! +) @auth(level: USER) { + event_delete(id: $id) +} diff --git a/dataconnect/connector/event/queries.gql b/dataconnect/connector/event/queries.gql index 1c7103d5..c8c1c98b 100644 --- a/dataconnect/connector/event/queries.gql +++ b/dataconnect/connector/event/queries.gql @@ -4,11 +4,144 @@ query listEvents @auth(level: USER) { eventName status date + isRapid isRecurring + isMultiDay recurrenceType + recurrenceStartDate + recurrenceEndDate + scatterDates + multiDayStartDate + multiDayEndDate + bufferTimeBefore + bufferTimeAfter + conflictDetectionEnabled + detectedConflicts businessId + businessName vendorId + vendorName + hub + eventLocation + contractType + poReference + shifts + addons total + clientName + clientEmail + clientPhone + invoiceId + notes requested + assignedStaff } -} \ No newline at end of file +} + +query getEventById( + $id: UUID! +) @auth(level: USER) { + event(id: $id) { + id + eventName + status + date + isRapid + isRecurring + isMultiDay + recurrenceType + recurrenceStartDate + recurrenceEndDate + scatterDates + multiDayStartDate + multiDayEndDate + bufferTimeBefore + bufferTimeAfter + conflictDetectionEnabled + detectedConflicts + businessId + businessName + vendorId + vendorName + hub + eventLocation + contractType + poReference + shifts + addons + total + clientName + clientEmail + clientPhone + invoiceId + notes + requested + assignedStaff + } +} + +query filterEvents( + $status: EventStatus, + $businessId: UUID, + $vendorId: UUID, + $isRecurring: Boolean, + $isRapid: Boolean, + $isMultiDay: Boolean, + $recurrenceType: RecurrenceType, + $date: Timestamp, + $hub: String, + $eventLocation: String, + $contractType: ContractType, + $clientEmail: String +) @auth(level: USER) { + events(where: { + status: { eq: $status } + businessId: { eq: $businessId } + vendorId: { eq: $vendorId } + isRecurring: { eq: $isRecurring } + isRapid: { eq: $isRapid } + isMultiDay: { eq: $isMultiDay } + recurrenceType: { eq: $recurrenceType } + date: { eq: $date } + hub: { eq: $hub } + eventLocation: { eq: $eventLocation } + contractType: { eq: $contractType } + clientEmail: { eq: $clientEmail } + }) { + id + eventName + status + date + isRapid + isRecurring + isMultiDay + recurrenceType + recurrenceStartDate + recurrenceEndDate + scatterDates + multiDayStartDate + multiDayEndDate + bufferTimeBefore + bufferTimeAfter + conflictDetectionEnabled + detectedConflicts + businessId + businessName + vendorId + vendorName + hub + eventLocation + contractType + poReference + shifts + addons + total + clientName + clientEmail + clientPhone + invoiceId + notes + requested + assignedStaff + } +} diff --git a/dataconnect/schema/event.gql b/dataconnect/schema/event.gql index 96d4f67a..1767fbc2 100644 --- a/dataconnect/schema/event.gql +++ b/dataconnect/schema/event.gql @@ -15,19 +15,49 @@ enum RecurrenceType { SCATTER } +#enums cant start by a number, reason of _1099 +enum ContractType { + W2 + _1099 + TEMP + CONTRACT +} + type Event @table(name: "events") { id: UUID! @default(expr: "uuidV4()") eventName: String! - isRecurring: Boolean! + isRapid: Boolean @default(expr: "false") + isRecurring: Boolean @default(expr: "false") + isMultiDay: Boolean @default(expr: "false") recurrenceType: RecurrenceType + recurrenceStartDate: Timestamp + recurrenceEndDate: Timestamp + scatterDates: String + multiDayStartDate: Timestamp + multiDayEndDate: Timestamp + bufferTimeBefore: Float @default(expr: "0") + bufferTimeAfter: Float @default(expr: "0") + conflictDetectionEnabled: Boolean @default(expr: "true") + detectedConflicts: String businessId: UUID! + businessName: String vendorId: UUID + vendorName: Stringhub: String + eventLocation: String + contractType: ContractType + poReference: String status: EventStatus! date: Timestamp! shifts: String + addons: String total: Float - requested: Int + clientName: String + clientEmail: String + clientPhone: String + invoiceId: UUID + notes: String + requested: Int @default(expr: "0") assignedStaff: String createdDate: Timestamp @default(expr: "request.time") updatedDate: Timestamp @default(expr: "request.time") From 352adfed1c5557bf00254033352ed363f5b4668a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Tue, 25 Nov 2025 12:03:04 -0500 Subject: [PATCH 2/3] changing enum contractType and name of hub --- dataconnect/schema/event.gql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dataconnect/schema/event.gql b/dataconnect/schema/event.gql index 1767fbc2..48485ecb 100644 --- a/dataconnect/schema/event.gql +++ b/dataconnect/schema/event.gql @@ -15,10 +15,10 @@ enum RecurrenceType { SCATTER } -#enums cant start by a number, reason of _1099 +#enums cant start by a number, reason of C1099 enum ContractType { W2 - _1099 + C1099 TEMP CONTRACT } @@ -43,7 +43,8 @@ type Event @table(name: "events") { businessId: UUID! businessName: String vendorId: UUID - vendorName: Stringhub: String + vendorName: String + hub: String eventLocation: String contractType: ContractType poReference: String From 25fd4e1f18c77b514b5818987b3b9e44f5161d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Tue, 25 Nov 2025 12:03:32 -0500 Subject: [PATCH 3/3] new schema for event v.3 --- .../dataconnect-generated/.guides/usage.md | 14 +- .../src/dataconnect-generated/README.md | 961 ++++++++++++++++-- .../dataconnect-generated/esm/index.esm.js | 73 +- .../src/dataconnect-generated/index.cjs.js | 80 +- .../src/dataconnect-generated/index.d.ts | 280 ++++- .../src/dataconnect-generated/react/README.md | 763 ++++++++++++-- .../react/esm/index.esm.js | 43 +- .../dataconnect-generated/react/index.cjs.js | 43 +- .../dataconnect-generated/react/index.d.ts | 20 +- .../dataconnect-generated/.guides/usage.md | 14 +- .../src/dataconnect-generated/README.md | 961 ++++++++++++++++-- .../dataconnect-generated/esm/index.esm.js | 73 +- .../src/dataconnect-generated/index.cjs.js | 80 +- .../src/dataconnect-generated/index.d.ts | 280 ++++- .../src/dataconnect-generated/react/README.md | 763 ++++++++++++-- .../react/esm/index.esm.js | 43 +- .../dataconnect-generated/react/index.cjs.js | 43 +- .../dataconnect-generated/react/index.d.ts | 20 +- 18 files changed, 4046 insertions(+), 508 deletions(-) diff --git a/frontend-web/src/dataconnect-generated/.guides/usage.md b/frontend-web/src/dataconnect-generated/.guides/usage.md index 9f12f2ca..d04f7413 100644 --- a/frontend-web/src/dataconnect-generated/.guides/usage.md +++ b/frontend-web/src/dataconnect-generated/.guides/usage.md @@ -12,11 +12,9 @@ For each operation, there is a wrapper hook that can be used to call the operati Here are all of the hooks that get generated: ```ts -import { useListEvents, useCreateStaff, useListStaff, useCreateVendor, useUpdateVendor, useDeleteVendor, useListVendor, useGetVendorById, useFilterVendors, useCreateEvent } from '@dataconnect/generated/react'; +import { useCreateStaff, useListStaff, useCreateVendor, useUpdateVendor, useDeleteVendor, useListVendor, useGetVendorById, useFilterVendors, useCreateEvent, useUpdateEvent } from '@dataconnect/generated/react'; // The types of these hooks are available in react/index.d.ts -const { data, isPending, isSuccess, isError, error } = useListEvents(); - const { data, isPending, isSuccess, isError, error } = useCreateStaff(createStaffVars); const { data, isPending, isSuccess, isError, error } = useListStaff(); @@ -35,6 +33,8 @@ const { data, isPending, isSuccess, isError, error } = useFilterVendors(filterVe const { data, isPending, isSuccess, isError, error } = useCreateEvent(createEventVars); +const { data, isPending, isSuccess, isError, error } = useUpdateEvent(updateEventVars); + ``` Here's an example from a different generated SDK: @@ -72,12 +72,9 @@ If a user is not using a supported framework, they can use the generated SDK dir Here's an example of how to use it with the first 5 operations: ```js -import { listEvents, createStaff, listStaff, createVendor, updateVendor, deleteVendor, listVendor, getVendorById, filterVendors, createEvent } from '@dataconnect/generated'; +import { createStaff, listStaff, createVendor, updateVendor, deleteVendor, listVendor, getVendorById, filterVendors, createEvent, updateEvent } from '@dataconnect/generated'; -// Operation listEvents: -const { data } = await ListEvents(dataConnect); - // Operation CreateStaff: For variables, look at type CreateStaffVars in ../index.d.ts const { data } = await CreateStaff(dataConnect, createStaffVars); @@ -105,5 +102,8 @@ const { data } = await FilterVendors(dataConnect, filterVendorsVars); // Operation CreateEvent: For variables, look at type CreateEventVars in ../index.d.ts const { data } = await CreateEvent(dataConnect, createEventVars); +// Operation UpdateEvent: For variables, look at type UpdateEventVars in ../index.d.ts +const { data } = await UpdateEvent(dataConnect, updateEventVars); + ``` \ No newline at end of file diff --git a/frontend-web/src/dataconnect-generated/README.md b/frontend-web/src/dataconnect-generated/README.md index f642ed82..1cfab8f7 100644 --- a/frontend-web/src/dataconnect-generated/README.md +++ b/frontend-web/src/dataconnect-generated/README.md @@ -10,17 +10,21 @@ This README will guide you through the process of using the generated JavaScript - [**Accessing the connector**](#accessing-the-connector) - [*Connecting to the local Emulator*](#connecting-to-the-local-emulator) - [**Queries**](#queries) - - [*listEvents*](#listevents) - [*listStaff*](#liststaff) - [*listVendor*](#listvendor) - [*getVendorById*](#getvendorbyid) - [*filterVendors*](#filtervendors) + - [*listEvents*](#listevents) + - [*getEventById*](#geteventbyid) + - [*filterEvents*](#filterevents) - [**Mutations**](#mutations) - [*CreateStaff*](#createstaff) - [*CreateVendor*](#createvendor) - [*UpdateVendor*](#updatevendor) - [*DeleteVendor*](#deletevendor) - [*CreateEvent*](#createevent) + - [*UpdateEvent*](#updateevent) + - [*DeleteEvent*](#deleteevent) # Accessing the connector A connector is a collection of Queries and Mutations. One SDK is generated for each connector - this SDK is generated for the connector `krow-connector`. You can find more information about connectors in the [Data Connect documentation](https://firebase.google.com/docs/data-connect#how-does). @@ -67,108 +71,6 @@ The following is true for both the action shortcut function and the `QueryRef` f Below are examples of how to use the `krow-connector` connector's generated functions to execute each query. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#using-queries). -## listEvents -You can execute the `listEvents` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): -```typescript -listEvents(): QueryPromise; - -interface ListEventsRef { - ... - /* Allow users to create refs without passing in DataConnect */ - (): QueryRef; -} -export const listEventsRef: ListEventsRef; -``` -You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. -```typescript -listEvents(dc: DataConnect): QueryPromise; - -interface ListEventsRef { - ... - (dc: DataConnect): QueryRef; -} -export const listEventsRef: ListEventsRef; -``` - -If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the listEventsRef: -```typescript -const name = listEventsRef.operationName; -console.log(name); -``` - -### Variables -The `listEvents` query has no variables. -### Return Type -Recall that executing the `listEvents` query returns a `QueryPromise` that resolves to an object with a `data` property. - -The `data` property is an object of type `ListEventsData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: -```typescript -export interface ListEventsData { - events: ({ - id: UUIDString; - eventName: string; - status: EventStatus; - date: TimestampString; - isRecurring: boolean; - recurrenceType?: RecurrenceType | null; - businessId: UUIDString; - vendorId?: UUIDString | null; - total?: number | null; - requested?: number | null; - } & Event_Key)[]; -} -``` -### Using `listEvents`'s action shortcut function - -```typescript -import { getDataConnect } from 'firebase/data-connect'; -import { connectorConfig, listEvents } from '@dataconnect/generated'; - - -// Call the `listEvents()` function to execute the query. -// You can use the `await` keyword to wait for the promise to resolve. -const { data } = await listEvents(); - -// You can also pass in a `DataConnect` instance to the action shortcut function. -const dataConnect = getDataConnect(connectorConfig); -const { data } = await listEvents(dataConnect); - -console.log(data.events); - -// Or, you can use the `Promise` API. -listEvents().then((response) => { - const data = response.data; - console.log(data.events); -}); -``` - -### Using `listEvents`'s `QueryRef` function - -```typescript -import { getDataConnect, executeQuery } from 'firebase/data-connect'; -import { connectorConfig, listEventsRef } from '@dataconnect/generated'; - - -// Call the `listEventsRef()` function to get a reference to the query. -const ref = listEventsRef(); - -// You can also pass in a `DataConnect` instance to the `QueryRef` function. -const dataConnect = getDataConnect(connectorConfig); -const ref = listEventsRef(dataConnect); - -// Call `executeQuery()` on the reference to execute the query. -// You can use the `await` keyword to wait for the promise to resolve. -const { data } = await executeQuery(ref); - -console.log(data.events); - -// Or, you can use the `Promise` API. -executeQuery(ref).then((response) => { - const data = response.data; - console.log(data.events); -}); -``` - ## listStaff You can execute the `listStaff` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): ```typescript @@ -629,6 +531,460 @@ executeQuery(ref).then((response) => { }); ``` +## listEvents +You can execute the `listEvents` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): +```typescript +listEvents(): QueryPromise; + +interface ListEventsRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (): QueryRef; +} +export const listEventsRef: ListEventsRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```typescript +listEvents(dc: DataConnect): QueryPromise; + +interface ListEventsRef { + ... + (dc: DataConnect): QueryRef; +} +export const listEventsRef: ListEventsRef; +``` + +If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the listEventsRef: +```typescript +const name = listEventsRef.operationName; +console.log(name); +``` + +### Variables +The `listEvents` query has no variables. +### Return Type +Recall that executing the `listEvents` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `ListEventsData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface ListEventsData { + events: ({ + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key)[]; +} +``` +### Using `listEvents`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, listEvents } from '@dataconnect/generated'; + + +// Call the `listEvents()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await listEvents(); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await listEvents(dataConnect); + +console.log(data.events); + +// Or, you can use the `Promise` API. +listEvents().then((response) => { + const data = response.data; + console.log(data.events); +}); +``` + +### Using `listEvents`'s `QueryRef` function + +```typescript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, listEventsRef } from '@dataconnect/generated'; + + +// Call the `listEventsRef()` function to get a reference to the query. +const ref = listEventsRef(); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = listEventsRef(dataConnect); + +// Call `executeQuery()` on the reference to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await executeQuery(ref); + +console.log(data.events); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.events); +}); +``` + +## getEventById +You can execute the `getEventById` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): +```typescript +getEventById(vars: GetEventByIdVariables): QueryPromise; + +interface GetEventByIdRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: GetEventByIdVariables): QueryRef; +} +export const getEventByIdRef: GetEventByIdRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```typescript +getEventById(dc: DataConnect, vars: GetEventByIdVariables): QueryPromise; + +interface GetEventByIdRef { + ... + (dc: DataConnect, vars: GetEventByIdVariables): QueryRef; +} +export const getEventByIdRef: GetEventByIdRef; +``` + +If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the getEventByIdRef: +```typescript +const name = getEventByIdRef.operationName; +console.log(name); +``` + +### Variables +The `getEventById` query requires an argument of type `GetEventByIdVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface GetEventByIdVariables { + id: UUIDString; +} +``` +### Return Type +Recall that executing the `getEventById` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `GetEventByIdData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface GetEventByIdData { + event?: { + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key; +} +``` +### Using `getEventById`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, getEventById, GetEventByIdVariables } from '@dataconnect/generated'; + +// The `getEventById` query requires an argument of type `GetEventByIdVariables`: +const getEventByIdVars: GetEventByIdVariables = { + id: ..., +}; + +// Call the `getEventById()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await getEventById(getEventByIdVars); +// Variables can be defined inline as well. +const { data } = await getEventById({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await getEventById(dataConnect, getEventByIdVars); + +console.log(data.event); + +// Or, you can use the `Promise` API. +getEventById(getEventByIdVars).then((response) => { + const data = response.data; + console.log(data.event); +}); +``` + +### Using `getEventById`'s `QueryRef` function + +```typescript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, getEventByIdRef, GetEventByIdVariables } from '@dataconnect/generated'; + +// The `getEventById` query requires an argument of type `GetEventByIdVariables`: +const getEventByIdVars: GetEventByIdVariables = { + id: ..., +}; + +// Call the `getEventByIdRef()` function to get a reference to the query. +const ref = getEventByIdRef(getEventByIdVars); +// Variables can be defined inline as well. +const ref = getEventByIdRef({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = getEventByIdRef(dataConnect, getEventByIdVars); + +// Call `executeQuery()` on the reference to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await executeQuery(ref); + +console.log(data.event); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.event); +}); +``` + +## filterEvents +You can execute the `filterEvents` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): +```typescript +filterEvents(vars?: FilterEventsVariables): QueryPromise; + +interface FilterEventsRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars?: FilterEventsVariables): QueryRef; +} +export const filterEventsRef: FilterEventsRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```typescript +filterEvents(dc: DataConnect, vars?: FilterEventsVariables): QueryPromise; + +interface FilterEventsRef { + ... + (dc: DataConnect, vars?: FilterEventsVariables): QueryRef; +} +export const filterEventsRef: FilterEventsRef; +``` + +If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the filterEventsRef: +```typescript +const name = filterEventsRef.operationName; +console.log(name); +``` + +### Variables +The `filterEvents` query has an optional argument of type `FilterEventsVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface FilterEventsVariables { + status?: EventStatus | null; + businessId?: UUIDString | null; + vendorId?: UUIDString | null; + isRecurring?: boolean | null; + isRapid?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + date?: TimestampString | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + clientEmail?: string | null; +} +``` +### Return Type +Recall that executing the `filterEvents` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `FilterEventsData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface FilterEventsData { + events: ({ + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key)[]; +} +``` +### Using `filterEvents`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, filterEvents, FilterEventsVariables } from '@dataconnect/generated'; + +// The `filterEvents` query has an optional argument of type `FilterEventsVariables`: +const filterEventsVars: FilterEventsVariables = { + status: ..., // optional + businessId: ..., // optional + vendorId: ..., // optional + isRecurring: ..., // optional + isRapid: ..., // optional + isMultiDay: ..., // optional + recurrenceType: ..., // optional + date: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + clientEmail: ..., // optional +}; + +// Call the `filterEvents()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await filterEvents(filterEventsVars); +// Variables can be defined inline as well. +const { data } = await filterEvents({ status: ..., businessId: ..., vendorId: ..., isRecurring: ..., isRapid: ..., isMultiDay: ..., recurrenceType: ..., date: ..., hub: ..., eventLocation: ..., contractType: ..., clientEmail: ..., }); +// Since all variables are optional for this query, you can omit the `FilterEventsVariables` argument. +const { data } = await filterEvents(); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await filterEvents(dataConnect, filterEventsVars); + +console.log(data.events); + +// Or, you can use the `Promise` API. +filterEvents(filterEventsVars).then((response) => { + const data = response.data; + console.log(data.events); +}); +``` + +### Using `filterEvents`'s `QueryRef` function + +```typescript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, filterEventsRef, FilterEventsVariables } from '@dataconnect/generated'; + +// The `filterEvents` query has an optional argument of type `FilterEventsVariables`: +const filterEventsVars: FilterEventsVariables = { + status: ..., // optional + businessId: ..., // optional + vendorId: ..., // optional + isRecurring: ..., // optional + isRapid: ..., // optional + isMultiDay: ..., // optional + recurrenceType: ..., // optional + date: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + clientEmail: ..., // optional +}; + +// Call the `filterEventsRef()` function to get a reference to the query. +const ref = filterEventsRef(filterEventsVars); +// Variables can be defined inline as well. +const ref = filterEventsRef({ status: ..., businessId: ..., vendorId: ..., isRecurring: ..., isRapid: ..., isMultiDay: ..., recurrenceType: ..., date: ..., hub: ..., eventLocation: ..., contractType: ..., clientEmail: ..., }); +// Since all variables are optional for this query, you can omit the `FilterEventsVariables` argument. +const ref = filterEventsRef(); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = filterEventsRef(dataConnect, filterEventsVars); + +// Call `executeQuery()` on the reference to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await executeQuery(ref); + +console.log(data.events); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.events); +}); +``` + # Mutations There are two ways to execute a Data Connect Mutation using the generated Web SDK: @@ -1178,14 +1534,37 @@ The `CreateEvent` mutation requires an argument of type `CreateEventVariables`, ```typescript export interface CreateEventVariables { eventName: string; - isRecurring: boolean; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; businessId: UUIDString; + businessName?: string | null; vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; status: EventStatus; date: TimestampString; shifts?: string | null; + addons?: string | null; total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; requested?: number | null; assignedStaff?: string | null; } @@ -1208,14 +1587,37 @@ import { connectorConfig, createEvent, CreateEventVariables } from '@dataconnect // The `CreateEvent` mutation requires an argument of type `CreateEventVariables`: const createEventVars: CreateEventVariables = { eventName: ..., - isRecurring: ..., + isRapid: ..., // optional + isRecurring: ..., // optional + isMultiDay: ..., // optional recurrenceType: ..., // optional + recurrenceStartDate: ..., // optional + recurrenceEndDate: ..., // optional + scatterDates: ..., // optional + multiDayStartDate: ..., // optional + multiDayEndDate: ..., // optional + bufferTimeBefore: ..., // optional + bufferTimeAfter: ..., // optional + conflictDetectionEnabled: ..., // optional + detectedConflicts: ..., // optional businessId: ..., + businessName: ..., // optional vendorId: ..., // optional + vendorName: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + poReference: ..., // optional status: ..., date: ..., shifts: ..., // optional + addons: ..., // optional total: ..., // optional + clientName: ..., // optional + clientEmail: ..., // optional + clientPhone: ..., // optional + invoiceId: ..., // optional + notes: ..., // optional requested: ..., // optional assignedStaff: ..., // optional }; @@ -1224,7 +1626,7 @@ const createEventVars: CreateEventVariables = { // You can use the `await` keyword to wait for the promise to resolve. const { data } = await createEvent(createEventVars); // Variables can be defined inline as well. -const { data } = await createEvent({ eventName: ..., isRecurring: ..., recurrenceType: ..., businessId: ..., vendorId: ..., status: ..., date: ..., shifts: ..., total: ..., requested: ..., assignedStaff: ..., }); +const { data } = await createEvent({ eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., }); // You can also pass in a `DataConnect` instance to the action shortcut function. const dataConnect = getDataConnect(connectorConfig); @@ -1248,14 +1650,37 @@ import { connectorConfig, createEventRef, CreateEventVariables } from '@dataconn // The `CreateEvent` mutation requires an argument of type `CreateEventVariables`: const createEventVars: CreateEventVariables = { eventName: ..., - isRecurring: ..., + isRapid: ..., // optional + isRecurring: ..., // optional + isMultiDay: ..., // optional recurrenceType: ..., // optional + recurrenceStartDate: ..., // optional + recurrenceEndDate: ..., // optional + scatterDates: ..., // optional + multiDayStartDate: ..., // optional + multiDayEndDate: ..., // optional + bufferTimeBefore: ..., // optional + bufferTimeAfter: ..., // optional + conflictDetectionEnabled: ..., // optional + detectedConflicts: ..., // optional businessId: ..., + businessName: ..., // optional vendorId: ..., // optional + vendorName: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + poReference: ..., // optional status: ..., date: ..., shifts: ..., // optional + addons: ..., // optional total: ..., // optional + clientName: ..., // optional + clientEmail: ..., // optional + clientPhone: ..., // optional + invoiceId: ..., // optional + notes: ..., // optional requested: ..., // optional assignedStaff: ..., // optional }; @@ -1263,7 +1688,7 @@ const createEventVars: CreateEventVariables = { // Call the `createEventRef()` function to get a reference to the mutation. const ref = createEventRef(createEventVars); // Variables can be defined inline as well. -const ref = createEventRef({ eventName: ..., isRecurring: ..., recurrenceType: ..., businessId: ..., vendorId: ..., status: ..., date: ..., shifts: ..., total: ..., requested: ..., assignedStaff: ..., }); +const ref = createEventRef({ eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., }); // You can also pass in a `DataConnect` instance to the `MutationRef` function. const dataConnect = getDataConnect(connectorConfig); @@ -1282,3 +1707,323 @@ executeMutation(ref).then((response) => { }); ``` +## UpdateEvent +You can execute the `UpdateEvent` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): +```typescript +updateEvent(vars: UpdateEventVariables): MutationPromise; + +interface UpdateEventRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: UpdateEventVariables): MutationRef; +} +export const updateEventRef: UpdateEventRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. +```typescript +updateEvent(dc: DataConnect, vars: UpdateEventVariables): MutationPromise; + +interface UpdateEventRef { + ... + (dc: DataConnect, vars: UpdateEventVariables): MutationRef; +} +export const updateEventRef: UpdateEventRef; +``` + +If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the updateEventRef: +```typescript +const name = updateEventRef.operationName; +console.log(name); +``` + +### Variables +The `UpdateEvent` mutation requires an argument of type `UpdateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface UpdateEventVariables { + id: UUIDString; + eventName?: string | null; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId?: UUIDString | null; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + status?: EventStatus | null; + date?: TimestampString | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; +} +``` +### Return Type +Recall that executing the `UpdateEvent` mutation returns a `MutationPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `UpdateEventData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface UpdateEventData { + event_update?: Event_Key | null; +} +``` +### Using `UpdateEvent`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, updateEvent, UpdateEventVariables } from '@dataconnect/generated'; + +// The `UpdateEvent` mutation requires an argument of type `UpdateEventVariables`: +const updateEventVars: UpdateEventVariables = { + id: ..., + eventName: ..., // optional + isRapid: ..., // optional + isRecurring: ..., // optional + isMultiDay: ..., // optional + recurrenceType: ..., // optional + recurrenceStartDate: ..., // optional + recurrenceEndDate: ..., // optional + scatterDates: ..., // optional + multiDayStartDate: ..., // optional + multiDayEndDate: ..., // optional + bufferTimeBefore: ..., // optional + bufferTimeAfter: ..., // optional + conflictDetectionEnabled: ..., // optional + detectedConflicts: ..., // optional + businessId: ..., // optional + businessName: ..., // optional + vendorId: ..., // optional + vendorName: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + poReference: ..., // optional + status: ..., // optional + date: ..., // optional + shifts: ..., // optional + addons: ..., // optional + total: ..., // optional + clientName: ..., // optional + clientEmail: ..., // optional + clientPhone: ..., // optional + invoiceId: ..., // optional + notes: ..., // optional + requested: ..., // optional + assignedStaff: ..., // optional +}; + +// Call the `updateEvent()` function to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await updateEvent(updateEventVars); +// Variables can be defined inline as well. +const { data } = await updateEvent({ id: ..., eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await updateEvent(dataConnect, updateEventVars); + +console.log(data.event_update); + +// Or, you can use the `Promise` API. +updateEvent(updateEventVars).then((response) => { + const data = response.data; + console.log(data.event_update); +}); +``` + +### Using `UpdateEvent`'s `MutationRef` function + +```typescript +import { getDataConnect, executeMutation } from 'firebase/data-connect'; +import { connectorConfig, updateEventRef, UpdateEventVariables } from '@dataconnect/generated'; + +// The `UpdateEvent` mutation requires an argument of type `UpdateEventVariables`: +const updateEventVars: UpdateEventVariables = { + id: ..., + eventName: ..., // optional + isRapid: ..., // optional + isRecurring: ..., // optional + isMultiDay: ..., // optional + recurrenceType: ..., // optional + recurrenceStartDate: ..., // optional + recurrenceEndDate: ..., // optional + scatterDates: ..., // optional + multiDayStartDate: ..., // optional + multiDayEndDate: ..., // optional + bufferTimeBefore: ..., // optional + bufferTimeAfter: ..., // optional + conflictDetectionEnabled: ..., // optional + detectedConflicts: ..., // optional + businessId: ..., // optional + businessName: ..., // optional + vendorId: ..., // optional + vendorName: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + poReference: ..., // optional + status: ..., // optional + date: ..., // optional + shifts: ..., // optional + addons: ..., // optional + total: ..., // optional + clientName: ..., // optional + clientEmail: ..., // optional + clientPhone: ..., // optional + invoiceId: ..., // optional + notes: ..., // optional + requested: ..., // optional + assignedStaff: ..., // optional +}; + +// Call the `updateEventRef()` function to get a reference to the mutation. +const ref = updateEventRef(updateEventVars); +// Variables can be defined inline as well. +const ref = updateEventRef({ id: ..., eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., }); + +// You can also pass in a `DataConnect` instance to the `MutationRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = updateEventRef(dataConnect, updateEventVars); + +// Call `executeMutation()` on the reference to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await executeMutation(ref); + +console.log(data.event_update); + +// Or, you can use the `Promise` API. +executeMutation(ref).then((response) => { + const data = response.data; + console.log(data.event_update); +}); +``` + +## DeleteEvent +You can execute the `DeleteEvent` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): +```typescript +deleteEvent(vars: DeleteEventVariables): MutationPromise; + +interface DeleteEventRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: DeleteEventVariables): MutationRef; +} +export const deleteEventRef: DeleteEventRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. +```typescript +deleteEvent(dc: DataConnect, vars: DeleteEventVariables): MutationPromise; + +interface DeleteEventRef { + ... + (dc: DataConnect, vars: DeleteEventVariables): MutationRef; +} +export const deleteEventRef: DeleteEventRef; +``` + +If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the deleteEventRef: +```typescript +const name = deleteEventRef.operationName; +console.log(name); +``` + +### Variables +The `DeleteEvent` mutation requires an argument of type `DeleteEventVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface DeleteEventVariables { + id: UUIDString; +} +``` +### Return Type +Recall that executing the `DeleteEvent` mutation returns a `MutationPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `DeleteEventData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface DeleteEventData { + event_delete?: Event_Key | null; +} +``` +### Using `DeleteEvent`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, deleteEvent, DeleteEventVariables } from '@dataconnect/generated'; + +// The `DeleteEvent` mutation requires an argument of type `DeleteEventVariables`: +const deleteEventVars: DeleteEventVariables = { + id: ..., +}; + +// Call the `deleteEvent()` function to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await deleteEvent(deleteEventVars); +// Variables can be defined inline as well. +const { data } = await deleteEvent({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await deleteEvent(dataConnect, deleteEventVars); + +console.log(data.event_delete); + +// Or, you can use the `Promise` API. +deleteEvent(deleteEventVars).then((response) => { + const data = response.data; + console.log(data.event_delete); +}); +``` + +### Using `DeleteEvent`'s `MutationRef` function + +```typescript +import { getDataConnect, executeMutation } from 'firebase/data-connect'; +import { connectorConfig, deleteEventRef, DeleteEventVariables } from '@dataconnect/generated'; + +// The `DeleteEvent` mutation requires an argument of type `DeleteEventVariables`: +const deleteEventVars: DeleteEventVariables = { + id: ..., +}; + +// Call the `deleteEventRef()` function to get a reference to the mutation. +const ref = deleteEventRef(deleteEventVars); +// Variables can be defined inline as well. +const ref = deleteEventRef({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the `MutationRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = deleteEventRef(dataConnect, deleteEventVars); + +// Call `executeMutation()` on the reference to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await executeMutation(ref); + +console.log(data.event_delete); + +// Or, you can use the `Promise` API. +executeMutation(ref).then((response) => { + const data = response.data; + console.log(data.event_delete); +}); +``` + diff --git a/frontend-web/src/dataconnect-generated/esm/index.esm.js b/frontend-web/src/dataconnect-generated/esm/index.esm.js index 5a6db9e0..3973bccc 100644 --- a/frontend-web/src/dataconnect-generated/esm/index.esm.js +++ b/frontend-web/src/dataconnect-generated/esm/index.esm.js @@ -7,6 +7,13 @@ export const BackgroundCheckStatus = { EXPIRED: "EXPIRED", } +export const ContractType = { + W2: "W2", + C1099: "C1099", + TEMP: "TEMP", + CONTRACT: "CONTRACT", +} + export const EmploymentType = { FULL_TIME: "FULL_TIME", PART_TIME: "PART_TIME", @@ -61,17 +68,6 @@ export const connectorConfig = { location: 'us-central1' }; -export const listEventsRef = (dc) => { - const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); - dcInstance._useGeneratedSdk(); - return queryRef(dcInstance, 'listEvents'); -} -listEventsRef.operationName = 'listEvents'; - -export function listEvents(dc) { - return executeQuery(listEventsRef(dc)); -} - export const createStaffRef = (dcOrVars, vars) => { const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); dcInstance._useGeneratedSdk(); @@ -171,3 +167,58 @@ export function createEvent(dcOrVars, vars) { return executeMutation(createEventRef(dcOrVars, vars)); } +export const updateEventRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'UpdateEvent', inputVars); +} +updateEventRef.operationName = 'UpdateEvent'; + +export function updateEvent(dcOrVars, vars) { + return executeMutation(updateEventRef(dcOrVars, vars)); +} + +export const deleteEventRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'DeleteEvent', inputVars); +} +deleteEventRef.operationName = 'DeleteEvent'; + +export function deleteEvent(dcOrVars, vars) { + return executeMutation(deleteEventRef(dcOrVars, vars)); +} + +export const listEventsRef = (dc) => { + const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'listEvents'); +} +listEventsRef.operationName = 'listEvents'; + +export function listEvents(dc) { + return executeQuery(listEventsRef(dc)); +} + +export const getEventByIdRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'getEventById', inputVars); +} +getEventByIdRef.operationName = 'getEventById'; + +export function getEventById(dcOrVars, vars) { + return executeQuery(getEventByIdRef(dcOrVars, vars)); +} + +export const filterEventsRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'filterEvents', inputVars); +} +filterEventsRef.operationName = 'filterEvents'; + +export function filterEvents(dcOrVars, vars) { + return executeQuery(filterEventsRef(dcOrVars, vars)); +} + diff --git a/frontend-web/src/dataconnect-generated/index.cjs.js b/frontend-web/src/dataconnect-generated/index.cjs.js index 1aaa1719..c566e227 100644 --- a/frontend-web/src/dataconnect-generated/index.cjs.js +++ b/frontend-web/src/dataconnect-generated/index.cjs.js @@ -8,6 +8,14 @@ const BackgroundCheckStatus = { } exports.BackgroundCheckStatus = BackgroundCheckStatus; +const ContractType = { + W2: "W2", + C1099: "C1099", + TEMP: "TEMP", + CONTRACT: "CONTRACT", +} +exports.ContractType = ContractType; + const EmploymentType = { FULL_TIME: "FULL_TIME", PART_TIME: "PART_TIME", @@ -69,18 +77,6 @@ const connectorConfig = { }; exports.connectorConfig = connectorConfig; -const listEventsRef = (dc) => { - const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); - dcInstance._useGeneratedSdk(); - return queryRef(dcInstance, 'listEvents'); -} -listEventsRef.operationName = 'listEvents'; -exports.listEventsRef = listEventsRef; - -exports.listEvents = function listEvents(dc) { - return executeQuery(listEventsRef(dc)); -}; - const createStaffRef = (dcOrVars, vars) => { const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); dcInstance._useGeneratedSdk(); @@ -188,3 +184,63 @@ exports.createEventRef = createEventRef; exports.createEvent = function createEvent(dcOrVars, vars) { return executeMutation(createEventRef(dcOrVars, vars)); }; + +const updateEventRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'UpdateEvent', inputVars); +} +updateEventRef.operationName = 'UpdateEvent'; +exports.updateEventRef = updateEventRef; + +exports.updateEvent = function updateEvent(dcOrVars, vars) { + return executeMutation(updateEventRef(dcOrVars, vars)); +}; + +const deleteEventRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'DeleteEvent', inputVars); +} +deleteEventRef.operationName = 'DeleteEvent'; +exports.deleteEventRef = deleteEventRef; + +exports.deleteEvent = function deleteEvent(dcOrVars, vars) { + return executeMutation(deleteEventRef(dcOrVars, vars)); +}; + +const listEventsRef = (dc) => { + const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'listEvents'); +} +listEventsRef.operationName = 'listEvents'; +exports.listEventsRef = listEventsRef; + +exports.listEvents = function listEvents(dc) { + return executeQuery(listEventsRef(dc)); +}; + +const getEventByIdRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'getEventById', inputVars); +} +getEventByIdRef.operationName = 'getEventById'; +exports.getEventByIdRef = getEventByIdRef; + +exports.getEventById = function getEventById(dcOrVars, vars) { + return executeQuery(getEventByIdRef(dcOrVars, vars)); +}; + +const filterEventsRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'filterEvents', inputVars); +} +filterEventsRef.operationName = 'filterEvents'; +exports.filterEventsRef = filterEventsRef; + +exports.filterEvents = function filterEvents(dcOrVars, vars) { + return executeQuery(filterEventsRef(dcOrVars, vars)); +}; diff --git a/frontend-web/src/dataconnect-generated/index.d.ts b/frontend-web/src/dataconnect-generated/index.d.ts index 4013e843..5d228d71 100644 --- a/frontend-web/src/dataconnect-generated/index.d.ts +++ b/frontend-web/src/dataconnect-generated/index.d.ts @@ -15,6 +15,13 @@ export enum BackgroundCheckStatus { EXPIRED = "EXPIRED", }; +export enum ContractType { + W2 = "W2", + C1099 = "C1099", + TEMP = "TEMP", + CONTRACT = "CONTRACT", +}; + export enum EmploymentType { FULL_TIME = "FULL_TIME", PART_TIME = "PART_TIME", @@ -71,14 +78,37 @@ export interface CreateEventData { export interface CreateEventVariables { eventName: string; - isRecurring: boolean; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; businessId: UUIDString; + businessName?: string | null; vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; status: EventStatus; date: TimestampString; shifts?: string | null; + addons?: string | null; total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; requested?: number | null; assignedStaff?: string | null; } @@ -113,6 +143,14 @@ export interface CreateVendorVariables { isActive?: boolean | null; } +export interface DeleteEventData { + event_delete?: Event_Key | null; +} + +export interface DeleteEventVariables { + id: UUIDString; +} + export interface DeleteVendorData { vendor_delete?: Vendor_Key | null; } @@ -126,6 +164,61 @@ export interface Event_Key { __typename?: 'Event_Key'; } +export interface FilterEventsData { + events: ({ + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key)[]; +} + +export interface FilterEventsVariables { + status?: EventStatus | null; + businessId?: UUIDString | null; + vendorId?: UUIDString | null; + isRecurring?: boolean | null; + isRapid?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + date?: TimestampString | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + clientEmail?: string | null; +} + export interface FilterVendorsData { vendors: ({ id: UUIDString; @@ -149,6 +242,50 @@ export interface FilterVendorsVariables { platformType?: VendorPlatformType | null; } +export interface GetEventByIdData { + event?: { + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key; +} + +export interface GetEventByIdVariables { + id: UUIDString; +} + export interface GetVendorByIdData { vendor?: { id: UUIDString; @@ -172,12 +309,37 @@ export interface ListEventsData { eventName: string; status: EventStatus; date: TimestampString; - isRecurring: boolean; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; businessId: UUIDString; + businessName?: string | null; vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; requested?: number | null; + assignedStaff?: string | null; } & Event_Key)[]; } @@ -214,6 +376,48 @@ export interface Staff_Key { __typename?: 'Staff_Key'; } +export interface UpdateEventData { + event_update?: Event_Key | null; +} + +export interface UpdateEventVariables { + id: UUIDString; + eventName?: string | null; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId?: UUIDString | null; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + status?: EventStatus | null; + date?: TimestampString | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; +} + export interface UpdateVendorData { vendor_update?: Vendor_Key | null; } @@ -234,18 +438,6 @@ export interface Vendor_Key { __typename?: 'Vendor_Key'; } -interface ListEventsRef { - /* Allow users to create refs without passing in DataConnect */ - (): QueryRef; - /* Allow users to pass in custom DataConnect instances */ - (dc: DataConnect): QueryRef; - operationName: string; -} -export const listEventsRef: ListEventsRef; - -export function listEvents(): QueryPromise; -export function listEvents(dc: DataConnect): QueryPromise; - interface CreateStaffRef { /* Allow users to create refs without passing in DataConnect */ (vars: CreateStaffVariables): MutationRef; @@ -354,3 +546,63 @@ export const createEventRef: CreateEventRef; export function createEvent(vars: CreateEventVariables): MutationPromise; export function createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise; +interface UpdateEventRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: UpdateEventVariables): MutationRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: UpdateEventVariables): MutationRef; + operationName: string; +} +export const updateEventRef: UpdateEventRef; + +export function updateEvent(vars: UpdateEventVariables): MutationPromise; +export function updateEvent(dc: DataConnect, vars: UpdateEventVariables): MutationPromise; + +interface DeleteEventRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: DeleteEventVariables): MutationRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: DeleteEventVariables): MutationRef; + operationName: string; +} +export const deleteEventRef: DeleteEventRef; + +export function deleteEvent(vars: DeleteEventVariables): MutationPromise; +export function deleteEvent(dc: DataConnect, vars: DeleteEventVariables): MutationPromise; + +interface ListEventsRef { + /* Allow users to create refs without passing in DataConnect */ + (): QueryRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect): QueryRef; + operationName: string; +} +export const listEventsRef: ListEventsRef; + +export function listEvents(): QueryPromise; +export function listEvents(dc: DataConnect): QueryPromise; + +interface GetEventByIdRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: GetEventByIdVariables): QueryRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: GetEventByIdVariables): QueryRef; + operationName: string; +} +export const getEventByIdRef: GetEventByIdRef; + +export function getEventById(vars: GetEventByIdVariables): QueryPromise; +export function getEventById(dc: DataConnect, vars: GetEventByIdVariables): QueryPromise; + +interface FilterEventsRef { + /* Allow users to create refs without passing in DataConnect */ + (vars?: FilterEventsVariables): QueryRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars?: FilterEventsVariables): QueryRef; + operationName: string; +} +export const filterEventsRef: FilterEventsRef; + +export function filterEvents(vars?: FilterEventsVariables): QueryPromise; +export function filterEvents(dc: DataConnect, vars?: FilterEventsVariables): QueryPromise; + diff --git a/frontend-web/src/dataconnect-generated/react/README.md b/frontend-web/src/dataconnect-generated/react/README.md index 694d71dc..dd87a50d 100644 --- a/frontend-web/src/dataconnect-generated/react/README.md +++ b/frontend-web/src/dataconnect-generated/react/README.md @@ -17,17 +17,21 @@ You can also follow the instructions from the [Data Connect documentation](https - [**Accessing the connector**](#accessing-the-connector) - [*Connecting to the local Emulator*](#connecting-to-the-local-emulator) - [**Queries**](#queries) - - [*listEvents*](#listevents) - [*listStaff*](#liststaff) - [*listVendor*](#listvendor) - [*getVendorById*](#getvendorbyid) - [*filterVendors*](#filtervendors) + - [*listEvents*](#listevents) + - [*getEventById*](#geteventbyid) + - [*filterEvents*](#filterevents) - [**Mutations**](#mutations) - [*CreateStaff*](#createstaff) - [*CreateVendor*](#createvendor) - [*UpdateVendor*](#updatevendor) - [*DeleteVendor*](#deletevendor) - [*CreateEvent*](#createevent) + - [*UpdateEvent*](#updateevent) + - [*DeleteEvent*](#deleteevent) # TanStack Query Firebase & TanStack React Query This SDK provides [React](https://react.dev/) hooks generated specific to your application, for the operations found in the connector `krow-connector`. These hooks are generated using [TanStack Query Firebase](https://react-query-firebase.invertase.dev/) by our partners at Invertase, a library built on top of [TanStack React Query v5](https://tanstack.com/query/v5/docs/framework/react/overview). @@ -119,86 +123,6 @@ Here's a general overview of how to use the generated Query hooks in your code: Below are examples of how to use the `krow-connector` connector's generated Query hook functions to execute each Query. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#operations-react-angular). -## listEvents -You can execute the `listEvents` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): - -```javascript -useListEvents(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; -``` -You can also pass in a `DataConnect` instance to the Query hook function. -```javascript -useListEvents(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; -``` - -### Variables -The `listEvents` Query has no variables. -### Return Type -Recall that calling the `listEvents` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things. - -To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields. - -To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `listEvents` Query is of type `ListEventsData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: -```javascript -export interface ListEventsData { - events: ({ - id: UUIDString; - eventName: string; - status: EventStatus; - date: TimestampString; - isRecurring: boolean; - recurrenceType?: RecurrenceType | null; - businessId: UUIDString; - vendorId?: UUIDString | null; - total?: number | null; - requested?: number | null; - } & Event_Key)[]; -} -``` - -To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery). - -### Using `listEvents`'s Query hook function - -```javascript -import { getDataConnect } from 'firebase/data-connect'; -import { connectorConfig } from '@dataconnect/generated'; -import { useListEvents } from '@dataconnect/generated/react' - -export default function ListEventsComponent() { - // You don't have to do anything to "execute" the Query. - // Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query. - const query = useListEvents(); - - // You can also pass in a `DataConnect` instance to the Query hook function. - const dataConnect = getDataConnect(connectorConfig); - const query = useListEvents(dataConnect); - - // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. - const options = { staleTime: 5 * 1000 }; - const query = useListEvents(options); - - // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. - const dataConnect = getDataConnect(connectorConfig); - const options = { staleTime: 5 * 1000 }; - const query = useListEvents(dataConnect, options); - - // Then, you can render your component dynamically based on the status of the Query. - if (query.isPending) { - return
Loading...
; - } - - if (query.isError) { - return
Error: {query.error.message}
; - } - - // If the Query is successful, you can access the data returned using the `UseQueryResult.data` field. - if (query.isSuccess) { - console.log(query.data.events); - } - return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; -} -``` - ## listStaff You can execute the `listStaff` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): @@ -557,6 +481,375 @@ export default function FilterVendorsComponent() { } ``` +## listEvents +You can execute the `listEvents` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): + +```javascript +useListEvents(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` +You can also pass in a `DataConnect` instance to the Query hook function. +```javascript +useListEvents(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` + +### Variables +The `listEvents` Query has no variables. +### Return Type +Recall that calling the `listEvents` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things. + +To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields. + +To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `listEvents` Query is of type `ListEventsData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface ListEventsData { + events: ({ + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key)[]; +} +``` + +To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery). + +### Using `listEvents`'s Query hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig } from '@dataconnect/generated'; +import { useListEvents } from '@dataconnect/generated/react' + +export default function ListEventsComponent() { + // You don't have to do anything to "execute" the Query. + // Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query. + const query = useListEvents(); + + // You can also pass in a `DataConnect` instance to the Query hook function. + const dataConnect = getDataConnect(connectorConfig); + const query = useListEvents(dataConnect); + + // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. + const options = { staleTime: 5 * 1000 }; + const query = useListEvents(options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { staleTime: 5 * 1000 }; + const query = useListEvents(dataConnect, options); + + // Then, you can render your component dynamically based on the status of the Query. + if (query.isPending) { + return
Loading...
; + } + + if (query.isError) { + return
Error: {query.error.message}
; + } + + // If the Query is successful, you can access the data returned using the `UseQueryResult.data` field. + if (query.isSuccess) { + console.log(query.data.events); + } + return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## getEventById +You can execute the `getEventById` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): + +```javascript +useGetEventById(dc: DataConnect, vars: GetEventByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` +You can also pass in a `DataConnect` instance to the Query hook function. +```javascript +useGetEventById(vars: GetEventByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` + +### Variables +The `getEventById` Query requires an argument of type `GetEventByIdVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface GetEventByIdVariables { + id: UUIDString; +} +``` +### Return Type +Recall that calling the `getEventById` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things. + +To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields. + +To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `getEventById` Query is of type `GetEventByIdData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface GetEventByIdData { + event?: { + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key; +} +``` + +To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery). + +### Using `getEventById`'s Query hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, GetEventByIdVariables } from '@dataconnect/generated'; +import { useGetEventById } from '@dataconnect/generated/react' + +export default function GetEventByIdComponent() { + // The `useGetEventById` Query hook requires an argument of type `GetEventByIdVariables`: + const getEventByIdVars: GetEventByIdVariables = { + id: ..., + }; + + // You don't have to do anything to "execute" the Query. + // Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query. + const query = useGetEventById(getEventByIdVars); + // Variables can be defined inline as well. + const query = useGetEventById({ id: ..., }); + + // You can also pass in a `DataConnect` instance to the Query hook function. + const dataConnect = getDataConnect(connectorConfig); + const query = useGetEventById(dataConnect, getEventByIdVars); + + // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. + const options = { staleTime: 5 * 1000 }; + const query = useGetEventById(getEventByIdVars, options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { staleTime: 5 * 1000 }; + const query = useGetEventById(dataConnect, getEventByIdVars, options); + + // Then, you can render your component dynamically based on the status of the Query. + if (query.isPending) { + return
Loading...
; + } + + if (query.isError) { + return
Error: {query.error.message}
; + } + + // If the Query is successful, you can access the data returned using the `UseQueryResult.data` field. + if (query.isSuccess) { + console.log(query.data.event); + } + return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## filterEvents +You can execute the `filterEvents` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): + +```javascript +useFilterEvents(dc: DataConnect, vars?: FilterEventsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` +You can also pass in a `DataConnect` instance to the Query hook function. +```javascript +useFilterEvents(vars?: FilterEventsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` + +### Variables +The `filterEvents` Query has an optional argument of type `FilterEventsVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface FilterEventsVariables { + status?: EventStatus | null; + businessId?: UUIDString | null; + vendorId?: UUIDString | null; + isRecurring?: boolean | null; + isRapid?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + date?: TimestampString | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + clientEmail?: string | null; +} +``` +### Return Type +Recall that calling the `filterEvents` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things. + +To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields. + +To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `filterEvents` Query is of type `FilterEventsData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface FilterEventsData { + events: ({ + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key)[]; +} +``` + +To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery). + +### Using `filterEvents`'s Query hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, FilterEventsVariables } from '@dataconnect/generated'; +import { useFilterEvents } from '@dataconnect/generated/react' + +export default function FilterEventsComponent() { + // The `useFilterEvents` Query hook has an optional argument of type `FilterEventsVariables`: + const filterEventsVars: FilterEventsVariables = { + status: ..., // optional + businessId: ..., // optional + vendorId: ..., // optional + isRecurring: ..., // optional + isRapid: ..., // optional + isMultiDay: ..., // optional + recurrenceType: ..., // optional + date: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + clientEmail: ..., // optional + }; + + // You don't have to do anything to "execute" the Query. + // Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query. + const query = useFilterEvents(filterEventsVars); + // Variables can be defined inline as well. + const query = useFilterEvents({ status: ..., businessId: ..., vendorId: ..., isRecurring: ..., isRapid: ..., isMultiDay: ..., recurrenceType: ..., date: ..., hub: ..., eventLocation: ..., contractType: ..., clientEmail: ..., }); + // Since all variables are optional for this Query, you can omit the `FilterEventsVariables` argument. + // (as long as you don't want to provide any `options`!) + const query = useFilterEvents(); + + // You can also pass in a `DataConnect` instance to the Query hook function. + const dataConnect = getDataConnect(connectorConfig); + const query = useFilterEvents(dataConnect, filterEventsVars); + + // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. + const options = { staleTime: 5 * 1000 }; + const query = useFilterEvents(filterEventsVars, options); + // If you'd like to provide options without providing any variables, you must + // pass `undefined` where you would normally pass the variables. + const query = useFilterEvents(undefined, options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { staleTime: 5 * 1000 }; + const query = useFilterEvents(dataConnect, filterEventsVars /** or undefined */, options); + + // Then, you can render your component dynamically based on the status of the Query. + if (query.isPending) { + return
Loading...
; + } + + if (query.isError) { + return
Error: {query.error.message}
; + } + + // If the Query is successful, you can access the data returned using the `UseQueryResult.data` field. + if (query.isSuccess) { + console.log(query.data.events); + } + return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; +} +``` + # Mutations The React generated SDK provides Mutations hook functions that call and return [`useDataConnectMutation`](https://react-query-firebase.invertase.dev/react/data-connect/mutations) hooks from TanStack Query Firebase. @@ -1016,14 +1309,37 @@ The `CreateEvent` Mutation requires an argument of type `CreateEventVariables`, ```javascript export interface CreateEventVariables { eventName: string; - isRecurring: boolean; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; businessId: UUIDString; + businessName?: string | null; vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; status: EventStatus; date: TimestampString; shifts?: string | null; + addons?: string | null; total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; requested?: number | null; assignedStaff?: string | null; } @@ -1076,20 +1392,43 @@ export default function CreateEventComponent() { // The `useCreateEvent` Mutation requires an argument of type `CreateEventVariables`: const createEventVars: CreateEventVariables = { eventName: ..., - isRecurring: ..., + isRapid: ..., // optional + isRecurring: ..., // optional + isMultiDay: ..., // optional recurrenceType: ..., // optional + recurrenceStartDate: ..., // optional + recurrenceEndDate: ..., // optional + scatterDates: ..., // optional + multiDayStartDate: ..., // optional + multiDayEndDate: ..., // optional + bufferTimeBefore: ..., // optional + bufferTimeAfter: ..., // optional + conflictDetectionEnabled: ..., // optional + detectedConflicts: ..., // optional businessId: ..., + businessName: ..., // optional vendorId: ..., // optional + vendorName: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + poReference: ..., // optional status: ..., date: ..., shifts: ..., // optional + addons: ..., // optional total: ..., // optional + clientName: ..., // optional + clientEmail: ..., // optional + clientPhone: ..., // optional + invoiceId: ..., // optional + notes: ..., // optional requested: ..., // optional assignedStaff: ..., // optional }; mutation.mutate(createEventVars); // Variables can be defined inline as well. - mutation.mutate({ eventName: ..., isRecurring: ..., recurrenceType: ..., businessId: ..., vendorId: ..., status: ..., date: ..., shifts: ..., total: ..., requested: ..., assignedStaff: ..., }); + mutation.mutate({ eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., }); // You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`. const options = { @@ -1114,3 +1453,259 @@ export default function CreateEventComponent() { } ``` +## UpdateEvent +You can execute the `UpdateEvent` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)): +```javascript +useUpdateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` +You can also pass in a `DataConnect` instance to the Mutation hook function. +```javascript +useUpdateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` + +### Variables +The `UpdateEvent` Mutation requires an argument of type `UpdateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface UpdateEventVariables { + id: UUIDString; + eventName?: string | null; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId?: UUIDString | null; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + status?: EventStatus | null; + date?: TimestampString | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; +} +``` +### Return Type +Recall that calling the `UpdateEvent` Mutation hook function returns a `UseMutationResult` object. This object holds the state of your Mutation, including whether the Mutation is loading, has completed, or has succeeded/failed, among other things. + +To check the status of a Mutation, use the `UseMutationResult.status` field. You can also check for pending / success / error status using the `UseMutationResult.isPending`, `UseMutationResult.isSuccess`, and `UseMutationResult.isError` fields. + +To execute the Mutation, call `UseMutationResult.mutate()`. This function executes the Mutation, but does not return the data from the Mutation. + +To access the data returned by a Mutation, use the `UseMutationResult.data` field. The data for the `UpdateEvent` Mutation is of type `UpdateEventData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface UpdateEventData { + event_update?: Event_Key | null; +} +``` + +To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation). + +### Using `UpdateEvent`'s Mutation hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, UpdateEventVariables } from '@dataconnect/generated'; +import { useUpdateEvent } from '@dataconnect/generated/react' + +export default function UpdateEventComponent() { + // Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation. + const mutation = useUpdateEvent(); + + // You can also pass in a `DataConnect` instance to the Mutation hook function. + const dataConnect = getDataConnect(connectorConfig); + const mutation = useUpdateEvent(dataConnect); + + // You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useUpdateEvent(options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectMutationOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useUpdateEvent(dataConnect, options); + + // After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation. + // The `useUpdateEvent` Mutation requires an argument of type `UpdateEventVariables`: + const updateEventVars: UpdateEventVariables = { + id: ..., + eventName: ..., // optional + isRapid: ..., // optional + isRecurring: ..., // optional + isMultiDay: ..., // optional + recurrenceType: ..., // optional + recurrenceStartDate: ..., // optional + recurrenceEndDate: ..., // optional + scatterDates: ..., // optional + multiDayStartDate: ..., // optional + multiDayEndDate: ..., // optional + bufferTimeBefore: ..., // optional + bufferTimeAfter: ..., // optional + conflictDetectionEnabled: ..., // optional + detectedConflicts: ..., // optional + businessId: ..., // optional + businessName: ..., // optional + vendorId: ..., // optional + vendorName: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + poReference: ..., // optional + status: ..., // optional + date: ..., // optional + shifts: ..., // optional + addons: ..., // optional + total: ..., // optional + clientName: ..., // optional + clientEmail: ..., // optional + clientPhone: ..., // optional + invoiceId: ..., // optional + notes: ..., // optional + requested: ..., // optional + assignedStaff: ..., // optional + }; + mutation.mutate(updateEventVars); + // Variables can be defined inline as well. + mutation.mutate({ id: ..., eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., }); + + // You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + mutation.mutate(updateEventVars, options); + + // Then, you can render your component dynamically based on the status of the Mutation. + if (mutation.isPending) { + return
Loading...
; + } + + if (mutation.isError) { + return
Error: {mutation.error.message}
; + } + + // If the Mutation is successful, you can access the data returned using the `UseMutationResult.data` field. + if (mutation.isSuccess) { + console.log(mutation.data.event_update); + } + return
Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## DeleteEvent +You can execute the `DeleteEvent` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)): +```javascript +useDeleteEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` +You can also pass in a `DataConnect` instance to the Mutation hook function. +```javascript +useDeleteEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` + +### Variables +The `DeleteEvent` Mutation requires an argument of type `DeleteEventVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface DeleteEventVariables { + id: UUIDString; +} +``` +### Return Type +Recall that calling the `DeleteEvent` Mutation hook function returns a `UseMutationResult` object. This object holds the state of your Mutation, including whether the Mutation is loading, has completed, or has succeeded/failed, among other things. + +To check the status of a Mutation, use the `UseMutationResult.status` field. You can also check for pending / success / error status using the `UseMutationResult.isPending`, `UseMutationResult.isSuccess`, and `UseMutationResult.isError` fields. + +To execute the Mutation, call `UseMutationResult.mutate()`. This function executes the Mutation, but does not return the data from the Mutation. + +To access the data returned by a Mutation, use the `UseMutationResult.data` field. The data for the `DeleteEvent` Mutation is of type `DeleteEventData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface DeleteEventData { + event_delete?: Event_Key | null; +} +``` + +To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation). + +### Using `DeleteEvent`'s Mutation hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, DeleteEventVariables } from '@dataconnect/generated'; +import { useDeleteEvent } from '@dataconnect/generated/react' + +export default function DeleteEventComponent() { + // Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation. + const mutation = useDeleteEvent(); + + // You can also pass in a `DataConnect` instance to the Mutation hook function. + const dataConnect = getDataConnect(connectorConfig); + const mutation = useDeleteEvent(dataConnect); + + // You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useDeleteEvent(options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectMutationOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useDeleteEvent(dataConnect, options); + + // After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation. + // The `useDeleteEvent` Mutation requires an argument of type `DeleteEventVariables`: + const deleteEventVars: DeleteEventVariables = { + id: ..., + }; + mutation.mutate(deleteEventVars); + // Variables can be defined inline as well. + mutation.mutate({ id: ..., }); + + // You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + mutation.mutate(deleteEventVars, options); + + // Then, you can render your component dynamically based on the status of the Mutation. + if (mutation.isPending) { + return
Loading...
; + } + + if (mutation.isError) { + return
Error: {mutation.error.message}
; + } + + // If the Mutation is successful, you can access the data returned using the `UseMutationResult.data` field. + if (mutation.isSuccess) { + console.log(mutation.data.event_delete); + } + return
Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!
; +} +``` + diff --git a/frontend-web/src/dataconnect-generated/react/esm/index.esm.js b/frontend-web/src/dataconnect-generated/react/esm/index.esm.js index a2bc80c3..ef730402 100644 --- a/frontend-web/src/dataconnect-generated/react/esm/index.esm.js +++ b/frontend-web/src/dataconnect-generated/react/esm/index.esm.js @@ -1,13 +1,7 @@ -import { listEventsRef, createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, connectorConfig } from '../../esm/index.esm.js'; +import { createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, updateEventRef, deleteEventRef, listEventsRef, getEventByIdRef, filterEventsRef, connectorConfig } from '../../esm/index.esm.js'; import { validateArgs, CallerSdkTypeEnum } from 'firebase/data-connect'; import { useDataConnectQuery, useDataConnectMutation, validateReactArgs } from '@tanstack-query-firebase/react/data-connect'; - -export function useListEvents(dcOrOptions, options) { - const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); - const ref = listEventsRef(dcInstance); - return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); -} export function useCreateStaff(dcOrOptions, options) { const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); function refFactory(vars) { @@ -71,3 +65,38 @@ export function useCreateEvent(dcOrOptions, options) { } return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); } + +export function useUpdateEvent(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return updateEventRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +export function useDeleteEvent(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return deleteEventRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + + +export function useListEvents(dcOrOptions, options) { + const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); + const ref = listEventsRef(dcInstance); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +export function useGetEventById(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, true); + const ref = getEventByIdRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +export function useFilterEvents(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, false); + const ref = filterEventsRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} \ No newline at end of file diff --git a/frontend-web/src/dataconnect-generated/react/index.cjs.js b/frontend-web/src/dataconnect-generated/react/index.cjs.js index c3717435..8983af01 100644 --- a/frontend-web/src/dataconnect-generated/react/index.cjs.js +++ b/frontend-web/src/dataconnect-generated/react/index.cjs.js @@ -1,13 +1,7 @@ -const { listEventsRef, createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, connectorConfig } = require('../index.cjs.js'); +const { createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, updateEventRef, deleteEventRef, listEventsRef, getEventByIdRef, filterEventsRef, connectorConfig } = require('../index.cjs.js'); const { validateArgs, CallerSdkTypeEnum } = require('firebase/data-connect'); const { useDataConnectQuery, useDataConnectMutation, validateReactArgs } = require('@tanstack-query-firebase/react/data-connect'); - -exports.useListEvents = function useListEvents(dcOrOptions, options) { - const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); - const ref = listEventsRef(dcInstance); - return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); -} exports.useCreateStaff = function useCreateStaff(dcOrOptions, options) { const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); function refFactory(vars) { @@ -71,3 +65,38 @@ exports.useCreateEvent = function useCreateEvent(dcOrOptions, options) { } return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); } + +exports.useUpdateEvent = function useUpdateEvent(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return updateEventRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +exports.useDeleteEvent = function useDeleteEvent(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return deleteEventRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + + +exports.useListEvents = function useListEvents(dcOrOptions, options) { + const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); + const ref = listEventsRef(dcInstance); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +exports.useGetEventById = function useGetEventById(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, true); + const ref = getEventByIdRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +exports.useFilterEvents = function useFilterEvents(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, false); + const ref = filterEventsRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} \ No newline at end of file diff --git a/frontend-web/src/dataconnect-generated/react/index.d.ts b/frontend-web/src/dataconnect-generated/react/index.d.ts index dd68f1e5..8888c622 100644 --- a/frontend-web/src/dataconnect-generated/react/index.d.ts +++ b/frontend-web/src/dataconnect-generated/react/index.d.ts @@ -1,13 +1,10 @@ -import { ListEventsData, CreateStaffData, CreateStaffVariables, ListStaffData, CreateVendorData, CreateVendorVariables, UpdateVendorData, UpdateVendorVariables, DeleteVendorData, DeleteVendorVariables, ListVendorData, GetVendorByIdData, GetVendorByIdVariables, FilterVendorsData, FilterVendorsVariables, CreateEventData, CreateEventVariables } from '../'; +import { CreateStaffData, CreateStaffVariables, ListStaffData, CreateVendorData, CreateVendorVariables, UpdateVendorData, UpdateVendorVariables, DeleteVendorData, DeleteVendorVariables, ListVendorData, GetVendorByIdData, GetVendorByIdVariables, FilterVendorsData, FilterVendorsVariables, CreateEventData, CreateEventVariables, UpdateEventData, UpdateEventVariables, DeleteEventData, DeleteEventVariables, ListEventsData, GetEventByIdData, GetEventByIdVariables, FilterEventsData, FilterEventsVariables } from '../'; import { UseDataConnectQueryResult, useDataConnectQueryOptions, UseDataConnectMutationResult, useDataConnectMutationOptions} from '@tanstack-query-firebase/react/data-connect'; import { UseQueryResult, UseMutationResult} from '@tanstack/react-query'; import { DataConnect } from 'firebase/data-connect'; import { FirebaseError } from 'firebase/app'; -export function useListEvents(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; -export function useListEvents(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; - export function useCreateStaff(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; export function useCreateStaff(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; @@ -34,3 +31,18 @@ export function useFilterVendors(dc: DataConnect, vars?: FilterVendorsVariables, export function useCreateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; export function useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; + +export function useUpdateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +export function useUpdateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; + +export function useDeleteEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +export function useDeleteEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; + +export function useListEvents(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +export function useListEvents(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; + +export function useGetEventById(vars: GetEventByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +export function useGetEventById(dc: DataConnect, vars: GetEventByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; + +export function useFilterEvents(vars?: FilterEventsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +export function useFilterEvents(dc: DataConnect, vars?: FilterEventsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; diff --git a/internal-api-harness/src/dataconnect-generated/.guides/usage.md b/internal-api-harness/src/dataconnect-generated/.guides/usage.md index 9f12f2ca..d04f7413 100644 --- a/internal-api-harness/src/dataconnect-generated/.guides/usage.md +++ b/internal-api-harness/src/dataconnect-generated/.guides/usage.md @@ -12,11 +12,9 @@ For each operation, there is a wrapper hook that can be used to call the operati Here are all of the hooks that get generated: ```ts -import { useListEvents, useCreateStaff, useListStaff, useCreateVendor, useUpdateVendor, useDeleteVendor, useListVendor, useGetVendorById, useFilterVendors, useCreateEvent } from '@dataconnect/generated/react'; +import { useCreateStaff, useListStaff, useCreateVendor, useUpdateVendor, useDeleteVendor, useListVendor, useGetVendorById, useFilterVendors, useCreateEvent, useUpdateEvent } from '@dataconnect/generated/react'; // The types of these hooks are available in react/index.d.ts -const { data, isPending, isSuccess, isError, error } = useListEvents(); - const { data, isPending, isSuccess, isError, error } = useCreateStaff(createStaffVars); const { data, isPending, isSuccess, isError, error } = useListStaff(); @@ -35,6 +33,8 @@ const { data, isPending, isSuccess, isError, error } = useFilterVendors(filterVe const { data, isPending, isSuccess, isError, error } = useCreateEvent(createEventVars); +const { data, isPending, isSuccess, isError, error } = useUpdateEvent(updateEventVars); + ``` Here's an example from a different generated SDK: @@ -72,12 +72,9 @@ If a user is not using a supported framework, they can use the generated SDK dir Here's an example of how to use it with the first 5 operations: ```js -import { listEvents, createStaff, listStaff, createVendor, updateVendor, deleteVendor, listVendor, getVendorById, filterVendors, createEvent } from '@dataconnect/generated'; +import { createStaff, listStaff, createVendor, updateVendor, deleteVendor, listVendor, getVendorById, filterVendors, createEvent, updateEvent } from '@dataconnect/generated'; -// Operation listEvents: -const { data } = await ListEvents(dataConnect); - // Operation CreateStaff: For variables, look at type CreateStaffVars in ../index.d.ts const { data } = await CreateStaff(dataConnect, createStaffVars); @@ -105,5 +102,8 @@ const { data } = await FilterVendors(dataConnect, filterVendorsVars); // Operation CreateEvent: For variables, look at type CreateEventVars in ../index.d.ts const { data } = await CreateEvent(dataConnect, createEventVars); +// Operation UpdateEvent: For variables, look at type UpdateEventVars in ../index.d.ts +const { data } = await UpdateEvent(dataConnect, updateEventVars); + ``` \ No newline at end of file diff --git a/internal-api-harness/src/dataconnect-generated/README.md b/internal-api-harness/src/dataconnect-generated/README.md index f642ed82..1cfab8f7 100644 --- a/internal-api-harness/src/dataconnect-generated/README.md +++ b/internal-api-harness/src/dataconnect-generated/README.md @@ -10,17 +10,21 @@ This README will guide you through the process of using the generated JavaScript - [**Accessing the connector**](#accessing-the-connector) - [*Connecting to the local Emulator*](#connecting-to-the-local-emulator) - [**Queries**](#queries) - - [*listEvents*](#listevents) - [*listStaff*](#liststaff) - [*listVendor*](#listvendor) - [*getVendorById*](#getvendorbyid) - [*filterVendors*](#filtervendors) + - [*listEvents*](#listevents) + - [*getEventById*](#geteventbyid) + - [*filterEvents*](#filterevents) - [**Mutations**](#mutations) - [*CreateStaff*](#createstaff) - [*CreateVendor*](#createvendor) - [*UpdateVendor*](#updatevendor) - [*DeleteVendor*](#deletevendor) - [*CreateEvent*](#createevent) + - [*UpdateEvent*](#updateevent) + - [*DeleteEvent*](#deleteevent) # Accessing the connector A connector is a collection of Queries and Mutations. One SDK is generated for each connector - this SDK is generated for the connector `krow-connector`. You can find more information about connectors in the [Data Connect documentation](https://firebase.google.com/docs/data-connect#how-does). @@ -67,108 +71,6 @@ The following is true for both the action shortcut function and the `QueryRef` f Below are examples of how to use the `krow-connector` connector's generated functions to execute each query. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#using-queries). -## listEvents -You can execute the `listEvents` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): -```typescript -listEvents(): QueryPromise; - -interface ListEventsRef { - ... - /* Allow users to create refs without passing in DataConnect */ - (): QueryRef; -} -export const listEventsRef: ListEventsRef; -``` -You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. -```typescript -listEvents(dc: DataConnect): QueryPromise; - -interface ListEventsRef { - ... - (dc: DataConnect): QueryRef; -} -export const listEventsRef: ListEventsRef; -``` - -If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the listEventsRef: -```typescript -const name = listEventsRef.operationName; -console.log(name); -``` - -### Variables -The `listEvents` query has no variables. -### Return Type -Recall that executing the `listEvents` query returns a `QueryPromise` that resolves to an object with a `data` property. - -The `data` property is an object of type `ListEventsData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: -```typescript -export interface ListEventsData { - events: ({ - id: UUIDString; - eventName: string; - status: EventStatus; - date: TimestampString; - isRecurring: boolean; - recurrenceType?: RecurrenceType | null; - businessId: UUIDString; - vendorId?: UUIDString | null; - total?: number | null; - requested?: number | null; - } & Event_Key)[]; -} -``` -### Using `listEvents`'s action shortcut function - -```typescript -import { getDataConnect } from 'firebase/data-connect'; -import { connectorConfig, listEvents } from '@dataconnect/generated'; - - -// Call the `listEvents()` function to execute the query. -// You can use the `await` keyword to wait for the promise to resolve. -const { data } = await listEvents(); - -// You can also pass in a `DataConnect` instance to the action shortcut function. -const dataConnect = getDataConnect(connectorConfig); -const { data } = await listEvents(dataConnect); - -console.log(data.events); - -// Or, you can use the `Promise` API. -listEvents().then((response) => { - const data = response.data; - console.log(data.events); -}); -``` - -### Using `listEvents`'s `QueryRef` function - -```typescript -import { getDataConnect, executeQuery } from 'firebase/data-connect'; -import { connectorConfig, listEventsRef } from '@dataconnect/generated'; - - -// Call the `listEventsRef()` function to get a reference to the query. -const ref = listEventsRef(); - -// You can also pass in a `DataConnect` instance to the `QueryRef` function. -const dataConnect = getDataConnect(connectorConfig); -const ref = listEventsRef(dataConnect); - -// Call `executeQuery()` on the reference to execute the query. -// You can use the `await` keyword to wait for the promise to resolve. -const { data } = await executeQuery(ref); - -console.log(data.events); - -// Or, you can use the `Promise` API. -executeQuery(ref).then((response) => { - const data = response.data; - console.log(data.events); -}); -``` - ## listStaff You can execute the `listStaff` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): ```typescript @@ -629,6 +531,460 @@ executeQuery(ref).then((response) => { }); ``` +## listEvents +You can execute the `listEvents` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): +```typescript +listEvents(): QueryPromise; + +interface ListEventsRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (): QueryRef; +} +export const listEventsRef: ListEventsRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```typescript +listEvents(dc: DataConnect): QueryPromise; + +interface ListEventsRef { + ... + (dc: DataConnect): QueryRef; +} +export const listEventsRef: ListEventsRef; +``` + +If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the listEventsRef: +```typescript +const name = listEventsRef.operationName; +console.log(name); +``` + +### Variables +The `listEvents` query has no variables. +### Return Type +Recall that executing the `listEvents` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `ListEventsData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface ListEventsData { + events: ({ + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key)[]; +} +``` +### Using `listEvents`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, listEvents } from '@dataconnect/generated'; + + +// Call the `listEvents()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await listEvents(); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await listEvents(dataConnect); + +console.log(data.events); + +// Or, you can use the `Promise` API. +listEvents().then((response) => { + const data = response.data; + console.log(data.events); +}); +``` + +### Using `listEvents`'s `QueryRef` function + +```typescript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, listEventsRef } from '@dataconnect/generated'; + + +// Call the `listEventsRef()` function to get a reference to the query. +const ref = listEventsRef(); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = listEventsRef(dataConnect); + +// Call `executeQuery()` on the reference to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await executeQuery(ref); + +console.log(data.events); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.events); +}); +``` + +## getEventById +You can execute the `getEventById` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): +```typescript +getEventById(vars: GetEventByIdVariables): QueryPromise; + +interface GetEventByIdRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: GetEventByIdVariables): QueryRef; +} +export const getEventByIdRef: GetEventByIdRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```typescript +getEventById(dc: DataConnect, vars: GetEventByIdVariables): QueryPromise; + +interface GetEventByIdRef { + ... + (dc: DataConnect, vars: GetEventByIdVariables): QueryRef; +} +export const getEventByIdRef: GetEventByIdRef; +``` + +If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the getEventByIdRef: +```typescript +const name = getEventByIdRef.operationName; +console.log(name); +``` + +### Variables +The `getEventById` query requires an argument of type `GetEventByIdVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface GetEventByIdVariables { + id: UUIDString; +} +``` +### Return Type +Recall that executing the `getEventById` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `GetEventByIdData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface GetEventByIdData { + event?: { + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key; +} +``` +### Using `getEventById`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, getEventById, GetEventByIdVariables } from '@dataconnect/generated'; + +// The `getEventById` query requires an argument of type `GetEventByIdVariables`: +const getEventByIdVars: GetEventByIdVariables = { + id: ..., +}; + +// Call the `getEventById()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await getEventById(getEventByIdVars); +// Variables can be defined inline as well. +const { data } = await getEventById({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await getEventById(dataConnect, getEventByIdVars); + +console.log(data.event); + +// Or, you can use the `Promise` API. +getEventById(getEventByIdVars).then((response) => { + const data = response.data; + console.log(data.event); +}); +``` + +### Using `getEventById`'s `QueryRef` function + +```typescript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, getEventByIdRef, GetEventByIdVariables } from '@dataconnect/generated'; + +// The `getEventById` query requires an argument of type `GetEventByIdVariables`: +const getEventByIdVars: GetEventByIdVariables = { + id: ..., +}; + +// Call the `getEventByIdRef()` function to get a reference to the query. +const ref = getEventByIdRef(getEventByIdVars); +// Variables can be defined inline as well. +const ref = getEventByIdRef({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = getEventByIdRef(dataConnect, getEventByIdVars); + +// Call `executeQuery()` on the reference to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await executeQuery(ref); + +console.log(data.event); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.event); +}); +``` + +## filterEvents +You can execute the `filterEvents` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): +```typescript +filterEvents(vars?: FilterEventsVariables): QueryPromise; + +interface FilterEventsRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars?: FilterEventsVariables): QueryRef; +} +export const filterEventsRef: FilterEventsRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```typescript +filterEvents(dc: DataConnect, vars?: FilterEventsVariables): QueryPromise; + +interface FilterEventsRef { + ... + (dc: DataConnect, vars?: FilterEventsVariables): QueryRef; +} +export const filterEventsRef: FilterEventsRef; +``` + +If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the filterEventsRef: +```typescript +const name = filterEventsRef.operationName; +console.log(name); +``` + +### Variables +The `filterEvents` query has an optional argument of type `FilterEventsVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface FilterEventsVariables { + status?: EventStatus | null; + businessId?: UUIDString | null; + vendorId?: UUIDString | null; + isRecurring?: boolean | null; + isRapid?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + date?: TimestampString | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + clientEmail?: string | null; +} +``` +### Return Type +Recall that executing the `filterEvents` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `FilterEventsData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface FilterEventsData { + events: ({ + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key)[]; +} +``` +### Using `filterEvents`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, filterEvents, FilterEventsVariables } from '@dataconnect/generated'; + +// The `filterEvents` query has an optional argument of type `FilterEventsVariables`: +const filterEventsVars: FilterEventsVariables = { + status: ..., // optional + businessId: ..., // optional + vendorId: ..., // optional + isRecurring: ..., // optional + isRapid: ..., // optional + isMultiDay: ..., // optional + recurrenceType: ..., // optional + date: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + clientEmail: ..., // optional +}; + +// Call the `filterEvents()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await filterEvents(filterEventsVars); +// Variables can be defined inline as well. +const { data } = await filterEvents({ status: ..., businessId: ..., vendorId: ..., isRecurring: ..., isRapid: ..., isMultiDay: ..., recurrenceType: ..., date: ..., hub: ..., eventLocation: ..., contractType: ..., clientEmail: ..., }); +// Since all variables are optional for this query, you can omit the `FilterEventsVariables` argument. +const { data } = await filterEvents(); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await filterEvents(dataConnect, filterEventsVars); + +console.log(data.events); + +// Or, you can use the `Promise` API. +filterEvents(filterEventsVars).then((response) => { + const data = response.data; + console.log(data.events); +}); +``` + +### Using `filterEvents`'s `QueryRef` function + +```typescript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, filterEventsRef, FilterEventsVariables } from '@dataconnect/generated'; + +// The `filterEvents` query has an optional argument of type `FilterEventsVariables`: +const filterEventsVars: FilterEventsVariables = { + status: ..., // optional + businessId: ..., // optional + vendorId: ..., // optional + isRecurring: ..., // optional + isRapid: ..., // optional + isMultiDay: ..., // optional + recurrenceType: ..., // optional + date: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + clientEmail: ..., // optional +}; + +// Call the `filterEventsRef()` function to get a reference to the query. +const ref = filterEventsRef(filterEventsVars); +// Variables can be defined inline as well. +const ref = filterEventsRef({ status: ..., businessId: ..., vendorId: ..., isRecurring: ..., isRapid: ..., isMultiDay: ..., recurrenceType: ..., date: ..., hub: ..., eventLocation: ..., contractType: ..., clientEmail: ..., }); +// Since all variables are optional for this query, you can omit the `FilterEventsVariables` argument. +const ref = filterEventsRef(); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = filterEventsRef(dataConnect, filterEventsVars); + +// Call `executeQuery()` on the reference to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await executeQuery(ref); + +console.log(data.events); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.events); +}); +``` + # Mutations There are two ways to execute a Data Connect Mutation using the generated Web SDK: @@ -1178,14 +1534,37 @@ The `CreateEvent` mutation requires an argument of type `CreateEventVariables`, ```typescript export interface CreateEventVariables { eventName: string; - isRecurring: boolean; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; businessId: UUIDString; + businessName?: string | null; vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; status: EventStatus; date: TimestampString; shifts?: string | null; + addons?: string | null; total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; requested?: number | null; assignedStaff?: string | null; } @@ -1208,14 +1587,37 @@ import { connectorConfig, createEvent, CreateEventVariables } from '@dataconnect // The `CreateEvent` mutation requires an argument of type `CreateEventVariables`: const createEventVars: CreateEventVariables = { eventName: ..., - isRecurring: ..., + isRapid: ..., // optional + isRecurring: ..., // optional + isMultiDay: ..., // optional recurrenceType: ..., // optional + recurrenceStartDate: ..., // optional + recurrenceEndDate: ..., // optional + scatterDates: ..., // optional + multiDayStartDate: ..., // optional + multiDayEndDate: ..., // optional + bufferTimeBefore: ..., // optional + bufferTimeAfter: ..., // optional + conflictDetectionEnabled: ..., // optional + detectedConflicts: ..., // optional businessId: ..., + businessName: ..., // optional vendorId: ..., // optional + vendorName: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + poReference: ..., // optional status: ..., date: ..., shifts: ..., // optional + addons: ..., // optional total: ..., // optional + clientName: ..., // optional + clientEmail: ..., // optional + clientPhone: ..., // optional + invoiceId: ..., // optional + notes: ..., // optional requested: ..., // optional assignedStaff: ..., // optional }; @@ -1224,7 +1626,7 @@ const createEventVars: CreateEventVariables = { // You can use the `await` keyword to wait for the promise to resolve. const { data } = await createEvent(createEventVars); // Variables can be defined inline as well. -const { data } = await createEvent({ eventName: ..., isRecurring: ..., recurrenceType: ..., businessId: ..., vendorId: ..., status: ..., date: ..., shifts: ..., total: ..., requested: ..., assignedStaff: ..., }); +const { data } = await createEvent({ eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., }); // You can also pass in a `DataConnect` instance to the action shortcut function. const dataConnect = getDataConnect(connectorConfig); @@ -1248,14 +1650,37 @@ import { connectorConfig, createEventRef, CreateEventVariables } from '@dataconn // The `CreateEvent` mutation requires an argument of type `CreateEventVariables`: const createEventVars: CreateEventVariables = { eventName: ..., - isRecurring: ..., + isRapid: ..., // optional + isRecurring: ..., // optional + isMultiDay: ..., // optional recurrenceType: ..., // optional + recurrenceStartDate: ..., // optional + recurrenceEndDate: ..., // optional + scatterDates: ..., // optional + multiDayStartDate: ..., // optional + multiDayEndDate: ..., // optional + bufferTimeBefore: ..., // optional + bufferTimeAfter: ..., // optional + conflictDetectionEnabled: ..., // optional + detectedConflicts: ..., // optional businessId: ..., + businessName: ..., // optional vendorId: ..., // optional + vendorName: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + poReference: ..., // optional status: ..., date: ..., shifts: ..., // optional + addons: ..., // optional total: ..., // optional + clientName: ..., // optional + clientEmail: ..., // optional + clientPhone: ..., // optional + invoiceId: ..., // optional + notes: ..., // optional requested: ..., // optional assignedStaff: ..., // optional }; @@ -1263,7 +1688,7 @@ const createEventVars: CreateEventVariables = { // Call the `createEventRef()` function to get a reference to the mutation. const ref = createEventRef(createEventVars); // Variables can be defined inline as well. -const ref = createEventRef({ eventName: ..., isRecurring: ..., recurrenceType: ..., businessId: ..., vendorId: ..., status: ..., date: ..., shifts: ..., total: ..., requested: ..., assignedStaff: ..., }); +const ref = createEventRef({ eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., }); // You can also pass in a `DataConnect` instance to the `MutationRef` function. const dataConnect = getDataConnect(connectorConfig); @@ -1282,3 +1707,323 @@ executeMutation(ref).then((response) => { }); ``` +## UpdateEvent +You can execute the `UpdateEvent` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): +```typescript +updateEvent(vars: UpdateEventVariables): MutationPromise; + +interface UpdateEventRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: UpdateEventVariables): MutationRef; +} +export const updateEventRef: UpdateEventRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. +```typescript +updateEvent(dc: DataConnect, vars: UpdateEventVariables): MutationPromise; + +interface UpdateEventRef { + ... + (dc: DataConnect, vars: UpdateEventVariables): MutationRef; +} +export const updateEventRef: UpdateEventRef; +``` + +If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the updateEventRef: +```typescript +const name = updateEventRef.operationName; +console.log(name); +``` + +### Variables +The `UpdateEvent` mutation requires an argument of type `UpdateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface UpdateEventVariables { + id: UUIDString; + eventName?: string | null; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId?: UUIDString | null; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + status?: EventStatus | null; + date?: TimestampString | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; +} +``` +### Return Type +Recall that executing the `UpdateEvent` mutation returns a `MutationPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `UpdateEventData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface UpdateEventData { + event_update?: Event_Key | null; +} +``` +### Using `UpdateEvent`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, updateEvent, UpdateEventVariables } from '@dataconnect/generated'; + +// The `UpdateEvent` mutation requires an argument of type `UpdateEventVariables`: +const updateEventVars: UpdateEventVariables = { + id: ..., + eventName: ..., // optional + isRapid: ..., // optional + isRecurring: ..., // optional + isMultiDay: ..., // optional + recurrenceType: ..., // optional + recurrenceStartDate: ..., // optional + recurrenceEndDate: ..., // optional + scatterDates: ..., // optional + multiDayStartDate: ..., // optional + multiDayEndDate: ..., // optional + bufferTimeBefore: ..., // optional + bufferTimeAfter: ..., // optional + conflictDetectionEnabled: ..., // optional + detectedConflicts: ..., // optional + businessId: ..., // optional + businessName: ..., // optional + vendorId: ..., // optional + vendorName: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + poReference: ..., // optional + status: ..., // optional + date: ..., // optional + shifts: ..., // optional + addons: ..., // optional + total: ..., // optional + clientName: ..., // optional + clientEmail: ..., // optional + clientPhone: ..., // optional + invoiceId: ..., // optional + notes: ..., // optional + requested: ..., // optional + assignedStaff: ..., // optional +}; + +// Call the `updateEvent()` function to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await updateEvent(updateEventVars); +// Variables can be defined inline as well. +const { data } = await updateEvent({ id: ..., eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await updateEvent(dataConnect, updateEventVars); + +console.log(data.event_update); + +// Or, you can use the `Promise` API. +updateEvent(updateEventVars).then((response) => { + const data = response.data; + console.log(data.event_update); +}); +``` + +### Using `UpdateEvent`'s `MutationRef` function + +```typescript +import { getDataConnect, executeMutation } from 'firebase/data-connect'; +import { connectorConfig, updateEventRef, UpdateEventVariables } from '@dataconnect/generated'; + +// The `UpdateEvent` mutation requires an argument of type `UpdateEventVariables`: +const updateEventVars: UpdateEventVariables = { + id: ..., + eventName: ..., // optional + isRapid: ..., // optional + isRecurring: ..., // optional + isMultiDay: ..., // optional + recurrenceType: ..., // optional + recurrenceStartDate: ..., // optional + recurrenceEndDate: ..., // optional + scatterDates: ..., // optional + multiDayStartDate: ..., // optional + multiDayEndDate: ..., // optional + bufferTimeBefore: ..., // optional + bufferTimeAfter: ..., // optional + conflictDetectionEnabled: ..., // optional + detectedConflicts: ..., // optional + businessId: ..., // optional + businessName: ..., // optional + vendorId: ..., // optional + vendorName: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + poReference: ..., // optional + status: ..., // optional + date: ..., // optional + shifts: ..., // optional + addons: ..., // optional + total: ..., // optional + clientName: ..., // optional + clientEmail: ..., // optional + clientPhone: ..., // optional + invoiceId: ..., // optional + notes: ..., // optional + requested: ..., // optional + assignedStaff: ..., // optional +}; + +// Call the `updateEventRef()` function to get a reference to the mutation. +const ref = updateEventRef(updateEventVars); +// Variables can be defined inline as well. +const ref = updateEventRef({ id: ..., eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., }); + +// You can also pass in a `DataConnect` instance to the `MutationRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = updateEventRef(dataConnect, updateEventVars); + +// Call `executeMutation()` on the reference to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await executeMutation(ref); + +console.log(data.event_update); + +// Or, you can use the `Promise` API. +executeMutation(ref).then((response) => { + const data = response.data; + console.log(data.event_update); +}); +``` + +## DeleteEvent +You can execute the `DeleteEvent` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): +```typescript +deleteEvent(vars: DeleteEventVariables): MutationPromise; + +interface DeleteEventRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: DeleteEventVariables): MutationRef; +} +export const deleteEventRef: DeleteEventRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. +```typescript +deleteEvent(dc: DataConnect, vars: DeleteEventVariables): MutationPromise; + +interface DeleteEventRef { + ... + (dc: DataConnect, vars: DeleteEventVariables): MutationRef; +} +export const deleteEventRef: DeleteEventRef; +``` + +If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the deleteEventRef: +```typescript +const name = deleteEventRef.operationName; +console.log(name); +``` + +### Variables +The `DeleteEvent` mutation requires an argument of type `DeleteEventVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface DeleteEventVariables { + id: UUIDString; +} +``` +### Return Type +Recall that executing the `DeleteEvent` mutation returns a `MutationPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `DeleteEventData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface DeleteEventData { + event_delete?: Event_Key | null; +} +``` +### Using `DeleteEvent`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, deleteEvent, DeleteEventVariables } from '@dataconnect/generated'; + +// The `DeleteEvent` mutation requires an argument of type `DeleteEventVariables`: +const deleteEventVars: DeleteEventVariables = { + id: ..., +}; + +// Call the `deleteEvent()` function to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await deleteEvent(deleteEventVars); +// Variables can be defined inline as well. +const { data } = await deleteEvent({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await deleteEvent(dataConnect, deleteEventVars); + +console.log(data.event_delete); + +// Or, you can use the `Promise` API. +deleteEvent(deleteEventVars).then((response) => { + const data = response.data; + console.log(data.event_delete); +}); +``` + +### Using `DeleteEvent`'s `MutationRef` function + +```typescript +import { getDataConnect, executeMutation } from 'firebase/data-connect'; +import { connectorConfig, deleteEventRef, DeleteEventVariables } from '@dataconnect/generated'; + +// The `DeleteEvent` mutation requires an argument of type `DeleteEventVariables`: +const deleteEventVars: DeleteEventVariables = { + id: ..., +}; + +// Call the `deleteEventRef()` function to get a reference to the mutation. +const ref = deleteEventRef(deleteEventVars); +// Variables can be defined inline as well. +const ref = deleteEventRef({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the `MutationRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = deleteEventRef(dataConnect, deleteEventVars); + +// Call `executeMutation()` on the reference to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await executeMutation(ref); + +console.log(data.event_delete); + +// Or, you can use the `Promise` API. +executeMutation(ref).then((response) => { + const data = response.data; + console.log(data.event_delete); +}); +``` + diff --git a/internal-api-harness/src/dataconnect-generated/esm/index.esm.js b/internal-api-harness/src/dataconnect-generated/esm/index.esm.js index 5a6db9e0..3973bccc 100644 --- a/internal-api-harness/src/dataconnect-generated/esm/index.esm.js +++ b/internal-api-harness/src/dataconnect-generated/esm/index.esm.js @@ -7,6 +7,13 @@ export const BackgroundCheckStatus = { EXPIRED: "EXPIRED", } +export const ContractType = { + W2: "W2", + C1099: "C1099", + TEMP: "TEMP", + CONTRACT: "CONTRACT", +} + export const EmploymentType = { FULL_TIME: "FULL_TIME", PART_TIME: "PART_TIME", @@ -61,17 +68,6 @@ export const connectorConfig = { location: 'us-central1' }; -export const listEventsRef = (dc) => { - const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); - dcInstance._useGeneratedSdk(); - return queryRef(dcInstance, 'listEvents'); -} -listEventsRef.operationName = 'listEvents'; - -export function listEvents(dc) { - return executeQuery(listEventsRef(dc)); -} - export const createStaffRef = (dcOrVars, vars) => { const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); dcInstance._useGeneratedSdk(); @@ -171,3 +167,58 @@ export function createEvent(dcOrVars, vars) { return executeMutation(createEventRef(dcOrVars, vars)); } +export const updateEventRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'UpdateEvent', inputVars); +} +updateEventRef.operationName = 'UpdateEvent'; + +export function updateEvent(dcOrVars, vars) { + return executeMutation(updateEventRef(dcOrVars, vars)); +} + +export const deleteEventRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'DeleteEvent', inputVars); +} +deleteEventRef.operationName = 'DeleteEvent'; + +export function deleteEvent(dcOrVars, vars) { + return executeMutation(deleteEventRef(dcOrVars, vars)); +} + +export const listEventsRef = (dc) => { + const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'listEvents'); +} +listEventsRef.operationName = 'listEvents'; + +export function listEvents(dc) { + return executeQuery(listEventsRef(dc)); +} + +export const getEventByIdRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'getEventById', inputVars); +} +getEventByIdRef.operationName = 'getEventById'; + +export function getEventById(dcOrVars, vars) { + return executeQuery(getEventByIdRef(dcOrVars, vars)); +} + +export const filterEventsRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'filterEvents', inputVars); +} +filterEventsRef.operationName = 'filterEvents'; + +export function filterEvents(dcOrVars, vars) { + return executeQuery(filterEventsRef(dcOrVars, vars)); +} + diff --git a/internal-api-harness/src/dataconnect-generated/index.cjs.js b/internal-api-harness/src/dataconnect-generated/index.cjs.js index 1aaa1719..c566e227 100644 --- a/internal-api-harness/src/dataconnect-generated/index.cjs.js +++ b/internal-api-harness/src/dataconnect-generated/index.cjs.js @@ -8,6 +8,14 @@ const BackgroundCheckStatus = { } exports.BackgroundCheckStatus = BackgroundCheckStatus; +const ContractType = { + W2: "W2", + C1099: "C1099", + TEMP: "TEMP", + CONTRACT: "CONTRACT", +} +exports.ContractType = ContractType; + const EmploymentType = { FULL_TIME: "FULL_TIME", PART_TIME: "PART_TIME", @@ -69,18 +77,6 @@ const connectorConfig = { }; exports.connectorConfig = connectorConfig; -const listEventsRef = (dc) => { - const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); - dcInstance._useGeneratedSdk(); - return queryRef(dcInstance, 'listEvents'); -} -listEventsRef.operationName = 'listEvents'; -exports.listEventsRef = listEventsRef; - -exports.listEvents = function listEvents(dc) { - return executeQuery(listEventsRef(dc)); -}; - const createStaffRef = (dcOrVars, vars) => { const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); dcInstance._useGeneratedSdk(); @@ -188,3 +184,63 @@ exports.createEventRef = createEventRef; exports.createEvent = function createEvent(dcOrVars, vars) { return executeMutation(createEventRef(dcOrVars, vars)); }; + +const updateEventRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'UpdateEvent', inputVars); +} +updateEventRef.operationName = 'UpdateEvent'; +exports.updateEventRef = updateEventRef; + +exports.updateEvent = function updateEvent(dcOrVars, vars) { + return executeMutation(updateEventRef(dcOrVars, vars)); +}; + +const deleteEventRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'DeleteEvent', inputVars); +} +deleteEventRef.operationName = 'DeleteEvent'; +exports.deleteEventRef = deleteEventRef; + +exports.deleteEvent = function deleteEvent(dcOrVars, vars) { + return executeMutation(deleteEventRef(dcOrVars, vars)); +}; + +const listEventsRef = (dc) => { + const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'listEvents'); +} +listEventsRef.operationName = 'listEvents'; +exports.listEventsRef = listEventsRef; + +exports.listEvents = function listEvents(dc) { + return executeQuery(listEventsRef(dc)); +}; + +const getEventByIdRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'getEventById', inputVars); +} +getEventByIdRef.operationName = 'getEventById'; +exports.getEventByIdRef = getEventByIdRef; + +exports.getEventById = function getEventById(dcOrVars, vars) { + return executeQuery(getEventByIdRef(dcOrVars, vars)); +}; + +const filterEventsRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'filterEvents', inputVars); +} +filterEventsRef.operationName = 'filterEvents'; +exports.filterEventsRef = filterEventsRef; + +exports.filterEvents = function filterEvents(dcOrVars, vars) { + return executeQuery(filterEventsRef(dcOrVars, vars)); +}; diff --git a/internal-api-harness/src/dataconnect-generated/index.d.ts b/internal-api-harness/src/dataconnect-generated/index.d.ts index 4013e843..5d228d71 100644 --- a/internal-api-harness/src/dataconnect-generated/index.d.ts +++ b/internal-api-harness/src/dataconnect-generated/index.d.ts @@ -15,6 +15,13 @@ export enum BackgroundCheckStatus { EXPIRED = "EXPIRED", }; +export enum ContractType { + W2 = "W2", + C1099 = "C1099", + TEMP = "TEMP", + CONTRACT = "CONTRACT", +}; + export enum EmploymentType { FULL_TIME = "FULL_TIME", PART_TIME = "PART_TIME", @@ -71,14 +78,37 @@ export interface CreateEventData { export interface CreateEventVariables { eventName: string; - isRecurring: boolean; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; businessId: UUIDString; + businessName?: string | null; vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; status: EventStatus; date: TimestampString; shifts?: string | null; + addons?: string | null; total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; requested?: number | null; assignedStaff?: string | null; } @@ -113,6 +143,14 @@ export interface CreateVendorVariables { isActive?: boolean | null; } +export interface DeleteEventData { + event_delete?: Event_Key | null; +} + +export interface DeleteEventVariables { + id: UUIDString; +} + export interface DeleteVendorData { vendor_delete?: Vendor_Key | null; } @@ -126,6 +164,61 @@ export interface Event_Key { __typename?: 'Event_Key'; } +export interface FilterEventsData { + events: ({ + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key)[]; +} + +export interface FilterEventsVariables { + status?: EventStatus | null; + businessId?: UUIDString | null; + vendorId?: UUIDString | null; + isRecurring?: boolean | null; + isRapid?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + date?: TimestampString | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + clientEmail?: string | null; +} + export interface FilterVendorsData { vendors: ({ id: UUIDString; @@ -149,6 +242,50 @@ export interface FilterVendorsVariables { platformType?: VendorPlatformType | null; } +export interface GetEventByIdData { + event?: { + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key; +} + +export interface GetEventByIdVariables { + id: UUIDString; +} + export interface GetVendorByIdData { vendor?: { id: UUIDString; @@ -172,12 +309,37 @@ export interface ListEventsData { eventName: string; status: EventStatus; date: TimestampString; - isRecurring: boolean; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; businessId: UUIDString; + businessName?: string | null; vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; requested?: number | null; + assignedStaff?: string | null; } & Event_Key)[]; } @@ -214,6 +376,48 @@ export interface Staff_Key { __typename?: 'Staff_Key'; } +export interface UpdateEventData { + event_update?: Event_Key | null; +} + +export interface UpdateEventVariables { + id: UUIDString; + eventName?: string | null; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId?: UUIDString | null; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + status?: EventStatus | null; + date?: TimestampString | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; +} + export interface UpdateVendorData { vendor_update?: Vendor_Key | null; } @@ -234,18 +438,6 @@ export interface Vendor_Key { __typename?: 'Vendor_Key'; } -interface ListEventsRef { - /* Allow users to create refs without passing in DataConnect */ - (): QueryRef; - /* Allow users to pass in custom DataConnect instances */ - (dc: DataConnect): QueryRef; - operationName: string; -} -export const listEventsRef: ListEventsRef; - -export function listEvents(): QueryPromise; -export function listEvents(dc: DataConnect): QueryPromise; - interface CreateStaffRef { /* Allow users to create refs without passing in DataConnect */ (vars: CreateStaffVariables): MutationRef; @@ -354,3 +546,63 @@ export const createEventRef: CreateEventRef; export function createEvent(vars: CreateEventVariables): MutationPromise; export function createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise; +interface UpdateEventRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: UpdateEventVariables): MutationRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: UpdateEventVariables): MutationRef; + operationName: string; +} +export const updateEventRef: UpdateEventRef; + +export function updateEvent(vars: UpdateEventVariables): MutationPromise; +export function updateEvent(dc: DataConnect, vars: UpdateEventVariables): MutationPromise; + +interface DeleteEventRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: DeleteEventVariables): MutationRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: DeleteEventVariables): MutationRef; + operationName: string; +} +export const deleteEventRef: DeleteEventRef; + +export function deleteEvent(vars: DeleteEventVariables): MutationPromise; +export function deleteEvent(dc: DataConnect, vars: DeleteEventVariables): MutationPromise; + +interface ListEventsRef { + /* Allow users to create refs without passing in DataConnect */ + (): QueryRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect): QueryRef; + operationName: string; +} +export const listEventsRef: ListEventsRef; + +export function listEvents(): QueryPromise; +export function listEvents(dc: DataConnect): QueryPromise; + +interface GetEventByIdRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: GetEventByIdVariables): QueryRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: GetEventByIdVariables): QueryRef; + operationName: string; +} +export const getEventByIdRef: GetEventByIdRef; + +export function getEventById(vars: GetEventByIdVariables): QueryPromise; +export function getEventById(dc: DataConnect, vars: GetEventByIdVariables): QueryPromise; + +interface FilterEventsRef { + /* Allow users to create refs without passing in DataConnect */ + (vars?: FilterEventsVariables): QueryRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars?: FilterEventsVariables): QueryRef; + operationName: string; +} +export const filterEventsRef: FilterEventsRef; + +export function filterEvents(vars?: FilterEventsVariables): QueryPromise; +export function filterEvents(dc: DataConnect, vars?: FilterEventsVariables): QueryPromise; + diff --git a/internal-api-harness/src/dataconnect-generated/react/README.md b/internal-api-harness/src/dataconnect-generated/react/README.md index 694d71dc..dd87a50d 100644 --- a/internal-api-harness/src/dataconnect-generated/react/README.md +++ b/internal-api-harness/src/dataconnect-generated/react/README.md @@ -17,17 +17,21 @@ You can also follow the instructions from the [Data Connect documentation](https - [**Accessing the connector**](#accessing-the-connector) - [*Connecting to the local Emulator*](#connecting-to-the-local-emulator) - [**Queries**](#queries) - - [*listEvents*](#listevents) - [*listStaff*](#liststaff) - [*listVendor*](#listvendor) - [*getVendorById*](#getvendorbyid) - [*filterVendors*](#filtervendors) + - [*listEvents*](#listevents) + - [*getEventById*](#geteventbyid) + - [*filterEvents*](#filterevents) - [**Mutations**](#mutations) - [*CreateStaff*](#createstaff) - [*CreateVendor*](#createvendor) - [*UpdateVendor*](#updatevendor) - [*DeleteVendor*](#deletevendor) - [*CreateEvent*](#createevent) + - [*UpdateEvent*](#updateevent) + - [*DeleteEvent*](#deleteevent) # TanStack Query Firebase & TanStack React Query This SDK provides [React](https://react.dev/) hooks generated specific to your application, for the operations found in the connector `krow-connector`. These hooks are generated using [TanStack Query Firebase](https://react-query-firebase.invertase.dev/) by our partners at Invertase, a library built on top of [TanStack React Query v5](https://tanstack.com/query/v5/docs/framework/react/overview). @@ -119,86 +123,6 @@ Here's a general overview of how to use the generated Query hooks in your code: Below are examples of how to use the `krow-connector` connector's generated Query hook functions to execute each Query. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#operations-react-angular). -## listEvents -You can execute the `listEvents` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): - -```javascript -useListEvents(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; -``` -You can also pass in a `DataConnect` instance to the Query hook function. -```javascript -useListEvents(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; -``` - -### Variables -The `listEvents` Query has no variables. -### Return Type -Recall that calling the `listEvents` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things. - -To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields. - -To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `listEvents` Query is of type `ListEventsData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: -```javascript -export interface ListEventsData { - events: ({ - id: UUIDString; - eventName: string; - status: EventStatus; - date: TimestampString; - isRecurring: boolean; - recurrenceType?: RecurrenceType | null; - businessId: UUIDString; - vendorId?: UUIDString | null; - total?: number | null; - requested?: number | null; - } & Event_Key)[]; -} -``` - -To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery). - -### Using `listEvents`'s Query hook function - -```javascript -import { getDataConnect } from 'firebase/data-connect'; -import { connectorConfig } from '@dataconnect/generated'; -import { useListEvents } from '@dataconnect/generated/react' - -export default function ListEventsComponent() { - // You don't have to do anything to "execute" the Query. - // Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query. - const query = useListEvents(); - - // You can also pass in a `DataConnect` instance to the Query hook function. - const dataConnect = getDataConnect(connectorConfig); - const query = useListEvents(dataConnect); - - // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. - const options = { staleTime: 5 * 1000 }; - const query = useListEvents(options); - - // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. - const dataConnect = getDataConnect(connectorConfig); - const options = { staleTime: 5 * 1000 }; - const query = useListEvents(dataConnect, options); - - // Then, you can render your component dynamically based on the status of the Query. - if (query.isPending) { - return
Loading...
; - } - - if (query.isError) { - return
Error: {query.error.message}
; - } - - // If the Query is successful, you can access the data returned using the `UseQueryResult.data` field. - if (query.isSuccess) { - console.log(query.data.events); - } - return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; -} -``` - ## listStaff You can execute the `listStaff` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): @@ -557,6 +481,375 @@ export default function FilterVendorsComponent() { } ``` +## listEvents +You can execute the `listEvents` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): + +```javascript +useListEvents(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` +You can also pass in a `DataConnect` instance to the Query hook function. +```javascript +useListEvents(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` + +### Variables +The `listEvents` Query has no variables. +### Return Type +Recall that calling the `listEvents` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things. + +To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields. + +To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `listEvents` Query is of type `ListEventsData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface ListEventsData { + events: ({ + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key)[]; +} +``` + +To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery). + +### Using `listEvents`'s Query hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig } from '@dataconnect/generated'; +import { useListEvents } from '@dataconnect/generated/react' + +export default function ListEventsComponent() { + // You don't have to do anything to "execute" the Query. + // Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query. + const query = useListEvents(); + + // You can also pass in a `DataConnect` instance to the Query hook function. + const dataConnect = getDataConnect(connectorConfig); + const query = useListEvents(dataConnect); + + // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. + const options = { staleTime: 5 * 1000 }; + const query = useListEvents(options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { staleTime: 5 * 1000 }; + const query = useListEvents(dataConnect, options); + + // Then, you can render your component dynamically based on the status of the Query. + if (query.isPending) { + return
Loading...
; + } + + if (query.isError) { + return
Error: {query.error.message}
; + } + + // If the Query is successful, you can access the data returned using the `UseQueryResult.data` field. + if (query.isSuccess) { + console.log(query.data.events); + } + return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## getEventById +You can execute the `getEventById` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): + +```javascript +useGetEventById(dc: DataConnect, vars: GetEventByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` +You can also pass in a `DataConnect` instance to the Query hook function. +```javascript +useGetEventById(vars: GetEventByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` + +### Variables +The `getEventById` Query requires an argument of type `GetEventByIdVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface GetEventByIdVariables { + id: UUIDString; +} +``` +### Return Type +Recall that calling the `getEventById` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things. + +To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields. + +To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `getEventById` Query is of type `GetEventByIdData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface GetEventByIdData { + event?: { + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key; +} +``` + +To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery). + +### Using `getEventById`'s Query hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, GetEventByIdVariables } from '@dataconnect/generated'; +import { useGetEventById } from '@dataconnect/generated/react' + +export default function GetEventByIdComponent() { + // The `useGetEventById` Query hook requires an argument of type `GetEventByIdVariables`: + const getEventByIdVars: GetEventByIdVariables = { + id: ..., + }; + + // You don't have to do anything to "execute" the Query. + // Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query. + const query = useGetEventById(getEventByIdVars); + // Variables can be defined inline as well. + const query = useGetEventById({ id: ..., }); + + // You can also pass in a `DataConnect` instance to the Query hook function. + const dataConnect = getDataConnect(connectorConfig); + const query = useGetEventById(dataConnect, getEventByIdVars); + + // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. + const options = { staleTime: 5 * 1000 }; + const query = useGetEventById(getEventByIdVars, options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { staleTime: 5 * 1000 }; + const query = useGetEventById(dataConnect, getEventByIdVars, options); + + // Then, you can render your component dynamically based on the status of the Query. + if (query.isPending) { + return
Loading...
; + } + + if (query.isError) { + return
Error: {query.error.message}
; + } + + // If the Query is successful, you can access the data returned using the `UseQueryResult.data` field. + if (query.isSuccess) { + console.log(query.data.event); + } + return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## filterEvents +You can execute the `filterEvents` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): + +```javascript +useFilterEvents(dc: DataConnect, vars?: FilterEventsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` +You can also pass in a `DataConnect` instance to the Query hook function. +```javascript +useFilterEvents(vars?: FilterEventsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` + +### Variables +The `filterEvents` Query has an optional argument of type `FilterEventsVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface FilterEventsVariables { + status?: EventStatus | null; + businessId?: UUIDString | null; + vendorId?: UUIDString | null; + isRecurring?: boolean | null; + isRapid?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + date?: TimestampString | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + clientEmail?: string | null; +} +``` +### Return Type +Recall that calling the `filterEvents` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things. + +To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields. + +To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `filterEvents` Query is of type `FilterEventsData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface FilterEventsData { + events: ({ + id: UUIDString; + eventName: string; + status: EventStatus; + date: TimestampString; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId: UUIDString; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; + } & Event_Key)[]; +} +``` + +To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery). + +### Using `filterEvents`'s Query hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, FilterEventsVariables } from '@dataconnect/generated'; +import { useFilterEvents } from '@dataconnect/generated/react' + +export default function FilterEventsComponent() { + // The `useFilterEvents` Query hook has an optional argument of type `FilterEventsVariables`: + const filterEventsVars: FilterEventsVariables = { + status: ..., // optional + businessId: ..., // optional + vendorId: ..., // optional + isRecurring: ..., // optional + isRapid: ..., // optional + isMultiDay: ..., // optional + recurrenceType: ..., // optional + date: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + clientEmail: ..., // optional + }; + + // You don't have to do anything to "execute" the Query. + // Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query. + const query = useFilterEvents(filterEventsVars); + // Variables can be defined inline as well. + const query = useFilterEvents({ status: ..., businessId: ..., vendorId: ..., isRecurring: ..., isRapid: ..., isMultiDay: ..., recurrenceType: ..., date: ..., hub: ..., eventLocation: ..., contractType: ..., clientEmail: ..., }); + // Since all variables are optional for this Query, you can omit the `FilterEventsVariables` argument. + // (as long as you don't want to provide any `options`!) + const query = useFilterEvents(); + + // You can also pass in a `DataConnect` instance to the Query hook function. + const dataConnect = getDataConnect(connectorConfig); + const query = useFilterEvents(dataConnect, filterEventsVars); + + // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. + const options = { staleTime: 5 * 1000 }; + const query = useFilterEvents(filterEventsVars, options); + // If you'd like to provide options without providing any variables, you must + // pass `undefined` where you would normally pass the variables. + const query = useFilterEvents(undefined, options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { staleTime: 5 * 1000 }; + const query = useFilterEvents(dataConnect, filterEventsVars /** or undefined */, options); + + // Then, you can render your component dynamically based on the status of the Query. + if (query.isPending) { + return
Loading...
; + } + + if (query.isError) { + return
Error: {query.error.message}
; + } + + // If the Query is successful, you can access the data returned using the `UseQueryResult.data` field. + if (query.isSuccess) { + console.log(query.data.events); + } + return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; +} +``` + # Mutations The React generated SDK provides Mutations hook functions that call and return [`useDataConnectMutation`](https://react-query-firebase.invertase.dev/react/data-connect/mutations) hooks from TanStack Query Firebase. @@ -1016,14 +1309,37 @@ The `CreateEvent` Mutation requires an argument of type `CreateEventVariables`, ```javascript export interface CreateEventVariables { eventName: string; - isRecurring: boolean; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; businessId: UUIDString; + businessName?: string | null; vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; status: EventStatus; date: TimestampString; shifts?: string | null; + addons?: string | null; total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; requested?: number | null; assignedStaff?: string | null; } @@ -1076,20 +1392,43 @@ export default function CreateEventComponent() { // The `useCreateEvent` Mutation requires an argument of type `CreateEventVariables`: const createEventVars: CreateEventVariables = { eventName: ..., - isRecurring: ..., + isRapid: ..., // optional + isRecurring: ..., // optional + isMultiDay: ..., // optional recurrenceType: ..., // optional + recurrenceStartDate: ..., // optional + recurrenceEndDate: ..., // optional + scatterDates: ..., // optional + multiDayStartDate: ..., // optional + multiDayEndDate: ..., // optional + bufferTimeBefore: ..., // optional + bufferTimeAfter: ..., // optional + conflictDetectionEnabled: ..., // optional + detectedConflicts: ..., // optional businessId: ..., + businessName: ..., // optional vendorId: ..., // optional + vendorName: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + poReference: ..., // optional status: ..., date: ..., shifts: ..., // optional + addons: ..., // optional total: ..., // optional + clientName: ..., // optional + clientEmail: ..., // optional + clientPhone: ..., // optional + invoiceId: ..., // optional + notes: ..., // optional requested: ..., // optional assignedStaff: ..., // optional }; mutation.mutate(createEventVars); // Variables can be defined inline as well. - mutation.mutate({ eventName: ..., isRecurring: ..., recurrenceType: ..., businessId: ..., vendorId: ..., status: ..., date: ..., shifts: ..., total: ..., requested: ..., assignedStaff: ..., }); + mutation.mutate({ eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., }); // You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`. const options = { @@ -1114,3 +1453,259 @@ export default function CreateEventComponent() { } ``` +## UpdateEvent +You can execute the `UpdateEvent` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)): +```javascript +useUpdateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` +You can also pass in a `DataConnect` instance to the Mutation hook function. +```javascript +useUpdateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` + +### Variables +The `UpdateEvent` Mutation requires an argument of type `UpdateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface UpdateEventVariables { + id: UUIDString; + eventName?: string | null; + isRapid?: boolean | null; + isRecurring?: boolean | null; + isMultiDay?: boolean | null; + recurrenceType?: RecurrenceType | null; + recurrenceStartDate?: TimestampString | null; + recurrenceEndDate?: TimestampString | null; + scatterDates?: string | null; + multiDayStartDate?: TimestampString | null; + multiDayEndDate?: TimestampString | null; + bufferTimeBefore?: number | null; + bufferTimeAfter?: number | null; + conflictDetectionEnabled?: boolean | null; + detectedConflicts?: string | null; + businessId?: UUIDString | null; + businessName?: string | null; + vendorId?: UUIDString | null; + vendorName?: string | null; + hub?: string | null; + eventLocation?: string | null; + contractType?: ContractType | null; + poReference?: string | null; + status?: EventStatus | null; + date?: TimestampString | null; + shifts?: string | null; + addons?: string | null; + total?: number | null; + clientName?: string | null; + clientEmail?: string | null; + clientPhone?: string | null; + invoiceId?: UUIDString | null; + notes?: string | null; + requested?: number | null; + assignedStaff?: string | null; +} +``` +### Return Type +Recall that calling the `UpdateEvent` Mutation hook function returns a `UseMutationResult` object. This object holds the state of your Mutation, including whether the Mutation is loading, has completed, or has succeeded/failed, among other things. + +To check the status of a Mutation, use the `UseMutationResult.status` field. You can also check for pending / success / error status using the `UseMutationResult.isPending`, `UseMutationResult.isSuccess`, and `UseMutationResult.isError` fields. + +To execute the Mutation, call `UseMutationResult.mutate()`. This function executes the Mutation, but does not return the data from the Mutation. + +To access the data returned by a Mutation, use the `UseMutationResult.data` field. The data for the `UpdateEvent` Mutation is of type `UpdateEventData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface UpdateEventData { + event_update?: Event_Key | null; +} +``` + +To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation). + +### Using `UpdateEvent`'s Mutation hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, UpdateEventVariables } from '@dataconnect/generated'; +import { useUpdateEvent } from '@dataconnect/generated/react' + +export default function UpdateEventComponent() { + // Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation. + const mutation = useUpdateEvent(); + + // You can also pass in a `DataConnect` instance to the Mutation hook function. + const dataConnect = getDataConnect(connectorConfig); + const mutation = useUpdateEvent(dataConnect); + + // You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useUpdateEvent(options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectMutationOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useUpdateEvent(dataConnect, options); + + // After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation. + // The `useUpdateEvent` Mutation requires an argument of type `UpdateEventVariables`: + const updateEventVars: UpdateEventVariables = { + id: ..., + eventName: ..., // optional + isRapid: ..., // optional + isRecurring: ..., // optional + isMultiDay: ..., // optional + recurrenceType: ..., // optional + recurrenceStartDate: ..., // optional + recurrenceEndDate: ..., // optional + scatterDates: ..., // optional + multiDayStartDate: ..., // optional + multiDayEndDate: ..., // optional + bufferTimeBefore: ..., // optional + bufferTimeAfter: ..., // optional + conflictDetectionEnabled: ..., // optional + detectedConflicts: ..., // optional + businessId: ..., // optional + businessName: ..., // optional + vendorId: ..., // optional + vendorName: ..., // optional + hub: ..., // optional + eventLocation: ..., // optional + contractType: ..., // optional + poReference: ..., // optional + status: ..., // optional + date: ..., // optional + shifts: ..., // optional + addons: ..., // optional + total: ..., // optional + clientName: ..., // optional + clientEmail: ..., // optional + clientPhone: ..., // optional + invoiceId: ..., // optional + notes: ..., // optional + requested: ..., // optional + assignedStaff: ..., // optional + }; + mutation.mutate(updateEventVars); + // Variables can be defined inline as well. + mutation.mutate({ id: ..., eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., }); + + // You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + mutation.mutate(updateEventVars, options); + + // Then, you can render your component dynamically based on the status of the Mutation. + if (mutation.isPending) { + return
Loading...
; + } + + if (mutation.isError) { + return
Error: {mutation.error.message}
; + } + + // If the Mutation is successful, you can access the data returned using the `UseMutationResult.data` field. + if (mutation.isSuccess) { + console.log(mutation.data.event_update); + } + return
Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## DeleteEvent +You can execute the `DeleteEvent` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)): +```javascript +useDeleteEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` +You can also pass in a `DataConnect` instance to the Mutation hook function. +```javascript +useDeleteEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` + +### Variables +The `DeleteEvent` Mutation requires an argument of type `DeleteEventVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface DeleteEventVariables { + id: UUIDString; +} +``` +### Return Type +Recall that calling the `DeleteEvent` Mutation hook function returns a `UseMutationResult` object. This object holds the state of your Mutation, including whether the Mutation is loading, has completed, or has succeeded/failed, among other things. + +To check the status of a Mutation, use the `UseMutationResult.status` field. You can also check for pending / success / error status using the `UseMutationResult.isPending`, `UseMutationResult.isSuccess`, and `UseMutationResult.isError` fields. + +To execute the Mutation, call `UseMutationResult.mutate()`. This function executes the Mutation, but does not return the data from the Mutation. + +To access the data returned by a Mutation, use the `UseMutationResult.data` field. The data for the `DeleteEvent` Mutation is of type `DeleteEventData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface DeleteEventData { + event_delete?: Event_Key | null; +} +``` + +To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation). + +### Using `DeleteEvent`'s Mutation hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, DeleteEventVariables } from '@dataconnect/generated'; +import { useDeleteEvent } from '@dataconnect/generated/react' + +export default function DeleteEventComponent() { + // Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation. + const mutation = useDeleteEvent(); + + // You can also pass in a `DataConnect` instance to the Mutation hook function. + const dataConnect = getDataConnect(connectorConfig); + const mutation = useDeleteEvent(dataConnect); + + // You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useDeleteEvent(options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectMutationOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useDeleteEvent(dataConnect, options); + + // After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation. + // The `useDeleteEvent` Mutation requires an argument of type `DeleteEventVariables`: + const deleteEventVars: DeleteEventVariables = { + id: ..., + }; + mutation.mutate(deleteEventVars); + // Variables can be defined inline as well. + mutation.mutate({ id: ..., }); + + // You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + mutation.mutate(deleteEventVars, options); + + // Then, you can render your component dynamically based on the status of the Mutation. + if (mutation.isPending) { + return
Loading...
; + } + + if (mutation.isError) { + return
Error: {mutation.error.message}
; + } + + // If the Mutation is successful, you can access the data returned using the `UseMutationResult.data` field. + if (mutation.isSuccess) { + console.log(mutation.data.event_delete); + } + return
Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!
; +} +``` + diff --git a/internal-api-harness/src/dataconnect-generated/react/esm/index.esm.js b/internal-api-harness/src/dataconnect-generated/react/esm/index.esm.js index a2bc80c3..ef730402 100644 --- a/internal-api-harness/src/dataconnect-generated/react/esm/index.esm.js +++ b/internal-api-harness/src/dataconnect-generated/react/esm/index.esm.js @@ -1,13 +1,7 @@ -import { listEventsRef, createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, connectorConfig } from '../../esm/index.esm.js'; +import { createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, updateEventRef, deleteEventRef, listEventsRef, getEventByIdRef, filterEventsRef, connectorConfig } from '../../esm/index.esm.js'; import { validateArgs, CallerSdkTypeEnum } from 'firebase/data-connect'; import { useDataConnectQuery, useDataConnectMutation, validateReactArgs } from '@tanstack-query-firebase/react/data-connect'; - -export function useListEvents(dcOrOptions, options) { - const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); - const ref = listEventsRef(dcInstance); - return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); -} export function useCreateStaff(dcOrOptions, options) { const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); function refFactory(vars) { @@ -71,3 +65,38 @@ export function useCreateEvent(dcOrOptions, options) { } return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); } + +export function useUpdateEvent(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return updateEventRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +export function useDeleteEvent(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return deleteEventRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + + +export function useListEvents(dcOrOptions, options) { + const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); + const ref = listEventsRef(dcInstance); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +export function useGetEventById(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, true); + const ref = getEventByIdRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +export function useFilterEvents(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, false); + const ref = filterEventsRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} \ No newline at end of file diff --git a/internal-api-harness/src/dataconnect-generated/react/index.cjs.js b/internal-api-harness/src/dataconnect-generated/react/index.cjs.js index c3717435..8983af01 100644 --- a/internal-api-harness/src/dataconnect-generated/react/index.cjs.js +++ b/internal-api-harness/src/dataconnect-generated/react/index.cjs.js @@ -1,13 +1,7 @@ -const { listEventsRef, createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, connectorConfig } = require('../index.cjs.js'); +const { createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, updateEventRef, deleteEventRef, listEventsRef, getEventByIdRef, filterEventsRef, connectorConfig } = require('../index.cjs.js'); const { validateArgs, CallerSdkTypeEnum } = require('firebase/data-connect'); const { useDataConnectQuery, useDataConnectMutation, validateReactArgs } = require('@tanstack-query-firebase/react/data-connect'); - -exports.useListEvents = function useListEvents(dcOrOptions, options) { - const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); - const ref = listEventsRef(dcInstance); - return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); -} exports.useCreateStaff = function useCreateStaff(dcOrOptions, options) { const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); function refFactory(vars) { @@ -71,3 +65,38 @@ exports.useCreateEvent = function useCreateEvent(dcOrOptions, options) { } return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); } + +exports.useUpdateEvent = function useUpdateEvent(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return updateEventRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +exports.useDeleteEvent = function useDeleteEvent(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return deleteEventRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + + +exports.useListEvents = function useListEvents(dcOrOptions, options) { + const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); + const ref = listEventsRef(dcInstance); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +exports.useGetEventById = function useGetEventById(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, true); + const ref = getEventByIdRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +exports.useFilterEvents = function useFilterEvents(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, false); + const ref = filterEventsRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} \ No newline at end of file diff --git a/internal-api-harness/src/dataconnect-generated/react/index.d.ts b/internal-api-harness/src/dataconnect-generated/react/index.d.ts index dd68f1e5..8888c622 100644 --- a/internal-api-harness/src/dataconnect-generated/react/index.d.ts +++ b/internal-api-harness/src/dataconnect-generated/react/index.d.ts @@ -1,13 +1,10 @@ -import { ListEventsData, CreateStaffData, CreateStaffVariables, ListStaffData, CreateVendorData, CreateVendorVariables, UpdateVendorData, UpdateVendorVariables, DeleteVendorData, DeleteVendorVariables, ListVendorData, GetVendorByIdData, GetVendorByIdVariables, FilterVendorsData, FilterVendorsVariables, CreateEventData, CreateEventVariables } from '../'; +import { CreateStaffData, CreateStaffVariables, ListStaffData, CreateVendorData, CreateVendorVariables, UpdateVendorData, UpdateVendorVariables, DeleteVendorData, DeleteVendorVariables, ListVendorData, GetVendorByIdData, GetVendorByIdVariables, FilterVendorsData, FilterVendorsVariables, CreateEventData, CreateEventVariables, UpdateEventData, UpdateEventVariables, DeleteEventData, DeleteEventVariables, ListEventsData, GetEventByIdData, GetEventByIdVariables, FilterEventsData, FilterEventsVariables } from '../'; import { UseDataConnectQueryResult, useDataConnectQueryOptions, UseDataConnectMutationResult, useDataConnectMutationOptions} from '@tanstack-query-firebase/react/data-connect'; import { UseQueryResult, UseMutationResult} from '@tanstack/react-query'; import { DataConnect } from 'firebase/data-connect'; import { FirebaseError } from 'firebase/app'; -export function useListEvents(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; -export function useListEvents(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; - export function useCreateStaff(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; export function useCreateStaff(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; @@ -34,3 +31,18 @@ export function useFilterVendors(dc: DataConnect, vars?: FilterVendorsVariables, export function useCreateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; export function useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; + +export function useUpdateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +export function useUpdateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; + +export function useDeleteEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +export function useDeleteEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; + +export function useListEvents(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +export function useListEvents(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; + +export function useGetEventById(vars: GetEventByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +export function useGetEventById(dc: DataConnect, vars: GetEventByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; + +export function useFilterEvents(vars?: FilterEventsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +export function useFilterEvents(dc: DataConnect, vars?: FilterEventsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult;