@foundrynorth/compass-schema 1.0.3 → 1.0.5

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
@@ -1528,6 +1528,9 @@ export const partners = pgTable("partners", {
1528
1528
  // Metadata
1529
1529
  createdAt: timestamp("created_at").notNull().defaultNow(),
1530
1530
  createdBy: text("created_by"), // Super admin who created this partner
1531
+ slug: varchar("slug"),
1532
+ isActive: boolean("is_active"),
1533
+ settings: jsonb("settings"),
1531
1534
  updatedAt: timestamp("updated_at").notNull().defaultNow(),
1532
1535
  });
1533
1536
  export const insertPartnerSchema = createInsertSchema(partners).omit({
@@ -1933,6 +1936,12 @@ export const investmentOptimizationSettings = pgTable("investment_optimization_s
1933
1936
  .notNull()
1934
1937
  .default(1),
1935
1938
  useGoldAccents: integer("use_gold_accents").notNull().default(1),
1939
+ tierThresholds: jsonb("tier_thresholds"),
1940
+ productPolicies: jsonb("product_policies"),
1941
+ partnerId: varchar("partner_id"),
1942
+ version: integer("version"),
1943
+ enabled: integer("enabled"),
1944
+ createdAt: timestamp("created_at"),
1936
1945
  updatedAt: timestamp("updated_at").notNull().defaultNow(),
1937
1946
  updatedBy: text("updated_by"),
1938
1947
  });
@@ -1993,6 +2002,8 @@ export const rfpRequests = pgTable("rfp_requests", {
1993
2002
  partnerId: text("partner_id"), // Partner association if applicable
1994
2003
  // Extracted RFP Details
1995
2004
  metadata: jsonb("metadata").$type(),
2005
+ // Company
2006
+ companyName: text("company_name"),
1996
2007
  // Timestamps
1997
2008
  createdAt: timestamp("created_at").notNull().defaultNow(),
1998
2009
  updatedAt: timestamp("updated_at").notNull().defaultNow(),
@@ -4233,6 +4244,8 @@ export const hubspotSyncErrors = pgTable("hubspot_sync_errors", {
4233
4244
  resolvedAt: timestamp("resolved_at", { withTimezone: true, mode: 'string' }),
4234
4245
  resolvedBy: text("resolved_by"),
4235
4246
  resolutionNotes: text("resolution_notes"),
4247
+ errorCode: text("error_code"),
4248
+ retryCount: integer("retry_count"),
4236
4249
  createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
4237
4250
  }, (table) => ({
4238
4251
  systemIdx: index("hubspot_sync_errors_system_idx").on(table.system),
@@ -4270,7 +4283,21 @@ export const mapsGridScans = pgTable("maps_grid_scans", {
4270
4283
  gridPoints: jsonb("grid_points").notNull(),
4271
4284
  results: jsonb().notNull(),
4272
4285
  locationCode: integer("location_code"),
4286
+ zoomLevel: integer("zoom_level"),
4287
+ uniquePlaceIds: jsonb("unique_place_ids"),
4288
+ justificationSummary: jsonb("justification_summary"),
4289
+ topBusinesses: jsonb("top_businesses"),
4290
+ targetPlaceId: varchar("target_place_id"),
4291
+ targetRanks: jsonb("target_ranks"),
4292
+ planId: varchar("plan_id"),
4293
+ radiusKm: doublePrecision("radius_km"),
4294
+ status: varchar("status"),
4295
+ errorMessage: text("error_message"),
4296
+ totalBusinesses: integer("total_businesses"),
4273
4297
  scannedAt: timestamp("scanned_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
4298
+ completedAt: timestamp("completed_at"),
4299
+ createdAt: timestamp("created_at"),
4300
+ updatedAt: timestamp("updated_at"),
4274
4301
  }, (table) => ({
4275
4302
  jobIdIdx: index("maps_grid_scans_job_id_idx").on(table.jobId),
4276
4303
  keywordIdx: index("maps_grid_scans_keyword_idx").on(table.keyword),
@@ -4338,9 +4365,24 @@ export const planAnnotations = pgTable("plan_annotations", {
4338
4365
  content: text().notNull(),
4339
4366
  metadata: jsonb(),
4340
4367
  createdBy: text("created_by").notNull(),
4368
+ shouldInfluenceFuture: boolean("should_influence_future"),
4369
+ targetPath: text("target_path"),
4370
+ originalValue: jsonb("original_value"),
4371
+ overrideValue: jsonb("override_value"),
4372
+ reasoning: text("reasoning"),
4373
+ reasoningCategory: varchar("reasoning_category"),
4374
+ similarityConditions: jsonb("similarity_conditions"),
4375
+ timesApplied: integer("times_applied"),
4376
+ timesAccepted: integer("times_accepted"),
4377
+ timesRejected: integer("times_rejected"),
4378
+ createdByUserId: text("created_by_user_id"),
4379
+ createdByUserName: text("created_by_user_name"),
4380
+ createdByUserEmail: text("created_by_user_email"),
4381
+ partnerId: varchar("partner_id"),
4341
4382
  createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
4342
4383
  updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
4343
4384
  deletedAt: timestamp("deleted_at", { withTimezone: true, mode: 'string' }),
4385
+ archivedAt: timestamp("archived_at"),
4344
4386
  }, (table) => ({
4345
4387
  planIdIdx: index("plan_annotations_plan_id_idx").on(table.planId),
4346
4388
  targetIdx: index("plan_annotations_target_idx").on(table.targetType, table.targetId),
@@ -4383,6 +4425,9 @@ export const projectLocations = pgTable("project_locations", {
4383
4425
  lng: doublePrecision(),
4384
4426
  placeId: text("place_id"),
4385
4427
  isPrimary: integer("is_primary").default(0),
4428
+ website: varchar("website"),
4429
+ dmaCode: varchar("dma_code"),
4430
+ dmaName: varchar("dma_name"),
4386
4431
  metadata: jsonb(),
4387
4432
  createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
4388
4433
  updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
@@ -4396,6 +4441,9 @@ export const projects = pgTable("projects", {
4396
4441
  status: text().notNull(),
4397
4442
  ownerId: text("owner_id").notNull(),
4398
4443
  partnerId: text("partner_id"),
4444
+ domain: varchar("domain"),
4445
+ category: varchar("category"),
4446
+ triggerRunId: varchar("trigger_run_id"),
4399
4447
  metadata: jsonb(),
4400
4448
  createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
4401
4449
  updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
@@ -4421,6 +4469,17 @@ export const prospects = pgTable("prospects", {
4421
4469
  prospectWebsite: text("prospect_website"),
4422
4470
  prospectCategory: text("prospect_category"),
4423
4471
  prospectGeo: text("prospect_geo"),
4472
+ isChain: boolean("is_chain"),
4473
+ chainId: varchar("chain_id"),
4474
+ branchCount: integer("branch_count"),
4475
+ locations: jsonb("locations"),
4476
+ analysisStatus: varchar("analysis_status"),
4477
+ partnerId: varchar("partner_id"),
4478
+ url: text("url"),
4479
+ dmaCode: varchar("dma_code"),
4480
+ dmaName: varchar("dma_name"),
4481
+ analysisData: jsonb("analysis_data"),
4482
+ competitors: jsonb("competitors"),
4424
4483
  createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
4425
4484
  updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
4426
4485
  }, (table) => ({
@@ -4441,6 +4500,11 @@ export const reports = pgTable("reports", {
4441
4500
  locationId: uuid("location_id"),
4442
4501
  competitorData: jsonb("competitor_data"),
4443
4502
  analysisData: jsonb("analysis_data"),
4503
+ seoData: jsonb("seo_data"),
4504
+ socialData: jsonb("social_data"),
4505
+ triggerRunId: varchar("trigger_run_id"),
4506
+ planData: jsonb("plan_data"),
4507
+ errorMessage: text("error_message"),
4444
4508
  createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
4445
4509
  updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(),
4446
4510
  }, (table) => ({
@@ -5499,4 +5563,34 @@ export const geoTargets = pgTable("geo_targets", {
5499
5563
  index("geo_targets_client_name_idx").on(table.clientName),
5500
5564
  index("geo_targets_active_idx").on(table.isActive),
5501
5565
  ]);
5566
+ // ─── Business Intelligence Cache ──────────────────────────────────────────────
5567
+ // Migration: 0034_business_intel_cache.sql
5568
+ // Cross-flow enrichment cache keyed by domain or HubSpot company ID.
5569
+ // Populated by inline-assist, background enrichment, and deep research.
5570
+ export const businessIntelCache = pgTable("business_intel_cache", {
5571
+ id: uuid("id").primaryKey().defaultRandom(),
5572
+ partnerId: varchar("partner_id"),
5573
+ domain: text("domain"),
5574
+ hubspotCompanyId: text("hubspot_company_id"),
5575
+ clientName: text("client_name"),
5576
+ quickEnrichData: jsonb("quick_enrich_data"),
5577
+ trueNorthHistory: jsonb("true_north_history"),
5578
+ contractTier: text("contract_tier"),
5579
+ adActivity: jsonb("ad_activity"),
5580
+ seoSnapshot: jsonb("seo_snapshot"),
5581
+ techSignals: jsonb("tech_signals"),
5582
+ confidenceLevel: text("confidence_level"),
5583
+ sources: text("sources").array(),
5584
+ lastEnrichedAt: timestamp("last_enriched_at", { withTimezone: true }),
5585
+ ttlExpiresAt: timestamp("ttl_expires_at", { withTimezone: true }),
5586
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
5587
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
5588
+ }, (table) => [
5589
+ uniqueIndex("bic_partner_domain_unique_idx")
5590
+ .on(table.partnerId, table.domain)
5591
+ .where(sql `domain IS NOT NULL`),
5592
+ uniqueIndex("bic_partner_hubspot_company_id_unique_idx")
5593
+ .on(table.partnerId, table.hubspotCompanyId)
5594
+ .where(sql `hubspot_company_id IS NOT NULL`),
5595
+ ]);
5502
5596
  //# sourceMappingURL=schema.js.map