@airtop/json-schema-adapter-typebox
v1.0.0-alpha2.2
Published
Typebox adapter for JSON Schema output for use with the Airtop SDK
Readme
Typebox JSON Schema Adapter for the Airtop SDK
This schema adapter allows specifying typebox objects as input when an Airtop SDK method requires a JSON schema.
Installation
npm install @airtop/sdk @airtop/json-schema-adapter-typebox @sinclair/typeboxUsage
import { AirtopClient } from "@airtop/sdk";
import { TypeboxSchemaAdapter } from "@airtop/json-schema-adapter-typebox";
import { Type } from "@sinclair/typebox";
const schema = Type.Object(
{
results: Type.Optional(
Type.Array(
Type.Object(
{
name: Type.String({ description: "The name of the product" }),
description: Type.String({ description: "A brief description of the product's purpose" }),
benefit: Type.String({ description: "How the product supports developers" }),
},
{ additionalProperties: false },
),
),
),
error: Type.Optional(Type.String({ minLength: 1, description: "Error message in case of failure" })),
},
{ additionalProperties: false },
);
const client = new AirtopClient({
outputSchemaAdapter: new TypeboxSchemaAdapter(),
});
await client
.withSessionId("session-id")
.withWindowId("window-id")
.pageQuery("title of the page", {
configuration: {
outputSchema: schema,
}
})