Apply Composer changes: comprehensive API updates, migrations, middleware, and infrastructure improvements

- Add comprehensive database migrations (001-024) for schema evolution
- Enhance API schema with expanded type definitions and resolvers
- Add new middleware: audit logging, rate limiting, MFA enforcement, security, tenant auth
- Implement new services: AI optimization, billing, blockchain, compliance, marketplace
- Add adapter layer for cloud integrations (Cloudflare, Kubernetes, Proxmox, storage)
- Update Crossplane provider with enhanced VM management capabilities
- Add comprehensive test suite for API endpoints and services
- Update frontend components with improved GraphQL subscriptions and real-time updates
- Enhance security configurations and headers (CSP, CORS, etc.)
- Update documentation and configuration files
- Add new CI/CD workflows and validation scripts
- Implement design system improvements and UI enhancements
This commit is contained in:
defiQUG
2025-12-12 18:01:35 -08:00
parent e01131efaf
commit 9daf1fd378
968 changed files with 160890 additions and 1092 deletions
+1
View File
@@ -1,4 +1,5 @@
export * from './useAuth'
export * from './useResources'
export * from './useSites'
export * from './useInfrastructure'
+187
View File
@@ -0,0 +1,187 @@
import { useQuery, useMutation } from '@apollo/client'
import {
GET_COUNTRIES,
GET_COUNTRY,
GET_NETWORK_TOPOLOGIES,
GET_NETWORK_TOPOLOGY,
GET_COMPLIANCE_REQUIREMENTS,
GET_COMPLIANCE_REQUIREMENT,
GET_DEPLOYMENT_MILESTONES,
GET_DEPLOYMENT_MILESTONE,
GET_COST_ESTIMATES,
GET_COST_ESTIMATE,
GET_INFRASTRUCTURE_SUMMARY,
UPDATE_NETWORK_TOPOLOGY,
CREATE_DEPLOYMENT_MILESTONE,
UPDATE_DEPLOYMENT_MILESTONE,
DELETE_DEPLOYMENT_MILESTONE,
UPDATE_COMPLIANCE_REQUIREMENT,
UPDATE_COST_ESTIMATE,
} from '../queries/infrastructure'
export function useCountries(filter?: {
region?: string
priority?: string
relationshipType?: string
}) {
return useQuery(GET_COUNTRIES, {
variables: { filter },
fetchPolicy: 'cache-and-network',
})
}
export function useCountry(name: string) {
return useQuery(GET_COUNTRY, {
variables: { name },
skip: !name,
})
}
export function useNetworkTopologies(filter?: { region?: string; entity?: string }) {
return useQuery(GET_NETWORK_TOPOLOGIES, {
variables: { filter },
fetchPolicy: 'cache-and-network',
})
}
export function useNetworkTopology(id: string) {
return useQuery(GET_NETWORK_TOPOLOGY, {
variables: { id },
skip: !id,
})
}
export function useComplianceRequirements(filter?: {
country?: string
region?: string
status?: string
framework?: string
}) {
return useQuery(GET_COMPLIANCE_REQUIREMENTS, {
variables: { filter },
fetchPolicy: 'cache-and-network',
})
}
export function useComplianceRequirement(country: string) {
return useQuery(GET_COMPLIANCE_REQUIREMENT, {
variables: { country },
skip: !country,
})
}
export function useDeploymentMilestones(filter?: {
region?: string
entity?: string
priority?: string
status?: string
}) {
return useQuery(GET_DEPLOYMENT_MILESTONES, {
variables: { filter },
fetchPolicy: 'cache-and-network',
})
}
export function useDeploymentMilestone(id: string) {
return useQuery(GET_DEPLOYMENT_MILESTONE, {
variables: { id },
skip: !id,
})
}
export function useCostEstimates(filter?: {
region?: string
entity?: string
category?: string
}) {
return useQuery(GET_COST_ESTIMATES, {
variables: { filter },
fetchPolicy: 'cache-and-network',
})
}
export function useCostEstimate(region: string, entity: string, category: string) {
return useQuery(GET_COST_ESTIMATE, {
variables: { region, entity, category },
skip: !region || !entity || !category,
})
}
export function useInfrastructureSummary() {
return useQuery(GET_INFRASTRUCTURE_SUMMARY, {
fetchPolicy: 'cache-and-network',
})
}
export function useUpdateNetworkTopology() {
const [mutate, { loading, error }] = useMutation(UPDATE_NETWORK_TOPOLOGY, {
refetchQueries: [{ query: GET_NETWORK_TOPOLOGIES }],
})
return {
updateTopology: mutate,
loading,
error,
}
}
export function useCreateDeploymentMilestone() {
const [mutate, { loading, error }] = useMutation(CREATE_DEPLOYMENT_MILESTONE, {
refetchQueries: [{ query: GET_DEPLOYMENT_MILESTONES }],
})
return {
createMilestone: mutate,
loading,
error,
}
}
export function useUpdateDeploymentMilestone() {
const [mutate, { loading, error }] = useMutation(UPDATE_DEPLOYMENT_MILESTONE, {
refetchQueries: [{ query: GET_DEPLOYMENT_MILESTONES }],
})
return {
updateMilestone: mutate,
loading,
error,
}
}
export function useDeleteDeploymentMilestone() {
const [mutate, { loading, error }] = useMutation(DELETE_DEPLOYMENT_MILESTONE, {
refetchQueries: [{ query: GET_DEPLOYMENT_MILESTONES }],
})
return {
deleteMilestone: mutate,
loading,
error,
}
}
export function useUpdateComplianceRequirement() {
const [mutate, { loading, error }] = useMutation(UPDATE_COMPLIANCE_REQUIREMENT, {
refetchQueries: [{ query: GET_COMPLIANCE_REQUIREMENTS }],
})
return {
updateCompliance: mutate,
loading,
error,
}
}
export function useUpdateCostEstimate() {
const [mutate, { loading, error }] = useMutation(UPDATE_COST_ESTIMATE, {
refetchQueries: [{ query: GET_COST_ESTIMATES }],
})
return {
updateCostEstimate: mutate,
loading,
error,
}
}
@@ -0,0 +1,110 @@
'use client'
import { useSubscription } from '@apollo/client'
import { gql } from 'graphql-tag'
import { useEffect } from 'react'
import { useQueryClient } from '@tanstack/react-query'
const RESOURCE_CREATED_SUBSCRIPTION = gql`
subscription ResourceCreated {
resourceCreated {
id
name
type
status
site {
id
name
}
createdAt
}
}
`
const RESOURCE_UPDATED_SUBSCRIPTION = gql`
subscription ResourceUpdated($id: ID!) {
resourceUpdated(id: $id) {
id
name
type
status
metadata
updatedAt
}
}
`
const RESOURCE_DELETED_SUBSCRIPTION = gql`
subscription ResourceDeleted($id: ID!) {
resourceDeleted(id: $id)
}
`
export function useResourceCreated() {
const queryClient = useQueryClient()
const { data, error } = useSubscription(RESOURCE_CREATED_SUBSCRIPTION)
useEffect(() => {
if (data?.resourceCreated) {
// Invalidate queries to refetch updated data
queryClient.invalidateQueries({ queryKey: ['resources'] })
// Optionally show toast notification
if (typeof window !== 'undefined' && (window as any).toast) {
;(window as any).toast({
title: 'New Resource Created',
description: `${data.resourceCreated.name} has been created`,
})
}
}
}, [data, queryClient])
return { data: data?.resourceCreated, error }
}
export function useResourceUpdated(resourceId: string) {
const queryClient = useQueryClient()
const { data, error } = useSubscription(RESOURCE_UPDATED_SUBSCRIPTION, {
variables: { id: resourceId },
skip: !resourceId,
})
useEffect(() => {
if (data?.resourceUpdated) {
// Invalidate specific resource and list queries
queryClient.invalidateQueries({ queryKey: ['resources'] })
queryClient.invalidateQueries({ queryKey: ['resource', resourceId] })
}
}, [data, queryClient, resourceId])
return { data: data?.resourceUpdated, error }
}
export function useResourceDeleted(resourceId: string) {
const queryClient = useQueryClient()
const { data, error } = useSubscription(RESOURCE_DELETED_SUBSCRIPTION, {
variables: { id: resourceId },
skip: !resourceId,
})
useEffect(() => {
if (data?.resourceDeleted) {
// Remove from cache and invalidate queries
queryClient.removeQueries({ queryKey: ['resource', resourceId] })
queryClient.invalidateQueries({ queryKey: ['resources'] })
if (typeof window !== 'undefined' && (window as any).toast) {
;(window as any).toast({
title: 'Resource Deleted',
description: 'Resource has been deleted',
})
}
}
}, [data, queryClient, resourceId])
return { deletedId: data?.resourceDeleted, error }
}
+87
View File
@@ -0,0 +1,87 @@
import { useSubscription } from '@apollo/client'
import {
RESOURCE_UPDATED,
METRICS_UPDATED,
HEALTH_CHANGED,
FINDING_CREATED,
RISK_CREATED,
} from '../subscriptions'
/**
* Hook for subscribing to resource updates
*/
export function useResourceUpdate(resourceId: string) {
const { data, loading, error } = useSubscription(RESOURCE_UPDATED, {
variables: { resourceId },
skip: !resourceId,
})
return {
resource: data?.resourceUpdated,
loading,
error,
}
}
/**
* Hook for subscribing to metrics updates
*/
export function useMetricsUpdate(resourceId: string, metricType: string) {
const { data, loading, error } = useSubscription(METRICS_UPDATED, {
variables: { resourceId, metricType },
skip: !resourceId || !metricType,
})
return {
metric: data?.metricsUpdated,
loading,
error,
}
}
/**
* Hook for subscribing to health changes
*/
export function useHealthChange(resourceId: string) {
const { data, loading, error } = useSubscription(HEALTH_CHANGED, {
variables: { resourceId },
skip: !resourceId,
})
return {
health: data?.healthChanged,
loading,
error,
}
}
/**
* Hook for subscribing to new findings
*/
export function useFindingCreated(controlId?: string) {
const { data, loading, error } = useSubscription(FINDING_CREATED, {
variables: { controlId: controlId || null },
})
return {
finding: data?.findingCreated,
loading,
error,
}
}
/**
* Hook for subscribing to new risks
*/
export function useRiskCreated(resourceId?: string) {
const { data, loading, error } = useSubscription(RISK_CREATED, {
variables: { resourceId: resourceId || null },
})
return {
risk: data?.riskCreated,
loading,
error,
}
}