catts-sdk
Version:
Facilitates the local development of C-ATTS recipes.
223 lines (222 loc) • 6.83 kB
TypeScript
import { SchemaItem } from "@ethereum-attestation-service/eas-sdk";
import { z } from "zod";
/**
* Zod schema for query variables. Defines the shape of query variables to be used
* in GraphQL queries.
*/
export declare const queryVariablesSchema: z.ZodTypeAny;
/**
* Defines the shape of query variables to be used in GraphQL queries.
*/
export type QueryVariables = z.infer<typeof queryVariablesSchema>;
/**
* Zod schema for query variables. Defines the components of a GraphQL query,
* including endpoint and variables.
*/
export declare const querySchema: z.ZodObject<{
url: z.ZodString;
filter: z.ZodNullable<z.ZodOptional<z.ZodString>>;
headers: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
body: z.ZodNullable<z.ZodOptional<z.ZodObject<{
query: z.ZodString;
variables: z.ZodAny;
}, "strip", z.ZodTypeAny, {
query: string;
variables?: any;
}, {
query: string;
variables?: any;
}>>>;
}, "strict", z.ZodTypeAny, {
url: string;
filter?: string | null | undefined;
headers?: any;
body?: {
query: string;
variables?: any;
} | null | undefined;
}, {
url: string;
filter?: string | null | undefined;
headers?: any;
body?: {
query: string;
variables?: any;
} | null | undefined;
}>;
/**
* Defines the components of a GraphQL query, including endpoint and variables.
*/
export type Query = z.infer<typeof querySchema>;
/**
* Zod schema for an array of queries.
*/
export declare const queriesSchema: z.ZodArray<z.ZodObject<{
url: z.ZodString;
filter: z.ZodNullable<z.ZodOptional<z.ZodString>>;
headers: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
body: z.ZodNullable<z.ZodOptional<z.ZodObject<{
query: z.ZodString;
variables: z.ZodAny;
}, "strip", z.ZodTypeAny, {
query: string;
variables?: any;
}, {
query: string;
variables?: any;
}>>>;
}, "strict", z.ZodTypeAny, {
url: string;
filter?: string | null | undefined;
headers?: any;
body?: {
query: string;
variables?: any;
} | null | undefined;
}, {
url: string;
filter?: string | null | undefined;
headers?: any;
body?: {
query: string;
variables?: any;
} | null | undefined;
}>, "many">;
/**
* An array of queries.
*/
export type Queries = z.infer<typeof queriesSchema>;
/**
* Zod schema for a recipe. Defines the structure of a recipe, including queries
* and output schema.
*/
export declare const recipeSchema: z.ZodObject<{
name: z.ZodEffects<z.ZodString, string, string>;
description: z.ZodOptional<z.ZodString>;
keywords: z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>, string[] | undefined, string[] | undefined>;
queries: z.ZodArray<z.ZodObject<{
url: z.ZodString;
filter: z.ZodNullable<z.ZodOptional<z.ZodString>>;
headers: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
body: z.ZodNullable<z.ZodOptional<z.ZodObject<{
query: z.ZodString;
variables: z.ZodAny;
}, "strip", z.ZodTypeAny, {
query: string;
variables?: any;
}, {
query: string;
variables?: any;
}>>>;
}, "strict", z.ZodTypeAny, {
url: string;
filter?: string | null | undefined;
headers?: any;
body?: {
query: string;
variables?: any;
} | null | undefined;
}, {
url: string;
filter?: string | null | undefined;
headers?: any;
body?: {
query: string;
variables?: any;
} | null | undefined;
}>, "many">;
schema: z.ZodString;
resolver: z.ZodString;
revokable: z.ZodEffects<z.ZodBoolean, boolean, boolean>;
}, "strict", z.ZodTypeAny, {
name: string;
queries: {
url: string;
filter?: string | null | undefined;
headers?: any;
body?: {
query: string;
variables?: any;
} | null | undefined;
}[];
schema: string;
resolver: string;
revokable: boolean;
description?: string | undefined;
keywords?: string[] | undefined;
}, {
name: string;
queries: {
url: string;
filter?: string | null | undefined;
headers?: any;
body?: {
query: string;
variables?: any;
} | null | undefined;
}[];
schema: string;
resolver: string;
revokable: boolean;
description?: string | undefined;
keywords?: string[] | undefined;
}>;
/**
* Defines the structure of a recipe, including queries and output schema.
*/
export type Recipe = z.infer<typeof recipeSchema>;
declare const SchemaItem: z.ZodObject<{
name: z.ZodString;
type: z.ZodString;
value: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodBoolean, z.ZodNumber, z.ZodBigInt]>, z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">, z.ZodArray<z.ZodUnknown, "many">]>]>;
}, "strict", z.ZodTypeAny, {
value: string | number | bigint | boolean | unknown[] | Record<string, unknown> | Record<string, unknown>[];
type: string;
name: string;
}, {
value: string | number | bigint | boolean | unknown[] | Record<string, unknown> | Record<string, unknown>[];
type: string;
name: string;
}>;
export declare function parseRecipe(input: unknown): Recipe;
type FetchQueryArgs = {
query: Query;
cacheKey?: string;
placeHolderValues?: {
userEthAddress?: string;
};
proxyUrl?: string;
verbose?: boolean;
};
/**
* Fetches the result of a query from the GraphQl endpoint specified in the query.
*
* @returns The result of the query in JSON format.
*/
export declare function fetchQuery(args: FetchQueryArgs): Promise<any>;
/**
* Validates that the processor result matches the output schema specified in the recipe.
*
* @param processorResult The raw result of the processor script as a string.
*
* @returns The result of the processor script in JSON format. On success, the output should match outputSchema specified in the recipe.
*/
export declare function validateProcessorResult({ processorResult, }: {
processorResult: string;
}): Promise<SchemaItem[]>;
/**
* Validates that an array of schema items matches what is expected by the schema.
*/
export declare function validateSchemaItems({ schemaItems, schema, }: {
schemaItems: SchemaItem[];
schema: string;
}): Promise<string>;
/**
* An EAS schema UID is a hash of the schema, resolver and revokable flag.
*/
export declare function getSchemaUid({ schema, resolver, revokable, }: {
schema: string;
resolver: string;
revokable: boolean;
}): string;
export {};