
    %iF                         d Z ddlmZmZmZmZmZ ddlmZ ddlm	Z	  G d de
e	      Z G d de
e	      Z G d	 d
e
e	      Z G d de
e	      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z	 	 d)de
de
de
dee   d ef
d!Zd"ed#ed efd$Zd"ed%e
d&e
d efd'Zd"ed%e
d&e
d efd(Zy)*zW
SEO Campaign State Schema
Defines TypedDict state definitions for LangGraph workflows
    )	TypedDictListOptionalLiteralAny)datetime)Enumc                   <    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZy)CampaignPhasezCampaign phase trackingresearchcontent	technicalserp_features	link_oppshuman_review	executionreport	completedpausedfailedN)__name__
__module____qualname____doc__RESEARCHCONTENT	TECHNICALSERP_FEATURES	LINK_OPPSHUMAN_REVIEW	EXECUTIONREPORT	COMPLETEDPAUSEDFAILED     C/var/www/html/eventheodds/langgraph-service/state/campaign_state.pyr   r      s<    !HGI#MI!LIFIFFr'   r   c                   $    e Zd ZdZdZdZdZdZdZy)LinkOpportunityStatusz Link opportunity approval statuspendingapprovedrejectedexecutedr   N)	r   r   r   r   PENDINGAPPROVEDREJECTEDEXECUTEDr%   r&   r'   r(   r*   r*      s    *GHHHFr'   r*   c                   (    e Zd ZdZdZdZdZdZdZdZ	y)	OpportunityTypez$Types of link building opportunitiesharo
guest_postbroken_linkmentionresource_page
skyscraperN)
r   r   r   r   HARO
GUEST_POSTBROKEN_LINKUNLINKED_MENTIONRESOURCE_PAGE
SKYSCRAPERr&   r'   r(   r4   r4   #   s$    .DJK #MJr'   r4   c                   ,    e Zd ZdZdZdZdZdZdZdZ	dZ
y	)
SERPFeatureTypez Types of SERP features to targetsnippetpaaai_overview
local_packknowledge_panel
image_packvideo_carouselN)r   r   r   r   FEATURED_SNIPPETPEOPLE_ALSO_ASKAI_OVERVIEW
LOCAL_PACKKNOWLEDGE_PANEL
IMAGE_PACKVIDEO_CAROUSELr&   r'   r(   rB   rB   -   s)    * OKJ'OJ%Nr'   rB   c                      e Zd ZU dZeed<   eed<   eed<   eed<   ee   ed<   eed<   eed<   eed	<   eed
<   ee   ed<   ee   ed<   ee   ed<   ee   ed<   ee   ed<   ee   ed<   ee   ed<   e	ed<   ee   ed<   eed<   ee   ed<   y)LinkOpportunityz?A discovered link building opportunity requiring human approvalid
target_urlsource_domaindomain_authoritymonthly_trafficrelevance_scoreopportunity_typestatuspitch_draftpitch_approvedcontact_emailcontact_nameapproved_byapproved_atrejection_reasonexecuted_atlink_acquiredacquired_urldiscovered_atnotesN)
r   r   r   r   str__annotations__intr   floatboolr&   r'   r(   rR   rR   8   s    IGOc]"K SM! C= 3- ##sm# #3- C=r'   rR   c                       e Zd ZU dZeed<   eed<   ee   ed<   eed<   ee   ed<   ee   ed<   eed<   ee   ed	<   eed
<   ee   ed<   y)SERPFeatureDataz2Data about SERP feature opportunities and captureskeywordfeature_typecurrent_positioncapturedcaptured_atcontent_hashai_overview_mentioncitation_context	optimizedoptimization_appliedN)	r   r   r   r   rg   rh   r   ri   rk   r&   r'   r(   rm   rm   Z   sV    <Lsm#N#3- sm# O"3-'r'   rm   c                   n    e Zd ZU dZeed<   eed<   eed<   ee   ed<   eed<   eed<   ee   ed<   eed	<   y
)ContentQueueItemz$Item in the content generation queuerS   rn   content_typetarget_serp_featurespriorityrZ   page_id
created_atN)	r   r   r   r   rg   rh   r   ri   r   r&   r'   r(   ry   ry   l   s8    .GLs)#MKc]Or'   ry   c                   ^    e Zd ZU dZeed<   eed<   eed<   eed<   eed<   eed<   ee   ed<   y	)
OptimizationQueueItemzItem in the optimization queuerS   r}   optimization_typetarget_keywordr|   rZ   completed_atN)r   r   r   r   rg   rh   ri   r   r&   r'   r(   r   r   x   s/    (GLMK3-r'   r   c                   x    e Zd ZU dZeed<   eed<   eed<   eed<   eed<   eed<   e	e   ed<   e	e   ed	<   eed
<   y)GSCDataz#Google Search Console data snapshotproperty_url
date_rangetotal_impressionstotal_clicksaverage_ctraverage_positiontop_queries	top_pages
fetched_atN)
r   r   r   r   rg   rh   dictri   rj   r   r&   r'   r(   r   r      sB    -dDzOr'   r   c                   j    e Zd ZU dZeed<   eed<   eed<   ee   ed<   ee   ed<   ee   ed<   eed<   y	)
CompetitorDatazCompetitor analysis datadomainrV   estimated_traffictop_keywordscontent_gapsbacklink_sourcesanalyzed_atN)	r   r   r   r   rg   rh   ri   r   r   r&   r'   r(   r   r      s:    "Kt*t*4j r'   r   c                      e Zd ZU dZeed<   eed<   eed<   eed<   ee   ed<   ee   ed<   ee   ed<   e	ed	<   ee   ed
<   ee   ed<   ee
   ed<   ee   ed<   ee   ed<   ee   ed<   ee   ed<   ee   ed<   ee   ed<   eed<   eed<   eed<   eed<   eed<   eed<   eed<   ee   ed<   ee   ed<   eed<   eed<   ee   ed<   eed<   y )!SEOCampaignStatez
    Main campaign state for LangGraph SEO workflows

    This state is persisted across workflow executions using Redis checkpointing,
    enabling human-in-the-loop approvals and long-running campaigns.
    site_idcampaign_idcampaign_typecurrent_phasephase_started_atphases_completedpending_approvalsrequires_human_review	paused_atpause_reasongsc_datacompetitor_dataserp_features_datacontent_queueoptimization_queuelink_opportunitiesserp_features_targetedpages_generatedpages_optimizedsnippets_capturedpaa_capturedai_overview_mentionslinks_approvedlinks_acquirederrorswarnings
