UNPKG

pcf-vite-harness

Version:

Modern Vite-based development harness for PowerApps Component Framework (PCF) with hot module replacement and PowerApps-like environment simulation

1,285 lines (1,243 loc) 38.1 kB
import * as vite from 'vite'; import { UserConfig } from 'vite'; import * as React$1 from 'react'; /** * Creates a mock PCF context with realistic PowerApps data * For datasets, we'll create datasets based on manifest information */ declare function createMockContext<TInputs>(options?: { controlId?: string; viewId?: string; displayName?: string; userName?: string; userId?: string; datasetOptions?: Partial<ComponentFramework.PropertyTypes.DataSet>; webAPI?: Partial<ComponentFramework.WebApi>; entityType?: string; manifestInfo?: { datasets?: Array<{ name: string; displayNameKey?: string; }>; namespace?: string; constructor?: string; version?: string; displayName?: string; description?: string; componentType?: 'dataset' | 'field'; }; }): ComponentFramework.Context<TInputs>; /** * PCF Harness Type Definitions * Types for the PCF Vite Harness configuration and options */ /** * Options for PCF Vite configuration */ interface PCFViteOptions { /** * Dataverse URL for authentication and API access */ dataverseUrl?: string; /** * Development server port * @default 3000 */ port?: number; /** * HMR (Hot Module Replacement) port * @default 3001 */ hmrPort?: number; /** * Whether to open browser on server start * @default true */ open?: boolean; /** * Additional Vite configuration to merge */ viteConfig?: UserConfig; } /** * Dataset Type Definitions * Types for PCF dataset structures, records, and columns */ /** * PCF Dataset Record Structure */ interface DatasetRecord { /** * Internal record structure with fields */ _record: { initialized: number; identifier: { etn: string; id: { guid: string; }; }; fields: DatasetFieldCollection; }; /** * Column alias mapping */ _columnAliasNameMap: Record<string, string>; /** * Primary field name for this record */ _primaryFieldName: string; /** * Dirty flag indicating if record has unsaved changes */ _isDirty: boolean; /** * Entity reference information */ _entityReference: { _etn: string; _id: string; _name: string; }; /** * Additional fields can be added directly to the record */ [key: string]: any; } /** * Collection of fields in a dataset record */ interface DatasetFieldCollection { [fieldName: string]: DatasetFieldValue; } /** * Base field value structure */ interface BaseFieldValue { timestamp: string; validationResult: ValidationResult; } /** * String field value */ interface StringFieldValue extends BaseFieldValue { value: string; formatted?: string; } /** * Number field value */ interface NumberFieldValue extends BaseFieldValue { value: number; formatted?: string; } /** * Boolean field value */ interface BooleanFieldValue extends BaseFieldValue { label: string; valueString: string; } /** * Date field value */ interface DateFieldValue extends BaseFieldValue { value: string; formatted?: string; } /** * Lookup field value */ interface LookupFieldValue extends BaseFieldValue { reference: { etn: string; id: { guid: string; }; name: string; }; } /** * Option set field value */ interface OptionSetFieldValue extends BaseFieldValue { label: string; valueString: string; } /** * Multi-select option set field value */ interface MultiSelectOptionSetFieldValue extends BaseFieldValue { value: number[]; formatted?: string; } /** * Union type for all field values */ type DatasetFieldValue = StringFieldValue | NumberFieldValue | BooleanFieldValue | DateFieldValue | LookupFieldValue | OptionSetFieldValue | MultiSelectOptionSetFieldValue | BaseFieldValue; /** * Validation result for field values */ interface ValidationResult { errorId: string | null; errorMessage: string | null; isValueValid: boolean; userInput: string | null; isOfflineSyncError: boolean; } /** * PCF Dataset Column Definition */ interface DatasetColumn { /** * Logical name of the column */ name: string; /** * Display name for the column */ displayName: string; /** * Data type of the column */ dataType: DatasetColumnType; /** * Alias for the column */ alias: string; /** * Display order of the column */ order: number; /** * Whether this is the primary field */ isPrimary?: boolean; /** * Visual size factor for column width */ visualSizeFactor?: number; /** * Whether the column is hidden */ isHidden?: boolean; /** * Whether the column is read-only */ isReadOnly?: boolean; /** * For lookup columns, the target entities */ targets?: string[]; /** * For option set columns, the available options */ options?: OptionSetOption[]; } /** * Dataset column data types */ type DatasetColumnType = 'SingleLine.Text' | 'SingleLine.Email' | 'SingleLine.Phone' | 'SingleLine.URL' | 'SingleLine.Ticker' | 'Multiple' | 'TwoOptions' | 'OptionSet' | 'MultiSelectOptionSet' | 'Whole.None' | 'Currency' | 'FP' | 'Decimal' | 'DateAndTime.DateOnly' | 'DateAndTime.DateAndTime' | 'Lookup.Simple' | 'Lookup.Customer' | 'Lookup.Owner' | 'Lookup.PartyList' | 'Lookup.Regarding'; /** * Option for option set columns */ interface OptionSetOption { value: number; label: string; color?: string; } /** * Dataset paging information */ interface DatasetPaging { pageNumber: number; totalResultCount: number; firstPageNumber: number; lastPageNumber: number; pageSize: number; hasNextPage: boolean; hasPreviousPage: boolean; } /** * Dataset sorting information */ interface DatasetSorting { name: string; sortDirection: SortDirection; } type SortDirection = 0 | 1; /** * Dataset filtering information */ interface DatasetFiltering { aliasMap: Record<string, string>; filterExpression?: string; } /** * Full PCF Dataset Structure */ interface PCFDataset { loading: boolean; columns: DatasetColumn[]; error: boolean; errorMessage: string | null; innerError: any | null; sortedRecordIds: string[]; records: Record<string, DatasetRecord>; sorting: DatasetSorting[]; filtering: DatasetFiltering; paging: DatasetPaging; linking: any; entityDisplayCollectionName: string; _capabilities: { hasRecordNavigation: boolean; }; getTargetEntityType?(): string; getViewId?(): string; getTitle?(): string; refresh?(): void; openDatasetItem?(recordId: string): void; clearSelectedRecordIds?(): void; setSelectedRecordIds?(recordIds: string[]): void; getSelectedRecordIds?(): string[]; getFormattedValue?(recordId: string, columnName: string): string | null; } /** * Type guard for dataset record */ declare function isDatasetRecord(value: any): value is DatasetRecord; /** * Type guard for lookup field value */ declare function isLookupFieldValue(value: DatasetFieldValue): value is LookupFieldValue; /** * Type guard for option set field value */ declare function isOptionSetFieldValue(value: DatasetFieldValue): value is OptionSetFieldValue; /** * Generic dataset with typed records */ interface TypedDataset<T extends DatasetRecord = DatasetRecord> extends Omit<PCFDataset, 'records'> { records: Record<string, T>; } /** * PCF Context Type Definitions * Types for PowerApps Component Framework context objects */ /** * PCF Input parameters with dataset support */ interface PCFInputs extends ComponentFramework.Dictionary { [key: string]: ComponentFramework.PropertyTypes.Property | PCFDataset; } /** * PCF Output parameters */ interface PCFOutputs extends ComponentFramework.Dictionary { [key: string]: any; } /** * Enhanced PCF Context with typed parameters */ interface PCFContext<TInputs extends PCFInputs = PCFInputs> extends ComponentFramework.Context<TInputs> { parameters: TInputs; webAPI: ComponentFramework.WebApi; navigation: ComponentFramework.Navigation; formatting: ComponentFramework.Formatting; resources: ComponentFramework.Resources; device: ComponentFramework.Device; client: ComponentFramework.Client; mode: ComponentFramework.Mode; updatedProperties: string[]; } /** * Standard Control interface with typed inputs/outputs */ interface PCFStandardControl<TInputs extends PCFInputs = PCFInputs, TOutputs extends PCFOutputs = PCFOutputs> extends ComponentFramework.StandardControl<TInputs, TOutputs> { init(context: PCFContext<TInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container: HTMLDivElement): void; updateView(context: PCFContext<TInputs>): void; getOutputs(): TOutputs; destroy(): void; } /** * React Control interface with typed inputs/outputs */ interface PCFReactControl<TInputs extends PCFInputs = PCFInputs, TOutputs extends PCFOutputs = PCFOutputs> extends ComponentFramework.ReactControl<TInputs, TOutputs> { init(context: PCFContext<TInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary): void; updateView(context: PCFContext<TInputs>): React.ReactElement; getOutputs(): TOutputs; destroy(): void; } /** * Dataverse Type Definitions * Core types for Dataverse metadata, entities, and WebAPI responses */ /** * Entity Metadata from Dataverse Web API */ interface EntityMetadata { MetadataId: string; LogicalName: string; SchemaName: string; EntitySetName: string; PrimaryIdAttribute: string; PrimaryNameAttribute: string; PrimaryImageAttribute?: string; LogicalCollectionName?: string; CollectionSchemaName?: string; EntityTypeCode?: number; IsActivity?: boolean; IsCustomEntity?: boolean; IsManaged?: boolean; IsValidForAdvancedFind?: boolean; DisplayName?: LocalizedLabel; DisplayCollectionName?: LocalizedLabel; Description?: LocalizedLabel; ObjectTypeCode?: number; OwnershipType?: 'UserOwned' | 'OrganizationOwned' | 'BusinessOwned' | 'None'; Attributes?: AttributeMetadata[]; } /** * Attribute Metadata from Dataverse Web API */ interface AttributeMetadata { MetadataId: string; LogicalName: string; SchemaName: string; AttributeType: AttributeTypeCode; AttributeTypeName?: AttributeTypeName; DisplayName?: LocalizedLabel; Description?: LocalizedLabel; IsCustomAttribute?: boolean; IsManaged?: boolean; IsValidForCreate?: boolean; IsValidForRead?: boolean; IsValidForUpdate?: boolean; IsPrimaryId?: boolean; IsPrimaryName?: boolean; RequiredLevel?: RequiredLevel; MaxLength?: number; MinValue?: number; MaxValue?: number; Precision?: number; Format?: string; FormatName?: string; DateTimeBehavior?: DateTimeBehavior; Options?: OptionMetadata[]; Targets?: string[]; } /** * Option Metadata for picklist/optionset fields */ interface OptionMetadata { Value: number; Label: LocalizedLabel; Description?: LocalizedLabel; Color?: string; IsManaged?: boolean; ExternalValue?: string; } /** * Localized Label structure */ interface LocalizedLabel { LocalizedLabels: Array<{ Label: string; LanguageCode: number; IsManaged: boolean; MetadataId: string; HasChanged?: boolean | null; }>; UserLocalizedLabel?: { Label: string; LanguageCode: number; IsManaged: boolean; MetadataId: string; HasChanged?: boolean | null; }; } /** * Attribute Type Codes */ type AttributeTypeCode = 'Boolean' | 'Customer' | 'DateTime' | 'Decimal' | 'Double' | 'Integer' | 'Lookup' | 'Money' | 'Owner' | 'PartyList' | 'Picklist' | 'State' | 'Status' | 'String' | 'Uniqueidentifier' | 'CalendarRules' | 'Virtual' | 'BigInt' | 'ManagedProperty' | 'EntityName' | 'MultiSelectPicklist' | 'Image' | 'File'; /** * Attribute Type Names (used in OData) */ type AttributeTypeName = { Value: AttributeTypeCode; }; /** * Required Level for attributes */ type RequiredLevel = { Value: 'None' | 'SystemRequired' | 'ApplicationRequired' | 'Recommended'; CanBeChanged?: boolean; ManagedPropertyLogicalName?: string; }; /** * DateTime Behavior for DateTime attributes */ type DateTimeBehavior = { Value: 'UserLocal' | 'DateOnly' | 'TimeZoneIndependent'; }; /** * View Metadata */ interface ViewMetadata$1 { savedqueryid: string; name: string; querytype: number; fetchxml: string; layoutxml?: string; returnedtypecode: string; isquickfindquery?: boolean; isdefault?: boolean; isprivate?: boolean; iscustomizable?: { Value: boolean; CanBeChanged: boolean; }; } /** * Relationship Metadata */ interface RelationshipMetadata { SchemaName: string; RelationshipType: 'OneToManyRelationship' | 'ManyToManyRelationship'; IsManaged?: boolean; IsCustomizable?: { Value: boolean; CanBeChanged: boolean; }; ReferencedEntity?: string; ReferencedAttribute?: string; ReferencingEntity?: string; ReferencingAttribute?: string; RelationshipBehavior?: number; CascadeConfiguration?: CascadeConfiguration; } /** * Cascade Configuration for relationships */ interface CascadeConfiguration { Assign?: CascadeType; Share?: CascadeType; Unshare?: CascadeType; Reparent?: CascadeType; Delete?: CascadeType; Merge?: CascadeType; } type CascadeType = 'NoCascade' | 'Cascade' | 'Active' | 'UserOwned' | 'RemoveLink' | 'Restrict'; /** * WebAPI Entity Response */ interface DataverseEntity extends Record<string, any> { '@odata.context'?: string; '@odata.etag'?: string; '@odata.id'?: string; '@odata.editLink'?: string; '@odata.type'?: string; } /** * WebAPI Response with Entities */ interface DataverseEntityCollection<T extends DataverseEntity = DataverseEntity> { '@odata.context': string; '@odata.count'?: number; '@odata.nextLink'?: string; value: T[]; } /** * Formatted Value Suffix */ declare const FORMATTED_VALUE_SUFFIX = "@OData.Community.Display.V1.FormattedValue"; /** * Navigation Property Suffix */ declare const NAVIGATION_PROPERTY_SUFFIX = "@Microsoft.Dynamics.CRM.associatednavigationproperty"; /** * Lookup Logical Name Suffix */ declare const LOOKUP_LOGICALNAME_SUFFIX = "@Microsoft.Dynamics.CRM.lookuplogicalname"; /** * Entity Reference */ interface EntityReference { id: string; entityType: string; name?: string; } /** * Typed entity with formatted values */ type EntityWithFormattedValues<T extends Record<string, any>> = T & { [K in keyof T as `${string & K}${typeof FORMATTED_VALUE_SUFFIX}`]?: string; } & { [K in keyof T as `${string & K}${typeof NAVIGATION_PROPERTY_SUFFIX}`]?: string; } & { [K in keyof T as `${string & K}${typeof LOOKUP_LOGICALNAME_SUFFIX}`]?: string; }; /** * Creates a Vite configuration optimized for PCF development */ declare function createPCFViteConfig(options?: PCFViteOptions): Promise<vite.UserConfigFnPromise>; /** * Simple PCF Lifecycle Management * Function-based approach without classes */ interface PCFInstanceManager { instance: ComponentFramework.StandardControl<any, any> | null; container: HTMLDivElement; context: ComponentFramework.Context<any>; pcfClass: new () => ComponentFramework.StandardControl<any, any>; } declare function createPCFManager(pcfClass: new () => ComponentFramework.StandardControl<any, any>, context: ComponentFramework.Context<any>, container: HTMLDivElement): PCFInstanceManager; declare function updatePCFView(manager: PCFInstanceManager): Promise<void>; declare function destroyPCF(manager: PCFInstanceManager): Promise<void>; declare function isPCFInitialized(manager: PCFInstanceManager): boolean; /** * Check if required environment variables are present */ declare function checkRequiredEnvVars(): { isValid: boolean; missing: string[]; }; /** * Redirect to setup if required environment variables are missing * Only applies to dataset components - field components don't need setup */ declare function redirectToSetupIfNeeded(componentType?: 'dataset' | 'field'): boolean; interface PCFHarnessOptions<TInputs, TOutputs> { /** The PCF component class to render */ pcfClass: new () => ComponentFramework.StandardControl<TInputs, TOutputs>; /** Container element ID (defaults to 'pcf-container') */ containerId?: string; /** Mock context options */ contextOptions?: { controlId?: string; viewId?: string; displayName?: string; userName?: string; userId?: string; datasetOptions?: Partial<ComponentFramework.PropertyTypes.DataSet>; entityType?: string; mockScenario?: 'account' | 'contact' | 'initiative' | 'custom'; }; /** Additional CSS class for the container */ className?: string; /** Custom context instead of mock */ customContext?: ComponentFramework.Context<TInputs>; /** PCF manifest information for devtools */ manifestInfo?: { namespace: string; constructor: string; version: string; displayName?: string; description?: string; componentType: 'dataset' | 'field'; datasets?: Array<{ name: string; displayNameKey?: string; }>; }; } interface PCFHarnessResult<TInputs> { context: ComponentFramework.Context<TInputs>; manifestInfo: { namespace: string; constructor: string; version: string; displayName?: string; description?: string; componentType: 'dataset' | 'field'; datasets?: Array<{ name: string; displayNameKey?: string; }>; }; container: HTMLElement; } /** * Initializes the PCF harness with PowerApps-like environment */ declare function initializePCFHarness<TInputs, TOutputs>(options: PCFHarnessOptions<TInputs, TOutputs>): PCFHarnessResult<TInputs>; /** * Simple initialization function for quick setup */ declare function initPCF<TInputs, TOutputs>(pcfClass: new () => ComponentFramework.StandardControl<TInputs, TOutputs>, containerId?: string): PCFHarnessResult<TInputs>; interface PowerAppsContainerProps { context: ComponentFramework.Context<any>; pcfClass: new () => ComponentFramework.StandardControl<any, any>; className?: string; manifestInfo?: { namespace: string; constructor: string; version: string; displayName?: string; description?: string; }; } declare const PowerAppsContainer: React$1.FC<PowerAppsContainerProps>; /** * Types for the PCF Setup Wizard */ interface SetupWizardData { pageTable?: string; pageTableName?: string; pageRecordId?: string; targetTable: string; targetTableName?: string; selectedRelationship?: RelationshipOption; availableRelationships?: RelationshipOption[]; selectedViewId?: string; selectedViewName?: string; } interface WizardStep { id: number; title: string; description: string; isOptional?: boolean; isComplete: boolean; isActive: boolean; } interface RelationshipOption { schemaName: string; displayName: string; referencingEntity: string; referencedEntity: string; referencingAttribute: string; lookupFieldName: string; relationshipType: 'OneToMany' | 'ManyToOne'; description?: string; } /** * SetupWizard - Main wizard container with step navigation */ interface SetupWizardProps { onComplete: (data: SetupWizardData) => void; onCancel?: () => void; } declare const SetupWizard: React$1.FC<SetupWizardProps>; /** * SetupComplete - Shows generated environment variables and completion actions */ interface SetupCompleteProps { data: SetupWizardData; onStartDevelopment: () => void; onBackToWizard: () => void; } declare const SetupComplete: React$1.FC<SetupCompleteProps>; /** * Step1TableSelection - Select page table (optional) */ interface Step1TableSelectionProps { data: SetupWizardData; onUpdate: (updates: Partial<SetupWizardData>) => void; onNext: () => void; onSkip: () => void; onCancel: () => void; } declare const Step1TableSelection: React$1.FC<Step1TableSelectionProps>; /** * Step2RecordIdInput - Select page record from dropdown when page table is selected */ interface Step2RecordIdInputProps { data: SetupWizardData; onUpdate: (updates: Partial<SetupWizardData>) => void; onNext: () => void; onPrevious: () => void; onCancel: () => void; } declare const Step2RecordIdInput: React$1.FC<Step2RecordIdInputProps>; /** * Step3TargetTableSelection - Select target/record table (required) */ interface Step3TargetTableSelectionProps { data: SetupWizardData; onUpdate: (updates: Partial<SetupWizardData>) => void; onNext: () => void; onPrevious: () => void; onCancel: () => void; } declare const Step3TargetTableSelection: React$1.FC<Step3TargetTableSelectionProps>; /** * Step4RelationshipSelection - Relationship discovery and selection step */ interface Step4RelationshipSelectionProps { data: SetupWizardData; onNext: (data: SetupWizardData) => void; onBack: () => void; } declare const Step4RelationshipSelection: React$1.FC<Step4RelationshipSelectionProps>; /** * Step5ViewSelection - Select a view for the target table */ interface Step5ViewSelectionProps { data: SetupWizardData; onUpdate: (updates: Partial<SetupWizardData>) => void; onComplete: () => void; onPrevious: () => void; onCancel: () => void; } declare const Step5ViewSelection: React$1.FC<Step5ViewSelectionProps>; /** * StepIndicator - Progress indicator showing current wizard step */ interface StepIndicatorProps { steps: WizardStep[]; currentStep: number; } declare const StepIndicator: React$1.FC<StepIndicatorProps>; /** * WizardLayout - FluentUI-based layout for the setup wizard */ interface WizardLayoutRef { focusContinueButton: () => void; } interface WizardLayoutProps { title: string; description?: string; children: React$1.ReactNode; canGoNext: boolean; canGoPrevious: boolean; isLoading?: boolean; error?: string; onNext: () => void; onPrevious: () => void; onCancel?: () => void; nextLabel?: string; previousLabel?: string; cancelLabel?: string; } declare const WizardLayout: React$1.ForwardRefExoticComponent<WizardLayoutProps & React$1.RefAttributes<WizardLayoutRef>>; /** * Utility functions for extracting PCF manifest information from various sources */ /** * Extract dataset information from manifest XML content */ declare function extractDatasetsFromXml(xmlContent: string): Array<{ name: string; displayNameKey?: string; }>; /** * Extract manifest information from ControlManifest.Input.xml content */ declare function extractManifestFromXml(xmlContent: string): { namespace: string; constructor: string; version: string; displayName?: string; description?: string; datasets?: Array<{ name: string; displayNameKey?: string; }>; } | null; /** * Extract manifest information from the built ControlManifest.xml content */ declare function extractManifestFromBuiltXml(xmlContent: string): { namespace: string; constructor: string; version: string; displayName?: string; description?: string; datasets?: Array<{ name: string; displayNameKey?: string; }>; } | null; /** * Auto-detect manifest information from the current project * This function attempts to find and parse ControlManifest.Input.xml files */ declare function autoDetectManifest(): Promise<{ namespace: string; constructor: string; version: string; displayName?: string; description?: string; } | null>; /** * Extract manifest info from PCF component class name * This is a heuristic approach that tries to infer namespace/constructor from the class */ declare function extractManifestFromComponentClass(pcfClass: new () => ComponentFramework.StandardControl<any, any>, fallbackNamespace?: string): { namespace: string; constructor: string; version: string; displayName?: string; description?: string; }; /** * Create manifest info from the actual test project values */ declare function createTestProjectManifest(): { namespace: string; constructor: string; version: string; displayName?: string; description?: string; }; /** * Simple manifest reader that works at build/initialization time * No runtime fetch needed - reads directly from file system during setup */ /** * Read manifest from file system (Node.js environment only) * This is called during initialization when the environment supports file system access */ declare function readManifestFromFileSystem(): { namespace: string; constructor: string; version: string; displayName?: string; description?: string; componentType: 'dataset' | 'field'; datasets?: Array<{ name: string; displayNameKey?: string; }>; } | null; /** * Enhanced detection that tries file system first, then falls back to class name */ declare function detectManifestInfo(pcfClass: new () => ComponentFramework.StandardControl<any, any>): { namespace: string; constructor: string; version: string; displayName?: string; description?: string; componentType: 'dataset' | 'field'; datasets?: Array<{ name: string; displayNameKey?: string; }>; }; /** * PCF Discovery Tool * * Functions to discover and analyze PCF controls on Dataverse forms, * including subgrid views, target entities, and relationship information. */ interface PCFManifest { namespace: string; constructor: string; version: string; displayName?: string; description?: string; } interface PCFControlInfo { controlId: string; namespace: string; constructor: string; version: string; formFactor: string; dataSet?: { name: string; viewId?: string; isUserView?: boolean; targetEntityType?: string; relationshipName?: string; enableViewPicker?: boolean; filteredViewIds?: string[]; }; parameters?: Record<string, unknown>; } interface FormPCFMatch { formId: string; formName: string; entityTypeCode: number; entityLogicalName?: string; controls: PCFControlInfo[]; } interface FormDiscoveryOptions { entityTypeCode?: number; entityLogicalName?: string; publisher?: string; } /** * Parse PCF manifest XML to extract control information */ declare function parsePCFManifest(manifestXml: string): PCFManifest; /** * Parse FormXml to extract detailed PCF control information including subgrid data */ declare function parseFormXmlForPCF(formXml: string): PCFControlInfo[]; /** * Find all forms containing the specified PCF control */ declare function findPCFOnForms(manifest: PCFManifest, options?: FormDiscoveryOptions | number): Promise<FormPCFMatch[]>; /** * Find all PCF controls on a specific form */ declare function getPCFControlsOnForm(formId: string): Promise<PCFControlInfo[]>; /** * Get all forms for a specific entity that contain PCF controls */ declare function getPCFFormsForEntity(entityTypeCode: number): Promise<FormPCFMatch[]>; /** * Analyze a PCF control's subgrid configuration */ declare function analyzePCFSubgridConfig(control: PCFControlInfo): { hasSubgrid: boolean; targetEntity?: string; isRelated: boolean; relationshipName?: string; viewId?: string; isCustomView: boolean; allowViewSelection: boolean; }; /** * Get entity type code mapping (common entities) */ declare const ENTITY_TYPE_CODES: { readonly ACCOUNT: 1; readonly CONTACT: 2; readonly OPPORTUNITY: 3; readonly LEAD: 4; readonly CASE: 112; readonly USER: 8; readonly TEAM: 9; }; type EntityTypeCode = (typeof ENTITY_TYPE_CODES)[keyof typeof ENTITY_TYPE_CODES]; /** * View Discovery - Find and analyze Dataverse views (saved queries and user queries) */ interface SavedQuery { savedqueryid: string; name: string; returnedtypecode: string; fetchxml: string; layoutxml?: string; querytype: number; isdefault: boolean; isprivate: boolean; description?: string; entityname?: string; } interface UserQuery { userqueryid: string; name: string; returnedtypecode: string; fetchxml: string; layoutxml?: string; description?: string; entityname?: string; } interface ViewInfo { id: string; name: string; entityName: string; entityTypeCode?: string; fetchXml: string; layoutXml?: string; isUserView: boolean; isDefault: boolean; isPrivate: boolean; description?: string; queryType?: number; } /** * Get all saved queries (system views) for a specific entity */ declare function getSystemViewsForEntity(entityLogicalName: string): Promise<SavedQuery[]>; /** * Get all user queries (personal views) for a specific entity */ declare function getUserViewsForEntity(entityLogicalName: string): Promise<UserQuery[]>; /** * Get all views (both system and user) for a specific entity */ declare function getAllViewsForEntity(entityLogicalName: string): Promise<ViewInfo[]>; /** * Get a specific saved query by ID */ declare function getSystemViewById(savedQueryId: string): Promise<SavedQuery | null>; /** * Get a specific user query by ID */ declare function getUserViewById(userQueryId: string): Promise<UserQuery | null>; /** * Get view by ID (tries both system and user views) */ declare function getViewById(viewId: string): Promise<ViewInfo | null>; /** * Get default view for an entity */ declare function getDefaultViewForEntity(entityLogicalName: string): Promise<ViewInfo | null>; /** * Discover all entities that have views */ declare function discoverEntitiesWithViews(): Promise<string[]>; /** * Search views by name across all entities */ declare function searchViewsByName(searchTerm: string, entityLogicalName?: string): Promise<ViewInfo[]>; /** * Record Retrieval - Get records using Dataverse views and FetchXML */ interface RecordRetrievalOptions { maxPageSize?: number; pageNumber?: number; includeCount?: boolean; additionalFilters?: string; orderBy?: string; } interface RecordRetrievalResult { entities: ComponentFramework.WebApi.Entity[]; totalCount?: number; nextLink?: string; previousLink?: string; success: boolean; error?: string; fetchXml?: string; viewInfo?: ViewInfo; } interface PaginatedRecordResult { entities: ComponentFramework.WebApi.Entity[]; totalCount?: number; hasNextPage: boolean; hasPreviousPage: boolean; pageInfo: { currentPage: number; pageSize: number; totalPages?: number; }; success: boolean; error?: string; } /** * Get records using a saved query (system view) */ declare function getRecordsForSystemView(savedQueryId: string, options?: RecordRetrievalOptions): Promise<RecordRetrievalResult>; /** * Get records using a user query (personal view) */ declare function getRecordsForUserView(userQueryId: string, options?: RecordRetrievalOptions): Promise<RecordRetrievalResult>; /** * Get records for any view (detects if it's system or user view) */ declare function getRecordsForView(viewId: string, options?: RecordRetrievalOptions): Promise<RecordRetrievalResult>; /** * Execute a view query and return records */ declare function executeViewQuery(viewInfo: ViewInfo, options?: RecordRetrievalOptions): Promise<RecordRetrievalResult>; /** * Execute FetchXML directly */ declare function executeFetchXml(fetchXml: string, entityLogicalName: string, options?: RecordRetrievalOptions): Promise<RecordRetrievalResult>; /** * Get paginated records from a view */ declare function getPaginatedRecordsForView(viewId: string, pageNumber?: number, pageSize?: number): Promise<PaginatedRecordResult>; /** * Get record count for a view */ declare function getRecordCountForView(viewId: string): Promise<number | null>; /** * Helper: Extract entity name from FetchXML */ declare function extractEntityNameFromFetchXml(fetchXml: string): string | null; /** * View Analyzer - Analyze FetchXML queries, view metadata, and performance characteristics */ interface FetchXmlAnalysis { isValid: boolean; entityName?: string; attributes: string[]; filters: FetchXmlFilter[]; joins: FetchXmlJoin[]; orderBy: FetchXmlOrderBy[]; groupBy: string[]; aggregates: FetchXmlAggregate[]; pagination: { hasPageInfo: boolean; page?: number; count?: number; }; complexity: { score: number; level: 'Simple' | 'Moderate' | 'Complex' | 'Very Complex'; factors: string[]; }; performance: { estimatedRows?: number; warnings: string[]; suggestions: string[]; }; errors: string[]; } interface FetchXmlFilter { attribute: string; operator: string; value?: string; type: 'filter' | 'condition'; entityAlias?: string; } interface FetchXmlJoin { entityName: string; alias?: string; type: 'inner' | 'left' | 'natural'; fromAttribute: string; toAttribute: string; } interface FetchXmlOrderBy { attribute: string; direction: 'asc' | 'desc'; entityAlias?: string; } interface FetchXmlAggregate { attribute: string; function: 'count' | 'sum' | 'avg' | 'min' | 'max'; alias: string; entityAlias?: string; } interface ViewMetadata { columns: ViewColumn[]; totalWidth?: number; hasCustomWidth: boolean; layoutType: 'grid' | 'list' | 'card' | 'unknown'; } interface ViewColumn { name: string; width?: number; isVisible: boolean; displayName?: string; dataType?: string; isPrimaryField: boolean; isSortable: boolean; } /** * Analyze FetchXML query structure and complexity */ declare function analyzeFetchXml(fetchXml: string): FetchXmlAnalysis; /** * Analyze view layout XML to extract column information */ declare function analyzeViewLayout(layoutXml?: string): ViewMetadata; /** * Validate FetchXML syntax and structure */ declare function validateFetchXml(fetchXml: string): { isValid: boolean; errors: string[]; }; /** * Extract all entity names referenced in a FetchXML query */ declare function extractReferencedEntities(fetchXml: string): string[]; /** * PCF Vite Harness - Modern development environment for PowerApps Component Framework * * This library provides a Vite-based development harness that replicates the PowerApps * environment for PCF components, enabling hot module replacement and modern tooling. */ declare const PCF_STYLES = "../styles/powerapps.css"; /** * Version of the PCF Vite Harness */ declare const VERSION = "1.1.0-beta.3"; export { type AttributeMetadata, type AttributeTypeCode, type AttributeTypeName, type BaseFieldValue, type BooleanFieldValue, type CascadeConfiguration, type CascadeType, type DatasetColumn, type DatasetColumnType, type DatasetFieldCollection, type DatasetFieldValue, type DatasetFiltering, type DatasetPaging, type DatasetRecord, type DatasetSorting, type DataverseEntity, type DataverseEntityCollection, type ViewMetadata$1 as DataverseViewMetadata, type DateFieldValue, type DateTimeBehavior, ENTITY_TYPE_CODES, type EntityMetadata, type EntityReference, type EntityTypeCode, type EntityWithFormattedValues, FORMATTED_VALUE_SUFFIX, type FetchXmlAggregate, type FetchXmlAnalysis, type FetchXmlFilter, type FetchXmlJoin, type FetchXmlOrderBy, type FormPCFMatch, LOOKUP_LOGICALNAME_SUFFIX, type LocalizedLabel, type LookupFieldValue, type MultiSelectOptionSetFieldValue, NAVIGATION_PROPERTY_SUFFIX, type NumberFieldValue, type OptionMetadata, type OptionSetFieldValue, type OptionSetOption, type PCFContext, type PCFControlInfo, type PCFDataset, type PCFInputs, type PCFInstanceManager, type PCFManifest, type PCFOutputs, type PCFReactControl, type PCFStandardControl, PCF_STYLES, type PaginatedRecordResult, PowerAppsContainer, type RecordRetrievalOptions, type RecordRetrievalResult, type RelationshipMetadata, type RequiredLevel, type SavedQuery, SetupComplete, SetupWizard, type SetupWizardData, type SortDirection, Step1TableSelection, Step2RecordIdInput, Step3TargetTableSelection, Step4RelationshipSelection, Step5ViewSelection, StepIndicator, type StringFieldValue, type TypedDataset, type UserQuery, VERSION, type ValidationResult, type ViewColumn, type ViewInfo, type ViewMetadata, WizardLayout, analyzeFetchXml, analyzePCFSubgridConfig, analyzeViewLayout, autoDetectManifest, checkRequiredEnvVars, createMockContext, createPCFManager, createPCFViteConfig, createTestProjectManifest, destroyPCF, detectManifestInfo, discoverEntitiesWithViews, executeFetchXml, executeViewQuery, extractDatasetsFromXml, extractEntityNameFromFetchXml, extractManifestFromBuiltXml, extractManifestFromComponentClass, extractManifestFromXml, extractReferencedEntities, findPCFOnForms, getAllViewsForEntity, getDefaultViewForEntity, getPCFControlsOnForm, getPCFFormsForEntity, getPaginatedRecordsForView, getRecordCountForView, getRecordsForSystemView, getRecordsForUserView, getRecordsForView, getSystemViewById, getSystemViewsForEntity, getUserViewById, getUserViewsForEntity, getViewById, initPCF, initializePCFHarness, isDatasetRecord, isLookupFieldValue, isOptionSetFieldValue, isPCFInitialized, parseFormXmlForPCF, parsePCFManifest, readManifestFromFileSystem, redirectToSetupIfNeeded, searchViewsByName, updatePCFView, validateFetchXml };