Skip to content

Commit

Permalink
Fix schema for json api condition
Browse files Browse the repository at this point in the history
JSON path will always be able to be parsed.
It only becomes invalid when combined with JSON, and this will only be
known at decryption time.
  • Loading branch information
theref committed Jul 19, 2024
1 parent 5ef9cd4 commit 382870a
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions packages/taco/src/conditions/base/json-api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { JSONPath } from 'jsonpath-plus';
import { z } from 'zod';

import { Condition } from '../condition';
import {
OmitConditionType,
paramOrContextParamSchema,
returnValueTestSchema,
} from '../shared';

Expand All @@ -13,20 +11,8 @@ export const JsonApiConditionType = 'json-api';
export const JsonApiConditionSchema = z.object({
conditionType: z.literal(JsonApiConditionType).default(JsonApiConditionType),
endpoint: z.string().url(),
parameters: z.array(paramOrContextParamSchema),
query: z.string().refine(
(path) => {
try {
JSONPath.toPathArray(path);
return true;
} catch (error) {
return false;
}
},
{
message: "Invalid JSON path",
}
),
parameters: z.record(z.string(), z.unknown()),
query: z.string(),
returnValueTest: returnValueTestSchema, // Update to allow multiple return values after expanding supported methods
});

Expand Down

0 comments on commit 382870a

Please sign in to comment.