@snteam/amplify-angular-core 1.0.35 → 1.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -7,6 +7,767 @@ import { Observable } from 'rxjs';
7
7
  import { ErrorStateMatcher } from '@angular/material/core';
8
8
  import { MatDialog, MatDialogRef } from '@angular/material/dialog';
9
9
 
10
+ /**
11
+ * Interface for generating dynamic GraphQL selection sets for Amplify relationships
12
+ */
13
+ interface SelectionSetGenerator {
14
+ /**
15
+ * Generate a selection set for a given relationship configuration
16
+ * @param config The relationship configuration to analyze
17
+ * @returns Array of GraphQL field selectors
18
+ */
19
+ generateSelectionSet(config: RelationshipConfiguration): string[];
20
+ /**
21
+ * Generate a fallback selection set when primary generation fails
22
+ * @param fieldName The field name to create a basic selection set for
23
+ * @returns Array of basic GraphQL field selectors
24
+ */
25
+ generateFallbackSelectionSet(fieldName: string): string[];
26
+ /**
27
+ * Generate fallback selection set with progressive retry strategies
28
+ * @param fieldName The field name to create a selection set for
29
+ * @param previousErrors Array of previous error messages to skip failed strategies
30
+ * @returns Array of GraphQL field selectors using progressive fallback
31
+ */
32
+ generateFallbackSelectionSetWithRetry(fieldName: string, previousErrors?: string[]): string[];
33
+ /**
34
+ * Clear the internal cache of generated selection sets
35
+ */
36
+ clearCache(): void;
37
+ }
38
+ /**
39
+ * Configuration object describing a relationship between Amplify models
40
+ */
41
+ interface RelationshipConfiguration {
42
+ /** The name of the relationship/junction model (e.g., "FormViewField") */
43
+ relationshipModelName: string;
44
+ /** The name of the base/parent model (e.g., "FormView") */
45
+ baseModelName: string;
46
+ /** The field name used to access the related model (e.g., "formView") */
47
+ fieldName: string;
48
+ /** The foreign key field name in the relationship model (e.g., "formViewId") */
49
+ associatedWith: string;
50
+ }
51
+
52
+ /**
53
+ * Interface for analyzing relationship configurations to extract field mappings
54
+ */
55
+ interface ConfigurationAnalyzer {
56
+ /**
57
+ * Analyze a relationship configuration to extract field mappings and validate structure
58
+ * @param config The relationship configuration to analyze
59
+ * @returns Analysis result with extracted information and validation status
60
+ */
61
+ analyzeConfiguration(config: RelationshipConfiguration): AnalysisResult;
62
+ /**
63
+ * Extract the target model name from a relationship configuration
64
+ * @param config The relationship configuration to analyze
65
+ * @returns The name of the target model
66
+ */
67
+ extractTargetModelName(config: RelationshipConfiguration): string;
68
+ /**
69
+ * Determine appropriate field selectors for a target model
70
+ * @param targetModel The name of the target model
71
+ * @returns Array of field selector strings for common display properties
72
+ */
73
+ determineFieldSelectors(targetModel: string): string[];
74
+ }
75
+ /**
76
+ * Result of analyzing a relationship configuration
77
+ */
78
+ interface AnalysisResult {
79
+ /** The name of the target model extracted from the configuration */
80
+ targetModelName: string;
81
+ /** Array of field selectors appropriate for the target model */
82
+ fieldSelectors: string[];
83
+ /** Whether the configuration analysis was successful */
84
+ isValid: boolean;
85
+ /** Array of error messages if analysis failed */
86
+ errors: string[];
87
+ }
88
+
89
+ /**
90
+ * Interface for introspecting Amplify schema data to validate and enhance selection sets
91
+ */
92
+ interface SchemaIntrospector {
93
+ /**
94
+ * Get field information for a specific model from the schema
95
+ * @param modelName The name of the model to introspect
96
+ * @returns Array of field information for the model
97
+ */
98
+ getModelFields(modelName: string): ModelField[];
99
+ /**
100
+ * Validate that a specific field exists in a model
101
+ * @param modelName The name of the model to check
102
+ * @param fieldName The name of the field to validate
103
+ * @returns True if the field exists, false otherwise
104
+ */
105
+ validateFieldExists(modelName: string, fieldName: string): boolean;
106
+ /**
107
+ * Get common display fields for a model (e.g., name, title, label)
108
+ * @param modelName The name of the model to analyze
109
+ * @returns Array of field names suitable for display
110
+ */
111
+ getCommonDisplayFields(modelName: string): string[];
112
+ /**
113
+ * Check if schema introspection data is available
114
+ * @returns True if schema data is available, false otherwise
115
+ */
116
+ isSchemaAvailable(): boolean;
117
+ }
118
+ /**
119
+ * Information about a field in an Amplify model
120
+ */
121
+ interface ModelField {
122
+ /** The name of the field */
123
+ name: string;
124
+ /** The type of the field (string, number, object, etc.) */
125
+ type: string;
126
+ /** Whether the field is required */
127
+ isRequired: boolean;
128
+ /** Whether the field represents a relationship to another model */
129
+ isRelationship: boolean;
130
+ }
131
+
132
+ /**
133
+ * Cache key for storing generated selection sets
134
+ */
135
+ interface CacheKey {
136
+ /** The relationship model name */
137
+ relationshipModel: string;
138
+ /** The field name used to access the related model */
139
+ fieldName: string;
140
+ /** The target model name */
141
+ targetModel: string;
142
+ /** Optional schema version for cache invalidation */
143
+ schemaVersion?: string;
144
+ }
145
+ /**
146
+ * Cached selection set entry
147
+ */
148
+ interface CachedSelectionSet {
149
+ /** The cache key used to store this entry */
150
+ key: CacheKey;
151
+ /** The generated selection set */
152
+ selectionSet: string[];
153
+ /** Timestamp when this entry was created */
154
+ createdAt: Date;
155
+ /** Number of times this entry has been accessed */
156
+ accessCount: number;
157
+ }
158
+ /**
159
+ * Selection set generation patterns
160
+ */
161
+ declare enum SelectionSetPattern {
162
+ /** Basic relationship loading with id and common display fields */
163
+ BASIC = "basic",
164
+ /** Comprehensive field loading using wildcard selection */
165
+ COMPREHENSIVE = "comprehensive",
166
+ /** Selective field loading based on schema analysis */
167
+ SELECTIVE = "selective",
168
+ /** Minimal fallback pattern for error cases */
169
+ FALLBACK = "fallback"
170
+ }
171
+ /**
172
+ * Configuration for selection set generation
173
+ */
174
+ interface SelectionSetConfig {
175
+ /** The pattern to use for generation */
176
+ pattern: SelectionSetPattern;
177
+ /** Maximum nesting depth for relationships */
178
+ maxDepth: number;
179
+ /** Maximum number of fields to include */
180
+ maxFields: number;
181
+ /** Whether to include schema validation */
182
+ validateWithSchema: boolean;
183
+ /** Custom field names to always include */
184
+ requiredFields: string[];
185
+ /** Complexity limits for selection set validation */
186
+ complexityLimits: ComplexityLimits;
187
+ }
188
+ /**
189
+ * Complexity limits for selection set validation
190
+ */
191
+ interface ComplexityLimits {
192
+ /** Maximum nesting depth for relationships (default: 3) */
193
+ maxNestingDepth: number;
194
+ /** Maximum number of fields per selection set (default: 20) */
195
+ maxFieldCount: number;
196
+ /** Maximum number of wildcard selections allowed (default: 2) */
197
+ maxWildcardSelections: number;
198
+ /** Whether to detect and prevent circular references (default: true) */
199
+ preventCircularReferences: boolean;
200
+ /** Maximum length for individual field selectors (default: 100) */
201
+ maxSelectorLength: number;
202
+ }
203
+ /**
204
+ * Result of complexity validation
205
+ */
206
+ interface ComplexityValidationResult {
207
+ /** Whether the selection set passes complexity validation */
208
+ isValid: boolean;
209
+ /** List of validation errors if any */
210
+ errors: string[];
211
+ /** List of validation warnings */
212
+ warnings: string[];
213
+ /** Calculated complexity score */
214
+ complexityScore: number;
215
+ /** Detected circular references if any */
216
+ circularReferences: string[];
217
+ }
218
+ /**
219
+ * Display optimization configuration
220
+ */
221
+ interface DisplayOptimizationConfig {
222
+ /** Whether to enable display optimization */
223
+ enabled: boolean;
224
+ /** Fields that are commonly used for display */
225
+ commonDisplayFields: string[];
226
+ /** Fields that should be excluded from display optimization */
227
+ excludeFromOptimization: string[];
228
+ /** Whether to prioritize display fields over other fields */
229
+ prioritizeDisplayFields: boolean;
230
+ /** Maximum number of non-display fields to include */
231
+ maxNonDisplayFields: number;
232
+ }
233
+ /**
234
+ * Field classification for display optimization
235
+ */
236
+ declare enum FieldClassification {
237
+ /** Essential fields that must always be included */
238
+ ESSENTIAL = "essential",
239
+ /** Display fields commonly shown in UI */
240
+ DISPLAY = "display",
241
+ /** Metadata fields that provide additional context */
242
+ METADATA = "metadata",
243
+ /** Relationship fields that link to other models */
244
+ RELATIONSHIP = "relationship",
245
+ /** System fields used internally */
246
+ SYSTEM = "system",
247
+ /** Unknown or unclassified fields */
248
+ UNKNOWN = "unknown"
249
+ }
250
+ /**
251
+ * Field analysis result for optimization
252
+ */
253
+ interface FieldAnalysis {
254
+ /** The field selector */
255
+ selector: string;
256
+ /** Classification of the field */
257
+ classification: FieldClassification;
258
+ /** Priority score for inclusion (higher = more important) */
259
+ priority: number;
260
+ /** Estimated cost of including this field */
261
+ cost: number;
262
+ /** Whether this field is likely to be displayed in UI */
263
+ isDisplayRelevant: boolean;
264
+ }
265
+
266
+ /**
267
+ * Types of errors that can occur during selection set generation
268
+ */
269
+ declare enum SelectionSetErrorType {
270
+ /** Configuration is invalid or incomplete */
271
+ INVALID_CONFIGURATION = "invalid_configuration",
272
+ /** Target model not found in schema */
273
+ MODEL_NOT_FOUND = "model_not_found",
274
+ /** Field not found in target model */
275
+ FIELD_NOT_FOUND = "field_not_found",
276
+ /** Schema introspection data unavailable */
277
+ SCHEMA_UNAVAILABLE = "schema_unavailable",
278
+ /** Generated selection set exceeds complexity limits */
279
+ COMPLEXITY_EXCEEDED = "complexity_exceeded",
280
+ /** Circular reference detected in relationship chain */
281
+ CIRCULAR_REFERENCE = "circular_reference",
282
+ /** GraphQL query failed with generated selection set */
283
+ GRAPHQL_ERROR = "graphql_error"
284
+ }
285
+ /**
286
+ * Error information for selection set generation failures
287
+ */
288
+ interface SelectionSetError {
289
+ /** The type of error that occurred */
290
+ type: SelectionSetErrorType;
291
+ /** Human-readable error message */
292
+ message: string;
293
+ /** The relationship configuration that caused the error */
294
+ configuration?: RelationshipConfiguration;
295
+ /** The selection set that was being generated (if any) */
296
+ selectionSet?: string[];
297
+ /** Additional context information */
298
+ context?: Record<string, any>;
299
+ /** Timestamp when the error occurred */
300
+ timestamp: Date;
301
+ }
302
+ /**
303
+ * Result of a selection set generation attempt
304
+ */
305
+ interface SelectionSetResult {
306
+ /** Whether the generation was successful */
307
+ success: boolean;
308
+ /** The generated selection set (if successful) */
309
+ selectionSet?: string[];
310
+ /** Error information (if failed) */
311
+ error?: SelectionSetError;
312
+ /** Whether a fallback was used */
313
+ usedFallback: boolean;
314
+ /** The pattern that was used for generation */
315
+ patternUsed?: string;
316
+ }
317
+
318
+ /**
319
+ * Centralized error handling and logging service for the dynamic relationship loader system
320
+ *
321
+ * This service provides comprehensive error handling, logging, and recovery mechanisms
322
+ * for all relationship loading failures across the system.
323
+ */
324
+ declare class ErrorHandlerService {
325
+ /**
326
+ * Maximum number of error logs to keep in memory
327
+ */
328
+ private readonly MAX_ERROR_LOGS;
329
+ /**
330
+ * In-memory error log storage for debugging
331
+ */
332
+ private errorLogs;
333
+ /**
334
+ * Error statistics for monitoring
335
+ */
336
+ private errorStats;
337
+ /**
338
+ * Log a selection set generation error with comprehensive context
339
+ */
340
+ logSelectionSetError(type: SelectionSetErrorType, message: string, config?: RelationshipConfiguration, selectionSet?: string[], additionalContext?: Record<string, any>): SelectionSetError;
341
+ /**
342
+ * Log a GraphQL query error with retry context
343
+ */
344
+ logGraphQLError(error: any, config: RelationshipConfiguration, selectionSet: string[], retryAttempt: number, previousErrors?: string[]): SelectionSetError;
345
+ /**
346
+ * Log a configuration analysis error
347
+ */
348
+ logConfigurationError(config: RelationshipConfiguration | null, errors: string[], additionalContext?: Record<string, any>): SelectionSetError;
349
+ /**
350
+ * Log a schema introspection error
351
+ */
352
+ logSchemaError(modelName: string, fieldName?: string, additionalContext?: Record<string, any>): SelectionSetError;
353
+ /**
354
+ * Log a complexity validation error
355
+ */
356
+ logComplexityError(selectionSet: string[], validationErrors: string[], config?: RelationshipConfiguration): SelectionSetError;
357
+ /**
358
+ * Log a circular reference error
359
+ */
360
+ logCircularReferenceError(circularPath: string, selectionSet: string[], config?: RelationshipConfiguration): SelectionSetError;
361
+ /**
362
+ * Log a successful error recovery
363
+ */
364
+ logSuccessfulRecovery(originalError: SelectionSetError, recoveryMethod: string, finalSelectionSet: string[]): void;
365
+ /**
366
+ * Log a failed error recovery attempt
367
+ */
368
+ logFailedRecovery(originalError: SelectionSetError, recoveryAttempts: string[], finalError: any): void;
369
+ /**
370
+ * Create a SelectionSetResult for a successful operation
371
+ */
372
+ createSuccessResult(selectionSet: string[], patternUsed?: string, usedFallback?: boolean): SelectionSetResult;
373
+ /**
374
+ * Create a SelectionSetResult for a failed operation
375
+ */
376
+ createErrorResult(error: SelectionSetError): SelectionSetResult;
377
+ /**
378
+ * Get error statistics for monitoring and debugging
379
+ */
380
+ getErrorStats(): {
381
+ totalErrors: number;
382
+ errorsByType: Record<string, number>;
383
+ lastError: SelectionSetError | null;
384
+ recoveryAttempts: number;
385
+ successfulRecoveries: number;
386
+ recoveryRate: number;
387
+ recentErrors: SelectionSetError[];
388
+ };
389
+ /**
390
+ * Get recent error logs for debugging
391
+ */
392
+ getRecentErrors(count?: number): SelectionSetError[];
393
+ /**
394
+ * Clear all error logs and reset statistics
395
+ */
396
+ clearErrorLogs(): void;
397
+ /**
398
+ * Check if the system is experiencing high error rates
399
+ */
400
+ isHighErrorRate(timeWindowMinutes?: number, threshold?: number): boolean;
401
+ /**
402
+ * Get error patterns for analysis
403
+ */
404
+ getErrorPatterns(): {
405
+ mostCommonErrorType: SelectionSetErrorType | null;
406
+ mostProblematicModel: string | null;
407
+ mostProblematicField: string | null;
408
+ errorTrends: Array<{
409
+ hour: string;
410
+ errorCount: number;
411
+ }>;
412
+ };
413
+ /**
414
+ * Add error to the log with size management
415
+ */
416
+ private addErrorLog;
417
+ /**
418
+ * Update error statistics
419
+ */
420
+ private updateErrorStats;
421
+ /**
422
+ * Calculate recovery rate percentage
423
+ */
424
+ private getRecoveryRate;
425
+ /**
426
+ * Log error to console with structured format
427
+ */
428
+ private logToConsole;
429
+ static ɵfac: i0.ɵɵFactoryDeclaration<ErrorHandlerService, never>;
430
+ static ɵprov: i0.ɵɵInjectableDeclaration<ErrorHandlerService>;
431
+ }
432
+
433
+ /**
434
+ * Service for analyzing relationship configurations to extract field mappings
435
+ *
436
+ * This service analyzes relationship configurations to determine target models
437
+ * and generate appropriate field selectors for GraphQL queries.
438
+ */
439
+ declare class ConfigurationAnalyzerService implements ConfigurationAnalyzer {
440
+ private errorHandler;
441
+ /**
442
+ * Common display field names to look for in models
443
+ */
444
+ private readonly COMMON_DISPLAY_FIELDS;
445
+ constructor(errorHandler: ErrorHandlerService);
446
+ /**
447
+ * Analyze a relationship configuration to extract field mappings and validate structure
448
+ * Enhanced with comprehensive error handling and logging
449
+ */
450
+ analyzeConfiguration(config: RelationshipConfiguration): AnalysisResult;
451
+ /**
452
+ * Extract the target model name from a relationship configuration
453
+ * Enhanced with error handling and validation
454
+ *
455
+ * For a FormViewField relationship, this would extract the target model
456
+ * that we want to display (e.g., "Field" from the FormViewField junction)
457
+ */
458
+ extractTargetModelName(config: RelationshipConfiguration): string;
459
+ /**
460
+ * Determine appropriate field selectors for a target model
461
+ *
462
+ * This generates GraphQL field selectors that include the relationship field
463
+ * and common display properties like id, name, title, etc.
464
+ */
465
+ determineFieldSelectors(targetModel: string): string[];
466
+ /**
467
+ * Parse and validate nested relationship paths
468
+ *
469
+ * Handles complex relationship configurations like "formView.user.profile"
470
+ * and validates for circular references
471
+ */
472
+ parseNestedRelationshipPath(fieldName: string, maxDepth?: number): string[];
473
+ /**
474
+ * Generate field selectors for nested relationship paths
475
+ *
476
+ * Creates GraphQL selectors that can handle nested relationships
477
+ * like "formView.user.profile.name"
478
+ */
479
+ generateNestedFieldSelectors(fieldName: string, targetModel: string): string[];
480
+ /**
481
+ * Enhanced field selector determination that supports nested paths
482
+ */
483
+ determineFieldSelectorsEnhanced(targetModel: string, fieldName?: string): string[];
484
+ /**
485
+ * Convert a string to PascalCase (first letter uppercase, rest camelCase)
486
+ */
487
+ private toPascalCase;
488
+ /**
489
+ * Convert a string to camelCase (first letter lowercase)
490
+ */
491
+ private toCamelCase;
492
+ static ɵfac: i0.ɵɵFactoryDeclaration<ConfigurationAnalyzerService, never>;
493
+ static ɵprov: i0.ɵɵInjectableDeclaration<ConfigurationAnalyzerService>;
494
+ }
495
+
496
+ /**
497
+ * Service for introspecting Amplify schema data to validate and enhance selection sets
498
+ *
499
+ * This service leverages Amplify's schema introspection data to validate field existence,
500
+ * extract model information, and provide schema-aware field selection for GraphQL queries.
501
+ */
502
+ declare class SchemaIntrospectorService implements SchemaIntrospector {
503
+ private errorHandler;
504
+ private amplifyOutputs;
505
+ /**
506
+ * Common display field names that are typically used for showing model data
507
+ */
508
+ private readonly COMMON_DISPLAY_FIELDS;
509
+ /**
510
+ * System fields that are typically not used for display
511
+ */
512
+ private readonly SYSTEM_FIELDS;
513
+ constructor(errorHandler: ErrorHandlerService);
514
+ /**
515
+ * Initialize the service with Amplify outputs data
516
+ * Enhanced with error handling and validation
517
+ * This should be called by consuming applications to provide schema data
518
+ */
519
+ initializeSchema(amplifyOutputs: any): void;
520
+ /**
521
+ * Get field information for a specific model from the schema
522
+ * Enhanced with comprehensive error handling and logging
523
+ */
524
+ getModelFields(modelName: string): ModelField[];
525
+ /**
526
+ * Validate that a specific field exists in a model
527
+ */
528
+ validateFieldExists(modelName: string, fieldName: string): boolean;
529
+ /**
530
+ * Get common display fields for a model (e.g., name, title, label)
531
+ */
532
+ getCommonDisplayFields(modelName: string): string[];
533
+ /**
534
+ * Check if schema introspection data is available
535
+ */
536
+ isSchemaAvailable(): boolean;
537
+ /**
538
+ * Get conservative display fields when schema data is unavailable
539
+ * This provides a safe fallback that works with most Amplify models
540
+ */
541
+ getConservativeDisplayFields(modelName: string): string[];
542
+ /**
543
+ * Get model fields with fallback behavior when schema is unavailable
544
+ */
545
+ getModelFieldsWithFallback(modelName: string): ModelField[];
546
+ /**
547
+ * Validate field existence with fallback behavior
548
+ * When schema is unavailable, assumes common fields exist
549
+ */
550
+ validateFieldExistsWithFallback(modelName: string, fieldName: string): boolean;
551
+ /**
552
+ * Get safe field selectors that work even when schema data is unavailable
553
+ * This method prioritizes reliability over completeness
554
+ */
555
+ getSafeFieldSelectors(modelName: string, fieldName: string): string[];
556
+ /**
557
+ * Get schema status information for debugging
558
+ */
559
+ getSchemaStatus(): {
560
+ isAvailable: boolean;
561
+ modelCount: number;
562
+ availableModels: string[];
563
+ lastError?: string;
564
+ };
565
+ /**
566
+ * Get all available model names from the schema
567
+ */
568
+ getAvailableModels(): string[];
569
+ /**
570
+ * Get detailed information about a specific model
571
+ */
572
+ getModelInfo(modelName: string): any;
573
+ /**
574
+ * Determine the simplified type of a field from Amplify schema data
575
+ */
576
+ private determineFieldType;
577
+ /**
578
+ * Check if a field represents a relationship to another model
579
+ */
580
+ private isRelationshipField;
581
+ /**
582
+ * Get relationship information for a field
583
+ */
584
+ getRelationshipInfo(modelName: string, fieldName: string): any;
585
+ static ɵfac: i0.ɵɵFactoryDeclaration<SchemaIntrospectorService, never>;
586
+ static ɵprov: i0.ɵɵInjectableDeclaration<SchemaIntrospectorService>;
587
+ }
588
+
589
+ /**
590
+ * Service for generating dynamic GraphQL selection sets for Amplify relationships
591
+ *
592
+ * This service replaces hardcoded selection set logic with dynamic generation
593
+ * based on relationship configurations, schema introspection, and intelligent caching.
594
+ */
595
+ declare class SelectionSetGeneratorService implements SelectionSetGenerator {
596
+ private configurationAnalyzer;
597
+ private schemaIntrospector;
598
+ private errorHandler;
599
+ /**
600
+ * Cache for generated selection sets to improve performance
601
+ */
602
+ private selectionSetCache;
603
+ /**
604
+ * Default configuration for selection set generation
605
+ */
606
+ private readonly DEFAULT_CONFIG;
607
+ /**
608
+ * Default display optimization configuration
609
+ */
610
+ private readonly DEFAULT_DISPLAY_CONFIG;
611
+ constructor(configurationAnalyzer: ConfigurationAnalyzerService, schemaIntrospector: SchemaIntrospectorService, errorHandler: ErrorHandlerService);
612
+ /**
613
+ * Generate a selection set for a given relationship configuration
614
+ * Enhanced with comprehensive error handling and logging
615
+ */
616
+ generateSelectionSet(config: RelationshipConfiguration): string[];
617
+ /**
618
+ * Generate a fallback selection set when primary generation fails
619
+ * Uses progressive fallback strategies: comprehensive → selective → minimal
620
+ * Enhanced with comprehensive error handling and logging
621
+ */
622
+ generateFallbackSelectionSet(fieldName: string): string[];
623
+ /**
624
+ * Generate comprehensive fallback selection set using schema data
625
+ * This is the first fallback strategy when schema is available
626
+ */
627
+ private generateComprehensiveFallbackSelectionSet;
628
+ /**
629
+ * Generate selective fallback selection set using common field patterns
630
+ * This is the second fallback strategy when schema is unavailable
631
+ */
632
+ private generateSelectiveFallbackSelectionSet;
633
+ /**
634
+ * Generate minimal fallback selection set for critical error cases
635
+ * This is the last resort fallback strategy
636
+ */
637
+ private generateMinimalFallbackSelectionSet;
638
+ /**
639
+ * Generate fallback selection set with retry logic
640
+ * Attempts multiple fallback strategies and validates each one
641
+ * Enhanced with comprehensive error handling and recovery tracking
642
+ */
643
+ generateFallbackSelectionSetWithRetry(fieldName: string, previousErrors?: string[]): string[];
644
+ /**
645
+ * Handle generation errors by attempting fallback with comprehensive logging
646
+ */
647
+ private handleGenerationError;
648
+ /**
649
+ * Validate a selection set for basic correctness
650
+ */
651
+ private validateSelectionSet;
652
+ /**
653
+ * Clear the internal cache of generated selection sets
654
+ */
655
+ clearCache(): void;
656
+ /**
657
+ * Generate selection set from configuration analysis result
658
+ */
659
+ private generateSelectionSetFromAnalysis;
660
+ /**
661
+ * Generate selection set using schema introspection data
662
+ */
663
+ private generateSchemaAwareSelectionSet;
664
+ /**
665
+ * Generate selection set using configuration analysis only
666
+ */
667
+ private generateConfigurationBasedSelectionSet;
668
+ /**
669
+ * Apply display optimization to prioritize display-relevant fields
670
+ */
671
+ private applyDisplayOptimization;
672
+ /**
673
+ * Analyze a field selector for display optimization
674
+ */
675
+ private analyzeFieldForDisplay;
676
+ /**
677
+ * Check if a selector represents a relationship field
678
+ */
679
+ private isRelationshipField;
680
+ /**
681
+ * Check if a relationship field is likely to be displayed
682
+ */
683
+ private isDisplayRelevantRelationship;
684
+ /**
685
+ * Check if a selector represents a metadata field
686
+ */
687
+ private isMetadataField;
688
+ /**
689
+ * Check if a selector represents a system field
690
+ */
691
+ private isSystemField;
692
+ /**
693
+ * Apply complexity limits to prevent overly expensive GraphQL queries
694
+ * Enhanced with comprehensive error handling and logging
695
+ */
696
+ private applyComplexityLimits;
697
+ /**
698
+ * Validate selection set complexity against configured limits
699
+ */
700
+ private validateSelectionSetComplexity;
701
+ /**
702
+ * Detect circular references in field paths
703
+ */
704
+ private detectCircularReference;
705
+ /**
706
+ * Calculate complexity score for a selection set
707
+ */
708
+ private calculateComplexityScore;
709
+ /**
710
+ * Fix complexity issues in a selection set
711
+ */
712
+ private fixComplexityIssues;
713
+ /**
714
+ * Generate a cache key for a relationship configuration
715
+ */
716
+ private generateCacheKey;
717
+ /**
718
+ * Get cached selection set if available
719
+ */
720
+ private getCachedSelectionSet;
721
+ /**
722
+ * Cache a generated selection set
723
+ */
724
+ private cacheSelectionSet;
725
+ /**
726
+ * Evict oldest cache entries when cache gets too large
727
+ */
728
+ private evictOldestCacheEntries;
729
+ /**
730
+ * Get schema version for cache invalidation
731
+ */
732
+ private getSchemaVersion;
733
+ /**
734
+ * Get cache statistics for debugging
735
+ */
736
+ getCacheStats(): {
737
+ size: number;
738
+ totalAccesses: number;
739
+ entries: Array<{
740
+ key: CacheKey;
741
+ selectionSet: string[];
742
+ createdAt: Date;
743
+ accessCount: number;
744
+ }>;
745
+ };
746
+ /**
747
+ * Get optimization statistics for debugging
748
+ */
749
+ getOptimizationStats(): {
750
+ displayOptimizationEnabled: boolean;
751
+ complexityLimits: ComplexityLimits;
752
+ displayConfig: DisplayOptimizationConfig;
753
+ };
754
+ /**
755
+ * Analyze a selection set for optimization opportunities
756
+ */
757
+ analyzeSelectionSetOptimization(selectionSet: string[]): {
758
+ totalFields: number;
759
+ displayRelevantFields: number;
760
+ complexityScore: number;
761
+ optimizationOpportunities: string[];
762
+ };
763
+ /**
764
+ * Initialize the service with schema data
765
+ */
766
+ initializeWithSchema(amplifyOutputs: any): void;
767
+ static ɵfac: i0.ɵɵFactoryDeclaration<SelectionSetGeneratorService, never>;
768
+ static ɵprov: i0.ɵɵInjectableDeclaration<SelectionSetGeneratorService>;
769
+ }
770
+
10
771
  declare class AmplifyAngularCore {
11
772
  static ɵfac: i0.ɵɵFactoryDeclaration<AmplifyAngularCore, never>;
12
773
  static ɵcmp: i0.ɵɵComponentDeclaration<AmplifyAngularCore, "snteam-amplify-angular-core", never, {}, {}, never, never, true, never>;
@@ -98,8 +859,10 @@ declare class FormGroupQuestion<T> extends QuestionBase<T> {
98
859
  }
99
860
 
100
861
  declare class AmplifyModelService {
862
+ private selectionSetGenerator;
863
+ private errorHandler;
101
864
  private client;
102
- constructor();
865
+ constructor(selectionSetGenerator: SelectionSetGeneratorService, errorHandler: ErrorHandlerService);
103
866
  /**
104
867
  * Initialize the service with the Amplify client
105
868
  * This should be called by the consuming application after Amplify.configure()
@@ -125,12 +888,60 @@ declare class AmplifyModelService {
125
888
  deleteRelationship(relModel: string, relId: string): Promise<any>;
126
889
  createRelationship(relModel: string, relItem: any): Promise<any> | null;
127
890
  getRelationshipFilter(config: any, baseId?: string, removeIds?: string[]): any;
128
- getAmplifySelectionSet(config: any, baseId: string): any;
891
+ /**
892
+ * Generate dynamic selection set for relationship queries
893
+ * Replaces hardcoded selection set logic with dynamic generation
894
+ * Enhanced with comprehensive error handling and logging
895
+ * @param config Relationship configuration object
896
+ * @param baseId Base record ID (for compatibility, not used in generation)
897
+ * @returns Array of GraphQL field selectors
898
+ */
899
+ getAmplifySelectionSet(config: RelationshipConfiguration, baseId: string): string[];
129
900
  setRelatedSub(config: any, baseId: string): Observable<any> | null;
130
901
  /**
131
- * @param config {object} - see dynamic-relationship-builder.component getDetailsForManyToMany() for example of building config
902
+ * Get related items with enhanced error handling and retry logic
903
+ * @param config Relationship configuration object
904
+ * @param baseId Base record ID to filter relationships
905
+ * @returns Observable of related items with retry logic on GraphQL errors
906
+ */
907
+ getRelatedItems(config: RelationshipConfiguration, baseId: string): Observable<any> | null;
908
+ /**
909
+ * Get related items with progressive retry logic for GraphQL errors
910
+ * Implements progressive fallback: original → comprehensive → selective → minimal
911
+ */
912
+ private getRelatedItemsWithRetry;
913
+ /**
914
+ * Handle GraphQL query errors with retry logic
915
+ * Enhanced with comprehensive error logging and context
916
+ */
917
+ private handleQueryError;
918
+ /**
919
+ * Determine if an error should trigger a retry
920
+ * Enhanced with comprehensive error pattern matching
132
921
  */
133
- getRelatedItems(config: any, baseId: string): Observable<any> | null;
922
+ private shouldRetryOnError;
923
+ /**
924
+ * Validate that relationship field data is populated in query results
925
+ * Enhanced with comprehensive error logging
926
+ */
927
+ private validateRelationshipFieldPopulation;
928
+ /**
929
+ * Log query attempt details
930
+ */
931
+ private logQueryAttempt;
932
+ /**
933
+ * Log successful query details
934
+ */
935
+ private logQuerySuccess;
936
+ /**
937
+ * Log query error details
938
+ */
939
+ private logQueryError;
940
+ /**
941
+ * Log final failure when all retries are exhausted
942
+ * Enhanced with comprehensive error context and recovery suggestions
943
+ */
944
+ private logFinalFailure;
134
945
  createItemPromise(model: string, payload: any): Promise<any> | null;
135
946
  updateItemForModel(model: string, payload: any): Promise<any> | null;
136
947
  deleteItemForModel(model: string, id: string): Promise<any> | null;
@@ -313,13 +1124,16 @@ declare class ConfigurationsComponent implements OnInit {
313
1124
  ngOnInit(): void;
314
1125
  get outputs(): any;
315
1126
  checkAvailableModels(): void;
316
- private formatModelLabel;
317
1127
  populateDefaultFieldConfigs(): Promise<void>;
318
1128
  deleteAllConfigs(modelName: string): Promise<void>;
319
1129
  deleteTableConfigs(): Promise<void>;
320
1130
  deleteFormViews(): Promise<void>;
321
1131
  deleteListViews(): Promise<void>;
322
1132
  deleteFieldConfigs(): Promise<void>;
1133
+ populateDefaultTableConfigs(): Promise<void>;
1134
+ private formatModelLabel;
1135
+ private formatFieldLabel;
1136
+ private mapFieldType;
323
1137
  static ɵfac: i0.ɵɵFactoryDeclaration<ConfigurationsComponent, never>;
324
1138
  static ɵcmp: i0.ɵɵComponentDeclaration<ConfigurationsComponent, "snteam-configurations", never, { "amplifyOutputs": { "alias": "amplifyOutputs"; "required": false; }; }, {}, never, never, true, never>;
325
1139
  }
@@ -407,14 +1221,63 @@ declare class RecordRelationshipsComponent implements OnInit {
407
1221
 
408
1222
  declare class DynamicRelationshipBuilderComponent implements OnInit {
409
1223
  private ams;
1224
+ private errorHandler;
410
1225
  m2m: any;
411
1226
  item: any;
412
1227
  model: string;
413
- m2mItems: any;
414
- constructor(ams: AmplifyModelService);
1228
+ m2mItems: any[];
1229
+ errorMessage: string;
1230
+ isLoading: boolean;
1231
+ constructor(ams: AmplifyModelService, errorHandler: ErrorHandlerService);
415
1232
  modelItem: any;
416
1233
  readonly dialog: MatDialog;
417
1234
  ngOnInit(): void;
1235
+ /**
1236
+ * Set error message and clear loading state
1237
+ * Enhanced with comprehensive error context logging
1238
+ */
1239
+ private setError;
1240
+ /**
1241
+ * Clear error message and log recovery
1242
+ */
1243
+ private clearError;
1244
+ /**
1245
+ * Get display name for a relationship item, handling various field names
1246
+ */
1247
+ getDisplayName(relationshipItem: any): string;
1248
+ /**
1249
+ * Get display name for items with partial or missing relationship data
1250
+ */
1251
+ getPartialDisplayName(item: any): string;
1252
+ /**
1253
+ * Check if an item has complete relationship data
1254
+ */
1255
+ hasCompleteRelationshipData(item: any): boolean;
1256
+ /**
1257
+ * Check if an item has partial relationship data (item exists but relationship data is incomplete)
1258
+ */
1259
+ hasPartialRelationshipData(item: any): boolean;
1260
+ /**
1261
+ * Get loading state indicator for relationship data
1262
+ */
1263
+ getRelationshipLoadingState(item: any): 'complete' | 'partial' | 'missing' | 'loading';
1264
+ /**
1265
+ * Get appropriate CSS class for relationship item based on data completeness
1266
+ */
1267
+ getRelationshipItemClass(item: any): string;
1268
+ /**
1269
+ * Get tooltip text for relationship items based on their data state
1270
+ */
1271
+ getRelationshipTooltip(item: any): string;
1272
+ /**
1273
+ * Get summary of data states for all relationship items
1274
+ */
1275
+ getDataStateSummary(): {
1276
+ completeCount: number;
1277
+ partialCount: number;
1278
+ missingCount: number;
1279
+ hasPartialOrMissing: boolean;
1280
+ };
418
1281
  perhapsAddM2MItem(item: any): Promise<void>;
419
1282
  setCreateSubscription(): void;
420
1283
  listItems(): void;
@@ -454,5 +1317,5 @@ declare class ValToTitlePipe implements PipeTransform {
454
1317
  static ɵpipe: i0.ɵɵPipeDeclaration<ValToTitlePipe, "valToTitle", true>;
455
1318
  }
456
1319
 
457
- export { AddRelationshipDialogComponent, AmplifyAngularCore, AmplifyFormBuilderService, AmplifyModelService, AsyncDropdownQuestion, ConfigurationsComponent, DatePickerQuestion, DateTimePickerQuestion, DropdownQuestion, DynamicFormComponent, DynamicFormGroupComponent, DynamicFormQuestionComponent, DynamicNestedFormQuestionComponent, DynamicRelationshipBuilderComponent, EmailQuestion, FormGroupQuestion, ListViewComponent, MyErrorStateMatcher, NumberQuestion, PhoneQuestion, QuestionBase, QuestionControlService, RecordRelationshipsComponent, SliderQuestion, TextboxQuestion, TimePickerQuestion, ValToTitlePipe, phoneNumberValidator };
458
- export type { DialogData, RowAction };
1320
+ export { AddRelationshipDialogComponent, AmplifyAngularCore, AmplifyFormBuilderService, AmplifyModelService, AsyncDropdownQuestion, ConfigurationAnalyzerService, ConfigurationsComponent, DatePickerQuestion, DateTimePickerQuestion, DropdownQuestion, DynamicFormComponent, DynamicFormGroupComponent, DynamicFormQuestionComponent, DynamicNestedFormQuestionComponent, DynamicRelationshipBuilderComponent, EmailQuestion, FieldClassification, FormGroupQuestion, ListViewComponent, MyErrorStateMatcher, NumberQuestion, PhoneQuestion, QuestionBase, QuestionControlService, RecordRelationshipsComponent, SchemaIntrospectorService, SelectionSetErrorType, SelectionSetGeneratorService, SelectionSetPattern, SliderQuestion, TextboxQuestion, TimePickerQuestion, ValToTitlePipe, phoneNumberValidator };
1321
+ export type { AnalysisResult, CacheKey, CachedSelectionSet, ComplexityLimits, ComplexityValidationResult, ConfigurationAnalyzer, DialogData, DisplayOptimizationConfig, FieldAnalysis, ModelField, RelationshipConfiguration, RowAction, SchemaIntrospector, SelectionSetConfig, SelectionSetError, SelectionSetGenerator, SelectionSetResult };