@bettercms-ai/db 0.1.1 → 0.2.0

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/index.js CHANGED
@@ -11629,18 +11629,18 @@ var require_common = __commonJS({
11629
11629
  if (typeof args[0] !== "string") {
11630
11630
  args.unshift("%O");
11631
11631
  }
11632
- let index101 = 0;
11632
+ let index103 = 0;
11633
11633
  args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
11634
11634
  if (match === "%%") {
11635
11635
  return "%";
11636
11636
  }
11637
- index101++;
11637
+ index103++;
11638
11638
  const formatter = createDebug.formatters[format];
11639
11639
  if (typeof formatter === "function") {
11640
- const val = args[index101];
11640
+ const val = args[index103];
11641
11641
  match = formatter.call(self2, val);
11642
- args.splice(index101, 1);
11643
- index101--;
11642
+ args.splice(index103, 1);
11643
+ index103--;
11644
11644
  }
11645
11645
  return match;
11646
11646
  });
@@ -11876,15 +11876,15 @@ var require_browser = __commonJS({
11876
11876
  }
11877
11877
  const c = "color: " + this.color;
11878
11878
  args.splice(1, 0, c, "color: inherit");
11879
- let index101 = 0;
11879
+ let index103 = 0;
11880
11880
  let lastC = 0;
11881
11881
  args[0].replace(/%[a-zA-Z%]/g, (match) => {
11882
11882
  if (match === "%%") {
11883
11883
  return;
11884
11884
  }
11885
- index101++;
11885
+ index103++;
11886
11886
  if (match === "%c") {
11887
- lastC = index101;
11887
+ lastC = index103;
11888
11888
  }
11889
11889
  });
11890
11890
  args.splice(lastC, 0, c);
@@ -13368,10 +13368,10 @@ var require_axios = __commonJS({
13368
13368
  value = JSON.stringify(value);
13369
13369
  } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
13370
13370
  key = removeBrackets(key);
13371
- arr.forEach(function each(el, index101) {
13371
+ arr.forEach(function each(el, index103) {
13372
13372
  !(utils$1.isUndefined(el) || el === null) && formData.append(
13373
13373
  // eslint-disable-next-line no-nested-ternary
13374
- indexes === true ? renderKey([key], index101, dots) : indexes === null ? key : key + "[]",
13374
+ indexes === true ? renderKey([key], index103, dots) : indexes === null ? key : key + "[]",
13375
13375
  convertValue(el)
13376
13376
  );
13377
13377
  });
@@ -13618,11 +13618,11 @@ var require_axios = __commonJS({
13618
13618
  return obj;
13619
13619
  }
13620
13620
  function formDataToJSON(formData) {
13621
- function buildPath(path2, value, target, index101) {
13622
- let name = path2[index101++];
13621
+ function buildPath(path2, value, target, index103) {
13622
+ let name = path2[index103++];
13623
13623
  if (name === "__proto__") return true;
13624
13624
  const isNumericKey = Number.isFinite(+name);
13625
- const isLast = index101 >= path2.length;
13625
+ const isLast = index103 >= path2.length;
13626
13626
  name = !name && utils$1.isArray(target) ? target.length : name;
13627
13627
  if (isLast) {
13628
13628
  if (utils$1.hasOwnProp(target, name)) {
@@ -13635,7 +13635,7 @@ var require_axios = __commonJS({
13635
13635
  if (!target[name] || !utils$1.isObject(target[name])) {
13636
13636
  target[name] = [];
13637
13637
  }
13638
- const result = buildPath(path2, value, target[name], index101);
13638
+ const result = buildPath(path2, value, target[name], index103);
13639
13639
  if (result && utils$1.isArray(target[name])) {
13640
13640
  target[name] = arrayToObject(target[name]);
13641
13641
  }
@@ -14563,12 +14563,12 @@ var require_axios = __commonJS({
14563
14563
  };
14564
14564
  }
14565
14565
  function throttle(fn, freq) {
14566
- let timestamp106 = 0;
14566
+ let timestamp109 = 0;
14567
14567
  let threshold = 1e3 / freq;
14568
14568
  let lastArgs;
14569
14569
  let timer;
14570
14570
  const invoke = (args, now = Date.now()) => {
14571
- timestamp106 = now;
14571
+ timestamp109 = now;
14572
14572
  lastArgs = null;
14573
14573
  if (timer) {
14574
14574
  clearTimeout(timer);
@@ -14578,7 +14578,7 @@ var require_axios = __commonJS({
14578
14578
  };
14579
14579
  const throttled = (...args) => {
14580
14580
  const now = Date.now();
14581
- const passed = now - timestamp106;
14581
+ const passed = now - timestamp109;
14582
14582
  if (passed >= threshold) {
14583
14583
  invoke(args, now);
14584
14584
  } else {
@@ -16406,9 +16406,9 @@ var require_axios = __commonJS({
16406
16406
  if (!this._listeners) {
16407
16407
  return;
16408
16408
  }
16409
- const index101 = this._listeners.indexOf(listener);
16410
- if (index101 !== -1) {
16411
- this._listeners.splice(index101, 1);
16409
+ const index103 = this._listeners.indexOf(listener);
16410
+ if (index103 !== -1) {
16411
+ this._listeners.splice(index103, 1);
16412
16412
  }
16413
16413
  }
16414
16414
  toAbortSignal() {
@@ -20130,6 +20130,7 @@ __export(index_exports, {
20130
20130
  bcmsMigrationFlags: () => bcmsMigrationFlags,
20131
20131
  betaWaitlist: () => betaWaitlist,
20132
20132
  billingAddons: () => billingAddons,
20133
+ billingAlerts: () => billingAlerts,
20133
20134
  billingCustomers: () => billingCustomers,
20134
20135
  branchColumns: () => branchColumns,
20135
20136
  branchPreviewGrants: () => branchPreviewGrants,
@@ -20163,10 +20164,13 @@ __export(index_exports, {
20163
20164
  contentLocks: () => contentLocks,
20164
20165
  contentModels: () => contentModels,
20165
20166
  contentModelsRelations: () => contentModelsRelations,
20167
+ contentNavigation: () => contentNavigation,
20166
20168
  contentVersions: () => contentVersions,
20167
20169
  conversionBriefsIssued: () => conversionBriefsIssued,
20168
20170
  conversionProposals: () => conversionProposals,
20171
+ crmConnections: () => crmConnections,
20169
20172
  crmDeals: () => crmDeals,
20173
+ crmOauthStates: () => crmOauthStates,
20170
20174
  customDomains: () => customDomains,
20171
20175
  deployTargets: () => deployTargets,
20172
20176
  deviceAuthorizations: () => deviceAuthorizations,
@@ -20176,6 +20180,7 @@ __export(index_exports, {
20176
20180
  foldersRelations: () => foldersRelations,
20177
20181
  formContacts: () => formContacts,
20178
20182
  formContactsRelations: () => formContactsRelations,
20183
+ formIntegrationDeliveries: () => formIntegrationDeliveries,
20179
20184
  formIntegrations: () => formIntegrations,
20180
20185
  formIntegrationsRelations: () => formIntegrationsRelations,
20181
20186
  formSubmissions: () => formSubmissions,
@@ -20358,8 +20363,12 @@ import { sql } from "drizzle-orm";
20358
20363
  var workspaces = pgTable(
20359
20364
  "workspaces",
20360
20365
  {
20366
+ // TEXT, but the values are UUIDs: workspaces are created with crypto.randomUUID()
20367
+ // (src/workspaces.ts). That matters — setWorkspaceContext() pins RLS with
20368
+ // set_current_workspace(<id>::uuid), and there is a TEXT overload it does NOT use, so
20369
+ // reading this as a nanoid suggests the standard RLS pinning helper would throw on a
20370
+ // real id. It does not. Other tables here genuinely are nanoid; this one is not.
20361
20371
  id: text2("id").primaryKey(),
20362
- // nanoid — consistent with BetterAuth approach
20363
20372
  name: varchar("name", { length: 255 }).notNull(),
20364
20373
  slug: varchar("slug", { length: 255 }).notNull().unique(),
20365
20374
  // used in API paths: /api/v1/:workspace/...
@@ -21432,6 +21441,8 @@ var projects = pgTable10(
21432
21441
  // Brand kit (0162): colors/type/shape/logos/voice. NULL = never configured; the
21433
21442
  // API substitutes DEFAULT_BRAND_KIT rather than storing a row of defaults.
21434
21443
  brandKit: jsonb8("brand_kit").$type(),
21444
+ brandDesign: jsonb8("brand_design").$type(),
21445
+ brandDesignTarget: varchar10("brand_design_target", { length: 64 }),
21435
21446
  /**
21436
21447
  * Last annotate run per release slot (migration 0229): which declared field paths could not
21437
21448
  * be bound to an element on the built page. Lets the Visual Editor say "3 fields unbindable"
@@ -21532,10 +21543,14 @@ var projects = pgTable10(
21532
21543
  canvasEnabled: boolean7("canvas_enabled").notNull().default(false),
21533
21544
  // Validate components automatically once a release is live (migration 0324). Defaults FALSE: the run spends the
21534
21545
  // customer's own GitHub Actions minutes. `componentValidationDispatchedAt` debounces a release storm.
21535
- componentAutoValidate: boolean7("component_auto_validate").notNull().default(false),
21546
+ componentAutoValidate: boolean7("component_auto_validate").notNull().default(true),
21536
21547
  componentValidationDispatchedAt: timestamp11("component_validation_dispatched_at", { withTimezone: true }),
21537
21548
  // The last automatic pass left components out (LIMIT_REACHED); its batch's last report starts the next pass (0331).
21538
21549
  componentValidationOverflow: boolean7("component_validation_overflow").notNull().default(false),
21550
+ // The last automatic validation pass's decision, whatever it was (0333) — so a project that never validates says why.
21551
+ componentValidationLastPass: jsonb8("component_validation_last_pass").$type(),
21552
+ // The release commit the last dispatching automatic pass ran for: a redeploy of that commit does not dispatch (0333).
21553
+ componentValidationCommitSha: text11("component_validation_commit_sha"),
21539
21554
  // How nginx resolves a page request for this project (FLO-947; migration 0211, widened
21540
21555
  // to 'node' by 0225).
21541
21556
  // 'static' = today's disk-first `try_files`; the CMS renderer only fills gaps.
@@ -23084,7 +23099,8 @@ import {
23084
23099
  timestamp as timestamp44,
23085
23100
  integer as integer21,
23086
23101
  index as index43,
23087
- unique as unique3
23102
+ unique as unique3,
23103
+ jsonb as jsonb25
23088
23104
  } from "drizzle-orm/pg-core";
23089
23105
  var releases = pgTable46(
23090
23106
  "releases",
@@ -23102,6 +23118,11 @@ var releases = pgTable46(
23102
23118
  commitMessage: text47("commit_message"),
23103
23119
  // pending | ingested | releasing | live | failed | rolled_back
23104
23120
  status: varchar30("status", { length: 20 }).notNull().default("ingested"),
23121
+ designInput: jsonb25("design_input").$type(),
23122
+ designSnapshot: jsonb25("design_snapshot").$type(),
23123
+ designError: text47("design_error"),
23124
+ designAttempts: integer21("design_attempts").notNull().default(0),
23125
+ designRetryAt: timestamp44("design_retry_at"),
23105
23126
  // Artifact triple. NULL on a row that records a FAILED BUILD (0175): the build
23106
23127
  // never produced a .tgz, so there is nothing to key, checksum or size. Every
23107
23128
  // reader that resolves a deployable release must therefore filter on a status
@@ -23258,7 +23279,7 @@ var githubInstallations = pgTable49("github_installations", {
23258
23279
  });
23259
23280
 
23260
23281
  // src/schema/custom_domains.ts
23261
- import { pgTable as pgTable50, text as text51, varchar as varchar34, boolean as boolean23, timestamp as timestamp46, index as index44, uniqueIndex as uniqueIndex18, jsonb as jsonb25 } from "drizzle-orm/pg-core";
23282
+ import { pgTable as pgTable50, text as text51, varchar as varchar34, boolean as boolean23, timestamp as timestamp46, index as index44, uniqueIndex as uniqueIndex18, jsonb as jsonb26 } from "drizzle-orm/pg-core";
23262
23283
  var customDomains = pgTable50(
23263
23284
  "custom_domains",
23264
23285
  {
@@ -23292,7 +23313,7 @@ var customDomains = pgTable50(
23292
23313
  */
23293
23314
  deployTargetId: text51("deploy_target_id"),
23294
23315
  /** The DNS the PROVIDER asked for: pointing record plus any ownership challenge. */
23295
- providerRecords: jsonb25("provider_records").$type(),
23316
+ providerRecords: jsonb26("provider_records").$type(),
23296
23317
  /** Nonce published at `_bettercms.<host>` as `verify=<token>`; checked by POST /verify. */
23297
23318
  verificationToken: text51("verification_token"),
23298
23319
  /** When that TXT last matched. NULL = never confirmed BY US (≠ Cloudflare's ssl_status). */
@@ -23590,7 +23611,7 @@ var externalDeployments = pgTable55(
23590
23611
  );
23591
23612
 
23592
23613
  // src/schema/page_types.ts
23593
- import { pgTable as pgTable56, text as text57, varchar as varchar40, jsonb as jsonb26, index as index50, uniqueIndex as uniqueIndex22 } from "drizzle-orm/pg-core";
23614
+ import { pgTable as pgTable56, text as text57, varchar as varchar40, jsonb as jsonb27, index as index50, uniqueIndex as uniqueIndex22 } from "drizzle-orm/pg-core";
23594
23615
  var pageTypes = pgTable56(
23595
23616
  "page_types",
23596
23617
  {
@@ -23601,8 +23622,8 @@ var pageTypes = pgTable56(
23601
23622
  slug: varchar40("slug", { length: 255 }).notNull(),
23602
23623
  /** Same ContentModelField[] shape `pages.fields` holds — a type exists so several pages
23603
23624
  * can SHARE one schema instead of each carrying a copy. */
23604
- fields: jsonb26("fields").$type().notNull().default([]),
23605
- routingJson: jsonb26("routing_json").$type(),
23625
+ fields: jsonb27("fields").$type().notNull().default([]),
23626
+ routingJson: jsonb27("routing_json").$type(),
23606
23627
  ...branchColumns,
23607
23628
  ...auditColumns,
23608
23629
  ...softDeleteColumn
@@ -23615,7 +23636,7 @@ var pageTypes = pgTable56(
23615
23636
  );
23616
23637
 
23617
23638
  // src/schema/build_triggers.ts
23618
- import { pgTable as pgTable57, text as text58, varchar as varchar41, boolean as boolean26, timestamp as timestamp53, integer as integer24, jsonb as jsonb27, index as index51, uniqueIndex as uniqueIndex23 } from "drizzle-orm/pg-core";
23639
+ import { pgTable as pgTable57, text as text58, varchar as varchar41, boolean as boolean26, timestamp as timestamp53, integer as integer24, jsonb as jsonb28, index as index51, uniqueIndex as uniqueIndex23 } from "drizzle-orm/pg-core";
23619
23640
  var BUILD_TRIGGER_KINDS = ["webhook", "content", "schedule"];
23620
23641
  var buildTriggers = pgTable57(
23621
23642
  "build_triggers",
@@ -23637,7 +23658,7 @@ var buildTriggers = pgTable57(
23637
23658
  prevSecretEnc: text58("prev_secret_enc"),
23638
23659
  prevSecretExpiresAt: timestamp53("prev_secret_expires_at"),
23639
23660
  /** `[]` = every publish. Model SLUGS, not ids — ids break across a model rebuild. */
23640
- contentScopes: jsonb27("content_scopes").$type().notNull().default([]),
23661
+ contentScopes: jsonb28("content_scopes").$type().notNull().default([]),
23641
23662
  schedule: varchar41("schedule", { length: 120 }),
23642
23663
  /** IANA zone. "Rebuild at 9am" means 9am where the customer is. */
23643
23664
  timezone: varchar41("timezone", { length: 64 }).notNull().default("UTC"),
@@ -23747,7 +23768,7 @@ var aiProviderKeys = pgTable61(
23747
23768
  );
23748
23769
 
23749
23770
  // src/schema/agent_sessions.ts
23750
- import { pgTable as pgTable62, text as text63, varchar as varchar45, timestamp as timestamp56, doublePrecision, jsonb as jsonb28, index as index52 } from "drizzle-orm/pg-core";
23771
+ import { pgTable as pgTable62, text as text63, varchar as varchar45, timestamp as timestamp56, doublePrecision, jsonb as jsonb29, index as index52 } from "drizzle-orm/pg-core";
23751
23772
  var agentSessions = pgTable62(
23752
23773
  "agent_sessions",
23753
23774
  {
@@ -23788,7 +23809,7 @@ var agentMessages = pgTable62(
23788
23809
  sessionId: text63("session_id").notNull(),
23789
23810
  role: varchar45("role", { length: 16 }).notNull(),
23790
23811
  // user | assistant | tool
23791
- content: jsonb28("content").notNull(),
23812
+ content: jsonb29("content").notNull(),
23792
23813
  // { text? , toolName?, toolInput?, toolResult? ... }
23793
23814
  createdAt: timestamp56("created_at").notNull().defaultNow()
23794
23815
  },
@@ -23796,7 +23817,7 @@ var agentMessages = pgTable62(
23796
23817
  );
23797
23818
 
23798
23819
  // src/schema/agent_instructions.ts
23799
- import { pgTable as pgTable63, text as text64, varchar as varchar46, boolean as boolean27, jsonb as jsonb29, timestamp as timestamp57, index as index53, check as check2 } from "drizzle-orm/pg-core";
23820
+ import { pgTable as pgTable63, text as text64, varchar as varchar46, boolean as boolean27, jsonb as jsonb30, timestamp as timestamp57, index as index53, check as check2 } from "drizzle-orm/pg-core";
23800
23821
  import { sql as sql12 } from "drizzle-orm";
23801
23822
  var INSTRUCTION_KINDS = ["skill", "rule"];
23802
23823
  var INSTRUCTION_SOURCES = ["template", "manual", "import"];
@@ -23816,7 +23837,7 @@ var agentInstructions = pgTable63(
23816
23837
  /** Master switch. Off = ignored everywhere, regardless of `disabledFor`. */
23817
23838
  enabled: boolean27("enabled").notNull().default(true),
23818
23839
  /** Project ids that opted OUT. Workspace-wide by default, scoped by exception. */
23819
- disabledFor: jsonb29("disabled_for").$type().notNull().default([]),
23840
+ disabledFor: jsonb30("disabled_for").$type().notNull().default([]),
23820
23841
  source: varchar46("source", { length: 16 }).$type().notNull().default("manual"),
23821
23842
  templateId: varchar46("template_id", { length: 64 }),
23822
23843
  // set when source === "template"
@@ -23839,7 +23860,7 @@ var agentInstructions = pgTable63(
23839
23860
  );
23840
23861
 
23841
23862
  // src/schema/ai_generation_jobs.ts
23842
- import { pgTable as pgTable64, text as text65, varchar as varchar47, integer as integer26, jsonb as jsonb30, timestamp as timestamp58, index as index54 } from "drizzle-orm/pg-core";
23863
+ import { pgTable as pgTable64, text as text65, varchar as varchar47, integer as integer26, jsonb as jsonb31, timestamp as timestamp58, index as index54 } from "drizzle-orm/pg-core";
23843
23864
  var aiGenerationJobs = pgTable64(
23844
23865
  "ai_generation_jobs",
23845
23866
  {
@@ -23855,9 +23876,9 @@ var aiGenerationJobs = pgTable64(
23855
23876
  // Durable because the drain runs after the request connection (and its GUCs) is gone.
23856
23877
  // AI-produced content is always an agent write, even when a human queued the job.
23857
23878
  writeOrigin: text65("write_origin").$type().notNull().default("agent:tab"),
23858
- mapping: jsonb30("mapping").notNull(),
23879
+ mapping: jsonb31("mapping").notNull(),
23859
23880
  // GenerateMapping (generate) | { contentModelId } (seo)
23860
- rows: jsonb30("rows").notNull(),
23881
+ rows: jsonb31("rows").notNull(),
23861
23882
  /**
23862
23883
  * needs_approval | queued | running | done | failed
23863
23884
  *
@@ -23876,7 +23897,7 @@ var aiGenerationJobs = pgTable64(
23876
23897
  * scope/estimate that is approved is the scope/estimate that runs. Null on jobs that never
23877
23898
  * needed approval. Mirrors the migration_jobs.plan precedent.
23878
23899
  */
23879
- plan: jsonb30("plan"),
23900
+ plan: jsonb31("plan"),
23880
23901
  total: integer26("total").notNull().default(0),
23881
23902
  processed: integer26("processed").notNull().default(0),
23882
23903
  cursor: integer26("cursor").notNull().default(0),
@@ -23892,7 +23913,7 @@ var aiGenerationJobs = pgTable64(
23892
23913
  );
23893
23914
 
23894
23915
  // src/schema/mcp_tasks.ts
23895
- import { check as check3, index as index55, integer as integer27, jsonb as jsonb31, pgTable as pgTable65, text as text66, timestamp as timestamp59, uniqueIndex as uniqueIndex26, varchar as varchar48 } from "drizzle-orm/pg-core";
23916
+ import { check as check3, index as index55, integer as integer27, jsonb as jsonb32, pgTable as pgTable65, text as text66, timestamp as timestamp59, uniqueIndex as uniqueIndex26, varchar as varchar48 } from "drizzle-orm/pg-core";
23896
23917
  import { sql as sql13 } from "drizzle-orm";
23897
23918
  var MCP_TASK_STATUSES = [
23898
23919
  "working",
@@ -23913,8 +23934,8 @@ var mcpTasks = pgTable65(
23913
23934
  aiJobId: text66("ai_job_id"),
23914
23935
  status: varchar48("status", { length: 24 }).$type().notNull().default("working"),
23915
23936
  statusMessage: text66("status_message"),
23916
- inputState: jsonb31("input_state").$type().notNull().default({}),
23917
- finalResult: jsonb31("final_result").$type(),
23937
+ inputState: jsonb32("input_state").$type().notNull().default({}),
23938
+ finalResult: jsonb32("final_result").$type(),
23918
23939
  ttlMs: integer27("ttl_ms"),
23919
23940
  pollIntervalMs: integer27("poll_interval_ms").notNull().default(2e3),
23920
23941
  cancelRequestedAt: timestamp59("cancel_requested_at"),
@@ -23954,7 +23975,7 @@ var mcpTasks = pgTable65(
23954
23975
  );
23955
23976
 
23956
23977
  // src/schema/seo_reports.ts
23957
- import { pgTable as pgTable66, text as text67, date, jsonb as jsonb32, timestamp as timestamp60, uniqueIndex as uniqueIndex27, index as index56 } from "drizzle-orm/pg-core";
23978
+ import { pgTable as pgTable66, text as text67, date, jsonb as jsonb33, timestamp as timestamp60, uniqueIndex as uniqueIndex27, index as index56 } from "drizzle-orm/pg-core";
23958
23979
  var seoReports = pgTable66(
23959
23980
  "seo_reports",
23960
23981
  {
@@ -23964,7 +23985,7 @@ var seoReports = pgTable66(
23964
23985
  projectId: text67("project_id").notNull(),
23965
23986
  periodStart: date("period_start").notNull(),
23966
23987
  periodEnd: date("period_end").notNull(),
23967
- metricsJson: jsonb32("metrics_json").$type().notNull(),
23988
+ metricsJson: jsonb33("metrics_json").$type().notNull(),
23968
23989
  summary: text67("summary").notNull(),
23969
23990
  createdAt: timestamp60("created_at", { withTimezone: true }).notNull().defaultNow()
23970
23991
  },
@@ -23976,7 +23997,7 @@ var seoReports = pgTable66(
23976
23997
  );
23977
23998
 
23978
23999
  // src/schema/qa_reports.ts
23979
- import { pgTable as pgTable67, text as text68, integer as integer28, jsonb as jsonb33, timestamp as timestamp61, index as index57 } from "drizzle-orm/pg-core";
24000
+ import { pgTable as pgTable67, text as text68, integer as integer28, jsonb as jsonb34, timestamp as timestamp61, index as index57 } from "drizzle-orm/pg-core";
23980
24001
  var qaReports = pgTable67(
23981
24002
  "qa_reports",
23982
24003
  {
@@ -23984,7 +24005,7 @@ var qaReports = pgTable67(
23984
24005
  // nanoid
23985
24006
  workspaceId: text68("workspace_id").notNull(),
23986
24007
  projectId: text68("project_id").notNull(),
23987
- findingsJson: jsonb33("findings_json").$type().notNull(),
24008
+ findingsJson: jsonb34("findings_json").$type().notNull(),
23988
24009
  summary: text68("summary").notNull(),
23989
24010
  criticalCount: integer28("critical_count").notNull().default(0),
23990
24011
  createdAt: timestamp61("created_at", { withTimezone: true }).notNull().defaultNow()
@@ -23993,7 +24014,7 @@ var qaReports = pgTable67(
23993
24014
  );
23994
24015
 
23995
24016
  // src/schema/webflow_integrations.ts
23996
- import { pgTable as pgTable68, text as text69, varchar as varchar49, jsonb as jsonb34, timestamp as timestamp62, index as index58 } from "drizzle-orm/pg-core";
24017
+ import { pgTable as pgTable68, text as text69, varchar as varchar49, jsonb as jsonb35, timestamp as timestamp62, index as index58 } from "drizzle-orm/pg-core";
23997
24018
  var webflowIntegrations = pgTable68(
23998
24019
  "webflow_integrations",
23999
24020
  {
@@ -24007,7 +24028,7 @@ var webflowIntegrations = pgTable68(
24007
24028
  // display only; may be absent
24008
24029
  accessToken: text69("access_token").notNull(),
24009
24030
  // encrypted at rest
24010
- scopes: jsonb34("scopes").$type().notNull().default([]),
24031
+ scopes: jsonb35("scopes").$type().notNull().default([]),
24011
24032
  connectedBy: text69("connected_by"),
24012
24033
  // FK → users.id
24013
24034
  createdAt: timestamp62("created_at").notNull().defaultNow(),
@@ -24017,7 +24038,7 @@ var webflowIntegrations = pgTable68(
24017
24038
  );
24018
24039
 
24019
24040
  // src/schema/migration_jobs.ts
24020
- import { pgTable as pgTable69, text as text70, varchar as varchar50, integer as integer29, jsonb as jsonb35, timestamp as timestamp63, index as index59 } from "drizzle-orm/pg-core";
24041
+ import { pgTable as pgTable69, text as text70, varchar as varchar50, integer as integer29, jsonb as jsonb36, timestamp as timestamp63, index as index59 } from "drizzle-orm/pg-core";
24021
24042
  var migrationJobs = pgTable69(
24022
24043
  "migration_jobs",
24023
24044
  {
@@ -24030,11 +24051,11 @@ var migrationJobs = pgTable69(
24030
24051
  // webflow | framer
24031
24052
  framework: varchar50("framework", { length: 16 }).notNull().default("astro"),
24032
24053
  // astro | next
24033
- plan: jsonb35("plan").notNull(),
24054
+ plan: jsonb36("plan").notNull(),
24034
24055
  // MigrationPlan (user-confirmed mapping)
24035
- graph: jsonb35("graph"),
24056
+ graph: jsonb36("graph"),
24036
24057
  // reserved for a future per-phase checkpoint — NOT written today
24037
- report: jsonb35("report"),
24058
+ report: jsonb36("report"),
24038
24059
  // MigrationReport, written once when the job reaches done | failed
24039
24060
  // queued | crawling | binding | seeding | media | repo | done | failed
24040
24061
  status: varchar50("status", { length: 16 }).notNull().default("queued"),
@@ -24054,7 +24075,7 @@ var migrationJobs = pgTable69(
24054
24075
  );
24055
24076
 
24056
24077
  // src/schema/ai_reports.ts
24057
- import { pgTable as pgTable70, text as text71, varchar as varchar51, jsonb as jsonb36, timestamp as timestamp64, index as index60 } from "drizzle-orm/pg-core";
24078
+ import { pgTable as pgTable70, text as text71, varchar as varchar51, jsonb as jsonb37, timestamp as timestamp64, index as index60 } from "drizzle-orm/pg-core";
24058
24079
  var aiReports = pgTable70(
24059
24080
  "ai_reports",
24060
24081
  {
@@ -24063,7 +24084,7 @@ var aiReports = pgTable70(
24063
24084
  workspaceId: text71("workspace_id").notNull(),
24064
24085
  projectId: text71("project_id").notNull(),
24065
24086
  kind: varchar51("kind", { length: 16 }).$type().notNull(),
24066
- findingsJson: jsonb36("findings_json").$type().notNull(),
24087
+ findingsJson: jsonb37("findings_json").$type().notNull(),
24067
24088
  summary: text71("summary").notNull(),
24068
24089
  createdAt: timestamp64("created_at", { withTimezone: true }).notNull().defaultNow()
24069
24090
  },
@@ -24218,7 +24239,7 @@ var siteFiles = pgTable72(
24218
24239
  );
24219
24240
 
24220
24241
  // src/schema/indexnow_submissions.ts
24221
- import { pgTable as pgTable73, text as text74, varchar as varchar54, integer as integer32, jsonb as jsonb37, timestamp as timestamp67, index as index62 } from "drizzle-orm/pg-core";
24242
+ import { pgTable as pgTable73, text as text74, varchar as varchar54, integer as integer32, jsonb as jsonb38, timestamp as timestamp67, index as index62 } from "drizzle-orm/pg-core";
24222
24243
  var INDEXNOW_KINDS = ["auto", "manual", "retry"];
24223
24244
  var INDEXNOW_STATUSES = ["ok", "failed"];
24224
24245
  var indexnowSubmissions = pgTable73(
@@ -24231,7 +24252,7 @@ var indexnowSubmissions = pgTable73(
24231
24252
  // FK → projects.id ON DELETE CASCADE (migration 0234)
24232
24253
  /** The host as submitted, kept verbatim so a 422 stays explainable after a domain move. */
24233
24254
  host: text74("host").notNull(),
24234
- urls: jsonb37("urls").$type().notNull().default([]),
24255
+ urls: jsonb38("urls").$type().notNull().default([]),
24235
24256
  urlCount: integer32("url_count").notNull().default(0),
24236
24257
  status: varchar54("status", { length: 8 }).$type().notNull(),
24237
24258
  /** NULL only when the request never got a response at all (DNS/timeout after 3 attempts). */
@@ -24244,7 +24265,7 @@ var indexnowSubmissions = pgTable73(
24244
24265
  );
24245
24266
 
24246
24267
  // src/schema/brand_kit_versions.ts
24247
- import { pgTable as pgTable74, text as text75, integer as integer33, jsonb as jsonb38, timestamp as timestamp68, primaryKey as primaryKey5, index as index63 } from "drizzle-orm/pg-core";
24268
+ import { pgTable as pgTable74, text as text75, integer as integer33, jsonb as jsonb39, timestamp as timestamp68, primaryKey as primaryKey5, index as index63 } from "drizzle-orm/pg-core";
24248
24269
  var brandKitVersions = pgTable74(
24249
24270
  "brand_kit_versions",
24250
24271
  {
@@ -24255,7 +24276,7 @@ var brandKitVersions = pgTable74(
24255
24276
  projectId: text75("project_id").notNull(),
24256
24277
  // FK → projects.id ON DELETE CASCADE (0239)
24257
24278
  version: integer33("version").notNull(),
24258
- snapshot: jsonb38("snapshot").$type().notNull(),
24279
+ snapshot: jsonb39("snapshot").$type().notNull(),
24259
24280
  createdBy: text75("created_by"),
24260
24281
  // FK → users(id), nullable: a system write has no author
24261
24282
  createdAt: timestamp68("created_at").notNull().defaultNow()
@@ -24331,7 +24352,7 @@ import {
24331
24352
  text as text80,
24332
24353
  varchar as varchar59,
24333
24354
  timestamp as timestamp72,
24334
- jsonb as jsonb40,
24355
+ jsonb as jsonb41,
24335
24356
  integer as integer36,
24336
24357
  foreignKey as foreignKey4,
24337
24358
  index as index67,
@@ -24345,7 +24366,7 @@ import {
24345
24366
  foreignKey as foreignKey2,
24346
24367
  index as index65,
24347
24368
  integer as integer35,
24348
- jsonb as jsonb39,
24369
+ jsonb as jsonb40,
24349
24370
  pgTable as pgTable77,
24350
24371
  text as text78,
24351
24372
  timestamp as timestamp71,
@@ -24361,8 +24382,8 @@ var componentVariantGroups = pgTable77(
24361
24382
  projectId: text78("project_id"),
24362
24383
  name: varchar57("name", { length: 255 }).notNull(),
24363
24384
  slug: varchar57("slug", { length: 255 }).notNull(),
24364
- canonicalInputs: jsonb39("canonical_inputs").$type().notNull().default([]),
24365
- publishedCanonicalInputs: jsonb39("published_canonical_inputs").$type(),
24385
+ canonicalInputs: jsonb40("canonical_inputs").$type().notNull().default([]),
24386
+ publishedCanonicalInputs: jsonb40("published_canonical_inputs").$type(),
24366
24387
  status: varchar57("status", { length: 20 }).notNull().default("draft"),
24367
24388
  publishedAt: timestamp71("published_at"),
24368
24389
  optimisticVersion: integer35("optimistic_version").notNull().default(0),
@@ -24446,15 +24467,15 @@ var components = pgTable79(
24446
24467
  publishedVariantGroupId: text80("published_variant_group_id").references(() => componentVariantGroups.id, {
24447
24468
  onDelete: "restrict"
24448
24469
  }),
24449
- variantInputMappings: jsonb40("variant_input_mappings").$type().notNull().default([]),
24470
+ variantInputMappings: jsonb41("variant_input_mappings").$type().notNull().default([]),
24450
24471
  // The live canonical-input mapping snapshot. Draft mapping edits must never alter
24451
24472
  // already-published Layout output before the Component is explicitly re-published.
24452
- publishedVariantInputMappings: jsonb40("published_variant_input_mappings").$type(),
24473
+ publishedVariantInputMappings: jsonb41("published_variant_input_mappings").$type(),
24453
24474
  // Exact immutable family version adopted by this live variant. Legacy published rows
24454
24475
  // have no manifest pin and use the one-time `publishedCanonicalInputs` snapshot instead.
24455
24476
  publishedFamilyManifestId: text80("published_family_manifest_id"),
24456
24477
  publishedFamilyManifestHash: varchar59("published_family_manifest_hash", { length: 64 }),
24457
- publishedCanonicalInputs: jsonb40("published_canonical_inputs").$type(),
24478
+ publishedCanonicalInputs: jsonb41("published_canonical_inputs").$type(),
24458
24479
  // Placement governance (migration 0190). Existing rows were backfilled to ["*"] so
24459
24480
  // rollout preserves the old everywhere-visible behaviour; new project components start
24460
24481
  // with [] and are deliberately approved from the section picker. Tokens are
@@ -24486,8 +24507,8 @@ var components = pgTable79(
24486
24507
  groupId: text80("group_id").references(() => componentGroups.id, { onDelete: "restrict" }),
24487
24508
  // Stored as unknown[] to keep @bettercms-ai/db decoupled from @bettercms-ai/types,
24488
24509
  // matching pages.block_json. Validated as ContentBlock[] at the API layer.
24489
- blockJson: jsonb40("block_json").$type().notNull().default([]),
24490
- props: jsonb40("props").$type().notNull().default([]),
24510
+ blockJson: jsonb41("block_json").$type().notNull().default([]),
24511
+ props: jsonb41("props").$type().notNull().default([]),
24491
24512
  // Draft/live split (migration 0186_component_draft_live_split.sql). `blockJson`/`props`
24492
24513
  // above are the DRAFT; these two are the LIVE snapshot that get_components_by_handle()
24493
24514
  // serves. Nullable: a never-published component has no live copy. A DB trigger fills them
@@ -24495,8 +24516,8 @@ var components = pgTable79(
24495
24516
  // trigger deliberately skips published -> published, or every autosave would go live).
24496
24517
  // `props` splits alongside `blockJson` because applyOverrides() targets
24497
24518
  // props[].target.blockId/path — a live tree paired with draft prop-defs mis-targets.
24498
- publishedBlockJson: jsonb40("published_block_json").$type(),
24499
- publishedProps: jsonb40("published_props").$type(),
24519
+ publishedBlockJson: jsonb41("published_block_json").$type(),
24520
+ publishedProps: jsonb41("published_props").$type(),
24500
24521
  status: varchar59("status", { length: 20 }).$type().notNull().default("draft"),
24501
24522
  publishedAt: timestamp72("published_at"),
24502
24523
  // Out of the working set, still serving (FLO-1012). Deliberately NOT a third `status`
@@ -24504,6 +24525,10 @@ var components = pgTable79(
24504
24525
  // the draft/published bit that restore has to put back. NULL = active.
24505
24526
  archivedAt: timestamp72("archived_at"),
24506
24527
  thumbnail: varchar59("thumbnail", { length: 2048 }),
24528
+ // A snapshot of the validated Output (0334), stored under component-preview/<projectId>/snapshots/. Never written to `thumbnail`.
24529
+ outputSnapshotKey: text80("output_snapshot_key"),
24530
+ outputSnapshotCommitSha: text80("output_snapshot_commit_sha"),
24531
+ outputSnapshotAt: timestamp72("output_snapshot_at", { withTimezone: true }),
24507
24532
  optimisticVersion: integer36("optimistic_version").notNull().default(0),
24508
24533
  ...writeGovernanceColumns,
24509
24534
  ...branchColumns,
@@ -24564,30 +24589,53 @@ var componentsRelations = relations14(components, ({ one }) => ({
24564
24589
  })
24565
24590
  }));
24566
24591
 
24592
+ // src/schema/content_navigation.ts
24593
+ import { foreignKey as foreignKey5, index as index68, integer as integer37, jsonb as jsonb42, pgTable as pgTable80, text as text81, timestamp as timestamp73 } from "drizzle-orm/pg-core";
24594
+ var contentNavigation = pgTable80(
24595
+ "content_navigation",
24596
+ {
24597
+ projectId: text81("project_id").primaryKey(),
24598
+ workspaceId: text81("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24599
+ doc: jsonb42("doc").$type().notNull().default({ schema: 1, folders: [], items: [] }),
24600
+ version: integer37("version").notNull().default(1),
24601
+ updatedBy: text81("updated_by"),
24602
+ createdAt: timestamp73("created_at").notNull().defaultNow(),
24603
+ updatedAt: timestamp73("updated_at").notNull().defaultNow()
24604
+ },
24605
+ (table) => [
24606
+ foreignKey5({
24607
+ columns: [table.projectId, table.workspaceId],
24608
+ foreignColumns: [projects.id, projects.workspaceId],
24609
+ name: "content_navigation_project_workspace_fkey"
24610
+ }).onDelete("cascade").onUpdate("cascade"),
24611
+ index68("content_navigation_workspace_idx").on(table.workspaceId)
24612
+ ]
24613
+ );
24614
+
24567
24615
  // src/schema/component_variants.ts
24568
24616
  import {
24569
- pgTable as pgTable80,
24570
- text as text81,
24617
+ pgTable as pgTable81,
24618
+ text as text82,
24571
24619
  varchar as varchar60,
24572
- timestamp as timestamp73,
24573
- jsonb as jsonb41,
24574
- integer as integer37,
24575
- index as index68,
24620
+ timestamp as timestamp74,
24621
+ jsonb as jsonb43,
24622
+ integer as integer38,
24623
+ index as index69,
24576
24624
  unique as unique4,
24577
24625
  uniqueIndex as uniqueIndex34
24578
24626
  } from "drizzle-orm/pg-core";
24579
24627
  import { relations as relations15 } from "drizzle-orm/relations";
24580
24628
  import { sql as sql18 } from "drizzle-orm";
24581
- var componentVariants = pgTable80(
24629
+ var componentVariants = pgTable81(
24582
24630
  "component_variants",
24583
24631
  {
24584
- id: text81("id").primaryKey(),
24585
- workspaceId: text81("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24586
- componentId: text81("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24632
+ id: text82("id").primaryKey(),
24633
+ workspaceId: text82("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24634
+ componentId: text82("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24587
24635
  name: varchar60("name", { length: 255 }).notNull(),
24588
24636
  // `<component-root>-<variant-name>`, e.g. `footer-compact`.
24589
24637
  key: varchar60("key", { length: 356 }).notNull(),
24590
- delta: jsonb41("delta").$type().notNull().default({
24638
+ delta: jsonb43("delta").$type().notNull().default({
24591
24639
  fieldOverrides: [],
24592
24640
  addedProps: [],
24593
24641
  removedFieldKeys: [],
@@ -24595,13 +24643,13 @@ var componentVariants = pgTable80(
24595
24643
  valueOverrides: {},
24596
24644
  addedBlocks: []
24597
24645
  }),
24598
- publishedDelta: jsonb41("published_delta").$type(),
24646
+ publishedDelta: jsonb43("published_delta").$type(),
24599
24647
  status: varchar60("status", { length: 20 }).$type().notNull().default("draft"),
24600
- publishedAt: timestamp73("published_at"),
24601
- optimisticVersion: integer37("optimistic_version").notNull().default(0),
24602
- createdAt: timestamp73("created_at").notNull().defaultNow(),
24603
- updatedAt: timestamp73("updated_at").notNull().defaultNow(),
24604
- deletedAt: timestamp73("deleted_at")
24648
+ publishedAt: timestamp74("published_at"),
24649
+ optimisticVersion: integer38("optimistic_version").notNull().default(0),
24650
+ createdAt: timestamp74("created_at").notNull().defaultNow(),
24651
+ updatedAt: timestamp74("updated_at").notNull().defaultNow(),
24652
+ deletedAt: timestamp74("deleted_at")
24605
24653
  },
24606
24654
  (table) => [
24607
24655
  unique4("component_variants_id_workspace_component_unique").on(
@@ -24609,8 +24657,8 @@ var componentVariants = pgTable80(
24609
24657
  table.workspaceId,
24610
24658
  table.componentId
24611
24659
  ),
24612
- index68("component_variants_workspace_idx").on(table.workspaceId),
24613
- index68("component_variants_component_idx").on(table.componentId),
24660
+ index69("component_variants_workspace_idx").on(table.workspaceId),
24661
+ index69("component_variants_component_idx").on(table.componentId),
24614
24662
  uniqueIndex34("component_variants_component_key_unique").on(table.componentId, table.key).where(sql18`${table.deletedAt} IS NULL`)
24615
24663
  ]
24616
24664
  );
@@ -24628,41 +24676,41 @@ var componentVariantsRelations = relations15(componentVariants, ({ one }) => ({
24628
24676
  // src/schema/component_implementation_evidence.ts
24629
24677
  import {
24630
24678
  bigint as bigint4,
24631
- foreignKey as foreignKey5,
24632
- index as index69,
24633
- integer as integer38,
24634
- jsonb as jsonb42,
24635
- pgTable as pgTable81,
24636
- text as text82,
24637
- timestamp as timestamp74,
24679
+ foreignKey as foreignKey6,
24680
+ index as index70,
24681
+ integer as integer39,
24682
+ jsonb as jsonb44,
24683
+ pgTable as pgTable82,
24684
+ text as text83,
24685
+ timestamp as timestamp75,
24638
24686
  unique as unique5,
24639
24687
  uniqueIndex as uniqueIndex35,
24640
24688
  uuid as uuid2,
24641
24689
  varchar as varchar61
24642
24690
  } from "drizzle-orm/pg-core";
24643
24691
  import { sql as sql19 } from "drizzle-orm";
24644
- var componentImplementationCandidates = pgTable81(
24692
+ var componentImplementationCandidates = pgTable82(
24645
24693
  "component_implementation_candidates",
24646
24694
  {
24647
- id: text82("id").primaryKey(),
24648
- workspaceId: text82("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24649
- projectId: text82("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
24650
- componentId: text82("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24651
- variantGroupId: text82("variant_group_id"),
24652
- familyKey: text82("family_key").notNull(),
24695
+ id: text83("id").primaryKey(),
24696
+ workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24697
+ projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
24698
+ componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24699
+ variantGroupId: text83("variant_group_id"),
24700
+ familyKey: text83("family_key").notNull(),
24653
24701
  familyContractHash: varchar61("family_contract_hash", { length: 64 }).notNull(),
24654
24702
  // Exact value-bearing family contract. Unlike `contract.canonicalInputs` (the
24655
24703
  // renderer/schema projection), this snapshot deliberately retains defaults because it
24656
24704
  // becomes the immutable public-input source pinned by each published variant.
24657
- familyContract: jsonb42("family_contract").$type(),
24705
+ familyContract: jsonb44("family_contract").$type(),
24658
24706
  schemaHash: varchar61("schema_hash", { length: 64 }).notNull(),
24659
24707
  brandContractHash: varchar61("brand_contract_hash", { length: 64 }).notNull(),
24660
- contract: jsonb42("contract").$type().notNull(),
24661
- createdBy: text82("created_by"),
24662
- createdAt: timestamp74("created_at").notNull().defaultNow()
24708
+ contract: jsonb44("contract").$type().notNull(),
24709
+ createdBy: text83("created_by"),
24710
+ createdAt: timestamp75("created_at").notNull().defaultNow()
24663
24711
  },
24664
24712
  (table) => [
24665
- foreignKey5({
24713
+ foreignKey6({
24666
24714
  columns: [table.projectId, table.workspaceId],
24667
24715
  foreignColumns: [projects.id, projects.workspaceId],
24668
24716
  name: "component_implementation_candidates_project_workspace_fkey"
@@ -24678,29 +24726,29 @@ var componentImplementationCandidates = pgTable81(
24678
24726
  table.familyContractHash
24679
24727
  ).where(sql19`${table.familyContract} IS NOT NULL`),
24680
24728
  unique5("component_implementation_candidate_scope_unique").on(table.id, table.projectId, table.componentId),
24681
- index69("component_implementation_candidates_component_idx").on(table.projectId, table.componentId)
24729
+ index70("component_implementation_candidates_component_idx").on(table.projectId, table.componentId)
24682
24730
  ]
24683
24731
  );
24684
- var componentFamilyManifests = pgTable81(
24732
+ var componentFamilyManifests = pgTable82(
24685
24733
  "component_family_manifests",
24686
24734
  {
24687
- id: text82("id").primaryKey(),
24688
- workspaceId: text82("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24689
- projectId: text82("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
24690
- familyKey: text82("family_key").notNull(),
24735
+ id: text83("id").primaryKey(),
24736
+ workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24737
+ projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
24738
+ familyKey: text83("family_key").notNull(),
24691
24739
  familyContractHash: varchar61("family_contract_hash", { length: 64 }).notNull(),
24692
- familyContract: jsonb42("family_contract").$type(),
24740
+ familyContract: jsonb44("family_contract").$type(),
24693
24741
  commitSha: varchar61("commit_sha", { length: 64 }).notNull(),
24694
24742
  adapterHash: varchar61("adapter_hash", { length: 64 }).notNull(),
24695
24743
  manifestHash: varchar61("manifest_hash", { length: 64 }).notNull(),
24696
- previewOrigin: text82("preview_origin").notNull(),
24697
- nativeViewports: jsonb42("native_viewports").$type().notNull(),
24698
- adapter: jsonb42("adapter").$type().notNull(),
24699
- createdBy: text82("created_by"),
24700
- createdAt: timestamp74("created_at").notNull().defaultNow()
24744
+ previewOrigin: text83("preview_origin").notNull(),
24745
+ nativeViewports: jsonb44("native_viewports").$type().notNull(),
24746
+ adapter: jsonb44("adapter").$type().notNull(),
24747
+ createdBy: text83("created_by"),
24748
+ createdAt: timestamp75("created_at").notNull().defaultNow()
24701
24749
  },
24702
24750
  (table) => [
24703
- foreignKey5({
24751
+ foreignKey6({
24704
24752
  columns: [table.projectId, table.workspaceId],
24705
24753
  foreignColumns: [projects.id, projects.workspaceId],
24706
24754
  name: "component_family_manifests_project_workspace_fkey"
@@ -24709,21 +24757,21 @@ var componentFamilyManifests = pgTable81(
24709
24757
  unique5("component_family_manifests_id_project_unique").on(table.id, table.projectId),
24710
24758
  unique5("component_family_manifests_evidence_unique").on(table.id, table.projectId, table.manifestHash),
24711
24759
  uniqueIndex35("component_family_manifest_tuple_unique").on(table.projectId, table.familyKey, table.manifestHash),
24712
- index69("component_family_manifests_family_idx").on(table.projectId, table.familyKey, table.createdAt)
24760
+ index70("component_family_manifests_family_idx").on(table.projectId, table.familyKey, table.createdAt)
24713
24761
  ]
24714
24762
  );
24715
- var componentImplementationRequests = pgTable81(
24763
+ var componentImplementationRequests = pgTable82(
24716
24764
  "component_implementation_requests",
24717
24765
  {
24718
- id: text82("id").primaryKey(),
24719
- workspaceId: text82("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24720
- projectId: text82("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
24721
- componentId: text82("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24722
- candidateId: text82("candidate_id").notNull(),
24723
- componentVersion: integer38("component_version").notNull(),
24766
+ id: text83("id").primaryKey(),
24767
+ workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24768
+ projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
24769
+ componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24770
+ candidateId: text83("candidate_id").notNull(),
24771
+ componentVersion: integer39("component_version").notNull(),
24724
24772
  provider: varchar61("provider", { length: 20 }).$type().notNull(),
24725
24773
  status: varchar61("status", { length: 20 }).$type().notNull(),
24726
- familyKey: text82("family_key").notNull(),
24774
+ familyKey: text83("family_key").notNull(),
24727
24775
  familyContractHash: varchar61("family_contract_hash", { length: 64 }).notNull(),
24728
24776
  schemaHash: varchar61("schema_hash", { length: 64 }).notNull(),
24729
24777
  brandContractHash: varchar61("brand_contract_hash", { length: 64 }).notNull(),
@@ -24731,86 +24779,86 @@ var componentImplementationRequests = pgTable81(
24731
24779
  commitSha: varchar61("commit_sha", { length: 64 }),
24732
24780
  adapterHash: varchar61("adapter_hash", { length: 64 }),
24733
24781
  familyManifestHash: varchar61("family_manifest_hash", { length: 64 }),
24734
- previewOrigin: text82("preview_origin"),
24735
- nativeViewports: jsonb42("native_viewports").$type(),
24736
- adapter: jsonb42("adapter").$type(),
24737
- providerProvenance: jsonb42("provider_provenance").$type(),
24738
- claimedByApiKeyId: text82("claimed_by_api_key_id"),
24782
+ previewOrigin: text83("preview_origin"),
24783
+ nativeViewports: jsonb44("native_viewports").$type(),
24784
+ adapter: jsonb44("adapter").$type(),
24785
+ providerProvenance: jsonb44("provider_provenance").$type(),
24786
+ claimedByApiKeyId: text83("claimed_by_api_key_id"),
24739
24787
  claimCredentialHash: varchar61("claim_credential_hash", { length: 64 }),
24740
- claimCredentialExpiresAt: timestamp74("claim_credential_expires_at", { withTimezone: true }),
24741
- claimCredentialConsumedAt: timestamp74("claim_credential_consumed_at", { withTimezone: true }),
24788
+ claimCredentialExpiresAt: timestamp75("claim_credential_expires_at", { withTimezone: true }),
24789
+ claimCredentialConsumedAt: timestamp75("claim_credential_consumed_at", { withTimezone: true }),
24742
24790
  completionHash: varchar61("completion_hash", { length: 64 }),
24743
- evidenceId: text82("evidence_id"),
24744
- errorCode: text82("error_code"),
24745
- errorMessage: text82("error_message"),
24746
- requestedBy: text82("requested_by"),
24747
- createdAt: timestamp74("created_at", { withTimezone: true }).notNull().defaultNow(),
24748
- expiresAt: timestamp74("expires_at", { withTimezone: true }).notNull(),
24749
- claimedAt: timestamp74("claimed_at", { withTimezone: true }),
24750
- completedAt: timestamp74("completed_at", { withTimezone: true }),
24751
- failedAt: timestamp74("failed_at", { withTimezone: true }),
24752
- updatedAt: timestamp74("updated_at", { withTimezone: true }).notNull().defaultNow()
24791
+ evidenceId: text83("evidence_id"),
24792
+ errorCode: text83("error_code"),
24793
+ errorMessage: text83("error_message"),
24794
+ requestedBy: text83("requested_by"),
24795
+ createdAt: timestamp75("created_at", { withTimezone: true }).notNull().defaultNow(),
24796
+ expiresAt: timestamp75("expires_at", { withTimezone: true }).notNull(),
24797
+ claimedAt: timestamp75("claimed_at", { withTimezone: true }),
24798
+ completedAt: timestamp75("completed_at", { withTimezone: true }),
24799
+ failedAt: timestamp75("failed_at", { withTimezone: true }),
24800
+ updatedAt: timestamp75("updated_at", { withTimezone: true }).notNull().defaultNow()
24753
24801
  },
24754
24802
  (table) => [
24755
- foreignKey5({
24803
+ foreignKey6({
24756
24804
  columns: [table.projectId, table.workspaceId],
24757
24805
  foreignColumns: [projects.id, projects.workspaceId],
24758
24806
  name: "component_implementation_requests_project_workspace_fkey"
24759
24807
  }).onDelete("cascade"),
24760
- foreignKey5({
24808
+ foreignKey6({
24761
24809
  columns: [table.candidateId, table.projectId, table.componentId],
24762
24810
  foreignColumns: [componentImplementationCandidates.id, componentImplementationCandidates.projectId, componentImplementationCandidates.componentId],
24763
24811
  name: "component_implementation_requests_candidate_fkey"
24764
24812
  }).onDelete("cascade"),
24765
24813
  unique5("component_implementation_requests_scope_unique").on(table.id, table.projectId, table.componentId),
24766
24814
  uniqueIndex35("component_implementation_requests_active_unique").on(table.projectId, table.componentId).where(sql19`${table.status} IN ('pending', 'claimed')`),
24767
- index69("component_implementation_requests_claimable_idx").on(table.projectId, table.status, table.expiresAt, table.createdAt)
24815
+ index70("component_implementation_requests_claimable_idx").on(table.projectId, table.status, table.expiresAt, table.createdAt)
24768
24816
  ]
24769
24817
  );
24770
- var componentImplementationEvidence = pgTable81(
24818
+ var componentImplementationEvidence = pgTable82(
24771
24819
  "component_implementation_evidence",
24772
24820
  {
24773
- id: text82("id").primaryKey(),
24774
- workspaceId: text82("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24775
- projectId: text82("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
24776
- componentId: text82("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24777
- candidateId: text82("candidate_id").notNull(),
24778
- familyManifestId: text82("family_manifest_id").notNull(),
24821
+ id: text83("id").primaryKey(),
24822
+ workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24823
+ projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
24824
+ componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24825
+ candidateId: text83("candidate_id").notNull(),
24826
+ familyManifestId: text83("family_manifest_id").notNull(),
24779
24827
  familyManifestHash: varchar61("family_manifest_hash", { length: 64 }).notNull(),
24780
24828
  variantBindingHash: varchar61("variant_binding_hash", { length: 64 }).notNull(),
24781
- variantBinding: jsonb42("variant_binding").$type().notNull(),
24782
- requestId: text82("request_id"),
24829
+ variantBinding: jsonb44("variant_binding").$type().notNull(),
24830
+ requestId: text83("request_id"),
24783
24831
  schemaHash: varchar61("schema_hash", { length: 64 }).notNull(),
24784
24832
  brandContractHash: varchar61("brand_contract_hash", { length: 64 }).notNull(),
24785
24833
  commitSha: varchar61("commit_sha", { length: 64 }).notNull(),
24786
24834
  adapterHash: varchar61("adapter_hash", { length: 64 }).notNull(),
24787
- previewOrigin: text82("preview_origin").notNull(),
24788
- nativeViewports: jsonb42("native_viewports").$type().notNull(),
24789
- adapter: jsonb42("adapter").$type().notNull(),
24835
+ previewOrigin: text83("preview_origin").notNull(),
24836
+ nativeViewports: jsonb44("native_viewports").$type().notNull(),
24837
+ adapter: jsonb44("adapter").$type().notNull(),
24790
24838
  status: varchar61("status", { length: 20 }).$type().notNull(),
24791
- checks: jsonb42("checks").$type().notNull(),
24839
+ checks: jsonb44("checks").$type().notNull(),
24792
24840
  evidenceDigest: varchar61("evidence_digest", { length: 128 }).notNull(),
24793
24841
  evidenceTupleHash: varchar61("evidence_tuple_hash", { length: 64 }).notNull(),
24794
- createdBy: text82("created_by"),
24795
- createdAt: timestamp74("created_at").notNull().defaultNow()
24842
+ createdBy: text83("created_by"),
24843
+ createdAt: timestamp75("created_at").notNull().defaultNow()
24796
24844
  },
24797
24845
  (table) => [
24798
- foreignKey5({
24846
+ foreignKey6({
24799
24847
  columns: [table.projectId, table.workspaceId],
24800
24848
  foreignColumns: [projects.id, projects.workspaceId],
24801
24849
  name: "component_implementation_evidence_project_workspace_fkey"
24802
24850
  }).onDelete("cascade"),
24803
- foreignKey5({
24851
+ foreignKey6({
24804
24852
  columns: [table.familyManifestId, table.projectId, table.familyManifestHash],
24805
24853
  foreignColumns: [componentFamilyManifests.id, componentFamilyManifests.projectId, componentFamilyManifests.manifestHash],
24806
24854
  name: "component_implementation_evidence_manifest_fkey"
24807
24855
  }).onDelete("restrict"),
24808
- foreignKey5({
24856
+ foreignKey6({
24809
24857
  columns: [table.candidateId, table.projectId, table.componentId],
24810
24858
  foreignColumns: [componentImplementationCandidates.id, componentImplementationCandidates.projectId, componentImplementationCandidates.componentId],
24811
24859
  name: "component_implementation_evidence_candidate_fkey"
24812
24860
  }).onDelete("cascade"),
24813
- foreignKey5({
24861
+ foreignKey6({
24814
24862
  columns: [table.requestId, table.projectId, table.componentId],
24815
24863
  foreignColumns: [componentImplementationRequests.id, componentImplementationRequests.projectId, componentImplementationRequests.componentId],
24816
24864
  name: "component_implementation_evidence_request_fkey"
@@ -24818,43 +24866,43 @@ var componentImplementationEvidence = pgTable81(
24818
24866
  uniqueIndex35("component_implementation_evidence_digest_unique").on(table.projectId, table.componentId, table.evidenceDigest),
24819
24867
  uniqueIndex35("component_implementation_evidence_request_unique").on(table.requestId).where(sql19`${table.requestId} IS NOT NULL`),
24820
24868
  unique5("component_implementation_evidence_scope_unique").on(table.id, table.projectId, table.componentId),
24821
- index69("component_implementation_evidence_candidate_idx").on(table.candidateId, table.createdAt)
24869
+ index70("component_implementation_evidence_candidate_idx").on(table.candidateId, table.createdAt)
24822
24870
  ]
24823
24871
  );
24824
- var componentImplementationApprovals = pgTable81(
24872
+ var componentImplementationApprovals = pgTable82(
24825
24873
  "component_implementation_approvals",
24826
24874
  {
24827
- id: text82("id").primaryKey(),
24828
- workspaceId: text82("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24829
- projectId: text82("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
24830
- componentId: text82("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24831
- candidateId: text82("candidate_id").notNull(),
24832
- evidenceId: text82("evidence_id").notNull(),
24833
- approvedBy: text82("approved_by").notNull(),
24834
- approvedAt: timestamp74("approved_at").notNull().defaultNow()
24875
+ id: text83("id").primaryKey(),
24876
+ workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24877
+ projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
24878
+ componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24879
+ candidateId: text83("candidate_id").notNull(),
24880
+ evidenceId: text83("evidence_id").notNull(),
24881
+ approvedBy: text83("approved_by").notNull(),
24882
+ approvedAt: timestamp75("approved_at").notNull().defaultNow()
24835
24883
  },
24836
24884
  (table) => [
24837
- foreignKey5({
24885
+ foreignKey6({
24838
24886
  columns: [table.projectId, table.workspaceId],
24839
24887
  foreignColumns: [projects.id, projects.workspaceId],
24840
24888
  name: "component_implementation_approvals_project_workspace_fkey"
24841
24889
  }).onDelete("cascade"),
24842
- foreignKey5({
24890
+ foreignKey6({
24843
24891
  columns: [table.candidateId, table.projectId, table.componentId],
24844
24892
  foreignColumns: [componentImplementationCandidates.id, componentImplementationCandidates.projectId, componentImplementationCandidates.componentId],
24845
24893
  name: "component_implementation_approvals_candidate_fkey"
24846
24894
  }).onDelete("cascade"),
24847
- foreignKey5({
24895
+ foreignKey6({
24848
24896
  columns: [table.evidenceId, table.projectId, table.componentId],
24849
24897
  foreignColumns: [componentImplementationEvidence.id, componentImplementationEvidence.projectId, componentImplementationEvidence.componentId],
24850
24898
  name: "component_implementation_approvals_evidence_fkey"
24851
24899
  }).onDelete("cascade"),
24852
24900
  uniqueIndex35("component_implementation_approval_evidence_unique").on(table.evidenceId),
24853
24901
  unique5("component_implementation_approval_scope_unique").on(table.id, table.projectId, table.componentId),
24854
- index69("component_implementation_approvals_component_idx").on(table.projectId, table.componentId)
24902
+ index70("component_implementation_approvals_component_idx").on(table.projectId, table.componentId)
24855
24903
  ]
24856
24904
  );
24857
- var componentImplementationAdapters = pgTable81(
24905
+ var componentImplementationAdapters = pgTable82(
24858
24906
  "component_implementation_adapters",
24859
24907
  {
24860
24908
  // uuid generated BY THE DATABASE, unlike this file's older `text` ids with app-side prefixes.
@@ -24862,112 +24910,112 @@ var componentImplementationAdapters = pgTable81(
24862
24910
  // (project_id, component_id), which is unique — so there is nothing for a readable prefix to
24863
24911
  // help with, and one fewer identifier for a writer to have to mint correctly.
24864
24912
  id: uuid2("id").primaryKey().defaultRandom(),
24865
- workspaceId: text82("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24866
- projectId: text82("project_id").notNull(),
24867
- componentId: text82("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24868
- adapter: jsonb42("adapter").$type().notNull(),
24913
+ workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24914
+ projectId: text83("project_id").notNull(),
24915
+ componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24916
+ adapter: jsonb44("adapter").$type().notNull(),
24869
24917
  adapterHash: varchar61("adapter_hash", { length: 64 }).notNull(),
24870
24918
  source: varchar61("source", { length: 24 }).$type().notNull(),
24871
- declaredBy: text82("declared_by"),
24872
- declaredAt: timestamp74("declared_at", { withTimezone: true }).notNull().defaultNow(),
24873
- updatedAt: timestamp74("updated_at", { withTimezone: true }).notNull().defaultNow()
24919
+ declaredBy: text83("declared_by"),
24920
+ declaredAt: timestamp75("declared_at", { withTimezone: true }).notNull().defaultNow(),
24921
+ updatedAt: timestamp75("updated_at", { withTimezone: true }).notNull().defaultNow()
24874
24922
  },
24875
24923
  (table) => [
24876
- foreignKey5({
24924
+ foreignKey6({
24877
24925
  columns: [table.projectId, table.workspaceId],
24878
24926
  foreignColumns: [projects.id, projects.workspaceId],
24879
24927
  name: "component_implementation_adapters_scope_fkey"
24880
24928
  }).onDelete("cascade"),
24881
24929
  unique5("component_implementation_adapters_component_unique").on(table.projectId, table.componentId),
24882
- index69("component_implementation_adapters_project_idx").on(table.projectId, table.componentId)
24930
+ index70("component_implementation_adapters_project_idx").on(table.projectId, table.componentId)
24883
24931
  ]
24884
24932
  );
24885
- var componentImplementationStates = pgTable81(
24933
+ var componentImplementationStates = pgTable82(
24886
24934
  "component_implementation_states",
24887
24935
  {
24888
- id: text82("id").primaryKey(),
24889
- workspaceId: text82("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24890
- projectId: text82("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
24891
- componentId: text82("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24892
- selectedCandidateId: text82("selected_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
24893
- selectedEvidenceId: text82("selected_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
24894
- selectedApprovalId: text82("selected_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
24895
- publishedCandidateId: text82("published_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
24896
- publishedEvidenceId: text82("published_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
24897
- publishedApprovalId: text82("published_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
24898
- requestId: text82("request_id"),
24936
+ id: text83("id").primaryKey(),
24937
+ workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24938
+ projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
24939
+ componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24940
+ selectedCandidateId: text83("selected_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
24941
+ selectedEvidenceId: text83("selected_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
24942
+ selectedApprovalId: text83("selected_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
24943
+ publishedCandidateId: text83("published_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
24944
+ publishedEvidenceId: text83("published_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
24945
+ publishedApprovalId: text83("published_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
24946
+ requestId: text83("request_id"),
24899
24947
  requestProvider: varchar61("request_provider", { length: 20 }).$type(),
24900
24948
  requestStatus: varchar61("request_status", { length: 20 }).$type().notNull().default("not-requested"),
24901
- requestErrorCode: text82("request_error_code"),
24902
- requestErrorMessage: text82("request_error_message"),
24903
- requestedBy: text82("requested_by"),
24904
- requestedAt: timestamp74("requested_at"),
24905
- updatedAt: timestamp74("updated_at").notNull().defaultNow()
24949
+ requestErrorCode: text83("request_error_code"),
24950
+ requestErrorMessage: text83("request_error_message"),
24951
+ requestedBy: text83("requested_by"),
24952
+ requestedAt: timestamp75("requested_at"),
24953
+ updatedAt: timestamp75("updated_at").notNull().defaultNow()
24906
24954
  },
24907
24955
  (table) => [
24908
- foreignKey5({
24956
+ foreignKey6({
24909
24957
  columns: [table.projectId, table.workspaceId],
24910
24958
  foreignColumns: [projects.id, projects.workspaceId],
24911
24959
  name: "component_implementation_states_project_workspace_fkey"
24912
24960
  }).onDelete("cascade"),
24913
24961
  uniqueIndex35("component_implementation_states_component_unique").on(table.projectId, table.componentId),
24914
- index69("component_implementation_states_workspace_idx").on(table.workspaceId)
24962
+ index70("component_implementation_states_workspace_idx").on(table.workspaceId)
24915
24963
  ]
24916
24964
  );
24917
- var componentPreviewSources = pgTable81(
24965
+ var componentPreviewSources = pgTable82(
24918
24966
  "component_preview_sources",
24919
24967
  {
24920
24968
  id: uuid2("id").primaryKey().defaultRandom(),
24921
- workspaceId: text82("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24922
- projectId: text82("project_id").notNull(),
24923
- componentId: text82("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24924
- sourcePath: text82("source_path").notNull(),
24969
+ workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24970
+ projectId: text83("project_id").notNull(),
24971
+ componentId: text83("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
24972
+ sourcePath: text83("source_path").notNull(),
24925
24973
  sourceExport: varchar61("source_export", { length: 128 }).notNull().default("default"),
24926
24974
  /** `file`: props are the component's fields. `section`: codemod-extracted, props `{ blockId, bind, overrides, page }` (0321). */
24927
24975
  sourceKind: varchar61("source_kind", { length: 16 }).$type().notNull().default("file"),
24928
24976
  recordedBy: varchar61("recorded_by", { length: 24 }).$type().notNull().default("agent"),
24929
- updatedBy: text82("updated_by"),
24930
- createdAt: timestamp74("created_at", { withTimezone: true }).notNull().defaultNow(),
24931
- updatedAt: timestamp74("updated_at", { withTimezone: true }).notNull().defaultNow()
24977
+ updatedBy: text83("updated_by"),
24978
+ createdAt: timestamp75("created_at", { withTimezone: true }).notNull().defaultNow(),
24979
+ updatedAt: timestamp75("updated_at", { withTimezone: true }).notNull().defaultNow()
24932
24980
  },
24933
24981
  (table) => [
24934
- foreignKey5({
24982
+ foreignKey6({
24935
24983
  columns: [table.projectId, table.workspaceId],
24936
24984
  foreignColumns: [projects.id, projects.workspaceId],
24937
24985
  name: "component_preview_sources_scope_fkey"
24938
24986
  }).onDelete("cascade"),
24939
24987
  unique5("component_preview_sources_component_unique").on(table.projectId, table.componentId),
24940
- index69("component_preview_sources_project_idx").on(table.projectId)
24988
+ index70("component_preview_sources_project_idx").on(table.projectId)
24941
24989
  ]
24942
24990
  );
24943
- var componentPreviewBundles = pgTable81(
24991
+ var componentPreviewBundles = pgTable82(
24944
24992
  "component_preview_bundles",
24945
24993
  {
24946
24994
  id: uuid2("id").primaryKey().defaultRandom(),
24947
- workspaceId: text82("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24948
- projectId: text82("project_id").notNull(),
24995
+ workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
24996
+ projectId: text83("project_id").notNull(),
24949
24997
  commitSha: varchar61("commit_sha", { length: 64 }).notNull(),
24950
- artifactKey: text82("artifact_key").notNull(),
24998
+ artifactKey: text83("artifact_key").notNull(),
24951
24999
  checksum: varchar61("checksum", { length: 80 }).notNull(),
24952
25000
  sizeBytes: bigint4("size_bytes", { mode: "number" }).notNull(),
24953
- createdAt: timestamp74("created_at", { withTimezone: true }).notNull().defaultNow(),
25001
+ createdAt: timestamp75("created_at", { withTimezone: true }).notNull().defaultNow(),
24954
25002
  /** The preview-runtime version that built this bundle (0330); null from a runner before 0.5.0. */
24955
- runtimeVersion: text82("runtime_version"),
25003
+ runtimeVersion: text83("runtime_version"),
24956
25004
  /** The latest runtime refresh of this commit: rebuilt with a newer runner without re-validating (0330). */
24957
25005
  refreshId: uuid2("refresh_id"),
24958
- refreshStatus: text82("refresh_status"),
24959
- refreshErrorCode: text82("refresh_error_code"),
24960
- refreshErrorMessage: text82("refresh_error_message"),
24961
- refreshDispatchedAt: timestamp74("refresh_dispatched_at", { withTimezone: true })
25006
+ refreshStatus: text83("refresh_status"),
25007
+ refreshErrorCode: text83("refresh_error_code"),
25008
+ refreshErrorMessage: text83("refresh_error_message"),
25009
+ refreshDispatchedAt: timestamp75("refresh_dispatched_at", { withTimezone: true })
24962
25010
  },
24963
25011
  (table) => [
24964
- foreignKey5({
25012
+ foreignKey6({
24965
25013
  columns: [table.projectId, table.workspaceId],
24966
25014
  foreignColumns: [projects.id, projects.workspaceId],
24967
25015
  name: "component_preview_bundles_scope_fkey"
24968
25016
  }).onDelete("cascade"),
24969
25017
  unique5("component_preview_bundles_commit_unique").on(table.projectId, table.commitSha),
24970
- index69("component_preview_bundles_project_idx").on(table.projectId, table.createdAt)
25018
+ index70("component_preview_bundles_project_idx").on(table.projectId, table.createdAt)
24971
25019
  ]
24972
25020
  );
24973
25021
 
@@ -24975,14 +25023,14 @@ var componentPreviewBundles = pgTable81(
24975
25023
  import { sql as sql20 } from "drizzle-orm";
24976
25024
  import {
24977
25025
  check as check4,
24978
- foreignKey as foreignKey6,
24979
- index as index70,
24980
- integer as integer39,
24981
- jsonb as jsonb43,
24982
- pgTable as pgTable82,
25026
+ foreignKey as foreignKey7,
25027
+ index as index71,
25028
+ integer as integer40,
25029
+ jsonb as jsonb45,
25030
+ pgTable as pgTable83,
24983
25031
  primaryKey as primaryKey6,
24984
- text as text83,
24985
- timestamp as timestamp75,
25032
+ text as text84,
25033
+ timestamp as timestamp76,
24986
25034
  unique as unique6,
24987
25035
  uniqueIndex as uniqueIndex36,
24988
25036
  uuid as uuid3,
@@ -24996,62 +25044,62 @@ var ORCHESTRATION_RUN_STATUSES = [
24996
25044
  "completed",
24997
25045
  "abandoned"
24998
25046
  ];
24999
- var projectOrchestrationStates = pgTable82(
25047
+ var projectOrchestrationStates = pgTable83(
25000
25048
  "project_orchestration_states",
25001
25049
  {
25002
- projectId: text83("project_id").primaryKey().references(() => projects.id, { onDelete: "cascade" }),
25003
- workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25004
- generation: integer39("generation").notNull().default(2),
25005
- enabledBy: text83("enabled_by").notNull(),
25006
- enabledAt: timestamp75("enabled_at", { withTimezone: true }).notNull().defaultNow(),
25007
- updatedAt: timestamp75("updated_at", { withTimezone: true }).notNull().defaultNow()
25050
+ projectId: text84("project_id").primaryKey().references(() => projects.id, { onDelete: "cascade" }),
25051
+ workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25052
+ generation: integer40("generation").notNull().default(2),
25053
+ enabledBy: text84("enabled_by").notNull(),
25054
+ enabledAt: timestamp76("enabled_at", { withTimezone: true }).notNull().defaultNow(),
25055
+ updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
25008
25056
  },
25009
25057
  (table) => [
25010
- foreignKey6({
25058
+ foreignKey7({
25011
25059
  columns: [table.projectId, table.workspaceId],
25012
25060
  foreignColumns: [projects.id, projects.workspaceId],
25013
25061
  name: "project_orchestration_states_project_workspace_fkey"
25014
25062
  }).onDelete("cascade"),
25015
25063
  unique6("project_orchestration_states_scope_unique").on(table.projectId, table.workspaceId),
25016
25064
  check4("project_orchestration_states_generation_check", sql20`${table.generation} >= 2`),
25017
- index70("project_orchestration_states_workspace_idx").on(table.workspaceId)
25065
+ index71("project_orchestration_states_workspace_idx").on(table.workspaceId)
25018
25066
  ]
25019
25067
  );
25020
- var orchestrationRuns = pgTable82(
25068
+ var orchestrationRuns = pgTable83(
25021
25069
  "orchestration_runs",
25022
25070
  {
25023
25071
  id: uuid3("id").primaryKey().defaultRandom(),
25024
- workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25025
- projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25026
- projectGeneration: integer39("project_generation").notNull(),
25027
- startIdempotencyKey: text83("start_idempotency_key").notNull(),
25072
+ workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25073
+ projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25074
+ projectGeneration: integer40("project_generation").notNull(),
25075
+ startIdempotencyKey: text84("start_idempotency_key").notNull(),
25028
25076
  targetKind: varchar62("target_kind", { length: 32 }).$type().notNull().default("component-variant"),
25029
- targetId: text83("target_id").notNull().references(() => components.id, { onDelete: "no action" }),
25030
- targetVariantId: text83("target_variant_id"),
25031
- targetMetadata: jsonb43("target_metadata").$type().notNull(),
25077
+ targetId: text84("target_id").notNull().references(() => components.id, { onDelete: "no action" }),
25078
+ targetVariantId: text84("target_variant_id"),
25079
+ targetMetadata: jsonb45("target_metadata").$type().notNull(),
25032
25080
  status: varchar62("status", { length: 20 }).$type().notNull().default("open"),
25033
25081
  activeStage: varchar62("active_stage", { length: 64 }).notNull().default("awaiting-executor"),
25034
- version: integer39("version").notNull().default(1),
25035
- preferredExecutorId: text83("preferred_executor_id"),
25036
- cancellationRequestedAt: timestamp75("cancellation_requested_at", { withTimezone: true }),
25037
- cancellationRequestedBy: text83("cancellation_requested_by"),
25038
- createdBy: text83("created_by").notNull(),
25082
+ version: integer40("version").notNull().default(1),
25083
+ preferredExecutorId: text84("preferred_executor_id"),
25084
+ cancellationRequestedAt: timestamp76("cancellation_requested_at", { withTimezone: true }),
25085
+ cancellationRequestedBy: text84("cancellation_requested_by"),
25086
+ createdBy: text84("created_by").notNull(),
25039
25087
  policyVersion: varchar62("policy_version", { length: 64 }).notNull().default("orchestration-v2"),
25040
- createdAt: timestamp75("created_at", { withTimezone: true }).notNull().defaultNow(),
25041
- updatedAt: timestamp75("updated_at", { withTimezone: true }).notNull().defaultNow()
25088
+ createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow(),
25089
+ updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
25042
25090
  },
25043
25091
  (table) => [
25044
- foreignKey6({
25092
+ foreignKey7({
25045
25093
  columns: [table.projectId, table.workspaceId],
25046
25094
  foreignColumns: [projects.id, projects.workspaceId],
25047
25095
  name: "orchestration_runs_project_workspace_fkey"
25048
25096
  }).onDelete("cascade"),
25049
- foreignKey6({
25097
+ foreignKey7({
25050
25098
  columns: [table.targetVariantId, table.workspaceId, table.targetId],
25051
25099
  foreignColumns: [componentVariants.id, componentVariants.workspaceId, componentVariants.componentId],
25052
25100
  name: "orchestration_runs_target_variant_scope_fkey"
25053
25101
  }).onDelete("no action"),
25054
- foreignKey6({
25102
+ foreignKey7({
25055
25103
  columns: [table.projectId, table.workspaceId],
25056
25104
  foreignColumns: [projectOrchestrationStates.projectId, projectOrchestrationStates.workspaceId],
25057
25105
  name: "orchestration_runs_project_state_fkey"
@@ -25062,14 +25110,14 @@ var orchestrationRuns = pgTable82(
25062
25110
  table.startIdempotencyKey
25063
25111
  ),
25064
25112
  uniqueIndex36("orchestration_runs_nonterminal_project_unique").on(table.projectId).where(sql20`${table.status} IN ('open', 'paused', 'cancelling')`),
25065
- index70("orchestration_runs_project_target_idx").on(
25113
+ index71("orchestration_runs_project_target_idx").on(
25066
25114
  table.projectId,
25067
25115
  table.targetKind,
25068
25116
  table.targetId,
25069
25117
  table.targetVariantId,
25070
25118
  table.createdAt
25071
25119
  ),
25072
- index70("orchestration_runs_workspace_status_idx").on(
25120
+ index71("orchestration_runs_workspace_status_idx").on(
25073
25121
  table.workspaceId,
25074
25122
  table.status,
25075
25123
  table.updatedAt
@@ -25156,59 +25204,59 @@ var orchestrationRuns = pgTable82(
25156
25204
  check4("orchestration_runs_timestamps_check", sql20`${table.updatedAt} >= ${table.createdAt}`)
25157
25205
  ]
25158
25206
  );
25159
- var orchestrationRunStartKeys = pgTable82(
25207
+ var orchestrationRunStartKeys = pgTable83(
25160
25208
  "orchestration_run_start_keys",
25161
25209
  {
25162
- workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25163
- projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25164
- idempotencyKey: text83("idempotency_key").notNull(),
25210
+ workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25211
+ projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25212
+ idempotencyKey: text84("idempotency_key").notNull(),
25165
25213
  runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
25166
- createdAt: timestamp75("created_at", { withTimezone: true }).notNull().defaultNow()
25214
+ createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow()
25167
25215
  },
25168
25216
  (table) => [
25169
25217
  primaryKey6({ columns: [table.projectId, table.idempotencyKey] }),
25170
- foreignKey6({
25218
+ foreignKey7({
25171
25219
  columns: [table.runId, table.workspaceId, table.projectId],
25172
25220
  foreignColumns: [orchestrationRuns.id, orchestrationRuns.workspaceId, orchestrationRuns.projectId],
25173
25221
  name: "orchestration_run_start_keys_run_scope_fkey"
25174
25222
  }).onDelete("cascade"),
25175
- index70("orchestration_run_start_keys_run_created_idx").on(table.runId, table.createdAt),
25223
+ index71("orchestration_run_start_keys_run_created_idx").on(table.runId, table.createdAt),
25176
25224
  check4(
25177
25225
  "orchestration_run_start_keys_idempotency_key_check",
25178
25226
  sql20`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
25179
25227
  )
25180
25228
  ]
25181
25229
  );
25182
- var orchestrationRunEvents = pgTable82(
25230
+ var orchestrationRunEvents = pgTable83(
25183
25231
  "orchestration_run_events",
25184
25232
  {
25185
25233
  id: uuid3("id").primaryKey().defaultRandom(),
25186
25234
  runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
25187
- workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25188
- projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25189
- sequence: integer39("sequence").notNull(),
25190
- schemaVersion: integer39("schema_version").notNull().default(1),
25191
- idempotencyKey: text83("idempotency_key").notNull(),
25235
+ workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25236
+ projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25237
+ sequence: integer40("sequence").notNull(),
25238
+ schemaVersion: integer40("schema_version").notNull().default(1),
25239
+ idempotencyKey: text84("idempotency_key").notNull(),
25192
25240
  type: varchar62("type", { length: 100 }).notNull(),
25193
25241
  actorType: varchar62("actor_type", { length: 32 }).notNull(),
25194
- actorId: text83("actor_id").notNull(),
25195
- causationId: text83("causation_id"),
25196
- correlationId: text83("correlation_id"),
25197
- payload: jsonb43("payload").$type().notNull().default({}),
25242
+ actorId: text84("actor_id").notNull(),
25243
+ causationId: text84("causation_id"),
25244
+ correlationId: text84("correlation_id"),
25245
+ payload: jsonb45("payload").$type().notNull().default({}),
25198
25246
  payloadDigest: varchar62("payload_digest", { length: 71 }).generatedAlwaysAs(
25199
25247
  sql20`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
25200
25248
  ),
25201
- createdAt: timestamp75("created_at", { withTimezone: true }).notNull().defaultNow()
25249
+ createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow()
25202
25250
  },
25203
25251
  (table) => [
25204
- foreignKey6({
25252
+ foreignKey7({
25205
25253
  columns: [table.runId, table.workspaceId, table.projectId],
25206
25254
  foreignColumns: [orchestrationRuns.id, orchestrationRuns.workspaceId, orchestrationRuns.projectId],
25207
25255
  name: "orchestration_run_events_run_scope_fkey"
25208
25256
  }).onDelete("cascade"),
25209
25257
  unique6("orchestration_run_events_sequence_unique").on(table.runId, table.sequence),
25210
25258
  unique6("orchestration_run_events_idempotency_unique").on(table.runId, table.idempotencyKey),
25211
- index70("orchestration_run_events_project_created_idx").on(table.projectId, table.createdAt),
25259
+ index71("orchestration_run_events_project_created_idx").on(table.projectId, table.createdAt),
25212
25260
  check4("orchestration_run_events_sequence_check", sql20`${table.sequence} >= 1`),
25213
25261
  check4("orchestration_run_events_schema_version_check", sql20`${table.schemaVersion} >= 1`),
25214
25262
  check4(
@@ -25224,29 +25272,29 @@ var orchestrationRunEvents = pgTable82(
25224
25272
  )
25225
25273
  ]
25226
25274
  );
25227
- var orchestrationRunCommandResults = pgTable82(
25275
+ var orchestrationRunCommandResults = pgTable83(
25228
25276
  "orchestration_run_command_results",
25229
25277
  {
25230
25278
  commandId: uuid3("command_id").primaryKey(),
25231
- workspaceId: text83("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25232
- projectId: text83("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25279
+ workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25280
+ projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25233
25281
  runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
25234
25282
  command: varchar62("command", { length: 20 }).$type().notNull(),
25235
- expectedVersion: integer39("expected_version").notNull(),
25236
- resultingVersion: integer39("resulting_version").notNull(),
25237
- actorId: text83("actor_id").notNull(),
25283
+ expectedVersion: integer40("expected_version").notNull(),
25284
+ resultingVersion: integer40("resulting_version").notNull(),
25285
+ actorId: text84("actor_id").notNull(),
25238
25286
  eventId: uuid3("event_id").notNull().references(() => orchestrationRunEvents.id, { onDelete: "cascade" }),
25239
- resultPayload: jsonb43("result_payload").$type().notNull(),
25240
- createdAt: timestamp75("created_at", { withTimezone: true }).notNull().defaultNow()
25287
+ resultPayload: jsonb45("result_payload").$type().notNull(),
25288
+ createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow()
25241
25289
  },
25242
25290
  (table) => [
25243
- foreignKey6({
25291
+ foreignKey7({
25244
25292
  columns: [table.runId, table.workspaceId, table.projectId],
25245
25293
  foreignColumns: [orchestrationRuns.id, orchestrationRuns.workspaceId, orchestrationRuns.projectId],
25246
25294
  name: "orchestration_run_command_results_run_scope_fkey"
25247
25295
  }).onDelete("cascade"),
25248
- index70("orchestration_run_command_results_run_created_idx").on(table.runId, table.createdAt),
25249
- index70("orchestration_run_command_results_project_created_idx").on(
25296
+ index71("orchestration_run_command_results_run_created_idx").on(table.runId, table.createdAt),
25297
+ index71("orchestration_run_command_results_project_created_idx").on(
25250
25298
  table.projectId,
25251
25299
  table.createdAt
25252
25300
  ),
@@ -25279,13 +25327,13 @@ import {
25279
25327
  bigint as bigint5,
25280
25328
  boolean as boolean29,
25281
25329
  check as check5,
25282
- foreignKey as foreignKey7,
25283
- index as index71,
25284
- integer as integer40,
25285
- jsonb as jsonb44,
25286
- pgTable as pgTable83,
25287
- text as text84,
25288
- timestamp as timestamp76,
25330
+ foreignKey as foreignKey8,
25331
+ index as index72,
25332
+ integer as integer41,
25333
+ jsonb as jsonb46,
25334
+ pgTable as pgTable84,
25335
+ text as text85,
25336
+ timestamp as timestamp77,
25289
25337
  unique as unique7,
25290
25338
  uniqueIndex as uniqueIndex37,
25291
25339
  uuid as uuid4,
@@ -25330,23 +25378,23 @@ var EXECUTOR_COMMAND_KINDS = [
25330
25378
  "cancel",
25331
25379
  "handoff"
25332
25380
  ];
25333
- var orchestrationExecutorInstallations = pgTable83(
25381
+ var orchestrationExecutorInstallations = pgTable84(
25334
25382
  "orchestration_executor_installations",
25335
25383
  {
25336
25384
  id: uuid4("id").primaryKey().defaultRandom(),
25337
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25338
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25385
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25386
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25339
25387
  kind: varchar63("kind", { length: 24 }).$type().notNull(),
25340
- grantId: text84("grant_id").references(() => deviceAuthorizations.id, { onDelete: "cascade" }),
25388
+ grantId: text85("grant_id").references(() => deviceAuthorizations.id, { onDelete: "cascade" }),
25341
25389
  protocolVersion: varchar63("protocol_version", { length: 16 }).notNull(),
25342
- capabilityDigest: text84("capability_digest").notNull(),
25343
- repositoryClaim: jsonb44("repository_claim").$type().notNull().default({}),
25390
+ capabilityDigest: text85("capability_digest").notNull(),
25391
+ repositoryClaim: jsonb46("repository_claim").$type().notNull().default({}),
25344
25392
  status: varchar63("status", { length: 20 }).$type().notNull().default("active"),
25345
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow(),
25346
- updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
25393
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
25394
+ updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
25347
25395
  },
25348
25396
  (table) => [
25349
- foreignKey7({
25397
+ foreignKey8({
25350
25398
  columns: [table.projectId, table.workspaceId],
25351
25399
  foreignColumns: [projects.id, projects.workspaceId],
25352
25400
  name: "orchestration_executor_installations_project_workspace_fkey"
@@ -25356,7 +25404,7 @@ var orchestrationExecutorInstallations = pgTable83(
25356
25404
  table.workspaceId,
25357
25405
  table.projectId
25358
25406
  ),
25359
- index71("orchestration_executor_installations_project_status_idx").on(
25407
+ index72("orchestration_executor_installations_project_status_idx").on(
25360
25408
  table.projectId,
25361
25409
  table.status
25362
25410
  ),
@@ -25393,27 +25441,27 @@ var orchestrationExecutorInstallations = pgTable83(
25393
25441
  )
25394
25442
  ]
25395
25443
  );
25396
- var orchestrationExecutorSessions = pgTable83(
25444
+ var orchestrationExecutorSessions = pgTable84(
25397
25445
  "orchestration_executor_sessions",
25398
25446
  {
25399
25447
  id: uuid4("id").primaryKey().defaultRandom(),
25400
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25401
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25448
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25449
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25402
25450
  installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
25403
- sessionEpoch: integer40("session_epoch").notNull().default(1),
25451
+ sessionEpoch: integer41("session_epoch").notNull().default(1),
25404
25452
  credentialAudience: varchar63("credential_audience", { length: 64 }).notNull(),
25405
25453
  state: varchar63("state", { length: 20 }).$type().notNull().default("open"),
25406
25454
  clientCursor: bigint5("client_cursor", { mode: "number" }).notNull().default(0),
25407
25455
  serverCursor: bigint5("server_cursor", { mode: "number" }).notNull().default(0),
25408
- connectedAt: timestamp76("connected_at", { withTimezone: true }).notNull().defaultNow(),
25409
- lastHeartbeatAt: timestamp76("last_heartbeat_at", { withTimezone: true }),
25410
- serverReceivedAt: timestamp76("server_received_at", { withTimezone: true }),
25411
- closedAt: timestamp76("closed_at", { withTimezone: true }),
25412
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow(),
25413
- updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
25456
+ connectedAt: timestamp77("connected_at", { withTimezone: true }).notNull().defaultNow(),
25457
+ lastHeartbeatAt: timestamp77("last_heartbeat_at", { withTimezone: true }),
25458
+ serverReceivedAt: timestamp77("server_received_at", { withTimezone: true }),
25459
+ closedAt: timestamp77("closed_at", { withTimezone: true }),
25460
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
25461
+ updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
25414
25462
  },
25415
25463
  (table) => [
25416
- foreignKey7({
25464
+ foreignKey8({
25417
25465
  columns: [table.installationId, table.workspaceId, table.projectId],
25418
25466
  foreignColumns: [
25419
25467
  orchestrationExecutorInstallations.id,
@@ -25431,11 +25479,11 @@ var orchestrationExecutorSessions = pgTable83(
25431
25479
  table.installationId,
25432
25480
  table.sessionEpoch
25433
25481
  ),
25434
- index71("orchestration_executor_sessions_installation_state_idx").on(
25482
+ index72("orchestration_executor_sessions_installation_state_idx").on(
25435
25483
  table.installationId,
25436
25484
  table.state
25437
25485
  ),
25438
- index71("orchestration_executor_sessions_liveness_idx").on(table.serverReceivedAt).where(sql21`${table.state} = 'open'`),
25486
+ index72("orchestration_executor_sessions_liveness_idx").on(table.serverReceivedAt).where(sql21`${table.state} = 'open'`),
25439
25487
  check5("orchestration_executor_sessions_epoch_check", sql21`${table.sessionEpoch} >= 1`),
25440
25488
  check5(
25441
25489
  "orchestration_executor_sessions_state_check",
@@ -25459,18 +25507,18 @@ var orchestrationExecutorSessions = pgTable83(
25459
25507
  )
25460
25508
  ]
25461
25509
  );
25462
- var orchestrationImplementationAttempts = pgTable83(
25510
+ var orchestrationImplementationAttempts = pgTable84(
25463
25511
  "orchestration_implementation_attempts",
25464
25512
  {
25465
25513
  id: uuid4("id").primaryKey().defaultRandom(),
25466
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25467
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25514
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25515
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25468
25516
  runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
25469
25517
  installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
25470
- attemptNumber: integer40("attempt_number").notNull(),
25518
+ attemptNumber: integer41("attempt_number").notNull(),
25471
25519
  targetKind: varchar63("target_kind", { length: 32 }).notNull().default("component-variant"),
25472
- targetId: text84("target_id").notNull(),
25473
- targetBindingDigest: text84("target_binding_digest").notNull(),
25520
+ targetId: text85("target_id").notNull(),
25521
+ targetBindingDigest: text85("target_binding_digest").notNull(),
25474
25522
  repositoryId: bigint5("repository_id", { mode: "number" }),
25475
25523
  baseBranch: varchar63("base_branch", { length: 255 }),
25476
25524
  baseSha: varchar63("base_sha", { length: 64 }),
@@ -25479,7 +25527,7 @@ var orchestrationImplementationAttempts = pgTable83(
25479
25527
  * crash-safety line: if the process dies holding a branch, cancellation and reconciliation can
25480
25528
  * still find it. Null until the branch exists. Shape-checked to run branches only (0278).
25481
25529
  */
25482
- createdRef: text84("created_ref"),
25530
+ createdRef: text85("created_ref"),
25483
25531
  status: varchar63("status", { length: 24 }).$type().notNull().default("preflight"),
25484
25532
  supersededBy: uuid4("superseded_by"),
25485
25533
  /**
@@ -25487,19 +25535,19 @@ var orchestrationImplementationAttempts = pgTable83(
25487
25535
  * withdrawn attempt's pull request is kept BY URL, so a reader of the run never has to
25488
25536
  * discover from GitHub that one used to exist here.
25489
25537
  */
25490
- withdrawnAt: timestamp76("withdrawn_at", { withTimezone: true }),
25491
- withdrawnBy: text84("withdrawn_by"),
25492
- withdrawnPullRequestUrl: text84("withdrawn_pull_request_url"),
25493
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow(),
25494
- updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
25538
+ withdrawnAt: timestamp77("withdrawn_at", { withTimezone: true }),
25539
+ withdrawnBy: text85("withdrawn_by"),
25540
+ withdrawnPullRequestUrl: text85("withdrawn_pull_request_url"),
25541
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
25542
+ updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
25495
25543
  },
25496
25544
  (table) => [
25497
- foreignKey7({
25545
+ foreignKey8({
25498
25546
  columns: [table.supersededBy],
25499
25547
  foreignColumns: [table.id],
25500
25548
  name: "orchestration_implementation_attempts_superseded_by_fkey"
25501
25549
  }).onDelete("set null"),
25502
- foreignKey7({
25550
+ foreignKey8({
25503
25551
  columns: [table.runId, table.workspaceId, table.projectId],
25504
25552
  foreignColumns: [
25505
25553
  orchestrationRuns.id,
@@ -25508,7 +25556,7 @@ var orchestrationImplementationAttempts = pgTable83(
25508
25556
  ],
25509
25557
  name: "orchestration_implementation_attempts_run_scope_fkey"
25510
25558
  }).onDelete("cascade"),
25511
- foreignKey7({
25559
+ foreignKey8({
25512
25560
  columns: [table.installationId, table.workspaceId, table.projectId],
25513
25561
  foreignColumns: [
25514
25562
  orchestrationExecutorInstallations.id,
@@ -25526,7 +25574,7 @@ var orchestrationImplementationAttempts = pgTable83(
25526
25574
  table.runId,
25527
25575
  table.attemptNumber
25528
25576
  ),
25529
- index71("orchestration_implementation_attempts_run_created_idx").on(
25577
+ index72("orchestration_implementation_attempts_run_created_idx").on(
25530
25578
  table.runId,
25531
25579
  table.createdAt
25532
25580
  ),
@@ -25557,49 +25605,49 @@ var orchestrationImplementationAttempts = pgTable83(
25557
25605
  )
25558
25606
  ]
25559
25607
  );
25560
- var orchestrationPlanSnapshots = pgTable83(
25608
+ var orchestrationPlanSnapshots = pgTable84(
25561
25609
  "orchestration_plan_snapshots",
25562
25610
  {
25563
- planDigest: text84("plan_digest").primaryKey(),
25564
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25565
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25611
+ planDigest: text85("plan_digest").primaryKey(),
25612
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25613
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25566
25614
  baseHeadOid: varchar63("base_head_oid", { length: 64 }).notNull(),
25567
- budget: jsonb44("budget").notNull(),
25568
- files: jsonb44("files").notNull(),
25569
- fileCount: integer40("file_count").notNull(),
25615
+ budget: jsonb46("budget").notNull(),
25616
+ files: jsonb46("files").notNull(),
25617
+ fileCount: integer41("file_count").notNull(),
25570
25618
  byteCount: bigint5("byte_count", { mode: "number" }).notNull(),
25571
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow()
25619
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow()
25572
25620
  },
25573
- (table) => [index71("orchestration_plan_snapshots_project_idx").on(table.workspaceId, table.projectId, table.createdAt)]
25621
+ (table) => [index72("orchestration_plan_snapshots_project_idx").on(table.workspaceId, table.projectId, table.createdAt)]
25574
25622
  );
25575
- var orchestrationVisualApprovals = pgTable83(
25623
+ var orchestrationVisualApprovals = pgTable84(
25576
25624
  "orchestration_visual_approvals",
25577
25625
  {
25578
25626
  id: uuid4("id").primaryKey().defaultRandom(),
25579
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25580
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25627
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25628
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25581
25629
  runId: uuid4("run_id").notNull(),
25582
25630
  attemptId: uuid4("attempt_id").notNull(),
25583
25631
  headSha: varchar63("head_sha", { length: 64 }).notNull(),
25584
25632
  evidenceId: uuid4("evidence_id").notNull(),
25585
- authorizedBy: text84("authorized_by").notNull(),
25586
- idempotencyKey: text84("idempotency_key").notNull(),
25587
- expiresAt: timestamp76("expires_at", { withTimezone: true }).notNull(),
25588
- consumedAt: timestamp76("consumed_at", { withTimezone: true }),
25589
- consumedByRef: text84("consumed_by_ref"),
25590
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow(),
25591
- updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
25633
+ authorizedBy: text85("authorized_by").notNull(),
25634
+ idempotencyKey: text85("idempotency_key").notNull(),
25635
+ expiresAt: timestamp77("expires_at", { withTimezone: true }).notNull(),
25636
+ consumedAt: timestamp77("consumed_at", { withTimezone: true }),
25637
+ consumedByRef: text85("consumed_by_ref"),
25638
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
25639
+ updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
25592
25640
  }
25593
25641
  );
25594
- var orchestrationMergeAuthorizations = pgTable83(
25642
+ var orchestrationMergeAuthorizations = pgTable84(
25595
25643
  "orchestration_merge_authorizations",
25596
25644
  {
25597
25645
  id: uuid4("id").primaryKey().defaultRandom(),
25598
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25599
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25646
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25647
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25600
25648
  runId: uuid4("run_id").notNull(),
25601
25649
  attemptId: uuid4("attempt_id").notNull(),
25602
- pullRequestNumber: integer40("pull_request_number").notNull(),
25650
+ pullRequestNumber: integer41("pull_request_number").notNull(),
25603
25651
  expectedHeadSha: varchar63("expected_head_sha", { length: 64 }).notNull(),
25604
25652
  visualApprovalId: uuid4("visual_approval_id").notNull(),
25605
25653
  /**
@@ -25607,88 +25655,88 @@ var orchestrationMergeAuthorizations = pgTable83(
25607
25655
  * what an authorization BOUGHT, and a void bought nothing. A CHECK keeps the three together and
25608
25656
  * forbids a row that is both spent and voided.
25609
25657
  */
25610
- voidedAt: timestamp76("voided_at", { withTimezone: true }),
25611
- voidedBy: text84("voided_by"),
25612
- voidReason: text84("void_reason"),
25613
- authorizedBy: text84("authorized_by").notNull(),
25614
- idempotencyKey: text84("idempotency_key").notNull(),
25615
- expiresAt: timestamp76("expires_at", { withTimezone: true }).notNull(),
25616
- consumedAt: timestamp76("consumed_at", { withTimezone: true }),
25617
- consumedByRef: text84("consumed_by_ref"),
25618
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow(),
25619
- updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
25658
+ voidedAt: timestamp77("voided_at", { withTimezone: true }),
25659
+ voidedBy: text85("voided_by"),
25660
+ voidReason: text85("void_reason"),
25661
+ authorizedBy: text85("authorized_by").notNull(),
25662
+ idempotencyKey: text85("idempotency_key").notNull(),
25663
+ expiresAt: timestamp77("expires_at", { withTimezone: true }).notNull(),
25664
+ consumedAt: timestamp77("consumed_at", { withTimezone: true }),
25665
+ consumedByRef: text85("consumed_by_ref"),
25666
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
25667
+ updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
25620
25668
  }
25621
25669
  );
25622
- var orchestrationDeploymentAuthorizations = pgTable83(
25670
+ var orchestrationDeploymentAuthorizations = pgTable84(
25623
25671
  "orchestration_deployment_authorizations",
25624
25672
  {
25625
25673
  id: uuid4("id").primaryKey().defaultRandom(),
25626
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25627
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25674
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25675
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25628
25676
  runId: uuid4("run_id").notNull(),
25629
25677
  attemptId: uuid4("attempt_id").notNull(),
25630
25678
  mergeSha: varchar63("merge_sha", { length: 64 }).notNull(),
25631
25679
  artifactChecksum: varchar63("artifact_checksum", { length: 80 }).notNull(),
25632
25680
  mergeAuthorizationId: uuid4("merge_authorization_id").notNull(),
25633
- authorizedBy: text84("authorized_by").notNull(),
25634
- idempotencyKey: text84("idempotency_key").notNull(),
25635
- expiresAt: timestamp76("expires_at", { withTimezone: true }).notNull(),
25636
- consumedAt: timestamp76("consumed_at", { withTimezone: true }),
25637
- consumedByRef: text84("consumed_by_ref"),
25638
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow(),
25639
- updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
25681
+ authorizedBy: text85("authorized_by").notNull(),
25682
+ idempotencyKey: text85("idempotency_key").notNull(),
25683
+ expiresAt: timestamp77("expires_at", { withTimezone: true }).notNull(),
25684
+ consumedAt: timestamp77("consumed_at", { withTimezone: true }),
25685
+ consumedByRef: text85("consumed_by_ref"),
25686
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
25687
+ updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
25640
25688
  }
25641
25689
  );
25642
- var orchestrationDeploymentRequests = pgTable83(
25690
+ var orchestrationDeploymentRequests = pgTable84(
25643
25691
  "orchestration_deployment_requests",
25644
25692
  {
25645
25693
  id: uuid4("id").primaryKey().defaultRandom(),
25646
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25647
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25694
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25695
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25648
25696
  runId: uuid4("run_id").notNull(),
25649
25697
  attemptId: uuid4("attempt_id").notNull(),
25650
25698
  authorizationId: uuid4("authorization_id").notNull(),
25651
25699
  expectedMergeSha: varchar63("expected_merge_sha", { length: 64 }).notNull(),
25652
25700
  artifactChecksum: varchar63("artifact_checksum", { length: 80 }).notNull(),
25653
25701
  state: varchar63("state", { length: 12 }).$type().notNull().default("live"),
25654
- voidReason: text84("void_reason"),
25655
- releaseId: text84("release_id"),
25656
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow(),
25657
- updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
25702
+ voidReason: text85("void_reason"),
25703
+ releaseId: text85("release_id"),
25704
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
25705
+ updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
25658
25706
  }
25659
25707
  );
25660
- var orchestrationExecutionApprovals = pgTable83(
25708
+ var orchestrationExecutionApprovals = pgTable84(
25661
25709
  "orchestration_execution_approvals",
25662
25710
  {
25663
25711
  id: uuid4("id").primaryKey().defaultRandom(),
25664
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25665
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25712
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25713
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25666
25714
  runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
25667
25715
  attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
25668
25716
  installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
25669
- idempotencyKey: text84("idempotency_key").notNull(),
25670
- approvedBy: text84("approved_by").notNull(),
25717
+ idempotencyKey: text85("idempotency_key").notNull(),
25718
+ approvedBy: text85("approved_by").notNull(),
25671
25719
  targetKind: varchar63("target_kind", { length: 32 }).notNull().default("component-variant"),
25672
- targetId: text84("target_id").notNull(),
25673
- targetBindingDigest: text84("target_binding_digest").notNull(),
25720
+ targetId: text85("target_id").notNull(),
25721
+ targetBindingDigest: text85("target_binding_digest").notNull(),
25674
25722
  repositoryId: bigint5("repository_id", { mode: "number" }),
25675
25723
  baseBranch: varchar63("base_branch", { length: 255 }),
25676
25724
  baseSha: varchar63("base_sha", { length: 64 }),
25677
25725
  /** Set when the approval is spent. 0274 grants UPDATE on THESE TWO COLUMNS ONLY, so every
25678
25726
  * other field on a row a human signed stays as unwritable as it was before. */
25679
- consumedAt: timestamp76("consumed_at", { withTimezone: true }),
25727
+ consumedAt: timestamp77("consumed_at", { withTimezone: true }),
25680
25728
  consumedByAttemptId: uuid4("consumed_by_attempt_id"),
25681
- pathPolicy: jsonb44("path_policy").$type().notNull().default({}),
25682
- operationClasses: jsonb44("operation_classes").$type().notNull().default([]),
25683
- mutationBudget: jsonb44("mutation_budget").$type().notNull().default({}),
25684
- planDigest: text84("plan_digest").notNull(),
25685
- capabilityDigest: text84("capability_digest").notNull(),
25686
- validationDigest: text84("validation_digest").notNull(),
25687
- expiresAt: timestamp76("expires_at", { withTimezone: true }).notNull(),
25688
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow()
25729
+ pathPolicy: jsonb46("path_policy").$type().notNull().default({}),
25730
+ operationClasses: jsonb46("operation_classes").$type().notNull().default([]),
25731
+ mutationBudget: jsonb46("mutation_budget").$type().notNull().default({}),
25732
+ planDigest: text85("plan_digest").notNull(),
25733
+ capabilityDigest: text85("capability_digest").notNull(),
25734
+ validationDigest: text85("validation_digest").notNull(),
25735
+ expiresAt: timestamp77("expires_at", { withTimezone: true }).notNull(),
25736
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow()
25689
25737
  },
25690
25738
  (table) => [
25691
- foreignKey7({
25739
+ foreignKey8({
25692
25740
  columns: [table.runId, table.workspaceId, table.projectId],
25693
25741
  foreignColumns: [
25694
25742
  orchestrationRuns.id,
@@ -25697,7 +25745,7 @@ var orchestrationExecutionApprovals = pgTable83(
25697
25745
  ],
25698
25746
  name: "orchestration_execution_approvals_run_scope_fkey"
25699
25747
  }).onDelete("cascade"),
25700
- foreignKey7({
25748
+ foreignKey8({
25701
25749
  columns: [table.attemptId, table.workspaceId, table.projectId],
25702
25750
  foreignColumns: [
25703
25751
  orchestrationImplementationAttempts.id,
@@ -25706,7 +25754,7 @@ var orchestrationExecutionApprovals = pgTable83(
25706
25754
  ],
25707
25755
  name: "orchestration_execution_approvals_attempt_scope_fkey"
25708
25756
  }).onDelete("cascade"),
25709
- foreignKey7({
25757
+ foreignKey8({
25710
25758
  columns: [table.installationId, table.workspaceId, table.projectId],
25711
25759
  foreignColumns: [
25712
25760
  orchestrationExecutorInstallations.id,
@@ -25722,7 +25770,7 @@ var orchestrationExecutionApprovals = pgTable83(
25722
25770
  // One approval per attempt. A running implementation never introduces a second approval; a
25723
25771
  // changed binding requires a NEW attempt, which is what makes the authority auditable.
25724
25772
  unique7("orchestration_execution_approvals_attempt_unique").on(table.attemptId),
25725
- index71("orchestration_execution_approvals_run_created_idx").on(table.runId, table.createdAt),
25773
+ index72("orchestration_execution_approvals_run_created_idx").on(table.runId, table.createdAt),
25726
25774
  check5(
25727
25775
  "orchestration_execution_approvals_idempotency_key_check",
25728
25776
  sql21`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
@@ -25769,26 +25817,26 @@ var orchestrationExecutionApprovals = pgTable83(
25769
25817
  )
25770
25818
  ]
25771
25819
  );
25772
- var orchestrationExecutorLeases = pgTable83(
25820
+ var orchestrationExecutorLeases = pgTable84(
25773
25821
  "orchestration_executor_leases",
25774
25822
  {
25775
25823
  id: uuid4("id").primaryKey().defaultRandom(),
25776
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25777
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25824
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25825
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25778
25826
  runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
25779
25827
  attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
25780
25828
  sessionId: uuid4("session_id").notNull().references(() => orchestrationExecutorSessions.id, { onDelete: "cascade" }),
25781
- leaseEpoch: integer40("lease_epoch").notNull().default(1),
25829
+ leaseEpoch: integer41("lease_epoch").notNull().default(1),
25782
25830
  state: varchar63("state", { length: 20 }).$type().notNull().default("active"),
25783
- heartbeatDeadline: timestamp76("heartbeat_deadline", { withTimezone: true }).notNull(),
25784
- acquiredAt: timestamp76("acquired_at", { withTimezone: true }).notNull().defaultNow(),
25785
- releasedAt: timestamp76("released_at", { withTimezone: true }),
25831
+ heartbeatDeadline: timestamp77("heartbeat_deadline", { withTimezone: true }).notNull(),
25832
+ acquiredAt: timestamp77("acquired_at", { withTimezone: true }).notNull().defaultNow(),
25833
+ releasedAt: timestamp77("released_at", { withTimezone: true }),
25786
25834
  releaseReason: varchar63("release_reason", { length: 32 }).$type(),
25787
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow(),
25788
- updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
25835
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
25836
+ updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
25789
25837
  },
25790
25838
  (table) => [
25791
- foreignKey7({
25839
+ foreignKey8({
25792
25840
  columns: [table.runId, table.workspaceId, table.projectId],
25793
25841
  foreignColumns: [
25794
25842
  orchestrationRuns.id,
@@ -25797,7 +25845,7 @@ var orchestrationExecutorLeases = pgTable83(
25797
25845
  ],
25798
25846
  name: "orchestration_executor_leases_run_scope_fkey"
25799
25847
  }).onDelete("cascade"),
25800
- foreignKey7({
25848
+ foreignKey8({
25801
25849
  columns: [table.attemptId, table.workspaceId, table.projectId],
25802
25850
  foreignColumns: [
25803
25851
  orchestrationImplementationAttempts.id,
@@ -25806,7 +25854,7 @@ var orchestrationExecutorLeases = pgTable83(
25806
25854
  ],
25807
25855
  name: "orchestration_executor_leases_attempt_scope_fkey"
25808
25856
  }).onDelete("cascade"),
25809
- foreignKey7({
25857
+ foreignKey8({
25810
25858
  columns: [table.sessionId, table.workspaceId, table.projectId],
25811
25859
  foreignColumns: [
25812
25860
  orchestrationExecutorSessions.id,
@@ -25823,7 +25871,7 @@ var orchestrationExecutorLeases = pgTable83(
25823
25871
  unique7("orchestration_executor_leases_epoch_unique").on(table.attemptId, table.leaseEpoch),
25824
25872
  // Plan invariant 6, enforced in the database: a run has at most one active executor lease.
25825
25873
  uniqueIndex37("orchestration_executor_leases_one_active_per_run").on(table.runId).where(sql21`${table.state} = 'active'`),
25826
- index71("orchestration_executor_leases_deadline_idx").on(table.heartbeatDeadline).where(sql21`${table.state} = 'active'`),
25874
+ index72("orchestration_executor_leases_deadline_idx").on(table.heartbeatDeadline).where(sql21`${table.state} = 'active'`),
25827
25875
  check5("orchestration_executor_leases_epoch_check", sql21`${table.leaseEpoch} >= 1`),
25828
25876
  check5(
25829
25877
  "orchestration_executor_leases_state_check",
@@ -25843,35 +25891,35 @@ var orchestrationExecutorLeases = pgTable83(
25843
25891
  )
25844
25892
  ]
25845
25893
  );
25846
- var orchestrationExecutorCommands = pgTable83(
25894
+ var orchestrationExecutorCommands = pgTable84(
25847
25895
  "orchestration_executor_commands",
25848
25896
  {
25849
25897
  id: uuid4("id").primaryKey().defaultRandom(),
25850
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25851
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25898
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25899
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25852
25900
  runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
25853
25901
  attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
25854
25902
  leaseId: uuid4("lease_id").references(() => orchestrationExecutorLeases.id, {
25855
25903
  onDelete: "set null"
25856
25904
  }),
25857
- leaseEpoch: integer40("lease_epoch"),
25905
+ leaseEpoch: integer41("lease_epoch"),
25858
25906
  approvalId: uuid4("approval_id").references(() => orchestrationExecutionApprovals.id, {
25859
25907
  onDelete: "set null"
25860
25908
  }),
25861
25909
  sequence: bigint5("sequence", { mode: "number" }).notNull(),
25862
25910
  kind: varchar63("kind", { length: 32 }).$type().notNull(),
25863
- idempotencyKey: text84("idempotency_key").notNull(),
25864
- expectedRunVersion: integer40("expected_run_version").notNull(),
25865
- payload: jsonb44("payload").$type().notNull().default({}),
25911
+ idempotencyKey: text85("idempotency_key").notNull(),
25912
+ expectedRunVersion: integer41("expected_run_version").notNull(),
25913
+ payload: jsonb46("payload").$type().notNull().default({}),
25866
25914
  payloadDigest: varchar63("payload_digest", { length: 71 }).generatedAlwaysAs(
25867
25915
  sql21`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
25868
25916
  ),
25869
- deliveredAt: timestamp76("delivered_at", { withTimezone: true }),
25870
- acknowledgedAt: timestamp76("acknowledged_at", { withTimezone: true }),
25871
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow()
25917
+ deliveredAt: timestamp77("delivered_at", { withTimezone: true }),
25918
+ acknowledgedAt: timestamp77("acknowledged_at", { withTimezone: true }),
25919
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow()
25872
25920
  },
25873
25921
  (table) => [
25874
- foreignKey7({
25922
+ foreignKey8({
25875
25923
  columns: [table.runId, table.workspaceId, table.projectId],
25876
25924
  foreignColumns: [
25877
25925
  orchestrationRuns.id,
@@ -25880,7 +25928,7 @@ var orchestrationExecutorCommands = pgTable83(
25880
25928
  ],
25881
25929
  name: "orchestration_executor_commands_run_scope_fkey"
25882
25930
  }).onDelete("cascade"),
25883
- foreignKey7({
25931
+ foreignKey8({
25884
25932
  columns: [table.attemptId, table.workspaceId, table.projectId],
25885
25933
  foreignColumns: [
25886
25934
  orchestrationImplementationAttempts.id,
@@ -25894,9 +25942,9 @@ var orchestrationExecutorCommands = pgTable83(
25894
25942
  table.runId,
25895
25943
  table.idempotencyKey
25896
25944
  ),
25897
- index71("orchestration_executor_commands_run_sequence_idx").on(table.runId, table.sequence),
25945
+ index72("orchestration_executor_commands_run_sequence_idx").on(table.runId, table.sequence),
25898
25946
  // The long-poll cursor read: unacknowledged commands for a run, in order.
25899
- index71("orchestration_executor_commands_pending_idx").on(table.runId, table.sequence).where(sql21`${table.acknowledgedAt} IS NULL`),
25947
+ index72("orchestration_executor_commands_pending_idx").on(table.runId, table.sequence).where(sql21`${table.acknowledgedAt} IS NULL`),
25900
25948
  check5("orchestration_executor_commands_sequence_check", sql21`${table.sequence} >= 1`),
25901
25949
  check5(
25902
25950
  "orchestration_executor_commands_kind_check",
@@ -25926,28 +25974,28 @@ var orchestrationExecutorCommands = pgTable83(
25926
25974
  ]
25927
25975
  );
25928
25976
  var PATCH_OPERATIONS = ["create", "update", "delete"];
25929
- var orchestrationPatchManifests = pgTable83(
25977
+ var orchestrationPatchManifests = pgTable84(
25930
25978
  "orchestration_patch_manifests",
25931
25979
  {
25932
25980
  id: uuid4("id").primaryKey().defaultRandom(),
25933
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25934
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25981
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
25982
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
25935
25983
  runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
25936
25984
  attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
25937
25985
  approvalId: uuid4("approval_id").references(() => orchestrationExecutionApprovals.id, {
25938
25986
  onDelete: "set null"
25939
25987
  }),
25940
- sequence: integer40("sequence").notNull(),
25941
- path: text84("path").notNull(),
25988
+ sequence: integer41("sequence").notNull(),
25989
+ path: text85("path").notNull(),
25942
25990
  operation: varchar63("operation", { length: 16 }).$type().notNull(),
25943
25991
  fileMode: varchar63("file_mode", { length: 6 }).notNull().default("100644"),
25944
25992
  expectedBefore: varchar63("expected_before", { length: 64 }),
25945
25993
  resultingBlobSha: varchar63("resulting_blob_sha", { length: 64 }),
25946
25994
  byteCount: bigint5("byte_count", { mode: "number" }).notNull().default(0),
25947
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow()
25995
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow()
25948
25996
  },
25949
25997
  (table) => [
25950
- foreignKey7({
25998
+ foreignKey8({
25951
25999
  columns: [table.runId, table.workspaceId, table.projectId],
25952
26000
  foreignColumns: [
25953
26001
  orchestrationRuns.id,
@@ -25956,7 +26004,7 @@ var orchestrationPatchManifests = pgTable83(
25956
26004
  ],
25957
26005
  name: "orchestration_patch_manifests_run_scope_fkey"
25958
26006
  }).onDelete("cascade"),
25959
- foreignKey7({
26007
+ foreignKey8({
25960
26008
  columns: [table.attemptId, table.workspaceId, table.projectId],
25961
26009
  foreignColumns: [
25962
26010
  orchestrationImplementationAttempts.id,
@@ -25967,7 +26015,7 @@ var orchestrationPatchManifests = pgTable83(
25967
26015
  }).onDelete("cascade"),
25968
26016
  unique7("orchestration_patch_manifests_sequence_unique").on(table.attemptId, table.sequence),
25969
26017
  unique7("orchestration_patch_manifests_path_unique").on(table.attemptId, table.path),
25970
- index71("orchestration_patch_manifests_attempt_sequence_idx").on(table.attemptId, table.sequence),
26018
+ index72("orchestration_patch_manifests_attempt_sequence_idx").on(table.attemptId, table.sequence),
25971
26019
  check5("orchestration_patch_manifests_sequence_check", sql21`${table.sequence} >= 1`),
25972
26020
  check5(
25973
26021
  "orchestration_patch_manifests_operation_check",
@@ -25993,19 +26041,19 @@ var orchestrationPatchManifests = pgTable83(
25993
26041
  check5("orchestration_patch_manifests_byte_count_check", sql21`${table.byteCount} >= 0`)
25994
26042
  ]
25995
26043
  );
25996
- var orchestrationPullRequestReceipts = pgTable83(
26044
+ var orchestrationPullRequestReceipts = pgTable84(
25997
26045
  "orchestration_pull_request_receipts",
25998
26046
  {
25999
26047
  id: uuid4("id").primaryKey().defaultRandom(),
26000
- workspaceId: text84("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26001
- projectId: text84("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26048
+ workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26049
+ projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26002
26050
  runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
26003
26051
  attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
26004
26052
  repositoryId: bigint5("repository_id", { mode: "number" }).notNull(),
26005
26053
  installationId: bigint5("installation_id", { mode: "number" }),
26006
26054
  pullRequestId: bigint5("pull_request_id", { mode: "number" }).notNull(),
26007
- pullRequestNumber: integer40("pull_request_number").notNull(),
26008
- pullRequestUrl: text84("pull_request_url").notNull(),
26055
+ pullRequestNumber: integer41("pull_request_number").notNull(),
26056
+ pullRequestUrl: text85("pull_request_url").notNull(),
26009
26057
  baseRef: varchar63("base_ref", { length: 255 }).notNull(),
26010
26058
  baseSha: varchar63("base_sha", { length: 64 }).notNull(),
26011
26059
  headRef: varchar63("head_ref", { length: 255 }).notNull(),
@@ -26013,13 +26061,13 @@ var orchestrationPullRequestReceipts = pgTable83(
26013
26061
  /** True when BetterCMS created and owns the head branch. A head we do not own is observable
26014
26062
  * but never advanceable by the adapter. */
26015
26063
  branchOwned: boolean29("branch_owned").notNull().default(true),
26016
- generation: integer40("generation").notNull().default(1),
26064
+ generation: integer41("generation").notNull().default(1),
26017
26065
  isDraft: boolean29("is_draft").notNull().default(true),
26018
- createdAt: timestamp76("created_at", { withTimezone: true }).notNull().defaultNow(),
26019
- updatedAt: timestamp76("updated_at", { withTimezone: true }).notNull().defaultNow()
26066
+ createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
26067
+ updatedAt: timestamp77("updated_at", { withTimezone: true }).notNull().defaultNow()
26020
26068
  },
26021
26069
  (table) => [
26022
- foreignKey7({
26070
+ foreignKey8({
26023
26071
  columns: [table.runId, table.workspaceId, table.projectId],
26024
26072
  foreignColumns: [
26025
26073
  orchestrationRuns.id,
@@ -26028,7 +26076,7 @@ var orchestrationPullRequestReceipts = pgTable83(
26028
26076
  ],
26029
26077
  name: "orchestration_pull_request_receipts_run_scope_fkey"
26030
26078
  }).onDelete("cascade"),
26031
- foreignKey7({
26079
+ foreignKey8({
26032
26080
  columns: [table.attemptId, table.workspaceId, table.projectId],
26033
26081
  foreignColumns: [
26034
26082
  orchestrationImplementationAttempts.id,
@@ -26041,11 +26089,11 @@ var orchestrationPullRequestReceipts = pgTable83(
26041
26089
  table.attemptId,
26042
26090
  table.generation
26043
26091
  ),
26044
- index71("orchestration_pull_request_receipts_attempt_generation_idx").on(
26092
+ index72("orchestration_pull_request_receipts_attempt_generation_idx").on(
26045
26093
  table.attemptId,
26046
26094
  table.generation
26047
26095
  ),
26048
- index71("orchestration_pull_request_receipts_head_idx").on(table.repositoryId, table.headSha),
26096
+ index72("orchestration_pull_request_receipts_head_idx").on(table.repositoryId, table.headSha),
26049
26097
  check5("orchestration_pull_request_receipts_generation_check", sql21`${table.generation} >= 1`),
26050
26098
  check5("orchestration_pull_request_receipts_number_check", sql21`${table.pullRequestNumber} >= 1`),
26051
26099
  check5(
@@ -26074,24 +26122,24 @@ var orchestrationPullRequestReceipts = pgTable83(
26074
26122
 
26075
26123
  // src/schema/conversion_proposals.ts
26076
26124
  import { sql as sql22 } from "drizzle-orm";
26077
- import { check as check6, foreignKey as foreignKey8, index as index72, integer as integer41, jsonb as jsonb45, pgTable as pgTable84, text as text85, timestamp as timestamp77, unique as unique8, uuid as uuid5, varchar as varchar64 } from "drizzle-orm/pg-core";
26125
+ import { check as check6, foreignKey as foreignKey9, index as index73, integer as integer42, jsonb as jsonb47, pgTable as pgTable85, text as text86, timestamp as timestamp78, unique as unique8, uuid as uuid5, varchar as varchar64 } from "drizzle-orm/pg-core";
26078
26126
  var CONVERSION_PROPOSAL_STATUSES = ["draft", "approved", "superseded"];
26079
- var conversionProposals = pgTable84(
26127
+ var conversionProposals = pgTable85(
26080
26128
  "conversion_proposals",
26081
26129
  {
26082
26130
  id: uuid5("id").primaryKey().defaultRandom(),
26083
- workspaceId: text85("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26084
- projectId: text85("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26131
+ workspaceId: text86("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26132
+ projectId: text86("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26085
26133
  /** The plan snapshot holding the proposed file contents. */
26086
- planDigest: text85("plan_digest").notNull().references(() => orchestrationPlanSnapshots.planDigest),
26134
+ planDigest: text86("plan_digest").notNull().references(() => orchestrationPlanSnapshots.planDigest),
26087
26135
  /** sha256 of the canonical brief — what the CMS held when this was proposed. */
26088
- briefDigest: text85("brief_digest").notNull(),
26136
+ briefDigest: text86("brief_digest").notNull(),
26089
26137
  baseHeadOid: varchar64("base_head_oid", { length: 64 }).notNull(),
26090
- baseBranch: text85("base_branch").notNull(),
26138
+ baseBranch: text86("base_branch").notNull(),
26091
26139
  /** Brief paths whose `original` was not found in any source file. */
26092
- unlocated: jsonb45("unlocated").notNull().default(sql22`'[]'::jsonb`),
26140
+ unlocated: jsonb47("unlocated").notNull().default(sql22`'[]'::jsonb`),
26093
26141
  /** Files that matched a brief original but fell outside the acquisition caps. */
26094
- omittedByCap: jsonb45("omitted_by_cap").notNull().default(sql22`'[]'::jsonb`),
26142
+ omittedByCap: jsonb47("omitted_by_cap").notNull().default(sql22`'[]'::jsonb`),
26095
26143
  /**
26096
26144
  * The codemod's receipt (migration 0296) — every path it bound, and every one it could not.
26097
26145
  *
@@ -26099,27 +26147,27 @@ var conversionProposals = pgTable84(
26099
26147
  * pending list for those, which is exactly the silent "nothing left to do" this lane refuses.
26100
26148
  * Informative: `proposeConversion` re-derives every claim it acts on from the proposed files.
26101
26149
  */
26102
- receipt: jsonb45("receipt"),
26103
- status: text85("status").notNull().default("draft"),
26104
- version: integer41("version").notNull().default(1),
26105
- idempotencyKey: text85("idempotency_key").notNull(),
26150
+ receipt: jsonb47("receipt"),
26151
+ status: text86("status").notNull().default("draft"),
26152
+ version: integer42("version").notNull().default(1),
26153
+ idempotencyKey: text86("idempotency_key").notNull(),
26106
26154
  /**
26107
26155
  * The key of the transition that put this row in its CURRENT terminal state — the approve, or
26108
26156
  * the manual supersede. Separate from `idempotencyKey`, which belongs to the create: a client
26109
26157
  * retrying one act must never be answered with the result of another.
26110
26158
  */
26111
- transitionIdempotencyKey: text85("transition_idempotency_key"),
26112
- createdBy: text85("created_by").notNull(),
26113
- createdAt: timestamp77("created_at", { withTimezone: true }).notNull().defaultNow(),
26114
- approvedBy: text85("approved_by"),
26115
- approvedAt: timestamp77("approved_at", { withTimezone: true }),
26116
- supersededAt: timestamp77("superseded_at", { withTimezone: true }),
26117
- supersededReason: text85("superseded_reason")
26159
+ transitionIdempotencyKey: text86("transition_idempotency_key"),
26160
+ createdBy: text86("created_by").notNull(),
26161
+ createdAt: timestamp78("created_at", { withTimezone: true }).notNull().defaultNow(),
26162
+ approvedBy: text86("approved_by"),
26163
+ approvedAt: timestamp78("approved_at", { withTimezone: true }),
26164
+ supersededAt: timestamp78("superseded_at", { withTimezone: true }),
26165
+ supersededReason: text86("superseded_reason")
26118
26166
  },
26119
26167
  (table) => [
26120
- index72("conversion_proposals_project_idx").on(table.workspaceId, table.projectId, table.createdAt),
26168
+ index73("conversion_proposals_project_idx").on(table.workspaceId, table.projectId, table.createdAt),
26121
26169
  unique8("conversion_proposals_idempotency_unique").on(table.projectId, table.idempotencyKey),
26122
- foreignKey8({
26170
+ foreignKey9({
26123
26171
  columns: [table.projectId, table.workspaceId],
26124
26172
  foreignColumns: [projects.id, projects.workspaceId],
26125
26173
  name: "conversion_proposals_project_workspace_fkey"
@@ -26135,30 +26183,30 @@ var conversionProposals = pgTable84(
26135
26183
 
26136
26184
  // src/schema/conversion_briefs_issued.ts
26137
26185
  import { sql as sql23 } from "drizzle-orm";
26138
- import { check as check7, foreignKey as foreignKey9, index as index73, jsonb as jsonb46, pgTable as pgTable85, text as text86, timestamp as timestamp78, unique as unique9, uuid as uuid6 } from "drizzle-orm/pg-core";
26139
- var conversionBriefsIssued = pgTable85(
26186
+ import { check as check7, foreignKey as foreignKey10, index as index74, jsonb as jsonb48, pgTable as pgTable86, text as text87, timestamp as timestamp79, unique as unique9, uuid as uuid6 } from "drizzle-orm/pg-core";
26187
+ var conversionBriefsIssued = pgTable86(
26140
26188
  "conversion_briefs_issued",
26141
26189
  {
26142
26190
  id: uuid6("id").primaryKey().defaultRandom(),
26143
- workspaceId: text86("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26144
- projectId: text86("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26191
+ workspaceId: text87("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26192
+ projectId: text87("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26145
26193
  /** sha256 of the canonical brief — `briefDigest`, computed identically by the codemod. */
26146
- briefDigest: text86("brief_digest").notNull(),
26194
+ briefDigest: text87("brief_digest").notNull(),
26147
26195
  /** `[{ route, scope, path, kind, locator? }]` — every bindable path the brief listed. */
26148
- paths: jsonb46("paths").notNull().default(sql23`'[]'::jsonb`),
26196
+ paths: jsonb48("paths").notNull().default(sql23`'[]'::jsonb`),
26149
26197
  /**
26150
26198
  * The codemod's account of the run against THIS digest (`submit_conversion_receipt`): which
26151
26199
  * paths it rewrote, which it could not, and why. Null until one is submitted — a hand
26152
26200
  * conversion never submits one and still counts toward coverage.
26153
26201
  */
26154
- receipt: jsonb46("receipt"),
26202
+ receipt: jsonb48("receipt"),
26155
26203
  /** The LAST time this pin was issued. What a retention sweep keys on. */
26156
- issuedAt: timestamp78("issued_at", { withTimezone: true }).notNull().defaultNow()
26204
+ issuedAt: timestamp79("issued_at", { withTimezone: true }).notNull().defaultNow()
26157
26205
  },
26158
26206
  (table) => [
26159
- index73("conversion_briefs_issued_project_issued_idx").on(table.projectId, table.issuedAt),
26207
+ index74("conversion_briefs_issued_project_issued_idx").on(table.projectId, table.issuedAt),
26160
26208
  unique9("conversion_briefs_issued_digest_unique").on(table.projectId, table.briefDigest),
26161
- foreignKey9({
26209
+ foreignKey10({
26162
26210
  columns: [table.projectId, table.workspaceId],
26163
26211
  foreignColumns: [projects.id, projects.workspaceId],
26164
26212
  name: "conversion_briefs_issued_project_workspace_fkey"
@@ -26173,13 +26221,13 @@ import { sql as sql24 } from "drizzle-orm";
26173
26221
  import {
26174
26222
  bigint as bigint6,
26175
26223
  check as check8,
26176
- foreignKey as foreignKey10,
26177
- index as index74,
26178
- integer as integer42,
26179
- jsonb as jsonb47,
26180
- pgTable as pgTable86,
26181
- text as text87,
26182
- timestamp as timestamp79,
26224
+ foreignKey as foreignKey11,
26225
+ index as index75,
26226
+ integer as integer43,
26227
+ jsonb as jsonb49,
26228
+ pgTable as pgTable87,
26229
+ text as text88,
26230
+ timestamp as timestamp80,
26183
26231
  unique as unique10,
26184
26232
  uniqueIndex as uniqueIndex38,
26185
26233
  uuid as uuid7,
@@ -26196,24 +26244,24 @@ var VALIDATION_ENVELOPE_STATUSES = [
26196
26244
  "cancelled"
26197
26245
  ];
26198
26246
  var VALIDATION_LIVE_STATUSES = ["queued", "dispatched", "action_required"];
26199
- var orchestrationValidationEnvelopes = pgTable86(
26247
+ var orchestrationValidationEnvelopes = pgTable87(
26200
26248
  "orchestration_validation_envelopes",
26201
26249
  {
26202
26250
  id: uuid7("id").primaryKey().defaultRandom(),
26203
- workspaceId: text87("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26204
- projectId: text87("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26251
+ workspaceId: text88("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26252
+ projectId: text88("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26205
26253
  runId: uuid7("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
26206
26254
  attemptId: uuid7("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
26207
26255
  /** Null until a receipt writer exists (Phase 6). The head below is pinned regardless. */
26208
26256
  receiptId: uuid7("receipt_id").references(() => orchestrationPullRequestReceipts.id, {
26209
26257
  onDelete: "set null"
26210
26258
  }),
26211
- receiptGeneration: integer42("receipt_generation").notNull().default(1),
26259
+ receiptGeneration: integer43("receipt_generation").notNull().default(1),
26212
26260
  // The pinned tuple. Every field here is compared against returned evidence, and each mismatch
26213
26261
  // has its own error code — "wrong repository" and "wrong head" are different recoveries.
26214
26262
  repositoryId: bigint6("repository_id", { mode: "number" }).notNull(),
26215
26263
  pullRequestId: bigint6("pull_request_id", { mode: "number" }).notNull(),
26216
- pullRequestNumber: integer42("pull_request_number").notNull(),
26264
+ pullRequestNumber: integer43("pull_request_number").notNull(),
26217
26265
  /** The exact commit this validation is about. A validation proves nothing about any other. */
26218
26266
  headSha: varchar65("head_sha", { length: 64 }).notNull(),
26219
26267
  baseSha: varchar65("base_sha", { length: 64 }).notNull(),
@@ -26222,25 +26270,25 @@ var orchestrationValidationEnvelopes = pgTable86(
26222
26270
  brandContractHash: varchar65("brand_contract_hash", { length: 64 }).notNull(),
26223
26271
  baselineDigest: varchar65("baseline_digest", { length: 71 }).notNull(),
26224
26272
  toolchainHash: varchar65("toolchain_hash", { length: 64 }).notNull(),
26225
- validatorVersion: text87("validator_version").notNull(),
26273
+ validatorVersion: text88("validator_version").notNull(),
26226
26274
  workflowSha256: varchar65("workflow_sha256", { length: 64 }).notNull(),
26227
26275
  /** Digest only. The single-use credential itself is handed to the validator and never stored. */
26228
26276
  nonceHash: varchar65("nonce_hash", { length: 64 }).notNull(),
26229
- nonceExpiresAt: timestamp79("nonce_expires_at", { withTimezone: true }).notNull(),
26230
- nonceConsumedAt: timestamp79("nonce_consumed_at", { withTimezone: true }),
26277
+ nonceExpiresAt: timestamp80("nonce_expires_at", { withTimezone: true }).notNull(),
26278
+ nonceConsumedAt: timestamp80("nonce_consumed_at", { withTimezone: true }),
26231
26279
  status: varchar65("status", { length: 20 }).notNull().default("queued"),
26232
- errorCode: text87("error_code"),
26233
- errorMessage: text87("error_message"),
26280
+ errorCode: text88("error_code"),
26281
+ errorMessage: text88("error_message"),
26234
26282
  /** Composite-FK'd to (evidence.id, evidence.envelope_id) in 0273, so an envelope cannot be
26235
26283
  * marked passed while pointing at a DIFFERENT envelope's evidence. */
26236
26284
  evidenceId: uuid7("evidence_id"),
26237
26285
  /** Written on pass, read by nothing. The unlock that consumes it is a later phase. */
26238
26286
  attestationDigest: varchar65("attestation_digest", { length: 71 }),
26239
- dispatchedAt: timestamp79("dispatched_at", { withTimezone: true }),
26287
+ dispatchedAt: timestamp80("dispatched_at", { withTimezone: true }),
26240
26288
  /** A retry is a NEW row with a NEW nonce, linked back — never a status reset on this one. */
26241
26289
  retryOf: uuid7("retry_of"),
26242
- createdAt: timestamp79("created_at", { withTimezone: true }).notNull().defaultNow(),
26243
- updatedAt: timestamp79("updated_at", { withTimezone: true }).notNull().defaultNow()
26290
+ createdAt: timestamp80("created_at", { withTimezone: true }).notNull().defaultNow(),
26291
+ updatedAt: timestamp80("updated_at", { withTimezone: true }).notNull().defaultNow()
26244
26292
  },
26245
26293
  (table) => [
26246
26294
  unique10("orchestration_validation_envelopes_scope_unique").on(
@@ -26248,7 +26296,7 @@ var orchestrationValidationEnvelopes = pgTable86(
26248
26296
  table.workspaceId,
26249
26297
  table.projectId
26250
26298
  ),
26251
- foreignKey10({
26299
+ foreignKey11({
26252
26300
  columns: [table.attemptId, table.workspaceId, table.projectId],
26253
26301
  foreignColumns: [
26254
26302
  orchestrationImplementationAttempts.id,
@@ -26257,7 +26305,7 @@ var orchestrationValidationEnvelopes = pgTable86(
26257
26305
  ],
26258
26306
  name: "orchestration_validation_envelopes_attempt_scope_fkey"
26259
26307
  }).onDelete("cascade"),
26260
- foreignKey10({
26308
+ foreignKey11({
26261
26309
  columns: [table.retryOf],
26262
26310
  foreignColumns: [table.id],
26263
26311
  name: "orchestration_validation_envelopes_retry_of_fkey"
@@ -26265,11 +26313,11 @@ var orchestrationValidationEnvelopes = pgTable86(
26265
26313
  // One live envelope per (attempt, head): two validators can never both be authoritative for
26266
26314
  // the same commit. The index arbitrates, so no read-then-write can lose the race.
26267
26315
  uniqueIndex38("orchestration_validation_envelopes_one_live_per_head").on(table.attemptId, table.headSha).where(sql24`status IN ('queued', 'dispatched', 'action_required')`),
26268
- index74("orchestration_validation_envelopes_attempt_idx").on(
26316
+ index75("orchestration_validation_envelopes_attempt_idx").on(
26269
26317
  table.attemptId,
26270
26318
  table.createdAt.desc()
26271
26319
  ),
26272
- index74("orchestration_validation_envelopes_sweep_idx").on(table.status, table.nonceExpiresAt).where(sql24`status IN ('queued', 'dispatched')`),
26320
+ index75("orchestration_validation_envelopes_sweep_idx").on(table.status, table.nonceExpiresAt).where(sql24`status IN ('queued', 'dispatched')`),
26273
26321
  check8(
26274
26322
  "orchestration_validation_envelopes_status_check",
26275
26323
  sql24`${table.status} IN ('queued', 'dispatched', 'action_required', 'passed', 'failed', 'superseded', 'timed_out', 'cancelled')`
@@ -26285,28 +26333,28 @@ var orchestrationValidationEnvelopes = pgTable86(
26285
26333
  )
26286
26334
  ]
26287
26335
  );
26288
- var orchestrationValidationEvidence = pgTable86(
26336
+ var orchestrationValidationEvidence = pgTable87(
26289
26337
  "orchestration_validation_evidence",
26290
26338
  {
26291
26339
  id: uuid7("id").primaryKey().defaultRandom(),
26292
- workspaceId: text87("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26293
- projectId: text87("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26340
+ workspaceId: text88("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26341
+ projectId: text88("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26294
26342
  runId: uuid7("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
26295
26343
  attemptId: uuid7("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
26296
26344
  envelopeId: uuid7("envelope_id").notNull().references(() => orchestrationValidationEnvelopes.id, { onDelete: "cascade" }),
26297
26345
  headSha: varchar65("head_sha", { length: 64 }).notNull(),
26298
26346
  evidenceDigest: varchar65("evidence_digest", { length: 71 }).notNull(),
26299
26347
  artifactDigest: varchar65("artifact_digest", { length: 71 }).notNull(),
26300
- validatorVersion: text87("validator_version").notNull(),
26348
+ validatorVersion: text88("validator_version").notNull(),
26301
26349
  /** The BrandKit contract this evidence is filed under. 0273 ties it to
26302
26350
  * `checks->brandKit->contractHash`, so a payload cannot claim a different one. Comparing it
26303
26351
  * against the ENVELOPE's hash is an ingest check — a CHECK cannot reach another table. */
26304
26352
  brandContractHash: varchar65("brand_contract_hash", { length: 64 }).notNull(),
26305
26353
  status: varchar65("status", { length: 10 }).notNull(),
26306
26354
  /** brandKit / runtime / visual. The shape is enforced by CHECK in 0273, not by the writer. */
26307
- checks: jsonb47("checks").notNull(),
26308
- createdBy: text87("created_by"),
26309
- createdAt: timestamp79("created_at", { withTimezone: true }).notNull().defaultNow()
26355
+ checks: jsonb49("checks").notNull(),
26356
+ createdBy: text88("created_by"),
26357
+ createdAt: timestamp80("created_at", { withTimezone: true }).notNull().defaultNow()
26310
26358
  },
26311
26359
  (table) => [
26312
26360
  unique10("orchestration_validation_evidence_scope_unique").on(
@@ -26314,7 +26362,7 @@ var orchestrationValidationEvidence = pgTable86(
26314
26362
  table.workspaceId,
26315
26363
  table.projectId
26316
26364
  ),
26317
- foreignKey10({
26365
+ foreignKey11({
26318
26366
  columns: [table.envelopeId, table.workspaceId, table.projectId],
26319
26367
  foreignColumns: [
26320
26368
  orchestrationValidationEnvelopes.id,
@@ -26333,7 +26381,7 @@ var orchestrationValidationEvidence = pgTable86(
26333
26381
  table.attemptId,
26334
26382
  table.evidenceDigest
26335
26383
  ),
26336
- index74("orchestration_validation_evidence_envelope_idx").on(table.envelopeId),
26384
+ index75("orchestration_validation_evidence_envelope_idx").on(table.envelopeId),
26337
26385
  check8(
26338
26386
  "orchestration_validation_evidence_status_check",
26339
26387
  sql24`${table.status} IN ('passed', 'failed')`
@@ -26343,27 +26391,27 @@ var orchestrationValidationEvidence = pgTable86(
26343
26391
 
26344
26392
  // src/schema/orchestration_executor_grants.ts
26345
26393
  import { sql as sql25 } from "drizzle-orm";
26346
- import { check as check9, foreignKey as foreignKey11, index as index75, integer as integer43, pgTable as pgTable87, text as text88, timestamp as timestamp80, unique as unique11, uniqueIndex as uniqueIndex39, uuid as uuid8, varchar as varchar66 } from "drizzle-orm/pg-core";
26394
+ import { check as check9, foreignKey as foreignKey12, index as index76, integer as integer44, pgTable as pgTable88, text as text89, timestamp as timestamp81, unique as unique11, uniqueIndex as uniqueIndex39, uuid as uuid8, varchar as varchar66 } from "drizzle-orm/pg-core";
26347
26395
  var EXECUTOR_GRANT_STATUSES = ["active", "revoked", "expired"];
26348
- var orchestrationExecutorGrants = pgTable87(
26396
+ var orchestrationExecutorGrants = pgTable88(
26349
26397
  "orchestration_executor_grants",
26350
26398
  {
26351
- id: text88("id").primaryKey().default(sql25`gen_random_uuid()`),
26352
- workspaceId: text88("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26353
- projectId: text88("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26399
+ id: text89("id").primaryKey().default(sql25`gen_random_uuid()`),
26400
+ workspaceId: text89("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26401
+ projectId: text89("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26354
26402
  installationId: uuid8("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
26355
26403
  /** Digest only. The credential is returned once at mint and never stored. */
26356
26404
  credentialHash: varchar66("credential_hash", { length: 64 }).notNull(),
26357
- credentialAudience: text88("credential_audience").notNull(),
26358
- credentialExpiresAt: timestamp80("credential_expires_at", { withTimezone: true }).notNull(),
26405
+ credentialAudience: text89("credential_audience").notNull(),
26406
+ credentialExpiresAt: timestamp81("credential_expires_at", { withTimezone: true }).notNull(),
26359
26407
  /** The epoch this credential is valid for. A fenced session's credential dies before it expires. */
26360
- sessionEpoch: integer43("session_epoch").notNull(),
26408
+ sessionEpoch: integer44("session_epoch").notNull(),
26361
26409
  status: varchar66("status", { length: 16 }).notNull().default("active"),
26362
- revokedAt: timestamp80("revoked_at", { withTimezone: true }),
26363
- revokedBy: text88("revoked_by"),
26364
- createdBy: text88("created_by"),
26365
- createdAt: timestamp80("created_at", { withTimezone: true }).notNull().defaultNow(),
26366
- updatedAt: timestamp80("updated_at", { withTimezone: true }).notNull().defaultNow()
26410
+ revokedAt: timestamp81("revoked_at", { withTimezone: true }),
26411
+ revokedBy: text89("revoked_by"),
26412
+ createdBy: text89("created_by"),
26413
+ createdAt: timestamp81("created_at", { withTimezone: true }).notNull().defaultNow(),
26414
+ updatedAt: timestamp81("updated_at", { withTimezone: true }).notNull().defaultNow()
26367
26415
  },
26368
26416
  (table) => [
26369
26417
  unique11("orchestration_executor_grants_scope_unique").on(
@@ -26371,7 +26419,7 @@ var orchestrationExecutorGrants = pgTable87(
26371
26419
  table.workspaceId,
26372
26420
  table.projectId
26373
26421
  ),
26374
- foreignKey11({
26422
+ foreignKey12({
26375
26423
  columns: [table.installationId, table.workspaceId, table.projectId],
26376
26424
  foreignColumns: [
26377
26425
  orchestrationExecutorInstallations.id,
@@ -26383,7 +26431,7 @@ var orchestrationExecutorGrants = pgTable87(
26383
26431
  // One live credential per installation. Two would mean two processes can each present a valid
26384
26432
  // one, and the exclusion argument collapses before the lease layer is reached.
26385
26433
  uniqueIndex39("orchestration_executor_grants_one_active_per_installation").on(table.installationId).where(sql25`status = 'active'`),
26386
- index75("orchestration_executor_grants_credential_idx").on(table.workspaceId, table.credentialHash).where(sql25`status = 'active'`),
26434
+ index76("orchestration_executor_grants_credential_idx").on(table.workspaceId, table.credentialHash).where(sql25`status = 'active'`),
26387
26435
  check9(
26388
26436
  "orchestration_executor_grants_status_check",
26389
26437
  sql25`${table.status} IN ('active', 'revoked', 'expired')`
@@ -26396,27 +26444,27 @@ var orchestrationExecutorGrants = pgTable87(
26396
26444
  );
26397
26445
 
26398
26446
  // src/schema/component_presets.ts
26399
- import { pgTable as pgTable88, text as text89, varchar as varchar67, timestamp as timestamp81, jsonb as jsonb48, integer as integer44, index as index76, uniqueIndex as uniqueIndex40 } from "drizzle-orm/pg-core";
26447
+ import { pgTable as pgTable89, text as text90, varchar as varchar67, timestamp as timestamp82, jsonb as jsonb50, integer as integer45, index as index77, uniqueIndex as uniqueIndex40 } from "drizzle-orm/pg-core";
26400
26448
  import { relations as relations16 } from "drizzle-orm";
26401
- var componentPresets = pgTable88(
26449
+ var componentPresets = pgTable89(
26402
26450
  "component_presets",
26403
26451
  {
26404
- id: text89("id").primaryKey(),
26405
- workspaceId: text89("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26406
- componentId: text89("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
26452
+ id: text90("id").primaryKey(),
26453
+ workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26454
+ componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
26407
26455
  name: varchar67("name", { length: 255 }).notNull(),
26408
26456
  /** ^[a-z0-9-]+$, unique per component — stable across renames. */
26409
26457
  slug: varchar67("slug", { length: 255 }).notNull(),
26410
26458
  /** Prop key → value. Validated against the component's `props` on every write. */
26411
- values: jsonb48("values").$type().notNull().default({}),
26412
- position: integer44("position").notNull().default(0),
26413
- createdAt: timestamp81("created_at").notNull().defaultNow(),
26414
- updatedAt: timestamp81("updated_at").notNull().defaultNow(),
26415
- createdBy: text89("created_by"),
26416
- updatedBy: text89("updated_by")
26459
+ values: jsonb50("values").$type().notNull().default({}),
26460
+ position: integer45("position").notNull().default(0),
26461
+ createdAt: timestamp82("created_at").notNull().defaultNow(),
26462
+ updatedAt: timestamp82("updated_at").notNull().defaultNow(),
26463
+ createdBy: text90("created_by"),
26464
+ updatedBy: text90("updated_by")
26417
26465
  },
26418
26466
  (t) => [
26419
- index76("component_presets_component_position_idx").on(t.componentId, t.position, t.createdAt, t.id),
26467
+ index77("component_presets_component_position_idx").on(t.componentId, t.position, t.createdAt, t.id),
26420
26468
  uniqueIndex40("component_presets_component_slug_key").on(t.componentId, t.slug)
26421
26469
  ]
26422
26470
  );
@@ -26429,13 +26477,13 @@ var componentPresetsRelations = relations16(componentPresets, ({ one }) => ({
26429
26477
 
26430
26478
  // src/schema/section_zones.ts
26431
26479
  import {
26432
- foreignKey as foreignKey12,
26433
- index as index77,
26434
- integer as integer45,
26435
- jsonb as jsonb49,
26436
- pgTable as pgTable89,
26437
- text as text90,
26438
- timestamp as timestamp82,
26480
+ foreignKey as foreignKey13,
26481
+ index as index78,
26482
+ integer as integer46,
26483
+ jsonb as jsonb51,
26484
+ pgTable as pgTable90,
26485
+ text as text91,
26486
+ timestamp as timestamp83,
26439
26487
  unique as unique12,
26440
26488
  uniqueIndex as uniqueIndex41,
26441
26489
  varchar as varchar68
@@ -26449,50 +26497,50 @@ var SECTION_IMPLEMENTATION_REQUEST_STATUSES = [
26449
26497
  "passed",
26450
26498
  "failed"
26451
26499
  ];
26452
- var sectionDefinitions = pgTable89(
26500
+ var sectionDefinitions = pgTable90(
26453
26501
  "section_definitions",
26454
26502
  {
26455
- id: text90("id").primaryKey(),
26456
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26457
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26503
+ id: text91("id").primaryKey(),
26504
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26505
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26458
26506
  apiId: varchar68("api_id", { length: 100 }).notNull(),
26459
- firstPublishedAt: timestamp82("first_published_at"),
26460
- archivedAt: timestamp82("archived_at"),
26507
+ firstPublishedAt: timestamp83("first_published_at"),
26508
+ archivedAt: timestamp83("archived_at"),
26461
26509
  ...auditColumns
26462
26510
  },
26463
26511
  (table) => [
26464
- foreignKey12({
26512
+ foreignKey13({
26465
26513
  columns: [table.projectId, table.workspaceId],
26466
26514
  foreignColumns: [projects.id, projects.workspaceId],
26467
26515
  name: "section_definitions_project_workspace_fkey"
26468
26516
  }).onDelete("cascade").onUpdate("cascade"),
26469
26517
  unique12("section_definitions_id_project_unique").on(table.id, table.projectId),
26470
26518
  uniqueIndex41("section_definitions_project_api_id_unique").on(table.projectId, table.apiId),
26471
- index77("section_definitions_workspace_idx").on(table.workspaceId),
26472
- index77("section_definitions_project_idx").on(table.projectId)
26519
+ index78("section_definitions_workspace_idx").on(table.workspaceId),
26520
+ index78("section_definitions_project_idx").on(table.projectId)
26473
26521
  ]
26474
26522
  );
26475
- var sectionDefinitionVersions = pgTable89(
26523
+ var sectionDefinitionVersions = pgTable90(
26476
26524
  "section_definition_versions",
26477
26525
  {
26478
- id: text90("id").primaryKey(),
26479
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26480
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26481
- sectionDefinitionId: text90("section_definition_id").notNull(),
26482
- version: integer45("version").notNull(),
26526
+ id: text91("id").primaryKey(),
26527
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26528
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26529
+ sectionDefinitionId: text91("section_definition_id").notNull(),
26530
+ version: integer46("version").notNull(),
26483
26531
  label: varchar68("label", { length: 255 }).notNull(),
26484
- fields: jsonb49("fields").$type().notNull().default([]),
26532
+ fields: jsonb51("fields").$type().notNull().default([]),
26485
26533
  schemaHash: varchar68("schema_hash", { length: 64 }).notNull(),
26486
- createdBy: text90("created_by"),
26487
- createdAt: timestamp82("created_at").notNull().defaultNow()
26534
+ createdBy: text91("created_by"),
26535
+ createdAt: timestamp83("created_at").notNull().defaultNow()
26488
26536
  },
26489
26537
  (table) => [
26490
- foreignKey12({
26538
+ foreignKey13({
26491
26539
  columns: [table.projectId, table.workspaceId],
26492
26540
  foreignColumns: [projects.id, projects.workspaceId],
26493
26541
  name: "section_definition_versions_project_workspace_fkey"
26494
26542
  }).onDelete("cascade").onUpdate("cascade"),
26495
- foreignKey12({
26543
+ foreignKey13({
26496
26544
  columns: [table.sectionDefinitionId, table.projectId],
26497
26545
  foreignColumns: [sectionDefinitions.id, sectionDefinitions.projectId],
26498
26546
  name: "section_definition_versions_definition_project_fkey"
@@ -26503,63 +26551,63 @@ var sectionDefinitionVersions = pgTable89(
26503
26551
  table.version,
26504
26552
  table.projectId
26505
26553
  ),
26506
- index77("section_definition_versions_project_idx").on(table.projectId)
26554
+ index78("section_definition_versions_project_idx").on(table.projectId)
26507
26555
  ]
26508
26556
  );
26509
- var sectionZones = pgTable89(
26557
+ var sectionZones = pgTable90(
26510
26558
  "section_zones",
26511
26559
  {
26512
- id: text90("id").primaryKey(),
26513
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26514
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26560
+ id: text91("id").primaryKey(),
26561
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26562
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26515
26563
  schemaKind: varchar68("schema_kind", { length: 20 }).$type().notNull(),
26516
- schemaId: text90("schema_id").notNull(),
26564
+ schemaId: text91("schema_id").notNull(),
26517
26565
  fieldKey: varchar68("field_key", { length: 255 }).notNull(),
26518
- draftRevision: integer45("draft_revision").notNull().default(1),
26519
- publishedRevision: integer45("published_revision"),
26566
+ draftRevision: integer46("draft_revision").notNull().default(1),
26567
+ publishedRevision: integer46("published_revision"),
26520
26568
  ...auditColumns
26521
26569
  },
26522
26570
  (table) => [
26523
- foreignKey12({
26571
+ foreignKey13({
26524
26572
  columns: [table.projectId, table.workspaceId],
26525
26573
  foreignColumns: [projects.id, projects.workspaceId],
26526
26574
  name: "section_zones_project_workspace_fkey"
26527
26575
  }).onDelete("cascade").onUpdate("cascade"),
26528
26576
  unique12("section_zones_id_project_unique").on(table.id, table.projectId),
26529
26577
  uniqueIndex41("section_zones_schema_owner_unique").on(table.projectId, table.schemaKind, table.schemaId),
26530
- index77("section_zones_workspace_idx").on(table.workspaceId)
26578
+ index78("section_zones_workspace_idx").on(table.workspaceId)
26531
26579
  ]
26532
26580
  );
26533
- var sectionZoneAttachments = pgTable89(
26581
+ var sectionZoneAttachments = pgTable90(
26534
26582
  "section_zone_attachments",
26535
26583
  {
26536
- id: text90("id").primaryKey(),
26537
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26538
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26539
- zoneId: text90("zone_id").notNull(),
26540
- sectionDefinitionId: text90("section_definition_id").notNull(),
26541
- draftVersion: integer45("draft_version").notNull(),
26542
- publishedVersion: integer45("published_version"),
26543
- position: integer45("position").notNull().default(0),
26584
+ id: text91("id").primaryKey(),
26585
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26586
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26587
+ zoneId: text91("zone_id").notNull(),
26588
+ sectionDefinitionId: text91("section_definition_id").notNull(),
26589
+ draftVersion: integer46("draft_version").notNull(),
26590
+ publishedVersion: integer46("published_version"),
26591
+ position: integer46("position").notNull().default(0),
26544
26592
  ...auditColumns
26545
26593
  },
26546
26594
  (table) => [
26547
- foreignKey12({
26595
+ foreignKey13({
26548
26596
  columns: [table.projectId, table.workspaceId],
26549
26597
  foreignColumns: [projects.id, projects.workspaceId],
26550
26598
  name: "section_zone_attachments_project_workspace_fkey"
26551
26599
  }).onDelete("cascade").onUpdate("cascade"),
26552
- foreignKey12({
26600
+ foreignKey13({
26553
26601
  columns: [table.zoneId, table.projectId],
26554
26602
  foreignColumns: [sectionZones.id, sectionZones.projectId],
26555
26603
  name: "section_zone_attachments_zone_project_fkey"
26556
26604
  }).onDelete("cascade"),
26557
- foreignKey12({
26605
+ foreignKey13({
26558
26606
  columns: [table.sectionDefinitionId, table.projectId],
26559
26607
  foreignColumns: [sectionDefinitions.id, sectionDefinitions.projectId],
26560
26608
  name: "section_zone_attachments_definition_project_fkey"
26561
26609
  }).onDelete("restrict"),
26562
- foreignKey12({
26610
+ foreignKey13({
26563
26611
  columns: [table.sectionDefinitionId, table.draftVersion, table.projectId],
26564
26612
  foreignColumns: [
26565
26613
  sectionDefinitionVersions.sectionDefinitionId,
@@ -26568,7 +26616,7 @@ var sectionZoneAttachments = pgTable89(
26568
26616
  ],
26569
26617
  name: "section_zone_attachments_draft_version_fkey"
26570
26618
  }).onDelete("restrict"),
26571
- foreignKey12({
26619
+ foreignKey13({
26572
26620
  columns: [table.sectionDefinitionId, table.publishedVersion, table.projectId],
26573
26621
  foreignColumns: [
26574
26622
  sectionDefinitionVersions.sectionDefinitionId,
@@ -26578,31 +26626,31 @@ var sectionZoneAttachments = pgTable89(
26578
26626
  name: "section_zone_attachments_published_version_fkey"
26579
26627
  }).onDelete("restrict"),
26580
26628
  uniqueIndex41("section_zone_attachments_zone_definition_unique").on(table.zoneId, table.sectionDefinitionId),
26581
- index77("section_zone_attachments_zone_position_idx").on(table.zoneId, table.position, table.id)
26629
+ index78("section_zone_attachments_zone_position_idx").on(table.zoneId, table.position, table.id)
26582
26630
  ]
26583
26631
  );
26584
- var sectionManifests = pgTable89(
26632
+ var sectionManifests = pgTable90(
26585
26633
  "section_manifests",
26586
26634
  {
26587
- id: text90("id").primaryKey(),
26588
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26589
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26590
- sectionDefinitionId: text90("section_definition_id").notNull(),
26591
- sectionVersion: integer45("section_version").notNull(),
26635
+ id: text91("id").primaryKey(),
26636
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26637
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26638
+ sectionDefinitionId: text91("section_definition_id").notNull(),
26639
+ sectionVersion: integer46("section_version").notNull(),
26592
26640
  apiId: varchar68("api_id", { length: 100 }).notNull(),
26593
26641
  schemaHash: varchar68("schema_hash", { length: 64 }).notNull(),
26594
26642
  commitSha: varchar68("commit_sha", { length: 64 }).notNull(),
26595
- manifest: jsonb49("manifest").$type().notNull(),
26596
- createdBy: text90("created_by"),
26597
- createdAt: timestamp82("created_at").notNull().defaultNow()
26643
+ manifest: jsonb51("manifest").$type().notNull(),
26644
+ createdBy: text91("created_by"),
26645
+ createdAt: timestamp83("created_at").notNull().defaultNow()
26598
26646
  },
26599
26647
  (table) => [
26600
- foreignKey12({
26648
+ foreignKey13({
26601
26649
  columns: [table.projectId, table.workspaceId],
26602
26650
  foreignColumns: [projects.id, projects.workspaceId],
26603
26651
  name: "section_manifests_project_workspace_fkey"
26604
26652
  }).onDelete("cascade").onUpdate("cascade"),
26605
- foreignKey12({
26653
+ foreignKey13({
26606
26654
  columns: [table.sectionDefinitionId, table.sectionVersion, table.projectId],
26607
26655
  foreignColumns: [
26608
26656
  sectionDefinitionVersions.sectionDefinitionId,
@@ -26612,34 +26660,34 @@ var sectionManifests = pgTable89(
26612
26660
  name: "section_manifests_definition_version_project_fkey"
26613
26661
  }).onDelete("cascade"),
26614
26662
  unique12("section_manifests_id_project_unique").on(table.id, table.projectId),
26615
- index77("section_manifests_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
26663
+ index78("section_manifests_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
26616
26664
  ]
26617
26665
  );
26618
- var sectionValidationRuns = pgTable89(
26666
+ var sectionValidationRuns = pgTable90(
26619
26667
  "section_validation_runs",
26620
26668
  {
26621
- id: text90("id").primaryKey(),
26622
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26623
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26624
- sectionDefinitionId: text90("section_definition_id").notNull(),
26625
- sectionVersion: integer45("section_version").notNull(),
26626
- manifestId: text90("manifest_id").notNull(),
26669
+ id: text91("id").primaryKey(),
26670
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26671
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26672
+ sectionDefinitionId: text91("section_definition_id").notNull(),
26673
+ sectionVersion: integer46("section_version").notNull(),
26674
+ manifestId: text91("manifest_id").notNull(),
26627
26675
  status: varchar68("status", { length: 20 }).$type().notNull(),
26628
26676
  schemaHash: varchar68("schema_hash", { length: 64 }).notNull(),
26629
26677
  commitSha: varchar68("commit_sha", { length: 64 }).notNull(),
26630
26678
  fixtureHash: varchar68("fixture_hash", { length: 64 }).notNull(),
26631
26679
  evidenceDigest: varchar68("evidence_digest", { length: 128 }).notNull(),
26632
- results: jsonb49("results").$type().notNull(),
26633
- createdBy: text90("created_by"),
26634
- createdAt: timestamp82("created_at").notNull().defaultNow()
26680
+ results: jsonb51("results").$type().notNull(),
26681
+ createdBy: text91("created_by"),
26682
+ createdAt: timestamp83("created_at").notNull().defaultNow()
26635
26683
  },
26636
26684
  (table) => [
26637
- foreignKey12({
26685
+ foreignKey13({
26638
26686
  columns: [table.projectId, table.workspaceId],
26639
26687
  foreignColumns: [projects.id, projects.workspaceId],
26640
26688
  name: "section_validation_runs_project_workspace_fkey"
26641
26689
  }).onDelete("cascade").onUpdate("cascade"),
26642
- foreignKey12({
26690
+ foreignKey13({
26643
26691
  columns: [table.sectionDefinitionId, table.sectionVersion, table.projectId],
26644
26692
  foreignColumns: [
26645
26693
  sectionDefinitionVersions.sectionDefinitionId,
@@ -26648,39 +26696,39 @@ var sectionValidationRuns = pgTable89(
26648
26696
  ],
26649
26697
  name: "section_validation_runs_definition_version_project_fkey"
26650
26698
  }).onDelete("cascade").onUpdate("cascade"),
26651
- foreignKey12({
26699
+ foreignKey13({
26652
26700
  columns: [table.manifestId, table.projectId],
26653
26701
  foreignColumns: [sectionManifests.id, sectionManifests.projectId],
26654
26702
  name: "section_validation_runs_manifest_project_fkey"
26655
26703
  }).onDelete("restrict"),
26656
26704
  unique12("section_validation_runs_id_project_unique").on(table.id, table.projectId),
26657
- index77("section_validation_runs_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
26705
+ index78("section_validation_runs_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
26658
26706
  ]
26659
26707
  );
26660
- var sectionVisualApprovals = pgTable89(
26708
+ var sectionVisualApprovals = pgTable90(
26661
26709
  "section_visual_approvals",
26662
26710
  {
26663
- id: text90("id").primaryKey(),
26664
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26665
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26666
- sectionDefinitionId: text90("section_definition_id").notNull(),
26667
- sectionVersion: integer45("section_version").notNull(),
26668
- manifestId: text90("manifest_id").notNull(),
26669
- validationRunId: text90("validation_run_id").notNull(),
26711
+ id: text91("id").primaryKey(),
26712
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26713
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26714
+ sectionDefinitionId: text91("section_definition_id").notNull(),
26715
+ sectionVersion: integer46("section_version").notNull(),
26716
+ manifestId: text91("manifest_id").notNull(),
26717
+ validationRunId: text91("validation_run_id").notNull(),
26670
26718
  schemaHash: varchar68("schema_hash", { length: 64 }).notNull(),
26671
26719
  commitSha: varchar68("commit_sha", { length: 64 }).notNull(),
26672
26720
  fixtureHash: varchar68("fixture_hash", { length: 64 }).notNull(),
26673
26721
  evidenceDigest: varchar68("evidence_digest", { length: 128 }).notNull(),
26674
- approvedBy: text90("approved_by").notNull(),
26675
- createdAt: timestamp82("created_at").notNull().defaultNow()
26722
+ approvedBy: text91("approved_by").notNull(),
26723
+ createdAt: timestamp83("created_at").notNull().defaultNow()
26676
26724
  },
26677
26725
  (table) => [
26678
- foreignKey12({
26726
+ foreignKey13({
26679
26727
  columns: [table.projectId, table.workspaceId],
26680
26728
  foreignColumns: [projects.id, projects.workspaceId],
26681
26729
  name: "section_visual_approvals_project_workspace_fkey"
26682
26730
  }).onDelete("cascade").onUpdate("cascade"),
26683
- foreignKey12({
26731
+ foreignKey13({
26684
26732
  columns: [table.sectionDefinitionId, table.sectionVersion, table.projectId],
26685
26733
  foreignColumns: [
26686
26734
  sectionDefinitionVersions.sectionDefinitionId,
@@ -26689,54 +26737,54 @@ var sectionVisualApprovals = pgTable89(
26689
26737
  ],
26690
26738
  name: "section_visual_approvals_definition_version_project_fkey"
26691
26739
  }).onDelete("cascade").onUpdate("cascade"),
26692
- foreignKey12({
26740
+ foreignKey13({
26693
26741
  columns: [table.manifestId, table.projectId],
26694
26742
  foreignColumns: [sectionManifests.id, sectionManifests.projectId],
26695
26743
  name: "section_visual_approvals_manifest_project_fkey"
26696
26744
  }).onDelete("restrict"),
26697
- foreignKey12({
26745
+ foreignKey13({
26698
26746
  columns: [table.validationRunId, table.projectId],
26699
26747
  foreignColumns: [sectionValidationRuns.id, sectionValidationRuns.projectId],
26700
26748
  name: "section_visual_approvals_validation_project_fkey"
26701
26749
  }).onDelete("restrict"),
26702
- index77("section_visual_approvals_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
26750
+ index78("section_visual_approvals_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
26703
26751
  ]
26704
26752
  );
26705
- var sectionImplementationRequests = pgTable89(
26753
+ var sectionImplementationRequests = pgTable90(
26706
26754
  "section_implementation_requests",
26707
26755
  {
26708
- id: text90("id").primaryKey(),
26709
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26710
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26711
- sectionDefinitionId: text90("section_definition_id").notNull(),
26712
- sectionVersion: integer45("section_version").notNull(),
26756
+ id: text91("id").primaryKey(),
26757
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26758
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26759
+ sectionDefinitionId: text91("section_definition_id").notNull(),
26760
+ sectionVersion: integer46("section_version").notNull(),
26713
26761
  provider: varchar68("provider", { length: 20 }).$type().notNull(),
26714
26762
  status: varchar68("status", { length: 20 }).$type().notNull().default("queued"),
26715
26763
  schemaHash: varchar68("schema_hash", { length: 64 }).notNull(),
26716
26764
  targetCommitSha: varchar68("target_commit_sha", { length: 64 }),
26717
26765
  providerRunId: varchar68("provider_run_id", { length: 255 }),
26718
- providerRunUrl: text90("provider_run_url"),
26719
- manifestId: text90("manifest_id"),
26720
- validationRunId: text90("validation_run_id"),
26766
+ providerRunUrl: text91("provider_run_url"),
26767
+ manifestId: text91("manifest_id"),
26768
+ validationRunId: text91("validation_run_id"),
26721
26769
  /** SHA-256 of the request-scoped GitHub callback bearer. The plaintext is never persisted. */
26722
26770
  callbackTokenHash: varchar68("callback_token_hash", { length: 64 }),
26723
- requestedBy: text90("requested_by").notNull(),
26724
- claimedBy: text90("claimed_by"),
26771
+ requestedBy: text91("requested_by").notNull(),
26772
+ claimedBy: text91("claimed_by"),
26725
26773
  errorCode: varchar68("error_code", { length: 100 }),
26726
- errorMessage: text90("error_message"),
26727
- dispatchedAt: timestamp82("dispatched_at"),
26728
- startedAt: timestamp82("started_at"),
26729
- completedAt: timestamp82("completed_at"),
26730
- createdAt: timestamp82("created_at").notNull().defaultNow(),
26731
- updatedAt: timestamp82("updated_at").notNull().defaultNow()
26774
+ errorMessage: text91("error_message"),
26775
+ dispatchedAt: timestamp83("dispatched_at"),
26776
+ startedAt: timestamp83("started_at"),
26777
+ completedAt: timestamp83("completed_at"),
26778
+ createdAt: timestamp83("created_at").notNull().defaultNow(),
26779
+ updatedAt: timestamp83("updated_at").notNull().defaultNow()
26732
26780
  },
26733
26781
  (table) => [
26734
- foreignKey12({
26782
+ foreignKey13({
26735
26783
  columns: [table.projectId, table.workspaceId],
26736
26784
  foreignColumns: [projects.id, projects.workspaceId],
26737
26785
  name: "section_implementation_requests_project_workspace_fkey"
26738
26786
  }).onDelete("cascade").onUpdate("cascade"),
26739
- foreignKey12({
26787
+ foreignKey13({
26740
26788
  columns: [table.sectionDefinitionId, table.sectionVersion, table.projectId],
26741
26789
  foreignColumns: [
26742
26790
  sectionDefinitionVersions.sectionDefinitionId,
@@ -26745,51 +26793,51 @@ var sectionImplementationRequests = pgTable89(
26745
26793
  ],
26746
26794
  name: "section_implementation_requests_definition_version_project_fkey"
26747
26795
  }).onDelete("cascade"),
26748
- foreignKey12({
26796
+ foreignKey13({
26749
26797
  columns: [table.manifestId, table.projectId],
26750
26798
  foreignColumns: [sectionManifests.id, sectionManifests.projectId],
26751
26799
  name: "section_implementation_requests_manifest_project_fkey"
26752
26800
  }).onDelete("restrict"),
26753
- foreignKey12({
26801
+ foreignKey13({
26754
26802
  columns: [table.validationRunId, table.projectId],
26755
26803
  foreignColumns: [sectionValidationRuns.id, sectionValidationRuns.projectId],
26756
26804
  name: "section_implementation_requests_validation_project_fkey"
26757
26805
  }).onDelete("restrict"),
26758
26806
  unique12("section_implementation_requests_id_project_unique").on(table.id, table.projectId),
26759
26807
  uniqueIndex41("section_implementation_requests_one_active_unique").on(table.projectId, table.sectionDefinitionId, table.sectionVersion, table.schemaHash).where(sql26`${table.status} IN ('queued', 'dispatching', 'dispatched', 'running')`),
26760
- index77("section_implementation_requests_project_created_idx").on(table.projectId, table.createdAt)
26808
+ index78("section_implementation_requests_project_created_idx").on(table.projectId, table.createdAt)
26761
26809
  ]
26762
26810
  );
26763
- var sectionZoneReleases = pgTable89(
26811
+ var sectionZoneReleases = pgTable90(
26764
26812
  "section_zone_releases",
26765
26813
  {
26766
- id: text90("id").primaryKey(),
26767
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26768
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26769
- zoneId: text90("zone_id").notNull(),
26770
- revision: integer45("revision").notNull(),
26771
- snapshot: jsonb49("snapshot").$type().notNull(),
26772
- publishedBy: text90("published_by").notNull(),
26773
- publishedAt: timestamp82("published_at").notNull().defaultNow()
26814
+ id: text91("id").primaryKey(),
26815
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
26816
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
26817
+ zoneId: text91("zone_id").notNull(),
26818
+ revision: integer46("revision").notNull(),
26819
+ snapshot: jsonb51("snapshot").$type().notNull(),
26820
+ publishedBy: text91("published_by").notNull(),
26821
+ publishedAt: timestamp83("published_at").notNull().defaultNow()
26774
26822
  },
26775
26823
  (table) => [
26776
- foreignKey12({
26824
+ foreignKey13({
26777
26825
  columns: [table.projectId, table.workspaceId],
26778
26826
  foreignColumns: [projects.id, projects.workspaceId],
26779
26827
  name: "section_zone_releases_project_workspace_fkey"
26780
26828
  }).onDelete("cascade").onUpdate("cascade"),
26781
- foreignKey12({
26829
+ foreignKey13({
26782
26830
  columns: [table.zoneId, table.projectId],
26783
26831
  foreignColumns: [sectionZones.id, sectionZones.projectId],
26784
26832
  name: "section_zone_releases_zone_project_fkey"
26785
26833
  }).onDelete("cascade"),
26786
26834
  unique12("section_zone_releases_zone_revision_unique").on(table.zoneId, table.revision),
26787
- index77("section_zone_releases_project_published_idx").on(table.projectId, table.publishedAt)
26835
+ index78("section_zone_releases_project_published_idx").on(table.projectId, table.publishedAt)
26788
26836
  ]
26789
26837
  );
26790
26838
 
26791
26839
  // src/schema/content_locks.ts
26792
- import { check as check10, index as index78, jsonb as jsonb50, pgTable as pgTable90, text as text91, timestamp as timestamp83 } from "drizzle-orm/pg-core";
26840
+ import { check as check10, index as index79, jsonb as jsonb52, pgTable as pgTable91, text as text92, timestamp as timestamp84 } from "drizzle-orm/pg-core";
26793
26841
  import { sql as sql27 } from "drizzle-orm";
26794
26842
  var CONTENT_LOCK_TARGET_KINDS = [
26795
26843
  "page",
@@ -26798,30 +26846,30 @@ var CONTENT_LOCK_TARGET_KINDS = [
26798
26846
  "component_definition"
26799
26847
  ];
26800
26848
  var CONTENT_LOCK_MODES = ["all", "agents"];
26801
- var contentLocks = pgTable90(
26849
+ var contentLocks = pgTable91(
26802
26850
  "content_locks",
26803
26851
  {
26804
- id: text91("id").primaryKey(),
26805
- workspaceId: text91("workspace_id").notNull(),
26806
- projectId: text91("project_id").notNull(),
26807
- targetKind: text91("target_kind").$type().notNull(),
26808
- targetId: text91("target_id").notNull(),
26809
- blockId: text91("block_id"),
26852
+ id: text92("id").primaryKey(),
26853
+ workspaceId: text92("workspace_id").notNull(),
26854
+ projectId: text92("project_id").notNull(),
26855
+ targetKind: text92("target_kind").$type().notNull(),
26856
+ targetId: text92("target_id").notNull(),
26857
+ blockId: text92("block_id"),
26810
26858
  // Deterministic structural path plus block ancestry captured when the lock is created.
26811
26859
  // Nullable so Wave 5 remains compatible with locks created before this fingerprint existed.
26812
- blockFingerprint: jsonb50("block_fingerprint").$type(),
26813
- fieldPath: text91("field_path").array(),
26814
- mode: text91("mode").$type().notNull().default("all"),
26815
- reason: text91("reason"),
26816
- createdBy: text91("created_by").notNull(),
26817
- createdAt: timestamp83("created_at").notNull().defaultNow(),
26818
- releasedBy: text91("released_by"),
26819
- releasedAt: timestamp83("released_at")
26860
+ blockFingerprint: jsonb52("block_fingerprint").$type(),
26861
+ fieldPath: text92("field_path").array(),
26862
+ mode: text92("mode").$type().notNull().default("all"),
26863
+ reason: text92("reason"),
26864
+ createdBy: text92("created_by").notNull(),
26865
+ createdAt: timestamp84("created_at").notNull().defaultNow(),
26866
+ releasedBy: text92("released_by"),
26867
+ releasedAt: timestamp84("released_at")
26820
26868
  },
26821
26869
  (table) => [
26822
- index78("content_locks_workspace_idx").on(table.workspaceId),
26823
- index78("content_locks_project_idx").on(table.projectId),
26824
- index78("content_locks_target_idx").on(table.targetKind, table.targetId).where(sql27`${table.releasedAt} IS NULL`),
26870
+ index79("content_locks_workspace_idx").on(table.workspaceId),
26871
+ index79("content_locks_project_idx").on(table.projectId),
26872
+ index79("content_locks_target_idx").on(table.targetKind, table.targetId).where(sql27`${table.releasedAt} IS NULL`),
26825
26873
  check10("content_locks_target_kind_check", sql27`${table.targetKind} IN ('page','content_entry','singleton_entry','component_definition')`),
26826
26874
  check10("content_locks_mode_check", sql27`${table.mode} IN ('all','agents')`)
26827
26875
  // `content_locks_shape_check` lives in migration 0192 ONLY: it calls
@@ -26837,75 +26885,75 @@ var contentLocks = pgTable90(
26837
26885
 
26838
26886
  // src/schema/project_transfers.ts
26839
26887
  import {
26840
- pgTable as pgTable91,
26841
- text as text92,
26888
+ pgTable as pgTable92,
26889
+ text as text93,
26842
26890
  varchar as varchar69,
26843
- timestamp as timestamp84,
26844
- index as index79,
26891
+ timestamp as timestamp85,
26892
+ index as index80,
26845
26893
  uniqueIndex as uniqueIndex42
26846
26894
  } from "drizzle-orm/pg-core";
26847
26895
  import { sql as sql28 } from "drizzle-orm";
26848
- var projectTransfers = pgTable91(
26896
+ var projectTransfers = pgTable92(
26849
26897
  "project_transfers",
26850
26898
  {
26851
- id: text92("id").primaryKey(),
26899
+ id: text93("id").primaryKey(),
26852
26900
  // nanoid
26853
- token: text92("token").notNull(),
26901
+ token: text93("token").notNull(),
26854
26902
  // nanoid(32) — recipient handshake / magic link
26855
26903
  status: varchar69("status", { length: 20 }).notNull().default("pending"),
26856
26904
  // pending | accepted (transient) | completed | declined | cancelled | expired | failed
26857
- projectId: text92("project_id").notNull(),
26905
+ projectId: text93("project_id").notNull(),
26858
26906
  // FK → projects.id (ON DELETE CASCADE, via migration)
26859
- fromWorkspaceId: text92("from_workspace_id").notNull(),
26907
+ fromWorkspaceId: text93("from_workspace_id").notNull(),
26860
26908
  // FK → workspaces.id (source)
26861
- toWorkspaceId: text92("to_workspace_id"),
26909
+ toWorkspaceId: text93("to_workspace_id"),
26862
26910
  // FK → workspaces.id — resolved at accept (null while pending)
26863
- initiatedBy: text92("initiated_by").notNull(),
26911
+ initiatedBy: text93("initiated_by").notNull(),
26864
26912
  // FK → users.id (source owner)
26865
26913
  recipientEmail: varchar69("recipient_email", { length: 255 }).notNull(),
26866
26914
  // lowercased
26867
- note: text92("note"),
26915
+ note: text93("note"),
26868
26916
  // optional message to the recipient
26869
- resolvedAt: timestamp84("resolved_at"),
26917
+ resolvedAt: timestamp85("resolved_at"),
26870
26918
  // set on accept/decline/cancel/expire
26871
- resolvedBy: text92("resolved_by"),
26919
+ resolvedBy: text93("resolved_by"),
26872
26920
  // FK → users.id (accepter/decliner/canceller)
26873
- error: text92("error"),
26921
+ error: text93("error"),
26874
26922
  // failure detail when status='failed'
26875
- expiresAt: timestamp84("expires_at").notNull(),
26923
+ expiresAt: timestamp85("expires_at").notNull(),
26876
26924
  // createdAt + 7d
26877
- createdAt: timestamp84("created_at").notNull().defaultNow(),
26878
- updatedAt: timestamp84("updated_at").notNull().defaultNow()
26925
+ createdAt: timestamp85("created_at").notNull().defaultNow(),
26926
+ updatedAt: timestamp85("updated_at").notNull().defaultNow()
26879
26927
  },
26880
26928
  (table) => [
26881
26929
  // At most one OPEN transfer per project. Partial-unique so completed/declined/
26882
26930
  // cancelled/expired/failed rows never wedge a re-initiation.
26883
26931
  uniqueIndex42("project_transfers_one_pending_idx").on(table.projectId).where(sql28`${table.status} = 'pending'`),
26884
26932
  // Recipient inbox lookup (GET /me/transfers by email + status).
26885
- index79("project_transfers_recipient_idx").on(
26933
+ index80("project_transfers_recipient_idx").on(
26886
26934
  table.recipientEmail,
26887
26935
  table.status
26888
26936
  ),
26889
26937
  // Source-side list (GET /projects/:id/transfers) + cancel.
26890
- index79("project_transfers_from_ws_idx").on(table.fromWorkspaceId),
26891
- index79("project_transfers_project_idx").on(table.projectId),
26938
+ index80("project_transfers_from_ws_idx").on(table.fromWorkspaceId),
26939
+ index80("project_transfers_project_idx").on(table.projectId),
26892
26940
  // Magic-link resolution.
26893
26941
  uniqueIndex42("project_transfers_token_idx").on(table.token),
26894
26942
  // Expiry sweep — only pending rows are ever candidates.
26895
- index79("project_transfers_expires_idx").on(table.expiresAt).where(sql28`${table.status} = 'pending'`)
26943
+ index80("project_transfers_expires_idx").on(table.expiresAt).where(sql28`${table.status} = 'pending'`)
26896
26944
  ]
26897
26945
  );
26898
26946
 
26899
26947
  // src/schema/backups.ts
26900
26948
  import {
26901
- pgTable as pgTable92,
26902
- text as text93,
26949
+ pgTable as pgTable93,
26950
+ text as text94,
26903
26951
  varchar as varchar70,
26904
- integer as integer46,
26952
+ integer as integer47,
26905
26953
  bigint as bigint7,
26906
- jsonb as jsonb51,
26907
- timestamp as timestamp85,
26908
- index as index80
26954
+ jsonb as jsonb53,
26955
+ timestamp as timestamp86,
26956
+ index as index81
26909
26957
  } from "drizzle-orm/pg-core";
26910
26958
  var FULL_BACKUP_SCOPE = {
26911
26959
  content: true,
@@ -26914,261 +26962,261 @@ var FULL_BACKUP_SCOPE = {
26914
26962
  submissions: true,
26915
26963
  analytics: true
26916
26964
  };
26917
- var backups = pgTable92(
26965
+ var backups = pgTable93(
26918
26966
  "backups",
26919
26967
  {
26920
- id: text93("id").primaryKey(),
26968
+ id: text94("id").primaryKey(),
26921
26969
  // nanoid
26922
- workspaceId: text93("workspace_id").notNull(),
26970
+ workspaceId: text94("workspace_id").notNull(),
26923
26971
  // FK → workspaces.id (RLS scope)
26924
- projectId: text93("project_id").notNull(),
26972
+ projectId: text94("project_id").notNull(),
26925
26973
  // FK → projects.id
26926
26974
  name: varchar70("name", { length: 255 }).notNull(),
26927
26975
  source: varchar70("source", { length: 20 }).notNull().default("manual"),
26928
26976
  status: varchar70("status", { length: 20 }).notNull().default("pending"),
26929
- manifestKey: text93("manifest_key"),
26977
+ manifestKey: text94("manifest_key"),
26930
26978
  // R2 key of the gzipped manifest; NULL until ready
26931
- manifestVersion: integer46("manifest_version").notNull().default(1),
26979
+ manifestVersion: integer47("manifest_version").notNull().default(1),
26932
26980
  // forward-compat
26933
26981
  sizeBytes: bigint7("size_bytes", { mode: "number" }),
26934
- counts: jsonb51("counts").$type().notNull().default({}),
26982
+ counts: jsonb53("counts").$type().notNull().default({}),
26935
26983
  // R2 object keys this snapshot references. Powers the media-GC hold:
26936
26984
  // `list_backup_referenced_media_keys()` keeps these keys alive while the
26937
26985
  // backup is live, so a restore never finds a garbage-collected object.
26938
- mediaKeys: jsonb51("media_keys").$type().notNull().default([]),
26939
- scope: jsonb51("scope").$type().notNull().default(FULL_BACKUP_SCOPE),
26940
- error: text93("error"),
26941
- createdBy: text93("created_by"),
26986
+ mediaKeys: jsonb53("media_keys").$type().notNull().default([]),
26987
+ scope: jsonb53("scope").$type().notNull().default(FULL_BACKUP_SCOPE),
26988
+ error: text94("error"),
26989
+ createdBy: text94("created_by"),
26942
26990
  // FK → users(id); NULL = system-initiated
26943
- createdAt: timestamp85("created_at").notNull().defaultNow(),
26944
- readyAt: timestamp85("ready_at"),
26945
- expiresAt: timestamp85("expires_at"),
26991
+ createdAt: timestamp86("created_at").notNull().defaultNow(),
26992
+ readyAt: timestamp86("ready_at"),
26993
+ expiresAt: timestamp86("expires_at"),
26946
26994
  // retention horizon; NULL = keep until count-pruned
26947
- deletedAt: timestamp85("deleted_at")
26995
+ deletedAt: timestamp86("deleted_at")
26948
26996
  },
26949
26997
  (t) => [
26950
- index80("backups_project_idx").on(t.projectId, t.createdAt),
26951
- index80("backups_workspace_idx").on(t.workspaceId)
26998
+ index81("backups_project_idx").on(t.projectId, t.createdAt),
26999
+ index81("backups_workspace_idx").on(t.workspaceId)
26952
27000
  ]
26953
27001
  );
26954
27002
 
26955
27003
  // src/schema/backup_jobs.ts
26956
27004
  import {
26957
- pgTable as pgTable93,
26958
- text as text94,
27005
+ pgTable as pgTable94,
27006
+ text as text95,
26959
27007
  varchar as varchar71,
26960
- integer as integer47,
26961
- jsonb as jsonb52,
26962
- timestamp as timestamp86,
26963
- index as index81
27008
+ integer as integer48,
27009
+ jsonb as jsonb54,
27010
+ timestamp as timestamp87,
27011
+ index as index82
26964
27012
  } from "drizzle-orm/pg-core";
26965
- var backupJobs = pgTable93(
27013
+ var backupJobs = pgTable94(
26966
27014
  "backup_jobs",
26967
27015
  {
26968
- id: text94("id").primaryKey(),
27016
+ id: text95("id").primaryKey(),
26969
27017
  // nanoid
26970
- workspaceId: text94("workspace_id").notNull(),
26971
- projectId: text94("project_id").notNull(),
27018
+ workspaceId: text95("workspace_id").notNull(),
27019
+ projectId: text95("project_id").notNull(),
26972
27020
  // create → the pending backups.id this job fills; restore → the source backup.
26973
- backupId: text94("backup_id"),
27021
+ backupId: text95("backup_id"),
26974
27022
  operation: varchar71("operation", { length: 16 }).notNull(),
26975
27023
  status: varchar71("status", { length: 16 }).notNull().default("pending"),
26976
- progress: integer47("progress").notNull().default(0),
27024
+ progress: integer48("progress").notNull().default(0),
26977
27025
  // 0–100
26978
- workingSince: timestamp86("working_since", { withTimezone: true }),
26979
- attempts: integer47("attempts").notNull().default(0),
26980
- error: text94("error"),
26981
- payload: jsonb52("payload").$type().notNull().default({}),
26982
- createdAt: timestamp86("created_at").notNull().defaultNow(),
26983
- updatedAt: timestamp86("updated_at").notNull().defaultNow()
27026
+ workingSince: timestamp87("working_since", { withTimezone: true }),
27027
+ attempts: integer48("attempts").notNull().default(0),
27028
+ error: text95("error"),
27029
+ payload: jsonb54("payload").$type().notNull().default({}),
27030
+ createdAt: timestamp87("created_at").notNull().defaultNow(),
27031
+ updatedAt: timestamp87("updated_at").notNull().defaultNow()
26984
27032
  },
26985
27033
  (t) => [
26986
- index81("backup_jobs_drain_idx").on(t.status, t.createdAt),
26987
- index81("backup_jobs_project_idx").on(t.projectId)
27034
+ index82("backup_jobs_drain_idx").on(t.status, t.createdAt),
27035
+ index82("backup_jobs_project_idx").on(t.projectId)
26988
27036
  ]
26989
27037
  );
26990
27038
 
26991
27039
  // src/schema/clone_links.ts
26992
- import { pgTable as pgTable94, text as text95, boolean as boolean30, jsonb as jsonb53, timestamp as timestamp87, index as index82 } from "drizzle-orm/pg-core";
26993
- var cloneLinks = pgTable94(
27040
+ import { pgTable as pgTable95, text as text96, boolean as boolean30, jsonb as jsonb55, timestamp as timestamp88, index as index83 } from "drizzle-orm/pg-core";
27041
+ var cloneLinks = pgTable95(
26994
27042
  "clone_links",
26995
27043
  {
26996
- id: text95("id").primaryKey(),
27044
+ id: text96("id").primaryKey(),
26997
27045
  // nanoid
26998
- workspaceId: text95("workspace_id").notNull(),
27046
+ workspaceId: text96("workspace_id").notNull(),
26999
27047
  // FK → workspaces.id (RLS scope)
27000
- projectId: text95("project_id").notNull(),
27048
+ projectId: text96("project_id").notNull(),
27001
27049
  // FK → projects.id
27002
- token: text95("token").notNull(),
27050
+ token: text96("token").notNull(),
27003
27051
  // public share token (nanoid); unique among active links
27004
27052
  enabled: boolean30("enabled").notNull().default(true),
27005
- scope: jsonb53("scope").$type().notNull(),
27006
- createdBy: text95("created_by"),
27053
+ scope: jsonb55("scope").$type().notNull(),
27054
+ createdBy: text96("created_by"),
27007
27055
  // FK → users(id); NULL = system-initiated
27008
- createdAt: timestamp87("created_at").notNull().defaultNow(),
27009
- updatedAt: timestamp87("updated_at").notNull().defaultNow(),
27010
- revokedAt: timestamp87("revoked_at")
27056
+ createdAt: timestamp88("created_at").notNull().defaultNow(),
27057
+ updatedAt: timestamp88("updated_at").notNull().defaultNow(),
27058
+ revokedAt: timestamp88("revoked_at")
27011
27059
  // set when the link is rotated/disabled
27012
27060
  },
27013
27061
  (t) => [
27014
- index82("clone_links_project_idx").on(t.projectId),
27015
- index82("clone_links_workspace_idx").on(t.workspaceId)
27062
+ index83("clone_links_project_idx").on(t.projectId),
27063
+ index83("clone_links_workspace_idx").on(t.workspaceId)
27016
27064
  ]
27017
27065
  );
27018
27066
 
27019
27067
  // src/schema/clone_jobs.ts
27020
- import { pgTable as pgTable95, text as text96, varchar as varchar72, integer as integer48, jsonb as jsonb54, timestamp as timestamp88, index as index83 } from "drizzle-orm/pg-core";
27021
- var cloneJobs = pgTable95(
27068
+ import { pgTable as pgTable96, text as text97, varchar as varchar72, integer as integer49, jsonb as jsonb56, timestamp as timestamp89, index as index84 } from "drizzle-orm/pg-core";
27069
+ var cloneJobs = pgTable96(
27022
27070
  "clone_jobs",
27023
27071
  {
27024
- id: text96("id").primaryKey(),
27072
+ id: text97("id").primaryKey(),
27025
27073
  // nanoid
27026
- workspaceId: text96("workspace_id").notNull(),
27074
+ workspaceId: text97("workspace_id").notNull(),
27027
27075
  // = targetWorkspaceId (RLS scope)
27028
- sourceProjectId: text96("source_project_id").notNull(),
27029
- sourceWorkspaceId: text96("source_workspace_id").notNull(),
27030
- targetProjectId: text96("target_project_id"),
27076
+ sourceProjectId: text97("source_project_id").notNull(),
27077
+ sourceWorkspaceId: text97("source_workspace_id").notNull(),
27078
+ targetProjectId: text97("target_project_id"),
27031
27079
  // stamped on success
27032
27080
  requestedName: varchar72("requested_name", { length: 255 }),
27033
27081
  requestedSlug: varchar72("requested_slug", { length: 255 }),
27034
27082
  status: varchar72("status", { length: 16 }).notNull().default("pending"),
27035
- progress: integer48("progress").notNull().default(0),
27083
+ progress: integer49("progress").notNull().default(0),
27036
27084
  // 0–100
27037
- workingSince: timestamp88("working_since", { withTimezone: true }),
27038
- attempts: integer48("attempts").notNull().default(0),
27039
- error: text96("error"),
27040
- payload: jsonb54("payload").$type().notNull().default({}),
27041
- initiatedBy: text96("initiated_by"),
27085
+ workingSince: timestamp89("working_since", { withTimezone: true }),
27086
+ attempts: integer49("attempts").notNull().default(0),
27087
+ error: text97("error"),
27088
+ payload: jsonb56("payload").$type().notNull().default({}),
27089
+ initiatedBy: text97("initiated_by"),
27042
27090
  // FK → users(id); NULL = system/agent
27043
- createdAt: timestamp88("created_at").notNull().defaultNow(),
27044
- updatedAt: timestamp88("updated_at").notNull().defaultNow()
27091
+ createdAt: timestamp89("created_at").notNull().defaultNow(),
27092
+ updatedAt: timestamp89("updated_at").notNull().defaultNow()
27045
27093
  },
27046
27094
  (t) => [
27047
- index83("clone_jobs_drain_idx").on(t.status, t.createdAt),
27048
- index83("clone_jobs_workspace_idx").on(t.workspaceId)
27095
+ index84("clone_jobs_drain_idx").on(t.status, t.createdAt),
27096
+ index84("clone_jobs_workspace_idx").on(t.workspaceId)
27049
27097
  ]
27050
27098
  );
27051
27099
 
27052
27100
  // src/schema/project_branches.ts
27053
27101
  import {
27054
- pgTable as pgTable96,
27055
- text as text97,
27102
+ pgTable as pgTable97,
27103
+ text as text98,
27056
27104
  varchar as varchar73,
27057
- timestamp as timestamp89,
27058
- index as index84,
27105
+ timestamp as timestamp90,
27106
+ index as index85,
27059
27107
  uniqueIndex as uniqueIndex43
27060
27108
  } from "drizzle-orm/pg-core";
27061
27109
  import { sql as sql29 } from "drizzle-orm";
27062
- var projectBranches = pgTable96(
27110
+ var projectBranches = pgTable97(
27063
27111
  "project_branches",
27064
27112
  {
27065
- id: text97("id").primaryKey(),
27066
- workspaceId: text97("workspace_id").notNull(),
27067
- projectId: text97("project_id").notNull(),
27113
+ id: text98("id").primaryKey(),
27114
+ workspaceId: text98("workspace_id").notNull(),
27115
+ projectId: text98("project_id").notNull(),
27068
27116
  name: varchar73("name", { length: 80 }).notNull(),
27069
27117
  slug: varchar73("slug", { length: 80 }).notNull(),
27070
- parentBranchId: text97("parent_branch_id"),
27118
+ parentBranchId: text98("parent_branch_id"),
27071
27119
  status: varchar73("status", { length: 16 }).$type().notNull().default("open"),
27072
- appliedAt: timestamp89("applied_at"),
27073
- abandonedAt: timestamp89("abandoned_at"),
27120
+ appliedAt: timestamp90("applied_at"),
27121
+ abandonedAt: timestamp90("abandoned_at"),
27074
27122
  ...auditColumns
27075
27123
  },
27076
27124
  (t) => [
27077
- index84("project_branches_project_idx").on(t.projectId),
27125
+ index85("project_branches_project_idx").on(t.projectId),
27078
27126
  uniqueIndex43("project_branches_project_slug_open_idx").on(t.projectId, t.slug).where(sql29`${t.status} = 'open'`)
27079
27127
  ]
27080
27128
  );
27081
27129
 
27082
27130
  // src/schema/branch_preview_share.ts
27083
- import { pgTable as pgTable97, text as text98, boolean as boolean31, timestamp as timestamp90, index as index85, uniqueIndex as uniqueIndex44 } from "drizzle-orm/pg-core";
27084
- var branchPreviewShares = pgTable97(
27131
+ import { pgTable as pgTable98, text as text99, boolean as boolean31, timestamp as timestamp91, index as index86, uniqueIndex as uniqueIndex44 } from "drizzle-orm/pg-core";
27132
+ var branchPreviewShares = pgTable98(
27085
27133
  "branch_preview_shares",
27086
27134
  {
27087
- id: text98("id").primaryKey(),
27088
- workspaceId: text98("workspace_id").notNull(),
27089
- projectId: text98("project_id").notNull(),
27090
- branchId: text98("branch_id").notNull(),
27135
+ id: text99("id").primaryKey(),
27136
+ workspaceId: text99("workspace_id").notNull(),
27137
+ projectId: text99("project_id").notNull(),
27138
+ branchId: text99("branch_id").notNull(),
27091
27139
  publicEnabled: boolean31("public_enabled").notNull().default(false),
27092
- publicToken: text98("public_token"),
27093
- createdBy: text98("created_by"),
27094
- createdAt: timestamp90("created_at").notNull().defaultNow(),
27095
- updatedAt: timestamp90("updated_at").notNull().defaultNow()
27140
+ publicToken: text99("public_token"),
27141
+ createdBy: text99("created_by"),
27142
+ createdAt: timestamp91("created_at").notNull().defaultNow(),
27143
+ updatedAt: timestamp91("updated_at").notNull().defaultNow()
27096
27144
  },
27097
27145
  (t) => [
27098
27146
  uniqueIndex44("branch_preview_shares_branch_idx").on(t.branchId),
27099
27147
  uniqueIndex44("branch_preview_shares_active_token_idx").on(t.publicToken),
27100
- index85("branch_preview_shares_project_idx").on(t.projectId),
27101
- index85("branch_preview_shares_workspace_idx").on(t.workspaceId)
27148
+ index86("branch_preview_shares_project_idx").on(t.projectId),
27149
+ index86("branch_preview_shares_workspace_idx").on(t.workspaceId)
27102
27150
  ]
27103
27151
  );
27104
- var branchPreviewGrants = pgTable97(
27152
+ var branchPreviewGrants = pgTable98(
27105
27153
  "branch_preview_grants",
27106
27154
  {
27107
- id: text98("id").primaryKey(),
27108
- workspaceId: text98("workspace_id").notNull(),
27109
- projectId: text98("project_id").notNull(),
27110
- branchId: text98("branch_id").notNull(),
27111
- email: text98("email").notNull(),
27112
- invitedBy: text98("invited_by"),
27113
- createdAt: timestamp90("created_at").notNull().defaultNow()
27155
+ id: text99("id").primaryKey(),
27156
+ workspaceId: text99("workspace_id").notNull(),
27157
+ projectId: text99("project_id").notNull(),
27158
+ branchId: text99("branch_id").notNull(),
27159
+ email: text99("email").notNull(),
27160
+ invitedBy: text99("invited_by"),
27161
+ createdAt: timestamp91("created_at").notNull().defaultNow()
27114
27162
  },
27115
27163
  (t) => [
27116
27164
  uniqueIndex44("branch_preview_grants_branch_email_idx").on(t.branchId, t.email),
27117
- index85("branch_preview_grants_project_idx").on(t.projectId)
27165
+ index86("branch_preview_grants_project_idx").on(t.projectId)
27118
27166
  ]
27119
27167
  );
27120
27168
 
27121
27169
  // src/schema/share_links.ts
27122
- import { pgTable as pgTable98, text as text99, boolean as boolean32, timestamp as timestamp91, index as index86 } from "drizzle-orm/pg-core";
27123
- var shareLinks = pgTable98(
27170
+ import { pgTable as pgTable99, text as text100, boolean as boolean32, timestamp as timestamp92, index as index87 } from "drizzle-orm/pg-core";
27171
+ var shareLinks = pgTable99(
27124
27172
  "share_links",
27125
27173
  {
27126
- id: text99("id").primaryKey(),
27174
+ id: text100("id").primaryKey(),
27127
27175
  // nanoid
27128
- workspaceId: text99("workspace_id").notNull(),
27176
+ workspaceId: text100("workspace_id").notNull(),
27129
27177
  // FK → workspaces.id (RLS scope)
27130
- projectId: text99("project_id").notNull(),
27178
+ projectId: text100("project_id").notNull(),
27131
27179
  // FK → projects.id
27132
- token: text99("token").notNull(),
27180
+ token: text100("token").notNull(),
27133
27181
  // public share token (nanoid); unique among active links
27134
27182
  enabled: boolean32("enabled").notNull().default(true),
27135
- createdBy: text99("created_by"),
27183
+ createdBy: text100("created_by"),
27136
27184
  // FK → users(id); NULL = system-initiated
27137
- createdAt: timestamp91("created_at").notNull().defaultNow(),
27138
- updatedAt: timestamp91("updated_at").notNull().defaultNow(),
27139
- revokedAt: timestamp91("revoked_at")
27185
+ createdAt: timestamp92("created_at").notNull().defaultNow(),
27186
+ updatedAt: timestamp92("updated_at").notNull().defaultNow(),
27187
+ revokedAt: timestamp92("revoked_at")
27140
27188
  // set when the link is disabled
27141
27189
  },
27142
27190
  (t) => [
27143
- index86("share_links_project_idx").on(t.projectId),
27144
- index86("share_links_workspace_idx").on(t.workspaceId)
27191
+ index87("share_links_project_idx").on(t.projectId),
27192
+ index87("share_links_workspace_idx").on(t.workspaceId)
27145
27193
  ]
27146
27194
  );
27147
27195
 
27148
27196
  // src/schema/templates.ts
27149
27197
  import {
27150
- pgTable as pgTable99,
27151
- text as text100,
27198
+ pgTable as pgTable100,
27199
+ text as text101,
27152
27200
  varchar as varchar74,
27153
- timestamp as timestamp92,
27154
- jsonb as jsonb55,
27155
- integer as integer49,
27156
- index as index87,
27201
+ timestamp as timestamp93,
27202
+ jsonb as jsonb57,
27203
+ integer as integer50,
27204
+ index as index88,
27157
27205
  uniqueIndex as uniqueIndex45
27158
27206
  } from "drizzle-orm/pg-core";
27159
27207
  import { relations as relations17 } from "drizzle-orm/relations";
27160
27208
  import { sql as sql30 } from "drizzle-orm";
27161
- var templates = pgTable99(
27209
+ var templates = pgTable100(
27162
27210
  "templates",
27163
27211
  {
27164
- id: text100("id").primaryKey(),
27212
+ id: text101("id").primaryKey(),
27165
27213
  // nanoid
27166
- workspaceId: text100("workspace_id").notNull(),
27214
+ workspaceId: text101("workspace_id").notNull(),
27167
27215
  // FK to workspaces.id (RLS scope / owner)
27168
27216
  slug: varchar74("slug", { length: 255 }).notNull(),
27169
27217
  // ^[a-z0-9-]+$, unique per workspace
27170
27218
  name: varchar74("name", { length: 255 }).notNull(),
27171
- description: text100("description"),
27219
+ description: text101("description"),
27172
27220
  scope: varchar74("scope", { length: 10 }).$type().notNull().default("project"),
27173
27221
  // 'demo' ships seed content; 'starter-kit' is the same schema with the content blanked.
27174
27222
  // Defaults to 'demo' because a user template is a frozen snapshot of a real project,
@@ -27179,25 +27227,25 @@ var templates = pgTable99(
27179
27227
  thumbnail: varchar74("thumbnail", { length: 2048 }),
27180
27228
  // Frozen snapshot manifest (stripped snapshot_project output). Never returned in
27181
27229
  // list/gallery responses — only read server-side to instantiate.
27182
- manifest: jsonb55("manifest").$type().notNull(),
27230
+ manifest: jsonb57("manifest").$type().notNull(),
27183
27231
  visibility: varchar74("visibility", { length: 10 }).$type().notNull().default("private"),
27184
- sourceProjectId: text100("source_project_id"),
27232
+ sourceProjectId: text101("source_project_id"),
27185
27233
  // provenance (nullable — source may be deleted later)
27186
- createdBy: text100("created_by"),
27234
+ createdBy: text101("created_by"),
27187
27235
  // user id, or null for a management-key create
27188
- optimisticVersion: integer49("optimistic_version").notNull().default(0),
27189
- createdAt: timestamp92("created_at").notNull().defaultNow(),
27190
- updatedAt: timestamp92("updated_at").notNull().defaultNow(),
27191
- deletedAt: timestamp92("deleted_at")
27236
+ optimisticVersion: integer50("optimistic_version").notNull().default(0),
27237
+ createdAt: timestamp93("created_at").notNull().defaultNow(),
27238
+ updatedAt: timestamp93("updated_at").notNull().defaultNow(),
27239
+ deletedAt: timestamp93("deleted_at")
27192
27240
  // soft-delete
27193
27241
  },
27194
27242
  (table) => [
27195
- index87("templates_workspace_idx").on(table.workspaceId),
27243
+ index88("templates_workspace_idx").on(table.workspaceId),
27196
27244
  // Partial: only live rows. A soft-deleted template frees its slug (mirrors
27197
27245
  // components_ws_proj_slug_idx / migration 0114).
27198
27246
  uniqueIndex45("templates_ws_slug_idx").on(table.workspaceId, table.slug).where(sql30`${table.deletedAt} IS NULL`),
27199
27247
  // Public gallery scan (created_at DESC over live public rows).
27200
- index87("templates_public_idx").on(table.visibility).where(sql30`${table.visibility} = 'public' AND ${table.deletedAt} IS NULL`)
27248
+ index88("templates_public_idx").on(table.visibility).where(sql30`${table.visibility} = 'public' AND ${table.deletedAt} IS NULL`)
27201
27249
  ]
27202
27250
  );
27203
27251
  var templatesRelations = relations17(templates, ({ one }) => ({
@@ -27209,99 +27257,99 @@ var templatesRelations = relations17(templates, ({ one }) => ({
27209
27257
 
27210
27258
  // src/schema/payment_records.ts
27211
27259
  import {
27212
- pgTable as pgTable100,
27213
- text as text101,
27260
+ pgTable as pgTable101,
27261
+ text as text102,
27214
27262
  varchar as varchar75,
27215
- integer as integer50,
27216
- timestamp as timestamp93,
27217
- index as index88
27263
+ integer as integer51,
27264
+ timestamp as timestamp94,
27265
+ index as index89
27218
27266
  } from "drizzle-orm/pg-core";
27219
- var paymentRecords = pgTable100(
27267
+ var paymentRecords = pgTable101(
27220
27268
  "payment_records",
27221
27269
  {
27222
- id: text101("id").primaryKey(),
27270
+ id: text102("id").primaryKey(),
27223
27271
  // nanoid
27224
- workspaceId: text101("workspace_id").notNull(),
27272
+ workspaceId: text102("workspace_id").notNull(),
27225
27273
  // FK → workspaces.id
27226
- amountCents: integer50("amount_cents").notNull(),
27274
+ amountCents: integer51("amount_cents").notNull(),
27227
27275
  // store money as integer cents
27228
27276
  currency: varchar75("currency", { length: 3 }).notNull().default("usd"),
27229
27277
  method: varchar75("method", { length: 50 }).notNull().default("manual"),
27230
27278
  // manual | stripe | wire | ...
27231
- note: text101("note"),
27232
- recordedBy: text101("recorded_by"),
27279
+ note: text102("note"),
27280
+ recordedBy: text102("recorded_by"),
27233
27281
  // FK → users.id (the admin who entered it)
27234
- createdAt: timestamp93("created_at").notNull().defaultNow()
27282
+ createdAt: timestamp94("created_at").notNull().defaultNow()
27235
27283
  },
27236
27284
  (table) => [
27237
- index88("payment_records_workspace_idx").on(table.workspaceId, table.createdAt)
27285
+ index89("payment_records_workspace_idx").on(table.workspaceId, table.createdAt)
27238
27286
  ]
27239
27287
  );
27240
27288
 
27241
27289
  // src/schema/plan_changes.ts
27242
27290
  import {
27243
- pgTable as pgTable101,
27244
- text as text102,
27245
- timestamp as timestamp94,
27246
- index as index89
27291
+ pgTable as pgTable102,
27292
+ text as text103,
27293
+ timestamp as timestamp95,
27294
+ index as index90
27247
27295
  } from "drizzle-orm/pg-core";
27248
- var planChanges = pgTable101(
27296
+ var planChanges = pgTable102(
27249
27297
  "plan_changes",
27250
27298
  {
27251
- id: text102("id").primaryKey(),
27299
+ id: text103("id").primaryKey(),
27252
27300
  // nanoid
27253
- workspaceId: text102("workspace_id").notNull(),
27301
+ workspaceId: text103("workspace_id").notNull(),
27254
27302
  // FK → workspaces.id
27255
- fromPlan: text102("from_plan"),
27303
+ fromPlan: text103("from_plan"),
27256
27304
  // plan_limits.id before the change (null if unknown)
27257
- toPlan: text102("to_plan").notNull(),
27305
+ toPlan: text103("to_plan").notNull(),
27258
27306
  // plan_limits.id after the change
27259
- reason: text102("reason"),
27260
- changedBy: text102("changed_by"),
27307
+ reason: text103("reason"),
27308
+ changedBy: text103("changed_by"),
27261
27309
  // FK → users.id (the admin)
27262
- createdAt: timestamp94("created_at").notNull().defaultNow()
27310
+ createdAt: timestamp95("created_at").notNull().defaultNow()
27263
27311
  },
27264
27312
  (table) => [
27265
- index89("plan_changes_workspace_idx").on(table.workspaceId, table.createdAt)
27313
+ index90("plan_changes_workspace_idx").on(table.workspaceId, table.createdAt)
27266
27314
  ]
27267
27315
  );
27268
27316
 
27269
27317
  // src/schema/billing_addons.ts
27270
- import { pgTable as pgTable102, text as text103, varchar as varchar76, integer as integer51, boolean as boolean33, jsonb as jsonb56, index as index90 } from "drizzle-orm/pg-core";
27271
- var billingAddons = pgTable102(
27318
+ import { pgTable as pgTable103, text as text104, varchar as varchar76, integer as integer52, boolean as boolean33, jsonb as jsonb58, index as index91 } from "drizzle-orm/pg-core";
27319
+ var billingAddons = pgTable103(
27272
27320
  "billing_addons",
27273
27321
  {
27274
- id: text103("id").primaryKey(),
27322
+ id: text104("id").primaryKey(),
27275
27323
  // stable slug, e.g. "developer", "ai-1000", "localization"
27276
27324
  kind: varchar76("kind", { length: 20 }).notNull(),
27277
27325
  // seat_role | ai_credits | localization | ab_testing
27278
27326
  name: varchar76("name", { length: 100 }).notNull(),
27279
- dodoProductId: text103("dodo_product_id"),
27327
+ dodoProductId: text104("dodo_product_id"),
27280
27328
  // NULL until the Dodo product is created
27281
- unitPriceCents: integer51("unit_price_cents").notNull(),
27329
+ unitPriceCents: integer52("unit_price_cents").notNull(),
27282
27330
  currency: varchar76("currency", { length: 8 }).notNull().default("usd"),
27283
- credits: integer51("credits"),
27331
+ credits: integer52("credits"),
27284
27332
  // ai_credits packs only: credits granted per unit
27285
27333
  recurring: boolean33("recurring").notNull().default(false),
27286
27334
  // seats/localization/AB = true; credit packs = false
27287
- metadata: jsonb56("metadata").$type().default({})
27335
+ metadata: jsonb58("metadata").$type().default({})
27288
27336
  },
27289
- (t) => [index90("billing_addons_kind_idx").on(t.kind)]
27337
+ (t) => [index91("billing_addons_kind_idx").on(t.kind)]
27290
27338
  );
27291
27339
 
27292
27340
  // src/schema/billing_customers.ts
27293
- import { pgTable as pgTable103, text as text104, varchar as varchar77, timestamp as timestamp95, uniqueIndex as uniqueIndex46 } from "drizzle-orm/pg-core";
27294
- var billingCustomers = pgTable103(
27341
+ import { pgTable as pgTable104, text as text105, varchar as varchar77, timestamp as timestamp96, uniqueIndex as uniqueIndex46 } from "drizzle-orm/pg-core";
27342
+ var billingCustomers = pgTable104(
27295
27343
  "billing_customers",
27296
27344
  {
27297
- id: text104("id").primaryKey(),
27345
+ id: text105("id").primaryKey(),
27298
27346
  // nanoid
27299
- workspaceId: text104("workspace_id").notNull(),
27347
+ workspaceId: text105("workspace_id").notNull(),
27300
27348
  // FK → workspaces.id (RLS scope)
27301
- dodoCustomerId: text104("dodo_customer_id").notNull(),
27349
+ dodoCustomerId: text105("dodo_customer_id").notNull(),
27302
27350
  email: varchar77("email", { length: 255 }),
27303
- createdAt: timestamp95("created_at").notNull().defaultNow(),
27304
- updatedAt: timestamp95("updated_at").notNull().defaultNow()
27351
+ createdAt: timestamp96("created_at").notNull().defaultNow(),
27352
+ updatedAt: timestamp96("updated_at").notNull().defaultNow()
27305
27353
  },
27306
27354
  (t) => [
27307
27355
  uniqueIndex46("billing_customers_workspace_idx").on(t.workspaceId),
@@ -27310,34 +27358,34 @@ var billingCustomers = pgTable103(
27310
27358
  );
27311
27359
 
27312
27360
  // src/schema/subscriptions.ts
27313
- import { pgTable as pgTable104, text as text105, varchar as varchar78, boolean as boolean34, timestamp as timestamp96, index as index91, uniqueIndex as uniqueIndex47 } from "drizzle-orm/pg-core";
27361
+ import { pgTable as pgTable105, text as text106, varchar as varchar78, boolean as boolean34, timestamp as timestamp97, index as index92, uniqueIndex as uniqueIndex47 } from "drizzle-orm/pg-core";
27314
27362
  import { sql as sql31 } from "drizzle-orm";
27315
- var subscriptions = pgTable104(
27363
+ var subscriptions = pgTable105(
27316
27364
  "subscriptions",
27317
27365
  {
27318
- id: text105("id").primaryKey(),
27366
+ id: text106("id").primaryKey(),
27319
27367
  // nanoid
27320
- workspaceId: text105("workspace_id").notNull(),
27368
+ workspaceId: text106("workspace_id").notNull(),
27321
27369
  // FK → workspaces.id (RLS scope)
27322
- projectId: text105("project_id"),
27370
+ projectId: text106("project_id"),
27323
27371
  // NULL = workspace plan; set = site plan (FK → projects.id)
27324
- planId: text105("plan_id").notNull(),
27372
+ planId: text106("plan_id").notNull(),
27325
27373
  // FK → plan_limits.id
27326
- dodoSubscriptionId: text105("dodo_subscription_id"),
27327
- dodoCustomerId: text105("dodo_customer_id"),
27374
+ dodoSubscriptionId: text106("dodo_subscription_id"),
27375
+ dodoCustomerId: text106("dodo_customer_id"),
27328
27376
  status: varchar78("status", { length: 20 }).notNull().default("active"),
27329
27377
  // active | on_hold | cancelled | expired | pending
27330
27378
  // Which of plan_limits' two prices this row is billed at. Without it the bill cannot tell
27331
27379
  // whether the owner pays price_cents or price_cents_yearly (0147).
27332
27380
  interval: varchar78("interval", { length: 10 }).notNull().default("month"),
27333
27381
  // month | year
27334
- currentPeriodEnd: timestamp96("current_period_end"),
27382
+ currentPeriodEnd: timestamp97("current_period_end"),
27335
27383
  cancelAtPeriodEnd: boolean34("cancel_at_period_end").notNull().default(false),
27336
- createdAt: timestamp96("created_at").notNull().defaultNow(),
27337
- updatedAt: timestamp96("updated_at").notNull().defaultNow()
27384
+ createdAt: timestamp97("created_at").notNull().defaultNow(),
27385
+ updatedAt: timestamp97("updated_at").notNull().defaultNow()
27338
27386
  },
27339
27387
  (t) => [
27340
- index91("subscriptions_workspace_idx").on(t.workspaceId),
27388
+ index92("subscriptions_workspace_idx").on(t.workspaceId),
27341
27389
  uniqueIndex47("subscriptions_dodo_idx").on(t.dodoSubscriptionId).where(sql31`${t.dodoSubscriptionId} IS NOT NULL`),
27342
27390
  // At most one workspace-level subscription per workspace.
27343
27391
  uniqueIndex47("subscriptions_workspace_plan_unique").on(t.workspaceId).where(sql31`${t.projectId} IS NULL`),
@@ -27347,116 +27395,142 @@ var subscriptions = pgTable104(
27347
27395
  );
27348
27396
 
27349
27397
  // src/schema/subscription_addons.ts
27350
- import { pgTable as pgTable105, text as text106, varchar as varchar79, integer as integer52, timestamp as timestamp97, index as index92, uniqueIndex as uniqueIndex48 } from "drizzle-orm/pg-core";
27398
+ import { pgTable as pgTable106, text as text107, varchar as varchar79, integer as integer53, timestamp as timestamp98, index as index93, uniqueIndex as uniqueIndex48 } from "drizzle-orm/pg-core";
27351
27399
  import { sql as sql32 } from "drizzle-orm";
27352
- var subscriptionAddons = pgTable105(
27400
+ var subscriptionAddons = pgTable106(
27353
27401
  "subscription_addons",
27354
27402
  {
27355
- id: text106("id").primaryKey(),
27403
+ id: text107("id").primaryKey(),
27356
27404
  // nanoid
27357
- workspaceId: text106("workspace_id").notNull(),
27405
+ workspaceId: text107("workspace_id").notNull(),
27358
27406
  // FK → workspaces.id (RLS scope)
27359
- addonId: text106("addon_id").notNull(),
27407
+ addonId: text107("addon_id").notNull(),
27360
27408
  // FK → billing_addons.id
27361
- quantity: integer52("quantity").notNull().default(1),
27362
- dodoSubscriptionId: text106("dodo_subscription_id"),
27409
+ quantity: integer53("quantity").notNull().default(1),
27410
+ dodoSubscriptionId: text107("dodo_subscription_id"),
27363
27411
  // NULL for a manual/admin grant
27364
27412
  status: varchar79("status", { length: 20 }).notNull().default("active"),
27365
27413
  // active | cancelled | expired
27366
- createdAt: timestamp97("created_at").notNull().defaultNow(),
27367
- updatedAt: timestamp97("updated_at").notNull().defaultNow()
27414
+ createdAt: timestamp98("created_at").notNull().defaultNow(),
27415
+ updatedAt: timestamp98("updated_at").notNull().defaultNow()
27368
27416
  },
27369
27417
  (t) => [
27370
- index92("subscription_addons_workspace_idx").on(t.workspaceId),
27418
+ index93("subscription_addons_workspace_idx").on(t.workspaceId),
27371
27419
  uniqueIndex48("subscription_addons_dodo_idx").on(t.dodoSubscriptionId).where(sql32`${t.dodoSubscriptionId} IS NOT NULL`)
27372
27420
  ]
27373
27421
  );
27374
27422
 
27423
+ // src/schema/billing_alerts.ts
27424
+ import { pgTable as pgTable107, text as text108, varchar as varchar80, timestamp as timestamp99, index as index94, uniqueIndex as uniqueIndex49 } from "drizzle-orm/pg-core";
27425
+ var billingAlerts = pgTable107(
27426
+ "billing_alerts",
27427
+ {
27428
+ id: text108("id").primaryKey(),
27429
+ // nanoid
27430
+ workspaceId: text108("workspace_id").notNull(),
27431
+ // FK → workspaces.id (internal table, no RLS)
27432
+ kind: varchar80("kind", { length: 32 }).notNull(),
27433
+ // renewal_due | bandwidth_80 | bandwidth_100
27434
+ /**
27435
+ * What "already sent" means for this alert, built by the caller (alerts.ts owns the spellings).
27436
+ * Renewals key on the subscription + its period end, so one reminder per period survives a
27437
+ * period-end change. Bandwidth keys on the threshold + calendar month, matching the window
27438
+ * getUsage() measures — so the counter resetting on the 1st re-arms the alert.
27439
+ */
27440
+ dedupeKey: text108("dedupe_key").notNull(),
27441
+ sentAt: timestamp99("sent_at", { withTimezone: true }).notNull().defaultNow()
27442
+ },
27443
+ (t) => [
27444
+ uniqueIndex49("billing_alerts_dedupe_idx").on(t.dedupeKey),
27445
+ index94("billing_alerts_workspace_idx").on(t.workspaceId, t.sentAt)
27446
+ ]
27447
+ );
27448
+
27375
27449
  // src/schema/ai_credit_ledger.ts
27376
- import { pgTable as pgTable106, text as text107, varchar as varchar80, integer as integer53, timestamp as timestamp98, index as index93 } from "drizzle-orm/pg-core";
27377
- var aiCreditLedger = pgTable106(
27450
+ import { pgTable as pgTable108, text as text109, varchar as varchar81, integer as integer54, timestamp as timestamp100, index as index95 } from "drizzle-orm/pg-core";
27451
+ var aiCreditLedger = pgTable108(
27378
27452
  "ai_credit_ledger",
27379
27453
  {
27380
- id: text107("id").primaryKey(),
27454
+ id: text109("id").primaryKey(),
27381
27455
  // nanoid
27382
- workspaceId: text107("workspace_id").notNull(),
27456
+ workspaceId: text109("workspace_id").notNull(),
27383
27457
  // FK → workspaces.id (RLS scope)
27384
- delta: integer53("delta").notNull(),
27458
+ delta: integer54("delta").notNull(),
27385
27459
  // signed: +purchase/grant, -consume/expire
27386
- reason: varchar80("reason", { length: 20 }).notNull(),
27460
+ reason: varchar81("reason", { length: 20 }).notNull(),
27387
27461
  // purchase | consume | grant | expire
27388
- dodoPaymentId: text107("dodo_payment_id"),
27462
+ dodoPaymentId: text109("dodo_payment_id"),
27389
27463
  // set for purchases
27390
- note: text107("note"),
27391
- createdAt: timestamp98("created_at").notNull().defaultNow()
27464
+ note: text109("note"),
27465
+ createdAt: timestamp100("created_at").notNull().defaultNow()
27392
27466
  },
27393
- (t) => [index93("ai_credit_ledger_workspace_idx").on(t.workspaceId, t.createdAt)]
27467
+ (t) => [index95("ai_credit_ledger_workspace_idx").on(t.workspaceId, t.createdAt)]
27394
27468
  );
27395
27469
 
27396
27470
  // src/schema/support_tickets.ts
27397
27471
  import {
27398
- pgTable as pgTable107,
27399
- text as text108,
27400
- varchar as varchar81,
27401
- timestamp as timestamp99,
27472
+ pgTable as pgTable109,
27473
+ text as text110,
27474
+ varchar as varchar82,
27475
+ timestamp as timestamp101,
27402
27476
  boolean as boolean35,
27403
- jsonb as jsonb57,
27404
- index as index94
27477
+ jsonb as jsonb59,
27478
+ index as index96
27405
27479
  } from "drizzle-orm/pg-core";
27406
- var supportTickets = pgTable107(
27480
+ var supportTickets = pgTable109(
27407
27481
  "support_tickets",
27408
27482
  {
27409
- id: text108("id").primaryKey(),
27483
+ id: text110("id").primaryKey(),
27410
27484
  // nanoid
27411
- workspaceId: text108("workspace_id"),
27485
+ workspaceId: text110("workspace_id"),
27412
27486
  // FK → workspaces.id (nullable: account-level tickets)
27413
27487
  // FK → users.id (the customer). NULL for a ticket Plain created: an email or Slack
27414
27488
  // sender has no BetterCMS account. visibleTicketWhere() compares this to the session
27415
27489
  // user, and NULL never matches, so those tickets stay invisible to every customer —
27416
27490
  // which is correct, since there is no dashboard reply transport for them.
27417
- userId: text108("user_id"),
27491
+ userId: text110("user_id"),
27418
27492
  // The only identity a Plain-origin ticket has. The staff list coalesces it with
27419
27493
  // users.email; NULL whenever userId is set.
27420
- customerEmail: text108("customer_email"),
27421
- customerName: text108("customer_name"),
27422
- subject: varchar81("subject", { length: 255 }).notNull(),
27423
- body: text108("body").notNull(),
27424
- status: varchar81("status", { length: 20 }).notNull().default("open"),
27494
+ customerEmail: text110("customer_email"),
27495
+ customerName: text110("customer_name"),
27496
+ subject: varchar82("subject", { length: 255 }).notNull(),
27497
+ body: text110("body").notNull(),
27498
+ status: varchar82("status", { length: 20 }).notNull().default("open"),
27425
27499
  // open | pending | closed
27426
- priority: varchar81("priority", { length: 20 }).notNull().default("normal"),
27500
+ priority: varchar82("priority", { length: 20 }).notNull().default("normal"),
27427
27501
  // low | normal | high | urgent
27428
- assigneeId: text108("assignee_id"),
27502
+ assigneeId: text110("assignee_id"),
27429
27503
  // FK → users.id (staff member handling it)
27430
27504
  // Plain's ThreadChannel, lowercased. 'api' is a ticket opened in the dashboard; the
27431
27505
  // rest arrive from Plain. The staff reply path branches on this: 'api' threads deliver
27432
27506
  // nothing to the customer so we send the email ourselves, every other channel is
27433
27507
  // delivered by Plain.
27434
- channel: text108("channel").notNull().default("api"),
27508
+ channel: text110("channel").notNull().default("api"),
27435
27509
  // The Plain thread this ticket mirrors. NULL until the first outbound sync succeeds,
27436
27510
  // hence the partial unique index rather than a unique column.
27437
- plainThreadId: text108("plain_thread_id"),
27511
+ plainThreadId: text110("plain_thread_id"),
27438
27512
  // Files attached when the case was opened, before any message row exists.
27439
- attachments: jsonb57("attachments").$type().notNull().default([]),
27440
- createdAt: timestamp99("created_at").notNull().defaultNow(),
27441
- updatedAt: timestamp99("updated_at").notNull().defaultNow()
27513
+ attachments: jsonb59("attachments").$type().notNull().default([]),
27514
+ createdAt: timestamp101("created_at").notNull().defaultNow(),
27515
+ updatedAt: timestamp101("updated_at").notNull().defaultNow()
27442
27516
  },
27443
27517
  (table) => [
27444
- index94("support_tickets_status_idx").on(table.status, table.updatedAt),
27445
- index94("support_tickets_workspace_idx").on(table.workspaceId),
27446
- index94("support_tickets_user_idx").on(table.userId),
27447
- index94("support_tickets_channel_idx").on(table.channel, table.updatedAt)
27518
+ index96("support_tickets_status_idx").on(table.status, table.updatedAt),
27519
+ index96("support_tickets_workspace_idx").on(table.workspaceId),
27520
+ index96("support_tickets_user_idx").on(table.userId),
27521
+ index96("support_tickets_channel_idx").on(table.channel, table.updatedAt)
27448
27522
  ]
27449
27523
  );
27450
- var supportTicketMessages = pgTable107(
27524
+ var supportTicketMessages = pgTable109(
27451
27525
  "support_ticket_messages",
27452
27526
  {
27453
- id: text108("id").primaryKey(),
27527
+ id: text110("id").primaryKey(),
27454
27528
  // nanoid
27455
- ticketId: text108("ticket_id").notNull(),
27529
+ ticketId: text110("ticket_id").notNull(),
27456
27530
  // FK → support_tickets.id
27457
- authorId: text108("author_id"),
27531
+ authorId: text110("author_id"),
27458
27532
  // FK → users.id (staff or customer)
27459
- body: text108("body").notNull(),
27533
+ body: text110("body").notNull(),
27460
27534
  isStaff: boolean35("is_staff").notNull().default(false),
27461
27535
  // true = team reply
27462
27536
  // Staff-only triage note. NEVER leaves the platform-admin lane: the customer read
@@ -27466,99 +27540,99 @@ var supportTicketMessages = pgTable107(
27466
27540
  // at-least-once webhook. NULL for anything Plain never saw, and for our own replies on
27467
27541
  // channels whose mutation returns no entry id — replyToThread returns only an error
27468
27542
  // slot, which is why the echo check keys on the actor and this is the backstop.
27469
- plainMessageId: text108("plain_message_id"),
27470
- attachments: jsonb57("attachments").$type().notNull().default([]),
27471
- createdAt: timestamp99("created_at").notNull().defaultNow()
27543
+ plainMessageId: text110("plain_message_id"),
27544
+ attachments: jsonb59("attachments").$type().notNull().default([]),
27545
+ createdAt: timestamp101("created_at").notNull().defaultNow()
27472
27546
  },
27473
27547
  (table) => [
27474
- index94("support_ticket_messages_ticket_idx").on(table.ticketId, table.createdAt)
27548
+ index96("support_ticket_messages_ticket_idx").on(table.ticketId, table.createdAt)
27475
27549
  ]
27476
27550
  );
27477
27551
 
27478
27552
  // src/schema/admin_action_logs.ts
27479
27553
  import {
27480
- pgTable as pgTable108,
27481
- text as text109,
27482
- varchar as varchar82,
27483
- jsonb as jsonb58,
27484
- timestamp as timestamp100,
27485
- index as index95
27554
+ pgTable as pgTable110,
27555
+ text as text111,
27556
+ varchar as varchar83,
27557
+ jsonb as jsonb60,
27558
+ timestamp as timestamp102,
27559
+ index as index97
27486
27560
  } from "drizzle-orm/pg-core";
27487
- var adminActionLogs = pgTable108(
27561
+ var adminActionLogs = pgTable110(
27488
27562
  "admin_action_logs",
27489
27563
  {
27490
- id: text109("id").primaryKey(),
27564
+ id: text111("id").primaryKey(),
27491
27565
  // nanoid
27492
- actorId: text109("actor_id"),
27566
+ actorId: text111("actor_id"),
27493
27567
  // FK → users.id (the staff member)
27494
- actorEmail: varchar82("actor_email", { length: 320 }),
27568
+ actorEmail: varchar83("actor_email", { length: 320 }),
27495
27569
  // denormalized for display
27496
- actorRole: varchar82("actor_role", { length: 40 }),
27570
+ actorRole: varchar83("actor_role", { length: 40 }),
27497
27571
  // admin_role at action time
27498
- action: varchar82("action", { length: 80 }).notNull(),
27572
+ action: varchar83("action", { length: 80 }).notNull(),
27499
27573
  // e.g. workspace.plan_change
27500
- targetType: varchar82("target_type", { length: 40 }),
27574
+ targetType: varchar83("target_type", { length: 40 }),
27501
27575
  // workspace | user | plan | ticket
27502
- targetId: text109("target_id"),
27503
- reason: text109("reason"),
27504
- metadata: jsonb58("metadata").$type().notNull().default({}),
27505
- ipAddress: text109("ip_address"),
27506
- createdAt: timestamp100("created_at").notNull().defaultNow()
27576
+ targetId: text111("target_id"),
27577
+ reason: text111("reason"),
27578
+ metadata: jsonb60("metadata").$type().notNull().default({}),
27579
+ ipAddress: text111("ip_address"),
27580
+ createdAt: timestamp102("created_at").notNull().defaultNow()
27507
27581
  },
27508
27582
  (table) => [
27509
- index95("admin_action_logs_created_idx").on(table.createdAt),
27510
- index95("admin_action_logs_action_idx").on(table.action, table.createdAt)
27583
+ index97("admin_action_logs_created_idx").on(table.createdAt),
27584
+ index97("admin_action_logs_action_idx").on(table.action, table.createdAt)
27511
27585
  ]
27512
27586
  );
27513
27587
 
27514
27588
  // src/schema/admin_notes.ts
27515
- import { pgTable as pgTable109, text as text110, varchar as varchar83, boolean as boolean36, timestamp as timestamp101, index as index96 } from "drizzle-orm/pg-core";
27516
- var adminNotes = pgTable109(
27589
+ import { pgTable as pgTable111, text as text112, varchar as varchar84, boolean as boolean36, timestamp as timestamp103, index as index98 } from "drizzle-orm/pg-core";
27590
+ var adminNotes = pgTable111(
27517
27591
  "admin_notes",
27518
27592
  {
27519
- id: text110("id").primaryKey(),
27593
+ id: text112("id").primaryKey(),
27520
27594
  // nanoid
27521
- targetType: varchar83("target_type", { length: 20 }).notNull(),
27595
+ targetType: varchar84("target_type", { length: 20 }).notNull(),
27522
27596
  // user | workspace | project
27523
- targetId: text110("target_id").notNull(),
27524
- body: text110("body").notNull(),
27525
- authorId: text110("author_id"),
27597
+ targetId: text112("target_id").notNull(),
27598
+ body: text112("body").notNull(),
27599
+ authorId: text112("author_id"),
27526
27600
  // FK → users.id (the staff member)
27527
- authorEmail: varchar83("author_email", { length: 320 }),
27601
+ authorEmail: varchar84("author_email", { length: 320 }),
27528
27602
  // denormalized for display
27529
27603
  pinned: boolean36("pinned").notNull().default(false),
27530
- createdAt: timestamp101("created_at").notNull().defaultNow(),
27531
- updatedAt: timestamp101("updated_at").notNull().defaultNow()
27604
+ createdAt: timestamp103("created_at").notNull().defaultNow(),
27605
+ updatedAt: timestamp103("updated_at").notNull().defaultNow()
27532
27606
  },
27533
27607
  (t) => [
27534
27608
  // Pinned first, then newest — the exact order the tab renders.
27535
- index96("admin_notes_target_idx").on(t.targetType, t.targetId, t.pinned, t.createdAt)
27609
+ index98("admin_notes_target_idx").on(t.targetType, t.targetId, t.pinned, t.createdAt)
27536
27610
  ]
27537
27611
  );
27538
27612
 
27539
27613
  // src/schema/admin_agent_sessions.ts
27540
- import { pgTable as pgTable110, text as text111, varchar as varchar84, doublePrecision as doublePrecision2, timestamp as timestamp102, index as index97 } from "drizzle-orm/pg-core";
27541
- var adminAgentSessions = pgTable110(
27614
+ import { pgTable as pgTable112, text as text113, varchar as varchar85, doublePrecision as doublePrecision2, timestamp as timestamp104, index as index99 } from "drizzle-orm/pg-core";
27615
+ var adminAgentSessions = pgTable112(
27542
27616
  "admin_agent_sessions",
27543
27617
  {
27544
- id: text111("id").primaryKey(),
27618
+ id: text113("id").primaryKey(),
27545
27619
  // nanoid
27546
- actorId: text111("actor_id").notNull(),
27620
+ actorId: text113("actor_id").notNull(),
27547
27621
  // FK → users.id (the staff member)
27548
- actorEmail: varchar84("actor_email", { length: 320 }),
27549
- title: varchar84("title", { length: 200 }),
27550
- status: varchar84("status", { length: 20 }).notNull().default("active"),
27622
+ actorEmail: varchar85("actor_email", { length: 320 }),
27623
+ title: varchar85("title", { length: 200 }),
27624
+ status: varchar85("status", { length: 20 }).notNull().default("active"),
27551
27625
  // active | error
27552
27626
  costUsd: doublePrecision2("cost_usd").notNull().default(0),
27553
- createdAt: timestamp102("created_at").notNull().defaultNow(),
27554
- updatedAt: timestamp102("updated_at").notNull().defaultNow(),
27555
- lastActiveAt: timestamp102("last_active_at").notNull().defaultNow()
27627
+ createdAt: timestamp104("created_at").notNull().defaultNow(),
27628
+ updatedAt: timestamp104("updated_at").notNull().defaultNow(),
27629
+ lastActiveAt: timestamp104("last_active_at").notNull().defaultNow()
27556
27630
  },
27557
- (t) => [index97("admin_agent_sessions_actor_idx").on(t.actorId, t.lastActiveAt)]
27631
+ (t) => [index99("admin_agent_sessions_actor_idx").on(t.actorId, t.lastActiveAt)]
27558
27632
  );
27559
27633
 
27560
27634
  // src/schema/crm_deals.ts
27561
- import { pgTable as pgTable111, text as text112, varchar as varchar85, integer as integer54, timestamp as timestamp103, index as index98, unique as unique13 } from "drizzle-orm/pg-core";
27635
+ import { pgTable as pgTable113, text as text114, varchar as varchar86, integer as integer55, timestamp as timestamp105, index as index100, unique as unique13 } from "drizzle-orm/pg-core";
27562
27636
  var CRM_STAGES = [
27563
27637
  "qualified",
27564
27638
  "conversation",
@@ -27566,136 +27640,210 @@ var CRM_STAGES = [
27566
27640
  "customer",
27567
27641
  "at_risk"
27568
27642
  ];
27569
- var crmDeals = pgTable111(
27643
+ var crmDeals = pgTable113(
27570
27644
  "crm_deals",
27571
27645
  {
27572
- id: text112("id").primaryKey(),
27646
+ id: text114("id").primaryKey(),
27573
27647
  // nanoid
27574
- workspaceId: text112("workspace_id").notNull(),
27648
+ workspaceId: text114("workspace_id").notNull(),
27575
27649
  // FK → workspaces.id
27576
- stage: varchar85("stage", { length: 20 }).notNull().default("qualified").$type(),
27577
- valueCents: integer54("value_cents"),
27650
+ stage: varchar86("stage", { length: 20 }).notNull().default("qualified").$type(),
27651
+ valueCents: integer55("value_cents"),
27578
27652
  // annual contract value the rep is working toward
27579
- ownerId: text112("owner_id"),
27653
+ ownerId: text114("owner_id"),
27580
27654
  // FK → users.id (the staff member on the account)
27581
- nextStep: text112("next_step"),
27582
- notes: text112("notes"),
27583
- lastTouchAt: timestamp103("last_touch_at"),
27584
- createdAt: timestamp103("created_at").notNull().defaultNow(),
27585
- updatedAt: timestamp103("updated_at").notNull().defaultNow()
27655
+ nextStep: text114("next_step"),
27656
+ notes: text114("notes"),
27657
+ lastTouchAt: timestamp105("last_touch_at"),
27658
+ createdAt: timestamp105("created_at").notNull().defaultNow(),
27659
+ updatedAt: timestamp105("updated_at").notNull().defaultNow()
27586
27660
  },
27587
27661
  (t) => [
27588
27662
  unique13("crm_deals_workspace_id_key").on(t.workspaceId),
27589
- index98("crm_deals_stage_idx").on(t.stage, t.lastTouchAt),
27590
- index98("crm_deals_owner_idx").on(t.ownerId)
27663
+ index100("crm_deals_stage_idx").on(t.stage, t.lastTouchAt),
27664
+ index100("crm_deals_owner_idx").on(t.ownerId)
27591
27665
  ]
27592
27666
  );
27593
27667
 
27594
27668
  // src/schema/project_env_vars.ts
27595
27669
  import {
27596
- pgTable as pgTable112,
27597
- text as text113,
27598
- varchar as varchar86,
27599
- timestamp as timestamp104,
27600
- index as index99,
27601
- uniqueIndex as uniqueIndex49
27670
+ pgTable as pgTable114,
27671
+ text as text115,
27672
+ varchar as varchar87,
27673
+ timestamp as timestamp106,
27674
+ index as index101,
27675
+ uniqueIndex as uniqueIndex50
27602
27676
  } from "drizzle-orm/pg-core";
27603
27677
  var ENV_VAR_SCOPES = ["production", "preview", "development"];
27604
- var projectEnvVars = pgTable112(
27678
+ var projectEnvVars = pgTable114(
27605
27679
  "project_env_vars",
27606
27680
  {
27607
- id: text113("id").primaryKey(),
27681
+ id: text115("id").primaryKey(),
27608
27682
  // nanoid
27609
- projectId: text113("project_id").notNull(),
27683
+ projectId: text115("project_id").notNull(),
27610
27684
  // FK to projects.id
27611
- workspaceId: text113("workspace_id").notNull(),
27685
+ workspaceId: text115("workspace_id").notNull(),
27612
27686
  // FK to workspaces.id — RLS scope
27613
- key: varchar86("key", { length: 128 }).notNull(),
27614
- valueEnc: text113("value_enc").notNull(),
27687
+ key: varchar87("key", { length: 128 }).notNull(),
27688
+ valueEnc: text115("value_enc").notNull(),
27615
27689
  // AES-256-GCM, `iv:tag:ciphertext` hex
27616
- scope: varchar86("scope", { length: 16 }).$type().notNull(),
27617
- updatedBy: text113("updated_by"),
27690
+ scope: varchar87("scope", { length: 16 }).$type().notNull(),
27691
+ updatedBy: text115("updated_by"),
27618
27692
  // FK to users.id, nullable
27619
- updatedAt: timestamp104("updated_at", { withTimezone: true }).notNull().defaultNow(),
27620
- createdAt: timestamp104("created_at", { withTimezone: true }).notNull().defaultNow()
27693
+ updatedAt: timestamp106("updated_at", { withTimezone: true }).notNull().defaultNow(),
27694
+ createdAt: timestamp106("created_at", { withTimezone: true }).notNull().defaultNow()
27621
27695
  },
27622
27696
  (table) => [
27623
27697
  // One value per key per scope — the same key MAY exist in production and preview.
27624
- uniqueIndex49("project_env_vars_project_key_scope_idx").on(
27698
+ uniqueIndex50("project_env_vars_project_key_scope_idx").on(
27625
27699
  table.projectId,
27626
27700
  table.key,
27627
27701
  table.scope
27628
27702
  ),
27629
- index99("project_env_vars_project_idx").on(table.projectId)
27703
+ index101("project_env_vars_project_idx").on(table.projectId)
27630
27704
  ]
27631
27705
  );
27632
27706
 
27633
27707
  // src/schema/mcp_connections.ts
27634
- import { pgTable as pgTable113, text as text114, varchar as varchar87, jsonb as jsonb59, timestamp as timestamp105, index as index100, uniqueIndex as uniqueIndex50 } from "drizzle-orm/pg-core";
27708
+ import { pgTable as pgTable115, text as text116, varchar as varchar88, jsonb as jsonb61, timestamp as timestamp107, index as index102, uniqueIndex as uniqueIndex51 } from "drizzle-orm/pg-core";
27635
27709
  import { sql as sql33 } from "drizzle-orm";
27636
- var mcpConnections = pgTable113(
27710
+ var mcpConnections = pgTable115(
27637
27711
  "mcp_connections",
27638
27712
  {
27639
- id: text114("id").primaryKey(),
27713
+ id: text116("id").primaryKey(),
27640
27714
  // nanoid
27641
- workspaceId: text114("workspace_id").notNull(),
27715
+ workspaceId: text116("workspace_id").notNull(),
27642
27716
  // FK → workspaces.id (RLS scope)
27643
- projectId: text114("project_id").notNull(),
27717
+ projectId: text116("project_id").notNull(),
27644
27718
  // FK → projects.id (application-enforced)
27645
27719
  /** Catalog slug (`notion` | `linear` | `hubspot` | `figma`) or `custom` for a user-added server. */
27646
- providerSlug: varchar87("provider_slug", { length: 32 }).notNull(),
27720
+ providerSlug: varchar88("provider_slug", { length: 32 }).notNull(),
27647
27721
  /** Where tools come from. See the header note — NOT interchangeable with authMode. */
27648
- kind: varchar87("kind", { length: 16 }).notNull().$type(),
27722
+ kind: varchar88("kind", { length: 16 }).notNull().$type(),
27649
27723
  /** How the credential is obtained. See the header note. */
27650
- authMode: varchar87("auth_mode", { length: 24 }).notNull().$type(),
27724
+ authMode: varchar88("auth_mode", { length: 24 }).notNull().$type(),
27651
27725
  /** Display name. The catalog's name for a known provider; user-supplied for a custom one. */
27652
- name: varchar87("name", { length: 120 }).notNull(),
27726
+ name: varchar88("name", { length: 120 }).notNull(),
27653
27727
  /** Remote Streamable-HTTP endpoint. NULL for `kind: 'rest'`, which has no MCP server. */
27654
- serverUrl: text114("server_url"),
27728
+ serverUrl: text116("server_url"),
27655
27729
  /** Display only — the connected Notion workspace / Linear org / Figma account. */
27656
- accountLabel: varchar87("account_label", { length: 255 }),
27657
- accessTokenEnc: text114("access_token_enc"),
27658
- refreshTokenEnc: text114("refresh_token_enc"),
27659
- expiresAt: timestamp105("expires_at", { withTimezone: true }),
27730
+ accountLabel: varchar88("account_label", { length: 255 }),
27731
+ accessTokenEnc: text116("access_token_enc"),
27732
+ refreshTokenEnc: text116("refresh_token_enc"),
27733
+ expiresAt: timestamp107("expires_at", { withTimezone: true }),
27660
27734
  /** `custom_headers` mode only: the encrypted header map a gateway requires on every call. */
27661
- headersEnc: text114("headers_enc"),
27735
+ headersEnc: text116("headers_enc"),
27662
27736
  /** DCR-issued or statically configured — the same two columns serve both, deliberately. */
27663
- oauthClientId: varchar87("oauth_client_id", { length: 255 }),
27664
- oauthClientSecretEnc: text114("oauth_client_secret_enc"),
27737
+ oauthClientId: varchar88("oauth_client_id", { length: 255 }),
27738
+ oauthClientSecretEnc: text116("oauth_client_secret_enc"),
27665
27739
  /** Both cleared on a successful exchange; see the header note on why they must exist at all. */
27666
- oauthState: text114("oauth_state"),
27667
- pkceVerifierEnc: text114("pkce_verifier_enc"),
27740
+ oauthState: text116("oauth_state"),
27741
+ pkceVerifierEnc: text116("pkce_verifier_enc"),
27668
27742
  /** Discovery output: authorization server metadata, token endpoint, RFC 8707 resource. */
27669
- authMetadata: jsonb59("auth_metadata").$type(),
27670
- scopes: text114("scopes").array().$type(),
27743
+ authMetadata: jsonb61("auth_metadata").$type(),
27744
+ scopes: text116("scopes").array().$type(),
27671
27745
  /**
27672
27746
  * Full descriptors (name, description, inputSchema, annotations) — NOT just names. The
27673
27747
  * read-only boundary is decided from `annotations.readOnlyHint`, so the names alone would
27674
27748
  * force a live listTools on the turn path to answer a governance question.
27675
27749
  */
27676
- toolsCache: jsonb59("tools_cache").$type().notNull().default([]),
27677
- toolsCachedAt: timestamp105("tools_cached_at", { withTimezone: true }),
27750
+ toolsCache: jsonb61("tools_cache").$type().notNull().default([]),
27751
+ toolsCachedAt: timestamp107("tools_cached_at", { withTimezone: true }),
27678
27752
  /**
27679
27753
  * pending | ok | invalid | revoked. `pending` is the pre-consent row; `invalid` is set on a
27680
27754
  * provider 401 or a decrypt failure so the UI can say "reconnect" instead of replaying the
27681
27755
  * same auth error on every turn forever.
27682
27756
  */
27683
- status: varchar87("status", { length: 16 }).notNull().default("pending").$type(),
27757
+ status: varchar88("status", { length: 16 }).notNull().default("pending").$type(),
27684
27758
  /** Machine-readable companion to `status`, e.g. `decrypt_failed`, `provider_401`. */
27685
- statusReason: varchar87("status_reason", { length: 64 }),
27686
- lastError: text114("last_error"),
27687
- lastUsedAt: timestamp105("last_used_at", { withTimezone: true }),
27688
- connectedBy: text114("connected_by"),
27759
+ statusReason: varchar88("status_reason", { length: 64 }),
27760
+ lastError: text116("last_error"),
27761
+ lastUsedAt: timestamp107("last_used_at", { withTimezone: true }),
27762
+ connectedBy: text116("connected_by"),
27689
27763
  // FK → users(id), added in migration
27690
27764
  ...auditColumns,
27691
27765
  ...softDeleteColumn
27692
27766
  },
27693
27767
  (t) => [
27694
- index100("mcp_connections_workspace_idx").on(t.workspaceId),
27695
- index100("mcp_connections_project_idx").on(t.projectId),
27768
+ index102("mcp_connections_workspace_idx").on(t.workspaceId),
27769
+ index102("mcp_connections_project_idx").on(t.projectId),
27696
27770
  // Reconnecting a catalog provider UPDATEs rather than accumulating a second live credential.
27697
27771
  // Custom connectors are excluded: a project may legitimately add many distinct MCP servers.
27698
- uniqueIndex50("mcp_connections_project_provider_unique").on(t.projectId, t.providerSlug).where(sql33`deleted_at IS NULL AND provider_slug <> 'custom'`)
27772
+ uniqueIndex51("mcp_connections_project_provider_unique").on(t.projectId, t.providerSlug).where(sql33`deleted_at IS NULL AND provider_slug <> 'custom'`)
27773
+ ]
27774
+ );
27775
+
27776
+ // src/schema/crm_connections.ts
27777
+ import {
27778
+ pgTable as pgTable116,
27779
+ text as text117,
27780
+ timestamp as timestamp108,
27781
+ boolean as boolean37,
27782
+ jsonb as jsonb62,
27783
+ integer as integer56,
27784
+ uniqueIndex as uniqueIndex52
27785
+ } from "drizzle-orm/pg-core";
27786
+ var crmConnections = pgTable116(
27787
+ "crm_connections",
27788
+ {
27789
+ id: text117("id").primaryKey(),
27790
+ workspaceId: text117("workspace_id").notNull(),
27791
+ provider: text117("provider").$type().notNull(),
27792
+ accountId: text117("account_id").notNull(),
27793
+ accountName: text117("account_name").notNull(),
27794
+ instanceUrl: text117("instance_url").notNull(),
27795
+ sandbox: boolean37("sandbox").notNull().default(false),
27796
+ status: text117("status").notNull().default("connected"),
27797
+ accessToken: text117("access_token").notNull(),
27798
+ refreshToken: text117("refresh_token").notNull(),
27799
+ expiresAt: timestamp108("expires_at").notNull(),
27800
+ createdAt: timestamp108("created_at").notNull().defaultNow(),
27801
+ updatedAt: timestamp108("updated_at").notNull().defaultNow()
27802
+ },
27803
+ (t) => [
27804
+ uniqueIndex52("crm_connection_account_uq").on(
27805
+ t.workspaceId,
27806
+ t.provider,
27807
+ t.accountId
27808
+ )
27809
+ ]
27810
+ );
27811
+ var crmOauthStates = pgTable116("crm_oauth_states", {
27812
+ id: text117("id").primaryKey(),
27813
+ workspaceId: text117("workspace_id").notNull(),
27814
+ userId: text117("user_id").notNull(),
27815
+ provider: text117("provider").notNull(),
27816
+ verifier: text117("verifier").notNull(),
27817
+ returnPath: text117("return_path").notNull(),
27818
+ sandbox: boolean37("sandbox").notNull(),
27819
+ expiresAt: timestamp108("expires_at").notNull()
27820
+ });
27821
+ var formIntegrationDeliveries = pgTable116(
27822
+ "form_integration_deliveries",
27823
+ {
27824
+ id: text117("id").primaryKey(),
27825
+ workspaceId: text117("workspace_id").notNull(),
27826
+ formId: text117("form_id").notNull(),
27827
+ integrationId: text117("integration_id").notNull(),
27828
+ eventId: text117("event_id").notNull(),
27829
+ submissionId: text117("submission_id").notNull(),
27830
+ snapshot: jsonb62("snapshot").$type().notNull(),
27831
+ data: jsonb62("data").$type().notNull(),
27832
+ status: text117("status").notNull().default("queued"),
27833
+ attempts: integer56("attempts").notNull().default(0),
27834
+ lastError: text117("last_error"),
27835
+ remoteRecordId: text117("remote_record_id"),
27836
+ nextAttemptAt: timestamp108("next_attempt_at").notNull().defaultNow(),
27837
+ leaseUntil: timestamp108("lease_until"),
27838
+ createdAt: timestamp108("created_at").notNull().defaultNow(),
27839
+ updatedAt: timestamp108("updated_at").notNull().defaultNow()
27840
+ },
27841
+ (t) => [
27842
+ uniqueIndex52("crm_delivery_event_uq").on(
27843
+ t.workspaceId,
27844
+ t.eventId,
27845
+ t.integrationId
27846
+ )
27699
27847
  ]
27700
27848
  );
27701
27849
 
@@ -28263,6 +28411,7 @@ export {
28263
28411
  bcmsMigrationFlags,
28264
28412
  betaWaitlist,
28265
28413
  billingAddons,
28414
+ billingAlerts,
28266
28415
  billingCustomers,
28267
28416
  branchColumns,
28268
28417
  branchPreviewGrants,
@@ -28299,10 +28448,13 @@ export {
28299
28448
  contentLocks,
28300
28449
  contentModels,
28301
28450
  contentModelsRelations,
28451
+ contentNavigation,
28302
28452
  contentVersions,
28303
28453
  conversionBriefsIssued,
28304
28454
  conversionProposals,
28455
+ crmConnections,
28305
28456
  crmDeals,
28457
+ crmOauthStates,
28306
28458
  customDomains,
28307
28459
  db,
28308
28460
  deployTargets,
@@ -28317,6 +28469,7 @@ export {
28317
28469
  foldersRelations,
28318
28470
  formContacts,
28319
28471
  formContactsRelations,
28472
+ formIntegrationDeliveries,
28320
28473
  formIntegrations,
28321
28474
  formIntegrationsRelations,
28322
28475
  formSubmissions,