Skip to content

Commit

Permalink
fix: Refactor validators package
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachoudhari26 committed Nov 14, 2024
1 parent 306ed5c commit f4976fe
Show file tree
Hide file tree
Showing 43 changed files with 57 additions and 57 deletions.
2 changes: 1 addition & 1 deletion apps/event-worker/src/target-scan/google.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { KubernetesClusterAPIV1 } from "@ctrlplane/validators/targets";
import type { KubernetesClusterAPIV1 } from "@ctrlplane/validators/resources";
import type { ClusterManagerClient } from "@google-cloud/container";
import type { google } from "@google-cloud/container/build/protos/protos.js";
import type { AuthClient } from "google-auth-library";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
Expand All @@ -21,7 +21,7 @@ import {
TooltipProvider,
TooltipTrigger,
} from "@ctrlplane/ui/tooltip";
import { ResourceFilterType } from "@ctrlplane/validators/targets";
import { ResourceFilterType } from "@ctrlplane/validators/resources";

import { api } from "~/trpc/server";
import { ProviderActionsDropdown } from "./ProviderActionsDropdown";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import type * as schema from "@ctrlplane/db/schema";
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import React from "react";
import { IconDots, IconFilter, IconLoader2 } from "@tabler/icons-react";
import range from "lodash/range";
Expand All @@ -12,7 +12,7 @@ import { Skeleton } from "@ctrlplane/ui/skeleton";
import {
defaultCondition,
isEmptyCondition,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import { NoFilterMatch } from "~/app/[workspaceSlug]/_components/filter/NoFilterMatch";
import { TargetConditionBadge } from "~/app/[workspaceSlug]/_components/target-condition/TargetConditionBadge";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as SCHEMA from "@ctrlplane/db/schema";
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import { useState } from "react";
import Link from "next/link";
import { useParams } from "next/navigation";
Expand Down Expand Up @@ -38,7 +38,7 @@ import {
defaultCondition,
isComparisonCondition,
resourceCondition,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import { api } from "~/trpc/react";
import { TargetConditionRender } from "../target-condition/TargetConditionRender";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { JobTargetCondition } from "@ctrlplane/validators/jobs";
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import { useState } from "react";
import { useParams } from "next/navigation";
import { IconLoader2, IconSelector } from "@tabler/icons-react";
Expand All @@ -23,7 +23,7 @@ import {
import {
ResourceFilterType,
ResourceOperator,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import type { JobConditionRenderProps } from "./job-condition-props";
import { api } from "~/trpc/react";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
ComparisonCondition,
ResourceCondition,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";
import {
IconChevronDown,
IconCopy,
Expand Down Expand Up @@ -36,7 +36,7 @@ import {
isComparisonCondition,
ResourceFilterType,
ResourceOperator,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import type { TargetConditionRenderProps } from "./target-condition-props";
import { TargetConditionRender } from "./TargetConditionRender";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ColumnOperatorType } from "@ctrlplane/validators/conditions";
import type { IdentifierCondition } from "@ctrlplane/validators/targets";
import type { IdentifierCondition } from "@ctrlplane/validators/resources";

import type { TargetConditionRenderProps } from "./target-condition-props";
import { ColumnConditionRender } from "../filter/ColumnConditionRender";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { KindCondition } from "@ctrlplane/validators/targets";
import type { KindCondition } from "@ctrlplane/validators/resources";
import { useParams } from "next/navigation";

import type { TargetConditionRenderProps } from "./target-condition-props";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NameCondition } from "@ctrlplane/validators/targets";
import type { NameCondition } from "@ctrlplane/validators/resources";

import { cn } from "@ctrlplane/ui";
import { Input } from "@ctrlplane/ui/input";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ProviderCondition } from "@ctrlplane/validators/targets";
import type { ProviderCondition } from "@ctrlplane/validators/resources";
import { useParams } from "next/navigation";

import type { TargetConditionRenderProps } from "./target-condition-props";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
NameCondition,
ProviderCondition,
ResourceCondition,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";
import React from "react";
import _ from "lodash";

Expand All @@ -25,7 +25,7 @@ import {
isNameCondition,
isProviderCondition,
ResourceOperator,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import { api } from "~/trpc/react";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as schema from "@ctrlplane/db/schema";
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import React, { useState } from "react";
import { useRouter } from "next/navigation";

Expand All @@ -18,7 +18,7 @@ import {
defaultCondition,
isValidTargetCondition,
MAX_DEPTH_ALLOWED,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import type { TargetViewFormSchema } from "./TargetViewForm";
import { api } from "~/trpc/react";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import React from "react";

import {
Expand All @@ -8,7 +8,7 @@ import {
isMetadataCondition,
isNameCondition,
isProviderCondition,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import type { TargetConditionRenderProps } from "./target-condition-props";
import { ComparisonConditionRender } from "./ComparisonConditionRender";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
defaultCondition,
isValidTargetCondition,
resourceCondition,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import { TargetConditionRender } from "./TargetConditionRender";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";

export type TargetConditionRenderProps<T extends ResourceCondition> = {
condition: T;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as schema from "@ctrlplane/db/schema";
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import { useCallback, useMemo } from "react";
import { useRouter, useSearchParams } from "next/navigation";
import LZString from "lz-string";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import type * as schema from "@ctrlplane/db/schema";
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import React from "react";
import Link from "next/link";
import { useParams } from "next/navigation";
Expand All @@ -19,7 +19,7 @@ import {
import {
ResourceFilterType,
ResourceOperator,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import { DeleteSystemDialog } from "./[systemSlug]/_components/DeleteSystemDialog";
import { EditSystemDialog } from "./[systemSlug]/_components/EditSystemDialog";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import type {
BooleanVariableConfigType,
ChoiceVariableConfigType,
Expand All @@ -26,7 +26,7 @@ import { Textarea } from "@ctrlplane/ui/textarea";
import {
defaultCondition,
isEmptyCondition,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import { TargetConditionBadge } from "~/app/[workspaceSlug]/_components/target-condition/TargetConditionBadge";
import { TargetConditionDialog } from "~/app/[workspaceSlug]/_components/target-condition/TargetConditionDialog";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import type {
ChoiceVariableConfigType,
StringVariableConfigType,
Expand Down Expand Up @@ -28,7 +28,7 @@ import { Textarea } from "@ctrlplane/ui/textarea";
import {
ResourceFilterType,
ResourceOperator,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import { api } from "~/trpc/react";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Deployment } from "@ctrlplane/db/schema";
import type {
ComparisonCondition,
ResourceCondition,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";
import React from "react";
import { notFound } from "next/navigation";
import LZString from "lz-string";
Expand All @@ -12,7 +12,7 @@ import { Card } from "@ctrlplane/ui/card";
import {
ResourceFilterType,
ResourceOperator,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import { api } from "~/trpc/server";
import { EditDeploymentSection } from "./EditDeploymentSection";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
defaultCondition,
isValidTargetCondition,
resourceCondition,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import type { VariableValue } from "./variable-data";
import { TargetConditionRender } from "~/app/[workspaceSlug]/_components/target-condition/TargetConditionRender";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type {
ComparisonCondition,
ResourceCondition,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";
import { notFound } from "next/navigation";
import LZString from "lz-string";
import { isPresent } from "ts-is-present";

import {
ResourceFilterType,
ResourceOperator,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import { api } from "~/trpc/server";
import { VariableTable } from "./VariableTable";
Expand Down
4 changes: 2 additions & 2 deletions integrations/google-compute-scanner/src/gke.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { KubernetesClusterAPIV1 } from "@ctrlplane/validators/targets";
import type { KubernetesClusterAPIV1 } from "@ctrlplane/validators/resources";
import type { google } from "@google-cloud/container/build/protos/protos.js";
import type { V1Namespace } from "@kubernetes/client-node";
import Container from "@google-cloud/container";
Expand All @@ -9,7 +9,7 @@ import { SemVer } from "semver";

import { logger } from "@ctrlplane/logger";
import { ReservedMetadataKey } from "@ctrlplane/validators/conditions";
import { kubernetesNamespaceV1 } from "@ctrlplane/validators/targets";
import { kubernetesNamespaceV1 } from "@ctrlplane/validators/resources";

import { env } from "./config.js";
import { connectToCluster } from "./gke-connect.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/router/deployment-variable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DeploymentVariableValue } from "@ctrlplane/db/schema";
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import _ from "lodash";
import { isPresent } from "ts-is-present";
import { z } from "zod";
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/router/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from "@ctrlplane/job-dispatch";
import { variablesAES256 } from "@ctrlplane/secrets";
import { Permission } from "@ctrlplane/validators/auth";
import { resourceCondition } from "@ctrlplane/validators/targets";
import { resourceCondition } from "@ctrlplane/validators/resources";

import { createTRPCRouter, protectedProcedure } from "../trpc";
import { resourceMetadataGroupRouter } from "./target-metadata-group";
Expand Down
4 changes: 2 additions & 2 deletions packages/db/src/schema/deployment-variables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import type { VariableConfigType } from "@ctrlplane/validators/variables";
import type { InferInsertModel, InferSelectModel } from "drizzle-orm";
import type { AnyPgColumn, ColumnsWithTable } from "drizzle-orm/pg-core";
Expand All @@ -14,7 +14,7 @@ import {
import { createInsertSchema } from "drizzle-zod";
import { z } from "zod";

import { resourceCondition } from "@ctrlplane/validators/targets";
import { resourceCondition } from "@ctrlplane/validators/resources";
import { VariableConfig } from "@ctrlplane/validators/variables";

import { deployment } from "./deployment.js";
Expand Down
4 changes: 2 additions & 2 deletions packages/db/src/schema/environment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import type { InferSelectModel } from "drizzle-orm";
import { relations, sql } from "drizzle-orm";
import {
Expand All @@ -18,7 +18,7 @@ import { z } from "zod";
import {
isValidTargetCondition,
resourceCondition,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import { user } from "./auth.js";
import { deployment } from "./deployment.js";
Expand Down
4 changes: 2 additions & 2 deletions packages/db/src/schema/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { MetadataCondition } from "@ctrlplane/validators/conditions";
import type {
IdentifierCondition,
ResourceCondition,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";
import type { InferInsertModel, InferSelectModel, SQL } from "drizzle-orm";
import { exists, like, not, notExists, or, relations, sql } from "drizzle-orm";
import {
Expand All @@ -28,7 +28,7 @@ import {
import {
resourceCondition,
ResourceFilterType,
} from "@ctrlplane/validators/targets";
} from "@ctrlplane/validators/resources";

import type { Tx } from "../common.js";
import { resourceProvider } from "./resource-provider.js";
Expand Down
4 changes: 2 additions & 2 deletions packages/events/src/triggers/deployment-deleted.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { HookEvent } from "@ctrlplane/validators/events";
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import { isPresent } from "ts-is-present";

import { eq, isNotNull } from "@ctrlplane/db";
import { db } from "@ctrlplane/db/client";
import * as SCHEMA from "@ctrlplane/db/schema";
import { ComparisonOperator } from "@ctrlplane/validators/conditions";
import { ResourceFilterType } from "@ctrlplane/validators/targets";
import { ResourceFilterType } from "@ctrlplane/validators/resources";

export const getEventsForDeploymentDeleted = async (
deployment: SCHEMA.Deployment,
Expand Down
4 changes: 2 additions & 2 deletions packages/events/src/triggers/environment-deleted.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { HookEvent } from "@ctrlplane/validators/events";
import type { ResourceCondition } from "@ctrlplane/validators/targets";
import type { ResourceCondition } from "@ctrlplane/validators/resources";
import { isPresent } from "ts-is-present";

import { and, eq, inArray, isNotNull, ne } from "@ctrlplane/db";
import { db } from "@ctrlplane/db/client";
import * as SCHEMA from "@ctrlplane/db/schema";
import { ComparisonOperator } from "@ctrlplane/validators/conditions";
import { ResourceFilterType } from "@ctrlplane/validators/targets";
import { ResourceFilterType } from "@ctrlplane/validators/resources";

export const getEventsForEnvironmentDeleted = async (
environment: SCHEMA.Environment,
Expand Down
Loading

0 comments on commit f4976fe

Please sign in to comment.