Code-Confluence Multi-Language Library Feature Schema
website·Indexed 31 days ago
https://docs.unoplat.io/Documentation for the Code-Confluence Multi-Language Library Feature Schema v4.1, providing JSON schemas for framework and library feature signatures. It includes construct category definitions, constructQueryDef objects, and refinements for auto-generated Tree-sitter queries, with framework definitions for Python and TypeScript libraries such as FastAPI, Pydantic, Next.js, and Firebase.
What's inside Code-Confluence
- SQLModel is a library designed for interacting with SQL databases from Python code. It combines SQLAlchemy and Pydantic to provide type-safe database operations with automatic validation, ensuring simplicity and robustness in database model definitions.
Overview of FastAPI
FastAPI is a modern, high-performance web framework for building APIs with Python. It leverages standard Python type hints to provide automatic interactive documentation and is designed for ease of use and speed.Overview of @tanstack/react-db
@tanstack/react-db provides React bindings for executing live queries over TanStack DB collections, allowing React components to consume continuously synchronized collection state.Use Pydantic for data validation and serialization
Pydantic is a fast and extensible data validation library for Python. It leverages Python type hints to define data schemas, providing automatic validation, serialization, and error handling.Configure CallExpression operations in Code-Confluence Schema v4.1
When defining an operation with the
conceptset toCallExpression, the schema enforces specific constraints to handle ambiguity and targeting:- Target Level: Must be set to
function. - Base Confidence: A
base_confidencevalue (between 0.0 and 1.0) is required. This represents the contributor-authored confidence in the pattern. - Disambiguation: If
base_confidenceis less than 0.7, thenotesfield is mandatory and must contain disambiguation guidance. - Query Refinement: If a
match_policyis specified within theconstruct_query, theconceptmust beCallExpression.
- Target Level: Must be set to
Use Axios for promise-based HTTP requests
Axios is a promise-based HTTP client used for making outbound HTTP requests. Requests can be made using the globalaxiosobject, theaxios.requestmethod, or by creating a custom instance viaaxios.create.import axios from 'axios'; // Simple request axios.get('https://api.example.com/data'); // Custom instance const instance = axios.create({ baseURL: 'https://api.example.com' }); instance.get('/user');Configure operation concepts and target levels
Operations in the library schema must be categorized by a
conceptand atarget_level. The schema enforces specific pairings to ensure consistency:Concept Required Target Level Notes CallExpressionfunctionRequires base_confidence.InheritanceclassUsed for base class identification. FunctionDefinitionfunctionUsed for function-based signatures. AnnotationLike(As specified) Used for decorator/annotation patterns. Special Constraints for
CallExpression:- Confidence: Must include a
base_confidence(0.0 to 1.0). - Ambiguity: If
base_confidenceis less than 0.7, thenotesfield is mandatory to provide disambiguation guidance.
- Confidence: Must include a
Define REST API routes in FastAPI
FastAPI uses HTTP verb decorators to register route handlers. These decorators can be applied to instances of
fastapi.FastAPI(orfastapi.applications.FastAPI) andfastapi.APIRouter(orfastapi.routing.APIRouter).Supported HTTP methods include:
get(): Handle GET requestspost(): Handle POST requestsput(): Handle PUT requestsdelete(): Handle DELETE requestspatch(): Handle PATCH requestshead(): Handle HEAD requestsoptions(): Handle OPTIONS requeststrace(): Handle TRACE requests
Create a Zustand state store
Zustand provides lightweight client state containers. Stores can be created using thecreateAPI for React-integrated stores orcreateStore(available inzustandandzustand/vanilla) for vanilla JavaScript stores.import { create } from 'zustand' const useStore = create((set) => ({ count: 0, inc: () => set((state) => ({ count: state.count + 1 })), }))Construct PydanticAI Agents and Durable TemporalAgent Wrappers
PydanticAI allows for the construction of agents to perform language-model inference. For durable execution, PydanticAI provides aTemporalAgentwrapper. Valid constructors for these agents are located in thepydantic_ai.Agentandpydantic_ai.durable_exec.temporal.TemporalAgentpaths.from pydantic_ai import Agent from pydantic_ai.durable_exec.temporal import TemporalAgent # Example of agent construction agent = Agent('openai:gpt-4o') # Example of a durable Temporal wrapper temporal_agent = TemporalAgent(agent)Construct a GraphQL client using the gql Python library
Thegqllibrary (version 3.5.3) provides aClientclass used to establish outbound GraphQL access. To instantiate a client, usegql.Clientorgql.client.Client. This is the primary entry point for setting up GraphQL operations in Python.from gql import Client # Initialize the GraphQL client client = Client(transport=your_transport_here)Define data models using Pydantic BaseModel
To create a data model with automatic validation in Pydantic, inherit from theBaseModelclass. This allows you to define the schema of your data using type hints, and Pydantic will ensure that any data instantiated into the model conforms to those types.from pydantic import BaseModel class User(BaseModel): id: int name: str email: str