Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const operatorVerbs = {
is <span className="text-orange-500">null</span>
</span>
),
[DeploymentVersionOperator.Regex]: "matches",
[DeploymentVersionOperator.Like]: "contains",
[DateOperator.After]: "after",
[DateOperator.Before]: "before",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@ export const ColumnConditionRender: React.FC<ColumnConditionRenderProps> = ({
Starts with
</SelectItem>
<SelectItem value={ColumnOperator.EndsWith}>Ends with</SelectItem>
<SelectItem value={ColumnOperator.Regex}>Regex</SelectItem>
</SelectContent>
</Select>
</div>
<div className="col-span-7">
<Input
placeholder={
operator === ColumnOperator.Regex ? "^[a-zA-Z]+$" : "Value"
}
placeholder="Value"
value={value}
onChange={(e) => setValue(e.target.value)}
className="w-full cursor-pointer rounded-l-none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export const MetadataConditionRender: React.FC<
onValueChange={(
v:
| MetadataOperator.Equals
| MetadataOperator.Regex
| MetadataOperator.Null
| MetadataOperator.StartsWith
| MetadataOperator.EndsWith
Expand All @@ -110,7 +109,6 @@ export const MetadataConditionRender: React.FC<
</SelectTrigger>
<SelectContent className="text-muted-foreground">
<SelectItem value={MetadataOperator.Equals}>Equals</SelectItem>
<SelectItem value={MetadataOperator.Regex}>Regex</SelectItem>
<SelectItem value={MetadataOperator.StartsWith}>
Starts with
</SelectItem>
Expand All @@ -128,11 +126,7 @@ export const MetadataConditionRender: React.FC<
{condition.operator !== MetadataOperator.Null ? (
<div className="col-span-4">
<Input
placeholder={
condition.operator === MetadataOperator.Regex
? "^[a-zA-Z]+$"
: "Value"
}
placeholder="Value"
value={condition.value}
onChange={(e) => setValue(e.target.value)}
className="rounded-l-none rounded-r-sm hover:bg-neutral-800/50"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const operatorVerbs = {
is <span className="text-orange-500">null</span>
</span>
),
[MetadataOperator.Regex]: "matches",
[DateOperator.After]: "after",
[DateOperator.Before]: "before",
[DateOperator.AfterOrOn]: "after or on",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const operatorVerbs = {
is <span className="text-orange-500">null</span>
</span>
),
[ResourceOperator.Regex]: "matches",
[ResourceOperator.Like]: "contains",
[ColumnOperator.StartsWith]: "starts with",
[ColumnOperator.EndsWith]: "ends with",
Expand Down
19 changes: 1 addition & 18 deletions packages/db/src/schema/deployment-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,6 @@ const buildMetadataCondition = (tx: Tx, cond: MetadataCondition): SQL => {
.limit(1),
);

if (cond.operator === MetadataOperator.Regex)
return exists(
tx
.select({ value: sql<number>`1` })
.from(deploymentVersionMetadata)
.where(
and(
eq(deploymentVersionMetadata.versionId, deploymentVersion.id),
eq(deploymentVersionMetadata.key, cond.key),
sql`${deploymentVersionMetadata.value} ~ ${cond.value}`,
),
)
.limit(1),
);

if (cond.operator === MetadataOperator.StartsWith)
return exists(
tx
Expand Down Expand Up @@ -272,9 +257,7 @@ const buildVersionCondition = (cond: VersionCondition): SQL => {
return ilike(deploymentVersion.tag, `${cond.value}%`);
if (cond.operator === ColumnOperator.EndsWith)
return ilike(deploymentVersion.tag, `%${cond.value}`);
if (cond.operator === ColumnOperator.Contains)
return ilike(deploymentVersion.tag, `%${cond.value}%`);
return sql`${deploymentVersion.tag} ~ ${cond.value}`;
return ilike(deploymentVersion.tag, `%${cond.value}%`);
};

const buildCondition = (tx: Tx, cond: DeploymentVersionCondition): SQL => {
Expand Down
19 changes: 1 addition & 18 deletions packages/db/src/schema/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,6 @@ const buildMetadataCondition = (tx: Tx, cond: MetadataCondition): SQL => {
.limit(1),
);

if (cond.operator === MetadataOperator.Regex)
return exists(
tx
.select({ value: sql<number>`1` })
.from(jobMetadata)
.where(
and(
eq(jobMetadata.jobId, job.id),
eq(jobMetadata.key, cond.key),
sql`${jobMetadata.value} ~ ${cond.value}`,
),
)
.limit(1),
);

if (cond.operator === MetadataOperator.StartsWith)
return exists(
tx
Expand Down Expand Up @@ -263,9 +248,7 @@ const buildVersionCondition = (cond: VersionCondition): SQL => {
return ilike(deploymentVersion.tag, `${cond.value}%`);
if (cond.operator === ColumnOperator.EndsWith)
return ilike(deploymentVersion.tag, `%${cond.value}`);
if (cond.operator === ColumnOperator.Contains)
return ilike(deploymentVersion.tag, `%${cond.value}%`);
return sql`${deploymentVersion.tag} ~ ${cond.value}`;
return ilike(deploymentVersion.tag, `%${cond.value}%`);
};

const buildCondition = (tx: Tx, cond: JobCondition): SQL => {
Expand Down
23 changes: 2 additions & 21 deletions packages/db/src/schema/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,6 @@ const buildMetadataCondition = (tx: Tx, cond: MetadataCondition): SQL => {
.limit(1),
);

if (cond.operator === MetadataOperator.Regex)
return exists(
tx
.select({ value: sql<number>`1` })
.from(resourceMetadata)
.where(
and(
eq(resourceMetadata.resourceId, resource.id),
eq(resourceMetadata.key, cond.key),
sql`${resourceMetadata.value} ~ ${cond.value}`,
),
)
.limit(1),
);

if (cond.operator === MetadataOperator.StartsWith)
return exists(
tx
Expand Down Expand Up @@ -269,9 +254,7 @@ const buildIdentifierCondition = (tx: Tx, cond: IdentifierCondition): SQL => {
return ilike(resource.identifier, `${cond.value}%`);
if (cond.operator === ColumnOperator.EndsWith)
return ilike(resource.identifier, `%${cond.value}`);
if (cond.operator === ColumnOperator.Contains)
return ilike(resource.identifier, `%${cond.value}%`);
return sql`${resource.identifier} ~ ${cond.value}`;
return ilike(resource.identifier, `%${cond.value}%`);
};

const buildNameCondition = (tx: Tx, cond: NameCondition): SQL => {
Expand All @@ -281,9 +264,7 @@ const buildNameCondition = (tx: Tx, cond: NameCondition): SQL => {
return ilike(resource.name, `${cond.value}%`);
if (cond.operator === ColumnOperator.EndsWith)
return ilike(resource.name, `%${cond.value}`);
if (cond.operator === ColumnOperator.Contains)
return ilike(resource.name, `%${cond.value}%`);
return sql`${resource.name} ~ ${cond.value}`;
return ilike(resource.name, `%${cond.value}%`);
};

const buildCreatedAtCondition = (tx: Tx, cond: CreatedAtCondition): SQL => {
Expand Down
1 change: 0 additions & 1 deletion packages/validators/src/conditions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export * from "./date-condition.js";

export enum ColumnOperator {
Equals = "equals",
Regex = "regex",
StartsWith = "starts-with",
EndsWith = "ends-with",
Contains = "contains",
Expand Down
12 changes: 0 additions & 12 deletions packages/validators/src/conditions/metadata-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ export const equalsCondition = z.object({

export type EqualCondition = z.infer<typeof equalsCondition>;

export const regexCondition = z.object({
type: z.literal("metadata"),
key: z.string().min(1),
value: z.string(),
operator: z.literal("regex"),
});

export type RegexCondition = z.infer<typeof regexCondition>;

export const startsWithCondition = z.object({
type: z.literal("metadata"),
key: z.string().min(1),
Expand Down Expand Up @@ -58,7 +49,6 @@ export const metadataCondition = z.union([
startsWithCondition,
endsWithCondition,
containsCondition,
regexCondition,
equalsCondition,
nullCondition,
]);
Expand All @@ -67,7 +57,6 @@ export type MetadataCondition = z.infer<typeof metadataCondition>;

export enum MetadataOperator {
Equals = "equals",
Regex = "regex",
Null = "null",
StartsWith = "starts-with",
EndsWith = "ends-with",
Expand All @@ -76,7 +65,6 @@ export enum MetadataOperator {

export type MetadataOperatorType =
| MetadataOperator.Equals
| MetadataOperator.Regex
| MetadataOperator.Null
| MetadataOperator.StartsWith
| MetadataOperator.EndsWith
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const deploymentVersionCondition = z.union([
export enum DeploymentVersionOperator {
Equals = "equals",
Like = "like",
Regex = "regex",
Null = "null",
And = "and",
Or = "or",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export const resourceCondition = z.union([
export enum ResourceOperator {
Equals = "equals",
Like = "like",
Regex = "regex",
Null = "null",
And = "and",
Or = "or",
Expand Down
Loading