(domain: string)
| 838 | // ── Single Domain Crawl ────────────────────────────────────────── |
| 839 | |
| 840 | async crawlSingleDomain(domain: string): Promise<void> { |
| 841 | if (this.crawling) { |
| 842 | log.warn({ domain }, 'Full crawl in progress, skipping single domain crawl'); |
| 843 | return; |
| 844 | } |
| 845 | |
| 846 | log.info({ domain }, 'Single domain crawl requested'); |
| 847 | |
| 848 | try { |
| 849 | const validation = await this.adAgentsManager.validateDomain(domain); |
| 850 | |
| 851 | if (!validation.valid || !validation.raw_data?.authorized_agents) { |
| 852 | log.warn({ domain }, 'No valid adagents.json for domain'); |
| 853 | return; |
| 854 | } |
| 855 | |
| 856 | await this.cacheAdagentsManifest(domain, validation.raw_data as AdagentsManifest); |
| 857 | |
| 858 | // Record agents and properties |
| 859 | for (const authorizedAgent of validation.raw_data.authorized_agents) { |
| 860 | if (!authorizedAgent.url) continue; |
| 861 | |
| 862 | await this.federatedIndex.recordAgentFromAdagentsJson( |
| 863 | authorizedAgent.url, |
| 864 | domain, |
| 865 | authorizedAgent.authorized_for, |
| 866 | authorizedAgent.property_ids |
| 867 | ); |
| 868 | |
| 869 | await this.recordPropertiesForAgent( |
| 870 | validation.raw_data.properties || [], |
| 871 | domain, |
| 872 | authorizedAgent.url, |
| 873 | authorizedAgent.authorized_for, |
| 874 | authorizedAgent.property_ids |
| 875 | ); |
| 876 | } |
| 877 | |
| 878 | // Produce per-domain events |
| 879 | if (this.eventsDb) { |
| 880 | await this.eventsDb.writeEvent({ |
| 881 | event_type: 'publisher.adagents_changed', |
| 882 | entity_type: 'publisher', |
| 883 | entity_id: domain, |
| 884 | payload: { |
| 885 | publisher_domain: domain, |
| 886 | agent_count: validation.raw_data.authorized_agents.length, |
| 887 | property_count: validation.raw_data.properties?.length ?? 0, |
| 888 | }, |
| 889 | actor: 'api:crawl-request', |
| 890 | }); |
| 891 | } |
| 892 | |
| 893 | // Scan brand.json for this domain |
| 894 | try { |
| 895 | await this.scanBrandForDomain(domain); |
| 896 | } catch (err) { |
| 897 | log.warn({ domain, err: err instanceof Error ? err.message : err }, 'Brand scan during single domain crawl failed'); |
no test coverage detected