Add watcher status and additional typing.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { UUID } from "crypto";
|
||||
import { parse, TypedQueryDocumentNode } from "graphql";
|
||||
import { gql } from "graphql-request";
|
||||
|
||||
import { AvailableJobSchema } from "../decoder/decoder";
|
||||
// Define types for the query result and variables
|
||||
export interface ActiveBodyshopQueryResult {
|
||||
bodyshops: Array<{
|
||||
@@ -9,10 +10,8 @@ export interface ActiveBodyshopQueryResult {
|
||||
region_config: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
// No variables needed for this query
|
||||
interface ActiveBodyshopQueryVariables {}
|
||||
|
||||
// Transform the string query into a TypedQueryDocumentNode
|
||||
export const QUERY_ACTIVE_BODYSHOP_TYPED: TypedQueryDocumentNode<
|
||||
ActiveBodyshopQueryResult,
|
||||
@@ -25,7 +24,10 @@ export const QUERY_ACTIVE_BODYSHOP_TYPED: TypedQueryDocumentNode<
|
||||
region_config
|
||||
}
|
||||
}
|
||||
`);
|
||||
`) as TypedQueryDocumentNode<
|
||||
ActiveBodyshopQueryResult,
|
||||
ActiveBodyshopQueryVariables
|
||||
>;
|
||||
|
||||
export interface MasterdataQueryResult {
|
||||
masterdata: Array<{
|
||||
@@ -33,11 +35,9 @@ export interface MasterdataQueryResult {
|
||||
key: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface MasterdataQueryVariables {
|
||||
key: string;
|
||||
}
|
||||
|
||||
export const QUERY_MASTERDATA_TYPED: TypedQueryDocumentNode<
|
||||
MasterdataQueryResult,
|
||||
MasterdataQueryVariables
|
||||
@@ -48,19 +48,16 @@ export const QUERY_MASTERDATA_TYPED: TypedQueryDocumentNode<
|
||||
key
|
||||
}
|
||||
}
|
||||
`);
|
||||
`) as TypedQueryDocumentNode<MasterdataQueryResult, MasterdataQueryVariables>;
|
||||
|
||||
export interface VehicleQueryResult {
|
||||
masterdata: Array<{
|
||||
value: string;
|
||||
key: string;
|
||||
vehicles: Array<{
|
||||
id: UUID;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface VehicleQueryVariables {
|
||||
vin: string;
|
||||
}
|
||||
|
||||
export const QUERY_VEHICLE_BY_VIN_TYPED: TypedQueryDocumentNode<
|
||||
VehicleQueryResult,
|
||||
VehicleQueryVariables
|
||||
@@ -70,4 +67,62 @@ export const QUERY_VEHICLE_BY_VIN_TYPED: TypedQueryDocumentNode<
|
||||
id
|
||||
}
|
||||
}
|
||||
`);
|
||||
`) as TypedQueryDocumentNode<VehicleQueryResult, VehicleQueryVariables>;
|
||||
|
||||
export interface QueryJobByClmNoResult {
|
||||
jobs: Array<{
|
||||
id: UUID;
|
||||
}>;
|
||||
}
|
||||
export interface QueryJobByClmNoVariables {
|
||||
clm_no: string;
|
||||
}
|
||||
export const QUERY_JOB_BY_CLM_NO_TYPED: TypedQueryDocumentNode<
|
||||
QueryJobByClmNoResult,
|
||||
QueryJobByClmNoVariables
|
||||
> = parse(gql`
|
||||
query QUERY_JOB_BY_CLM_NO($clm_no: String!) {
|
||||
jobs(where: { clm_no: { _eq: $clm_no } }) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`) as TypedQueryDocumentNode<QueryJobByClmNoResult, QueryJobByClmNoVariables>;
|
||||
|
||||
export interface InsertAvailableJobResult {
|
||||
returning: Array<{
|
||||
id: UUID;
|
||||
}>;
|
||||
}
|
||||
export interface InsertAvailableJobVariables {
|
||||
jobInput: Array<AvailableJobSchema>;
|
||||
}
|
||||
export const INSERT_AVAILABLE_JOB_TYPED: TypedQueryDocumentNode<
|
||||
InsertAvailableJobResult,
|
||||
InsertAvailableJobVariables
|
||||
> = parse(gql`
|
||||
mutation INSERT_AVAILABLE_JOB($jobInput: [available_jobs_insert_input!]!) {
|
||||
insert_available_jobs(
|
||||
objects: $jobInput
|
||||
on_conflict: {
|
||||
constraint: available_jobs_clm_no_bodyshopid_key
|
||||
update_columns: [
|
||||
clm_amt
|
||||
cieca_id
|
||||
est_data
|
||||
issupplement
|
||||
ownr_name
|
||||
source_system
|
||||
supplement_number
|
||||
vehicle_info
|
||||
]
|
||||
}
|
||||
) {
|
||||
returning {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`) as TypedQueryDocumentNode<
|
||||
InsertAvailableJobResult,
|
||||
InsertAvailableJobVariables
|
||||
>;
|
||||
|
||||
Reference in New Issue
Block a user