@foundrynorth/compass-schema 1.0.5 → 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/relations.d.ts +5 -0
- package/dist/relations.d.ts.map +1 -1
- package/dist/relations.js +12 -1
- package/dist/relations.js.map +1 -1
- package/dist/schema.d.ts +939 -21
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +173 -0
- package/dist/schema.js.map +1 -1
- package/package.json +1 -1
package/dist/schema.js
CHANGED
|
@@ -3314,6 +3314,8 @@ export const mediaOrderLineItems = pgTable("media_order_line_items", {
|
|
|
3314
3314
|
// Datasys 360 integration
|
|
3315
3315
|
datasysCountId: varchar("datasys_count_id"),
|
|
3316
3316
|
datasysCampaignId: varchar("datasys_campaign_id"),
|
|
3317
|
+
// Simpli.fi DSP integration
|
|
3318
|
+
simplifiCampaignId: varchar("simplifi_campaign_id"),
|
|
3317
3319
|
// Fulfillment details (product-specific fields for HubSpot sync)
|
|
3318
3320
|
fulfillmentDetails: jsonb("fulfillment_details"),
|
|
3319
3321
|
creativeSource: varchar("creative_source"),
|
|
@@ -4826,6 +4828,7 @@ export const insertDatasysDeploymentSchema = createInsertSchema(datasysDeploymen
|
|
|
4826
4828
|
export const programmaticVendorEnum = pgEnum("programmatic_vendor", [
|
|
4827
4829
|
"ttd",
|
|
4828
4830
|
"datasys",
|
|
4831
|
+
"simpli_fi",
|
|
4829
4832
|
]);
|
|
4830
4833
|
/**
|
|
4831
4834
|
* Account readiness status for a vendor.
|
|
@@ -5593,4 +5596,174 @@ export const businessIntelCache = pgTable("business_intel_cache", {
|
|
|
5593
5596
|
.on(table.partnerId, table.hubspotCompanyId)
|
|
5594
5597
|
.where(sql `hubspot_company_id IS NOT NULL`),
|
|
5595
5598
|
]);
|
|
5599
|
+
// =============================================================================
|
|
5600
|
+
// SIMPLI.FI DSP INTEGRATION
|
|
5601
|
+
// =============================================================================
|
|
5602
|
+
export const simplifiCampaignStatusEnum = pgEnum("simplifi_campaign_status", [
|
|
5603
|
+
"draft",
|
|
5604
|
+
"active",
|
|
5605
|
+
"paused",
|
|
5606
|
+
"ended",
|
|
5607
|
+
"error",
|
|
5608
|
+
]);
|
|
5609
|
+
export const simplifiGeoFenceTypeEnum = pgEnum("simplifi_geo_fence_type", [
|
|
5610
|
+
"addressable",
|
|
5611
|
+
"location",
|
|
5612
|
+
"conversion_zone",
|
|
5613
|
+
"event",
|
|
5614
|
+
]);
|
|
5615
|
+
/**
|
|
5616
|
+
* simplifi_campaigns — Tracks campaigns pushed to Simpli.fi DSP.
|
|
5617
|
+
* One campaign per eligible line item.
|
|
5618
|
+
*/
|
|
5619
|
+
export const simplifiCampaigns = pgTable("simplifi_campaigns", {
|
|
5620
|
+
id: varchar("id")
|
|
5621
|
+
.primaryKey()
|
|
5622
|
+
.default(sql `gen_random_uuid()`),
|
|
5623
|
+
/** Simpli.fi's campaign ID */
|
|
5624
|
+
simplifiCampaignId: text("simplifi_campaign_id").notNull().unique(),
|
|
5625
|
+
/** Simpli.fi organization ID this campaign belongs to */
|
|
5626
|
+
organizationId: text("organization_id").notNull(),
|
|
5627
|
+
/** Campaign name as created in Simpli.fi */
|
|
5628
|
+
campaignName: text("campaign_name").notNull(),
|
|
5629
|
+
/** Campaign lifecycle status */
|
|
5630
|
+
status: simplifiCampaignStatusEnum("status").notNull().default("draft"),
|
|
5631
|
+
/** FK → media_orders.id */
|
|
5632
|
+
mediaOrderId: varchar("media_order_id"),
|
|
5633
|
+
/** FK → media_order_line_items.id */
|
|
5634
|
+
lineItemId: varchar("line_item_id"),
|
|
5635
|
+
/** Total campaign budget in dollars */
|
|
5636
|
+
totalBudget: numeric("total_budget", { precision: 12, scale: 2 }),
|
|
5637
|
+
/** Campaign start date */
|
|
5638
|
+
startDate: date("start_date"),
|
|
5639
|
+
/** Campaign end date */
|
|
5640
|
+
endDate: date("end_date"),
|
|
5641
|
+
/** Vendor-specific metadata (bid type, ad sizes, etc.) */
|
|
5642
|
+
simplifiMetadata: jsonb("simplifi_metadata").$type(),
|
|
5643
|
+
/** Last sync error message (null = no error) */
|
|
5644
|
+
syncError: text("sync_error"),
|
|
5645
|
+
/** Last time this campaign was synced with Simpli.fi API */
|
|
5646
|
+
lastSyncedAt: timestamp("last_synced_at"),
|
|
5647
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
5648
|
+
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
5649
|
+
}, (table) => [
|
|
5650
|
+
index("simplifi_campaigns_order_idx").on(table.mediaOrderId),
|
|
5651
|
+
index("simplifi_campaigns_line_item_idx").on(table.lineItemId),
|
|
5652
|
+
index("simplifi_campaigns_status_idx").on(table.status),
|
|
5653
|
+
]);
|
|
5654
|
+
export const insertSimplifiCampaignSchema = createInsertSchema(simplifiCampaigns).omit({
|
|
5655
|
+
id: true,
|
|
5656
|
+
createdAt: true,
|
|
5657
|
+
updatedAt: true,
|
|
5658
|
+
});
|
|
5659
|
+
/**
|
|
5660
|
+
* simplifi_geo_fences — Tracks geo-fences pushed to Simpli.fi campaigns.
|
|
5661
|
+
* Links a Simpli.fi campaign to geo-targets from the shared geo_targets table.
|
|
5662
|
+
*/
|
|
5663
|
+
export const simplifiGeoFences = pgTable("simplifi_geo_fences", {
|
|
5664
|
+
id: varchar("id")
|
|
5665
|
+
.primaryKey()
|
|
5666
|
+
.default(sql `gen_random_uuid()`),
|
|
5667
|
+
/** FK → simplifi_campaigns.simplifi_campaign_id */
|
|
5668
|
+
simplifiCampaignId: text("simplifi_campaign_id").notNull(),
|
|
5669
|
+
/** FK → geo_targets.id (nullable for ad-hoc fences without saved geo-targets) */
|
|
5670
|
+
geoTargetId: varchar("geo_target_id"),
|
|
5671
|
+
/** Fence type in Simpli.fi */
|
|
5672
|
+
fenceType: simplifiGeoFenceTypeEnum("fence_type").notNull().default("location"),
|
|
5673
|
+
/** Fence display name */
|
|
5674
|
+
name: text("name").notNull(),
|
|
5675
|
+
/** Latitude of fence center */
|
|
5676
|
+
lat: numeric("lat", { precision: 10, scale: 7 }).notNull(),
|
|
5677
|
+
/** Longitude of fence center */
|
|
5678
|
+
lng: numeric("lng", { precision: 10, scale: 7 }).notNull(),
|
|
5679
|
+
/** Fence radius in meters */
|
|
5680
|
+
radiusMeters: numeric("radius_meters", { precision: 10, scale: 2 }).notNull(),
|
|
5681
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
5682
|
+
}, (table) => [
|
|
5683
|
+
index("simplifi_geo_fences_campaign_idx").on(table.simplifiCampaignId),
|
|
5684
|
+
index("simplifi_geo_fences_geo_target_idx").on(table.geoTargetId),
|
|
5685
|
+
]);
|
|
5686
|
+
/**
|
|
5687
|
+
* simplifi_budget_flights — Budget flights (monthly/periodic budget splits)
|
|
5688
|
+
* for Simpli.fi campaigns. Proportional to days in each period.
|
|
5689
|
+
*/
|
|
5690
|
+
export const simplifiBudgetFlights = pgTable("simplifi_budget_flights", {
|
|
5691
|
+
id: varchar("id")
|
|
5692
|
+
.primaryKey()
|
|
5693
|
+
.default(sql `gen_random_uuid()`),
|
|
5694
|
+
/** FK → simplifi_campaigns.simplifi_campaign_id */
|
|
5695
|
+
simplifiCampaignId: text("simplifi_campaign_id").notNull(),
|
|
5696
|
+
/** Simpli.fi's budget flight ID */
|
|
5697
|
+
simplifiFlightId: text("simplifi_flight_id"),
|
|
5698
|
+
/** Flight start date */
|
|
5699
|
+
startDate: date("start_date").notNull(),
|
|
5700
|
+
/** Flight end date */
|
|
5701
|
+
endDate: date("end_date").notNull(),
|
|
5702
|
+
/** Budget allocated to this flight */
|
|
5703
|
+
budget: numeric("budget", { precision: 12, scale: 2 }).notNull(),
|
|
5704
|
+
/** Impression cap for this flight (if applicable) */
|
|
5705
|
+
impressionCap: integer("impression_cap"),
|
|
5706
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
5707
|
+
}, (table) => [
|
|
5708
|
+
index("simplifi_budget_flights_campaign_idx").on(table.simplifiCampaignId),
|
|
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
|
+
]);
|
|
5596
5769
|
//# sourceMappingURL=schema.js.map
|