import { AxiosInstance } from "axios"; import { EntitiesModule } from "../../types/entity"; import { createEntityMethods } from "./entity"; /** * Create the entities module with dynamic entity access * @param client HTTP client * @param appId Application ID * @returns Entities module */ export function createEntitiesModule( client: AxiosInstance, appId: string | number ): EntitiesModule { // Use a Proxy to dynamically handle entity access return new Proxy( {}, { get(_target, prop) { // Ignore special properties like 'then' and properties starting with '_' if ( typeof prop === "string" && prop !== "then" && !prop.startsWith("_") ) { // Create entity methods for the requested entity type return createEntityMethods(client, appId, prop); } return undefined; }, } ) as EntitiesModule; }