
    4 ju                        d Z ddlmZ ddlmZmZmZ ddlmZm	Z	m
Z
mZmZ ddlmZ ddlmZmZmZ ddlmZ  ede	      Z ed
e	      Z G d ded      Z G d ded      Z G d ded      Z G d deeeef   d      Zy)zLModels and methods to define the metadata fields in database index mappings.    )Path)GenericOptionalTypeVar)	BaseModelField	StrictStrValidationInfofield_validator)Package)CollectionTypeEnumStrictDateTime
UniqueList)
AliasModelClassificationT)boundDomainTc                   6    e Zd ZU dZeed<   eed<   eed<   d Zy)S3PathzDThe path details within a cloud object storage for CCS-parsed files.bucketprefixinfixc                 t    t        t        |       ft        | j                  j	                               z         S )z-Return the hash value for this S3Path object.)hashtypetuple__dict__values)selfs    K/home/agent/.local/lib/python3.12/site-packages/docling_core/search/meta.py__hash__zS3Path.__hash__   s*    T$ZME$--*>*>*@$AABB    N)__name__
__module____qualname____doc__r	   __annotations__r!    r"   r    r   r      s    NCr"   r   forbid)extrac                   >    e Zd ZU dZeed<    ed      Zee	   ed<   y)	S3CcsDatazBThe access details to a cloud object storage for CCS-parsed files.endpoint   
min_lengthpathsN)
r#   r$   r%   r&   r	   r'   r   r1   r   r   r(   r"   r    r,   r,      s    L % 3E:f3r"   r,   c                   F    e Zd ZU dZdZeee      ed<   dZ	eee      ed<   y)DocumentLicensezGDocument license for a search database index within the index mappings.Ncodetext)
r#   r$   r%   r&   r4   r   listr	   r'   r5   r(   r"   r    r3   r3   #   s+    Q&*D(4	?
#*&*D(4	?
#*r"   r3   c                      e Zd ZU dZdZeee      ed<   e	ed<   dZ
ee   ed<   eed<   dZee   ed<   dZee   ed<   eed	<   dZeee      ed
<    ed      Zee   ed<   dZee   ed<   dZee   ed<   dZeee      ed<    edd      Zee   ed<   dZee   ed<   dZee   ed<   dZee   ed<   dZee   ed<    e d      e!de"fd              Z# e d      e!d               Z$y)Metaz>Metadata of a search database index within the index mappings.Naliasescreateddescriptionsourcestoragedisplay_namer   classificationr.   r/   versionlicensefilenamedomainz$ref)defaultalias	referenceccs_s3_datadocument_license	index_keyproject_keyinfoc                 l    d|j                   v r%|j                   d   dk(  r|r|dk7  rt        d      y|S )z:Validate the reference field for indexes of type Document.r   Documentzccs:schemas#/Documentz'wrong reference value for Document type)data
ValueError)clsvrK   s      r    reference_for_documentzMeta.reference_for_document?   s?     TYY499V#4
#BQ11 !JKK.Hr"   c                     |D cg c]  }|j                   dk(  s| }}|st        d      t        |      dkD  rt        d      |S c c}w )zFValidate that the docling-core library is always set in version field.zdocling-corez@the version should include at least a valid docling-core packager.   z=the version must not include more than 1 docling-core package)namerO   len)rP   rQ   itemdocling_cores       r    version_has_schemazMeta.version_has_schemaK   sU     *+Jdii>.IJJ_``"\]]H Ks
   AA)%r#   r$   r%   r&   r9   r   r6   r	   r'   r   r;   r=   r>   r   r?   r   r   r@   r   r   rA   rB   r   rC   r   rF   rG   r,   rH   r3   rI   rJ   r   classmethodr
   rR   rX   r(   r"   r    r8   r8   *   sI   H)-GXd9o&-'+K)$+#'GXi '(,L(9%,
6:NHT/23:#(A#6GZ 6#'GXi '#Hhtn#&*FHT']#*%*4v%FIx	"F'+K)$+26h/6%)Ix	")'+K)$+[!^   " Y   r"   r8   N)r&   pathlibr   typingr   r   r   pydanticr   r   r	   r
   r   docling_core.search.packager   docling_core.types.baser   r   r   docling_core.utils.aliasr   strr   r   r   r,   r3   r8   r(   r"   r    <module>ra      s    R  - - Q Q / R R /+37
)3
'	CYh 	C4	 4+ix ++:w78 +r"   