UNPKG

@kraveir0/webapi-proxy-interceptor

Version:

Drop-in replacement for PCF WebAPI that automatically routes calls to your local development proxy.

95 lines 3.38 kB
import { ProxyInterceptorConfig } from "./config"; import "./types"; /** * Proxied WebAPI Implementation * A drop-in replacement for PCF context.webAPI that routes calls through a local development proxy */ export declare class ProxiedWebAPI { private config; private logger; private entityMetadataCache; constructor(config?: ProxyInterceptorConfig); /** * Creates a record * @param entityLogicalName The logical name of the entity * @param data The record data */ createRecord(entityLogicalName: string, data: any): Promise<any>; /** * Updates a record * @param entityLogicalName The logical name of the entity * @param id The record ID * @param data The update data */ updateRecord(entityLogicalName: string, id: string, data: any): Promise<any>; /** * Deletes a record * @param entityLogicalName The logical name of the entity * @param id The record ID */ deleteRecord(entityLogicalName: string, id: string): Promise<any>; /** * Retrieves a single record * @param entityLogicalName The logical name of the entity * @param id The record ID * @param options Query options */ retrieveRecord(entityLogicalName: string, id: string, options?: any): Promise<any>; /** * Retrieves multiple records * @param entityLogicalName The logical name of the entity * @param query OData query string * @param maxPageSize Maximum page size */ retrieveMultipleRecords(entityLogicalName: string, query?: string, maxPageSize?: number): Promise<any>; /** * Queries Dataverse metadata to get the correct entity set name for a logical name * @param logicalName The logical name of the entity * @returns The entity set name (schema name) used in REST API endpoints */ private getEntitySetNameFromMetadata; /** * Fallback pluralization logic when metadata query fails * @param logicalName The logical name to pluralize * @returns The pluralized form */ private fallbackToPluralization; /** * Gets the entity set name, either from cache, metadata query, or fallback pluralization * @param entityLogicalName The logical name of the entity * @returns Promise that resolves to the entity set name */ private getEntitySetName; /** * Builds the full URL for the request */ private buildUrl; /** * Makes an HTTP request to the proxy */ private makeRequest; /** * Handles and formats errors */ private handleError; /** * Checks if we're in local development environment */ private isLocalDevelopment; /** * Gets the current configuration */ getConfig(): Required<ProxyInterceptorConfig>; /** * Updates the configuration */ updateConfig(newConfig: Partial<ProxyInterceptorConfig>): void; } /** * Factory function to create the appropriate WebAPI implementation * @param context The PCF context (optional, used to detect environment) * @param config Configuration for the proxy * @returns ProxiedWebAPI for local development, or the original context.webAPI for live environments */ export declare function createWebAPI(context?: ComponentFramework.Context<any>, config?: ProxyInterceptorConfig): any; //# sourceMappingURL=interceptor.d.ts.map