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,CAAO,KAAK,CAAA,EAAG;AAC5B,QAAA,MAAA,CAAO,KAAK,CAAA,2BAAA,EAA8B,SAAA,CAAU,IAAI,CAAA,GAAA,EAAM,MAAA,CAAO,KAAK,CAAA,CAAE,CAAA;AAAA,MAC9E;AACA,MAAA,MAAA,CAAO,GAAA,CAAI,OAAO,KAAK,CAAA;AAAA,IACzB;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,OAAO,MAAA,KAAW,CAAA;AAAA,IAC3B,MAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-IF2SU3NK.mjs","sourcesContent":["import type { \n  EntityDefinition, \n  AttributeMetadata,\n  LocalizedLabel\n} from '../types.js'\nimport type {\n  GlobalOptionSetDefinition,\n  PicklistAttributeMetadata,\n  MultiSelectPicklistAttributeMetadata,\n  LookupAttributeMetadata,\n  StateAttributeMetadata,\n  StatusAttributeMetadata\n} from '../client/index.js'\n\n/**\n * Related entity information for type-safe nested expands\n */\nexport interface RelatedEntityInfo {\n  relationshipName: string // e.g., \"pum_program\"\n  targetEntityLogicalName: string // e.g., \"pum_program\" \n  targetEntitySetName: string // e.g., \"pum_programs\"\n  relationshipType: 'OneToMany' | 'ManyToOne' | 'ManyToMany'\n}\n\n/**\n * Processed entity metadata for type generation\n */\nexport interface ProcessedEntityMetadata {\n  logicalName: string\n  schemaName: string\n  displayName: string\n  description?: string\n  primaryIdAttribute: string\n  primaryNameAttribute: string\n  entitySetName: string\n  isCustomEntity: boolean\n  attributes: ProcessedAttributeMetadata[]\n  optionSets: ProcessedOptionSet[]\n  expandableProperties: string[] // Lookup fields + relationship names for $expand\n  oneToManyRelationships: ProcessedRelationshipMetadata[]\n  manyToOneRelationships: ProcessedRelationshipMetadata[]\n  manyToManyRelationships: ProcessedManyToManyRelationshipMetadata[]\n  /** Related entities with their full metadata for type-safe expands */\n  relatedEntities: Record<string, RelatedEntityInfo>\n}\n\n/**\n * String attribute metadata for processing\n */\ninterface StringAttributeTypeMetadata {\n  MaxLength?: number\n  Format?: string\n}\n\n/**\n * Numeric attribute metadata for processing\n */\ninterface NumericAttributeTypeMetadata {\n  MinValue?: number\n  MaxValue?: number\n  Precision?: number\n}\n\n/**\n * DateTime attribute metadata for processing\n */\ninterface DateTimeAttributeTypeMetadata {\n  Format?: string\n}\n\n/**\n * Processed attribute metadata\n */\nexport interface ProcessedAttributeMetadata {\n  logicalName: string\n  schemaName: string\n  displayName: string\n  description?: string\n  attributeType: string\n  isCustomAttribute: boolean\n  isValidForCreate: boolean\n  isValidForRead: boolean\n  isValidForUpdate: boolean\n  requiredLevel: 'None' | 'SystemRequired' | 'ApplicationRequired' | 'Recommended'\n  isPrimaryId: boolean\n  isPrimaryName: boolean\n  attributeOf?: string // For auxiliary attribute filtering\n  // Type-specific properties\n  maxLength?: number\n  minValue?: number\n  maxValue?: number\n  precision?: number\n  format?: string\n  targets?: string[] // For lookup attributes\n  optionSetName?: string // For picklist attributes\n  globalOptionSet?: string // For global option sets\n  isMultiSelect?: boolean // For multi-select picklists\n  optionSet?: ProcessedOptionSet // For picklist attributes with full option set data\n}\n\n/**\n * Processed option set for type generation\n */\nexport interface ProcessedOptionSet {\n  name: string\n  displayName: string\n  description?: string\n  isGlobal: boolean\n  isCustom: boolean\n  options: ProcessedOption[]\n}\n\n/**\n * Processed option for constants generation\n */\nexport interface ProcessedOption {\n  value: number\n  label: string\n  description?: string\n}\n\n/**\n * Processed relationship metadata for type generation\n */\nexport interface ProcessedRelationshipMetadata {\n  schemaName: string\n  referencedEntity: string\n  referencedAttribute: string\n  referencingEntity: string\n  referencingAttribute: string\n  isCustomRelationship: boolean\n}\n\n/**\n * Processed many-to-many relationship metadata for type generation\n */\nexport interface ProcessedManyToManyRelationshipMetadata {\n  schemaName: string\n  entity1LogicalName: string\n  entity1IntersectAttribute: string\n  entity2LogicalName: string\n  entity2IntersectAttribute: string\n  intersectEntityName: string\n  isCustomRelationship: boolean\n}\n\n/**\n * Extract display name from localized label structure\n */\nfunction extractDisplayName(localizedLabel?: LocalizedLabel): string {\n  if (!localizedLabel) return ''\n  \n  // Try user localized label first, then first available label\n  const label = localizedLabel.UserLocalizedLabel?.Label || \n                localizedLabel.LocalizedLabels?.[0]?.Label || \n                ''\n  \n  return label\n}\n\n/**\n * Extract required level from metadata\n */\nfunction extractRequiredLevel(requiredLevel?: { Value: string }): 'None' | 'SystemRequired' | 'ApplicationRequired' | 'Recommended' {\n  if (!requiredLevel?.Value) return 'None'\n  \n  switch (requiredLevel.Value) {\n    case 'SystemRequired':\n      return 'SystemRequired'\n    case 'ApplicationRequired':\n      return 'ApplicationRequired'\n    case 'Recommended':\n      return 'Recommended'\n    default:\n      return 'None'\n  }\n}\n\n/**\n * Process entity metadata for type generation\n */\nexport function processEntityMetadata(entityMetadata: EntityDefinition, options?: { excludeSystemAuditRelationships?: boolean }): ProcessedEntityMetadata {\n  const processed: ProcessedEntityMetadata = {\n    logicalName: entityMetadata.LogicalName,\n    schemaName: entityMetadata.SchemaName,\n    displayName: extractDisplayName(entityMetadata.DisplayName) || entityMetadata.SchemaName,\n    description: extractDisplayName(entityMetadata.Description),\n    primaryIdAttribute: entityMetadata.PrimaryIdAttribute || '',\n    primaryNameAttribute: entityMetadata.PrimaryNameAttribute || '',\n    entitySetName: entityMetadata.EntitySetName || '',\n    isCustomEntity: entityMetadata.IsCustomEntity,\n    attributes: [],\n    optionSets: [],\n    expandableProperties: [],\n    oneToManyRelationships: [],\n    manyToOneRelationships: [],\n    manyToManyRelationships: [],\n    relatedEntities: {}\n  }\n  \n  // Process attributes if available\n  if (entityMetadata.Attributes) {\n    const allProcessedAttributes = entityMetadata.Attributes.map(attr => processAttributeMetadata(attr))\n    \n    // Store all attributes initially (filtering will be applied during generation if configured)\n    processed.attributes = allProcessedAttributes\n    \n    // Extract option sets from attributes\n    processed.optionSets = extractOptionSetsFromAttributes(entityMetadata.Attributes)\n    \n    // Extract expandable properties (lookup fields for many-to-one relationships)\n    const lookupFields = processed.attributes\n      .filter(attr => attr.attributeType === 'Lookup')\n      .map(attr => attr.schemaName)\n    \n    processed.expandableProperties = [...lookupFields]\n  }\n  \n  // Process relationships if available\n  if (entityMetadata.OneToManyRelationships) {\n    processed.oneToManyRelationships = entityMetadata.OneToManyRelationships.map(rel => ({\n      schemaName: rel.SchemaName,\n      referencedEntity: rel.ReferencedEntity,\n      referencedAttribute: rel.ReferencedAttribute,\n      referencingEntity: rel.ReferencingEntity,\n      referencingAttribute: rel.ReferencingAttribute,\n      isCustomRelationship: rel.IsCustomRelationship\n    }))\n    \n    // Add one-to-many relationship names to expandable properties\n    const oneToManyNames = processed.oneToManyRelationships.map(rel => rel.schemaName)\n    processed.expandableProperties.push(...oneToManyNames)\n  }\n  \n  if (entityMetadata.ManyToOneRelationships) {\n    processed.manyToOneRelationships = entityMetadata.ManyToOneRelationships.map(rel => ({\n      schemaName: rel.SchemaName,\n      referencedEntity: rel.ReferencedEntity,\n      referencedAttribute: rel.ReferencedAttribute,\n      referencingEntity: rel.ReferencingEntity,\n      referencingAttribute: rel.ReferencingAttribute,\n      isCustomRelationship: rel.IsCustomRelationship\n    }))\n  }\n  \n  if (entityMetadata.ManyToManyRelationships) {\n    processed.manyToManyRelationships = entityMetadata.ManyToManyRelationships.map(rel => ({\n      schemaName: rel.SchemaName,\n      entity1LogicalName: rel.Entity1LogicalName,\n      entity1IntersectAttribute: rel.Entity1IntersectAttribute,\n      entity2LogicalName: rel.Entity2LogicalName,\n      entity2IntersectAttribute: rel.Entity2IntersectAttribute,\n      intersectEntityName: rel.IntersectEntityName,\n      isCustomRelationship: rel.IsCustomRelationship\n    }))\n    \n    // Add many-to-many relationship names to expandable properties\n    const manyToManyNames = processed.manyToManyRelationships.map(rel => rel.schemaName)\n    processed.expandableProperties.push(...manyToManyNames)\n  }\n  \n  // Build related entities info from relationships and lookup attributes\n  processed.relatedEntities = buildRelatedEntitiesInfo(processed, options?.excludeSystemAuditRelationships)\n  \n  return processed\n}\n\n/**\n * Build related entities information for type-safe expands\n */\nfunction buildRelatedEntitiesInfo(primaryEntity: ProcessedEntityMetadata, excludeSystemAuditRelationships = false): Record<string, RelatedEntityInfo> {\n  const relatedEntities: Record<string, RelatedEntityInfo> = {}\n\n  // System audit relationship patterns to exclude for systemuser\n  const systemAuditPatterns = [\n    /^lk_.*_createdby$/,\n    /^lk_.*_modifiedby$/,\n    /^lk_.*_createdonbehalfby$/,\n    /^lk_.*_modifiedonbehalfby$/,\n    /^user_.*$/,\n    /^systemuser_.*$/,\n    /^createdby_.*$/,\n    /^modifiedby_.*$/,\n    /^createdonbehalfby_.*$/,\n    /^modifiedonbehalfby_.*$/\n  ]\n\n  // Process lookup attributes (many-to-one relationships)\n  for (const attr of primaryEntity.attributes) {\n    if (attr.attributeType === 'Lookup' && attr.targets) {\n      for (const targetEntity of attr.targets) {\n        const relationshipName = attr.logicalName.replace(/_value$/, '')\n        \n        // Skip if this is a duplicate key\n        if (relatedEntities[relationshipName]) {\n          continue\n        }\n        \n        relatedEntities[relationshipName] = {\n          relationshipName,\n          targetEntityLogicalName: targetEntity,\n          targetEntitySetName: `${targetEntity}s`, // Will be corrected when we have actual metadata\n          relationshipType: 'ManyToOne'\n        }\n      }\n    }\n  }\n\n  // Process one-to-many relationships\n  for (const rel of primaryEntity.oneToManyRelationships) {\n    // Skip system audit relationships if configured\n    if (excludeSystemAuditRelationships && primaryEntity.logicalName === 'systemuser') {\n      const isSystemAuditRelationship = systemAuditPatterns.some(pattern => \n        pattern.test(rel.schemaName)\n      )\n      if (isSystemAuditRelationship) {\n        continue\n      }\n    }\n    \n    // Skip if this is a duplicate key\n    if (relatedEntities[rel.schemaName]) {\n      continue\n    }\n    \n    relatedEntities[rel.schemaName] = {\n      relationshipName: rel.schemaName,\n      targetEntityLogicalName: rel.referencingEntity,\n      targetEntitySetName: `${rel.referencingEntity}s`, // Will be corrected when we have actual metadata\n      relationshipType: 'OneToMany'\n    }\n  }\n\n  // Process many-to-many relationships\n  for (const rel of primaryEntity.manyToManyRelationships) {\n    // Determine the target entity (the one that's not the current entity)\n    const targetEntity = rel.entity1LogicalName === primaryEntity.logicalName \n      ? rel.entity2LogicalName \n      : rel.entity1LogicalName\n    \n    // Skip if this is a duplicate key\n    if (relatedEntities[rel.schemaName]) {\n      continue\n    }\n    \n    relatedEntities[rel.schemaName] = {\n      relationshipName: rel.schemaName,\n      targetEntityLogicalName: targetEntity,\n      targetEntitySetName: `${targetEntity}s`, // Will be corrected when we have actual metadata\n      relationshipType: 'ManyToMany'\n    }\n  }\n\n  return relatedEntities\n}\n\n/**\n * Extract all related entity names from processed metadata\n */\nexport function extractRelatedEntityNames(metadata: ProcessedEntityMetadata): string[] {\n  const relatedEntityNames = new Set<string>()\n\n  // From related entities info\n  for (const relatedEntity of Object.values(metadata.relatedEntities)) {\n    relatedEntityNames.add(relatedEntity.targetEntityLogicalName)\n  }\n\n  return Array.from(relatedEntityNames)\n}\n\n/**\n * Process individual attribute metadata\n */\nexport function processAttributeMetadata(attributeMetadata: AttributeMetadata): ProcessedAttributeMetadata {\n  const processed: ProcessedAttributeMetadata = {\n    logicalName: attributeMetadata.LogicalName,\n    schemaName: attributeMetadata.SchemaName,\n    displayName: extractDisplayName(attributeMetadata.DisplayName) || attributeMetadata.SchemaName,\n    description: extractDisplayName(attributeMetadata.Description),\n    attributeType: attributeMetadata.AttributeType,\n    isCustomAttribute: attributeMetadata.IsCustomAttribute,\n    isValidForCreate: attributeMetadata.IsValidForCreate,\n    isValidForRead: attributeMetadata.IsValidForRead,\n    isValidForUpdate: attributeMetadata.IsValidForUpdate,\n    requiredLevel: extractRequiredLevel(attributeMetadata.RequiredLevel),\n    isPrimaryId: attributeMetadata.IsPrimaryId || false,\n    isPrimaryName: attributeMetadata.IsPrimaryName || false,\n    attributeOf: attributeMetadata.AttributeOf\n  }\n  \n  // Handle type-specific properties\n  const odataType = (attributeMetadata as { '@odata.type'?: string })['@odata.type']\n  \n  // Normalize OData type by removing # prefix if present\n  const normalizedODataType = odataType?.startsWith('#') ? odataType.substring(1) : odataType\n  \n  switch (normalizedODataType) {\n    case 'Microsoft.Dynamics.CRM.PicklistAttributeMetadata':\n      processPicklistAttribute(processed, attributeMetadata as PicklistAttributeMetadata)\n      break\n      \n    case 'Microsoft.Dynamics.CRM.MultiSelectPicklistAttributeMetadata':\n      processMultiSelectPicklistAttribute(processed, attributeMetadata as MultiSelectPicklistAttributeMetadata)\n      break\n      \n    case 'Microsoft.Dynamics.CRM.LookupAttributeMetadata':\n      processLookupAttribute(processed, attributeMetadata as LookupAttributeMetadata)\n      break\n      \n    case 'Microsoft.Dynamics.CRM.StateAttributeMetadata':\n    case 'Microsoft.Dynamics.CRM.StatusAttributeMetadata':\n      processStateStatusAttribute(processed, attributeMetadata as StateAttributeMetadata | StatusAttributeMetadata)\n      break\n      \n    case 'Microsoft.Dynamics.CRM.StringAttributeMetadata':\n      processStringAttribute(processed, attributeMetadata as AttributeMetadata & StringAttributeTypeMetadata)\n      break\n      \n    case 'Microsoft.Dynamics.CRM.IntegerAttributeMetadata':\n    case 'Microsoft.Dynamics.CRM.BigIntAttributeMetadata':\n    case 'Microsoft.Dynamics.CRM.DecimalAttributeMetadata':\n    case 'Microsoft.Dynamics.CRM.DoubleAttributeMetadata':\n    case 'Microsoft.Dynamics.CRM.MoneyAttributeMetadata':\n      processNumericAttribute(processed, attributeMetadata as AttributeMetadata & NumericAttributeTypeMetadata)\n      break\n      \n    case 'Microsoft.Dynamics.CRM.DateTimeAttributeMetadata':\n      processDateTimeAttribute(processed, attributeMetadata as AttributeMetadata & DateTimeAttributeTypeMetadata)\n      break\n  }\n  \n  return processed\n}\n\n/**\n * Process picklist attribute\n */\nfunction processPicklistAttribute(processed: ProcessedAttributeMetadata, attr: PicklistAttributeMetadata): void {\n  if (attr.OptionSet) {\n    processed.optionSetName = attr.OptionSet.Name || `${processed.logicalName}_options`\n  }\n  \n  if (attr.GlobalOptionSet) {\n    processed.globalOptionSet = attr.GlobalOptionSet\n  }\n}\n\n/**\n * Process multi-select picklist attribute\n */\nfunction processMultiSelectPicklistAttribute(processed: ProcessedAttributeMetadata, attr: MultiSelectPicklistAttributeMetadata): void {\n  processed.isMultiSelect = true\n  \n  if (attr.OptionSet) {\n    processed.optionSetName = attr.OptionSet.Name || `${processed.logicalName}_options`\n  }\n  \n  if (attr.GlobalOptionSet) {\n    processed.globalOptionSet = attr.GlobalOptionSet\n  }\n}\n\n/**\n * Process lookup attribute\n */\nfunction processLookupAttribute(processed: ProcessedAttributeMetadata, attr: LookupAttributeMetadata): void {\n  processed.targets = attr.Targets || []\n  processed.format = attr.Format\n}\n\n/**\n * Process state/status attribute\n */\nfunction processStateStatusAttribute(processed: ProcessedAttributeMetadata, attr: StateAttributeMetadata | StatusAttributeMetadata): void {\n  if (attr.OptionSet) {\n    processed.optionSetName = attr.OptionSet.Name || `${processed.logicalName}_options`\n  }\n}\n\n/**\n * Process string attribute\n */\nfunction processStringAttribute(processed: ProcessedAttributeMetadata, attr: AttributeMetadata & StringAttributeTypeMetadata): void {\n  if (attr.MaxLength !== undefined) {\n    processed.maxLength = attr.MaxLength\n  }\n  if (attr.Format) {\n    processed.format = attr.Format\n  }\n}\n\n/**\n * Process numeric attribute\n */\nfunction processNumericAttribute(processed: ProcessedAttributeMetadata, attr: AttributeMetadata & NumericAttributeTypeMetadata): void {\n  if (attr.MinValue !== undefined) {\n    processed.minValue = attr.MinValue\n  }\n  if (attr.MaxValue !== undefined) {\n    processed.maxValue = attr.MaxValue\n  }\n  if (attr.Precision !== undefined) {\n    processed.precision = attr.Precision\n  }\n}\n\n/**\n * Process datetime attribute\n */\nfunction processDateTimeAttribute(processed: ProcessedAttributeMetadata, attr: AttributeMetadata & DateTimeAttributeTypeMetadata): void {\n  if (attr.Format) {\n    processed.format = attr.Format\n  }\n}\n\n/**\n * Extract option sets from entity attributes\n */\nexport function extractOptionSetsFromAttributes(attributes: AttributeMetadata[]): ProcessedOptionSet[] {\n  const optionSets: ProcessedOptionSet[] = []\n  \n  for (const attr of attributes) {\n    const odataType = (attr as { '@odata.type'?: string })['@odata.type']\n    \n    // Normalize OData type by removing # prefix if present\n    const normalizedODataType = odataType?.startsWith('#') ? odataType.substring(1) : odataType\n    \n    if (normalizedODataType?.includes('PicklistAttributeMetadata') || \n        normalizedODataType?.includes('StateAttributeMetadata') || \n        normalizedODataType?.includes('StatusAttributeMetadata')) {\n      \n      const picklistAttr = attr as PicklistAttributeMetadata\n      \n      if (picklistAttr.OptionSet && !picklistAttr.GlobalOptionSet) {\n        // Local option set\n        const processedOptionSet = processOptionSet(picklistAttr.OptionSet, attr.LogicalName)\n        if (processedOptionSet) {\n          optionSets.push(processedOptionSet)\n        }\n      }\n    }\n  }\n  \n  return optionSets\n}\n\n/**\n * Process option set metadata\n */\nexport function processOptionSet(\n  optionSetMetadata: PicklistAttributeMetadata['OptionSet'] | GlobalOptionSetDefinition,\n  fallbackName?: string\n): ProcessedOptionSet | null {\n  if (!optionSetMetadata?.Options) return null\n  \n  const processed: ProcessedOptionSet = {\n    name: optionSetMetadata.Name || fallbackName || 'unknown_optionset',\n    displayName: extractDisplayName(optionSetMetadata.DisplayName) || optionSetMetadata.Name || fallbackName || 'Unknown',\n    description: extractDisplayName((optionSetMetadata as { Description?: LocalizedLabel }).Description),\n    isGlobal: (optionSetMetadata as GlobalOptionSetDefinition).IsGlobal || false,\n    isCustom: (optionSetMetadata as GlobalOptionSetDefinition).IsCustomOptionSet || (optionSetMetadata as { IsCustomOptionSet?: boolean }).IsCustomOptionSet || false,\n    options: []\n  }\n  \n  // Process options\n  processed.options = optionSetMetadata.Options.map(option => ({\n    value: option.Value,\n    label: extractDisplayName(option.Label) || option.Value.toString(),\n    description: extractDisplayName((option as { Description?: LocalizedLabel }).Description)\n  }))\n  \n  return processed\n}\n\n/**\n * Process global option set\n */\nexport function processGlobalOptionSet(globalOptionSet: GlobalOptionSetDefinition): ProcessedOptionSet {\n  return {\n    name: globalOptionSet.Name,\n    displayName: extractDisplayName(globalOptionSet.DisplayName) || globalOptionSet.Name,\n    description: extractDisplayName(globalOptionSet.Description),\n    isGlobal: globalOptionSet.IsGlobal,\n    isCustom: globalOptionSet.IsCustomOptionSet,\n    options: globalOptionSet.Options.map(option => ({\n      value: option.Value,\n      label: extractDisplayName(option.Label) || option.Value.toString(),\n      description: extractDisplayName((option as { Description?: LocalizedLabel }).Description)\n    }))\n  }\n}\n\n/**\n * Merge processed option sets, avoiding duplicates\n */\nexport function mergeOptionSets(optionSets: ProcessedOptionSet[]): ProcessedOptionSet[] {\n  const uniqueOptionSets = new Map<string, ProcessedOptionSet>()\n  \n  for (const optionSet of optionSets) {\n    const key = optionSet.name\n    if (!uniqueOptionSets.has(key)) {\n      uniqueOptionSets.set(key, optionSet)\n    }\n  }\n  \n  return Array.from(uniqueOptionSets.values())\n}\n\n/**\n * Filter attributes by type\n */\nexport function filterAttributesByType(\n  attributes: ProcessedAttributeMetadata[], \n  types: string[]\n): ProcessedAttributeMetadata[] {\n  return attributes.filter(attr => types.includes(attr.attributeType))\n}\n\n/**\n * Get primary attributes (ID and Name)\n */\nexport function getPrimaryAttributes(attributes: ProcessedAttributeMetadata[]): {\n  primaryId?: ProcessedAttributeMetadata\n  primaryName?: ProcessedAttributeMetadata\n} {\n  return {\n    primaryId: attributes.find(attr => attr.isPrimaryId),\n    primaryName: attributes.find(attr => attr.isPrimaryName)\n  }\n}\n\n/**\n * Group attributes by type\n */\nexport function groupAttributesByType(attributes: ProcessedAttributeMetadata[]): Record<string, ProcessedAttributeMetadata[]> {\n  const groups: Record<string, ProcessedAttributeMetadata[]> = {}\n  \n  for (const attr of attributes) {\n    if (!groups[attr.attributeType]) {\n      groups[attr.attributeType] = []\n    }\n    groups[attr.attributeType].push(attr)\n  }\n  \n  return groups\n}\n\n/**\n * Get lookup attributes with their targets\n */\nexport function getLookupAttributes(attributes: ProcessedAttributeMetadata[]): Array<ProcessedAttributeMetadata & { targets: string[] }> {\n  return attributes\n    .filter(attr => attr.attributeType === 'Lookup' && attr.targets)\n    .map(attr => ({ ...attr, targets: attr.targets! }))\n}\n\n/**\n * Get option set attributes\n */\nexport function getOptionSetAttributes(attributes: ProcessedAttributeMetadata[]): ProcessedAttributeMetadata[] {\n  return attributes.filter(attr => \n    attr.attributeType === 'Picklist' || \n    attr.attributeType === 'MultiSelectPicklist' ||\n    attr.attributeType === 'State' ||\n    attr.attributeType === 'Status'\n  )\n}\n\n/**\n * Filter out auxiliary attributes using AttributeOf field\n * Auxiliary attributes are system-generated fields like lookup name fields that reference other attributes\n * \n * @param attributes - Array of processed attribute metadata\n * @returns Filtered array without auxiliary attributes\n */\nexport function filterAuxiliaryAttributes(attributes: ProcessedAttributeMetadata[]): ProcessedAttributeMetadata[] {\n  return attributes.filter(attr => !attr.attributeOf)\n}\n\n/**\n * Validate processed metadata\n */\nexport function validateProcessedMetadata(metadata: ProcessedEntityMetadata): {\n  isValid: boolean\n  errors: string[]\n  warnings: string[]\n} {\n  const errors: string[] = []\n  const warnings: string[] = []\n  \n  // Required fields validation\n  if (!metadata.logicalName) {\n    errors.push('Missing logical name')\n  }\n  \n  if (!metadata.schemaName) {\n    errors.push('Missing schema name')\n  }\n  \n  if (!metadata.primaryIdAttribute) {\n    warnings.push('Missing primary ID attribute')\n  }\n  \n  if (!metadata.primaryNameAttribute) {\n    warnings.push('Missing primary name attribute')\n  }\n  \n  // Attributes validation\n  if (metadata.attributes.length === 0) {\n    warnings.push('No attributes found')\n  }\n  \n  // Check for duplicate attribute logical names\n  const logicalNames = new Set<string>()\n  for (const attr of metadata.attributes) {\n    if (logicalNames.has(attr.logicalName)) {\n      errors.push(`Duplicate attribute logical name: ${attr.logicalName}`)\n    }\n    logicalNames.add(attr.logicalName)\n  }\n  \n  // Option sets validation\n  for (const optionSet of metadata.optionSets) {\n    if (optionSet.options.length === 0) {\n      warnings.push(`Option set '${optionSet.name}' has no options`)\n    }\n    \n    // Check for duplicate option values\n    const values = new Set<number>()\n    for (const option of optionSet.options) {\n      if (values.has(option.value)) {\n        errors.push(`Duplicate option value in '${optionSet.name}': ${option.value}`)\n      }\n      values.add(option.value)\n    }\n  }\n  \n  return {\n    isValid: errors.length === 0,\n    errors,\n    warnings\n  }\n}"]}