@foundrynorth/compass-schema 1.0.6 → 1.0.7

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/dist/schema.js CHANGED
@@ -5707,4 +5707,63 @@ export const simplifiBudgetFlights = pgTable("simplifi_budget_flights", {
5707
5707
  }, (table) => [
5708
5708
  index("simplifi_budget_flights_campaign_idx").on(table.simplifiCampaignId),
5709
5709
  ]);
5710
+ // ─── SEM Campaign Intelligence ────────────────────────────────────────────────
5711
+ /** SEM campaign lifecycle status — tracks progression from intake through completion. */
5712
+ export const semCampaignStatusEnum = pgEnum("sem_campaign_status", [
5713
+ "intake", // Strategist filling intake form
5714
+ "enriching", // Auto-enrichment running (DataForSEO, LLM)
5715
+ "ready", // Enrichment complete, ready for Google Ads Editor export
5716
+ "exported", // CSV generated and downloaded
5717
+ "active", // Campaign live in Google Ads
5718
+ "completed", // Flight ended
5719
+ ]);
5720
+ /** SEM enrichment pipeline status — tracks the async enrichment Trigger.dev task. */
5721
+ export const semEnrichmentStatusEnum = pgEnum("sem_enrichment_status", [
5722
+ "pending", // Queued for enrichment
5723
+ "running", // Enrichment task executing
5724
+ "completed", // All enrichment steps finished
5725
+ "failed", // Enrichment failed (see enrichmentError)
5726
+ ]);
5727
+ /**
5728
+ * sem_campaigns — SEM campaign intelligence and lifecycle tracking.
5729
+ *
5730
+ * Created when an order with SEM_SEO line items transitions to "sent".
5731
+ * Enriched asynchronously by the sem-enrich Trigger.dev task with keyword
5732
+ * research, competitor analysis, landing page audit, and AI account structure.
5733
+ *
5734
+ * One record per SEM line item. The enrichmentData JSONB stores the full
5735
+ * DataForSEO + LLM output; accountStructure stores the Google Ads Editor-ready
5736
+ * campaign tree; exportHistory tracks CSV downloads.
5737
+ */
5738
+ export const semCampaigns = pgTable("sem_campaigns", {
5739
+ id: varchar("id")
5740
+ .primaryKey()
5741
+ .default(sql `gen_random_uuid()`),
5742
+ /** FK → media_orders.id */
5743
+ mediaOrderId: varchar("media_order_id", { length: 36 }).notNull(),
5744
+ /** FK → media_order_line_items.id */
5745
+ lineItemId: varchar("line_item_id", { length: 36 }).notNull(),
5746
+ /** Client website domain (extracted from semClientUrl) */
5747
+ clientDomain: text("client_domain"),
5748
+ /** Google Ads account ID (XXX-XXX-XXXX) if client has existing account */
5749
+ googleAdsAccountId: text("google_ads_account_id"),
5750
+ /** Campaign lifecycle status */
5751
+ status: semCampaignStatusEnum("status").default("intake").notNull(),
5752
+ /** Enrichment pipeline status */
5753
+ enrichmentStatus: semEnrichmentStatusEnum("enrichment_status").default("pending").notNull(),
5754
+ /** Full enrichment payload: { keywordResearch, competitorAnalysis, landingPageAudit, existingEnrichment } */
5755
+ enrichmentData: jsonb("enrichment_data"),
5756
+ /** Error message if enrichment failed */
5757
+ enrichmentError: text("enrichment_error"),
5758
+ /** AI-generated Google Ads account structure (campaigns → ad groups → keywords → ads) */
5759
+ accountStructure: jsonb("account_structure"),
5760
+ /** Array of export records: [{ exportedAt, storageKey, fileName, exportedBy }] */
5761
+ exportHistory: jsonb("export_history").default(sql `'[]'::jsonb`),
5762
+ createdAt: timestamp("created_at").notNull().defaultNow(),
5763
+ updatedAt: timestamp("updated_at").notNull().defaultNow(),
5764
+ }, (table) => [
5765
+ index("sem_campaigns_media_order_id_idx").on(table.mediaOrderId),
5766
+ index("sem_campaigns_line_item_id_idx").on(table.lineItemId),
5767
+ index("sem_campaigns_status_idx").on(table.status),
5768
+ ]);
5710
5769
  //# sourceMappingURL=schema.js.map