diff --git a/apps/hpc-ftsadmin/src/app/components/tables/organizations-table.tsx b/apps/hpc-ftsadmin/src/app/components/tables/organizations-table.tsx index bff28d0f..ee2cd994 100644 --- a/apps/hpc-ftsadmin/src/app/components/tables/organizations-table.tsx +++ b/apps/hpc-ftsadmin/src/app/components/tables/organizations-table.tsx @@ -141,7 +141,7 @@ export default function OrganizationTable(props: OrganizationTableProps) { data, }: { lang: LanguageKey; - data: organizations.SearchOrnganizationResult; + data: organizations.SearchOrganizationResult; }) => { const nonSafeTypedTableHeaders = decodeTableHeaders( query.tableHeaders, @@ -290,7 +290,7 @@ export default function OrganizationTable(props: OrganizationTableProps) { data, }: { lang: LanguageKey; - data: organizations.SearchOrnganizationResult; + data: organizations.SearchOrganizationResult; }) => { const nonSafeTypedTableHeaders = decodeTableHeaders( query.tableHeaders, diff --git a/libs/hpc-data/src/lib/categories.ts b/libs/hpc-data/src/lib/categories.ts index c93cb910..6fcb3d9a 100644 --- a/libs/hpc-data/src/lib/categories.ts +++ b/libs/hpc-data/src/lib/categories.ts @@ -43,15 +43,7 @@ export const CATEGORY = t.type({ export type Category = t.TypeOf; export const KEYWORD = t.type({ - id: t.number, - name: t.string, - description: t.union([t.string, t.null]), - parentID: t.union([t.number, t.null]), - code: t.union([t.string, t.null]), - group: t.string, - includeTotals: t.union([t.boolean, t.null]), - createdAt: t.string, - updatedAt: t.string, + ...CATEGORY.props, refCount: t.string, }); diff --git a/libs/hpc-data/src/lib/emergencies.ts b/libs/hpc-data/src/lib/emergencies.ts index 73e0c96e..4f9ef26c 100644 --- a/libs/hpc-data/src/lib/emergencies.ts +++ b/libs/hpc-data/src/lib/emergencies.ts @@ -1,6 +1,6 @@ import * as t from 'io-ts'; -const EMERGENCY = t.type({ +export const EMERGENCY = t.type({ id: t.number, name: t.string, description: t.union([t.string, t.null]), diff --git a/libs/hpc-data/src/lib/flows.ts b/libs/hpc-data/src/lib/flows.ts index be6bcfc4..1dfe9f2d 100644 --- a/libs/hpc-data/src/lib/flows.ts +++ b/libs/hpc-data/src/lib/flows.ts @@ -33,7 +33,7 @@ const FLOW_OBJECT = t.intersection([ export type FlowObject = t.TypeOf; -const FLOW_CATEGORY = t.intersection([ +const FLOW_CATEGORY_REST = t.intersection([ t.type({ name: t.string, group: t.string, @@ -56,7 +56,7 @@ const FLOW_CATEGORY = t.intersection([ }), }), ]); -export type FlowCategory = t.TypeOf; +export type FlowCategory = t.TypeOf; const CREATED_BY_OR_LAST_UPDATED_BY = t.type({ name: t.string, @@ -117,30 +117,30 @@ export const GET_FLOW_RESULT = FLOW_REST; export type GetFlowResult = t.TypeOf; -// GRAPHQL CODE FROM HERE +// * GRAPHQL CODE FROM HERE * const DIRECTION = t.union([t.literal('source'), t.literal('destination')]); -const FlowLocation = t.type({ +const FLOW_LOCATION = t.type({ id: t.number, name: t.string, direction: DIRECTION, }); -const FlowOrganization = t.type({ +const FLOW_ORGANIZATION = t.type({ id: t.number, direction: t.union([t.string, t.null, t.undefined]), // Accepts string or null/undefined name: t.string, abbreviation: t.string, }); -export type FlowOrganization = t.TypeOf; -const FlowUsageYear = t.type({ +export type FlowOrganization = t.TypeOf; +const FLOW_USAGE_YEAR = t.type({ year: t.string, direction: DIRECTION, }); -const FlowExternalReference = t.type({ +const FLOW_EXTERNAL_REFERENCE = t.type({ systemID: t.string, flowID: t.number, externalRecordID: t.string, @@ -148,26 +148,32 @@ const FlowExternalReference = t.type({ updatedAt: t.string, }); -const FlowReportDetail = t.type({ - id: t.number, - versionID: t.number, - source: t.string, - date: t.union([t.string, t.null]), - verified: t.boolean, - channel: t.union([t.string, t.null]), - updatedAt: t.string, - contactInfo: t.union([t.string, t.null, t.undefined]), // accepts string or null/undefined - sourceID: t.union([t.string, t.null, t.undefined]), // accepts string or null/undefined - refCode: t.union([t.string, t.null, t.undefined]), // accepts string or null/undefined - organizationID: t.union([t.number, t.null, t.undefined]), // accepts number or null/undefined -}); +const FLOW_REPORT_DETAIL = t.intersection([ + t.type({ + id: t.number, + versionID: t.number, + source: t.string, + verified: t.boolean, + updatedAt: t.string, + createdAt: t.string, + }), + t.partial({ + flowID: t.number, + date: t.union([t.string, t.null]), + channel: t.union([t.string, t.null]), + contactInfo: t.union([t.string, t.null]), + sourceID: t.union([t.string, t.null]), + refCode: t.union([t.string, t.null]), + organizationID: t.number, + }), +]); -const FlowParkedParentSource = t.type({ +const FLOW_PARKED_PARENT_SOURCE = t.type({ organization: t.array(t.number), orgName: t.array(t.string), }); -const FlowCategoryRef = t.type({ +const FLOW_CATEGORY_REF = t.type({ objectID: t.number, versionID: t.number, objectType: t.string, @@ -175,49 +181,61 @@ const FlowCategoryRef = t.type({ updatedAt: t.string, }); -const FlowCategory = t.type({ - id: t.number, - name: t.string, - group: t.string, - createdAt: t.union([t.string, t.null, t.undefined]), // accepts string or null/undefined - updatedAt: t.union([t.string, t.null, t.undefined]), // accepts string or null/undefined - description: t.union([t.string, t.null, t.undefined]), // accepts string or null/undefined - parentID: t.union([t.number, t.null, t.undefined]), // accepts number or null/undefined - code: t.union([t.string, t.null, t.undefined]), // accepts string or null/undefined - includeTotals: t.union([t.boolean, t.null, t.undefined]), // accepts boolean or null/undefined - categoryRef: FlowCategoryRef, -}); +const FLOW_CATEGORY = t.intersection([ + t.type({ + id: t.number, + name: t.string, + group: t.string, + categoryRef: FLOW_CATEGORY_REF, + }), + t.partial({ + createdAt: t.string, + updatedAt: t.string, + description: t.string, + parentID: t.union([t.number, t.null]), + code: t.union([t.string, t.null]), + includeTotals: t.union([t.boolean, t.null]), + }), +]); -const FlowPlan = t.type({ +const FLOW_PLAN = t.type({ id: t.number, name: t.string, direction: DIRECTION, }); -const FLOW = t.type({ - id: t.number, - versionID: t.number, - amountUSD: t.string, - updatedAt: t.string, - activeStatus: t.boolean, - restricted: t.boolean, - locations: t.union([t.array(FlowLocation), t.null, t.undefined]), - categories: t.union([t.array(FlowCategory), t.null, t.undefined]), - organizations: t.union([t.array(FlowOrganization), t.null, t.undefined]), - plans: t.union([t.array(FlowPlan), t.null, t.undefined]), - usageYears: t.union([t.array(FlowUsageYear), t.null, t.undefined]), - childIDs: t.union([t.array(t.number), t.null, t.undefined]), - parentIDs: t.union([t.array(t.number), t.null, t.undefined]), // accepts an array of numbers or null/undefined - origAmount: t.union([t.string, t.null, t.undefined]), // accepts string or null/undefined - origCurrency: t.union([t.string, t.null, t.undefined]), // accepts string or null/undefined - externalReferences: t.array(FlowExternalReference), - reportDetails: t.array(FlowReportDetail), - parkedParentSource: t.union([FlowParkedParentSource, t.null]), - newMoney: t.union([t.boolean, t.null]), - decisionDate: t.union([t.string, t.null]), - flowDate: t.union([t.string, t.null]), - exchangeRate: t.union([t.string, t.null]), -}); +export const FLOW = t.intersection([ + t.type({ + id: t.number, + versionID: t.number, + amountUSD: t.string, + updatedAt: t.string, + activeStatus: t.boolean, + restricted: t.boolean, + externalReferences: t.array(FLOW_EXTERNAL_REFERENCE), + reportDetails: t.array(FLOW_REPORT_DETAIL), + newMoney: t.union([t.boolean, t.null]), + decisionDate: t.union([t.string, t.null]), + flowDate: t.union([t.string, t.null]), + exchangeRate: t.union([t.string, t.null]), + parkedParentSource: t.union([FLOW_PARKED_PARENT_SOURCE, t.null]), + }), + t.partial({ + description: t.string, + budgetYear: t.string, + locations: t.union([t.array(FLOW_LOCATION), t.null]), + categories: t.union([t.array(FLOW_CATEGORY), t.null]), + organizations: t.union([t.array(FLOW_ORGANIZATION), t.null]), + destinationOrganizations: t.union([t.array(FLOW_ORGANIZATION), t.null]), + sourceOrganizations: t.union([t.array(FLOW_ORGANIZATION), t.null]), + plans: t.union([t.array(FLOW_PLAN), t.null]), + usageYears: t.union([t.array(FLOW_USAGE_YEAR), t.null]), + childIDs: t.union([t.array(t.number), t.null]), + parentIDs: t.union([t.array(t.number), t.null]), + origAmount: t.union([t.string, t.null]), + origCurrency: t.union([t.string, t.null]), + }), +]); const FLOW_RESULT = t.array(FLOW); export type Flow = t.TypeOf; diff --git a/libs/hpc-data/src/lib/global-clusters.ts b/libs/hpc-data/src/lib/global-clusters.ts index e3e588d5..2b91bec4 100644 --- a/libs/hpc-data/src/lib/global-clusters.ts +++ b/libs/hpc-data/src/lib/global-clusters.ts @@ -1,6 +1,6 @@ import * as t from 'io-ts'; -const GLOBAL_CLUSTER = t.type({ +export const GLOBAL_CLUSTER = t.type({ id: t.number, hrinfoId: t.union([t.number, t.null]), type: t.string, diff --git a/libs/hpc-data/src/lib/organizations.ts b/libs/hpc-data/src/lib/organizations.ts index e4819afa..057324b2 100644 --- a/libs/hpc-data/src/lib/organizations.ts +++ b/libs/hpc-data/src/lib/organizations.ts @@ -88,10 +88,10 @@ const SEARCH_ORGANIZATION = t.type({ create: t.array(UPDATED_CREATED_BY), update: t.array(UPDATED_CREATED_BY), }); -export type SearchOrganiation = t.TypeOf; +export type SearchOrganization = t.TypeOf; export const SEARCH_ORGANIZATIONS = t.array(SEARCH_ORGANIZATION); -export type SearchOrganiations = t.TypeOf; +export type SearchOrganizations = t.TypeOf; export const GET_ORGANIZATIONS_AUTOCOMPLETE_PARAMS = t.type({ query: t.string, @@ -136,7 +136,7 @@ export const SEARCH_ORGANIZATION_RESULT = t.type({ organizations: SEARCH_ORGANIZATIONS, }); -export type SearchOrnganizationResult = t.TypeOf< +export type SearchOrganizationResult = t.TypeOf< typeof SEARCH_ORGANIZATION_RESULT >; @@ -161,7 +161,7 @@ export const CREATE_ORGANIZATION_PARAMS = t.type({ url: t.string, notes: t.string, comments: t.string, - verfied: t.boolean, + verified: t.boolean, parentID: t.number, }), ]), @@ -252,7 +252,7 @@ export interface Model { ): Promise; searchOrganizations( params: SearchOrganizationParams - ): Promise; + ): Promise; getOrganization( params: GetOrganizationParams ): Promise; diff --git a/libs/hpc-data/src/lib/projects.ts b/libs/hpc-data/src/lib/projects.ts index 4073a28f..e3cc5162 100644 --- a/libs/hpc-data/src/lib/projects.ts +++ b/libs/hpc-data/src/lib/projects.ts @@ -21,7 +21,7 @@ const PDF = t.type({ ]), }); -const PROJECT = t.type({ +export const PROJECT = t.type({ id: t.number, createdAt: t.string, updatedAt: t.string, diff --git a/libs/hpc-dummy/src/lib/dummy.ts b/libs/hpc-dummy/src/lib/dummy.ts index ae9cab0c..7817fdb7 100644 --- a/libs/hpc-dummy/src/lib/dummy.ts +++ b/libs/hpc-dummy/src/lib/dummy.ts @@ -1127,7 +1127,7 @@ export class Dummy { ), searchOrganizations: dummyEndpoint( 'organizations.searchOrganizations', - async (): Promise => { + async (): Promise => { return { count: '1', organizations: [