started_at
updated_atr   configN)r   r   r   r   rg   rh   r   r   rR   rk   r   r   rm   ry   r   ri   r   r&   r'   r(   r   r      s    L sm#3i O,,}3- w.))_-- ())233_-- !I%  J4j OO3- Lr'   r   Nr   r   r   r   returnc                    t        j                         j                         }t        d"i d| d|d|dt        j
                  j                  d|dg dg dd	d
ddddddg dg dg dg dg dt        j                  j                  t        j                  j                  t        j                  j                  gdddddddddddddddg dg d|d|d dd!|xs i S )#z)Create a new campaign state with defaultsr   r   r   r   r   r   r   r   Fr   Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r&   )r   utcnow	isoformatr   r   r   valuerB   rJ   rK   rL   )r   r   r   r   nows        r(   create_initial_stater      s    //

%
%
'C ### $# $,,22	#
 # # # $# # # # # # # #  !#$ ,,22++11''-- 
##, -#. /#0 1#2 3#4 5#6 7#8 9#: ;#< =#> ?#@ A#B C#D |E# #r'   state	new_phasec                    t        j                         j                         }| j                  dg       j	                         }| j                  d      }|r||vr|j                  |       || d<   |j                  | d<   || d<   || d<   | S )z"Transition campaign to a new phaser   r   r   r   )r   r   r   getcopyappendr   )r   r   r   r   currents        r(   transition_phaser     s    
 //

%
%
'C 		,b1668Iii(G7)+! )E
&__E/ #E
E,Lr'   phasemessagec                    | j                  dg       j                         }|j                  ||t        j                         j                         d       || d<   t        j                         j                         | d<   | S )zAdd an error to the stater   r   r   	timestampr   r   r   r   r   r   r   )r   r   r   r   s       r(   	add_errorr     sq     YYx$))+F
MM__&002 
 E(O"//+557E,Lr'   c                    | j                  dg       j                         }|j                  ||t        j                         j                         d       || d<   t        j                         j                         | d<   | S )zAdd a warning to the stater   r   r   r   )r   r   r   r   s       r(   add_warningr   *  sr     yyR(--/HOO__&002 
 !E*"//+557E,Lr'   )
zero_clickN)r   typingr   r   r   r   r   r   enumr	   rg   r   r*   r4   rB   rR   rm   ry   r   r   r   r   r   r   r   r   r   r&   r'   r(   <module>r      sW  
 ; :  C C c4 &c4 &i D(i ($	y 	 I  
i 
Y 7y 7z &!	,,, , TN	,
 ,^ *  	"  	r'   