import type { ISupplyDataFunctions, IDataObject } from 'n8n-workflow'; export interface ParamDef { /** API field name if different from tool param name */ apiName?: string; location: 'body' | 'qs' | 'local'; type: 'string' | 'number' | 'boolean' | 'json'; required: boolean; description: string; enumValues?: string[]; } export interface OperationDef { method: 'GET' | 'POST' | 'PATCH' | 'DELETE'; endpoint: string; isWrite: boolean; isList: boolean; /** How the tenant identifier is sent. field = exact API field name. */ tenant: { location: 'qs' | 'body' | 'none'; field: string; }; params: Record; description: string; /** Hardcoded values injected into body/qs regardless of LLM input */ defaults?: { body?: Record; qs?: Record; }; /** Response unwrap path — the key containing the result array (e.g., 'Results', 'value') */ responseUnwrap?: string; /** Custom label for this operation in descriptions (overrides auto-generated) */ operationLabel?: string; /** Post-processing transform applied after API response, before result wrapping. * Return IDataObject for single-object output, IDataObject[] for list output. * Receives raw unwrapped results array and any params declared with location 'local'. */ transform?: (results: IDataObject[], localParams: Record) => IDataObject | IDataObject[]; } /** Named alias for the tenant descriptor shape used in both OperationDef and CompositeOperationDef */ export type TenantDef = { location: 'qs' | 'body' | 'none'; field: string; }; /** * Multi-step composite operation — makes several internal API calls and returns a shaped report. * No method/endpoint: dispatch is handled entirely by composite-executor.ts. */ export interface CompositeOperationDef { isComposite: true; isWrite: boolean; isList: false; /** Used by schema-generator to add tenantFilter param. Use TENANT.qs for single-tenant ops, TENANT.none for cross-tenant sweep. */ tenant: TenantDef; params: Record; description: string; } /** Union of all operation definition types */ export type AnyOperationDef = OperationDef | CompositeOperationDef; export interface ResourceConfig { label: string; description: string; operations: Record; /** * Custom executor — overrides the generic executor for this entire resource. * Use for resources with non-standard API call patterns (e.g., Graph-routed requests). * Receives stripped params (no n8n metadata), tenant filter, and the operation definition. * Only called for non-composite operations (composites are dispatched before customExecutor). */ customExecutor?: (context: ISupplyDataFunctions, operation: string, tenantFilter: string, params: Record, opDef: OperationDef) => Promise; } /** Shorthand helpers for compact param definitions */ export declare const P: { readonly qs: (desc: string, required?: boolean) => ParamDef; readonly qsNum: (desc: string, required?: boolean) => ParamDef; readonly qsBool: (desc: string, required?: boolean) => ParamDef; readonly body: (desc: string, required?: boolean) => ParamDef; readonly bodyNum: (desc: string, required?: boolean) => ParamDef; readonly bodyBool: (desc: string, required?: boolean) => ParamDef; readonly bodyJson: (desc: string, required?: boolean) => ParamDef; readonly bodyEnum: (desc: string, values: string[], required?: boolean) => ParamDef; readonly qsEnum: (desc: string, values: string[], required?: boolean) => ParamDef; readonly localEnum: (desc: string, values: string[], required?: boolean) => ParamDef; readonly localBool: (desc: string, required?: boolean) => ParamDef; }; /** Standard tenant patterns */ export declare const TENANT: { readonly qs: { readonly location: "qs"; readonly field: "tenantFilter"; }; readonly body: { readonly location: "body"; readonly field: "tenantFilter"; }; readonly bodyPascal: { readonly location: "body"; readonly field: "TenantFilter"; }; readonly bodyLower: { readonly location: "body"; readonly field: "tenantid"; }; readonly bodyLowerAll: { readonly location: "body"; readonly field: "tenantfilter"; }; readonly bodyTenantID: { readonly location: "body"; readonly field: "tenantID"; }; readonly bodySelected: { readonly location: "body"; readonly field: "selectedTenants"; }; readonly bodyTenant: { readonly location: "body"; readonly field: "tenant"; }; readonly bodyTenantId: { readonly location: "body"; readonly field: "tenantId"; }; readonly bodyTenantIdPascal: { readonly location: "body"; readonly field: "TenantId"; }; readonly none: { readonly location: "none"; readonly field: ""; }; }; /** n8n framework metadata fields to strip from all tool invocations */ export declare const N8N_METADATA_FIELDS: Set; /** Operation names that are considered write/mutating */ export declare function isWriteOperation(opName: string, resourceConfig: ResourceConfig): boolean; //# sourceMappingURL=types.d.ts.map