From f9e1fb6b9299f81f78d043cd8387ef4e8250d987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Mon, 24 Nov 2025 14:50:46 -0500 Subject: [PATCH 1/3] adding new operations for vendor --- dataconnect/connector/vendor/mutations.gql | 31 ++++++++++++++++++++++ dataconnect/connector/vendor/queries.gql | 30 +++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/dataconnect/connector/vendor/mutations.gql b/dataconnect/connector/vendor/mutations.gql index 82b66686..c40b1119 100644 --- a/dataconnect/connector/vendor/mutations.gql +++ b/dataconnect/connector/vendor/mutations.gql @@ -19,3 +19,34 @@ mutation CreateVendor( } ) } + +mutation UpdateVendor( + $id: UUID!, + $vendorNumber: String, + $legalName: String, + $region: VendorRegion, + $platformType: VendorPlatformType, + $primaryContactEmail: String, + $approvalStatus: VendorApprovalStatus, + $isActive: Boolean +) @auth(level: USER) { + vendor_update( + id: $id, + data: { + vendorNumber: $vendorNumber + legalName: $legalName + region: $region + platformType: $platformType + primaryContactEmail: $primaryContactEmail + approvalStatus: $approvalStatus + isActive: $isActive + } + ) +} + +mutation DeleteVendor( + $id: UUID! +) @auth(level: USER) { + vendor_delete(id: $id) +} + diff --git a/dataconnect/connector/vendor/queries.gql b/dataconnect/connector/vendor/queries.gql index 8247d508..996fd91b 100644 --- a/dataconnect/connector/vendor/queries.gql +++ b/dataconnect/connector/vendor/queries.gql @@ -10,3 +10,33 @@ query listVendor @auth(level: USER) { isActive } } + +query getVendorById( + $id: UUID! +) @auth(level: USER) { + vendor(id: $id) { + id + vendorNumber + legalName + region + platformType + primaryContactEmail + approvalStatus + isActive + } +} + +query filterVendors( + $where: Vendor_bool_exp! +) @auth(level: USER) { + vendors(where: $where) { + id + vendorNumber + legalName + region + platformType + primaryContactEmail + approvalStatus + isActive + } +} \ No newline at end of file From 7a751b19507397f431c505bd1f9d84a790b0e424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Mon, 24 Nov 2025 16:07:11 -0500 Subject: [PATCH 2/3] solving problem with filter --- dataconnect/connector/vendor/queries.gql | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/dataconnect/connector/vendor/queries.gql b/dataconnect/connector/vendor/queries.gql index 996fd91b..c1d0e700 100644 --- a/dataconnect/connector/vendor/queries.gql +++ b/dataconnect/connector/vendor/queries.gql @@ -27,9 +27,24 @@ query getVendorById( } query filterVendors( - $where: Vendor_bool_exp! + $region: VendorRegion, + $approvalStatus: VendorApprovalStatus, + $isActive: Boolean, + $vendorNumber:String, + $primaryContactEmail:String, + $legalName: String, + $platformType: VendorPlatformType ) @auth(level: USER) { - vendors(where: $where) { + vendors(where:{ + region: { eq: $region } + approvalStatus: { eq: $approvalStatus } + isActive: { eq: $isActive } + vendorNumber: { eq: $vendorNumber } + primaryContactEmail: { eq: $primaryContactEmail } + legalName: { eq: $legalName } + platformType: { eq: $platformType } + + }) { id vendorNumber legalName From bf37bb45ad56892d592c73ca0661fb66d669e76e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Mon, 24 Nov 2025 16:07:50 -0500 Subject: [PATCH 3/3] new sdk with full funcionts of ventors --- .../dataconnect-generated/.guides/usage.md | 44 +- .../src/dataconnect-generated/README.md | 983 +++++++++++++----- .../dataconnect-generated/esm/index.esm.js | 88 +- .../src/dataconnect-generated/index.cjs.js | 96 +- .../src/dataconnect-generated/index.d.ts | 159 ++- .../src/dataconnect-generated/react/README.md | 794 ++++++++++---- .../react/esm/index.esm.js | 58 +- .../dataconnect-generated/react/index.cjs.js | 58 +- .../dataconnect-generated/react/index.d.ts | 26 +- .../dataconnect-generated/.guides/usage.md | 44 +- .../src/dataconnect-generated/README.md | 983 +++++++++++++----- .../dataconnect-generated/esm/index.esm.js | 88 +- .../src/dataconnect-generated/index.cjs.js | 96 +- .../src/dataconnect-generated/index.d.ts | 159 ++- .../src/dataconnect-generated/react/README.md | 794 ++++++++++---- .../react/esm/index.esm.js | 58 +- .../dataconnect-generated/react/index.cjs.js | 58 +- .../dataconnect-generated/react/index.d.ts | 26 +- 18 files changed, 3504 insertions(+), 1108 deletions(-) diff --git a/frontend-web/src/dataconnect-generated/.guides/usage.md b/frontend-web/src/dataconnect-generated/.guides/usage.md index 201172eb..9f12f2ca 100644 --- a/frontend-web/src/dataconnect-generated/.guides/usage.md +++ b/frontend-web/src/dataconnect-generated/.guides/usage.md @@ -12,13 +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 { useListVendor, useCreateEvent, useListEvents, useCreateStaff, useListStaff, useCreateVendor } from '@dataconnect/generated/react'; +import { useListEvents, useCreateStaff, useListStaff, useCreateVendor, useUpdateVendor, useDeleteVendor, useListVendor, useGetVendorById, useFilterVendors, useCreateEvent } from '@dataconnect/generated/react'; // The types of these hooks are available in react/index.d.ts -const { data, isPending, isSuccess, isError, error } = useListVendor(); - -const { data, isPending, isSuccess, isError, error } = useCreateEvent(createEventVars); - const { data, isPending, isSuccess, isError, error } = useListEvents(); const { data, isPending, isSuccess, isError, error } = useCreateStaff(createStaffVars); @@ -27,6 +23,18 @@ const { data, isPending, isSuccess, isError, error } = useListStaff(); const { data, isPending, isSuccess, isError, error } = useCreateVendor(createVendorVars); +const { data, isPending, isSuccess, isError, error } = useUpdateVendor(updateVendorVars); + +const { data, isPending, isSuccess, isError, error } = useDeleteVendor(deleteVendorVars); + +const { data, isPending, isSuccess, isError, error } = useListVendor(); + +const { data, isPending, isSuccess, isError, error } = useGetVendorById(getVendorByIdVars); + +const { data, isPending, isSuccess, isError, error } = useFilterVendors(filterVendorsVars); + +const { data, isPending, isSuccess, isError, error } = useCreateEvent(createEventVars); + ``` Here's an example from a different generated SDK: @@ -64,15 +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 { listVendor, createEvent, listEvents, createStaff, listStaff, createVendor } from '@dataconnect/generated'; +import { listEvents, createStaff, listStaff, createVendor, updateVendor, deleteVendor, listVendor, getVendorById, filterVendors, createEvent } from '@dataconnect/generated'; -// Operation listVendor: -const { data } = await ListVendor(dataConnect); - -// Operation CreateEvent: For variables, look at type CreateEventVars in ../index.d.ts -const { data } = await CreateEvent(dataConnect, createEventVars); - // Operation listEvents: const { data } = await ListEvents(dataConnect); @@ -85,5 +87,23 @@ const { data } = await ListStaff(dataConnect); // Operation CreateVendor: For variables, look at type CreateVendorVars in ../index.d.ts const { data } = await CreateVendor(dataConnect, createVendorVars); +// Operation UpdateVendor: For variables, look at type UpdateVendorVars in ../index.d.ts +const { data } = await UpdateVendor(dataConnect, updateVendorVars); + +// Operation DeleteVendor: For variables, look at type DeleteVendorVars in ../index.d.ts +const { data } = await DeleteVendor(dataConnect, deleteVendorVars); + +// Operation listVendor: +const { data } = await ListVendor(dataConnect); + +// Operation getVendorById: For variables, look at type GetVendorByIdVars in ../index.d.ts +const { data } = await GetVendorById(dataConnect, getVendorByIdVars); + +// Operation filterVendors: For variables, look at type FilterVendorsVars in ../index.d.ts +const { data } = await FilterVendors(dataConnect, filterVendorsVars); + +// Operation CreateEvent: For variables, look at type CreateEventVars in ../index.d.ts +const { data } = await CreateEvent(dataConnect, createEventVars); + ``` \ 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 f11b417e..f642ed82 100644 --- a/frontend-web/src/dataconnect-generated/README.md +++ b/frontend-web/src/dataconnect-generated/README.md @@ -10,13 +10,17 @@ 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) - - [*listVendor*](#listvendor) - [*listEvents*](#listevents) - [*listStaff*](#liststaff) + - [*listVendor*](#listvendor) + - [*getVendorById*](#getvendorbyid) + - [*filterVendors*](#filtervendors) - [**Mutations**](#mutations) - - [*CreateEvent*](#createevent) - [*CreateStaff*](#createstaff) - [*CreateVendor*](#createvendor) + - [*UpdateVendor*](#updatevendor) + - [*DeleteVendor*](#deletevendor) + - [*CreateEvent*](#createevent) # 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). @@ -63,106 +67,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). -## listVendor -You can execute the `listVendor` 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 -listVendor(): QueryPromise; - -interface ListVendorRef { - ... - /* Allow users to create refs without passing in DataConnect */ - (): QueryRef; -} -export const listVendorRef: ListVendorRef; -``` -You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. -```typescript -listVendor(dc: DataConnect): QueryPromise; - -interface ListVendorRef { - ... - (dc: DataConnect): QueryRef; -} -export const listVendorRef: ListVendorRef; -``` - -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 listVendorRef: -```typescript -const name = listVendorRef.operationName; -console.log(name); -``` - -### Variables -The `listVendor` query has no variables. -### Return Type -Recall that executing the `listVendor` query returns a `QueryPromise` that resolves to an object with a `data` property. - -The `data` property is an object of type `ListVendorData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: -```typescript -export interface ListVendorData { - vendors: ({ - id: UUIDString; - vendorNumber: string; - legalName: string; - region: VendorRegion; - platformType: VendorPlatformType; - primaryContactEmail: string; - approvalStatus: VendorApprovalStatus; - isActive?: boolean | null; - } & Vendor_Key)[]; -} -``` -### Using `listVendor`'s action shortcut function - -```typescript -import { getDataConnect } from 'firebase/data-connect'; -import { connectorConfig, listVendor } from '@dataconnect/generated'; - - -// Call the `listVendor()` function to execute the query. -// You can use the `await` keyword to wait for the promise to resolve. -const { data } = await listVendor(); - -// You can also pass in a `DataConnect` instance to the action shortcut function. -const dataConnect = getDataConnect(connectorConfig); -const { data } = await listVendor(dataConnect); - -console.log(data.vendors); - -// Or, you can use the `Promise` API. -listVendor().then((response) => { - const data = response.data; - console.log(data.vendors); -}); -``` - -### Using `listVendor`'s `QueryRef` function - -```typescript -import { getDataConnect, executeQuery } from 'firebase/data-connect'; -import { connectorConfig, listVendorRef } from '@dataconnect/generated'; - - -// Call the `listVendorRef()` function to get a reference to the query. -const ref = listVendorRef(); - -// You can also pass in a `DataConnect` instance to the `QueryRef` function. -const dataConnect = getDataConnect(connectorConfig); -const ref = listVendorRef(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.vendors); - -// Or, you can use the `Promise` API. -executeQuery(ref).then((response) => { - const data = response.data; - console.log(data.vendors); -}); -``` - ## 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 @@ -367,6 +271,364 @@ executeQuery(ref).then((response) => { }); ``` +## listVendor +You can execute the `listVendor` 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 +listVendor(): QueryPromise; + +interface ListVendorRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (): QueryRef; +} +export const listVendorRef: ListVendorRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```typescript +listVendor(dc: DataConnect): QueryPromise; + +interface ListVendorRef { + ... + (dc: DataConnect): QueryRef; +} +export const listVendorRef: ListVendorRef; +``` + +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 listVendorRef: +```typescript +const name = listVendorRef.operationName; +console.log(name); +``` + +### Variables +The `listVendor` query has no variables. +### Return Type +Recall that executing the `listVendor` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `ListVendorData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface ListVendorData { + vendors: ({ + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_Key)[]; +} +``` +### Using `listVendor`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, listVendor } from '@dataconnect/generated'; + + +// Call the `listVendor()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await listVendor(); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await listVendor(dataConnect); + +console.log(data.vendors); + +// Or, you can use the `Promise` API. +listVendor().then((response) => { + const data = response.data; + console.log(data.vendors); +}); +``` + +### Using `listVendor`'s `QueryRef` function + +```typescript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, listVendorRef } from '@dataconnect/generated'; + + +// Call the `listVendorRef()` function to get a reference to the query. +const ref = listVendorRef(); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = listVendorRef(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.vendors); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.vendors); +}); +``` + +## getVendorById +You can execute the `getVendorById` 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 +getVendorById(vars: GetVendorByIdVariables): QueryPromise; + +interface GetVendorByIdRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: GetVendorByIdVariables): QueryRef; +} +export const getVendorByIdRef: GetVendorByIdRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```typescript +getVendorById(dc: DataConnect, vars: GetVendorByIdVariables): QueryPromise; + +interface GetVendorByIdRef { + ... + (dc: DataConnect, vars: GetVendorByIdVariables): QueryRef; +} +export const getVendorByIdRef: GetVendorByIdRef; +``` + +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 getVendorByIdRef: +```typescript +const name = getVendorByIdRef.operationName; +console.log(name); +``` + +### Variables +The `getVendorById` query requires an argument of type `GetVendorByIdVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface GetVendorByIdVariables { + id: UUIDString; +} +``` +### Return Type +Recall that executing the `getVendorById` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `GetVendorByIdData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface GetVendorByIdData { + vendor?: { + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_Key; +} +``` +### Using `getVendorById`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, getVendorById, GetVendorByIdVariables } from '@dataconnect/generated'; + +// The `getVendorById` query requires an argument of type `GetVendorByIdVariables`: +const getVendorByIdVars: GetVendorByIdVariables = { + id: ..., +}; + +// Call the `getVendorById()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await getVendorById(getVendorByIdVars); +// Variables can be defined inline as well. +const { data } = await getVendorById({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await getVendorById(dataConnect, getVendorByIdVars); + +console.log(data.vendor); + +// Or, you can use the `Promise` API. +getVendorById(getVendorByIdVars).then((response) => { + const data = response.data; + console.log(data.vendor); +}); +``` + +### Using `getVendorById`'s `QueryRef` function + +```typescript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, getVendorByIdRef, GetVendorByIdVariables } from '@dataconnect/generated'; + +// The `getVendorById` query requires an argument of type `GetVendorByIdVariables`: +const getVendorByIdVars: GetVendorByIdVariables = { + id: ..., +}; + +// Call the `getVendorByIdRef()` function to get a reference to the query. +const ref = getVendorByIdRef(getVendorByIdVars); +// Variables can be defined inline as well. +const ref = getVendorByIdRef({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = getVendorByIdRef(dataConnect, getVendorByIdVars); + +// 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.vendor); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.vendor); +}); +``` + +## filterVendors +You can execute the `filterVendors` 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 +filterVendors(vars?: FilterVendorsVariables): QueryPromise; + +interface FilterVendorsRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars?: FilterVendorsVariables): QueryRef; +} +export const filterVendorsRef: FilterVendorsRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```typescript +filterVendors(dc: DataConnect, vars?: FilterVendorsVariables): QueryPromise; + +interface FilterVendorsRef { + ... + (dc: DataConnect, vars?: FilterVendorsVariables): QueryRef; +} +export const filterVendorsRef: FilterVendorsRef; +``` + +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 filterVendorsRef: +```typescript +const name = filterVendorsRef.operationName; +console.log(name); +``` + +### Variables +The `filterVendors` query has an optional argument of type `FilterVendorsVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface FilterVendorsVariables { + region?: VendorRegion | null; + approvalStatus?: VendorApprovalStatus | null; + isActive?: boolean | null; + vendorNumber?: string | null; + primaryContactEmail?: string | null; + legalName?: string | null; + platformType?: VendorPlatformType | null; +} +``` +### Return Type +Recall that executing the `filterVendors` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `FilterVendorsData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface FilterVendorsData { + vendors: ({ + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_Key)[]; +} +``` +### Using `filterVendors`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, filterVendors, FilterVendorsVariables } from '@dataconnect/generated'; + +// The `filterVendors` query has an optional argument of type `FilterVendorsVariables`: +const filterVendorsVars: FilterVendorsVariables = { + region: ..., // optional + approvalStatus: ..., // optional + isActive: ..., // optional + vendorNumber: ..., // optional + primaryContactEmail: ..., // optional + legalName: ..., // optional + platformType: ..., // optional +}; + +// Call the `filterVendors()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await filterVendors(filterVendorsVars); +// Variables can be defined inline as well. +const { data } = await filterVendors({ region: ..., approvalStatus: ..., isActive: ..., vendorNumber: ..., primaryContactEmail: ..., legalName: ..., platformType: ..., }); +// Since all variables are optional for this query, you can omit the `FilterVendorsVariables` argument. +const { data } = await filterVendors(); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await filterVendors(dataConnect, filterVendorsVars); + +console.log(data.vendors); + +// Or, you can use the `Promise` API. +filterVendors(filterVendorsVars).then((response) => { + const data = response.data; + console.log(data.vendors); +}); +``` + +### Using `filterVendors`'s `QueryRef` function + +```typescript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, filterVendorsRef, FilterVendorsVariables } from '@dataconnect/generated'; + +// The `filterVendors` query has an optional argument of type `FilterVendorsVariables`: +const filterVendorsVars: FilterVendorsVariables = { + region: ..., // optional + approvalStatus: ..., // optional + isActive: ..., // optional + vendorNumber: ..., // optional + primaryContactEmail: ..., // optional + legalName: ..., // optional + platformType: ..., // optional +}; + +// Call the `filterVendorsRef()` function to get a reference to the query. +const ref = filterVendorsRef(filterVendorsVars); +// Variables can be defined inline as well. +const ref = filterVendorsRef({ region: ..., approvalStatus: ..., isActive: ..., vendorNumber: ..., primaryContactEmail: ..., legalName: ..., platformType: ..., }); +// Since all variables are optional for this query, you can omit the `FilterVendorsVariables` argument. +const ref = filterVendorsRef(); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = filterVendorsRef(dataConnect, filterVendorsVars); + +// 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.vendors); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.vendors); +}); +``` + # Mutations There are two ways to execute a Data Connect Mutation using the generated Web SDK: @@ -382,145 +644,6 @@ The following is true for both the action shortcut function and the `MutationRef Below are examples of how to use the `krow-connector` connector's generated functions to execute each mutation. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#using-mutations). -## CreateEvent -You can execute the `CreateEvent` 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 -createEvent(vars: CreateEventVariables): MutationPromise; - -interface CreateEventRef { - ... - /* Allow users to create refs without passing in DataConnect */ - (vars: CreateEventVariables): MutationRef; -} -export const createEventRef: CreateEventRef; -``` -You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. -```typescript -createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise; - -interface CreateEventRef { - ... - (dc: DataConnect, vars: CreateEventVariables): MutationRef; -} -export const createEventRef: CreateEventRef; -``` - -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 createEventRef: -```typescript -const name = createEventRef.operationName; -console.log(name); -``` - -### Variables -The `CreateEvent` mutation requires an argument of type `CreateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: - -```typescript -export interface CreateEventVariables { - eventName: string; - isRecurring: boolean; - recurrenceType?: RecurrenceType | null; - businessId: UUIDString; - vendorId?: UUIDString | null; - status: EventStatus; - date: TimestampString; - shifts?: string | null; - total?: number | null; - requested?: number | null; - assignedStaff?: string | null; -} -``` -### Return Type -Recall that executing the `CreateEvent` mutation returns a `MutationPromise` that resolves to an object with a `data` property. - -The `data` property is an object of type `CreateEventData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: -```typescript -export interface CreateEventData { - event_insert: Event_Key; -} -``` -### Using `CreateEvent`'s action shortcut function - -```typescript -import { getDataConnect } from 'firebase/data-connect'; -import { connectorConfig, createEvent, CreateEventVariables } from '@dataconnect/generated'; - -// The `CreateEvent` mutation requires an argument of type `CreateEventVariables`: -const createEventVars: CreateEventVariables = { - eventName: ..., - isRecurring: ..., - recurrenceType: ..., // optional - businessId: ..., - vendorId: ..., // optional - status: ..., - date: ..., - shifts: ..., // optional - total: ..., // optional - requested: ..., // optional - assignedStaff: ..., // optional -}; - -// Call the `createEvent()` function to execute the mutation. -// 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: ..., }); - -// You can also pass in a `DataConnect` instance to the action shortcut function. -const dataConnect = getDataConnect(connectorConfig); -const { data } = await createEvent(dataConnect, createEventVars); - -console.log(data.event_insert); - -// Or, you can use the `Promise` API. -createEvent(createEventVars).then((response) => { - const data = response.data; - console.log(data.event_insert); -}); -``` - -### Using `CreateEvent`'s `MutationRef` function - -```typescript -import { getDataConnect, executeMutation } from 'firebase/data-connect'; -import { connectorConfig, createEventRef, CreateEventVariables } from '@dataconnect/generated'; - -// The `CreateEvent` mutation requires an argument of type `CreateEventVariables`: -const createEventVars: CreateEventVariables = { - eventName: ..., - isRecurring: ..., - recurrenceType: ..., // optional - businessId: ..., - vendorId: ..., // optional - status: ..., - date: ..., - shifts: ..., // optional - total: ..., // optional - requested: ..., // optional - assignedStaff: ..., // optional -}; - -// 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: ..., }); - -// You can also pass in a `DataConnect` instance to the `MutationRef` function. -const dataConnect = getDataConnect(connectorConfig); -const ref = createEventRef(dataConnect, createEventVars); - -// 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_insert); - -// Or, you can use the `Promise` API. -executeMutation(ref).then((response) => { - const data = response.data; - console.log(data.event_insert); -}); -``` - ## CreateStaff You can execute the `CreateStaff` 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 @@ -781,3 +904,381 @@ executeMutation(ref).then((response) => { }); ``` +## UpdateVendor +You can execute the `UpdateVendor` 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 +updateVendor(vars: UpdateVendorVariables): MutationPromise; + +interface UpdateVendorRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: UpdateVendorVariables): MutationRef; +} +export const updateVendorRef: UpdateVendorRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. +```typescript +updateVendor(dc: DataConnect, vars: UpdateVendorVariables): MutationPromise; + +interface UpdateVendorRef { + ... + (dc: DataConnect, vars: UpdateVendorVariables): MutationRef; +} +export const updateVendorRef: UpdateVendorRef; +``` + +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 updateVendorRef: +```typescript +const name = updateVendorRef.operationName; +console.log(name); +``` + +### Variables +The `UpdateVendor` mutation requires an argument of type `UpdateVendorVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface UpdateVendorVariables { + id: UUIDString; + vendorNumber?: string | null; + legalName?: string | null; + region?: VendorRegion | null; + platformType?: VendorPlatformType | null; + primaryContactEmail?: string | null; + approvalStatus?: VendorApprovalStatus | null; + isActive?: boolean | null; +} +``` +### Return Type +Recall that executing the `UpdateVendor` mutation returns a `MutationPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `UpdateVendorData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface UpdateVendorData { + vendor_update?: Vendor_Key | null; +} +``` +### Using `UpdateVendor`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, updateVendor, UpdateVendorVariables } from '@dataconnect/generated'; + +// The `UpdateVendor` mutation requires an argument of type `UpdateVendorVariables`: +const updateVendorVars: UpdateVendorVariables = { + id: ..., + vendorNumber: ..., // optional + legalName: ..., // optional + region: ..., // optional + platformType: ..., // optional + primaryContactEmail: ..., // optional + approvalStatus: ..., // optional + isActive: ..., // optional +}; + +// Call the `updateVendor()` function to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await updateVendor(updateVendorVars); +// Variables can be defined inline as well. +const { data } = await updateVendor({ id: ..., vendorNumber: ..., legalName: ..., region: ..., platformType: ..., primaryContactEmail: ..., approvalStatus: ..., isActive: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await updateVendor(dataConnect, updateVendorVars); + +console.log(data.vendor_update); + +// Or, you can use the `Promise` API. +updateVendor(updateVendorVars).then((response) => { + const data = response.data; + console.log(data.vendor_update); +}); +``` + +### Using `UpdateVendor`'s `MutationRef` function + +```typescript +import { getDataConnect, executeMutation } from 'firebase/data-connect'; +import { connectorConfig, updateVendorRef, UpdateVendorVariables } from '@dataconnect/generated'; + +// The `UpdateVendor` mutation requires an argument of type `UpdateVendorVariables`: +const updateVendorVars: UpdateVendorVariables = { + id: ..., + vendorNumber: ..., // optional + legalName: ..., // optional + region: ..., // optional + platformType: ..., // optional + primaryContactEmail: ..., // optional + approvalStatus: ..., // optional + isActive: ..., // optional +}; + +// Call the `updateVendorRef()` function to get a reference to the mutation. +const ref = updateVendorRef(updateVendorVars); +// Variables can be defined inline as well. +const ref = updateVendorRef({ id: ..., vendorNumber: ..., legalName: ..., region: ..., platformType: ..., primaryContactEmail: ..., approvalStatus: ..., isActive: ..., }); + +// You can also pass in a `DataConnect` instance to the `MutationRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = updateVendorRef(dataConnect, updateVendorVars); + +// 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.vendor_update); + +// Or, you can use the `Promise` API. +executeMutation(ref).then((response) => { + const data = response.data; + console.log(data.vendor_update); +}); +``` + +## DeleteVendor +You can execute the `DeleteVendor` 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 +deleteVendor(vars: DeleteVendorVariables): MutationPromise; + +interface DeleteVendorRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: DeleteVendorVariables): MutationRef; +} +export const deleteVendorRef: DeleteVendorRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. +```typescript +deleteVendor(dc: DataConnect, vars: DeleteVendorVariables): MutationPromise; + +interface DeleteVendorRef { + ... + (dc: DataConnect, vars: DeleteVendorVariables): MutationRef; +} +export const deleteVendorRef: DeleteVendorRef; +``` + +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 deleteVendorRef: +```typescript +const name = deleteVendorRef.operationName; +console.log(name); +``` + +### Variables +The `DeleteVendor` mutation requires an argument of type `DeleteVendorVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface DeleteVendorVariables { + id: UUIDString; +} +``` +### Return Type +Recall that executing the `DeleteVendor` mutation returns a `MutationPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `DeleteVendorData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface DeleteVendorData { + vendor_delete?: Vendor_Key | null; +} +``` +### Using `DeleteVendor`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, deleteVendor, DeleteVendorVariables } from '@dataconnect/generated'; + +// The `DeleteVendor` mutation requires an argument of type `DeleteVendorVariables`: +const deleteVendorVars: DeleteVendorVariables = { + id: ..., +}; + +// Call the `deleteVendor()` function to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await deleteVendor(deleteVendorVars); +// Variables can be defined inline as well. +const { data } = await deleteVendor({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await deleteVendor(dataConnect, deleteVendorVars); + +console.log(data.vendor_delete); + +// Or, you can use the `Promise` API. +deleteVendor(deleteVendorVars).then((response) => { + const data = response.data; + console.log(data.vendor_delete); +}); +``` + +### Using `DeleteVendor`'s `MutationRef` function + +```typescript +import { getDataConnect, executeMutation } from 'firebase/data-connect'; +import { connectorConfig, deleteVendorRef, DeleteVendorVariables } from '@dataconnect/generated'; + +// The `DeleteVendor` mutation requires an argument of type `DeleteVendorVariables`: +const deleteVendorVars: DeleteVendorVariables = { + id: ..., +}; + +// Call the `deleteVendorRef()` function to get a reference to the mutation. +const ref = deleteVendorRef(deleteVendorVars); +// Variables can be defined inline as well. +const ref = deleteVendorRef({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the `MutationRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = deleteVendorRef(dataConnect, deleteVendorVars); + +// 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.vendor_delete); + +// Or, you can use the `Promise` API. +executeMutation(ref).then((response) => { + const data = response.data; + console.log(data.vendor_delete); +}); +``` + +## CreateEvent +You can execute the `CreateEvent` 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 +createEvent(vars: CreateEventVariables): MutationPromise; + +interface CreateEventRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: CreateEventVariables): MutationRef; +} +export const createEventRef: CreateEventRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. +```typescript +createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise; + +interface CreateEventRef { + ... + (dc: DataConnect, vars: CreateEventVariables): MutationRef; +} +export const createEventRef: CreateEventRef; +``` + +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 createEventRef: +```typescript +const name = createEventRef.operationName; +console.log(name); +``` + +### Variables +The `CreateEvent` mutation requires an argument of type `CreateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface CreateEventVariables { + eventName: string; + isRecurring: boolean; + recurrenceType?: RecurrenceType | null; + businessId: UUIDString; + vendorId?: UUIDString | null; + status: EventStatus; + date: TimestampString; + shifts?: string | null; + total?: number | null; + requested?: number | null; + assignedStaff?: string | null; +} +``` +### Return Type +Recall that executing the `CreateEvent` mutation returns a `MutationPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `CreateEventData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface CreateEventData { + event_insert: Event_Key; +} +``` +### Using `CreateEvent`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, createEvent, CreateEventVariables } from '@dataconnect/generated'; + +// The `CreateEvent` mutation requires an argument of type `CreateEventVariables`: +const createEventVars: CreateEventVariables = { + eventName: ..., + isRecurring: ..., + recurrenceType: ..., // optional + businessId: ..., + vendorId: ..., // optional + status: ..., + date: ..., + shifts: ..., // optional + total: ..., // optional + requested: ..., // optional + assignedStaff: ..., // optional +}; + +// Call the `createEvent()` function to execute the mutation. +// 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: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await createEvent(dataConnect, createEventVars); + +console.log(data.event_insert); + +// Or, you can use the `Promise` API. +createEvent(createEventVars).then((response) => { + const data = response.data; + console.log(data.event_insert); +}); +``` + +### Using `CreateEvent`'s `MutationRef` function + +```typescript +import { getDataConnect, executeMutation } from 'firebase/data-connect'; +import { connectorConfig, createEventRef, CreateEventVariables } from '@dataconnect/generated'; + +// The `CreateEvent` mutation requires an argument of type `CreateEventVariables`: +const createEventVars: CreateEventVariables = { + eventName: ..., + isRecurring: ..., + recurrenceType: ..., // optional + businessId: ..., + vendorId: ..., // optional + status: ..., + date: ..., + shifts: ..., // optional + total: ..., // optional + requested: ..., // optional + assignedStaff: ..., // optional +}; + +// 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: ..., }); + +// You can also pass in a `DataConnect` instance to the `MutationRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = createEventRef(dataConnect, createEventVars); + +// 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_insert); + +// Or, you can use the `Promise` API. +executeMutation(ref).then((response) => { + const data = response.data; + console.log(data.event_insert); +}); +``` + diff --git a/frontend-web/src/dataconnect-generated/esm/index.esm.js b/frontend-web/src/dataconnect-generated/esm/index.esm.js index e3a5e91f..5a6db9e0 100644 --- a/frontend-web/src/dataconnect-generated/esm/index.esm.js +++ b/frontend-web/src/dataconnect-generated/esm/index.esm.js @@ -61,28 +61,6 @@ export const connectorConfig = { location: 'us-central1' }; -export const listVendorRef = (dc) => { - const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); - dcInstance._useGeneratedSdk(); - return queryRef(dcInstance, 'listVendor'); -} -listVendorRef.operationName = 'listVendor'; - -export function listVendor(dc) { - return executeQuery(listVendorRef(dc)); -} - -export const createEventRef = (dcOrVars, vars) => { - const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); - dcInstance._useGeneratedSdk(); - return mutationRef(dcInstance, 'CreateEvent', inputVars); -} -createEventRef.operationName = 'CreateEvent'; - -export function createEvent(dcOrVars, vars) { - return executeMutation(createEventRef(dcOrVars, vars)); -} - export const listEventsRef = (dc) => { const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); dcInstance._useGeneratedSdk(); @@ -127,3 +105,69 @@ export function createVendor(dcOrVars, vars) { return executeMutation(createVendorRef(dcOrVars, vars)); } +export const updateVendorRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'UpdateVendor', inputVars); +} +updateVendorRef.operationName = 'UpdateVendor'; + +export function updateVendor(dcOrVars, vars) { + return executeMutation(updateVendorRef(dcOrVars, vars)); +} + +export const deleteVendorRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'DeleteVendor', inputVars); +} +deleteVendorRef.operationName = 'DeleteVendor'; + +export function deleteVendor(dcOrVars, vars) { + return executeMutation(deleteVendorRef(dcOrVars, vars)); +} + +export const listVendorRef = (dc) => { + const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'listVendor'); +} +listVendorRef.operationName = 'listVendor'; + +export function listVendor(dc) { + return executeQuery(listVendorRef(dc)); +} + +export const getVendorByIdRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'getVendorById', inputVars); +} +getVendorByIdRef.operationName = 'getVendorById'; + +export function getVendorById(dcOrVars, vars) { + return executeQuery(getVendorByIdRef(dcOrVars, vars)); +} + +export const filterVendorsRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'filterVendors', inputVars); +} +filterVendorsRef.operationName = 'filterVendors'; + +export function filterVendors(dcOrVars, vars) { + return executeQuery(filterVendorsRef(dcOrVars, vars)); +} + +export const createEventRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'CreateEvent', inputVars); +} +createEventRef.operationName = 'CreateEvent'; + +export function createEvent(dcOrVars, vars) { + return executeMutation(createEventRef(dcOrVars, vars)); +} + diff --git a/frontend-web/src/dataconnect-generated/index.cjs.js b/frontend-web/src/dataconnect-generated/index.cjs.js index f893680b..1aaa1719 100644 --- a/frontend-web/src/dataconnect-generated/index.cjs.js +++ b/frontend-web/src/dataconnect-generated/index.cjs.js @@ -69,30 +69,6 @@ const connectorConfig = { }; exports.connectorConfig = connectorConfig; -const listVendorRef = (dc) => { - const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); - dcInstance._useGeneratedSdk(); - return queryRef(dcInstance, 'listVendor'); -} -listVendorRef.operationName = 'listVendor'; -exports.listVendorRef = listVendorRef; - -exports.listVendor = function listVendor(dc) { - return executeQuery(listVendorRef(dc)); -}; - -const createEventRef = (dcOrVars, vars) => { - const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); - dcInstance._useGeneratedSdk(); - return mutationRef(dcInstance, 'CreateEvent', inputVars); -} -createEventRef.operationName = 'CreateEvent'; -exports.createEventRef = createEventRef; - -exports.createEvent = function createEvent(dcOrVars, vars) { - return executeMutation(createEventRef(dcOrVars, vars)); -}; - const listEventsRef = (dc) => { const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); dcInstance._useGeneratedSdk(); @@ -140,3 +116,75 @@ exports.createVendorRef = createVendorRef; exports.createVendor = function createVendor(dcOrVars, vars) { return executeMutation(createVendorRef(dcOrVars, vars)); }; + +const updateVendorRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'UpdateVendor', inputVars); +} +updateVendorRef.operationName = 'UpdateVendor'; +exports.updateVendorRef = updateVendorRef; + +exports.updateVendor = function updateVendor(dcOrVars, vars) { + return executeMutation(updateVendorRef(dcOrVars, vars)); +}; + +const deleteVendorRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'DeleteVendor', inputVars); +} +deleteVendorRef.operationName = 'DeleteVendor'; +exports.deleteVendorRef = deleteVendorRef; + +exports.deleteVendor = function deleteVendor(dcOrVars, vars) { + return executeMutation(deleteVendorRef(dcOrVars, vars)); +}; + +const listVendorRef = (dc) => { + const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'listVendor'); +} +listVendorRef.operationName = 'listVendor'; +exports.listVendorRef = listVendorRef; + +exports.listVendor = function listVendor(dc) { + return executeQuery(listVendorRef(dc)); +}; + +const getVendorByIdRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'getVendorById', inputVars); +} +getVendorByIdRef.operationName = 'getVendorById'; +exports.getVendorByIdRef = getVendorByIdRef; + +exports.getVendorById = function getVendorById(dcOrVars, vars) { + return executeQuery(getVendorByIdRef(dcOrVars, vars)); +}; + +const filterVendorsRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'filterVendors', inputVars); +} +filterVendorsRef.operationName = 'filterVendors'; +exports.filterVendorsRef = filterVendorsRef; + +exports.filterVendors = function filterVendors(dcOrVars, vars) { + return executeQuery(filterVendorsRef(dcOrVars, vars)); +}; + +const createEventRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'CreateEvent', inputVars); +} +createEventRef.operationName = 'CreateEvent'; +exports.createEventRef = createEventRef; + +exports.createEvent = function createEvent(dcOrVars, vars) { + return executeMutation(createEventRef(dcOrVars, vars)); +}; diff --git a/frontend-web/src/dataconnect-generated/index.d.ts b/frontend-web/src/dataconnect-generated/index.d.ts index 230eb09b..4013e843 100644 --- a/frontend-web/src/dataconnect-generated/index.d.ts +++ b/frontend-web/src/dataconnect-generated/index.d.ts @@ -113,11 +113,59 @@ export interface CreateVendorVariables { isActive?: boolean | null; } +export interface DeleteVendorData { + vendor_delete?: Vendor_Key | null; +} + +export interface DeleteVendorVariables { + id: UUIDString; +} + export interface Event_Key { id: UUIDString; __typename?: 'Event_Key'; } +export interface FilterVendorsData { + vendors: ({ + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_Key)[]; +} + +export interface FilterVendorsVariables { + region?: VendorRegion | null; + approvalStatus?: VendorApprovalStatus | null; + isActive?: boolean | null; + vendorNumber?: string | null; + primaryContactEmail?: string | null; + legalName?: string | null; + platformType?: VendorPlatformType | null; +} + +export interface GetVendorByIdData { + vendor?: { + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_Key; +} + +export interface GetVendorByIdVariables { + id: UUIDString; +} + export interface ListEventsData { events: ({ id: UUIDString; @@ -166,35 +214,26 @@ export interface Staff_Key { __typename?: 'Staff_Key'; } +export interface UpdateVendorData { + vendor_update?: Vendor_Key | null; +} + +export interface UpdateVendorVariables { + id: UUIDString; + vendorNumber?: string | null; + legalName?: string | null; + region?: VendorRegion | null; + platformType?: VendorPlatformType | null; + primaryContactEmail?: string | null; + approvalStatus?: VendorApprovalStatus | null; + isActive?: boolean | null; +} + export interface Vendor_Key { id: UUIDString; __typename?: 'Vendor_Key'; } -interface ListVendorRef { - /* 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 listVendorRef: ListVendorRef; - -export function listVendor(): QueryPromise; -export function listVendor(dc: DataConnect): QueryPromise; - -interface CreateEventRef { - /* Allow users to create refs without passing in DataConnect */ - (vars: CreateEventVariables): MutationRef; - /* Allow users to pass in custom DataConnect instances */ - (dc: DataConnect, vars: CreateEventVariables): MutationRef; - operationName: string; -} -export const createEventRef: CreateEventRef; - -export function createEvent(vars: CreateEventVariables): MutationPromise; -export function createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise; - interface ListEventsRef { /* Allow users to create refs without passing in DataConnect */ (): QueryRef; @@ -243,3 +282,75 @@ export const createVendorRef: CreateVendorRef; export function createVendor(vars: CreateVendorVariables): MutationPromise; export function createVendor(dc: DataConnect, vars: CreateVendorVariables): MutationPromise; +interface UpdateVendorRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: UpdateVendorVariables): MutationRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: UpdateVendorVariables): MutationRef; + operationName: string; +} +export const updateVendorRef: UpdateVendorRef; + +export function updateVendor(vars: UpdateVendorVariables): MutationPromise; +export function updateVendor(dc: DataConnect, vars: UpdateVendorVariables): MutationPromise; + +interface DeleteVendorRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: DeleteVendorVariables): MutationRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: DeleteVendorVariables): MutationRef; + operationName: string; +} +export const deleteVendorRef: DeleteVendorRef; + +export function deleteVendor(vars: DeleteVendorVariables): MutationPromise; +export function deleteVendor(dc: DataConnect, vars: DeleteVendorVariables): MutationPromise; + +interface ListVendorRef { + /* 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 listVendorRef: ListVendorRef; + +export function listVendor(): QueryPromise; +export function listVendor(dc: DataConnect): QueryPromise; + +interface GetVendorByIdRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: GetVendorByIdVariables): QueryRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: GetVendorByIdVariables): QueryRef; + operationName: string; +} +export const getVendorByIdRef: GetVendorByIdRef; + +export function getVendorById(vars: GetVendorByIdVariables): QueryPromise; +export function getVendorById(dc: DataConnect, vars: GetVendorByIdVariables): QueryPromise; + +interface FilterVendorsRef { + /* Allow users to create refs without passing in DataConnect */ + (vars?: FilterVendorsVariables): QueryRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars?: FilterVendorsVariables): QueryRef; + operationName: string; +} +export const filterVendorsRef: FilterVendorsRef; + +export function filterVendors(vars?: FilterVendorsVariables): QueryPromise; +export function filterVendors(dc: DataConnect, vars?: FilterVendorsVariables): QueryPromise; + +interface CreateEventRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: CreateEventVariables): MutationRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: CreateEventVariables): MutationRef; + operationName: string; +} +export const createEventRef: CreateEventRef; + +export function createEvent(vars: CreateEventVariables): MutationPromise; +export function createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise; + diff --git a/frontend-web/src/dataconnect-generated/react/README.md b/frontend-web/src/dataconnect-generated/react/README.md index 42322433..694d71dc 100644 --- a/frontend-web/src/dataconnect-generated/react/README.md +++ b/frontend-web/src/dataconnect-generated/react/README.md @@ -17,13 +17,17 @@ 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) - - [*listVendor*](#listvendor) - [*listEvents*](#listevents) - [*listStaff*](#liststaff) + - [*listVendor*](#listvendor) + - [*getVendorById*](#getvendorbyid) + - [*filterVendors*](#filtervendors) - [**Mutations**](#mutations) - - [*CreateEvent*](#createevent) - [*CreateStaff*](#createstaff) - [*CreateVendor*](#createvendor) + - [*UpdateVendor*](#updatevendor) + - [*DeleteVendor*](#deletevendor) + - [*CreateEvent*](#createevent) # 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). @@ -115,84 +119,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). -## listVendor -You can execute the `listVendor` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): - -```javascript -useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; -``` -You can also pass in a `DataConnect` instance to the Query hook function. -```javascript -useListVendor(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; -``` - -### Variables -The `listVendor` Query has no variables. -### Return Type -Recall that calling the `listVendor` 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 `listVendor` Query is of type `ListVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: -```javascript -export interface ListVendorData { - vendors: ({ - id: UUIDString; - vendorNumber: string; - legalName: string; - region: VendorRegion; - platformType: VendorPlatformType; - primaryContactEmail: string; - approvalStatus: VendorApprovalStatus; - isActive?: boolean | null; - } & Vendor_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 `listVendor`'s Query hook function - -```javascript -import { getDataConnect } from 'firebase/data-connect'; -import { connectorConfig } from '@dataconnect/generated'; -import { useListVendor } from '@dataconnect/generated/react' - -export default function ListVendorComponent() { - // 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 = useListVendor(); - - // You can also pass in a `DataConnect` instance to the Query hook function. - const dataConnect = getDataConnect(connectorConfig); - const query = useListVendor(dataConnect); - - // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. - const options = { staleTime: 5 * 1000 }; - const query = useListVendor(options); - - // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. - const dataConnect = getDataConnect(connectorConfig); - const options = { staleTime: 5 * 1000 }; - const query = useListVendor(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.vendors); - } - return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; -} -``` - ## 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): @@ -353,6 +279,284 @@ export default function ListStaffComponent() { } ``` +## listVendor +You can execute the `listVendor` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): + +```javascript +useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` +You can also pass in a `DataConnect` instance to the Query hook function. +```javascript +useListVendor(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` + +### Variables +The `listVendor` Query has no variables. +### Return Type +Recall that calling the `listVendor` 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 `listVendor` Query is of type `ListVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface ListVendorData { + vendors: ({ + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_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 `listVendor`'s Query hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig } from '@dataconnect/generated'; +import { useListVendor } from '@dataconnect/generated/react' + +export default function ListVendorComponent() { + // 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 = useListVendor(); + + // You can also pass in a `DataConnect` instance to the Query hook function. + const dataConnect = getDataConnect(connectorConfig); + const query = useListVendor(dataConnect); + + // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. + const options = { staleTime: 5 * 1000 }; + const query = useListVendor(options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { staleTime: 5 * 1000 }; + const query = useListVendor(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.vendors); + } + return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## getVendorById +You can execute the `getVendorById` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): + +```javascript +useGetVendorById(dc: DataConnect, vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` +You can also pass in a `DataConnect` instance to the Query hook function. +```javascript +useGetVendorById(vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` + +### Variables +The `getVendorById` Query requires an argument of type `GetVendorByIdVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface GetVendorByIdVariables { + id: UUIDString; +} +``` +### Return Type +Recall that calling the `getVendorById` 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 `getVendorById` Query is of type `GetVendorByIdData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface GetVendorByIdData { + vendor?: { + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_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 `getVendorById`'s Query hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, GetVendorByIdVariables } from '@dataconnect/generated'; +import { useGetVendorById } from '@dataconnect/generated/react' + +export default function GetVendorByIdComponent() { + // The `useGetVendorById` Query hook requires an argument of type `GetVendorByIdVariables`: + const getVendorByIdVars: GetVendorByIdVariables = { + 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 = useGetVendorById(getVendorByIdVars); + // Variables can be defined inline as well. + const query = useGetVendorById({ id: ..., }); + + // You can also pass in a `DataConnect` instance to the Query hook function. + const dataConnect = getDataConnect(connectorConfig); + const query = useGetVendorById(dataConnect, getVendorByIdVars); + + // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. + const options = { staleTime: 5 * 1000 }; + const query = useGetVendorById(getVendorByIdVars, options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { staleTime: 5 * 1000 }; + const query = useGetVendorById(dataConnect, getVendorByIdVars, 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.vendor); + } + return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## filterVendors +You can execute the `filterVendors` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): + +```javascript +useFilterVendors(dc: DataConnect, vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` +You can also pass in a `DataConnect` instance to the Query hook function. +```javascript +useFilterVendors(vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` + +### Variables +The `filterVendors` Query has an optional argument of type `FilterVendorsVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface FilterVendorsVariables { + region?: VendorRegion | null; + approvalStatus?: VendorApprovalStatus | null; + isActive?: boolean | null; + vendorNumber?: string | null; + primaryContactEmail?: string | null; + legalName?: string | null; + platformType?: VendorPlatformType | null; +} +``` +### Return Type +Recall that calling the `filterVendors` 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 `filterVendors` Query is of type `FilterVendorsData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface FilterVendorsData { + vendors: ({ + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_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 `filterVendors`'s Query hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, FilterVendorsVariables } from '@dataconnect/generated'; +import { useFilterVendors } from '@dataconnect/generated/react' + +export default function FilterVendorsComponent() { + // The `useFilterVendors` Query hook has an optional argument of type `FilterVendorsVariables`: + const filterVendorsVars: FilterVendorsVariables = { + region: ..., // optional + approvalStatus: ..., // optional + isActive: ..., // optional + vendorNumber: ..., // optional + primaryContactEmail: ..., // optional + legalName: ..., // optional + platformType: ..., // 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 = useFilterVendors(filterVendorsVars); + // Variables can be defined inline as well. + const query = useFilterVendors({ region: ..., approvalStatus: ..., isActive: ..., vendorNumber: ..., primaryContactEmail: ..., legalName: ..., platformType: ..., }); + // Since all variables are optional for this Query, you can omit the `FilterVendorsVariables` argument. + // (as long as you don't want to provide any `options`!) + const query = useFilterVendors(); + + // You can also pass in a `DataConnect` instance to the Query hook function. + const dataConnect = getDataConnect(connectorConfig); + const query = useFilterVendors(dataConnect, filterVendorsVars); + + // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. + const options = { staleTime: 5 * 1000 }; + const query = useFilterVendors(filterVendorsVars, 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 = useFilterVendors(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 = useFilterVendors(dataConnect, filterVendorsVars /** 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.vendors); + } + 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. @@ -378,120 +582,6 @@ Here's a general overview of how to use the generated Mutation hooks in your cod Below are examples of how to use the `krow-connector` connector's generated Mutation hook functions to execute each Mutation. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#operations-react-angular). -## CreateEvent -You can execute the `CreateEvent` 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 -useCreateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; -``` -You can also pass in a `DataConnect` instance to the Mutation hook function. -```javascript -useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; -``` - -### Variables -The `CreateEvent` Mutation requires an argument of type `CreateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: - -```javascript -export interface CreateEventVariables { - eventName: string; - isRecurring: boolean; - recurrenceType?: RecurrenceType | null; - businessId: UUIDString; - vendorId?: UUIDString | null; - status: EventStatus; - date: TimestampString; - shifts?: string | null; - total?: number | null; - requested?: number | null; - assignedStaff?: string | null; -} -``` -### Return Type -Recall that calling the `CreateEvent` 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 `CreateEvent` Mutation is of type `CreateEventData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: -```javascript -export interface CreateEventData { - event_insert: Event_Key; -} -``` - -To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation). - -### Using `CreateEvent`'s Mutation hook function - -```javascript -import { getDataConnect } from 'firebase/data-connect'; -import { connectorConfig, CreateEventVariables } from '@dataconnect/generated'; -import { useCreateEvent } from '@dataconnect/generated/react' - -export default function CreateEventComponent() { - // Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation. - const mutation = useCreateEvent(); - - // You can also pass in a `DataConnect` instance to the Mutation hook function. - const dataConnect = getDataConnect(connectorConfig); - const mutation = useCreateEvent(dataConnect); - - // You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function. - const options = { - onSuccess: () => { console.log('Mutation succeeded!'); } - }; - const mutation = useCreateEvent(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 = useCreateEvent(dataConnect, options); - - // After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation. - // The `useCreateEvent` Mutation requires an argument of type `CreateEventVariables`: - const createEventVars: CreateEventVariables = { - eventName: ..., - isRecurring: ..., - recurrenceType: ..., // optional - businessId: ..., - vendorId: ..., // optional - status: ..., - date: ..., - shifts: ..., // optional - total: ..., // 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: ..., }); - - // You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`. - const options = { - onSuccess: () => { console.log('Mutation succeeded!'); } - }; - mutation.mutate(createEventVars, 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_insert); - } - return
Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!
; -} -``` - ## CreateStaff You can execute the `CreateStaff` 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 @@ -708,3 +798,319 @@ export default function CreateVendorComponent() { } ``` +## UpdateVendor +You can execute the `UpdateVendor` 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 +useUpdateVendor(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` +You can also pass in a `DataConnect` instance to the Mutation hook function. +```javascript +useUpdateVendor(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` + +### Variables +The `UpdateVendor` Mutation requires an argument of type `UpdateVendorVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface UpdateVendorVariables { + id: UUIDString; + vendorNumber?: string | null; + legalName?: string | null; + region?: VendorRegion | null; + platformType?: VendorPlatformType | null; + primaryContactEmail?: string | null; + approvalStatus?: VendorApprovalStatus | null; + isActive?: boolean | null; +} +``` +### Return Type +Recall that calling the `UpdateVendor` 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 `UpdateVendor` Mutation is of type `UpdateVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface UpdateVendorData { + vendor_update?: Vendor_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 `UpdateVendor`'s Mutation hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, UpdateVendorVariables } from '@dataconnect/generated'; +import { useUpdateVendor } from '@dataconnect/generated/react' + +export default function UpdateVendorComponent() { + // Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation. + const mutation = useUpdateVendor(); + + // You can also pass in a `DataConnect` instance to the Mutation hook function. + const dataConnect = getDataConnect(connectorConfig); + const mutation = useUpdateVendor(dataConnect); + + // You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useUpdateVendor(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 = useUpdateVendor(dataConnect, options); + + // After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation. + // The `useUpdateVendor` Mutation requires an argument of type `UpdateVendorVariables`: + const updateVendorVars: UpdateVendorVariables = { + id: ..., + vendorNumber: ..., // optional + legalName: ..., // optional + region: ..., // optional + platformType: ..., // optional + primaryContactEmail: ..., // optional + approvalStatus: ..., // optional + isActive: ..., // optional + }; + mutation.mutate(updateVendorVars); + // Variables can be defined inline as well. + mutation.mutate({ id: ..., vendorNumber: ..., legalName: ..., region: ..., platformType: ..., primaryContactEmail: ..., approvalStatus: ..., isActive: ..., }); + + // You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + mutation.mutate(updateVendorVars, 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.vendor_update); + } + return
Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## DeleteVendor +You can execute the `DeleteVendor` 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 +useDeleteVendor(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` +You can also pass in a `DataConnect` instance to the Mutation hook function. +```javascript +useDeleteVendor(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` + +### Variables +The `DeleteVendor` Mutation requires an argument of type `DeleteVendorVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface DeleteVendorVariables { + id: UUIDString; +} +``` +### Return Type +Recall that calling the `DeleteVendor` 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 `DeleteVendor` Mutation is of type `DeleteVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface DeleteVendorData { + vendor_delete?: Vendor_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 `DeleteVendor`'s Mutation hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, DeleteVendorVariables } from '@dataconnect/generated'; +import { useDeleteVendor } from '@dataconnect/generated/react' + +export default function DeleteVendorComponent() { + // Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation. + const mutation = useDeleteVendor(); + + // You can also pass in a `DataConnect` instance to the Mutation hook function. + const dataConnect = getDataConnect(connectorConfig); + const mutation = useDeleteVendor(dataConnect); + + // You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useDeleteVendor(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 = useDeleteVendor(dataConnect, options); + + // After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation. + // The `useDeleteVendor` Mutation requires an argument of type `DeleteVendorVariables`: + const deleteVendorVars: DeleteVendorVariables = { + id: ..., + }; + mutation.mutate(deleteVendorVars); + // 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(deleteVendorVars, 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.vendor_delete); + } + return
Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## CreateEvent +You can execute the `CreateEvent` 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 +useCreateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` +You can also pass in a `DataConnect` instance to the Mutation hook function. +```javascript +useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` + +### Variables +The `CreateEvent` Mutation requires an argument of type `CreateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface CreateEventVariables { + eventName: string; + isRecurring: boolean; + recurrenceType?: RecurrenceType | null; + businessId: UUIDString; + vendorId?: UUIDString | null; + status: EventStatus; + date: TimestampString; + shifts?: string | null; + total?: number | null; + requested?: number | null; + assignedStaff?: string | null; +} +``` +### Return Type +Recall that calling the `CreateEvent` 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 `CreateEvent` Mutation is of type `CreateEventData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface CreateEventData { + event_insert: Event_Key; +} +``` + +To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation). + +### Using `CreateEvent`'s Mutation hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, CreateEventVariables } from '@dataconnect/generated'; +import { useCreateEvent } from '@dataconnect/generated/react' + +export default function CreateEventComponent() { + // Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation. + const mutation = useCreateEvent(); + + // You can also pass in a `DataConnect` instance to the Mutation hook function. + const dataConnect = getDataConnect(connectorConfig); + const mutation = useCreateEvent(dataConnect); + + // You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useCreateEvent(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 = useCreateEvent(dataConnect, options); + + // After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation. + // The `useCreateEvent` Mutation requires an argument of type `CreateEventVariables`: + const createEventVars: CreateEventVariables = { + eventName: ..., + isRecurring: ..., + recurrenceType: ..., // optional + businessId: ..., + vendorId: ..., // optional + status: ..., + date: ..., + shifts: ..., // optional + total: ..., // 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: ..., }); + + // You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + mutation.mutate(createEventVars, 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_insert); + } + 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 01723bf8..a2bc80c3 100644 --- a/frontend-web/src/dataconnect-generated/react/esm/index.esm.js +++ b/frontend-web/src/dataconnect-generated/react/esm/index.esm.js @@ -1,22 +1,8 @@ -import { listVendorRef, createEventRef, listEventsRef, createStaffRef, listStaffRef, createVendorRef, connectorConfig } from '../../esm/index.esm.js'; +import { listEventsRef, createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, 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 useListVendor(dcOrOptions, options) { - const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); - const ref = listVendorRef(dcInstance); - return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); -} -export function useCreateEvent(dcOrOptions, options) { - const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); - function refFactory(vars) { - return createEventRef(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); @@ -43,3 +29,45 @@ export function useCreateVendor(dcOrOptions, options) { } return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); } + +export function useUpdateVendor(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return updateVendorRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +export function useDeleteVendor(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return deleteVendorRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + + +export function useListVendor(dcOrOptions, options) { + const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); + const ref = listVendorRef(dcInstance); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +export function useGetVendorById(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, true); + const ref = getVendorByIdRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +export function useFilterVendors(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, false); + const ref = filterVendorsRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} +export function useCreateEvent(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return createEventRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} diff --git a/frontend-web/src/dataconnect-generated/react/index.cjs.js b/frontend-web/src/dataconnect-generated/react/index.cjs.js index af43f031..c3717435 100644 --- a/frontend-web/src/dataconnect-generated/react/index.cjs.js +++ b/frontend-web/src/dataconnect-generated/react/index.cjs.js @@ -1,22 +1,8 @@ -const { listVendorRef, createEventRef, listEventsRef, createStaffRef, listStaffRef, createVendorRef, connectorConfig } = require('../index.cjs.js'); +const { listEventsRef, createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, connectorConfig } = require('../index.cjs.js'); const { validateArgs, CallerSdkTypeEnum } = require('firebase/data-connect'); const { useDataConnectQuery, useDataConnectMutation, validateReactArgs } = require('@tanstack-query-firebase/react/data-connect'); -exports.useListVendor = function useListVendor(dcOrOptions, options) { - const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); - const ref = listVendorRef(dcInstance); - return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); -} -exports.useCreateEvent = function useCreateEvent(dcOrOptions, options) { - const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); - function refFactory(vars) { - return createEventRef(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); @@ -43,3 +29,45 @@ exports.useCreateVendor = function useCreateVendor(dcOrOptions, options) { } return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); } + +exports.useUpdateVendor = function useUpdateVendor(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return updateVendorRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +exports.useDeleteVendor = function useDeleteVendor(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return deleteVendorRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + + +exports.useListVendor = function useListVendor(dcOrOptions, options) { + const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); + const ref = listVendorRef(dcInstance); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +exports.useGetVendorById = function useGetVendorById(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, true); + const ref = getVendorByIdRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +exports.useFilterVendors = function useFilterVendors(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, false); + const ref = filterVendorsRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} +exports.useCreateEvent = function useCreateEvent(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return createEventRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} diff --git a/frontend-web/src/dataconnect-generated/react/index.d.ts b/frontend-web/src/dataconnect-generated/react/index.d.ts index be88d610..dd68f1e5 100644 --- a/frontend-web/src/dataconnect-generated/react/index.d.ts +++ b/frontend-web/src/dataconnect-generated/react/index.d.ts @@ -1,16 +1,10 @@ -import { ListVendorData, CreateEventData, CreateEventVariables, ListEventsData, CreateStaffData, CreateStaffVariables, ListStaffData, CreateVendorData, CreateVendorVariables } from '../'; +import { ListEventsData, CreateStaffData, CreateStaffVariables, ListStaffData, CreateVendorData, CreateVendorVariables, UpdateVendorData, UpdateVendorVariables, DeleteVendorData, DeleteVendorVariables, ListVendorData, GetVendorByIdData, GetVendorByIdVariables, FilterVendorsData, FilterVendorsVariables, CreateEventData, CreateEventVariables } 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 useListVendor(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; -export function useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; - -export function useCreateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; -export function useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; - export function useListEvents(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; export function useListEvents(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; @@ -22,3 +16,21 @@ export function useListStaff(dc: DataConnect, options?: useDataConnectQueryOptio export function useCreateVendor(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; export function useCreateVendor(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; + +export function useUpdateVendor(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +export function useUpdateVendor(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; + +export function useDeleteVendor(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +export function useDeleteVendor(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; + +export function useListVendor(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +export function useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; + +export function useGetVendorById(vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +export function useGetVendorById(dc: DataConnect, vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; + +export function useFilterVendors(vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +export function useFilterVendors(dc: DataConnect, vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; + +export function useCreateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +export function useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; diff --git a/internal-api-harness/src/dataconnect-generated/.guides/usage.md b/internal-api-harness/src/dataconnect-generated/.guides/usage.md index 201172eb..9f12f2ca 100644 --- a/internal-api-harness/src/dataconnect-generated/.guides/usage.md +++ b/internal-api-harness/src/dataconnect-generated/.guides/usage.md @@ -12,13 +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 { useListVendor, useCreateEvent, useListEvents, useCreateStaff, useListStaff, useCreateVendor } from '@dataconnect/generated/react'; +import { useListEvents, useCreateStaff, useListStaff, useCreateVendor, useUpdateVendor, useDeleteVendor, useListVendor, useGetVendorById, useFilterVendors, useCreateEvent } from '@dataconnect/generated/react'; // The types of these hooks are available in react/index.d.ts -const { data, isPending, isSuccess, isError, error } = useListVendor(); - -const { data, isPending, isSuccess, isError, error } = useCreateEvent(createEventVars); - const { data, isPending, isSuccess, isError, error } = useListEvents(); const { data, isPending, isSuccess, isError, error } = useCreateStaff(createStaffVars); @@ -27,6 +23,18 @@ const { data, isPending, isSuccess, isError, error } = useListStaff(); const { data, isPending, isSuccess, isError, error } = useCreateVendor(createVendorVars); +const { data, isPending, isSuccess, isError, error } = useUpdateVendor(updateVendorVars); + +const { data, isPending, isSuccess, isError, error } = useDeleteVendor(deleteVendorVars); + +const { data, isPending, isSuccess, isError, error } = useListVendor(); + +const { data, isPending, isSuccess, isError, error } = useGetVendorById(getVendorByIdVars); + +const { data, isPending, isSuccess, isError, error } = useFilterVendors(filterVendorsVars); + +const { data, isPending, isSuccess, isError, error } = useCreateEvent(createEventVars); + ``` Here's an example from a different generated SDK: @@ -64,15 +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 { listVendor, createEvent, listEvents, createStaff, listStaff, createVendor } from '@dataconnect/generated'; +import { listEvents, createStaff, listStaff, createVendor, updateVendor, deleteVendor, listVendor, getVendorById, filterVendors, createEvent } from '@dataconnect/generated'; -// Operation listVendor: -const { data } = await ListVendor(dataConnect); - -// Operation CreateEvent: For variables, look at type CreateEventVars in ../index.d.ts -const { data } = await CreateEvent(dataConnect, createEventVars); - // Operation listEvents: const { data } = await ListEvents(dataConnect); @@ -85,5 +87,23 @@ const { data } = await ListStaff(dataConnect); // Operation CreateVendor: For variables, look at type CreateVendorVars in ../index.d.ts const { data } = await CreateVendor(dataConnect, createVendorVars); +// Operation UpdateVendor: For variables, look at type UpdateVendorVars in ../index.d.ts +const { data } = await UpdateVendor(dataConnect, updateVendorVars); + +// Operation DeleteVendor: For variables, look at type DeleteVendorVars in ../index.d.ts +const { data } = await DeleteVendor(dataConnect, deleteVendorVars); + +// Operation listVendor: +const { data } = await ListVendor(dataConnect); + +// Operation getVendorById: For variables, look at type GetVendorByIdVars in ../index.d.ts +const { data } = await GetVendorById(dataConnect, getVendorByIdVars); + +// Operation filterVendors: For variables, look at type FilterVendorsVars in ../index.d.ts +const { data } = await FilterVendors(dataConnect, filterVendorsVars); + +// Operation CreateEvent: For variables, look at type CreateEventVars in ../index.d.ts +const { data } = await CreateEvent(dataConnect, createEventVars); + ``` \ 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 f11b417e..f642ed82 100644 --- a/internal-api-harness/src/dataconnect-generated/README.md +++ b/internal-api-harness/src/dataconnect-generated/README.md @@ -10,13 +10,17 @@ 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) - - [*listVendor*](#listvendor) - [*listEvents*](#listevents) - [*listStaff*](#liststaff) + - [*listVendor*](#listvendor) + - [*getVendorById*](#getvendorbyid) + - [*filterVendors*](#filtervendors) - [**Mutations**](#mutations) - - [*CreateEvent*](#createevent) - [*CreateStaff*](#createstaff) - [*CreateVendor*](#createvendor) + - [*UpdateVendor*](#updatevendor) + - [*DeleteVendor*](#deletevendor) + - [*CreateEvent*](#createevent) # 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). @@ -63,106 +67,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). -## listVendor -You can execute the `listVendor` 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 -listVendor(): QueryPromise; - -interface ListVendorRef { - ... - /* Allow users to create refs without passing in DataConnect */ - (): QueryRef; -} -export const listVendorRef: ListVendorRef; -``` -You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. -```typescript -listVendor(dc: DataConnect): QueryPromise; - -interface ListVendorRef { - ... - (dc: DataConnect): QueryRef; -} -export const listVendorRef: ListVendorRef; -``` - -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 listVendorRef: -```typescript -const name = listVendorRef.operationName; -console.log(name); -``` - -### Variables -The `listVendor` query has no variables. -### Return Type -Recall that executing the `listVendor` query returns a `QueryPromise` that resolves to an object with a `data` property. - -The `data` property is an object of type `ListVendorData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: -```typescript -export interface ListVendorData { - vendors: ({ - id: UUIDString; - vendorNumber: string; - legalName: string; - region: VendorRegion; - platformType: VendorPlatformType; - primaryContactEmail: string; - approvalStatus: VendorApprovalStatus; - isActive?: boolean | null; - } & Vendor_Key)[]; -} -``` -### Using `listVendor`'s action shortcut function - -```typescript -import { getDataConnect } from 'firebase/data-connect'; -import { connectorConfig, listVendor } from '@dataconnect/generated'; - - -// Call the `listVendor()` function to execute the query. -// You can use the `await` keyword to wait for the promise to resolve. -const { data } = await listVendor(); - -// You can also pass in a `DataConnect` instance to the action shortcut function. -const dataConnect = getDataConnect(connectorConfig); -const { data } = await listVendor(dataConnect); - -console.log(data.vendors); - -// Or, you can use the `Promise` API. -listVendor().then((response) => { - const data = response.data; - console.log(data.vendors); -}); -``` - -### Using `listVendor`'s `QueryRef` function - -```typescript -import { getDataConnect, executeQuery } from 'firebase/data-connect'; -import { connectorConfig, listVendorRef } from '@dataconnect/generated'; - - -// Call the `listVendorRef()` function to get a reference to the query. -const ref = listVendorRef(); - -// You can also pass in a `DataConnect` instance to the `QueryRef` function. -const dataConnect = getDataConnect(connectorConfig); -const ref = listVendorRef(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.vendors); - -// Or, you can use the `Promise` API. -executeQuery(ref).then((response) => { - const data = response.data; - console.log(data.vendors); -}); -``` - ## 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 @@ -367,6 +271,364 @@ executeQuery(ref).then((response) => { }); ``` +## listVendor +You can execute the `listVendor` 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 +listVendor(): QueryPromise; + +interface ListVendorRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (): QueryRef; +} +export const listVendorRef: ListVendorRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```typescript +listVendor(dc: DataConnect): QueryPromise; + +interface ListVendorRef { + ... + (dc: DataConnect): QueryRef; +} +export const listVendorRef: ListVendorRef; +``` + +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 listVendorRef: +```typescript +const name = listVendorRef.operationName; +console.log(name); +``` + +### Variables +The `listVendor` query has no variables. +### Return Type +Recall that executing the `listVendor` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `ListVendorData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface ListVendorData { + vendors: ({ + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_Key)[]; +} +``` +### Using `listVendor`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, listVendor } from '@dataconnect/generated'; + + +// Call the `listVendor()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await listVendor(); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await listVendor(dataConnect); + +console.log(data.vendors); + +// Or, you can use the `Promise` API. +listVendor().then((response) => { + const data = response.data; + console.log(data.vendors); +}); +``` + +### Using `listVendor`'s `QueryRef` function + +```typescript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, listVendorRef } from '@dataconnect/generated'; + + +// Call the `listVendorRef()` function to get a reference to the query. +const ref = listVendorRef(); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = listVendorRef(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.vendors); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.vendors); +}); +``` + +## getVendorById +You can execute the `getVendorById` 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 +getVendorById(vars: GetVendorByIdVariables): QueryPromise; + +interface GetVendorByIdRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: GetVendorByIdVariables): QueryRef; +} +export const getVendorByIdRef: GetVendorByIdRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```typescript +getVendorById(dc: DataConnect, vars: GetVendorByIdVariables): QueryPromise; + +interface GetVendorByIdRef { + ... + (dc: DataConnect, vars: GetVendorByIdVariables): QueryRef; +} +export const getVendorByIdRef: GetVendorByIdRef; +``` + +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 getVendorByIdRef: +```typescript +const name = getVendorByIdRef.operationName; +console.log(name); +``` + +### Variables +The `getVendorById` query requires an argument of type `GetVendorByIdVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface GetVendorByIdVariables { + id: UUIDString; +} +``` +### Return Type +Recall that executing the `getVendorById` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `GetVendorByIdData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface GetVendorByIdData { + vendor?: { + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_Key; +} +``` +### Using `getVendorById`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, getVendorById, GetVendorByIdVariables } from '@dataconnect/generated'; + +// The `getVendorById` query requires an argument of type `GetVendorByIdVariables`: +const getVendorByIdVars: GetVendorByIdVariables = { + id: ..., +}; + +// Call the `getVendorById()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await getVendorById(getVendorByIdVars); +// Variables can be defined inline as well. +const { data } = await getVendorById({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await getVendorById(dataConnect, getVendorByIdVars); + +console.log(data.vendor); + +// Or, you can use the `Promise` API. +getVendorById(getVendorByIdVars).then((response) => { + const data = response.data; + console.log(data.vendor); +}); +``` + +### Using `getVendorById`'s `QueryRef` function + +```typescript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, getVendorByIdRef, GetVendorByIdVariables } from '@dataconnect/generated'; + +// The `getVendorById` query requires an argument of type `GetVendorByIdVariables`: +const getVendorByIdVars: GetVendorByIdVariables = { + id: ..., +}; + +// Call the `getVendorByIdRef()` function to get a reference to the query. +const ref = getVendorByIdRef(getVendorByIdVars); +// Variables can be defined inline as well. +const ref = getVendorByIdRef({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = getVendorByIdRef(dataConnect, getVendorByIdVars); + +// 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.vendor); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.vendor); +}); +``` + +## filterVendors +You can execute the `filterVendors` 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 +filterVendors(vars?: FilterVendorsVariables): QueryPromise; + +interface FilterVendorsRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars?: FilterVendorsVariables): QueryRef; +} +export const filterVendorsRef: FilterVendorsRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. +```typescript +filterVendors(dc: DataConnect, vars?: FilterVendorsVariables): QueryPromise; + +interface FilterVendorsRef { + ... + (dc: DataConnect, vars?: FilterVendorsVariables): QueryRef; +} +export const filterVendorsRef: FilterVendorsRef; +``` + +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 filterVendorsRef: +```typescript +const name = filterVendorsRef.operationName; +console.log(name); +``` + +### Variables +The `filterVendors` query has an optional argument of type `FilterVendorsVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface FilterVendorsVariables { + region?: VendorRegion | null; + approvalStatus?: VendorApprovalStatus | null; + isActive?: boolean | null; + vendorNumber?: string | null; + primaryContactEmail?: string | null; + legalName?: string | null; + platformType?: VendorPlatformType | null; +} +``` +### Return Type +Recall that executing the `filterVendors` query returns a `QueryPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `FilterVendorsData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface FilterVendorsData { + vendors: ({ + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_Key)[]; +} +``` +### Using `filterVendors`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, filterVendors, FilterVendorsVariables } from '@dataconnect/generated'; + +// The `filterVendors` query has an optional argument of type `FilterVendorsVariables`: +const filterVendorsVars: FilterVendorsVariables = { + region: ..., // optional + approvalStatus: ..., // optional + isActive: ..., // optional + vendorNumber: ..., // optional + primaryContactEmail: ..., // optional + legalName: ..., // optional + platformType: ..., // optional +}; + +// Call the `filterVendors()` function to execute the query. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await filterVendors(filterVendorsVars); +// Variables can be defined inline as well. +const { data } = await filterVendors({ region: ..., approvalStatus: ..., isActive: ..., vendorNumber: ..., primaryContactEmail: ..., legalName: ..., platformType: ..., }); +// Since all variables are optional for this query, you can omit the `FilterVendorsVariables` argument. +const { data } = await filterVendors(); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await filterVendors(dataConnect, filterVendorsVars); + +console.log(data.vendors); + +// Or, you can use the `Promise` API. +filterVendors(filterVendorsVars).then((response) => { + const data = response.data; + console.log(data.vendors); +}); +``` + +### Using `filterVendors`'s `QueryRef` function + +```typescript +import { getDataConnect, executeQuery } from 'firebase/data-connect'; +import { connectorConfig, filterVendorsRef, FilterVendorsVariables } from '@dataconnect/generated'; + +// The `filterVendors` query has an optional argument of type `FilterVendorsVariables`: +const filterVendorsVars: FilterVendorsVariables = { + region: ..., // optional + approvalStatus: ..., // optional + isActive: ..., // optional + vendorNumber: ..., // optional + primaryContactEmail: ..., // optional + legalName: ..., // optional + platformType: ..., // optional +}; + +// Call the `filterVendorsRef()` function to get a reference to the query. +const ref = filterVendorsRef(filterVendorsVars); +// Variables can be defined inline as well. +const ref = filterVendorsRef({ region: ..., approvalStatus: ..., isActive: ..., vendorNumber: ..., primaryContactEmail: ..., legalName: ..., platformType: ..., }); +// Since all variables are optional for this query, you can omit the `FilterVendorsVariables` argument. +const ref = filterVendorsRef(); + +// You can also pass in a `DataConnect` instance to the `QueryRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = filterVendorsRef(dataConnect, filterVendorsVars); + +// 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.vendors); + +// Or, you can use the `Promise` API. +executeQuery(ref).then((response) => { + const data = response.data; + console.log(data.vendors); +}); +``` + # Mutations There are two ways to execute a Data Connect Mutation using the generated Web SDK: @@ -382,145 +644,6 @@ The following is true for both the action shortcut function and the `MutationRef Below are examples of how to use the `krow-connector` connector's generated functions to execute each mutation. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#using-mutations). -## CreateEvent -You can execute the `CreateEvent` 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 -createEvent(vars: CreateEventVariables): MutationPromise; - -interface CreateEventRef { - ... - /* Allow users to create refs without passing in DataConnect */ - (vars: CreateEventVariables): MutationRef; -} -export const createEventRef: CreateEventRef; -``` -You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. -```typescript -createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise; - -interface CreateEventRef { - ... - (dc: DataConnect, vars: CreateEventVariables): MutationRef; -} -export const createEventRef: CreateEventRef; -``` - -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 createEventRef: -```typescript -const name = createEventRef.operationName; -console.log(name); -``` - -### Variables -The `CreateEvent` mutation requires an argument of type `CreateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: - -```typescript -export interface CreateEventVariables { - eventName: string; - isRecurring: boolean; - recurrenceType?: RecurrenceType | null; - businessId: UUIDString; - vendorId?: UUIDString | null; - status: EventStatus; - date: TimestampString; - shifts?: string | null; - total?: number | null; - requested?: number | null; - assignedStaff?: string | null; -} -``` -### Return Type -Recall that executing the `CreateEvent` mutation returns a `MutationPromise` that resolves to an object with a `data` property. - -The `data` property is an object of type `CreateEventData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: -```typescript -export interface CreateEventData { - event_insert: Event_Key; -} -``` -### Using `CreateEvent`'s action shortcut function - -```typescript -import { getDataConnect } from 'firebase/data-connect'; -import { connectorConfig, createEvent, CreateEventVariables } from '@dataconnect/generated'; - -// The `CreateEvent` mutation requires an argument of type `CreateEventVariables`: -const createEventVars: CreateEventVariables = { - eventName: ..., - isRecurring: ..., - recurrenceType: ..., // optional - businessId: ..., - vendorId: ..., // optional - status: ..., - date: ..., - shifts: ..., // optional - total: ..., // optional - requested: ..., // optional - assignedStaff: ..., // optional -}; - -// Call the `createEvent()` function to execute the mutation. -// 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: ..., }); - -// You can also pass in a `DataConnect` instance to the action shortcut function. -const dataConnect = getDataConnect(connectorConfig); -const { data } = await createEvent(dataConnect, createEventVars); - -console.log(data.event_insert); - -// Or, you can use the `Promise` API. -createEvent(createEventVars).then((response) => { - const data = response.data; - console.log(data.event_insert); -}); -``` - -### Using `CreateEvent`'s `MutationRef` function - -```typescript -import { getDataConnect, executeMutation } from 'firebase/data-connect'; -import { connectorConfig, createEventRef, CreateEventVariables } from '@dataconnect/generated'; - -// The `CreateEvent` mutation requires an argument of type `CreateEventVariables`: -const createEventVars: CreateEventVariables = { - eventName: ..., - isRecurring: ..., - recurrenceType: ..., // optional - businessId: ..., - vendorId: ..., // optional - status: ..., - date: ..., - shifts: ..., // optional - total: ..., // optional - requested: ..., // optional - assignedStaff: ..., // optional -}; - -// 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: ..., }); - -// You can also pass in a `DataConnect` instance to the `MutationRef` function. -const dataConnect = getDataConnect(connectorConfig); -const ref = createEventRef(dataConnect, createEventVars); - -// 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_insert); - -// Or, you can use the `Promise` API. -executeMutation(ref).then((response) => { - const data = response.data; - console.log(data.event_insert); -}); -``` - ## CreateStaff You can execute the `CreateStaff` 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 @@ -781,3 +904,381 @@ executeMutation(ref).then((response) => { }); ``` +## UpdateVendor +You can execute the `UpdateVendor` 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 +updateVendor(vars: UpdateVendorVariables): MutationPromise; + +interface UpdateVendorRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: UpdateVendorVariables): MutationRef; +} +export const updateVendorRef: UpdateVendorRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. +```typescript +updateVendor(dc: DataConnect, vars: UpdateVendorVariables): MutationPromise; + +interface UpdateVendorRef { + ... + (dc: DataConnect, vars: UpdateVendorVariables): MutationRef; +} +export const updateVendorRef: UpdateVendorRef; +``` + +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 updateVendorRef: +```typescript +const name = updateVendorRef.operationName; +console.log(name); +``` + +### Variables +The `UpdateVendor` mutation requires an argument of type `UpdateVendorVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface UpdateVendorVariables { + id: UUIDString; + vendorNumber?: string | null; + legalName?: string | null; + region?: VendorRegion | null; + platformType?: VendorPlatformType | null; + primaryContactEmail?: string | null; + approvalStatus?: VendorApprovalStatus | null; + isActive?: boolean | null; +} +``` +### Return Type +Recall that executing the `UpdateVendor` mutation returns a `MutationPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `UpdateVendorData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface UpdateVendorData { + vendor_update?: Vendor_Key | null; +} +``` +### Using `UpdateVendor`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, updateVendor, UpdateVendorVariables } from '@dataconnect/generated'; + +// The `UpdateVendor` mutation requires an argument of type `UpdateVendorVariables`: +const updateVendorVars: UpdateVendorVariables = { + id: ..., + vendorNumber: ..., // optional + legalName: ..., // optional + region: ..., // optional + platformType: ..., // optional + primaryContactEmail: ..., // optional + approvalStatus: ..., // optional + isActive: ..., // optional +}; + +// Call the `updateVendor()` function to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await updateVendor(updateVendorVars); +// Variables can be defined inline as well. +const { data } = await updateVendor({ id: ..., vendorNumber: ..., legalName: ..., region: ..., platformType: ..., primaryContactEmail: ..., approvalStatus: ..., isActive: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await updateVendor(dataConnect, updateVendorVars); + +console.log(data.vendor_update); + +// Or, you can use the `Promise` API. +updateVendor(updateVendorVars).then((response) => { + const data = response.data; + console.log(data.vendor_update); +}); +``` + +### Using `UpdateVendor`'s `MutationRef` function + +```typescript +import { getDataConnect, executeMutation } from 'firebase/data-connect'; +import { connectorConfig, updateVendorRef, UpdateVendorVariables } from '@dataconnect/generated'; + +// The `UpdateVendor` mutation requires an argument of type `UpdateVendorVariables`: +const updateVendorVars: UpdateVendorVariables = { + id: ..., + vendorNumber: ..., // optional + legalName: ..., // optional + region: ..., // optional + platformType: ..., // optional + primaryContactEmail: ..., // optional + approvalStatus: ..., // optional + isActive: ..., // optional +}; + +// Call the `updateVendorRef()` function to get a reference to the mutation. +const ref = updateVendorRef(updateVendorVars); +// Variables can be defined inline as well. +const ref = updateVendorRef({ id: ..., vendorNumber: ..., legalName: ..., region: ..., platformType: ..., primaryContactEmail: ..., approvalStatus: ..., isActive: ..., }); + +// You can also pass in a `DataConnect` instance to the `MutationRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = updateVendorRef(dataConnect, updateVendorVars); + +// 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.vendor_update); + +// Or, you can use the `Promise` API. +executeMutation(ref).then((response) => { + const data = response.data; + console.log(data.vendor_update); +}); +``` + +## DeleteVendor +You can execute the `DeleteVendor` 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 +deleteVendor(vars: DeleteVendorVariables): MutationPromise; + +interface DeleteVendorRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: DeleteVendorVariables): MutationRef; +} +export const deleteVendorRef: DeleteVendorRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. +```typescript +deleteVendor(dc: DataConnect, vars: DeleteVendorVariables): MutationPromise; + +interface DeleteVendorRef { + ... + (dc: DataConnect, vars: DeleteVendorVariables): MutationRef; +} +export const deleteVendorRef: DeleteVendorRef; +``` + +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 deleteVendorRef: +```typescript +const name = deleteVendorRef.operationName; +console.log(name); +``` + +### Variables +The `DeleteVendor` mutation requires an argument of type `DeleteVendorVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface DeleteVendorVariables { + id: UUIDString; +} +``` +### Return Type +Recall that executing the `DeleteVendor` mutation returns a `MutationPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `DeleteVendorData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface DeleteVendorData { + vendor_delete?: Vendor_Key | null; +} +``` +### Using `DeleteVendor`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, deleteVendor, DeleteVendorVariables } from '@dataconnect/generated'; + +// The `DeleteVendor` mutation requires an argument of type `DeleteVendorVariables`: +const deleteVendorVars: DeleteVendorVariables = { + id: ..., +}; + +// Call the `deleteVendor()` function to execute the mutation. +// You can use the `await` keyword to wait for the promise to resolve. +const { data } = await deleteVendor(deleteVendorVars); +// Variables can be defined inline as well. +const { data } = await deleteVendor({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await deleteVendor(dataConnect, deleteVendorVars); + +console.log(data.vendor_delete); + +// Or, you can use the `Promise` API. +deleteVendor(deleteVendorVars).then((response) => { + const data = response.data; + console.log(data.vendor_delete); +}); +``` + +### Using `DeleteVendor`'s `MutationRef` function + +```typescript +import { getDataConnect, executeMutation } from 'firebase/data-connect'; +import { connectorConfig, deleteVendorRef, DeleteVendorVariables } from '@dataconnect/generated'; + +// The `DeleteVendor` mutation requires an argument of type `DeleteVendorVariables`: +const deleteVendorVars: DeleteVendorVariables = { + id: ..., +}; + +// Call the `deleteVendorRef()` function to get a reference to the mutation. +const ref = deleteVendorRef(deleteVendorVars); +// Variables can be defined inline as well. +const ref = deleteVendorRef({ id: ..., }); + +// You can also pass in a `DataConnect` instance to the `MutationRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = deleteVendorRef(dataConnect, deleteVendorVars); + +// 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.vendor_delete); + +// Or, you can use the `Promise` API. +executeMutation(ref).then((response) => { + const data = response.data; + console.log(data.vendor_delete); +}); +``` + +## CreateEvent +You can execute the `CreateEvent` 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 +createEvent(vars: CreateEventVariables): MutationPromise; + +interface CreateEventRef { + ... + /* Allow users to create refs without passing in DataConnect */ + (vars: CreateEventVariables): MutationRef; +} +export const createEventRef: CreateEventRef; +``` +You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. +```typescript +createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise; + +interface CreateEventRef { + ... + (dc: DataConnect, vars: CreateEventVariables): MutationRef; +} +export const createEventRef: CreateEventRef; +``` + +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 createEventRef: +```typescript +const name = createEventRef.operationName; +console.log(name); +``` + +### Variables +The `CreateEvent` mutation requires an argument of type `CreateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: + +```typescript +export interface CreateEventVariables { + eventName: string; + isRecurring: boolean; + recurrenceType?: RecurrenceType | null; + businessId: UUIDString; + vendorId?: UUIDString | null; + status: EventStatus; + date: TimestampString; + shifts?: string | null; + total?: number | null; + requested?: number | null; + assignedStaff?: string | null; +} +``` +### Return Type +Recall that executing the `CreateEvent` mutation returns a `MutationPromise` that resolves to an object with a `data` property. + +The `data` property is an object of type `CreateEventData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: +```typescript +export interface CreateEventData { + event_insert: Event_Key; +} +``` +### Using `CreateEvent`'s action shortcut function + +```typescript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, createEvent, CreateEventVariables } from '@dataconnect/generated'; + +// The `CreateEvent` mutation requires an argument of type `CreateEventVariables`: +const createEventVars: CreateEventVariables = { + eventName: ..., + isRecurring: ..., + recurrenceType: ..., // optional + businessId: ..., + vendorId: ..., // optional + status: ..., + date: ..., + shifts: ..., // optional + total: ..., // optional + requested: ..., // optional + assignedStaff: ..., // optional +}; + +// Call the `createEvent()` function to execute the mutation. +// 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: ..., }); + +// You can also pass in a `DataConnect` instance to the action shortcut function. +const dataConnect = getDataConnect(connectorConfig); +const { data } = await createEvent(dataConnect, createEventVars); + +console.log(data.event_insert); + +// Or, you can use the `Promise` API. +createEvent(createEventVars).then((response) => { + const data = response.data; + console.log(data.event_insert); +}); +``` + +### Using `CreateEvent`'s `MutationRef` function + +```typescript +import { getDataConnect, executeMutation } from 'firebase/data-connect'; +import { connectorConfig, createEventRef, CreateEventVariables } from '@dataconnect/generated'; + +// The `CreateEvent` mutation requires an argument of type `CreateEventVariables`: +const createEventVars: CreateEventVariables = { + eventName: ..., + isRecurring: ..., + recurrenceType: ..., // optional + businessId: ..., + vendorId: ..., // optional + status: ..., + date: ..., + shifts: ..., // optional + total: ..., // optional + requested: ..., // optional + assignedStaff: ..., // optional +}; + +// 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: ..., }); + +// You can also pass in a `DataConnect` instance to the `MutationRef` function. +const dataConnect = getDataConnect(connectorConfig); +const ref = createEventRef(dataConnect, createEventVars); + +// 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_insert); + +// Or, you can use the `Promise` API. +executeMutation(ref).then((response) => { + const data = response.data; + console.log(data.event_insert); +}); +``` + 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 e3a5e91f..5a6db9e0 100644 --- a/internal-api-harness/src/dataconnect-generated/esm/index.esm.js +++ b/internal-api-harness/src/dataconnect-generated/esm/index.esm.js @@ -61,28 +61,6 @@ export const connectorConfig = { location: 'us-central1' }; -export const listVendorRef = (dc) => { - const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); - dcInstance._useGeneratedSdk(); - return queryRef(dcInstance, 'listVendor'); -} -listVendorRef.operationName = 'listVendor'; - -export function listVendor(dc) { - return executeQuery(listVendorRef(dc)); -} - -export const createEventRef = (dcOrVars, vars) => { - const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); - dcInstance._useGeneratedSdk(); - return mutationRef(dcInstance, 'CreateEvent', inputVars); -} -createEventRef.operationName = 'CreateEvent'; - -export function createEvent(dcOrVars, vars) { - return executeMutation(createEventRef(dcOrVars, vars)); -} - export const listEventsRef = (dc) => { const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); dcInstance._useGeneratedSdk(); @@ -127,3 +105,69 @@ export function createVendor(dcOrVars, vars) { return executeMutation(createVendorRef(dcOrVars, vars)); } +export const updateVendorRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'UpdateVendor', inputVars); +} +updateVendorRef.operationName = 'UpdateVendor'; + +export function updateVendor(dcOrVars, vars) { + return executeMutation(updateVendorRef(dcOrVars, vars)); +} + +export const deleteVendorRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'DeleteVendor', inputVars); +} +deleteVendorRef.operationName = 'DeleteVendor'; + +export function deleteVendor(dcOrVars, vars) { + return executeMutation(deleteVendorRef(dcOrVars, vars)); +} + +export const listVendorRef = (dc) => { + const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'listVendor'); +} +listVendorRef.operationName = 'listVendor'; + +export function listVendor(dc) { + return executeQuery(listVendorRef(dc)); +} + +export const getVendorByIdRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'getVendorById', inputVars); +} +getVendorByIdRef.operationName = 'getVendorById'; + +export function getVendorById(dcOrVars, vars) { + return executeQuery(getVendorByIdRef(dcOrVars, vars)); +} + +export const filterVendorsRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'filterVendors', inputVars); +} +filterVendorsRef.operationName = 'filterVendors'; + +export function filterVendors(dcOrVars, vars) { + return executeQuery(filterVendorsRef(dcOrVars, vars)); +} + +export const createEventRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'CreateEvent', inputVars); +} +createEventRef.operationName = 'CreateEvent'; + +export function createEvent(dcOrVars, vars) { + return executeMutation(createEventRef(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 f893680b..1aaa1719 100644 --- a/internal-api-harness/src/dataconnect-generated/index.cjs.js +++ b/internal-api-harness/src/dataconnect-generated/index.cjs.js @@ -69,30 +69,6 @@ const connectorConfig = { }; exports.connectorConfig = connectorConfig; -const listVendorRef = (dc) => { - const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); - dcInstance._useGeneratedSdk(); - return queryRef(dcInstance, 'listVendor'); -} -listVendorRef.operationName = 'listVendor'; -exports.listVendorRef = listVendorRef; - -exports.listVendor = function listVendor(dc) { - return executeQuery(listVendorRef(dc)); -}; - -const createEventRef = (dcOrVars, vars) => { - const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); - dcInstance._useGeneratedSdk(); - return mutationRef(dcInstance, 'CreateEvent', inputVars); -} -createEventRef.operationName = 'CreateEvent'; -exports.createEventRef = createEventRef; - -exports.createEvent = function createEvent(dcOrVars, vars) { - return executeMutation(createEventRef(dcOrVars, vars)); -}; - const listEventsRef = (dc) => { const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); dcInstance._useGeneratedSdk(); @@ -140,3 +116,75 @@ exports.createVendorRef = createVendorRef; exports.createVendor = function createVendor(dcOrVars, vars) { return executeMutation(createVendorRef(dcOrVars, vars)); }; + +const updateVendorRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'UpdateVendor', inputVars); +} +updateVendorRef.operationName = 'UpdateVendor'; +exports.updateVendorRef = updateVendorRef; + +exports.updateVendor = function updateVendor(dcOrVars, vars) { + return executeMutation(updateVendorRef(dcOrVars, vars)); +}; + +const deleteVendorRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'DeleteVendor', inputVars); +} +deleteVendorRef.operationName = 'DeleteVendor'; +exports.deleteVendorRef = deleteVendorRef; + +exports.deleteVendor = function deleteVendor(dcOrVars, vars) { + return executeMutation(deleteVendorRef(dcOrVars, vars)); +}; + +const listVendorRef = (dc) => { + const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'listVendor'); +} +listVendorRef.operationName = 'listVendor'; +exports.listVendorRef = listVendorRef; + +exports.listVendor = function listVendor(dc) { + return executeQuery(listVendorRef(dc)); +}; + +const getVendorByIdRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'getVendorById', inputVars); +} +getVendorByIdRef.operationName = 'getVendorById'; +exports.getVendorByIdRef = getVendorByIdRef; + +exports.getVendorById = function getVendorById(dcOrVars, vars) { + return executeQuery(getVendorByIdRef(dcOrVars, vars)); +}; + +const filterVendorsRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars); + dcInstance._useGeneratedSdk(); + return queryRef(dcInstance, 'filterVendors', inputVars); +} +filterVendorsRef.operationName = 'filterVendors'; +exports.filterVendorsRef = filterVendorsRef; + +exports.filterVendors = function filterVendors(dcOrVars, vars) { + return executeQuery(filterVendorsRef(dcOrVars, vars)); +}; + +const createEventRef = (dcOrVars, vars) => { + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); + dcInstance._useGeneratedSdk(); + return mutationRef(dcInstance, 'CreateEvent', inputVars); +} +createEventRef.operationName = 'CreateEvent'; +exports.createEventRef = createEventRef; + +exports.createEvent = function createEvent(dcOrVars, vars) { + return executeMutation(createEventRef(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 230eb09b..4013e843 100644 --- a/internal-api-harness/src/dataconnect-generated/index.d.ts +++ b/internal-api-harness/src/dataconnect-generated/index.d.ts @@ -113,11 +113,59 @@ export interface CreateVendorVariables { isActive?: boolean | null; } +export interface DeleteVendorData { + vendor_delete?: Vendor_Key | null; +} + +export interface DeleteVendorVariables { + id: UUIDString; +} + export interface Event_Key { id: UUIDString; __typename?: 'Event_Key'; } +export interface FilterVendorsData { + vendors: ({ + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_Key)[]; +} + +export interface FilterVendorsVariables { + region?: VendorRegion | null; + approvalStatus?: VendorApprovalStatus | null; + isActive?: boolean | null; + vendorNumber?: string | null; + primaryContactEmail?: string | null; + legalName?: string | null; + platformType?: VendorPlatformType | null; +} + +export interface GetVendorByIdData { + vendor?: { + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_Key; +} + +export interface GetVendorByIdVariables { + id: UUIDString; +} + export interface ListEventsData { events: ({ id: UUIDString; @@ -166,35 +214,26 @@ export interface Staff_Key { __typename?: 'Staff_Key'; } +export interface UpdateVendorData { + vendor_update?: Vendor_Key | null; +} + +export interface UpdateVendorVariables { + id: UUIDString; + vendorNumber?: string | null; + legalName?: string | null; + region?: VendorRegion | null; + platformType?: VendorPlatformType | null; + primaryContactEmail?: string | null; + approvalStatus?: VendorApprovalStatus | null; + isActive?: boolean | null; +} + export interface Vendor_Key { id: UUIDString; __typename?: 'Vendor_Key'; } -interface ListVendorRef { - /* 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 listVendorRef: ListVendorRef; - -export function listVendor(): QueryPromise; -export function listVendor(dc: DataConnect): QueryPromise; - -interface CreateEventRef { - /* Allow users to create refs without passing in DataConnect */ - (vars: CreateEventVariables): MutationRef; - /* Allow users to pass in custom DataConnect instances */ - (dc: DataConnect, vars: CreateEventVariables): MutationRef; - operationName: string; -} -export const createEventRef: CreateEventRef; - -export function createEvent(vars: CreateEventVariables): MutationPromise; -export function createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise; - interface ListEventsRef { /* Allow users to create refs without passing in DataConnect */ (): QueryRef; @@ -243,3 +282,75 @@ export const createVendorRef: CreateVendorRef; export function createVendor(vars: CreateVendorVariables): MutationPromise; export function createVendor(dc: DataConnect, vars: CreateVendorVariables): MutationPromise; +interface UpdateVendorRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: UpdateVendorVariables): MutationRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: UpdateVendorVariables): MutationRef; + operationName: string; +} +export const updateVendorRef: UpdateVendorRef; + +export function updateVendor(vars: UpdateVendorVariables): MutationPromise; +export function updateVendor(dc: DataConnect, vars: UpdateVendorVariables): MutationPromise; + +interface DeleteVendorRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: DeleteVendorVariables): MutationRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: DeleteVendorVariables): MutationRef; + operationName: string; +} +export const deleteVendorRef: DeleteVendorRef; + +export function deleteVendor(vars: DeleteVendorVariables): MutationPromise; +export function deleteVendor(dc: DataConnect, vars: DeleteVendorVariables): MutationPromise; + +interface ListVendorRef { + /* 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 listVendorRef: ListVendorRef; + +export function listVendor(): QueryPromise; +export function listVendor(dc: DataConnect): QueryPromise; + +interface GetVendorByIdRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: GetVendorByIdVariables): QueryRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: GetVendorByIdVariables): QueryRef; + operationName: string; +} +export const getVendorByIdRef: GetVendorByIdRef; + +export function getVendorById(vars: GetVendorByIdVariables): QueryPromise; +export function getVendorById(dc: DataConnect, vars: GetVendorByIdVariables): QueryPromise; + +interface FilterVendorsRef { + /* Allow users to create refs without passing in DataConnect */ + (vars?: FilterVendorsVariables): QueryRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars?: FilterVendorsVariables): QueryRef; + operationName: string; +} +export const filterVendorsRef: FilterVendorsRef; + +export function filterVendors(vars?: FilterVendorsVariables): QueryPromise; +export function filterVendors(dc: DataConnect, vars?: FilterVendorsVariables): QueryPromise; + +interface CreateEventRef { + /* Allow users to create refs without passing in DataConnect */ + (vars: CreateEventVariables): MutationRef; + /* Allow users to pass in custom DataConnect instances */ + (dc: DataConnect, vars: CreateEventVariables): MutationRef; + operationName: string; +} +export const createEventRef: CreateEventRef; + +export function createEvent(vars: CreateEventVariables): MutationPromise; +export function createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise; + diff --git a/internal-api-harness/src/dataconnect-generated/react/README.md b/internal-api-harness/src/dataconnect-generated/react/README.md index 42322433..694d71dc 100644 --- a/internal-api-harness/src/dataconnect-generated/react/README.md +++ b/internal-api-harness/src/dataconnect-generated/react/README.md @@ -17,13 +17,17 @@ 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) - - [*listVendor*](#listvendor) - [*listEvents*](#listevents) - [*listStaff*](#liststaff) + - [*listVendor*](#listvendor) + - [*getVendorById*](#getvendorbyid) + - [*filterVendors*](#filtervendors) - [**Mutations**](#mutations) - - [*CreateEvent*](#createevent) - [*CreateStaff*](#createstaff) - [*CreateVendor*](#createvendor) + - [*UpdateVendor*](#updatevendor) + - [*DeleteVendor*](#deletevendor) + - [*CreateEvent*](#createevent) # 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). @@ -115,84 +119,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). -## listVendor -You can execute the `listVendor` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): - -```javascript -useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; -``` -You can also pass in a `DataConnect` instance to the Query hook function. -```javascript -useListVendor(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; -``` - -### Variables -The `listVendor` Query has no variables. -### Return Type -Recall that calling the `listVendor` 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 `listVendor` Query is of type `ListVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: -```javascript -export interface ListVendorData { - vendors: ({ - id: UUIDString; - vendorNumber: string; - legalName: string; - region: VendorRegion; - platformType: VendorPlatformType; - primaryContactEmail: string; - approvalStatus: VendorApprovalStatus; - isActive?: boolean | null; - } & Vendor_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 `listVendor`'s Query hook function - -```javascript -import { getDataConnect } from 'firebase/data-connect'; -import { connectorConfig } from '@dataconnect/generated'; -import { useListVendor } from '@dataconnect/generated/react' - -export default function ListVendorComponent() { - // 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 = useListVendor(); - - // You can also pass in a `DataConnect` instance to the Query hook function. - const dataConnect = getDataConnect(connectorConfig); - const query = useListVendor(dataConnect); - - // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. - const options = { staleTime: 5 * 1000 }; - const query = useListVendor(options); - - // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. - const dataConnect = getDataConnect(connectorConfig); - const options = { staleTime: 5 * 1000 }; - const query = useListVendor(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.vendors); - } - return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; -} -``` - ## 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): @@ -353,6 +279,284 @@ export default function ListStaffComponent() { } ``` +## listVendor +You can execute the `listVendor` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): + +```javascript +useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` +You can also pass in a `DataConnect` instance to the Query hook function. +```javascript +useListVendor(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` + +### Variables +The `listVendor` Query has no variables. +### Return Type +Recall that calling the `listVendor` 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 `listVendor` Query is of type `ListVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface ListVendorData { + vendors: ({ + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_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 `listVendor`'s Query hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig } from '@dataconnect/generated'; +import { useListVendor } from '@dataconnect/generated/react' + +export default function ListVendorComponent() { + // 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 = useListVendor(); + + // You can also pass in a `DataConnect` instance to the Query hook function. + const dataConnect = getDataConnect(connectorConfig); + const query = useListVendor(dataConnect); + + // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. + const options = { staleTime: 5 * 1000 }; + const query = useListVendor(options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { staleTime: 5 * 1000 }; + const query = useListVendor(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.vendors); + } + return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## getVendorById +You can execute the `getVendorById` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): + +```javascript +useGetVendorById(dc: DataConnect, vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` +You can also pass in a `DataConnect` instance to the Query hook function. +```javascript +useGetVendorById(vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` + +### Variables +The `getVendorById` Query requires an argument of type `GetVendorByIdVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface GetVendorByIdVariables { + id: UUIDString; +} +``` +### Return Type +Recall that calling the `getVendorById` 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 `getVendorById` Query is of type `GetVendorByIdData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface GetVendorByIdData { + vendor?: { + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_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 `getVendorById`'s Query hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, GetVendorByIdVariables } from '@dataconnect/generated'; +import { useGetVendorById } from '@dataconnect/generated/react' + +export default function GetVendorByIdComponent() { + // The `useGetVendorById` Query hook requires an argument of type `GetVendorByIdVariables`: + const getVendorByIdVars: GetVendorByIdVariables = { + 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 = useGetVendorById(getVendorByIdVars); + // Variables can be defined inline as well. + const query = useGetVendorById({ id: ..., }); + + // You can also pass in a `DataConnect` instance to the Query hook function. + const dataConnect = getDataConnect(connectorConfig); + const query = useGetVendorById(dataConnect, getVendorByIdVars); + + // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. + const options = { staleTime: 5 * 1000 }; + const query = useGetVendorById(getVendorByIdVars, options); + + // You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object. + const dataConnect = getDataConnect(connectorConfig); + const options = { staleTime: 5 * 1000 }; + const query = useGetVendorById(dataConnect, getVendorByIdVars, 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.vendor); + } + return
Query execution {query.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## filterVendors +You can execute the `filterVendors` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts): + +```javascript +useFilterVendors(dc: DataConnect, vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` +You can also pass in a `DataConnect` instance to the Query hook function. +```javascript +useFilterVendors(vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +``` + +### Variables +The `filterVendors` Query has an optional argument of type `FilterVendorsVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface FilterVendorsVariables { + region?: VendorRegion | null; + approvalStatus?: VendorApprovalStatus | null; + isActive?: boolean | null; + vendorNumber?: string | null; + primaryContactEmail?: string | null; + legalName?: string | null; + platformType?: VendorPlatformType | null; +} +``` +### Return Type +Recall that calling the `filterVendors` 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 `filterVendors` Query is of type `FilterVendorsData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface FilterVendorsData { + vendors: ({ + id: UUIDString; + vendorNumber: string; + legalName: string; + region: VendorRegion; + platformType: VendorPlatformType; + primaryContactEmail: string; + approvalStatus: VendorApprovalStatus; + isActive?: boolean | null; + } & Vendor_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 `filterVendors`'s Query hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, FilterVendorsVariables } from '@dataconnect/generated'; +import { useFilterVendors } from '@dataconnect/generated/react' + +export default function FilterVendorsComponent() { + // The `useFilterVendors` Query hook has an optional argument of type `FilterVendorsVariables`: + const filterVendorsVars: FilterVendorsVariables = { + region: ..., // optional + approvalStatus: ..., // optional + isActive: ..., // optional + vendorNumber: ..., // optional + primaryContactEmail: ..., // optional + legalName: ..., // optional + platformType: ..., // 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 = useFilterVendors(filterVendorsVars); + // Variables can be defined inline as well. + const query = useFilterVendors({ region: ..., approvalStatus: ..., isActive: ..., vendorNumber: ..., primaryContactEmail: ..., legalName: ..., platformType: ..., }); + // Since all variables are optional for this Query, you can omit the `FilterVendorsVariables` argument. + // (as long as you don't want to provide any `options`!) + const query = useFilterVendors(); + + // You can also pass in a `DataConnect` instance to the Query hook function. + const dataConnect = getDataConnect(connectorConfig); + const query = useFilterVendors(dataConnect, filterVendorsVars); + + // You can also pass in a `useDataConnectQueryOptions` object to the Query hook function. + const options = { staleTime: 5 * 1000 }; + const query = useFilterVendors(filterVendorsVars, 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 = useFilterVendors(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 = useFilterVendors(dataConnect, filterVendorsVars /** 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.vendors); + } + 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. @@ -378,120 +582,6 @@ Here's a general overview of how to use the generated Mutation hooks in your cod Below are examples of how to use the `krow-connector` connector's generated Mutation hook functions to execute each Mutation. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#operations-react-angular). -## CreateEvent -You can execute the `CreateEvent` 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 -useCreateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; -``` -You can also pass in a `DataConnect` instance to the Mutation hook function. -```javascript -useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; -``` - -### Variables -The `CreateEvent` Mutation requires an argument of type `CreateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: - -```javascript -export interface CreateEventVariables { - eventName: string; - isRecurring: boolean; - recurrenceType?: RecurrenceType | null; - businessId: UUIDString; - vendorId?: UUIDString | null; - status: EventStatus; - date: TimestampString; - shifts?: string | null; - total?: number | null; - requested?: number | null; - assignedStaff?: string | null; -} -``` -### Return Type -Recall that calling the `CreateEvent` 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 `CreateEvent` Mutation is of type `CreateEventData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: -```javascript -export interface CreateEventData { - event_insert: Event_Key; -} -``` - -To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation). - -### Using `CreateEvent`'s Mutation hook function - -```javascript -import { getDataConnect } from 'firebase/data-connect'; -import { connectorConfig, CreateEventVariables } from '@dataconnect/generated'; -import { useCreateEvent } from '@dataconnect/generated/react' - -export default function CreateEventComponent() { - // Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation. - const mutation = useCreateEvent(); - - // You can also pass in a `DataConnect` instance to the Mutation hook function. - const dataConnect = getDataConnect(connectorConfig); - const mutation = useCreateEvent(dataConnect); - - // You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function. - const options = { - onSuccess: () => { console.log('Mutation succeeded!'); } - }; - const mutation = useCreateEvent(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 = useCreateEvent(dataConnect, options); - - // After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation. - // The `useCreateEvent` Mutation requires an argument of type `CreateEventVariables`: - const createEventVars: CreateEventVariables = { - eventName: ..., - isRecurring: ..., - recurrenceType: ..., // optional - businessId: ..., - vendorId: ..., // optional - status: ..., - date: ..., - shifts: ..., // optional - total: ..., // 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: ..., }); - - // You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`. - const options = { - onSuccess: () => { console.log('Mutation succeeded!'); } - }; - mutation.mutate(createEventVars, 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_insert); - } - return
Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!
; -} -``` - ## CreateStaff You can execute the `CreateStaff` 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 @@ -708,3 +798,319 @@ export default function CreateVendorComponent() { } ``` +## UpdateVendor +You can execute the `UpdateVendor` 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 +useUpdateVendor(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` +You can also pass in a `DataConnect` instance to the Mutation hook function. +```javascript +useUpdateVendor(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` + +### Variables +The `UpdateVendor` Mutation requires an argument of type `UpdateVendorVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface UpdateVendorVariables { + id: UUIDString; + vendorNumber?: string | null; + legalName?: string | null; + region?: VendorRegion | null; + platformType?: VendorPlatformType | null; + primaryContactEmail?: string | null; + approvalStatus?: VendorApprovalStatus | null; + isActive?: boolean | null; +} +``` +### Return Type +Recall that calling the `UpdateVendor` 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 `UpdateVendor` Mutation is of type `UpdateVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface UpdateVendorData { + vendor_update?: Vendor_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 `UpdateVendor`'s Mutation hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, UpdateVendorVariables } from '@dataconnect/generated'; +import { useUpdateVendor } from '@dataconnect/generated/react' + +export default function UpdateVendorComponent() { + // Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation. + const mutation = useUpdateVendor(); + + // You can also pass in a `DataConnect` instance to the Mutation hook function. + const dataConnect = getDataConnect(connectorConfig); + const mutation = useUpdateVendor(dataConnect); + + // You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useUpdateVendor(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 = useUpdateVendor(dataConnect, options); + + // After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation. + // The `useUpdateVendor` Mutation requires an argument of type `UpdateVendorVariables`: + const updateVendorVars: UpdateVendorVariables = { + id: ..., + vendorNumber: ..., // optional + legalName: ..., // optional + region: ..., // optional + platformType: ..., // optional + primaryContactEmail: ..., // optional + approvalStatus: ..., // optional + isActive: ..., // optional + }; + mutation.mutate(updateVendorVars); + // Variables can be defined inline as well. + mutation.mutate({ id: ..., vendorNumber: ..., legalName: ..., region: ..., platformType: ..., primaryContactEmail: ..., approvalStatus: ..., isActive: ..., }); + + // You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + mutation.mutate(updateVendorVars, 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.vendor_update); + } + return
Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## DeleteVendor +You can execute the `DeleteVendor` 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 +useDeleteVendor(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` +You can also pass in a `DataConnect` instance to the Mutation hook function. +```javascript +useDeleteVendor(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` + +### Variables +The `DeleteVendor` Mutation requires an argument of type `DeleteVendorVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface DeleteVendorVariables { + id: UUIDString; +} +``` +### Return Type +Recall that calling the `DeleteVendor` 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 `DeleteVendor` Mutation is of type `DeleteVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface DeleteVendorData { + vendor_delete?: Vendor_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 `DeleteVendor`'s Mutation hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, DeleteVendorVariables } from '@dataconnect/generated'; +import { useDeleteVendor } from '@dataconnect/generated/react' + +export default function DeleteVendorComponent() { + // Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation. + const mutation = useDeleteVendor(); + + // You can also pass in a `DataConnect` instance to the Mutation hook function. + const dataConnect = getDataConnect(connectorConfig); + const mutation = useDeleteVendor(dataConnect); + + // You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useDeleteVendor(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 = useDeleteVendor(dataConnect, options); + + // After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation. + // The `useDeleteVendor` Mutation requires an argument of type `DeleteVendorVariables`: + const deleteVendorVars: DeleteVendorVariables = { + id: ..., + }; + mutation.mutate(deleteVendorVars); + // 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(deleteVendorVars, 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.vendor_delete); + } + return
Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!
; +} +``` + +## CreateEvent +You can execute the `CreateEvent` 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 +useCreateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` +You can also pass in a `DataConnect` instance to the Mutation hook function. +```javascript +useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +``` + +### Variables +The `CreateEvent` Mutation requires an argument of type `CreateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: + +```javascript +export interface CreateEventVariables { + eventName: string; + isRecurring: boolean; + recurrenceType?: RecurrenceType | null; + businessId: UUIDString; + vendorId?: UUIDString | null; + status: EventStatus; + date: TimestampString; + shifts?: string | null; + total?: number | null; + requested?: number | null; + assignedStaff?: string | null; +} +``` +### Return Type +Recall that calling the `CreateEvent` 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 `CreateEvent` Mutation is of type `CreateEventData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields: +```javascript +export interface CreateEventData { + event_insert: Event_Key; +} +``` + +To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation). + +### Using `CreateEvent`'s Mutation hook function + +```javascript +import { getDataConnect } from 'firebase/data-connect'; +import { connectorConfig, CreateEventVariables } from '@dataconnect/generated'; +import { useCreateEvent } from '@dataconnect/generated/react' + +export default function CreateEventComponent() { + // Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation. + const mutation = useCreateEvent(); + + // You can also pass in a `DataConnect` instance to the Mutation hook function. + const dataConnect = getDataConnect(connectorConfig); + const mutation = useCreateEvent(dataConnect); + + // You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + const mutation = useCreateEvent(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 = useCreateEvent(dataConnect, options); + + // After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation. + // The `useCreateEvent` Mutation requires an argument of type `CreateEventVariables`: + const createEventVars: CreateEventVariables = { + eventName: ..., + isRecurring: ..., + recurrenceType: ..., // optional + businessId: ..., + vendorId: ..., // optional + status: ..., + date: ..., + shifts: ..., // optional + total: ..., // 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: ..., }); + + // You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`. + const options = { + onSuccess: () => { console.log('Mutation succeeded!'); } + }; + mutation.mutate(createEventVars, 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_insert); + } + 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 01723bf8..a2bc80c3 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,22 +1,8 @@ -import { listVendorRef, createEventRef, listEventsRef, createStaffRef, listStaffRef, createVendorRef, connectorConfig } from '../../esm/index.esm.js'; +import { listEventsRef, createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, 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 useListVendor(dcOrOptions, options) { - const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); - const ref = listVendorRef(dcInstance); - return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); -} -export function useCreateEvent(dcOrOptions, options) { - const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); - function refFactory(vars) { - return createEventRef(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); @@ -43,3 +29,45 @@ export function useCreateVendor(dcOrOptions, options) { } return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); } + +export function useUpdateVendor(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return updateVendorRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +export function useDeleteVendor(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return deleteVendorRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + + +export function useListVendor(dcOrOptions, options) { + const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); + const ref = listVendorRef(dcInstance); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +export function useGetVendorById(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, true); + const ref = getVendorByIdRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +export function useFilterVendors(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, false); + const ref = filterVendorsRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} +export function useCreateEvent(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return createEventRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} 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 af43f031..c3717435 100644 --- a/internal-api-harness/src/dataconnect-generated/react/index.cjs.js +++ b/internal-api-harness/src/dataconnect-generated/react/index.cjs.js @@ -1,22 +1,8 @@ -const { listVendorRef, createEventRef, listEventsRef, createStaffRef, listStaffRef, createVendorRef, connectorConfig } = require('../index.cjs.js'); +const { listEventsRef, createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, connectorConfig } = require('../index.cjs.js'); const { validateArgs, CallerSdkTypeEnum } = require('firebase/data-connect'); const { useDataConnectQuery, useDataConnectMutation, validateReactArgs } = require('@tanstack-query-firebase/react/data-connect'); -exports.useListVendor = function useListVendor(dcOrOptions, options) { - const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); - const ref = listVendorRef(dcInstance); - return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); -} -exports.useCreateEvent = function useCreateEvent(dcOrOptions, options) { - const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); - function refFactory(vars) { - return createEventRef(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); @@ -43,3 +29,45 @@ exports.useCreateVendor = function useCreateVendor(dcOrOptions, options) { } return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); } + +exports.useUpdateVendor = function useUpdateVendor(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return updateVendorRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +exports.useDeleteVendor = function useDeleteVendor(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return deleteVendorRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + + +exports.useListVendor = function useListVendor(dcOrOptions, options) { + const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options); + const ref = listVendorRef(dcInstance); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +exports.useGetVendorById = function useGetVendorById(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, true); + const ref = getVendorByIdRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} + +exports.useFilterVendors = function useFilterVendors(dcOrVars, varsOrOptions, options) { + const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, false); + const ref = filterVendorsRef(dcInstance, inputVars); + return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} +exports.useCreateEvent = function useCreateEvent(dcOrOptions, options) { + const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options); + function refFactory(vars) { + return createEventRef(dcInstance, vars); + } + return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact); +} 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 be88d610..dd68f1e5 100644 --- a/internal-api-harness/src/dataconnect-generated/react/index.d.ts +++ b/internal-api-harness/src/dataconnect-generated/react/index.d.ts @@ -1,16 +1,10 @@ -import { ListVendorData, CreateEventData, CreateEventVariables, ListEventsData, CreateStaffData, CreateStaffVariables, ListStaffData, CreateVendorData, CreateVendorVariables } from '../'; +import { ListEventsData, CreateStaffData, CreateStaffVariables, ListStaffData, CreateVendorData, CreateVendorVariables, UpdateVendorData, UpdateVendorVariables, DeleteVendorData, DeleteVendorVariables, ListVendorData, GetVendorByIdData, GetVendorByIdVariables, FilterVendorsData, FilterVendorsVariables, CreateEventData, CreateEventVariables } 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 useListVendor(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; -export function useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; - -export function useCreateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; -export function useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; - export function useListEvents(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; export function useListEvents(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; @@ -22,3 +16,21 @@ export function useListStaff(dc: DataConnect, options?: useDataConnectQueryOptio export function useCreateVendor(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; export function useCreateVendor(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; + +export function useUpdateVendor(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +export function useUpdateVendor(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; + +export function useDeleteVendor(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +export function useDeleteVendor(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult; + +export function useListVendor(options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +export function useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; + +export function useGetVendorById(vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +export function useGetVendorById(dc: DataConnect, vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; + +export function useFilterVendors(vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; +export function useFilterVendors(dc: DataConnect, vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions): UseDataConnectQueryResult; + +export function useCreateEvent(options?: useDataConnectMutationOptions): UseDataConnectMutationResult; +export function useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions): UseDataConnectMutationResult;