UNPKG

@squidcloud/client

Version:

A typescript implementation of the Squid client

356 lines (355 loc) 14.5 kB
import { IntegrationId, IntegrationInfo, IntegrationType } from './public-types'; /** * IntegrationClient manages integrations within an application, * providing methods for listing, retrieving, updating, and deleting integrations. * @category Platform */ export declare class IntegrationClient { private readonly rpcManager; private readonly iacBaseUrl; /** * Lists all integrations for the current application. * * @param type - (Optional) Filter by integration type. * @returns A promise that resolves with a list of integrations. */ list<ConfigurationType = Record<string, any>>(type?: IntegrationType): Promise<Array<IntegrationInfo<ConfigurationType>>>; /** * Retrieves the integration by its ID. * * @param integrationId - The ID of the integration to retrieve. * @returns A promise that resolves with the integration info, or `undefined` if not found. */ get<ConfigurationType = Record<string, any>>(integrationId: IntegrationId): Promise<IntegrationInfo<ConfigurationType> | undefined>; /** * Retrieves the integration's schema by its ID. * * @param integrationId - The ID of the integration to retrieve. * @returns A promise that resolves with the integration schema, or `undefined` if not found. */ getIntegrationSchema<SchemaType = Record<string, any>>(integrationId: IntegrationId): Promise<SchemaType | undefined>; /** * Sets the integration's schema by its ID. * * @param integrationId - The ID of the integration to update. * @param schema - The schema to set for the integration. * @returns A promise that resolves when the schema has been updated. */ setIntegrationSchema<SchemaType = Record<string, any>>(integrationId: IntegrationId, schema: SchemaType): Promise<void>; /** * Deletes the integration with the given ID. * * @param integrationId - The ID of the integration to delete. * @returns A promise that resolves when the integration has been deleted. */ delete(integrationId: IntegrationId): Promise<void>; /** * Deletes multiple integrations by their IDs. * * @param integrationIds - An array of integration IDs to delete. * @returns A promise that resolves when all deletions are complete. */ deleteMany(integrationIds: Array<IntegrationId>): Promise<void>; /** * Creates or updates an integration. * * @param integration - The integration information to upsert. * @returns A promise that resolves when the operation is complete. */ upsertIntegration<ConfigurationType = Record<string, any>>(integration: IntegrationInfo<ConfigurationType>): Promise<void>; /** * Generates AI descriptions for the data schema of an integration. * Uses AI to analyze the schema structure and generate meaningful descriptions * for collections and their fields. * * @param integrationId - The ID of the integration. * @param request - The request containing schema and optional parameters. * @returns A promise that resolves with the schema containing AI-generated descriptions. */ generateAiDescriptionsForDataSchema<SchemaType = Record<string, any>>(integrationId: IntegrationId, request: GenerateAiDescriptionsForDataSchemaRequest<SchemaType>): Promise<GenerateAiDescriptionsForDataSchemaResponse<SchemaType>>; /** * Generates AI descriptions for associations (relationships) in a data schema. * Uses AI to analyze entity relationships and generate meaningful descriptions. * * @param integrationId - The ID of the integration. * @param request - The request containing schema with associations and optional parameters. * @returns A promise that resolves with the schema containing AI-generated association descriptions. */ generateAiDescriptionsForAssociations<SchemaType = Record<string, any>>(integrationId: IntegrationId, request: GenerateAiDescriptionsForAssociationsRequest<SchemaType>): Promise<GenerateAiDescriptionsForSchemaResponse<SchemaType>>; /** * Generates AI descriptions for stored procedures in a data schema. * Uses AI to analyze stored procedures and generate meaningful descriptions. * * @param integrationId - The ID of the integration. * @param request - The request containing schema with stored procedures and optional parameters. * @returns A promise that resolves with the schema containing AI-generated stored procedure descriptions. */ generateAiDescriptionsForStoredProcedures<SchemaType = Record<string, any>>(integrationId: IntegrationId, request: GenerateAiDescriptionsForStoredProceduresRequest<SchemaType>): Promise<GenerateAiDescriptionsForSchemaResponse<SchemaType>>; /** * Generates AI descriptions for API endpoints in an API schema. * Uses AI to analyze endpoints and generate meaningful descriptions. * * @param integrationId - The ID of the integration. * @param request - The request containing API schema with endpoints and optional parameters. * @returns A promise that resolves with the schema containing AI-generated endpoint descriptions. */ generateAiDescriptionsForEndpoints<SchemaType = Record<string, any>>(integrationId: IntegrationId, request: GenerateAiDescriptionsForEndpointsRequest<SchemaType>): Promise<GenerateAiDescriptionsForSchemaResponse<SchemaType>>; /** * Discovers the schema of a data connection (database). * Connects to the database and introspects its structure including tables, columns, and relationships. * * @param integrationId - The ID of the database integration. * @returns A promise that resolves with the discovered schema and collection readiness information. */ discoverDataConnectionSchema<SchemaType = Record<string, any>>(integrationId: IntegrationId): Promise<DiscoverDataConnectionSchemaResponse<SchemaType>>; /** * Tests a data connection (database) to verify it is working. * Attempts to connect to the database and perform a basic operation to validate connectivity. * This can be used to test connection settings before saving the integration. * * @param config - The integration configuration to test. * @returns A promise that resolves with the test result indicating success or failure with an optional error message. */ testDataConnection<ConfigurationType = Record<string, any>>(config: IntegrationInfo<ConfigurationType>): Promise<TestDataConnectionResponse>; /** * Discovers the schema of a GraphQL connection. * Performs introspection on the GraphQL endpoint to discover types and operations. * * @param integrationId - The ID of the GraphQL integration. * @param request - The request containing GraphQL connection options. * @returns A promise that resolves with the discovered GraphQL schema. */ discoverGraphQLConnectionSchema<SchemaType = Record<string, any>>(integrationId: IntegrationId, request: DiscoverGraphQLConnectionSchemaRequest): Promise<DiscoverGraphQLConnectionSchemaResponse<SchemaType>>; /** * Discovers the schema from an OpenAPI specification URL. * Fetches and parses the OpenAPI spec to discover endpoints and their schemas. * * @param integrationId - The ID of the API integration. * @param request - The request containing OpenAPI discovery options. * @returns A promise that resolves with the discovered API schema. */ discoverOpenApiSchema<SchemaType = Record<string, any>>(integrationId: IntegrationId, request: DiscoverOpenApiSchemaRequest): Promise<DiscoverOpenApiSchemaResponse<SchemaType>>; /** * Discovers the schema from an uploaded OpenAPI specification file. * Parses the OpenAPI spec file that was previously uploaded to the integration. * * @param integrationId - The ID of the API integration with the uploaded spec file. * @returns A promise that resolves with the discovered API schema. */ discoverOpenApiSchemaFromFile<SchemaType = Record<string, any>>(integrationId: IntegrationId): Promise<DiscoverOpenApiSchemaResponse<SchemaType>>; } /** * Request for generating AI descriptions for a data schema. * @category Platform */ export interface GenerateAiDescriptionsForDataSchemaRequest<SchemaType = Record<string, any>> { /** * List of collection names to generate descriptions for. * If not provided or empty, descriptions will be generated for all collections. */ collections?: string[]; /** * The current schema of the integration containing collections and their fields. */ schema: SchemaType; /** * Optional instructions to guide the AI in generating descriptions. * For example: "Focus on business context" or "Use technical terminology". */ instructions?: string; } /** * Response from generating AI descriptions for a data schema. * @category Platform */ export interface GenerateAiDescriptionsForDataSchemaResponse<SchemaType = Record<string, any>> { /** * The schema with AI-generated descriptions added to collections and fields. */ schema: SchemaType; } /** * Generic response from generating AI descriptions for a schema. * @category Platform */ export interface GenerateAiDescriptionsForSchemaResponse<SchemaType = Record<string, any>> { /** * The schema with AI-generated descriptions. */ schema: SchemaType; } /** * Request for generating AI descriptions for associations in a data schema. * @category Platform */ export interface GenerateAiDescriptionsForAssociationsRequest<SchemaType = Record<string, any>> { /** * List of association names to generate descriptions for. * If not provided or empty, descriptions will be generated for all associations. */ associations?: string[]; /** * The current schema of the integration containing associations. */ schema: SchemaType; /** * Optional instructions to guide the AI in generating descriptions. */ instructions?: string; } /** * Request for generating AI descriptions for stored procedures in a data schema. * @category Platform */ export interface GenerateAiDescriptionsForStoredProceduresRequest<SchemaType = Record<string, any>> { /** * List of stored procedure names to generate descriptions for. * If not provided or empty, descriptions will be generated for all stored procedures. */ storedProcedures?: string[]; /** * The current schema of the integration containing stored procedures. */ schema: SchemaType; /** * Optional instructions to guide the AI in generating descriptions. */ instructions?: string; } /** * Request for generating AI descriptions for API endpoints. * @category Platform */ export interface GenerateAiDescriptionsForEndpointsRequest<SchemaType = Record<string, any>> { /** * List of endpoint IDs to generate descriptions for. * If not provided or empty, descriptions will be generated for all endpoints. */ endpoints?: string[]; /** * The current API schema containing endpoints. */ schema: SchemaType; /** * Optional instructions to guide the AI in generating descriptions. */ instructions?: string; } /** * Response from discovering a data connection schema. * @category Platform */ export interface DiscoverDataConnectionSchemaResponse<SchemaType = Record<string, any>> { /** * The discovered schema containing collections, fields, associations, and stored procedures. */ schema: SchemaType; /** * Information about collection readiness for CRUD operations and replication. */ collectionReadiness: Record<string, CollectionReadiness>; } /** * Response from testing a data connection. * @category Platform */ export interface TestDataConnectionResponse { /** * Whether the connection test was successful. */ success: boolean; /** * Error message if the connection test failed. */ errorMessage?: string; } /** * Information about a collection's readiness for operations. * @category Platform */ export interface CollectionReadiness { /** * Whether the user has permissions to perform CRUD operations on the collection. */ hasPermissions: boolean; /** * Commands needed to grant the required permissions. */ grantPermissionsCommands: string[]; /** * Whether the collection is ready for external updates/replication. */ replicationEnabled: boolean; /** * Commands needed to enable replication. */ enableReplicationCommands: string[]; } /** * Request for discovering a GraphQL connection schema. * @category Platform */ export interface DiscoverGraphQLConnectionSchemaRequest { /** * GraphQL connection options including URL and authentication. */ connectionOptions: DiscoverGraphQLConnectionOptions; } /** * GraphQL connection options for schema discovery. * @category Platform */ export interface DiscoverGraphQLConnectionOptions { /** * The GraphQL endpoint URL. */ url: string; /** * Optional headers to include in requests. */ headers?: Record<string, string>; } /** * Response from discovering a GraphQL connection schema. * @category Platform */ export interface DiscoverGraphQLConnectionSchemaResponse<SchemaType = Record<string, any>> { /** * The discovered GraphQL schema. */ schema: SchemaType; } /** * Request for discovering an OpenAPI schema from a URL. * @category Platform */ export interface DiscoverOpenApiSchemaRequest { /** * OpenAPI discovery options including URL and authentication. */ discoveryOptions: DiscoverOpenApiOptions; } /** * OpenAPI discovery options for schema discovery. * @category Platform */ export interface DiscoverOpenApiOptions { /** * The URL of the OpenAPI specification. */ openApiSpecUrl?: string; /** * Optional headers to include when fetching the spec. */ headers?: Record<string, string>; } /** * Response from discovering an OpenAPI schema. * @category Platform */ export interface DiscoverOpenApiSchemaResponse<SchemaType = Record<string, any>> { /** * The discovered API schema containing endpoints and their definitions. */ schema: SchemaType; }