@bettercms-ai/db 0.11.0 → 0.12.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
@@ -11654,18 +11654,18 @@ var require_common = __commonJS({
11654
11654
  if (typeof args[0] !== "string") {
11655
11655
  args.unshift("%O");
11656
11656
  }
11657
- let index111 = 0;
11657
+ let index113 = 0;
11658
11658
  args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
11659
11659
  if (match === "%%") {
11660
11660
  return "%";
11661
11661
  }
11662
- index111++;
11662
+ index113++;
11663
11663
  const formatter = createDebug.formatters[format];
11664
11664
  if (typeof formatter === "function") {
11665
- const val = args[index111];
11665
+ const val = args[index113];
11666
11666
  match = formatter.call(self2, val);
11667
- args.splice(index111, 1);
11668
- index111--;
11667
+ args.splice(index113, 1);
11668
+ index113--;
11669
11669
  }
11670
11670
  return match;
11671
11671
  });
@@ -11901,15 +11901,15 @@ var require_browser = __commonJS({
11901
11901
  }
11902
11902
  const c = "color: " + this.color;
11903
11903
  args.splice(1, 0, c, "color: inherit");
11904
- let index111 = 0;
11904
+ let index113 = 0;
11905
11905
  let lastC = 0;
11906
11906
  args[0].replace(/%[a-zA-Z%]/g, (match) => {
11907
11907
  if (match === "%%") {
11908
11908
  return;
11909
11909
  }
11910
- index111++;
11910
+ index113++;
11911
11911
  if (match === "%c") {
11912
- lastC = index111;
11912
+ lastC = index113;
11913
11913
  }
11914
11914
  });
11915
11915
  args.splice(lastC, 0, c);
@@ -14470,10 +14470,10 @@ var require_axios = __commonJS({
14470
14470
  value = stringifyWithDepthLimit(value, 1);
14471
14471
  } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
14472
14472
  key = removeBrackets(key);
14473
- arr.forEach(function each(el, index111) {
14473
+ arr.forEach(function each(el, index113) {
14474
14474
  !(utils$1.isUndefined(el) || el === null) && formData.append(
14475
14475
  // eslint-disable-next-line no-nested-ternary
14476
- indexes === true ? renderKey([key], index111, dots) : indexes === null ? key : key + "[]",
14476
+ indexes === true ? renderKey([key], index113, dots) : indexes === null ? key : key + "[]",
14477
14477
  convertValue(el)
14478
14478
  );
14479
14479
  });
@@ -14774,9 +14774,9 @@ var require_axios = __commonJS({
14774
14774
  });
14775
14775
  }
14776
14776
  var MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
14777
- function throwIfDepthExceeded(index111) {
14778
- if (index111 > MAX_DEPTH) {
14779
- throw new AxiosError("FormData field is too deeply nested (" + index111 + " levels). Max depth: " + MAX_DEPTH, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
14777
+ function throwIfDepthExceeded(index113) {
14778
+ if (index113 > MAX_DEPTH) {
14779
+ throw new AxiosError("FormData field is too deeply nested (" + index113 + " levels). Max depth: " + MAX_DEPTH, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
14780
14780
  }
14781
14781
  }
14782
14782
  function parsePropPath(name) {
@@ -14802,12 +14802,12 @@ var require_axios = __commonJS({
14802
14802
  return obj;
14803
14803
  }
14804
14804
  function formDataToJSON(formData) {
14805
- function buildPath(path2, value, target, index111) {
14806
- throwIfDepthExceeded(index111);
14807
- let name = path2[index111++];
14805
+ function buildPath(path2, value, target, index113) {
14806
+ throwIfDepthExceeded(index113);
14807
+ let name = path2[index113++];
14808
14808
  if (name === "__proto__") return true;
14809
14809
  const isNumericKey = Number.isFinite(+name);
14810
- const isLast = index111 >= path2.length;
14810
+ const isLast = index113 >= path2.length;
14811
14811
  name = !name && utils$1.isArray(target) ? target.length : name;
14812
14812
  if (isLast) {
14813
14813
  if (utils$1.hasOwnProp(target, name)) {
@@ -14820,7 +14820,7 @@ var require_axios = __commonJS({
14820
14820
  if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
14821
14821
  target[name] = [];
14822
14822
  }
14823
- const result = buildPath(path2, value, target[name], index111);
14823
+ const result = buildPath(path2, value, target[name], index113);
14824
14824
  if (result && utils$1.isArray(target[name])) {
14825
14825
  target[name] = arrayToObject(target[name]);
14826
14826
  }
@@ -15489,20 +15489,20 @@ var require_axios = __commonJS({
15489
15489
  if (parts[0] !== "127") return false;
15490
15490
  return parts.every((p) => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
15491
15491
  };
15492
- var parseIPv4Octet = (text128) => {
15493
- if (/^0[xX][0-9a-fA-F]+$/.test(text128)) {
15494
- const n = parseInt(text128.slice(2), 16);
15492
+ var parseIPv4Octet = (text130) => {
15493
+ if (/^0[xX][0-9a-fA-F]+$/.test(text130)) {
15494
+ const n = parseInt(text130.slice(2), 16);
15495
15495
  return Number.isFinite(n) ? n : null;
15496
15496
  }
15497
- if (text128.length > 1 && /^0[0-7]+$/.test(text128)) {
15498
- const n = parseInt(text128, 8);
15497
+ if (text130.length > 1 && /^0[0-7]+$/.test(text130)) {
15498
+ const n = parseInt(text130, 8);
15499
15499
  return Number.isFinite(n) ? n : null;
15500
15500
  }
15501
- if (text128.length > 1 && /^0[0-9]+$/.test(text128)) {
15501
+ if (text130.length > 1 && /^0[0-9]+$/.test(text130)) {
15502
15502
  return null;
15503
15503
  }
15504
- if (/^[0-9]+$/.test(text128)) {
15505
- const n = parseInt(text128, 10);
15504
+ if (/^[0-9]+$/.test(text130)) {
15505
+ const n = parseInt(text130, 10);
15506
15506
  return Number.isFinite(n) ? n : null;
15507
15507
  }
15508
15508
  return null;
@@ -15840,12 +15840,12 @@ var require_axios = __commonJS({
15840
15840
  };
15841
15841
  }
15842
15842
  function throttle(fn, freq) {
15843
- let timestamp119 = 0;
15843
+ let timestamp121 = 0;
15844
15844
  let threshold = 1e3 / freq;
15845
15845
  let lastArgs;
15846
15846
  let timer;
15847
15847
  const invoke = (args, now = Date.now()) => {
15848
- timestamp119 = now;
15848
+ timestamp121 = now;
15849
15849
  lastArgs = null;
15850
15850
  if (timer) {
15851
15851
  clearTimeout(timer);
@@ -15855,7 +15855,7 @@ var require_axios = __commonJS({
15855
15855
  };
15856
15856
  const throttled = (...args) => {
15857
15857
  const now = Date.now();
15858
- const passed = now - timestamp119;
15858
+ const passed = now - timestamp121;
15859
15859
  if (passed >= threshold) {
15860
15860
  invoke(args, now);
15861
15861
  } else {
@@ -18242,9 +18242,9 @@ var require_axios = __commonJS({
18242
18242
  if (!this._listeners) {
18243
18243
  return;
18244
18244
  }
18245
- const index111 = this._listeners.indexOf(listener);
18246
- if (index111 !== -1) {
18247
- this._listeners.splice(index111, 1);
18245
+ const index113 = this._listeners.indexOf(listener);
18246
+ if (index113 !== -1) {
18247
+ this._listeners.splice(index113, 1);
18248
18248
  }
18249
18249
  }
18250
18250
  toAbortSignal() {
@@ -21914,6 +21914,8 @@ var require_Typesense = __commonJS({
21914
21914
  // src/schema/_index.ts
21915
21915
  var index_exports = {};
21916
21916
  __export(index_exports, {
21917
+ BINDING_DECISION_OPS: () => BINDING_DECISION_OPS,
21918
+ BINDING_DECISION_STATES: () => BINDING_DECISION_STATES,
21917
21919
  BUILD_TRIGGER_KINDS: () => BUILD_TRIGGER_KINDS,
21918
21920
  CONTENT_LOCK_MODES: () => CONTENT_LOCK_MODES,
21919
21921
  CONTENT_LOCK_TARGET_KINDS: () => CONTENT_LOCK_TARGET_KINDS,
@@ -21983,6 +21985,7 @@ __export(index_exports, {
21983
21985
  billingAddons: () => billingAddons,
21984
21986
  billingAlerts: () => billingAlerts,
21985
21987
  billingCustomers: () => billingCustomers,
21988
+ bindingDecisions: () => bindingDecisions,
21986
21989
  branchColumns: () => branchColumns,
21987
21990
  branchPreviewGrants: () => branchPreviewGrants,
21988
21991
  branchPreviewShares: () => branchPreviewShares,
@@ -22031,6 +22034,7 @@ __export(index_exports, {
22031
22034
  deployTargets: () => deployTargets,
22032
22035
  deviceAuthorizations: () => deviceAuthorizations,
22033
22036
  emailSuppressions: () => emailSuppressions,
22037
+ entrySlotModels: () => entrySlotModels,
22034
22038
  externalDeployments: () => externalDeployments,
22035
22039
  folders: () => folders,
22036
22040
  foldersRelations: () => foldersRelations,
@@ -23362,6 +23366,10 @@ var projects = pgTable10(
23362
23366
  // deploy-pass deploys under /srv/bcms/<subdomain>. Unique index + LDH check live
23363
23367
  // in migration 0036 (applied via setup-db). NULL = no staging site yet.
23364
23368
  subdomain: varchar10("subdomain", { length: 63 }),
23369
+ // The staging name the owner chose: <alias>.bettercms.site serves the same site as the
23370
+ // handle, which never changes (it keys the release dirs, R2 pointers and runtimes).
23371
+ // Unique across live projects, and never equal to any handle — both enforced in 0468.
23372
+ subdomainAlias: varchar10("subdomain_alias", { length: 63 }),
23365
23373
  // Site access visibility (FLO-159): 'workspace' = every workspace member can view
23366
23374
  // (default = legacy behaviour); 'restricted' = only workspace owners/admins and
23367
23375
  // explicitly-added project_members. See src/lib/auth/project-access.ts.
@@ -27049,50 +27057,78 @@ var savedBlocks = pgTable86(
27049
27057
  (t) => [index73("saved_blocks_project_idx").on(t.workspaceId, t.projectId, t.createdAt)]
27050
27058
  );
27051
27059
 
27060
+ // src/schema/entry_slot_models.ts
27061
+ import { index as index74, integer as integer41, jsonb as jsonb47, pgTable as pgTable87, primaryKey as primaryKey8, real as real2, text as text88, timestamp as timestamp80, varchar as varchar64 } from "drizzle-orm/pg-core";
27062
+ var entrySlotModels = pgTable87(
27063
+ "entry_slot_models",
27064
+ {
27065
+ workspaceId: text88("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27066
+ projectId: text88("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27067
+ releaseSha: text88("release_sha").notNull(),
27068
+ templateSig: text88("template_sig").notNull(),
27069
+ path: text88("path").notNull(),
27070
+ /** The collection's name as the catalog spells it (its page slug). */
27071
+ collectionId: text88("collection_id").notNull(),
27072
+ slotKey: text88("slot_key").notNull(),
27073
+ /** The display function (`Fx`, @bettercms-ai/entry-bind). */
27074
+ fx: jsonb47("fx").$type().notNull(),
27075
+ support: integer41("support").notNull(),
27076
+ conf: real2("conf").notNull(),
27077
+ /** `induced` | `declared` | `guest` | `override` (CHECK in the migration). */
27078
+ source: varchar64("source", { length: 16 }).notNull(),
27079
+ createdBy: text88("created_by").references(() => users.id, { onDelete: "set null" }),
27080
+ createdAt: timestamp80("created_at").notNull().defaultNow()
27081
+ },
27082
+ (t) => [
27083
+ primaryKey8({ name: "entry_slot_models_pkey", columns: [t.projectId, t.releaseSha, t.templateSig, t.path] }),
27084
+ index74("entry_slot_models_project_sha_idx").on(t.workspaceId, t.projectId, t.releaseSha)
27085
+ ]
27086
+ );
27087
+
27052
27088
  // src/schema/content_model_versions.ts
27053
- import { index as index74, integer as integer41, jsonb as jsonb47, pgTable as pgTable87, text as text88, timestamp as timestamp80 } from "drizzle-orm/pg-core";
27054
- var contentModelVersions = pgTable87(
27089
+ import { index as index75, integer as integer42, jsonb as jsonb48, pgTable as pgTable88, text as text89, timestamp as timestamp81 } from "drizzle-orm/pg-core";
27090
+ var contentModelVersions = pgTable88(
27055
27091
  "content_model_versions",
27056
27092
  {
27057
- id: text88("id").primaryKey(),
27058
- workspaceId: text88("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27059
- modelId: text88("model_id").notNull().references(() => contentModels.id, { onDelete: "cascade" }),
27060
- version: integer41("version").notNull(),
27093
+ id: text89("id").primaryKey(),
27094
+ workspaceId: text89("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27095
+ modelId: text89("model_id").notNull().references(() => contentModels.id, { onDelete: "cascade" }),
27096
+ version: integer42("version").notNull(),
27061
27097
  /** The model as written. @see ContentModelSnapshot */
27062
- snapshot: jsonb47("snapshot").$type().notNull(),
27098
+ snapshot: jsonb48("snapshot").$type().notNull(),
27063
27099
  /** What changed against the state this write replaced. @see ContentModelChangeSummary */
27064
- summary: jsonb47("summary").$type().notNull().default({}),
27065
- origin: text88("origin").$type().notNull(),
27066
- createdBy: text88("created_by").references(() => users.id, { onDelete: "set null" }),
27067
- createdAt: timestamp80("created_at").notNull().defaultNow()
27100
+ summary: jsonb48("summary").$type().notNull().default({}),
27101
+ origin: text89("origin").$type().notNull(),
27102
+ createdBy: text89("created_by").references(() => users.id, { onDelete: "set null" }),
27103
+ createdAt: timestamp81("created_at").notNull().defaultNow()
27068
27104
  },
27069
- (t) => [index74("content_model_versions_model_version_idx").on(t.modelId, t.version.desc())]
27105
+ (t) => [index75("content_model_versions_model_version_idx").on(t.modelId, t.version.desc())]
27070
27106
  );
27071
27107
 
27072
27108
  // src/schema/component_variants.ts
27073
27109
  import {
27074
- pgTable as pgTable88,
27075
- text as text89,
27076
- varchar as varchar64,
27077
- timestamp as timestamp81,
27078
- jsonb as jsonb48,
27079
- integer as integer42,
27080
- index as index75,
27110
+ pgTable as pgTable89,
27111
+ text as text90,
27112
+ varchar as varchar65,
27113
+ timestamp as timestamp82,
27114
+ jsonb as jsonb49,
27115
+ integer as integer43,
27116
+ index as index76,
27081
27117
  unique as unique4,
27082
27118
  uniqueIndex as uniqueIndex37
27083
27119
  } from "drizzle-orm/pg-core";
27084
27120
  import { relations as relations15 } from "drizzle-orm/relations";
27085
27121
  import { sql as sql20 } from "drizzle-orm";
27086
- var componentVariants = pgTable88(
27122
+ var componentVariants = pgTable89(
27087
27123
  "component_variants",
27088
27124
  {
27089
- id: text89("id").primaryKey(),
27090
- workspaceId: text89("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27091
- componentId: text89("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27092
- name: varchar64("name", { length: 255 }).notNull(),
27125
+ id: text90("id").primaryKey(),
27126
+ workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27127
+ componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27128
+ name: varchar65("name", { length: 255 }).notNull(),
27093
27129
  // `<component-root>-<variant-name>`, e.g. `footer-compact`.
27094
- key: varchar64("key", { length: 356 }).notNull(),
27095
- delta: jsonb48("delta").$type().notNull().default({
27130
+ key: varchar65("key", { length: 356 }).notNull(),
27131
+ delta: jsonb49("delta").$type().notNull().default({
27096
27132
  fieldOverrides: [],
27097
27133
  addedProps: [],
27098
27134
  removedFieldKeys: [],
@@ -27100,13 +27136,13 @@ var componentVariants = pgTable88(
27100
27136
  valueOverrides: {},
27101
27137
  addedBlocks: []
27102
27138
  }),
27103
- publishedDelta: jsonb48("published_delta").$type(),
27104
- status: varchar64("status", { length: 20 }).$type().notNull().default("draft"),
27105
- publishedAt: timestamp81("published_at"),
27106
- optimisticVersion: integer42("optimistic_version").notNull().default(0),
27107
- createdAt: timestamp81("created_at").notNull().defaultNow(),
27108
- updatedAt: timestamp81("updated_at").notNull().defaultNow(),
27109
- deletedAt: timestamp81("deleted_at")
27139
+ publishedDelta: jsonb49("published_delta").$type(),
27140
+ status: varchar65("status", { length: 20 }).$type().notNull().default("draft"),
27141
+ publishedAt: timestamp82("published_at"),
27142
+ optimisticVersion: integer43("optimistic_version").notNull().default(0),
27143
+ createdAt: timestamp82("created_at").notNull().defaultNow(),
27144
+ updatedAt: timestamp82("updated_at").notNull().defaultNow(),
27145
+ deletedAt: timestamp82("deleted_at")
27110
27146
  },
27111
27147
  (table) => [
27112
27148
  unique4("component_variants_id_workspace_component_unique").on(
@@ -27114,8 +27150,8 @@ var componentVariants = pgTable88(
27114
27150
  table.workspaceId,
27115
27151
  table.componentId
27116
27152
  ),
27117
- index75("component_variants_workspace_idx").on(table.workspaceId),
27118
- index75("component_variants_component_idx").on(table.componentId),
27153
+ index76("component_variants_workspace_idx").on(table.workspaceId),
27154
+ index76("component_variants_component_idx").on(table.componentId),
27119
27155
  uniqueIndex37("component_variants_component_key_unique").on(table.componentId, table.key).where(sql20`${table.deletedAt} IS NULL`)
27120
27156
  ]
27121
27157
  );
@@ -27134,37 +27170,37 @@ var componentVariantsRelations = relations15(componentVariants, ({ one }) => ({
27134
27170
  import {
27135
27171
  bigint as bigint4,
27136
27172
  foreignKey as foreignKey6,
27137
- index as index76,
27138
- integer as integer43,
27139
- jsonb as jsonb49,
27140
- pgTable as pgTable89,
27141
- text as text90,
27142
- timestamp as timestamp82,
27173
+ index as index77,
27174
+ integer as integer44,
27175
+ jsonb as jsonb50,
27176
+ pgTable as pgTable90,
27177
+ text as text91,
27178
+ timestamp as timestamp83,
27143
27179
  unique as unique5,
27144
27180
  uniqueIndex as uniqueIndex38,
27145
27181
  uuid as uuid2,
27146
- varchar as varchar65
27182
+ varchar as varchar66
27147
27183
  } from "drizzle-orm/pg-core";
27148
27184
  import { sql as sql21 } from "drizzle-orm";
27149
- var componentImplementationCandidates = pgTable89(
27185
+ var componentImplementationCandidates = pgTable90(
27150
27186
  "component_implementation_candidates",
27151
27187
  {
27152
- id: text90("id").primaryKey(),
27153
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27154
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27155
- componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27156
- variantGroupId: text90("variant_group_id"),
27157
- familyKey: text90("family_key").notNull(),
27158
- familyContractHash: varchar65("family_contract_hash", { length: 64 }).notNull(),
27188
+ id: text91("id").primaryKey(),
27189
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27190
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27191
+ componentId: text91("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27192
+ variantGroupId: text91("variant_group_id"),
27193
+ familyKey: text91("family_key").notNull(),
27194
+ familyContractHash: varchar66("family_contract_hash", { length: 64 }).notNull(),
27159
27195
  // Exact value-bearing family contract. Unlike `contract.canonicalInputs` (the
27160
27196
  // renderer/schema projection), this snapshot deliberately retains defaults because it
27161
27197
  // becomes the immutable public-input source pinned by each published variant.
27162
- familyContract: jsonb49("family_contract").$type(),
27163
- schemaHash: varchar65("schema_hash", { length: 64 }).notNull(),
27164
- brandContractHash: varchar65("brand_contract_hash", { length: 64 }).notNull(),
27165
- contract: jsonb49("contract").$type().notNull(),
27166
- createdBy: text90("created_by"),
27167
- createdAt: timestamp82("created_at").notNull().defaultNow()
27198
+ familyContract: jsonb50("family_contract").$type(),
27199
+ schemaHash: varchar66("schema_hash", { length: 64 }).notNull(),
27200
+ brandContractHash: varchar66("brand_contract_hash", { length: 64 }).notNull(),
27201
+ contract: jsonb50("contract").$type().notNull(),
27202
+ createdBy: text91("created_by"),
27203
+ createdAt: timestamp83("created_at").notNull().defaultNow()
27168
27204
  },
27169
27205
  (table) => [
27170
27206
  foreignKey6({
@@ -27183,26 +27219,26 @@ var componentImplementationCandidates = pgTable89(
27183
27219
  table.familyContractHash
27184
27220
  ).where(sql21`${table.familyContract} IS NOT NULL`),
27185
27221
  unique5("component_implementation_candidate_scope_unique").on(table.id, table.projectId, table.componentId),
27186
- index76("component_implementation_candidates_component_idx").on(table.projectId, table.componentId)
27222
+ index77("component_implementation_candidates_component_idx").on(table.projectId, table.componentId)
27187
27223
  ]
27188
27224
  );
27189
- var componentFamilyManifests = pgTable89(
27225
+ var componentFamilyManifests = pgTable90(
27190
27226
  "component_family_manifests",
27191
27227
  {
27192
- id: text90("id").primaryKey(),
27193
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27194
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27195
- familyKey: text90("family_key").notNull(),
27196
- familyContractHash: varchar65("family_contract_hash", { length: 64 }).notNull(),
27197
- familyContract: jsonb49("family_contract").$type(),
27198
- commitSha: varchar65("commit_sha", { length: 64 }).notNull(),
27199
- adapterHash: varchar65("adapter_hash", { length: 64 }).notNull(),
27200
- manifestHash: varchar65("manifest_hash", { length: 64 }).notNull(),
27201
- previewOrigin: text90("preview_origin").notNull(),
27202
- nativeViewports: jsonb49("native_viewports").$type().notNull(),
27203
- adapter: jsonb49("adapter").$type().notNull(),
27204
- createdBy: text90("created_by"),
27205
- createdAt: timestamp82("created_at").notNull().defaultNow()
27228
+ id: text91("id").primaryKey(),
27229
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27230
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27231
+ familyKey: text91("family_key").notNull(),
27232
+ familyContractHash: varchar66("family_contract_hash", { length: 64 }).notNull(),
27233
+ familyContract: jsonb50("family_contract").$type(),
27234
+ commitSha: varchar66("commit_sha", { length: 64 }).notNull(),
27235
+ adapterHash: varchar66("adapter_hash", { length: 64 }).notNull(),
27236
+ manifestHash: varchar66("manifest_hash", { length: 64 }).notNull(),
27237
+ previewOrigin: text91("preview_origin").notNull(),
27238
+ nativeViewports: jsonb50("native_viewports").$type().notNull(),
27239
+ adapter: jsonb50("adapter").$type().notNull(),
27240
+ createdBy: text91("created_by"),
27241
+ createdAt: timestamp83("created_at").notNull().defaultNow()
27206
27242
  },
27207
27243
  (table) => [
27208
27244
  foreignKey6({
@@ -27214,47 +27250,47 @@ var componentFamilyManifests = pgTable89(
27214
27250
  unique5("component_family_manifests_id_project_unique").on(table.id, table.projectId),
27215
27251
  unique5("component_family_manifests_evidence_unique").on(table.id, table.projectId, table.manifestHash),
27216
27252
  uniqueIndex38("component_family_manifest_tuple_unique").on(table.projectId, table.familyKey, table.manifestHash),
27217
- index76("component_family_manifests_family_idx").on(table.projectId, table.familyKey, table.createdAt)
27253
+ index77("component_family_manifests_family_idx").on(table.projectId, table.familyKey, table.createdAt)
27218
27254
  ]
27219
27255
  );
27220
- var componentImplementationRequests = pgTable89(
27256
+ var componentImplementationRequests = pgTable90(
27221
27257
  "component_implementation_requests",
27222
27258
  {
27223
- id: text90("id").primaryKey(),
27224
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27225
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27226
- componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27227
- candidateId: text90("candidate_id").notNull(),
27228
- componentVersion: integer43("component_version").notNull(),
27229
- provider: varchar65("provider", { length: 20 }).$type().notNull(),
27230
- status: varchar65("status", { length: 20 }).$type().notNull(),
27231
- familyKey: text90("family_key").notNull(),
27232
- familyContractHash: varchar65("family_contract_hash", { length: 64 }).notNull(),
27233
- schemaHash: varchar65("schema_hash", { length: 64 }).notNull(),
27234
- brandContractHash: varchar65("brand_contract_hash", { length: 64 }).notNull(),
27235
- dependenciesHash: varchar65("dependencies_hash", { length: 64 }).notNull(),
27236
- commitSha: varchar65("commit_sha", { length: 64 }),
27237
- adapterHash: varchar65("adapter_hash", { length: 64 }),
27238
- familyManifestHash: varchar65("family_manifest_hash", { length: 64 }),
27239
- previewOrigin: text90("preview_origin"),
27240
- nativeViewports: jsonb49("native_viewports").$type(),
27241
- adapter: jsonb49("adapter").$type(),
27242
- providerProvenance: jsonb49("provider_provenance").$type(),
27243
- claimedByApiKeyId: text90("claimed_by_api_key_id"),
27244
- claimCredentialHash: varchar65("claim_credential_hash", { length: 64 }),
27245
- claimCredentialExpiresAt: timestamp82("claim_credential_expires_at", { withTimezone: true }),
27246
- claimCredentialConsumedAt: timestamp82("claim_credential_consumed_at", { withTimezone: true }),
27247
- completionHash: varchar65("completion_hash", { length: 64 }),
27248
- evidenceId: text90("evidence_id"),
27249
- errorCode: text90("error_code"),
27250
- errorMessage: text90("error_message"),
27251
- requestedBy: text90("requested_by"),
27252
- createdAt: timestamp82("created_at", { withTimezone: true }).notNull().defaultNow(),
27253
- expiresAt: timestamp82("expires_at", { withTimezone: true }).notNull(),
27254
- claimedAt: timestamp82("claimed_at", { withTimezone: true }),
27255
- completedAt: timestamp82("completed_at", { withTimezone: true }),
27256
- failedAt: timestamp82("failed_at", { withTimezone: true }),
27257
- updatedAt: timestamp82("updated_at", { withTimezone: true }).notNull().defaultNow()
27259
+ id: text91("id").primaryKey(),
27260
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27261
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27262
+ componentId: text91("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27263
+ candidateId: text91("candidate_id").notNull(),
27264
+ componentVersion: integer44("component_version").notNull(),
27265
+ provider: varchar66("provider", { length: 20 }).$type().notNull(),
27266
+ status: varchar66("status", { length: 20 }).$type().notNull(),
27267
+ familyKey: text91("family_key").notNull(),
27268
+ familyContractHash: varchar66("family_contract_hash", { length: 64 }).notNull(),
27269
+ schemaHash: varchar66("schema_hash", { length: 64 }).notNull(),
27270
+ brandContractHash: varchar66("brand_contract_hash", { length: 64 }).notNull(),
27271
+ dependenciesHash: varchar66("dependencies_hash", { length: 64 }).notNull(),
27272
+ commitSha: varchar66("commit_sha", { length: 64 }),
27273
+ adapterHash: varchar66("adapter_hash", { length: 64 }),
27274
+ familyManifestHash: varchar66("family_manifest_hash", { length: 64 }),
27275
+ previewOrigin: text91("preview_origin"),
27276
+ nativeViewports: jsonb50("native_viewports").$type(),
27277
+ adapter: jsonb50("adapter").$type(),
27278
+ providerProvenance: jsonb50("provider_provenance").$type(),
27279
+ claimedByApiKeyId: text91("claimed_by_api_key_id"),
27280
+ claimCredentialHash: varchar66("claim_credential_hash", { length: 64 }),
27281
+ claimCredentialExpiresAt: timestamp83("claim_credential_expires_at", { withTimezone: true }),
27282
+ claimCredentialConsumedAt: timestamp83("claim_credential_consumed_at", { withTimezone: true }),
27283
+ completionHash: varchar66("completion_hash", { length: 64 }),
27284
+ evidenceId: text91("evidence_id"),
27285
+ errorCode: text91("error_code"),
27286
+ errorMessage: text91("error_message"),
27287
+ requestedBy: text91("requested_by"),
27288
+ createdAt: timestamp83("created_at", { withTimezone: true }).notNull().defaultNow(),
27289
+ expiresAt: timestamp83("expires_at", { withTimezone: true }).notNull(),
27290
+ claimedAt: timestamp83("claimed_at", { withTimezone: true }),
27291
+ completedAt: timestamp83("completed_at", { withTimezone: true }),
27292
+ failedAt: timestamp83("failed_at", { withTimezone: true }),
27293
+ updatedAt: timestamp83("updated_at", { withTimezone: true }).notNull().defaultNow()
27258
27294
  },
27259
27295
  (table) => [
27260
27296
  foreignKey6({
@@ -27269,35 +27305,35 @@ var componentImplementationRequests = pgTable89(
27269
27305
  }).onDelete("cascade"),
27270
27306
  unique5("component_implementation_requests_scope_unique").on(table.id, table.projectId, table.componentId),
27271
27307
  uniqueIndex38("component_implementation_requests_active_unique").on(table.projectId, table.componentId).where(sql21`${table.status} IN ('pending', 'claimed')`),
27272
- index76("component_implementation_requests_claimable_idx").on(table.projectId, table.status, table.expiresAt, table.createdAt)
27308
+ index77("component_implementation_requests_claimable_idx").on(table.projectId, table.status, table.expiresAt, table.createdAt)
27273
27309
  ]
27274
27310
  );
27275
- var componentImplementationEvidence = pgTable89(
27311
+ var componentImplementationEvidence = pgTable90(
27276
27312
  "component_implementation_evidence",
27277
27313
  {
27278
- id: text90("id").primaryKey(),
27279
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27280
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27281
- componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27282
- candidateId: text90("candidate_id").notNull(),
27283
- familyManifestId: text90("family_manifest_id").notNull(),
27284
- familyManifestHash: varchar65("family_manifest_hash", { length: 64 }).notNull(),
27285
- variantBindingHash: varchar65("variant_binding_hash", { length: 64 }).notNull(),
27286
- variantBinding: jsonb49("variant_binding").$type().notNull(),
27287
- requestId: text90("request_id"),
27288
- schemaHash: varchar65("schema_hash", { length: 64 }).notNull(),
27289
- brandContractHash: varchar65("brand_contract_hash", { length: 64 }).notNull(),
27290
- commitSha: varchar65("commit_sha", { length: 64 }).notNull(),
27291
- adapterHash: varchar65("adapter_hash", { length: 64 }).notNull(),
27292
- previewOrigin: text90("preview_origin").notNull(),
27293
- nativeViewports: jsonb49("native_viewports").$type().notNull(),
27294
- adapter: jsonb49("adapter").$type().notNull(),
27295
- status: varchar65("status", { length: 20 }).$type().notNull(),
27296
- checks: jsonb49("checks").$type().notNull(),
27297
- evidenceDigest: varchar65("evidence_digest", { length: 128 }).notNull(),
27298
- evidenceTupleHash: varchar65("evidence_tuple_hash", { length: 64 }).notNull(),
27299
- createdBy: text90("created_by"),
27300
- createdAt: timestamp82("created_at").notNull().defaultNow()
27314
+ id: text91("id").primaryKey(),
27315
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27316
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27317
+ componentId: text91("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27318
+ candidateId: text91("candidate_id").notNull(),
27319
+ familyManifestId: text91("family_manifest_id").notNull(),
27320
+ familyManifestHash: varchar66("family_manifest_hash", { length: 64 }).notNull(),
27321
+ variantBindingHash: varchar66("variant_binding_hash", { length: 64 }).notNull(),
27322
+ variantBinding: jsonb50("variant_binding").$type().notNull(),
27323
+ requestId: text91("request_id"),
27324
+ schemaHash: varchar66("schema_hash", { length: 64 }).notNull(),
27325
+ brandContractHash: varchar66("brand_contract_hash", { length: 64 }).notNull(),
27326
+ commitSha: varchar66("commit_sha", { length: 64 }).notNull(),
27327
+ adapterHash: varchar66("adapter_hash", { length: 64 }).notNull(),
27328
+ previewOrigin: text91("preview_origin").notNull(),
27329
+ nativeViewports: jsonb50("native_viewports").$type().notNull(),
27330
+ adapter: jsonb50("adapter").$type().notNull(),
27331
+ status: varchar66("status", { length: 20 }).$type().notNull(),
27332
+ checks: jsonb50("checks").$type().notNull(),
27333
+ evidenceDigest: varchar66("evidence_digest", { length: 128 }).notNull(),
27334
+ evidenceTupleHash: varchar66("evidence_tuple_hash", { length: 64 }).notNull(),
27335
+ createdBy: text91("created_by"),
27336
+ createdAt: timestamp83("created_at").notNull().defaultNow()
27301
27337
  },
27302
27338
  (table) => [
27303
27339
  foreignKey6({
@@ -27323,20 +27359,20 @@ var componentImplementationEvidence = pgTable89(
27323
27359
  uniqueIndex38("component_implementation_evidence_digest_unique").on(table.projectId, table.componentId, table.evidenceDigest),
27324
27360
  uniqueIndex38("component_implementation_evidence_request_unique").on(table.requestId).where(sql21`${table.requestId} IS NOT NULL`),
27325
27361
  unique5("component_implementation_evidence_scope_unique").on(table.id, table.projectId, table.componentId),
27326
- index76("component_implementation_evidence_candidate_idx").on(table.candidateId, table.createdAt)
27362
+ index77("component_implementation_evidence_candidate_idx").on(table.candidateId, table.createdAt)
27327
27363
  ]
27328
27364
  );
27329
- var componentImplementationApprovals = pgTable89(
27365
+ var componentImplementationApprovals = pgTable90(
27330
27366
  "component_implementation_approvals",
27331
27367
  {
27332
- id: text90("id").primaryKey(),
27333
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27334
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27335
- componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27336
- candidateId: text90("candidate_id").notNull(),
27337
- evidenceId: text90("evidence_id").notNull(),
27338
- approvedBy: text90("approved_by").notNull(),
27339
- approvedAt: timestamp82("approved_at").notNull().defaultNow()
27368
+ id: text91("id").primaryKey(),
27369
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27370
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27371
+ componentId: text91("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27372
+ candidateId: text91("candidate_id").notNull(),
27373
+ evidenceId: text91("evidence_id").notNull(),
27374
+ approvedBy: text91("approved_by").notNull(),
27375
+ approvedAt: timestamp83("approved_at").notNull().defaultNow()
27340
27376
  },
27341
27377
  (table) => [
27342
27378
  foreignKey6({
@@ -27356,10 +27392,10 @@ var componentImplementationApprovals = pgTable89(
27356
27392
  }).onDelete("cascade"),
27357
27393
  uniqueIndex38("component_implementation_approval_evidence_unique").on(table.evidenceId),
27358
27394
  unique5("component_implementation_approval_scope_unique").on(table.id, table.projectId, table.componentId),
27359
- index76("component_implementation_approvals_component_idx").on(table.projectId, table.componentId)
27395
+ index77("component_implementation_approvals_component_idx").on(table.projectId, table.componentId)
27360
27396
  ]
27361
27397
  );
27362
- var componentImplementationAdapters = pgTable89(
27398
+ var componentImplementationAdapters = pgTable90(
27363
27399
  "component_implementation_adapters",
27364
27400
  {
27365
27401
  // uuid generated BY THE DATABASE, unlike this file's older `text` ids with app-side prefixes.
@@ -27367,15 +27403,15 @@ var componentImplementationAdapters = pgTable89(
27367
27403
  // (project_id, component_id), which is unique — so there is nothing for a readable prefix to
27368
27404
  // help with, and one fewer identifier for a writer to have to mint correctly.
27369
27405
  id: uuid2("id").primaryKey().defaultRandom(),
27370
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27371
- projectId: text90("project_id").notNull(),
27372
- componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27373
- adapter: jsonb49("adapter").$type().notNull(),
27374
- adapterHash: varchar65("adapter_hash", { length: 64 }).notNull(),
27375
- source: varchar65("source", { length: 24 }).$type().notNull(),
27376
- declaredBy: text90("declared_by"),
27377
- declaredAt: timestamp82("declared_at", { withTimezone: true }).notNull().defaultNow(),
27378
- updatedAt: timestamp82("updated_at", { withTimezone: true }).notNull().defaultNow()
27406
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27407
+ projectId: text91("project_id").notNull(),
27408
+ componentId: text91("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27409
+ adapter: jsonb50("adapter").$type().notNull(),
27410
+ adapterHash: varchar66("adapter_hash", { length: 64 }).notNull(),
27411
+ source: varchar66("source", { length: 24 }).$type().notNull(),
27412
+ declaredBy: text91("declared_by"),
27413
+ declaredAt: timestamp83("declared_at", { withTimezone: true }).notNull().defaultNow(),
27414
+ updatedAt: timestamp83("updated_at", { withTimezone: true }).notNull().defaultNow()
27379
27415
  },
27380
27416
  (table) => [
27381
27417
  foreignKey6({
@@ -27384,30 +27420,30 @@ var componentImplementationAdapters = pgTable89(
27384
27420
  name: "component_implementation_adapters_scope_fkey"
27385
27421
  }).onDelete("cascade"),
27386
27422
  unique5("component_implementation_adapters_component_unique").on(table.projectId, table.componentId),
27387
- index76("component_implementation_adapters_project_idx").on(table.projectId, table.componentId)
27423
+ index77("component_implementation_adapters_project_idx").on(table.projectId, table.componentId)
27388
27424
  ]
27389
27425
  );
27390
- var componentImplementationStates = pgTable89(
27426
+ var componentImplementationStates = pgTable90(
27391
27427
  "component_implementation_states",
27392
27428
  {
27393
- id: text90("id").primaryKey(),
27394
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27395
- projectId: text90("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27396
- componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27397
- selectedCandidateId: text90("selected_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
27398
- selectedEvidenceId: text90("selected_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
27399
- selectedApprovalId: text90("selected_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
27400
- publishedCandidateId: text90("published_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
27401
- publishedEvidenceId: text90("published_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
27402
- publishedApprovalId: text90("published_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
27403
- requestId: text90("request_id"),
27404
- requestProvider: varchar65("request_provider", { length: 20 }).$type(),
27405
- requestStatus: varchar65("request_status", { length: 20 }).$type().notNull().default("not-requested"),
27406
- requestErrorCode: text90("request_error_code"),
27407
- requestErrorMessage: text90("request_error_message"),
27408
- requestedBy: text90("requested_by"),
27409
- requestedAt: timestamp82("requested_at"),
27410
- updatedAt: timestamp82("updated_at").notNull().defaultNow()
27429
+ id: text91("id").primaryKey(),
27430
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27431
+ projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27432
+ componentId: text91("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27433
+ selectedCandidateId: text91("selected_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
27434
+ selectedEvidenceId: text91("selected_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
27435
+ selectedApprovalId: text91("selected_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
27436
+ publishedCandidateId: text91("published_candidate_id").references(() => componentImplementationCandidates.id, { onDelete: "set null" }),
27437
+ publishedEvidenceId: text91("published_evidence_id").references(() => componentImplementationEvidence.id, { onDelete: "set null" }),
27438
+ publishedApprovalId: text91("published_approval_id").references(() => componentImplementationApprovals.id, { onDelete: "set null" }),
27439
+ requestId: text91("request_id"),
27440
+ requestProvider: varchar66("request_provider", { length: 20 }).$type(),
27441
+ requestStatus: varchar66("request_status", { length: 20 }).$type().notNull().default("not-requested"),
27442
+ requestErrorCode: text91("request_error_code"),
27443
+ requestErrorMessage: text91("request_error_message"),
27444
+ requestedBy: text91("requested_by"),
27445
+ requestedAt: timestamp83("requested_at"),
27446
+ updatedAt: timestamp83("updated_at").notNull().defaultNow()
27411
27447
  },
27412
27448
  (table) => [
27413
27449
  foreignKey6({
@@ -27416,24 +27452,24 @@ var componentImplementationStates = pgTable89(
27416
27452
  name: "component_implementation_states_project_workspace_fkey"
27417
27453
  }).onDelete("cascade"),
27418
27454
  uniqueIndex38("component_implementation_states_component_unique").on(table.projectId, table.componentId),
27419
- index76("component_implementation_states_workspace_idx").on(table.workspaceId)
27455
+ index77("component_implementation_states_workspace_idx").on(table.workspaceId)
27420
27456
  ]
27421
27457
  );
27422
- var componentPreviewSources = pgTable89(
27458
+ var componentPreviewSources = pgTable90(
27423
27459
  "component_preview_sources",
27424
27460
  {
27425
27461
  id: uuid2("id").primaryKey().defaultRandom(),
27426
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27427
- projectId: text90("project_id").notNull(),
27428
- componentId: text90("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27429
- sourcePath: text90("source_path").notNull(),
27430
- sourceExport: varchar65("source_export", { length: 128 }).notNull().default("default"),
27462
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27463
+ projectId: text91("project_id").notNull(),
27464
+ componentId: text91("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
27465
+ sourcePath: text91("source_path").notNull(),
27466
+ sourceExport: varchar66("source_export", { length: 128 }).notNull().default("default"),
27431
27467
  /** `file`: props are the component's fields. `section`: codemod-extracted, props `{ blockId, bind, overrides, page }` (0321). */
27432
- sourceKind: varchar65("source_kind", { length: 16 }).$type().notNull().default("file"),
27433
- recordedBy: varchar65("recorded_by", { length: 24 }).$type().notNull().default("agent"),
27434
- updatedBy: text90("updated_by"),
27435
- createdAt: timestamp82("created_at", { withTimezone: true }).notNull().defaultNow(),
27436
- updatedAt: timestamp82("updated_at", { withTimezone: true }).notNull().defaultNow()
27468
+ sourceKind: varchar66("source_kind", { length: 16 }).$type().notNull().default("file"),
27469
+ recordedBy: varchar66("recorded_by", { length: 24 }).$type().notNull().default("agent"),
27470
+ updatedBy: text91("updated_by"),
27471
+ createdAt: timestamp83("created_at", { withTimezone: true }).notNull().defaultNow(),
27472
+ updatedAt: timestamp83("updated_at", { withTimezone: true }).notNull().defaultNow()
27437
27473
  },
27438
27474
  (table) => [
27439
27475
  foreignKey6({
@@ -27442,28 +27478,28 @@ var componentPreviewSources = pgTable89(
27442
27478
  name: "component_preview_sources_scope_fkey"
27443
27479
  }).onDelete("cascade"),
27444
27480
  unique5("component_preview_sources_component_unique").on(table.projectId, table.componentId),
27445
- index76("component_preview_sources_project_idx").on(table.projectId)
27481
+ index77("component_preview_sources_project_idx").on(table.projectId)
27446
27482
  ]
27447
27483
  );
27448
- var componentPreviewBundles = pgTable89(
27484
+ var componentPreviewBundles = pgTable90(
27449
27485
  "component_preview_bundles",
27450
27486
  {
27451
27487
  id: uuid2("id").primaryKey().defaultRandom(),
27452
- workspaceId: text90("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27453
- projectId: text90("project_id").notNull(),
27454
- commitSha: varchar65("commit_sha", { length: 64 }).notNull(),
27455
- artifactKey: text90("artifact_key").notNull(),
27456
- checksum: varchar65("checksum", { length: 80 }).notNull(),
27488
+ workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27489
+ projectId: text91("project_id").notNull(),
27490
+ commitSha: varchar66("commit_sha", { length: 64 }).notNull(),
27491
+ artifactKey: text91("artifact_key").notNull(),
27492
+ checksum: varchar66("checksum", { length: 80 }).notNull(),
27457
27493
  sizeBytes: bigint4("size_bytes", { mode: "number" }).notNull(),
27458
- createdAt: timestamp82("created_at", { withTimezone: true }).notNull().defaultNow(),
27494
+ createdAt: timestamp83("created_at", { withTimezone: true }).notNull().defaultNow(),
27459
27495
  /** The preview-runtime version that built this bundle (0330); null from a runner before 0.5.0. */
27460
- runtimeVersion: text90("runtime_version"),
27496
+ runtimeVersion: text91("runtime_version"),
27461
27497
  /** The latest runtime refresh of this commit: rebuilt with a newer runner without re-validating (0330). */
27462
27498
  refreshId: uuid2("refresh_id"),
27463
- refreshStatus: text90("refresh_status"),
27464
- refreshErrorCode: text90("refresh_error_code"),
27465
- refreshErrorMessage: text90("refresh_error_message"),
27466
- refreshDispatchedAt: timestamp82("refresh_dispatched_at", { withTimezone: true })
27499
+ refreshStatus: text91("refresh_status"),
27500
+ refreshErrorCode: text91("refresh_error_code"),
27501
+ refreshErrorMessage: text91("refresh_error_message"),
27502
+ refreshDispatchedAt: timestamp83("refresh_dispatched_at", { withTimezone: true })
27467
27503
  },
27468
27504
  (table) => [
27469
27505
  foreignKey6({
@@ -27472,7 +27508,7 @@ var componentPreviewBundles = pgTable89(
27472
27508
  name: "component_preview_bundles_scope_fkey"
27473
27509
  }).onDelete("cascade"),
27474
27510
  unique5("component_preview_bundles_commit_unique").on(table.projectId, table.commitSha),
27475
- index76("component_preview_bundles_project_idx").on(table.projectId, table.createdAt)
27511
+ index77("component_preview_bundles_project_idx").on(table.projectId, table.createdAt)
27476
27512
  ]
27477
27513
  );
27478
27514
 
@@ -27481,17 +27517,17 @@ import { sql as sql22 } from "drizzle-orm";
27481
27517
  import {
27482
27518
  check as check5,
27483
27519
  foreignKey as foreignKey7,
27484
- index as index77,
27485
- integer as integer44,
27486
- jsonb as jsonb50,
27487
- pgTable as pgTable90,
27488
- primaryKey as primaryKey8,
27489
- text as text91,
27490
- timestamp as timestamp83,
27520
+ index as index78,
27521
+ integer as integer45,
27522
+ jsonb as jsonb51,
27523
+ pgTable as pgTable91,
27524
+ primaryKey as primaryKey9,
27525
+ text as text92,
27526
+ timestamp as timestamp84,
27491
27527
  unique as unique6,
27492
27528
  uniqueIndex as uniqueIndex39,
27493
27529
  uuid as uuid3,
27494
- varchar as varchar66
27530
+ varchar as varchar67
27495
27531
  } from "drizzle-orm/pg-core";
27496
27532
  var ORCHESTRATION_RUN_STATUSES = [
27497
27533
  "open",
@@ -27501,15 +27537,15 @@ var ORCHESTRATION_RUN_STATUSES = [
27501
27537
  "completed",
27502
27538
  "abandoned"
27503
27539
  ];
27504
- var projectOrchestrationStates = pgTable90(
27540
+ var projectOrchestrationStates = pgTable91(
27505
27541
  "project_orchestration_states",
27506
27542
  {
27507
- projectId: text91("project_id").primaryKey().references(() => projects.id, { onDelete: "cascade" }),
27508
- workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27509
- generation: integer44("generation").notNull().default(2),
27510
- enabledBy: text91("enabled_by").notNull(),
27511
- enabledAt: timestamp83("enabled_at", { withTimezone: true }).notNull().defaultNow(),
27512
- updatedAt: timestamp83("updated_at", { withTimezone: true }).notNull().defaultNow()
27543
+ projectId: text92("project_id").primaryKey().references(() => projects.id, { onDelete: "cascade" }),
27544
+ workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27545
+ generation: integer45("generation").notNull().default(2),
27546
+ enabledBy: text92("enabled_by").notNull(),
27547
+ enabledAt: timestamp84("enabled_at", { withTimezone: true }).notNull().defaultNow(),
27548
+ updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
27513
27549
  },
27514
27550
  (table) => [
27515
27551
  foreignKey7({
@@ -27519,31 +27555,31 @@ var projectOrchestrationStates = pgTable90(
27519
27555
  }).onDelete("cascade"),
27520
27556
  unique6("project_orchestration_states_scope_unique").on(table.projectId, table.workspaceId),
27521
27557
  check5("project_orchestration_states_generation_check", sql22`${table.generation} >= 2`),
27522
- index77("project_orchestration_states_workspace_idx").on(table.workspaceId)
27558
+ index78("project_orchestration_states_workspace_idx").on(table.workspaceId)
27523
27559
  ]
27524
27560
  );
27525
- var orchestrationRuns = pgTable90(
27561
+ var orchestrationRuns = pgTable91(
27526
27562
  "orchestration_runs",
27527
27563
  {
27528
27564
  id: uuid3("id").primaryKey().defaultRandom(),
27529
- workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27530
- projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27531
- projectGeneration: integer44("project_generation").notNull(),
27532
- startIdempotencyKey: text91("start_idempotency_key").notNull(),
27533
- targetKind: varchar66("target_kind", { length: 32 }).$type().notNull().default("component-variant"),
27534
- targetId: text91("target_id").notNull().references(() => components.id, { onDelete: "no action" }),
27535
- targetVariantId: text91("target_variant_id"),
27536
- targetMetadata: jsonb50("target_metadata").$type().notNull(),
27537
- status: varchar66("status", { length: 20 }).$type().notNull().default("open"),
27538
- activeStage: varchar66("active_stage", { length: 64 }).notNull().default("awaiting-executor"),
27539
- version: integer44("version").notNull().default(1),
27540
- preferredExecutorId: text91("preferred_executor_id"),
27541
- cancellationRequestedAt: timestamp83("cancellation_requested_at", { withTimezone: true }),
27542
- cancellationRequestedBy: text91("cancellation_requested_by"),
27543
- createdBy: text91("created_by").notNull(),
27544
- policyVersion: varchar66("policy_version", { length: 64 }).notNull().default("orchestration-v2"),
27545
- createdAt: timestamp83("created_at", { withTimezone: true }).notNull().defaultNow(),
27546
- updatedAt: timestamp83("updated_at", { withTimezone: true }).notNull().defaultNow()
27565
+ workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27566
+ projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27567
+ projectGeneration: integer45("project_generation").notNull(),
27568
+ startIdempotencyKey: text92("start_idempotency_key").notNull(),
27569
+ targetKind: varchar67("target_kind", { length: 32 }).$type().notNull().default("component-variant"),
27570
+ targetId: text92("target_id").notNull().references(() => components.id, { onDelete: "no action" }),
27571
+ targetVariantId: text92("target_variant_id"),
27572
+ targetMetadata: jsonb51("target_metadata").$type().notNull(),
27573
+ status: varchar67("status", { length: 20 }).$type().notNull().default("open"),
27574
+ activeStage: varchar67("active_stage", { length: 64 }).notNull().default("awaiting-executor"),
27575
+ version: integer45("version").notNull().default(1),
27576
+ preferredExecutorId: text92("preferred_executor_id"),
27577
+ cancellationRequestedAt: timestamp84("cancellation_requested_at", { withTimezone: true }),
27578
+ cancellationRequestedBy: text92("cancellation_requested_by"),
27579
+ createdBy: text92("created_by").notNull(),
27580
+ policyVersion: varchar67("policy_version", { length: 64 }).notNull().default("orchestration-v2"),
27581
+ createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
27582
+ updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
27547
27583
  },
27548
27584
  (table) => [
27549
27585
  foreignKey7({
@@ -27567,14 +27603,14 @@ var orchestrationRuns = pgTable90(
27567
27603
  table.startIdempotencyKey
27568
27604
  ),
27569
27605
  uniqueIndex39("orchestration_runs_nonterminal_project_unique").on(table.projectId).where(sql22`${table.status} IN ('open', 'paused', 'cancelling')`),
27570
- index77("orchestration_runs_project_target_idx").on(
27606
+ index78("orchestration_runs_project_target_idx").on(
27571
27607
  table.projectId,
27572
27608
  table.targetKind,
27573
27609
  table.targetId,
27574
27610
  table.targetVariantId,
27575
27611
  table.createdAt
27576
27612
  ),
27577
- index77("orchestration_runs_workspace_status_idx").on(
27613
+ index78("orchestration_runs_workspace_status_idx").on(
27578
27614
  table.workspaceId,
27579
27615
  table.status,
27580
27616
  table.updatedAt
@@ -27661,49 +27697,49 @@ var orchestrationRuns = pgTable90(
27661
27697
  check5("orchestration_runs_timestamps_check", sql22`${table.updatedAt} >= ${table.createdAt}`)
27662
27698
  ]
27663
27699
  );
27664
- var orchestrationRunStartKeys = pgTable90(
27700
+ var orchestrationRunStartKeys = pgTable91(
27665
27701
  "orchestration_run_start_keys",
27666
27702
  {
27667
- workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27668
- projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27669
- idempotencyKey: text91("idempotency_key").notNull(),
27703
+ workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27704
+ projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27705
+ idempotencyKey: text92("idempotency_key").notNull(),
27670
27706
  runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
27671
- createdAt: timestamp83("created_at", { withTimezone: true }).notNull().defaultNow()
27707
+ createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow()
27672
27708
  },
27673
27709
  (table) => [
27674
- primaryKey8({ columns: [table.projectId, table.idempotencyKey] }),
27710
+ primaryKey9({ columns: [table.projectId, table.idempotencyKey] }),
27675
27711
  foreignKey7({
27676
27712
  columns: [table.runId, table.workspaceId, table.projectId],
27677
27713
  foreignColumns: [orchestrationRuns.id, orchestrationRuns.workspaceId, orchestrationRuns.projectId],
27678
27714
  name: "orchestration_run_start_keys_run_scope_fkey"
27679
27715
  }).onDelete("cascade"),
27680
- index77("orchestration_run_start_keys_run_created_idx").on(table.runId, table.createdAt),
27716
+ index78("orchestration_run_start_keys_run_created_idx").on(table.runId, table.createdAt),
27681
27717
  check5(
27682
27718
  "orchestration_run_start_keys_idempotency_key_check",
27683
27719
  sql22`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27684
27720
  )
27685
27721
  ]
27686
27722
  );
27687
- var orchestrationRunEvents = pgTable90(
27723
+ var orchestrationRunEvents = pgTable91(
27688
27724
  "orchestration_run_events",
27689
27725
  {
27690
27726
  id: uuid3("id").primaryKey().defaultRandom(),
27691
27727
  runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
27692
- workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27693
- projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27694
- sequence: integer44("sequence").notNull(),
27695
- schemaVersion: integer44("schema_version").notNull().default(1),
27696
- idempotencyKey: text91("idempotency_key").notNull(),
27697
- type: varchar66("type", { length: 100 }).notNull(),
27698
- actorType: varchar66("actor_type", { length: 32 }).notNull(),
27699
- actorId: text91("actor_id").notNull(),
27700
- causationId: text91("causation_id"),
27701
- correlationId: text91("correlation_id"),
27702
- payload: jsonb50("payload").$type().notNull().default({}),
27703
- payloadDigest: varchar66("payload_digest", { length: 71 }).generatedAlwaysAs(
27728
+ workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27729
+ projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27730
+ sequence: integer45("sequence").notNull(),
27731
+ schemaVersion: integer45("schema_version").notNull().default(1),
27732
+ idempotencyKey: text92("idempotency_key").notNull(),
27733
+ type: varchar67("type", { length: 100 }).notNull(),
27734
+ actorType: varchar67("actor_type", { length: 32 }).notNull(),
27735
+ actorId: text92("actor_id").notNull(),
27736
+ causationId: text92("causation_id"),
27737
+ correlationId: text92("correlation_id"),
27738
+ payload: jsonb51("payload").$type().notNull().default({}),
27739
+ payloadDigest: varchar67("payload_digest", { length: 71 }).generatedAlwaysAs(
27704
27740
  sql22`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
27705
27741
  ),
27706
- createdAt: timestamp83("created_at", { withTimezone: true }).notNull().defaultNow()
27742
+ createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow()
27707
27743
  },
27708
27744
  (table) => [
27709
27745
  foreignKey7({
@@ -27713,7 +27749,7 @@ var orchestrationRunEvents = pgTable90(
27713
27749
  }).onDelete("cascade"),
27714
27750
  unique6("orchestration_run_events_sequence_unique").on(table.runId, table.sequence),
27715
27751
  unique6("orchestration_run_events_idempotency_unique").on(table.runId, table.idempotencyKey),
27716
- index77("orchestration_run_events_project_created_idx").on(table.projectId, table.createdAt),
27752
+ index78("orchestration_run_events_project_created_idx").on(table.projectId, table.createdAt),
27717
27753
  check5("orchestration_run_events_sequence_check", sql22`${table.sequence} >= 1`),
27718
27754
  check5("orchestration_run_events_schema_version_check", sql22`${table.schemaVersion} >= 1`),
27719
27755
  check5(
@@ -27729,20 +27765,20 @@ var orchestrationRunEvents = pgTable90(
27729
27765
  )
27730
27766
  ]
27731
27767
  );
27732
- var orchestrationRunCommandResults = pgTable90(
27768
+ var orchestrationRunCommandResults = pgTable91(
27733
27769
  "orchestration_run_command_results",
27734
27770
  {
27735
27771
  commandId: uuid3("command_id").primaryKey(),
27736
- workspaceId: text91("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27737
- projectId: text91("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27772
+ workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27773
+ projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27738
27774
  runId: uuid3("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
27739
- command: varchar66("command", { length: 20 }).$type().notNull(),
27740
- expectedVersion: integer44("expected_version").notNull(),
27741
- resultingVersion: integer44("resulting_version").notNull(),
27742
- actorId: text91("actor_id").notNull(),
27775
+ command: varchar67("command", { length: 20 }).$type().notNull(),
27776
+ expectedVersion: integer45("expected_version").notNull(),
27777
+ resultingVersion: integer45("resulting_version").notNull(),
27778
+ actorId: text92("actor_id").notNull(),
27743
27779
  eventId: uuid3("event_id").notNull().references(() => orchestrationRunEvents.id, { onDelete: "cascade" }),
27744
- resultPayload: jsonb50("result_payload").$type().notNull(),
27745
- createdAt: timestamp83("created_at", { withTimezone: true }).notNull().defaultNow()
27780
+ resultPayload: jsonb51("result_payload").$type().notNull(),
27781
+ createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow()
27746
27782
  },
27747
27783
  (table) => [
27748
27784
  foreignKey7({
@@ -27750,8 +27786,8 @@ var orchestrationRunCommandResults = pgTable90(
27750
27786
  foreignColumns: [orchestrationRuns.id, orchestrationRuns.workspaceId, orchestrationRuns.projectId],
27751
27787
  name: "orchestration_run_command_results_run_scope_fkey"
27752
27788
  }).onDelete("cascade"),
27753
- index77("orchestration_run_command_results_run_created_idx").on(table.runId, table.createdAt),
27754
- index77("orchestration_run_command_results_project_created_idx").on(
27789
+ index78("orchestration_run_command_results_run_created_idx").on(table.runId, table.createdAt),
27790
+ index78("orchestration_run_command_results_project_created_idx").on(
27755
27791
  table.projectId,
27756
27792
  table.createdAt
27757
27793
  ),
@@ -27785,16 +27821,16 @@ import {
27785
27821
  boolean as boolean30,
27786
27822
  check as check6,
27787
27823
  foreignKey as foreignKey8,
27788
- index as index78,
27789
- integer as integer45,
27790
- jsonb as jsonb51,
27791
- pgTable as pgTable91,
27792
- text as text92,
27793
- timestamp as timestamp84,
27824
+ index as index79,
27825
+ integer as integer46,
27826
+ jsonb as jsonb52,
27827
+ pgTable as pgTable92,
27828
+ text as text93,
27829
+ timestamp as timestamp85,
27794
27830
  unique as unique7,
27795
27831
  uniqueIndex as uniqueIndex40,
27796
27832
  uuid as uuid4,
27797
- varchar as varchar67
27833
+ varchar as varchar68
27798
27834
  } from "drizzle-orm/pg-core";
27799
27835
  var EXECUTOR_KINDS = ["dashboard-agent", "native-bridge"];
27800
27836
  var EXECUTOR_INSTALLATION_STATUSES = ["active", "revoked", "incompatible"];
@@ -27835,20 +27871,20 @@ var EXECUTOR_COMMAND_KINDS = [
27835
27871
  "cancel",
27836
27872
  "handoff"
27837
27873
  ];
27838
- var orchestrationExecutorInstallations = pgTable91(
27874
+ var orchestrationExecutorInstallations = pgTable92(
27839
27875
  "orchestration_executor_installations",
27840
27876
  {
27841
27877
  id: uuid4("id").primaryKey().defaultRandom(),
27842
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27843
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27844
- kind: varchar67("kind", { length: 24 }).$type().notNull(),
27845
- grantId: text92("grant_id").references(() => deviceAuthorizations.id, { onDelete: "cascade" }),
27846
- protocolVersion: varchar67("protocol_version", { length: 16 }).notNull(),
27847
- capabilityDigest: text92("capability_digest").notNull(),
27848
- repositoryClaim: jsonb51("repository_claim").$type().notNull().default({}),
27849
- status: varchar67("status", { length: 20 }).$type().notNull().default("active"),
27850
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
27851
- updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
27878
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27879
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27880
+ kind: varchar68("kind", { length: 24 }).$type().notNull(),
27881
+ grantId: text93("grant_id").references(() => deviceAuthorizations.id, { onDelete: "cascade" }),
27882
+ protocolVersion: varchar68("protocol_version", { length: 16 }).notNull(),
27883
+ capabilityDigest: text93("capability_digest").notNull(),
27884
+ repositoryClaim: jsonb52("repository_claim").$type().notNull().default({}),
27885
+ status: varchar68("status", { length: 20 }).$type().notNull().default("active"),
27886
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow(),
27887
+ updatedAt: timestamp85("updated_at", { withTimezone: true }).notNull().defaultNow()
27852
27888
  },
27853
27889
  (table) => [
27854
27890
  foreignKey8({
@@ -27861,7 +27897,7 @@ var orchestrationExecutorInstallations = pgTable91(
27861
27897
  table.workspaceId,
27862
27898
  table.projectId
27863
27899
  ),
27864
- index78("orchestration_executor_installations_project_status_idx").on(
27900
+ index79("orchestration_executor_installations_project_status_idx").on(
27865
27901
  table.projectId,
27866
27902
  table.status
27867
27903
  ),
@@ -27898,24 +27934,24 @@ var orchestrationExecutorInstallations = pgTable91(
27898
27934
  )
27899
27935
  ]
27900
27936
  );
27901
- var orchestrationExecutorSessions = pgTable91(
27937
+ var orchestrationExecutorSessions = pgTable92(
27902
27938
  "orchestration_executor_sessions",
27903
27939
  {
27904
27940
  id: uuid4("id").primaryKey().defaultRandom(),
27905
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27906
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27941
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27942
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27907
27943
  installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
27908
- sessionEpoch: integer45("session_epoch").notNull().default(1),
27909
- credentialAudience: varchar67("credential_audience", { length: 64 }).notNull(),
27910
- state: varchar67("state", { length: 20 }).$type().notNull().default("open"),
27944
+ sessionEpoch: integer46("session_epoch").notNull().default(1),
27945
+ credentialAudience: varchar68("credential_audience", { length: 64 }).notNull(),
27946
+ state: varchar68("state", { length: 20 }).$type().notNull().default("open"),
27911
27947
  clientCursor: bigint5("client_cursor", { mode: "number" }).notNull().default(0),
27912
27948
  serverCursor: bigint5("server_cursor", { mode: "number" }).notNull().default(0),
27913
- connectedAt: timestamp84("connected_at", { withTimezone: true }).notNull().defaultNow(),
27914
- lastHeartbeatAt: timestamp84("last_heartbeat_at", { withTimezone: true }),
27915
- serverReceivedAt: timestamp84("server_received_at", { withTimezone: true }),
27916
- closedAt: timestamp84("closed_at", { withTimezone: true }),
27917
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
27918
- updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
27949
+ connectedAt: timestamp85("connected_at", { withTimezone: true }).notNull().defaultNow(),
27950
+ lastHeartbeatAt: timestamp85("last_heartbeat_at", { withTimezone: true }),
27951
+ serverReceivedAt: timestamp85("server_received_at", { withTimezone: true }),
27952
+ closedAt: timestamp85("closed_at", { withTimezone: true }),
27953
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow(),
27954
+ updatedAt: timestamp85("updated_at", { withTimezone: true }).notNull().defaultNow()
27919
27955
  },
27920
27956
  (table) => [
27921
27957
  foreignKey8({
@@ -27936,11 +27972,11 @@ var orchestrationExecutorSessions = pgTable91(
27936
27972
  table.installationId,
27937
27973
  table.sessionEpoch
27938
27974
  ),
27939
- index78("orchestration_executor_sessions_installation_state_idx").on(
27975
+ index79("orchestration_executor_sessions_installation_state_idx").on(
27940
27976
  table.installationId,
27941
27977
  table.state
27942
27978
  ),
27943
- index78("orchestration_executor_sessions_liveness_idx").on(table.serverReceivedAt).where(sql23`${table.state} = 'open'`),
27979
+ index79("orchestration_executor_sessions_liveness_idx").on(table.serverReceivedAt).where(sql23`${table.state} = 'open'`),
27944
27980
  check6("orchestration_executor_sessions_epoch_check", sql23`${table.sessionEpoch} >= 1`),
27945
27981
  check6(
27946
27982
  "orchestration_executor_sessions_state_check",
@@ -27964,39 +28000,39 @@ var orchestrationExecutorSessions = pgTable91(
27964
28000
  )
27965
28001
  ]
27966
28002
  );
27967
- var orchestrationImplementationAttempts = pgTable91(
28003
+ var orchestrationImplementationAttempts = pgTable92(
27968
28004
  "orchestration_implementation_attempts",
27969
28005
  {
27970
28006
  id: uuid4("id").primaryKey().defaultRandom(),
27971
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
27972
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28007
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28008
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
27973
28009
  runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
27974
28010
  installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
27975
- attemptNumber: integer45("attempt_number").notNull(),
27976
- targetKind: varchar67("target_kind", { length: 32 }).notNull().default("component-variant"),
27977
- targetId: text92("target_id").notNull(),
27978
- targetBindingDigest: text92("target_binding_digest").notNull(),
28011
+ attemptNumber: integer46("attempt_number").notNull(),
28012
+ targetKind: varchar68("target_kind", { length: 32 }).notNull().default("component-variant"),
28013
+ targetId: text93("target_id").notNull(),
28014
+ targetBindingDigest: text93("target_binding_digest").notNull(),
27979
28015
  repositoryId: bigint5("repository_id", { mode: "number" }),
27980
- baseBranch: varchar67("base_branch", { length: 255 }),
27981
- baseSha: varchar67("base_sha", { length: 64 }),
28016
+ baseBranch: varchar68("base_branch", { length: 255 }),
28017
+ baseSha: varchar68("base_sha", { length: 64 }),
27982
28018
  /**
27983
28019
  * The branch this attempt created, recorded BEFORE the first write lands on it. This is the
27984
28020
  * crash-safety line: if the process dies holding a branch, cancellation and reconciliation can
27985
28021
  * still find it. Null until the branch exists. Shape-checked to run branches only (0278).
27986
28022
  */
27987
- createdRef: text92("created_ref"),
27988
- status: varchar67("status", { length: 24 }).$type().notNull().default("preflight"),
28023
+ createdRef: text93("created_ref"),
28024
+ status: varchar68("status", { length: 24 }).$type().notNull().default("preflight"),
27989
28025
  supersededBy: uuid4("superseded_by"),
27990
28026
  /**
27991
28027
  * Withdrawal (0284): the three facts travel together or not at all, enforced by a CHECK. A
27992
28028
  * withdrawn attempt's pull request is kept BY URL, so a reader of the run never has to
27993
28029
  * discover from GitHub that one used to exist here.
27994
28030
  */
27995
- withdrawnAt: timestamp84("withdrawn_at", { withTimezone: true }),
27996
- withdrawnBy: text92("withdrawn_by"),
27997
- withdrawnPullRequestUrl: text92("withdrawn_pull_request_url"),
27998
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
27999
- updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
28031
+ withdrawnAt: timestamp85("withdrawn_at", { withTimezone: true }),
28032
+ withdrawnBy: text93("withdrawn_by"),
28033
+ withdrawnPullRequestUrl: text93("withdrawn_pull_request_url"),
28034
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow(),
28035
+ updatedAt: timestamp85("updated_at", { withTimezone: true }).notNull().defaultNow()
28000
28036
  },
28001
28037
  (table) => [
28002
28038
  foreignKey8({
@@ -28031,7 +28067,7 @@ var orchestrationImplementationAttempts = pgTable91(
28031
28067
  table.runId,
28032
28068
  table.attemptNumber
28033
28069
  ),
28034
- index78("orchestration_implementation_attempts_run_created_idx").on(
28070
+ index79("orchestration_implementation_attempts_run_created_idx").on(
28035
28071
  table.runId,
28036
28072
  table.createdAt
28037
28073
  ),
@@ -28062,135 +28098,135 @@ var orchestrationImplementationAttempts = pgTable91(
28062
28098
  )
28063
28099
  ]
28064
28100
  );
28065
- var orchestrationPlanSnapshots = pgTable91(
28101
+ var orchestrationPlanSnapshots = pgTable92(
28066
28102
  "orchestration_plan_snapshots",
28067
28103
  {
28068
- planDigest: text92("plan_digest").primaryKey(),
28069
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28070
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28071
- baseHeadOid: varchar67("base_head_oid", { length: 64 }).notNull(),
28072
- budget: jsonb51("budget").notNull(),
28073
- files: jsonb51("files").notNull(),
28074
- fileCount: integer45("file_count").notNull(),
28104
+ planDigest: text93("plan_digest").primaryKey(),
28105
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28106
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28107
+ baseHeadOid: varchar68("base_head_oid", { length: 64 }).notNull(),
28108
+ budget: jsonb52("budget").notNull(),
28109
+ files: jsonb52("files").notNull(),
28110
+ fileCount: integer46("file_count").notNull(),
28075
28111
  byteCount: bigint5("byte_count", { mode: "number" }).notNull(),
28076
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow()
28112
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow()
28077
28113
  },
28078
- (table) => [index78("orchestration_plan_snapshots_project_idx").on(table.workspaceId, table.projectId, table.createdAt)]
28114
+ (table) => [index79("orchestration_plan_snapshots_project_idx").on(table.workspaceId, table.projectId, table.createdAt)]
28079
28115
  );
28080
- var orchestrationVisualApprovals = pgTable91(
28116
+ var orchestrationVisualApprovals = pgTable92(
28081
28117
  "orchestration_visual_approvals",
28082
28118
  {
28083
28119
  id: uuid4("id").primaryKey().defaultRandom(),
28084
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28085
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28120
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28121
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28086
28122
  runId: uuid4("run_id").notNull(),
28087
28123
  attemptId: uuid4("attempt_id").notNull(),
28088
- headSha: varchar67("head_sha", { length: 64 }).notNull(),
28124
+ headSha: varchar68("head_sha", { length: 64 }).notNull(),
28089
28125
  evidenceId: uuid4("evidence_id").notNull(),
28090
- authorizedBy: text92("authorized_by").notNull(),
28091
- idempotencyKey: text92("idempotency_key").notNull(),
28092
- expiresAt: timestamp84("expires_at", { withTimezone: true }).notNull(),
28093
- consumedAt: timestamp84("consumed_at", { withTimezone: true }),
28094
- consumedByRef: text92("consumed_by_ref"),
28095
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
28096
- updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
28126
+ authorizedBy: text93("authorized_by").notNull(),
28127
+ idempotencyKey: text93("idempotency_key").notNull(),
28128
+ expiresAt: timestamp85("expires_at", { withTimezone: true }).notNull(),
28129
+ consumedAt: timestamp85("consumed_at", { withTimezone: true }),
28130
+ consumedByRef: text93("consumed_by_ref"),
28131
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow(),
28132
+ updatedAt: timestamp85("updated_at", { withTimezone: true }).notNull().defaultNow()
28097
28133
  }
28098
28134
  );
28099
- var orchestrationMergeAuthorizations = pgTable91(
28135
+ var orchestrationMergeAuthorizations = pgTable92(
28100
28136
  "orchestration_merge_authorizations",
28101
28137
  {
28102
28138
  id: uuid4("id").primaryKey().defaultRandom(),
28103
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28104
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28139
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28140
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28105
28141
  runId: uuid4("run_id").notNull(),
28106
28142
  attemptId: uuid4("attempt_id").notNull(),
28107
- pullRequestNumber: integer45("pull_request_number").notNull(),
28108
- expectedHeadSha: varchar67("expected_head_sha", { length: 64 }).notNull(),
28143
+ pullRequestNumber: integer46("pull_request_number").notNull(),
28144
+ expectedHeadSha: varchar68("expected_head_sha", { length: 64 }).notNull(),
28109
28145
  visualApprovalId: uuid4("visual_approval_id").notNull(),
28110
28146
  /**
28111
28147
  * 0285. A void is a first-class END, not a consumption with a special ref: consumption records
28112
28148
  * what an authorization BOUGHT, and a void bought nothing. A CHECK keeps the three together and
28113
28149
  * forbids a row that is both spent and voided.
28114
28150
  */
28115
- voidedAt: timestamp84("voided_at", { withTimezone: true }),
28116
- voidedBy: text92("voided_by"),
28117
- voidReason: text92("void_reason"),
28118
- authorizedBy: text92("authorized_by").notNull(),
28119
- idempotencyKey: text92("idempotency_key").notNull(),
28120
- expiresAt: timestamp84("expires_at", { withTimezone: true }).notNull(),
28121
- consumedAt: timestamp84("consumed_at", { withTimezone: true }),
28122
- consumedByRef: text92("consumed_by_ref"),
28123
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
28124
- updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
28151
+ voidedAt: timestamp85("voided_at", { withTimezone: true }),
28152
+ voidedBy: text93("voided_by"),
28153
+ voidReason: text93("void_reason"),
28154
+ authorizedBy: text93("authorized_by").notNull(),
28155
+ idempotencyKey: text93("idempotency_key").notNull(),
28156
+ expiresAt: timestamp85("expires_at", { withTimezone: true }).notNull(),
28157
+ consumedAt: timestamp85("consumed_at", { withTimezone: true }),
28158
+ consumedByRef: text93("consumed_by_ref"),
28159
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow(),
28160
+ updatedAt: timestamp85("updated_at", { withTimezone: true }).notNull().defaultNow()
28125
28161
  }
28126
28162
  );
28127
- var orchestrationDeploymentAuthorizations = pgTable91(
28163
+ var orchestrationDeploymentAuthorizations = pgTable92(
28128
28164
  "orchestration_deployment_authorizations",
28129
28165
  {
28130
28166
  id: uuid4("id").primaryKey().defaultRandom(),
28131
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28132
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28167
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28168
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28133
28169
  runId: uuid4("run_id").notNull(),
28134
28170
  attemptId: uuid4("attempt_id").notNull(),
28135
- mergeSha: varchar67("merge_sha", { length: 64 }).notNull(),
28136
- artifactChecksum: varchar67("artifact_checksum", { length: 80 }).notNull(),
28171
+ mergeSha: varchar68("merge_sha", { length: 64 }).notNull(),
28172
+ artifactChecksum: varchar68("artifact_checksum", { length: 80 }).notNull(),
28137
28173
  mergeAuthorizationId: uuid4("merge_authorization_id").notNull(),
28138
- authorizedBy: text92("authorized_by").notNull(),
28139
- idempotencyKey: text92("idempotency_key").notNull(),
28140
- expiresAt: timestamp84("expires_at", { withTimezone: true }).notNull(),
28141
- consumedAt: timestamp84("consumed_at", { withTimezone: true }),
28142
- consumedByRef: text92("consumed_by_ref"),
28143
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
28144
- updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
28174
+ authorizedBy: text93("authorized_by").notNull(),
28175
+ idempotencyKey: text93("idempotency_key").notNull(),
28176
+ expiresAt: timestamp85("expires_at", { withTimezone: true }).notNull(),
28177
+ consumedAt: timestamp85("consumed_at", { withTimezone: true }),
28178
+ consumedByRef: text93("consumed_by_ref"),
28179
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow(),
28180
+ updatedAt: timestamp85("updated_at", { withTimezone: true }).notNull().defaultNow()
28145
28181
  }
28146
28182
  );
28147
- var orchestrationDeploymentRequests = pgTable91(
28183
+ var orchestrationDeploymentRequests = pgTable92(
28148
28184
  "orchestration_deployment_requests",
28149
28185
  {
28150
28186
  id: uuid4("id").primaryKey().defaultRandom(),
28151
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28152
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28187
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28188
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28153
28189
  runId: uuid4("run_id").notNull(),
28154
28190
  attemptId: uuid4("attempt_id").notNull(),
28155
28191
  authorizationId: uuid4("authorization_id").notNull(),
28156
- expectedMergeSha: varchar67("expected_merge_sha", { length: 64 }).notNull(),
28157
- artifactChecksum: varchar67("artifact_checksum", { length: 80 }).notNull(),
28158
- state: varchar67("state", { length: 12 }).$type().notNull().default("live"),
28159
- voidReason: text92("void_reason"),
28160
- releaseId: text92("release_id"),
28161
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
28162
- updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
28192
+ expectedMergeSha: varchar68("expected_merge_sha", { length: 64 }).notNull(),
28193
+ artifactChecksum: varchar68("artifact_checksum", { length: 80 }).notNull(),
28194
+ state: varchar68("state", { length: 12 }).$type().notNull().default("live"),
28195
+ voidReason: text93("void_reason"),
28196
+ releaseId: text93("release_id"),
28197
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow(),
28198
+ updatedAt: timestamp85("updated_at", { withTimezone: true }).notNull().defaultNow()
28163
28199
  }
28164
28200
  );
28165
- var orchestrationExecutionApprovals = pgTable91(
28201
+ var orchestrationExecutionApprovals = pgTable92(
28166
28202
  "orchestration_execution_approvals",
28167
28203
  {
28168
28204
  id: uuid4("id").primaryKey().defaultRandom(),
28169
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28170
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28205
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28206
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28171
28207
  runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
28172
28208
  attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
28173
28209
  installationId: uuid4("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
28174
- idempotencyKey: text92("idempotency_key").notNull(),
28175
- approvedBy: text92("approved_by").notNull(),
28176
- targetKind: varchar67("target_kind", { length: 32 }).notNull().default("component-variant"),
28177
- targetId: text92("target_id").notNull(),
28178
- targetBindingDigest: text92("target_binding_digest").notNull(),
28210
+ idempotencyKey: text93("idempotency_key").notNull(),
28211
+ approvedBy: text93("approved_by").notNull(),
28212
+ targetKind: varchar68("target_kind", { length: 32 }).notNull().default("component-variant"),
28213
+ targetId: text93("target_id").notNull(),
28214
+ targetBindingDigest: text93("target_binding_digest").notNull(),
28179
28215
  repositoryId: bigint5("repository_id", { mode: "number" }),
28180
- baseBranch: varchar67("base_branch", { length: 255 }),
28181
- baseSha: varchar67("base_sha", { length: 64 }),
28216
+ baseBranch: varchar68("base_branch", { length: 255 }),
28217
+ baseSha: varchar68("base_sha", { length: 64 }),
28182
28218
  /** Set when the approval is spent. 0274 grants UPDATE on THESE TWO COLUMNS ONLY, so every
28183
28219
  * other field on a row a human signed stays as unwritable as it was before. */
28184
- consumedAt: timestamp84("consumed_at", { withTimezone: true }),
28220
+ consumedAt: timestamp85("consumed_at", { withTimezone: true }),
28185
28221
  consumedByAttemptId: uuid4("consumed_by_attempt_id"),
28186
- pathPolicy: jsonb51("path_policy").$type().notNull().default({}),
28187
- operationClasses: jsonb51("operation_classes").$type().notNull().default([]),
28188
- mutationBudget: jsonb51("mutation_budget").$type().notNull().default({}),
28189
- planDigest: text92("plan_digest").notNull(),
28190
- capabilityDigest: text92("capability_digest").notNull(),
28191
- validationDigest: text92("validation_digest").notNull(),
28192
- expiresAt: timestamp84("expires_at", { withTimezone: true }).notNull(),
28193
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow()
28222
+ pathPolicy: jsonb52("path_policy").$type().notNull().default({}),
28223
+ operationClasses: jsonb52("operation_classes").$type().notNull().default([]),
28224
+ mutationBudget: jsonb52("mutation_budget").$type().notNull().default({}),
28225
+ planDigest: text93("plan_digest").notNull(),
28226
+ capabilityDigest: text93("capability_digest").notNull(),
28227
+ validationDigest: text93("validation_digest").notNull(),
28228
+ expiresAt: timestamp85("expires_at", { withTimezone: true }).notNull(),
28229
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow()
28194
28230
  },
28195
28231
  (table) => [
28196
28232
  foreignKey8({
@@ -28227,7 +28263,7 @@ var orchestrationExecutionApprovals = pgTable91(
28227
28263
  // One approval per attempt. A running implementation never introduces a second approval; a
28228
28264
  // changed binding requires a NEW attempt, which is what makes the authority auditable.
28229
28265
  unique7("orchestration_execution_approvals_attempt_unique").on(table.attemptId),
28230
- index78("orchestration_execution_approvals_run_created_idx").on(table.runId, table.createdAt),
28266
+ index79("orchestration_execution_approvals_run_created_idx").on(table.runId, table.createdAt),
28231
28267
  check6(
28232
28268
  "orchestration_execution_approvals_idempotency_key_check",
28233
28269
  sql23`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
@@ -28274,23 +28310,23 @@ var orchestrationExecutionApprovals = pgTable91(
28274
28310
  )
28275
28311
  ]
28276
28312
  );
28277
- var orchestrationExecutorLeases = pgTable91(
28313
+ var orchestrationExecutorLeases = pgTable92(
28278
28314
  "orchestration_executor_leases",
28279
28315
  {
28280
28316
  id: uuid4("id").primaryKey().defaultRandom(),
28281
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28282
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28317
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28318
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28283
28319
  runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
28284
28320
  attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
28285
28321
  sessionId: uuid4("session_id").notNull().references(() => orchestrationExecutorSessions.id, { onDelete: "cascade" }),
28286
- leaseEpoch: integer45("lease_epoch").notNull().default(1),
28287
- state: varchar67("state", { length: 20 }).$type().notNull().default("active"),
28288
- heartbeatDeadline: timestamp84("heartbeat_deadline", { withTimezone: true }).notNull(),
28289
- acquiredAt: timestamp84("acquired_at", { withTimezone: true }).notNull().defaultNow(),
28290
- releasedAt: timestamp84("released_at", { withTimezone: true }),
28291
- releaseReason: varchar67("release_reason", { length: 32 }).$type(),
28292
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
28293
- updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
28322
+ leaseEpoch: integer46("lease_epoch").notNull().default(1),
28323
+ state: varchar68("state", { length: 20 }).$type().notNull().default("active"),
28324
+ heartbeatDeadline: timestamp85("heartbeat_deadline", { withTimezone: true }).notNull(),
28325
+ acquiredAt: timestamp85("acquired_at", { withTimezone: true }).notNull().defaultNow(),
28326
+ releasedAt: timestamp85("released_at", { withTimezone: true }),
28327
+ releaseReason: varchar68("release_reason", { length: 32 }).$type(),
28328
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow(),
28329
+ updatedAt: timestamp85("updated_at", { withTimezone: true }).notNull().defaultNow()
28294
28330
  },
28295
28331
  (table) => [
28296
28332
  foreignKey8({
@@ -28328,7 +28364,7 @@ var orchestrationExecutorLeases = pgTable91(
28328
28364
  unique7("orchestration_executor_leases_epoch_unique").on(table.attemptId, table.leaseEpoch),
28329
28365
  // Plan invariant 6, enforced in the database: a run has at most one active executor lease.
28330
28366
  uniqueIndex40("orchestration_executor_leases_one_active_per_run").on(table.runId).where(sql23`${table.state} = 'active'`),
28331
- index78("orchestration_executor_leases_deadline_idx").on(table.heartbeatDeadline).where(sql23`${table.state} = 'active'`),
28367
+ index79("orchestration_executor_leases_deadline_idx").on(table.heartbeatDeadline).where(sql23`${table.state} = 'active'`),
28332
28368
  check6("orchestration_executor_leases_epoch_check", sql23`${table.leaseEpoch} >= 1`),
28333
28369
  check6(
28334
28370
  "orchestration_executor_leases_state_check",
@@ -28348,32 +28384,32 @@ var orchestrationExecutorLeases = pgTable91(
28348
28384
  )
28349
28385
  ]
28350
28386
  );
28351
- var orchestrationExecutorCommands = pgTable91(
28387
+ var orchestrationExecutorCommands = pgTable92(
28352
28388
  "orchestration_executor_commands",
28353
28389
  {
28354
28390
  id: uuid4("id").primaryKey().defaultRandom(),
28355
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28356
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28391
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28392
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28357
28393
  runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
28358
28394
  attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
28359
28395
  leaseId: uuid4("lease_id").references(() => orchestrationExecutorLeases.id, {
28360
28396
  onDelete: "set null"
28361
28397
  }),
28362
- leaseEpoch: integer45("lease_epoch"),
28398
+ leaseEpoch: integer46("lease_epoch"),
28363
28399
  approvalId: uuid4("approval_id").references(() => orchestrationExecutionApprovals.id, {
28364
28400
  onDelete: "set null"
28365
28401
  }),
28366
28402
  sequence: bigint5("sequence", { mode: "number" }).notNull(),
28367
- kind: varchar67("kind", { length: 32 }).$type().notNull(),
28368
- idempotencyKey: text92("idempotency_key").notNull(),
28369
- expectedRunVersion: integer45("expected_run_version").notNull(),
28370
- payload: jsonb51("payload").$type().notNull().default({}),
28371
- payloadDigest: varchar67("payload_digest", { length: 71 }).generatedAlwaysAs(
28403
+ kind: varchar68("kind", { length: 32 }).$type().notNull(),
28404
+ idempotencyKey: text93("idempotency_key").notNull(),
28405
+ expectedRunVersion: integer46("expected_run_version").notNull(),
28406
+ payload: jsonb52("payload").$type().notNull().default({}),
28407
+ payloadDigest: varchar68("payload_digest", { length: 71 }).generatedAlwaysAs(
28372
28408
  sql23`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
28373
28409
  ),
28374
- deliveredAt: timestamp84("delivered_at", { withTimezone: true }),
28375
- acknowledgedAt: timestamp84("acknowledged_at", { withTimezone: true }),
28376
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow()
28410
+ deliveredAt: timestamp85("delivered_at", { withTimezone: true }),
28411
+ acknowledgedAt: timestamp85("acknowledged_at", { withTimezone: true }),
28412
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow()
28377
28413
  },
28378
28414
  (table) => [
28379
28415
  foreignKey8({
@@ -28399,9 +28435,9 @@ var orchestrationExecutorCommands = pgTable91(
28399
28435
  table.runId,
28400
28436
  table.idempotencyKey
28401
28437
  ),
28402
- index78("orchestration_executor_commands_run_sequence_idx").on(table.runId, table.sequence),
28438
+ index79("orchestration_executor_commands_run_sequence_idx").on(table.runId, table.sequence),
28403
28439
  // The long-poll cursor read: unacknowledged commands for a run, in order.
28404
- index78("orchestration_executor_commands_pending_idx").on(table.runId, table.sequence).where(sql23`${table.acknowledgedAt} IS NULL`),
28440
+ index79("orchestration_executor_commands_pending_idx").on(table.runId, table.sequence).where(sql23`${table.acknowledgedAt} IS NULL`),
28405
28441
  check6("orchestration_executor_commands_sequence_check", sql23`${table.sequence} >= 1`),
28406
28442
  check6(
28407
28443
  "orchestration_executor_commands_kind_check",
@@ -28431,25 +28467,25 @@ var orchestrationExecutorCommands = pgTable91(
28431
28467
  ]
28432
28468
  );
28433
28469
  var PATCH_OPERATIONS = ["create", "update", "delete"];
28434
- var orchestrationPatchManifests = pgTable91(
28470
+ var orchestrationPatchManifests = pgTable92(
28435
28471
  "orchestration_patch_manifests",
28436
28472
  {
28437
28473
  id: uuid4("id").primaryKey().defaultRandom(),
28438
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28439
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28474
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28475
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28440
28476
  runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
28441
28477
  attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
28442
28478
  approvalId: uuid4("approval_id").references(() => orchestrationExecutionApprovals.id, {
28443
28479
  onDelete: "set null"
28444
28480
  }),
28445
- sequence: integer45("sequence").notNull(),
28446
- path: text92("path").notNull(),
28447
- operation: varchar67("operation", { length: 16 }).$type().notNull(),
28448
- fileMode: varchar67("file_mode", { length: 6 }).notNull().default("100644"),
28449
- expectedBefore: varchar67("expected_before", { length: 64 }),
28450
- resultingBlobSha: varchar67("resulting_blob_sha", { length: 64 }),
28481
+ sequence: integer46("sequence").notNull(),
28482
+ path: text93("path").notNull(),
28483
+ operation: varchar68("operation", { length: 16 }).$type().notNull(),
28484
+ fileMode: varchar68("file_mode", { length: 6 }).notNull().default("100644"),
28485
+ expectedBefore: varchar68("expected_before", { length: 64 }),
28486
+ resultingBlobSha: varchar68("resulting_blob_sha", { length: 64 }),
28451
28487
  byteCount: bigint5("byte_count", { mode: "number" }).notNull().default(0),
28452
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow()
28488
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow()
28453
28489
  },
28454
28490
  (table) => [
28455
28491
  foreignKey8({
@@ -28472,7 +28508,7 @@ var orchestrationPatchManifests = pgTable91(
28472
28508
  }).onDelete("cascade"),
28473
28509
  unique7("orchestration_patch_manifests_sequence_unique").on(table.attemptId, table.sequence),
28474
28510
  unique7("orchestration_patch_manifests_path_unique").on(table.attemptId, table.path),
28475
- index78("orchestration_patch_manifests_attempt_sequence_idx").on(table.attemptId, table.sequence),
28511
+ index79("orchestration_patch_manifests_attempt_sequence_idx").on(table.attemptId, table.sequence),
28476
28512
  check6("orchestration_patch_manifests_sequence_check", sql23`${table.sequence} >= 1`),
28477
28513
  check6(
28478
28514
  "orchestration_patch_manifests_operation_check",
@@ -28498,30 +28534,30 @@ var orchestrationPatchManifests = pgTable91(
28498
28534
  check6("orchestration_patch_manifests_byte_count_check", sql23`${table.byteCount} >= 0`)
28499
28535
  ]
28500
28536
  );
28501
- var orchestrationPullRequestReceipts = pgTable91(
28537
+ var orchestrationPullRequestReceipts = pgTable92(
28502
28538
  "orchestration_pull_request_receipts",
28503
28539
  {
28504
28540
  id: uuid4("id").primaryKey().defaultRandom(),
28505
- workspaceId: text92("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28506
- projectId: text92("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28541
+ workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28542
+ projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28507
28543
  runId: uuid4("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
28508
28544
  attemptId: uuid4("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
28509
28545
  repositoryId: bigint5("repository_id", { mode: "number" }).notNull(),
28510
28546
  installationId: bigint5("installation_id", { mode: "number" }),
28511
28547
  pullRequestId: bigint5("pull_request_id", { mode: "number" }).notNull(),
28512
- pullRequestNumber: integer45("pull_request_number").notNull(),
28513
- pullRequestUrl: text92("pull_request_url").notNull(),
28514
- baseRef: varchar67("base_ref", { length: 255 }).notNull(),
28515
- baseSha: varchar67("base_sha", { length: 64 }).notNull(),
28516
- headRef: varchar67("head_ref", { length: 255 }).notNull(),
28517
- headSha: varchar67("head_sha", { length: 64 }).notNull(),
28548
+ pullRequestNumber: integer46("pull_request_number").notNull(),
28549
+ pullRequestUrl: text93("pull_request_url").notNull(),
28550
+ baseRef: varchar68("base_ref", { length: 255 }).notNull(),
28551
+ baseSha: varchar68("base_sha", { length: 64 }).notNull(),
28552
+ headRef: varchar68("head_ref", { length: 255 }).notNull(),
28553
+ headSha: varchar68("head_sha", { length: 64 }).notNull(),
28518
28554
  /** True when BetterCMS created and owns the head branch. A head we do not own is observable
28519
28555
  * but never advanceable by the adapter. */
28520
28556
  branchOwned: boolean30("branch_owned").notNull().default(true),
28521
- generation: integer45("generation").notNull().default(1),
28557
+ generation: integer46("generation").notNull().default(1),
28522
28558
  isDraft: boolean30("is_draft").notNull().default(true),
28523
- createdAt: timestamp84("created_at", { withTimezone: true }).notNull().defaultNow(),
28524
- updatedAt: timestamp84("updated_at", { withTimezone: true }).notNull().defaultNow()
28559
+ createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow(),
28560
+ updatedAt: timestamp85("updated_at", { withTimezone: true }).notNull().defaultNow()
28525
28561
  },
28526
28562
  (table) => [
28527
28563
  foreignKey8({
@@ -28546,11 +28582,11 @@ var orchestrationPullRequestReceipts = pgTable91(
28546
28582
  table.attemptId,
28547
28583
  table.generation
28548
28584
  ),
28549
- index78("orchestration_pull_request_receipts_attempt_generation_idx").on(
28585
+ index79("orchestration_pull_request_receipts_attempt_generation_idx").on(
28550
28586
  table.attemptId,
28551
28587
  table.generation
28552
28588
  ),
28553
- index78("orchestration_pull_request_receipts_head_idx").on(table.repositoryId, table.headSha),
28589
+ index79("orchestration_pull_request_receipts_head_idx").on(table.repositoryId, table.headSha),
28554
28590
  check6("orchestration_pull_request_receipts_generation_check", sql23`${table.generation} >= 1`),
28555
28591
  check6("orchestration_pull_request_receipts_number_check", sql23`${table.pullRequestNumber} >= 1`),
28556
28592
  check6(
@@ -28579,24 +28615,24 @@ var orchestrationPullRequestReceipts = pgTable91(
28579
28615
 
28580
28616
  // src/schema/conversion_proposals.ts
28581
28617
  import { sql as sql24 } from "drizzle-orm";
28582
- import { check as check7, foreignKey as foreignKey9, index as index79, integer as integer46, jsonb as jsonb52, pgTable as pgTable92, text as text93, timestamp as timestamp85, unique as unique8, uuid as uuid5, varchar as varchar68 } from "drizzle-orm/pg-core";
28618
+ import { check as check7, foreignKey as foreignKey9, index as index80, integer as integer47, jsonb as jsonb53, pgTable as pgTable93, text as text94, timestamp as timestamp86, unique as unique8, uuid as uuid5, varchar as varchar69 } from "drizzle-orm/pg-core";
28583
28619
  var CONVERSION_PROPOSAL_STATUSES = ["draft", "approved", "superseded"];
28584
- var conversionProposals = pgTable92(
28620
+ var conversionProposals = pgTable93(
28585
28621
  "conversion_proposals",
28586
28622
  {
28587
28623
  id: uuid5("id").primaryKey().defaultRandom(),
28588
- workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28589
- projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28624
+ workspaceId: text94("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28625
+ projectId: text94("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28590
28626
  /** The plan snapshot holding the proposed file contents. */
28591
- planDigest: text93("plan_digest").notNull().references(() => orchestrationPlanSnapshots.planDigest),
28627
+ planDigest: text94("plan_digest").notNull().references(() => orchestrationPlanSnapshots.planDigest),
28592
28628
  /** sha256 of the canonical brief — what the CMS held when this was proposed. */
28593
- briefDigest: text93("brief_digest").notNull(),
28594
- baseHeadOid: varchar68("base_head_oid", { length: 64 }).notNull(),
28595
- baseBranch: text93("base_branch").notNull(),
28629
+ briefDigest: text94("brief_digest").notNull(),
28630
+ baseHeadOid: varchar69("base_head_oid", { length: 64 }).notNull(),
28631
+ baseBranch: text94("base_branch").notNull(),
28596
28632
  /** Brief paths whose `original` was not found in any source file. */
28597
- unlocated: jsonb52("unlocated").notNull().default(sql24`'[]'::jsonb`),
28633
+ unlocated: jsonb53("unlocated").notNull().default(sql24`'[]'::jsonb`),
28598
28634
  /** Files that matched a brief original but fell outside the acquisition caps. */
28599
- omittedByCap: jsonb52("omitted_by_cap").notNull().default(sql24`'[]'::jsonb`),
28635
+ omittedByCap: jsonb53("omitted_by_cap").notNull().default(sql24`'[]'::jsonb`),
28600
28636
  /**
28601
28637
  * The codemod's receipt (migration 0296) — every path it bound, and every one it could not.
28602
28638
  *
@@ -28604,25 +28640,25 @@ var conversionProposals = pgTable92(
28604
28640
  * pending list for those, which is exactly the silent "nothing left to do" this lane refuses.
28605
28641
  * Informative: `proposeConversion` re-derives every claim it acts on from the proposed files.
28606
28642
  */
28607
- receipt: jsonb52("receipt"),
28608
- status: text93("status").notNull().default("draft"),
28609
- version: integer46("version").notNull().default(1),
28610
- idempotencyKey: text93("idempotency_key").notNull(),
28643
+ receipt: jsonb53("receipt"),
28644
+ status: text94("status").notNull().default("draft"),
28645
+ version: integer47("version").notNull().default(1),
28646
+ idempotencyKey: text94("idempotency_key").notNull(),
28611
28647
  /**
28612
28648
  * The key of the transition that put this row in its CURRENT terminal state — the approve, or
28613
28649
  * the manual supersede. Separate from `idempotencyKey`, which belongs to the create: a client
28614
28650
  * retrying one act must never be answered with the result of another.
28615
28651
  */
28616
- transitionIdempotencyKey: text93("transition_idempotency_key"),
28617
- createdBy: text93("created_by").notNull(),
28618
- createdAt: timestamp85("created_at", { withTimezone: true }).notNull().defaultNow(),
28619
- approvedBy: text93("approved_by"),
28620
- approvedAt: timestamp85("approved_at", { withTimezone: true }),
28621
- supersededAt: timestamp85("superseded_at", { withTimezone: true }),
28622
- supersededReason: text93("superseded_reason")
28652
+ transitionIdempotencyKey: text94("transition_idempotency_key"),
28653
+ createdBy: text94("created_by").notNull(),
28654
+ createdAt: timestamp86("created_at", { withTimezone: true }).notNull().defaultNow(),
28655
+ approvedBy: text94("approved_by"),
28656
+ approvedAt: timestamp86("approved_at", { withTimezone: true }),
28657
+ supersededAt: timestamp86("superseded_at", { withTimezone: true }),
28658
+ supersededReason: text94("superseded_reason")
28623
28659
  },
28624
28660
  (table) => [
28625
- index79("conversion_proposals_project_idx").on(table.workspaceId, table.projectId, table.createdAt),
28661
+ index80("conversion_proposals_project_idx").on(table.workspaceId, table.projectId, table.createdAt),
28626
28662
  unique8("conversion_proposals_idempotency_unique").on(table.projectId, table.idempotencyKey),
28627
28663
  foreignKey9({
28628
28664
  columns: [table.projectId, table.workspaceId],
@@ -28640,28 +28676,28 @@ var conversionProposals = pgTable92(
28640
28676
 
28641
28677
  // src/schema/conversion_briefs_issued.ts
28642
28678
  import { sql as sql25 } from "drizzle-orm";
28643
- import { check as check8, foreignKey as foreignKey10, index as index80, jsonb as jsonb53, pgTable as pgTable93, text as text94, timestamp as timestamp86, unique as unique9, uuid as uuid6 } from "drizzle-orm/pg-core";
28644
- var conversionBriefsIssued = pgTable93(
28679
+ import { check as check8, foreignKey as foreignKey10, index as index81, jsonb as jsonb54, pgTable as pgTable94, text as text95, timestamp as timestamp87, unique as unique9, uuid as uuid6 } from "drizzle-orm/pg-core";
28680
+ var conversionBriefsIssued = pgTable94(
28645
28681
  "conversion_briefs_issued",
28646
28682
  {
28647
28683
  id: uuid6("id").primaryKey().defaultRandom(),
28648
- workspaceId: text94("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28649
- projectId: text94("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28684
+ workspaceId: text95("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28685
+ projectId: text95("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28650
28686
  /** sha256 of the canonical brief — `briefDigest`, computed identically by the codemod. */
28651
- briefDigest: text94("brief_digest").notNull(),
28687
+ briefDigest: text95("brief_digest").notNull(),
28652
28688
  /** `[{ route, scope, path, kind, locator? }]` — every bindable path the brief listed. */
28653
- paths: jsonb53("paths").notNull().default(sql25`'[]'::jsonb`),
28689
+ paths: jsonb54("paths").notNull().default(sql25`'[]'::jsonb`),
28654
28690
  /**
28655
28691
  * The codemod's account of the run against THIS digest (`submit_conversion_receipt`): which
28656
28692
  * paths it rewrote, which it could not, and why. Null until one is submitted — a hand
28657
28693
  * conversion never submits one and still counts toward coverage.
28658
28694
  */
28659
- receipt: jsonb53("receipt"),
28695
+ receipt: jsonb54("receipt"),
28660
28696
  /** The LAST time this pin was issued. What a retention sweep keys on. */
28661
- issuedAt: timestamp86("issued_at", { withTimezone: true }).notNull().defaultNow()
28697
+ issuedAt: timestamp87("issued_at", { withTimezone: true }).notNull().defaultNow()
28662
28698
  },
28663
28699
  (table) => [
28664
- index80("conversion_briefs_issued_project_issued_idx").on(table.projectId, table.issuedAt),
28700
+ index81("conversion_briefs_issued_project_issued_idx").on(table.projectId, table.issuedAt),
28665
28701
  unique9("conversion_briefs_issued_digest_unique").on(table.projectId, table.briefDigest),
28666
28702
  foreignKey10({
28667
28703
  columns: [table.projectId, table.workspaceId],
@@ -28673,25 +28709,64 @@ var conversionBriefsIssued = pgTable93(
28673
28709
  ]
28674
28710
  );
28675
28711
 
28676
- // src/schema/orchestration_validation.ts
28712
+ // src/schema/binding_decisions.ts
28677
28713
  import { sql as sql26 } from "drizzle-orm";
28678
- import {
28679
- bigint as bigint6,
28680
- check as check9,
28681
- foreignKey as foreignKey11,
28682
- index as index81,
28683
- integer as integer47,
28684
- jsonb as jsonb54,
28685
- pgTable as pgTable94,
28686
- text as text95,
28687
- timestamp as timestamp87,
28688
- unique as unique10,
28689
- uniqueIndex as uniqueIndex41,
28690
- uuid as uuid7,
28691
- varchar as varchar69
28692
- } from "drizzle-orm/pg-core";
28693
- var VALIDATION_ENVELOPE_STATUSES = [
28694
- "queued",
28714
+ import { index as index82, jsonb as jsonb55, pgTable as pgTable95, smallint as smallint2, text as text96, timestamp as timestamp88, uniqueIndex as uniqueIndex41, uuid as uuid7 } from "drizzle-orm/pg-core";
28715
+ var BINDING_DECISION_OPS = ["bind", "code", "reject"];
28716
+ var BINDING_DECISION_STATES = ["stored", "materialized", "proven", "live", "lost"];
28717
+ var bindingDecisions = pgTable95(
28718
+ "binding_decisions",
28719
+ {
28720
+ id: uuid7("id").primaryKey().defaultRandom(),
28721
+ workspaceId: text96("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28722
+ projectId: text96("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28723
+ /** `current` | `staging` (CHECK in the migration): the slot the decision's release lands in. */
28724
+ slot: text96("slot").notNull(),
28725
+ target: text96("target").notNull(),
28726
+ /** `bind` | `code` | `reject` | `rule` (CHECK; `rule` since 0467, archive sites). An `accept` is stored as the op it expands to. */
28727
+ op: text96("op").notNull(),
28728
+ payload: jsonb55("payload").$type().notNull().default(sql26`'{}'::jsonb`),
28729
+ /** `person` | `ai` (CHECK), from the request's write origin only. */
28730
+ byKind: text96("by_kind").notNull(),
28731
+ by: text96("by"),
28732
+ /** `stored` | `materialized` | `proven` | `live` | `lost` (CHECK). */
28733
+ state: text96("state").notNull().default("stored"),
28734
+ /** The `force` reason an AI gave over a person's decision. */
28735
+ reason: text96("reason"),
28736
+ receiptsSeen: smallint2("receipts_seen").notNull().default(0),
28737
+ materializedSha: text96("materialized_sha"),
28738
+ provenSha: text96("proven_sha"),
28739
+ /** Non-null: no longer live (replaced, overridden or cleared), kept as the record. */
28740
+ supersededReason: text96("superseded_reason"),
28741
+ createdAt: timestamp88("created_at").notNull().defaultNow(),
28742
+ updatedAt: timestamp88("updated_at").notNull().defaultNow()
28743
+ },
28744
+ (t) => [
28745
+ uniqueIndex41("binding_decisions_target_op_unique").on(t.projectId, t.slot, t.target, t.op),
28746
+ uniqueIndex41("binding_decisions_live_target_unique").on(t.projectId, t.slot, t.target).where(sql26`superseded_reason IS NULL`),
28747
+ index82("binding_decisions_project_slot_state_idx").on(t.projectId, t.slot, t.state)
28748
+ ]
28749
+ );
28750
+
28751
+ // src/schema/orchestration_validation.ts
28752
+ import { sql as sql27 } from "drizzle-orm";
28753
+ import {
28754
+ bigint as bigint6,
28755
+ check as check9,
28756
+ foreignKey as foreignKey11,
28757
+ index as index83,
28758
+ integer as integer48,
28759
+ jsonb as jsonb56,
28760
+ pgTable as pgTable96,
28761
+ text as text97,
28762
+ timestamp as timestamp89,
28763
+ unique as unique10,
28764
+ uniqueIndex as uniqueIndex42,
28765
+ uuid as uuid8,
28766
+ varchar as varchar70
28767
+ } from "drizzle-orm/pg-core";
28768
+ var VALIDATION_ENVELOPE_STATUSES = [
28769
+ "queued",
28695
28770
  "dispatched",
28696
28771
  "action_required",
28697
28772
  "passed",
@@ -28701,51 +28776,51 @@ var VALIDATION_ENVELOPE_STATUSES = [
28701
28776
  "cancelled"
28702
28777
  ];
28703
28778
  var VALIDATION_LIVE_STATUSES = ["queued", "dispatched", "action_required"];
28704
- var orchestrationValidationEnvelopes = pgTable94(
28779
+ var orchestrationValidationEnvelopes = pgTable96(
28705
28780
  "orchestration_validation_envelopes",
28706
28781
  {
28707
- id: uuid7("id").primaryKey().defaultRandom(),
28708
- workspaceId: text95("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28709
- projectId: text95("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28710
- runId: uuid7("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
28711
- attemptId: uuid7("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
28782
+ id: uuid8("id").primaryKey().defaultRandom(),
28783
+ workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28784
+ projectId: text97("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28785
+ runId: uuid8("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
28786
+ attemptId: uuid8("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
28712
28787
  /** Null until a receipt writer exists (Phase 6). The head below is pinned regardless. */
28713
- receiptId: uuid7("receipt_id").references(() => orchestrationPullRequestReceipts.id, {
28788
+ receiptId: uuid8("receipt_id").references(() => orchestrationPullRequestReceipts.id, {
28714
28789
  onDelete: "set null"
28715
28790
  }),
28716
- receiptGeneration: integer47("receipt_generation").notNull().default(1),
28791
+ receiptGeneration: integer48("receipt_generation").notNull().default(1),
28717
28792
  // The pinned tuple. Every field here is compared against returned evidence, and each mismatch
28718
28793
  // has its own error code — "wrong repository" and "wrong head" are different recoveries.
28719
28794
  repositoryId: bigint6("repository_id", { mode: "number" }).notNull(),
28720
28795
  pullRequestId: bigint6("pull_request_id", { mode: "number" }).notNull(),
28721
- pullRequestNumber: integer47("pull_request_number").notNull(),
28796
+ pullRequestNumber: integer48("pull_request_number").notNull(),
28722
28797
  /** The exact commit this validation is about. A validation proves nothing about any other. */
28723
- headSha: varchar69("head_sha", { length: 64 }).notNull(),
28724
- baseSha: varchar69("base_sha", { length: 64 }).notNull(),
28725
- bindingDigest: varchar69("binding_digest", { length: 71 }).notNull(),
28726
- schemaHash: varchar69("schema_hash", { length: 64 }).notNull(),
28727
- brandContractHash: varchar69("brand_contract_hash", { length: 64 }).notNull(),
28728
- baselineDigest: varchar69("baseline_digest", { length: 71 }).notNull(),
28729
- toolchainHash: varchar69("toolchain_hash", { length: 64 }).notNull(),
28730
- validatorVersion: text95("validator_version").notNull(),
28731
- workflowSha256: varchar69("workflow_sha256", { length: 64 }).notNull(),
28798
+ headSha: varchar70("head_sha", { length: 64 }).notNull(),
28799
+ baseSha: varchar70("base_sha", { length: 64 }).notNull(),
28800
+ bindingDigest: varchar70("binding_digest", { length: 71 }).notNull(),
28801
+ schemaHash: varchar70("schema_hash", { length: 64 }).notNull(),
28802
+ brandContractHash: varchar70("brand_contract_hash", { length: 64 }).notNull(),
28803
+ baselineDigest: varchar70("baseline_digest", { length: 71 }).notNull(),
28804
+ toolchainHash: varchar70("toolchain_hash", { length: 64 }).notNull(),
28805
+ validatorVersion: text97("validator_version").notNull(),
28806
+ workflowSha256: varchar70("workflow_sha256", { length: 64 }).notNull(),
28732
28807
  /** Digest only. The single-use credential itself is handed to the validator and never stored. */
28733
- nonceHash: varchar69("nonce_hash", { length: 64 }).notNull(),
28734
- nonceExpiresAt: timestamp87("nonce_expires_at", { withTimezone: true }).notNull(),
28735
- nonceConsumedAt: timestamp87("nonce_consumed_at", { withTimezone: true }),
28736
- status: varchar69("status", { length: 20 }).notNull().default("queued"),
28737
- errorCode: text95("error_code"),
28738
- errorMessage: text95("error_message"),
28808
+ nonceHash: varchar70("nonce_hash", { length: 64 }).notNull(),
28809
+ nonceExpiresAt: timestamp89("nonce_expires_at", { withTimezone: true }).notNull(),
28810
+ nonceConsumedAt: timestamp89("nonce_consumed_at", { withTimezone: true }),
28811
+ status: varchar70("status", { length: 20 }).notNull().default("queued"),
28812
+ errorCode: text97("error_code"),
28813
+ errorMessage: text97("error_message"),
28739
28814
  /** Composite-FK'd to (evidence.id, evidence.envelope_id) in 0273, so an envelope cannot be
28740
28815
  * marked passed while pointing at a DIFFERENT envelope's evidence. */
28741
- evidenceId: uuid7("evidence_id"),
28816
+ evidenceId: uuid8("evidence_id"),
28742
28817
  /** Written on pass, read by nothing. The unlock that consumes it is a later phase. */
28743
- attestationDigest: varchar69("attestation_digest", { length: 71 }),
28744
- dispatchedAt: timestamp87("dispatched_at", { withTimezone: true }),
28818
+ attestationDigest: varchar70("attestation_digest", { length: 71 }),
28819
+ dispatchedAt: timestamp89("dispatched_at", { withTimezone: true }),
28745
28820
  /** A retry is a NEW row with a NEW nonce, linked back — never a status reset on this one. */
28746
- retryOf: uuid7("retry_of"),
28747
- createdAt: timestamp87("created_at", { withTimezone: true }).notNull().defaultNow(),
28748
- updatedAt: timestamp87("updated_at", { withTimezone: true }).notNull().defaultNow()
28821
+ retryOf: uuid8("retry_of"),
28822
+ createdAt: timestamp89("created_at", { withTimezone: true }).notNull().defaultNow(),
28823
+ updatedAt: timestamp89("updated_at", { withTimezone: true }).notNull().defaultNow()
28749
28824
  },
28750
28825
  (table) => [
28751
28826
  unique10("orchestration_validation_envelopes_scope_unique").on(
@@ -28769,15 +28844,15 @@ var orchestrationValidationEnvelopes = pgTable94(
28769
28844
  }).onDelete("set null"),
28770
28845
  // One live envelope per (attempt, head): two validators can never both be authoritative for
28771
28846
  // the same commit. The index arbitrates, so no read-then-write can lose the race.
28772
- uniqueIndex41("orchestration_validation_envelopes_one_live_per_head").on(table.attemptId, table.headSha).where(sql26`status IN ('queued', 'dispatched', 'action_required')`),
28773
- index81("orchestration_validation_envelopes_attempt_idx").on(
28847
+ uniqueIndex42("orchestration_validation_envelopes_one_live_per_head").on(table.attemptId, table.headSha).where(sql27`status IN ('queued', 'dispatched', 'action_required')`),
28848
+ index83("orchestration_validation_envelopes_attempt_idx").on(
28774
28849
  table.attemptId,
28775
28850
  table.createdAt.desc()
28776
28851
  ),
28777
- index81("orchestration_validation_envelopes_sweep_idx").on(table.status, table.nonceExpiresAt).where(sql26`status IN ('queued', 'dispatched')`),
28852
+ index83("orchestration_validation_envelopes_sweep_idx").on(table.status, table.nonceExpiresAt).where(sql27`status IN ('queued', 'dispatched')`),
28778
28853
  check9(
28779
28854
  "orchestration_validation_envelopes_status_check",
28780
- sql26`${table.status} IN ('queued', 'dispatched', 'action_required', 'passed', 'failed', 'superseded', 'timed_out', 'cancelled')`
28855
+ sql27`${table.status} IN ('queued', 'dispatched', 'action_required', 'passed', 'failed', 'superseded', 'timed_out', 'cancelled')`
28781
28856
  ),
28782
28857
  // Passing is not assignable. It requires evidence that was ingested, an attestation that was
28783
28858
  // written, and a nonce that was consumed — so executor success alone cannot spell it.
@@ -28786,32 +28861,32 @@ var orchestrationValidationEnvelopes = pgTable94(
28786
28861
  // evidence, which is exactly what an honest failing result is.
28787
28862
  check9(
28788
28863
  "orchestration_validation_envelopes_passed_requires_evidence",
28789
- sql26`${table.status} <> 'passed' OR (${table.evidenceId} IS NOT NULL AND ${table.attestationDigest} IS NOT NULL AND ${table.nonceConsumedAt} IS NOT NULL)`
28864
+ sql27`${table.status} <> 'passed' OR (${table.evidenceId} IS NOT NULL AND ${table.attestationDigest} IS NOT NULL AND ${table.nonceConsumedAt} IS NOT NULL)`
28790
28865
  )
28791
28866
  ]
28792
28867
  );
28793
- var orchestrationValidationEvidence = pgTable94(
28868
+ var orchestrationValidationEvidence = pgTable96(
28794
28869
  "orchestration_validation_evidence",
28795
28870
  {
28796
- id: uuid7("id").primaryKey().defaultRandom(),
28797
- workspaceId: text95("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28798
- projectId: text95("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28799
- runId: uuid7("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
28800
- attemptId: uuid7("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
28801
- envelopeId: uuid7("envelope_id").notNull().references(() => orchestrationValidationEnvelopes.id, { onDelete: "cascade" }),
28802
- headSha: varchar69("head_sha", { length: 64 }).notNull(),
28803
- evidenceDigest: varchar69("evidence_digest", { length: 71 }).notNull(),
28804
- artifactDigest: varchar69("artifact_digest", { length: 71 }).notNull(),
28805
- validatorVersion: text95("validator_version").notNull(),
28871
+ id: uuid8("id").primaryKey().defaultRandom(),
28872
+ workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28873
+ projectId: text97("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28874
+ runId: uuid8("run_id").notNull().references(() => orchestrationRuns.id, { onDelete: "cascade" }),
28875
+ attemptId: uuid8("attempt_id").notNull().references(() => orchestrationImplementationAttempts.id, { onDelete: "cascade" }),
28876
+ envelopeId: uuid8("envelope_id").notNull().references(() => orchestrationValidationEnvelopes.id, { onDelete: "cascade" }),
28877
+ headSha: varchar70("head_sha", { length: 64 }).notNull(),
28878
+ evidenceDigest: varchar70("evidence_digest", { length: 71 }).notNull(),
28879
+ artifactDigest: varchar70("artifact_digest", { length: 71 }).notNull(),
28880
+ validatorVersion: text97("validator_version").notNull(),
28806
28881
  /** The BrandKit contract this evidence is filed under. 0273 ties it to
28807
28882
  * `checks->brandKit->contractHash`, so a payload cannot claim a different one. Comparing it
28808
28883
  * against the ENVELOPE's hash is an ingest check — a CHECK cannot reach another table. */
28809
- brandContractHash: varchar69("brand_contract_hash", { length: 64 }).notNull(),
28810
- status: varchar69("status", { length: 10 }).notNull(),
28884
+ brandContractHash: varchar70("brand_contract_hash", { length: 64 }).notNull(),
28885
+ status: varchar70("status", { length: 10 }).notNull(),
28811
28886
  /** brandKit / runtime / visual. The shape is enforced by CHECK in 0273, not by the writer. */
28812
- checks: jsonb54("checks").notNull(),
28813
- createdBy: text95("created_by"),
28814
- createdAt: timestamp87("created_at", { withTimezone: true }).notNull().defaultNow()
28887
+ checks: jsonb56("checks").notNull(),
28888
+ createdBy: text97("created_by"),
28889
+ createdAt: timestamp89("created_at", { withTimezone: true }).notNull().defaultNow()
28815
28890
  },
28816
28891
  (table) => [
28817
28892
  unique10("orchestration_validation_evidence_scope_unique").on(
@@ -28838,37 +28913,37 @@ var orchestrationValidationEvidence = pgTable94(
28838
28913
  table.attemptId,
28839
28914
  table.evidenceDigest
28840
28915
  ),
28841
- index81("orchestration_validation_evidence_envelope_idx").on(table.envelopeId),
28916
+ index83("orchestration_validation_evidence_envelope_idx").on(table.envelopeId),
28842
28917
  check9(
28843
28918
  "orchestration_validation_evidence_status_check",
28844
- sql26`${table.status} IN ('passed', 'failed')`
28919
+ sql27`${table.status} IN ('passed', 'failed')`
28845
28920
  )
28846
28921
  ]
28847
28922
  );
28848
28923
 
28849
28924
  // src/schema/orchestration_executor_grants.ts
28850
- import { sql as sql27 } from "drizzle-orm";
28851
- import { check as check10, foreignKey as foreignKey12, index as index82, integer as integer48, pgTable as pgTable95, text as text96, timestamp as timestamp88, unique as unique11, uniqueIndex as uniqueIndex42, uuid as uuid8, varchar as varchar70 } from "drizzle-orm/pg-core";
28925
+ import { sql as sql28 } from "drizzle-orm";
28926
+ import { check as check10, foreignKey as foreignKey12, index as index84, integer as integer49, pgTable as pgTable97, text as text98, timestamp as timestamp90, unique as unique11, uniqueIndex as uniqueIndex43, uuid as uuid9, varchar as varchar71 } from "drizzle-orm/pg-core";
28852
28927
  var EXECUTOR_GRANT_STATUSES = ["active", "revoked", "expired"];
28853
- var orchestrationExecutorGrants = pgTable95(
28928
+ var orchestrationExecutorGrants = pgTable97(
28854
28929
  "orchestration_executor_grants",
28855
28930
  {
28856
- id: text96("id").primaryKey().default(sql27`gen_random_uuid()`),
28857
- workspaceId: text96("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28858
- projectId: text96("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28859
- installationId: uuid8("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
28931
+ id: text98("id").primaryKey().default(sql28`gen_random_uuid()`),
28932
+ workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28933
+ projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28934
+ installationId: uuid9("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
28860
28935
  /** Digest only. The credential is returned once at mint and never stored. */
28861
- credentialHash: varchar70("credential_hash", { length: 64 }).notNull(),
28862
- credentialAudience: text96("credential_audience").notNull(),
28863
- credentialExpiresAt: timestamp88("credential_expires_at", { withTimezone: true }).notNull(),
28936
+ credentialHash: varchar71("credential_hash", { length: 64 }).notNull(),
28937
+ credentialAudience: text98("credential_audience").notNull(),
28938
+ credentialExpiresAt: timestamp90("credential_expires_at", { withTimezone: true }).notNull(),
28864
28939
  /** The epoch this credential is valid for. A fenced session's credential dies before it expires. */
28865
- sessionEpoch: integer48("session_epoch").notNull(),
28866
- status: varchar70("status", { length: 16 }).notNull().default("active"),
28867
- revokedAt: timestamp88("revoked_at", { withTimezone: true }),
28868
- revokedBy: text96("revoked_by"),
28869
- createdBy: text96("created_by"),
28870
- createdAt: timestamp88("created_at", { withTimezone: true }).notNull().defaultNow(),
28871
- updatedAt: timestamp88("updated_at", { withTimezone: true }).notNull().defaultNow()
28940
+ sessionEpoch: integer49("session_epoch").notNull(),
28941
+ status: varchar71("status", { length: 16 }).notNull().default("active"),
28942
+ revokedAt: timestamp90("revoked_at", { withTimezone: true }),
28943
+ revokedBy: text98("revoked_by"),
28944
+ createdBy: text98("created_by"),
28945
+ createdAt: timestamp90("created_at", { withTimezone: true }).notNull().defaultNow(),
28946
+ updatedAt: timestamp90("updated_at", { withTimezone: true }).notNull().defaultNow()
28872
28947
  },
28873
28948
  (table) => [
28874
28949
  unique11("orchestration_executor_grants_scope_unique").on(
@@ -28887,42 +28962,42 @@ var orchestrationExecutorGrants = pgTable95(
28887
28962
  }).onDelete("cascade"),
28888
28963
  // One live credential per installation. Two would mean two processes can each present a valid
28889
28964
  // one, and the exclusion argument collapses before the lease layer is reached.
28890
- uniqueIndex42("orchestration_executor_grants_one_active_per_installation").on(table.installationId).where(sql27`status = 'active'`),
28891
- index82("orchestration_executor_grants_credential_idx").on(table.workspaceId, table.credentialHash).where(sql27`status = 'active'`),
28965
+ uniqueIndex43("orchestration_executor_grants_one_active_per_installation").on(table.installationId).where(sql28`status = 'active'`),
28966
+ index84("orchestration_executor_grants_credential_idx").on(table.workspaceId, table.credentialHash).where(sql28`status = 'active'`),
28892
28967
  check10(
28893
28968
  "orchestration_executor_grants_status_check",
28894
- sql27`${table.status} IN ('active', 'revoked', 'expired')`
28969
+ sql28`${table.status} IN ('active', 'revoked', 'expired')`
28895
28970
  ),
28896
28971
  check10(
28897
28972
  "orchestration_executor_grants_revocation_paired",
28898
- sql27`(${table.status} = 'revoked') = (${table.revokedAt} IS NOT NULL)`
28973
+ sql28`(${table.status} = 'revoked') = (${table.revokedAt} IS NOT NULL)`
28899
28974
  )
28900
28975
  ]
28901
28976
  );
28902
28977
 
28903
28978
  // src/schema/component_presets.ts
28904
- import { pgTable as pgTable96, text as text97, varchar as varchar71, timestamp as timestamp89, jsonb as jsonb55, integer as integer49, index as index83, uniqueIndex as uniqueIndex43 } from "drizzle-orm/pg-core";
28979
+ import { pgTable as pgTable98, text as text99, varchar as varchar72, timestamp as timestamp91, jsonb as jsonb57, integer as integer50, index as index85, uniqueIndex as uniqueIndex44 } from "drizzle-orm/pg-core";
28905
28980
  import { relations as relations16 } from "drizzle-orm";
28906
- var componentPresets = pgTable96(
28981
+ var componentPresets = pgTable98(
28907
28982
  "component_presets",
28908
28983
  {
28909
- id: text97("id").primaryKey(),
28910
- workspaceId: text97("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28911
- componentId: text97("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
28912
- name: varchar71("name", { length: 255 }).notNull(),
28984
+ id: text99("id").primaryKey(),
28985
+ workspaceId: text99("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28986
+ componentId: text99("component_id").notNull().references(() => components.id, { onDelete: "cascade" }),
28987
+ name: varchar72("name", { length: 255 }).notNull(),
28913
28988
  /** ^[a-z0-9-]+$, unique per component — stable across renames. */
28914
- slug: varchar71("slug", { length: 255 }).notNull(),
28989
+ slug: varchar72("slug", { length: 255 }).notNull(),
28915
28990
  /** Prop key → value. Validated against the component's `props` on every write. */
28916
- values: jsonb55("values").$type().notNull().default({}),
28917
- position: integer49("position").notNull().default(0),
28918
- createdAt: timestamp89("created_at").notNull().defaultNow(),
28919
- updatedAt: timestamp89("updated_at").notNull().defaultNow(),
28920
- createdBy: text97("created_by"),
28921
- updatedBy: text97("updated_by")
28991
+ values: jsonb57("values").$type().notNull().default({}),
28992
+ position: integer50("position").notNull().default(0),
28993
+ createdAt: timestamp91("created_at").notNull().defaultNow(),
28994
+ updatedAt: timestamp91("updated_at").notNull().defaultNow(),
28995
+ createdBy: text99("created_by"),
28996
+ updatedBy: text99("updated_by")
28922
28997
  },
28923
28998
  (t) => [
28924
- index83("component_presets_component_position_idx").on(t.componentId, t.position, t.createdAt, t.id),
28925
- uniqueIndex43("component_presets_component_slug_key").on(t.componentId, t.slug)
28999
+ index85("component_presets_component_position_idx").on(t.componentId, t.position, t.createdAt, t.id),
29000
+ uniqueIndex44("component_presets_component_slug_key").on(t.componentId, t.slug)
28926
29001
  ]
28927
29002
  );
28928
29003
  var componentPresetsRelations = relations16(componentPresets, ({ one }) => ({
@@ -28935,17 +29010,17 @@ var componentPresetsRelations = relations16(componentPresets, ({ one }) => ({
28935
29010
  // src/schema/section_zones.ts
28936
29011
  import {
28937
29012
  foreignKey as foreignKey13,
28938
- index as index84,
28939
- integer as integer50,
28940
- jsonb as jsonb56,
28941
- pgTable as pgTable97,
28942
- text as text98,
28943
- timestamp as timestamp90,
29013
+ index as index86,
29014
+ integer as integer51,
29015
+ jsonb as jsonb58,
29016
+ pgTable as pgTable99,
29017
+ text as text100,
29018
+ timestamp as timestamp92,
28944
29019
  unique as unique12,
28945
- uniqueIndex as uniqueIndex44,
28946
- varchar as varchar72
29020
+ uniqueIndex as uniqueIndex45,
29021
+ varchar as varchar73
28947
29022
  } from "drizzle-orm/pg-core";
28948
- import { sql as sql28 } from "drizzle-orm";
29023
+ import { sql as sql29 } from "drizzle-orm";
28949
29024
  var SECTION_IMPLEMENTATION_REQUEST_STATUSES = [
28950
29025
  "queued",
28951
29026
  "dispatching",
@@ -28954,15 +29029,15 @@ var SECTION_IMPLEMENTATION_REQUEST_STATUSES = [
28954
29029
  "passed",
28955
29030
  "failed"
28956
29031
  ];
28957
- var sectionDefinitions = pgTable97(
29032
+ var sectionDefinitions = pgTable99(
28958
29033
  "section_definitions",
28959
29034
  {
28960
- id: text98("id").primaryKey(),
28961
- workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28962
- projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28963
- apiId: varchar72("api_id", { length: 100 }).notNull(),
28964
- firstPublishedAt: timestamp90("first_published_at"),
28965
- archivedAt: timestamp90("archived_at"),
29035
+ id: text100("id").primaryKey(),
29036
+ workspaceId: text100("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29037
+ projectId: text100("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29038
+ apiId: varchar73("api_id", { length: 100 }).notNull(),
29039
+ firstPublishedAt: timestamp92("first_published_at"),
29040
+ archivedAt: timestamp92("archived_at"),
28966
29041
  ...auditColumns
28967
29042
  },
28968
29043
  (table) => [
@@ -28972,24 +29047,24 @@ var sectionDefinitions = pgTable97(
28972
29047
  name: "section_definitions_project_workspace_fkey"
28973
29048
  }).onDelete("cascade").onUpdate("cascade"),
28974
29049
  unique12("section_definitions_id_project_unique").on(table.id, table.projectId),
28975
- uniqueIndex44("section_definitions_project_api_id_unique").on(table.projectId, table.apiId),
28976
- index84("section_definitions_workspace_idx").on(table.workspaceId),
28977
- index84("section_definitions_project_idx").on(table.projectId)
29050
+ uniqueIndex45("section_definitions_project_api_id_unique").on(table.projectId, table.apiId),
29051
+ index86("section_definitions_workspace_idx").on(table.workspaceId),
29052
+ index86("section_definitions_project_idx").on(table.projectId)
28978
29053
  ]
28979
29054
  );
28980
- var sectionDefinitionVersions = pgTable97(
29055
+ var sectionDefinitionVersions = pgTable99(
28981
29056
  "section_definition_versions",
28982
29057
  {
28983
- id: text98("id").primaryKey(),
28984
- workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28985
- projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28986
- sectionDefinitionId: text98("section_definition_id").notNull(),
28987
- version: integer50("version").notNull(),
28988
- label: varchar72("label", { length: 255 }).notNull(),
28989
- fields: jsonb56("fields").$type().notNull().default([]),
28990
- schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
28991
- createdBy: text98("created_by"),
28992
- createdAt: timestamp90("created_at").notNull().defaultNow()
29058
+ id: text100("id").primaryKey(),
29059
+ workspaceId: text100("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29060
+ projectId: text100("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29061
+ sectionDefinitionId: text100("section_definition_id").notNull(),
29062
+ version: integer51("version").notNull(),
29063
+ label: varchar73("label", { length: 255 }).notNull(),
29064
+ fields: jsonb58("fields").$type().notNull().default([]),
29065
+ schemaHash: varchar73("schema_hash", { length: 64 }).notNull(),
29066
+ createdBy: text100("created_by"),
29067
+ createdAt: timestamp92("created_at").notNull().defaultNow()
28993
29068
  },
28994
29069
  (table) => [
28995
29070
  foreignKey13({
@@ -29008,20 +29083,20 @@ var sectionDefinitionVersions = pgTable97(
29008
29083
  table.version,
29009
29084
  table.projectId
29010
29085
  ),
29011
- index84("section_definition_versions_project_idx").on(table.projectId)
29086
+ index86("section_definition_versions_project_idx").on(table.projectId)
29012
29087
  ]
29013
29088
  );
29014
- var sectionZones = pgTable97(
29089
+ var sectionZones = pgTable99(
29015
29090
  "section_zones",
29016
29091
  {
29017
- id: text98("id").primaryKey(),
29018
- workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29019
- projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29020
- schemaKind: varchar72("schema_kind", { length: 20 }).$type().notNull(),
29021
- schemaId: text98("schema_id").notNull(),
29022
- fieldKey: varchar72("field_key", { length: 255 }).notNull(),
29023
- draftRevision: integer50("draft_revision").notNull().default(1),
29024
- publishedRevision: integer50("published_revision"),
29092
+ id: text100("id").primaryKey(),
29093
+ workspaceId: text100("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29094
+ projectId: text100("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29095
+ schemaKind: varchar73("schema_kind", { length: 20 }).$type().notNull(),
29096
+ schemaId: text100("schema_id").notNull(),
29097
+ fieldKey: varchar73("field_key", { length: 255 }).notNull(),
29098
+ draftRevision: integer51("draft_revision").notNull().default(1),
29099
+ publishedRevision: integer51("published_revision"),
29025
29100
  ...auditColumns
29026
29101
  },
29027
29102
  (table) => [
@@ -29031,21 +29106,21 @@ var sectionZones = pgTable97(
29031
29106
  name: "section_zones_project_workspace_fkey"
29032
29107
  }).onDelete("cascade").onUpdate("cascade"),
29033
29108
  unique12("section_zones_id_project_unique").on(table.id, table.projectId),
29034
- uniqueIndex44("section_zones_schema_owner_unique").on(table.projectId, table.schemaKind, table.schemaId),
29035
- index84("section_zones_workspace_idx").on(table.workspaceId)
29109
+ uniqueIndex45("section_zones_schema_owner_unique").on(table.projectId, table.schemaKind, table.schemaId),
29110
+ index86("section_zones_workspace_idx").on(table.workspaceId)
29036
29111
  ]
29037
29112
  );
29038
- var sectionZoneAttachments = pgTable97(
29113
+ var sectionZoneAttachments = pgTable99(
29039
29114
  "section_zone_attachments",
29040
29115
  {
29041
- id: text98("id").primaryKey(),
29042
- workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29043
- projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29044
- zoneId: text98("zone_id").notNull(),
29045
- sectionDefinitionId: text98("section_definition_id").notNull(),
29046
- draftVersion: integer50("draft_version").notNull(),
29047
- publishedVersion: integer50("published_version"),
29048
- position: integer50("position").notNull().default(0),
29116
+ id: text100("id").primaryKey(),
29117
+ workspaceId: text100("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29118
+ projectId: text100("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29119
+ zoneId: text100("zone_id").notNull(),
29120
+ sectionDefinitionId: text100("section_definition_id").notNull(),
29121
+ draftVersion: integer51("draft_version").notNull(),
29122
+ publishedVersion: integer51("published_version"),
29123
+ position: integer51("position").notNull().default(0),
29049
29124
  ...auditColumns
29050
29125
  },
29051
29126
  (table) => [
@@ -29082,24 +29157,24 @@ var sectionZoneAttachments = pgTable97(
29082
29157
  ],
29083
29158
  name: "section_zone_attachments_published_version_fkey"
29084
29159
  }).onDelete("restrict"),
29085
- uniqueIndex44("section_zone_attachments_zone_definition_unique").on(table.zoneId, table.sectionDefinitionId),
29086
- index84("section_zone_attachments_zone_position_idx").on(table.zoneId, table.position, table.id)
29160
+ uniqueIndex45("section_zone_attachments_zone_definition_unique").on(table.zoneId, table.sectionDefinitionId),
29161
+ index86("section_zone_attachments_zone_position_idx").on(table.zoneId, table.position, table.id)
29087
29162
  ]
29088
29163
  );
29089
- var sectionManifests = pgTable97(
29164
+ var sectionManifests = pgTable99(
29090
29165
  "section_manifests",
29091
29166
  {
29092
- id: text98("id").primaryKey(),
29093
- workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29094
- projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29095
- sectionDefinitionId: text98("section_definition_id").notNull(),
29096
- sectionVersion: integer50("section_version").notNull(),
29097
- apiId: varchar72("api_id", { length: 100 }).notNull(),
29098
- schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
29099
- commitSha: varchar72("commit_sha", { length: 64 }).notNull(),
29100
- manifest: jsonb56("manifest").$type().notNull(),
29101
- createdBy: text98("created_by"),
29102
- createdAt: timestamp90("created_at").notNull().defaultNow()
29167
+ id: text100("id").primaryKey(),
29168
+ workspaceId: text100("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29169
+ projectId: text100("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29170
+ sectionDefinitionId: text100("section_definition_id").notNull(),
29171
+ sectionVersion: integer51("section_version").notNull(),
29172
+ apiId: varchar73("api_id", { length: 100 }).notNull(),
29173
+ schemaHash: varchar73("schema_hash", { length: 64 }).notNull(),
29174
+ commitSha: varchar73("commit_sha", { length: 64 }).notNull(),
29175
+ manifest: jsonb58("manifest").$type().notNull(),
29176
+ createdBy: text100("created_by"),
29177
+ createdAt: timestamp92("created_at").notNull().defaultNow()
29103
29178
  },
29104
29179
  (table) => [
29105
29180
  foreignKey13({
@@ -29117,26 +29192,26 @@ var sectionManifests = pgTable97(
29117
29192
  name: "section_manifests_definition_version_project_fkey"
29118
29193
  }).onDelete("cascade"),
29119
29194
  unique12("section_manifests_id_project_unique").on(table.id, table.projectId),
29120
- index84("section_manifests_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
29195
+ index86("section_manifests_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
29121
29196
  ]
29122
29197
  );
29123
- var sectionValidationRuns = pgTable97(
29198
+ var sectionValidationRuns = pgTable99(
29124
29199
  "section_validation_runs",
29125
29200
  {
29126
- id: text98("id").primaryKey(),
29127
- workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29128
- projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29129
- sectionDefinitionId: text98("section_definition_id").notNull(),
29130
- sectionVersion: integer50("section_version").notNull(),
29131
- manifestId: text98("manifest_id").notNull(),
29132
- status: varchar72("status", { length: 20 }).$type().notNull(),
29133
- schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
29134
- commitSha: varchar72("commit_sha", { length: 64 }).notNull(),
29135
- fixtureHash: varchar72("fixture_hash", { length: 64 }).notNull(),
29136
- evidenceDigest: varchar72("evidence_digest", { length: 128 }).notNull(),
29137
- results: jsonb56("results").$type().notNull(),
29138
- createdBy: text98("created_by"),
29139
- createdAt: timestamp90("created_at").notNull().defaultNow()
29201
+ id: text100("id").primaryKey(),
29202
+ workspaceId: text100("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29203
+ projectId: text100("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29204
+ sectionDefinitionId: text100("section_definition_id").notNull(),
29205
+ sectionVersion: integer51("section_version").notNull(),
29206
+ manifestId: text100("manifest_id").notNull(),
29207
+ status: varchar73("status", { length: 20 }).$type().notNull(),
29208
+ schemaHash: varchar73("schema_hash", { length: 64 }).notNull(),
29209
+ commitSha: varchar73("commit_sha", { length: 64 }).notNull(),
29210
+ fixtureHash: varchar73("fixture_hash", { length: 64 }).notNull(),
29211
+ evidenceDigest: varchar73("evidence_digest", { length: 128 }).notNull(),
29212
+ results: jsonb58("results").$type().notNull(),
29213
+ createdBy: text100("created_by"),
29214
+ createdAt: timestamp92("created_at").notNull().defaultNow()
29140
29215
  },
29141
29216
  (table) => [
29142
29217
  foreignKey13({
@@ -29159,25 +29234,25 @@ var sectionValidationRuns = pgTable97(
29159
29234
  name: "section_validation_runs_manifest_project_fkey"
29160
29235
  }).onDelete("restrict"),
29161
29236
  unique12("section_validation_runs_id_project_unique").on(table.id, table.projectId),
29162
- index84("section_validation_runs_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
29237
+ index86("section_validation_runs_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
29163
29238
  ]
29164
29239
  );
29165
- var sectionVisualApprovals = pgTable97(
29240
+ var sectionVisualApprovals = pgTable99(
29166
29241
  "section_visual_approvals",
29167
29242
  {
29168
- id: text98("id").primaryKey(),
29169
- workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29170
- projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29171
- sectionDefinitionId: text98("section_definition_id").notNull(),
29172
- sectionVersion: integer50("section_version").notNull(),
29173
- manifestId: text98("manifest_id").notNull(),
29174
- validationRunId: text98("validation_run_id").notNull(),
29175
- schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
29176
- commitSha: varchar72("commit_sha", { length: 64 }).notNull(),
29177
- fixtureHash: varchar72("fixture_hash", { length: 64 }).notNull(),
29178
- evidenceDigest: varchar72("evidence_digest", { length: 128 }).notNull(),
29179
- approvedBy: text98("approved_by").notNull(),
29180
- createdAt: timestamp90("created_at").notNull().defaultNow()
29243
+ id: text100("id").primaryKey(),
29244
+ workspaceId: text100("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29245
+ projectId: text100("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29246
+ sectionDefinitionId: text100("section_definition_id").notNull(),
29247
+ sectionVersion: integer51("section_version").notNull(),
29248
+ manifestId: text100("manifest_id").notNull(),
29249
+ validationRunId: text100("validation_run_id").notNull(),
29250
+ schemaHash: varchar73("schema_hash", { length: 64 }).notNull(),
29251
+ commitSha: varchar73("commit_sha", { length: 64 }).notNull(),
29252
+ fixtureHash: varchar73("fixture_hash", { length: 64 }).notNull(),
29253
+ evidenceDigest: varchar73("evidence_digest", { length: 128 }).notNull(),
29254
+ approvedBy: text100("approved_by").notNull(),
29255
+ createdAt: timestamp92("created_at").notNull().defaultNow()
29181
29256
  },
29182
29257
  (table) => [
29183
29258
  foreignKey13({
@@ -29204,36 +29279,36 @@ var sectionVisualApprovals = pgTable97(
29204
29279
  foreignColumns: [sectionValidationRuns.id, sectionValidationRuns.projectId],
29205
29280
  name: "section_visual_approvals_validation_project_fkey"
29206
29281
  }).onDelete("restrict"),
29207
- index84("section_visual_approvals_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
29282
+ index86("section_visual_approvals_definition_version_idx").on(table.sectionDefinitionId, table.sectionVersion, table.createdAt)
29208
29283
  ]
29209
29284
  );
29210
- var sectionImplementationRequests = pgTable97(
29285
+ var sectionImplementationRequests = pgTable99(
29211
29286
  "section_implementation_requests",
29212
29287
  {
29213
- id: text98("id").primaryKey(),
29214
- workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29215
- projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29216
- sectionDefinitionId: text98("section_definition_id").notNull(),
29217
- sectionVersion: integer50("section_version").notNull(),
29218
- provider: varchar72("provider", { length: 20 }).$type().notNull(),
29219
- status: varchar72("status", { length: 20 }).$type().notNull().default("queued"),
29220
- schemaHash: varchar72("schema_hash", { length: 64 }).notNull(),
29221
- targetCommitSha: varchar72("target_commit_sha", { length: 64 }),
29222
- providerRunId: varchar72("provider_run_id", { length: 255 }),
29223
- providerRunUrl: text98("provider_run_url"),
29224
- manifestId: text98("manifest_id"),
29225
- validationRunId: text98("validation_run_id"),
29288
+ id: text100("id").primaryKey(),
29289
+ workspaceId: text100("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29290
+ projectId: text100("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29291
+ sectionDefinitionId: text100("section_definition_id").notNull(),
29292
+ sectionVersion: integer51("section_version").notNull(),
29293
+ provider: varchar73("provider", { length: 20 }).$type().notNull(),
29294
+ status: varchar73("status", { length: 20 }).$type().notNull().default("queued"),
29295
+ schemaHash: varchar73("schema_hash", { length: 64 }).notNull(),
29296
+ targetCommitSha: varchar73("target_commit_sha", { length: 64 }),
29297
+ providerRunId: varchar73("provider_run_id", { length: 255 }),
29298
+ providerRunUrl: text100("provider_run_url"),
29299
+ manifestId: text100("manifest_id"),
29300
+ validationRunId: text100("validation_run_id"),
29226
29301
  /** SHA-256 of the request-scoped GitHub callback bearer. The plaintext is never persisted. */
29227
- callbackTokenHash: varchar72("callback_token_hash", { length: 64 }),
29228
- requestedBy: text98("requested_by").notNull(),
29229
- claimedBy: text98("claimed_by"),
29230
- errorCode: varchar72("error_code", { length: 100 }),
29231
- errorMessage: text98("error_message"),
29232
- dispatchedAt: timestamp90("dispatched_at"),
29233
- startedAt: timestamp90("started_at"),
29234
- completedAt: timestamp90("completed_at"),
29235
- createdAt: timestamp90("created_at").notNull().defaultNow(),
29236
- updatedAt: timestamp90("updated_at").notNull().defaultNow()
29302
+ callbackTokenHash: varchar73("callback_token_hash", { length: 64 }),
29303
+ requestedBy: text100("requested_by").notNull(),
29304
+ claimedBy: text100("claimed_by"),
29305
+ errorCode: varchar73("error_code", { length: 100 }),
29306
+ errorMessage: text100("error_message"),
29307
+ dispatchedAt: timestamp92("dispatched_at"),
29308
+ startedAt: timestamp92("started_at"),
29309
+ completedAt: timestamp92("completed_at"),
29310
+ createdAt: timestamp92("created_at").notNull().defaultNow(),
29311
+ updatedAt: timestamp92("updated_at").notNull().defaultNow()
29237
29312
  },
29238
29313
  (table) => [
29239
29314
  foreignKey13({
@@ -29261,21 +29336,21 @@ var sectionImplementationRequests = pgTable97(
29261
29336
  name: "section_implementation_requests_validation_project_fkey"
29262
29337
  }).onDelete("restrict"),
29263
29338
  unique12("section_implementation_requests_id_project_unique").on(table.id, table.projectId),
29264
- uniqueIndex44("section_implementation_requests_one_active_unique").on(table.projectId, table.sectionDefinitionId, table.sectionVersion, table.schemaHash).where(sql28`${table.status} IN ('queued', 'dispatching', 'dispatched', 'running')`),
29265
- index84("section_implementation_requests_project_created_idx").on(table.projectId, table.createdAt)
29339
+ uniqueIndex45("section_implementation_requests_one_active_unique").on(table.projectId, table.sectionDefinitionId, table.sectionVersion, table.schemaHash).where(sql29`${table.status} IN ('queued', 'dispatching', 'dispatched', 'running')`),
29340
+ index86("section_implementation_requests_project_created_idx").on(table.projectId, table.createdAt)
29266
29341
  ]
29267
29342
  );
29268
- var sectionZoneReleases = pgTable97(
29343
+ var sectionZoneReleases = pgTable99(
29269
29344
  "section_zone_releases",
29270
29345
  {
29271
- id: text98("id").primaryKey(),
29272
- workspaceId: text98("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29273
- projectId: text98("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29274
- zoneId: text98("zone_id").notNull(),
29275
- revision: integer50("revision").notNull(),
29276
- snapshot: jsonb56("snapshot").$type().notNull(),
29277
- publishedBy: text98("published_by").notNull(),
29278
- publishedAt: timestamp90("published_at").notNull().defaultNow()
29346
+ id: text100("id").primaryKey(),
29347
+ workspaceId: text100("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
29348
+ projectId: text100("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
29349
+ zoneId: text100("zone_id").notNull(),
29350
+ revision: integer51("revision").notNull(),
29351
+ snapshot: jsonb58("snapshot").$type().notNull(),
29352
+ publishedBy: text100("published_by").notNull(),
29353
+ publishedAt: timestamp92("published_at").notNull().defaultNow()
29279
29354
  },
29280
29355
  (table) => [
29281
29356
  foreignKey13({
@@ -29289,13 +29364,13 @@ var sectionZoneReleases = pgTable97(
29289
29364
  name: "section_zone_releases_zone_project_fkey"
29290
29365
  }).onDelete("cascade"),
29291
29366
  unique12("section_zone_releases_zone_revision_unique").on(table.zoneId, table.revision),
29292
- index84("section_zone_releases_project_published_idx").on(table.projectId, table.publishedAt)
29367
+ index86("section_zone_releases_project_published_idx").on(table.projectId, table.publishedAt)
29293
29368
  ]
29294
29369
  );
29295
29370
 
29296
29371
  // src/schema/content_locks.ts
29297
- import { check as check11, index as index85, jsonb as jsonb57, pgTable as pgTable98, text as text99, timestamp as timestamp91 } from "drizzle-orm/pg-core";
29298
- import { sql as sql29 } from "drizzle-orm";
29372
+ import { check as check11, index as index87, jsonb as jsonb59, pgTable as pgTable100, text as text101, timestamp as timestamp93 } from "drizzle-orm/pg-core";
29373
+ import { sql as sql30 } from "drizzle-orm";
29299
29374
  var CONTENT_LOCK_TARGET_KINDS = [
29300
29375
  "page",
29301
29376
  "content_entry",
@@ -29303,32 +29378,32 @@ var CONTENT_LOCK_TARGET_KINDS = [
29303
29378
  "component_definition"
29304
29379
  ];
29305
29380
  var CONTENT_LOCK_MODES = ["all", "agents"];
29306
- var contentLocks = pgTable98(
29381
+ var contentLocks = pgTable100(
29307
29382
  "content_locks",
29308
29383
  {
29309
- id: text99("id").primaryKey(),
29310
- workspaceId: text99("workspace_id").notNull(),
29311
- projectId: text99("project_id").notNull(),
29312
- targetKind: text99("target_kind").$type().notNull(),
29313
- targetId: text99("target_id").notNull(),
29314
- blockId: text99("block_id"),
29384
+ id: text101("id").primaryKey(),
29385
+ workspaceId: text101("workspace_id").notNull(),
29386
+ projectId: text101("project_id").notNull(),
29387
+ targetKind: text101("target_kind").$type().notNull(),
29388
+ targetId: text101("target_id").notNull(),
29389
+ blockId: text101("block_id"),
29315
29390
  // Deterministic structural path plus block ancestry captured when the lock is created.
29316
29391
  // Nullable so Wave 5 remains compatible with locks created before this fingerprint existed.
29317
- blockFingerprint: jsonb57("block_fingerprint").$type(),
29318
- fieldPath: text99("field_path").array(),
29319
- mode: text99("mode").$type().notNull().default("all"),
29320
- reason: text99("reason"),
29321
- createdBy: text99("created_by").notNull(),
29322
- createdAt: timestamp91("created_at").notNull().defaultNow(),
29323
- releasedBy: text99("released_by"),
29324
- releasedAt: timestamp91("released_at")
29392
+ blockFingerprint: jsonb59("block_fingerprint").$type(),
29393
+ fieldPath: text101("field_path").array(),
29394
+ mode: text101("mode").$type().notNull().default("all"),
29395
+ reason: text101("reason"),
29396
+ createdBy: text101("created_by").notNull(),
29397
+ createdAt: timestamp93("created_at").notNull().defaultNow(),
29398
+ releasedBy: text101("released_by"),
29399
+ releasedAt: timestamp93("released_at")
29325
29400
  },
29326
29401
  (table) => [
29327
- index85("content_locks_workspace_idx").on(table.workspaceId),
29328
- index85("content_locks_project_idx").on(table.projectId),
29329
- index85("content_locks_target_idx").on(table.targetKind, table.targetId).where(sql29`${table.releasedAt} IS NULL`),
29330
- check11("content_locks_target_kind_check", sql29`${table.targetKind} IN ('page','content_entry','singleton_entry','component_definition')`),
29331
- check11("content_locks_mode_check", sql29`${table.mode} IN ('all','agents')`)
29402
+ index87("content_locks_workspace_idx").on(table.workspaceId),
29403
+ index87("content_locks_project_idx").on(table.projectId),
29404
+ index87("content_locks_target_idx").on(table.targetKind, table.targetId).where(sql30`${table.releasedAt} IS NULL`),
29405
+ check11("content_locks_target_kind_check", sql30`${table.targetKind} IN ('page','content_entry','singleton_entry','component_definition')`),
29406
+ check11("content_locks_mode_check", sql30`${table.mode} IN ('all','agents')`)
29332
29407
  // `content_locks_shape_check` lives in migration 0192 ONLY: it calls
29333
29408
  // content_lock_field_path_valid(), which that migration creates. Declared here it went into
29334
29409
  // `drizzle-kit push`'s CREATE TABLE on an empty database, where the function does not exist
@@ -29342,75 +29417,75 @@ var contentLocks = pgTable98(
29342
29417
 
29343
29418
  // src/schema/project_transfers.ts
29344
29419
  import {
29345
- pgTable as pgTable99,
29346
- text as text100,
29347
- varchar as varchar73,
29348
- timestamp as timestamp92,
29349
- index as index86,
29350
- uniqueIndex as uniqueIndex45
29420
+ pgTable as pgTable101,
29421
+ text as text102,
29422
+ varchar as varchar74,
29423
+ timestamp as timestamp94,
29424
+ index as index88,
29425
+ uniqueIndex as uniqueIndex46
29351
29426
  } from "drizzle-orm/pg-core";
29352
- import { sql as sql30 } from "drizzle-orm";
29353
- var projectTransfers = pgTable99(
29427
+ import { sql as sql31 } from "drizzle-orm";
29428
+ var projectTransfers = pgTable101(
29354
29429
  "project_transfers",
29355
29430
  {
29356
- id: text100("id").primaryKey(),
29431
+ id: text102("id").primaryKey(),
29357
29432
  // nanoid
29358
- token: text100("token").notNull(),
29433
+ token: text102("token").notNull(),
29359
29434
  // nanoid(32) — recipient handshake / magic link
29360
- status: varchar73("status", { length: 20 }).notNull().default("pending"),
29435
+ status: varchar74("status", { length: 20 }).notNull().default("pending"),
29361
29436
  // pending | accepted (transient) | completed | declined | cancelled | expired | failed
29362
- projectId: text100("project_id").notNull(),
29437
+ projectId: text102("project_id").notNull(),
29363
29438
  // FK → projects.id (ON DELETE CASCADE, via migration)
29364
- fromWorkspaceId: text100("from_workspace_id").notNull(),
29439
+ fromWorkspaceId: text102("from_workspace_id").notNull(),
29365
29440
  // FK → workspaces.id (source)
29366
- toWorkspaceId: text100("to_workspace_id"),
29441
+ toWorkspaceId: text102("to_workspace_id"),
29367
29442
  // FK → workspaces.id — resolved at accept (null while pending)
29368
- initiatedBy: text100("initiated_by").notNull(),
29443
+ initiatedBy: text102("initiated_by").notNull(),
29369
29444
  // FK → users.id (source owner)
29370
- recipientEmail: varchar73("recipient_email", { length: 255 }).notNull(),
29445
+ recipientEmail: varchar74("recipient_email", { length: 255 }).notNull(),
29371
29446
  // lowercased
29372
- note: text100("note"),
29447
+ note: text102("note"),
29373
29448
  // optional message to the recipient
29374
- resolvedAt: timestamp92("resolved_at"),
29449
+ resolvedAt: timestamp94("resolved_at"),
29375
29450
  // set on accept/decline/cancel/expire
29376
- resolvedBy: text100("resolved_by"),
29451
+ resolvedBy: text102("resolved_by"),
29377
29452
  // FK → users.id (accepter/decliner/canceller)
29378
- error: text100("error"),
29453
+ error: text102("error"),
29379
29454
  // failure detail when status='failed'
29380
- expiresAt: timestamp92("expires_at").notNull(),
29455
+ expiresAt: timestamp94("expires_at").notNull(),
29381
29456
  // createdAt + 7d
29382
- createdAt: timestamp92("created_at").notNull().defaultNow(),
29383
- updatedAt: timestamp92("updated_at").notNull().defaultNow()
29457
+ createdAt: timestamp94("created_at").notNull().defaultNow(),
29458
+ updatedAt: timestamp94("updated_at").notNull().defaultNow()
29384
29459
  },
29385
29460
  (table) => [
29386
29461
  // At most one OPEN transfer per project. Partial-unique so completed/declined/
29387
29462
  // cancelled/expired/failed rows never wedge a re-initiation.
29388
- uniqueIndex45("project_transfers_one_pending_idx").on(table.projectId).where(sql30`${table.status} = 'pending'`),
29463
+ uniqueIndex46("project_transfers_one_pending_idx").on(table.projectId).where(sql31`${table.status} = 'pending'`),
29389
29464
  // Recipient inbox lookup (GET /me/transfers by email + status).
29390
- index86("project_transfers_recipient_idx").on(
29465
+ index88("project_transfers_recipient_idx").on(
29391
29466
  table.recipientEmail,
29392
29467
  table.status
29393
29468
  ),
29394
29469
  // Source-side list (GET /projects/:id/transfers) + cancel.
29395
- index86("project_transfers_from_ws_idx").on(table.fromWorkspaceId),
29396
- index86("project_transfers_project_idx").on(table.projectId),
29470
+ index88("project_transfers_from_ws_idx").on(table.fromWorkspaceId),
29471
+ index88("project_transfers_project_idx").on(table.projectId),
29397
29472
  // Magic-link resolution.
29398
- uniqueIndex45("project_transfers_token_idx").on(table.token),
29473
+ uniqueIndex46("project_transfers_token_idx").on(table.token),
29399
29474
  // Expiry sweep — only pending rows are ever candidates.
29400
- index86("project_transfers_expires_idx").on(table.expiresAt).where(sql30`${table.status} = 'pending'`)
29475
+ index88("project_transfers_expires_idx").on(table.expiresAt).where(sql31`${table.status} = 'pending'`)
29401
29476
  ]
29402
29477
  );
29403
29478
 
29404
29479
  // src/schema/backups.ts
29405
29480
  import {
29406
- pgTable as pgTable100,
29407
- text as text101,
29408
- varchar as varchar74,
29409
- integer as integer51,
29481
+ pgTable as pgTable102,
29482
+ text as text103,
29483
+ varchar as varchar75,
29484
+ integer as integer52,
29410
29485
  bigint as bigint7,
29411
- jsonb as jsonb58,
29412
- timestamp as timestamp93,
29413
- index as index87
29486
+ jsonb as jsonb60,
29487
+ timestamp as timestamp95,
29488
+ index as index89
29414
29489
  } from "drizzle-orm/pg-core";
29415
29490
  var FULL_BACKUP_SCOPE = {
29416
29491
  content: true,
@@ -29419,315 +29494,315 @@ var FULL_BACKUP_SCOPE = {
29419
29494
  submissions: true,
29420
29495
  analytics: true
29421
29496
  };
29422
- var backups = pgTable100(
29497
+ var backups = pgTable102(
29423
29498
  "backups",
29424
29499
  {
29425
- id: text101("id").primaryKey(),
29500
+ id: text103("id").primaryKey(),
29426
29501
  // nanoid
29427
- workspaceId: text101("workspace_id").notNull(),
29502
+ workspaceId: text103("workspace_id").notNull(),
29428
29503
  // FK → workspaces.id (RLS scope)
29429
- projectId: text101("project_id").notNull(),
29504
+ projectId: text103("project_id").notNull(),
29430
29505
  // FK → projects.id
29431
- name: varchar74("name", { length: 255 }).notNull(),
29432
- source: varchar74("source", { length: 20 }).notNull().default("manual"),
29433
- status: varchar74("status", { length: 20 }).notNull().default("pending"),
29434
- manifestKey: text101("manifest_key"),
29506
+ name: varchar75("name", { length: 255 }).notNull(),
29507
+ source: varchar75("source", { length: 20 }).notNull().default("manual"),
29508
+ status: varchar75("status", { length: 20 }).notNull().default("pending"),
29509
+ manifestKey: text103("manifest_key"),
29435
29510
  // R2 key of the gzipped manifest; NULL until ready
29436
- manifestVersion: integer51("manifest_version").notNull().default(1),
29511
+ manifestVersion: integer52("manifest_version").notNull().default(1),
29437
29512
  // forward-compat
29438
29513
  sizeBytes: bigint7("size_bytes", { mode: "number" }),
29439
- counts: jsonb58("counts").$type().notNull().default({}),
29514
+ counts: jsonb60("counts").$type().notNull().default({}),
29440
29515
  // R2 object keys this snapshot references. Powers the media-GC hold:
29441
29516
  // `list_backup_referenced_media_keys()` keeps these keys alive while the
29442
29517
  // backup is live, so a restore never finds a garbage-collected object.
29443
- mediaKeys: jsonb58("media_keys").$type().notNull().default([]),
29444
- scope: jsonb58("scope").$type().notNull().default(FULL_BACKUP_SCOPE),
29445
- error: text101("error"),
29446
- createdBy: text101("created_by"),
29518
+ mediaKeys: jsonb60("media_keys").$type().notNull().default([]),
29519
+ scope: jsonb60("scope").$type().notNull().default(FULL_BACKUP_SCOPE),
29520
+ error: text103("error"),
29521
+ createdBy: text103("created_by"),
29447
29522
  // FK → users(id); NULL = system-initiated
29448
- createdAt: timestamp93("created_at").notNull().defaultNow(),
29449
- readyAt: timestamp93("ready_at"),
29450
- expiresAt: timestamp93("expires_at"),
29523
+ createdAt: timestamp95("created_at").notNull().defaultNow(),
29524
+ readyAt: timestamp95("ready_at"),
29525
+ expiresAt: timestamp95("expires_at"),
29451
29526
  // retention horizon; NULL = keep until count-pruned
29452
- deletedAt: timestamp93("deleted_at")
29527
+ deletedAt: timestamp95("deleted_at")
29453
29528
  },
29454
29529
  (t) => [
29455
- index87("backups_project_idx").on(t.projectId, t.createdAt),
29456
- index87("backups_workspace_idx").on(t.workspaceId)
29530
+ index89("backups_project_idx").on(t.projectId, t.createdAt),
29531
+ index89("backups_workspace_idx").on(t.workspaceId)
29457
29532
  ]
29458
29533
  );
29459
29534
 
29460
29535
  // src/schema/backup_jobs.ts
29461
29536
  import {
29462
- pgTable as pgTable101,
29463
- text as text102,
29464
- varchar as varchar75,
29465
- integer as integer52,
29466
- jsonb as jsonb59,
29467
- timestamp as timestamp94,
29468
- index as index88
29537
+ pgTable as pgTable103,
29538
+ text as text104,
29539
+ varchar as varchar76,
29540
+ integer as integer53,
29541
+ jsonb as jsonb61,
29542
+ timestamp as timestamp96,
29543
+ index as index90
29469
29544
  } from "drizzle-orm/pg-core";
29470
- var backupJobs = pgTable101(
29545
+ var backupJobs = pgTable103(
29471
29546
  "backup_jobs",
29472
29547
  {
29473
- id: text102("id").primaryKey(),
29548
+ id: text104("id").primaryKey(),
29474
29549
  // nanoid
29475
- workspaceId: text102("workspace_id").notNull(),
29476
- projectId: text102("project_id").notNull(),
29550
+ workspaceId: text104("workspace_id").notNull(),
29551
+ projectId: text104("project_id").notNull(),
29477
29552
  // create → the pending backups.id this job fills; restore → the source backup.
29478
- backupId: text102("backup_id"),
29479
- operation: varchar75("operation", { length: 16 }).notNull(),
29480
- status: varchar75("status", { length: 16 }).notNull().default("pending"),
29481
- progress: integer52("progress").notNull().default(0),
29553
+ backupId: text104("backup_id"),
29554
+ operation: varchar76("operation", { length: 16 }).notNull(),
29555
+ status: varchar76("status", { length: 16 }).notNull().default("pending"),
29556
+ progress: integer53("progress").notNull().default(0),
29482
29557
  // 0–100
29483
- workingSince: timestamp94("working_since", { withTimezone: true }),
29484
- attempts: integer52("attempts").notNull().default(0),
29485
- error: text102("error"),
29486
- payload: jsonb59("payload").$type().notNull().default({}),
29487
- createdAt: timestamp94("created_at").notNull().defaultNow(),
29488
- updatedAt: timestamp94("updated_at").notNull().defaultNow()
29558
+ workingSince: timestamp96("working_since", { withTimezone: true }),
29559
+ attempts: integer53("attempts").notNull().default(0),
29560
+ error: text104("error"),
29561
+ payload: jsonb61("payload").$type().notNull().default({}),
29562
+ createdAt: timestamp96("created_at").notNull().defaultNow(),
29563
+ updatedAt: timestamp96("updated_at").notNull().defaultNow()
29489
29564
  },
29490
29565
  (t) => [
29491
- index88("backup_jobs_drain_idx").on(t.status, t.createdAt),
29492
- index88("backup_jobs_project_idx").on(t.projectId)
29566
+ index90("backup_jobs_drain_idx").on(t.status, t.createdAt),
29567
+ index90("backup_jobs_project_idx").on(t.projectId)
29493
29568
  ]
29494
29569
  );
29495
29570
 
29496
29571
  // src/schema/clone_links.ts
29497
- import { pgTable as pgTable102, text as text103, boolean as boolean31, jsonb as jsonb60, timestamp as timestamp95, index as index89 } from "drizzle-orm/pg-core";
29498
- var cloneLinks = pgTable102(
29572
+ import { pgTable as pgTable104, text as text105, boolean as boolean31, jsonb as jsonb62, timestamp as timestamp97, index as index91 } from "drizzle-orm/pg-core";
29573
+ var cloneLinks = pgTable104(
29499
29574
  "clone_links",
29500
29575
  {
29501
- id: text103("id").primaryKey(),
29576
+ id: text105("id").primaryKey(),
29502
29577
  // nanoid
29503
- workspaceId: text103("workspace_id").notNull(),
29578
+ workspaceId: text105("workspace_id").notNull(),
29504
29579
  // FK → workspaces.id (RLS scope)
29505
- projectId: text103("project_id").notNull(),
29580
+ projectId: text105("project_id").notNull(),
29506
29581
  // FK → projects.id
29507
- token: text103("token").notNull(),
29582
+ token: text105("token").notNull(),
29508
29583
  // public share token (nanoid); unique among active links
29509
29584
  enabled: boolean31("enabled").notNull().default(true),
29510
- scope: jsonb60("scope").$type().notNull(),
29511
- createdBy: text103("created_by"),
29585
+ scope: jsonb62("scope").$type().notNull(),
29586
+ createdBy: text105("created_by"),
29512
29587
  // FK → users(id); NULL = system-initiated
29513
- createdAt: timestamp95("created_at").notNull().defaultNow(),
29514
- updatedAt: timestamp95("updated_at").notNull().defaultNow(),
29515
- revokedAt: timestamp95("revoked_at")
29588
+ createdAt: timestamp97("created_at").notNull().defaultNow(),
29589
+ updatedAt: timestamp97("updated_at").notNull().defaultNow(),
29590
+ revokedAt: timestamp97("revoked_at")
29516
29591
  // set when the link is rotated/disabled
29517
29592
  },
29518
29593
  (t) => [
29519
- index89("clone_links_project_idx").on(t.projectId),
29520
- index89("clone_links_workspace_idx").on(t.workspaceId)
29594
+ index91("clone_links_project_idx").on(t.projectId),
29595
+ index91("clone_links_workspace_idx").on(t.workspaceId)
29521
29596
  ]
29522
29597
  );
29523
29598
 
29524
29599
  // src/schema/clone_jobs.ts
29525
- import { pgTable as pgTable103, text as text104, varchar as varchar76, integer as integer53, jsonb as jsonb61, timestamp as timestamp96, index as index90, uniqueIndex as uniqueIndex46 } from "drizzle-orm/pg-core";
29526
- import { sql as sql31 } from "drizzle-orm";
29527
- var cloneJobs = pgTable103(
29600
+ import { pgTable as pgTable105, text as text106, varchar as varchar77, integer as integer54, jsonb as jsonb63, timestamp as timestamp98, index as index92, uniqueIndex as uniqueIndex47 } from "drizzle-orm/pg-core";
29601
+ import { sql as sql32 } from "drizzle-orm";
29602
+ var cloneJobs = pgTable105(
29528
29603
  "clone_jobs",
29529
29604
  {
29530
- id: text104("id").primaryKey(),
29605
+ id: text106("id").primaryKey(),
29531
29606
  // nanoid
29532
- workspaceId: text104("workspace_id").notNull(),
29607
+ workspaceId: text106("workspace_id").notNull(),
29533
29608
  // = targetWorkspaceId (RLS scope)
29534
- sourceProjectId: text104("source_project_id").notNull(),
29535
- sourceWorkspaceId: text104("source_workspace_id").notNull(),
29536
- targetProjectId: text104("target_project_id"),
29609
+ sourceProjectId: text106("source_project_id").notNull(),
29610
+ sourceWorkspaceId: text106("source_workspace_id").notNull(),
29611
+ targetProjectId: text106("target_project_id"),
29537
29612
  // stamped on success
29538
- requestedName: varchar76("requested_name", { length: 255 }),
29539
- requestedSlug: varchar76("requested_slug", { length: 255 }),
29540
- status: varchar76("status", { length: 16 }).notNull().default("pending"),
29541
- progress: integer53("progress").notNull().default(0),
29613
+ requestedName: varchar77("requested_name", { length: 255 }),
29614
+ requestedSlug: varchar77("requested_slug", { length: 255 }),
29615
+ status: varchar77("status", { length: 16 }).notNull().default("pending"),
29616
+ progress: integer54("progress").notNull().default(0),
29542
29617
  // 0–100
29543
- workingSince: timestamp96("working_since", { withTimezone: true }),
29544
- attempts: integer53("attempts").notNull().default(0),
29545
- error: text104("error"),
29546
- payload: jsonb61("payload").$type().notNull().default({}),
29618
+ workingSince: timestamp98("working_since", { withTimezone: true }),
29619
+ attempts: integer54("attempts").notNull().default(0),
29620
+ error: text106("error"),
29621
+ payload: jsonb63("payload").$type().notNull().default({}),
29547
29622
  // Which post-clone work the drain owes a finished job. 'clone' = none, today's behaviour.
29548
29623
  // Migration 0343.
29549
- purpose: varchar76("purpose", { length: 32 }).notNull().default("clone"),
29550
- initiatedBy: text104("initiated_by"),
29624
+ purpose: varchar77("purpose", { length: 32 }).notNull().default("clone"),
29625
+ initiatedBy: text106("initiated_by"),
29551
29626
  // FK → users(id); NULL = system/agent
29552
- createdAt: timestamp96("created_at").notNull().defaultNow(),
29553
- updatedAt: timestamp96("updated_at").notNull().defaultNow()
29627
+ createdAt: timestamp98("created_at").notNull().defaultNow(),
29628
+ updatedAt: timestamp98("updated_at").notNull().defaultNow()
29554
29629
  },
29555
29630
  (t) => [
29556
- index90("clone_jobs_drain_idx").on(t.status, t.createdAt),
29557
- index90("clone_jobs_workspace_idx").on(t.workspaceId),
29631
+ index92("clone_jobs_drain_idx").on(t.status, t.createdAt),
29632
+ index92("clone_jobs_workspace_idx").on(t.workspaceId),
29558
29633
  // One unfinished hybrid→headless switch per source (0343). The route maps its 23505 to
29559
29634
  // SWITCH_ALREADY_PENDING.
29560
- uniqueIndex46("clone_jobs_mode_switch_active_uniq").on(t.sourceProjectId).where(sql31`${t.purpose} = 'mode_switch' AND ${t.status} IN ('pending', 'working')`)
29635
+ uniqueIndex47("clone_jobs_mode_switch_active_uniq").on(t.sourceProjectId).where(sql32`${t.purpose} = 'mode_switch' AND ${t.status} IN ('pending', 'working')`)
29561
29636
  ]
29562
29637
  );
29563
29638
 
29564
29639
  // src/schema/project_branches.ts
29565
29640
  import {
29566
- primaryKey as primaryKey9,
29567
- pgTable as pgTable104,
29568
- text as text105,
29569
- varchar as varchar77,
29570
- timestamp as timestamp97,
29571
- index as index91,
29572
- uniqueIndex as uniqueIndex47
29641
+ primaryKey as primaryKey10,
29642
+ pgTable as pgTable106,
29643
+ text as text107,
29644
+ varchar as varchar78,
29645
+ timestamp as timestamp99,
29646
+ index as index93,
29647
+ uniqueIndex as uniqueIndex48
29573
29648
  } from "drizzle-orm/pg-core";
29574
- import { sql as sql32 } from "drizzle-orm";
29575
- var projectBranches = pgTable104(
29649
+ import { sql as sql33 } from "drizzle-orm";
29650
+ var projectBranches = pgTable106(
29576
29651
  "project_branches",
29577
29652
  {
29578
- id: text105("id").primaryKey(),
29579
- workspaceId: text105("workspace_id").notNull(),
29580
- projectId: text105("project_id").notNull(),
29581
- name: varchar77("name", { length: 80 }).notNull(),
29582
- slug: varchar77("slug", { length: 80 }).notNull(),
29583
- parentBranchId: text105("parent_branch_id"),
29584
- status: varchar77("status", { length: 16 }).$type().notNull().default("open"),
29585
- appliedAt: timestamp97("applied_at"),
29586
- abandonedAt: timestamp97("abandoned_at"),
29653
+ id: text107("id").primaryKey(),
29654
+ workspaceId: text107("workspace_id").notNull(),
29655
+ projectId: text107("project_id").notNull(),
29656
+ name: varchar78("name", { length: 80 }).notNull(),
29657
+ slug: varchar78("slug", { length: 80 }).notNull(),
29658
+ parentBranchId: text107("parent_branch_id"),
29659
+ status: varchar78("status", { length: 16 }).$type().notNull().default("open"),
29660
+ appliedAt: timestamp99("applied_at"),
29661
+ abandonedAt: timestamp99("abandoned_at"),
29587
29662
  /** Set while an Apply/Pull runs (0374); a second one is refused. Stale after five minutes. */
29588
- applyingAt: timestamp97("applying_at"),
29663
+ applyingAt: timestamp99("applying_at"),
29589
29664
  ...auditColumns
29590
29665
  },
29591
29666
  (t) => [
29592
- index91("project_branches_project_idx").on(t.projectId),
29593
- uniqueIndex47("project_branches_project_slug_open_idx").on(t.projectId, t.slug).where(sql32`${t.status} = 'open'`)
29667
+ index93("project_branches_project_idx").on(t.projectId),
29668
+ uniqueIndex48("project_branches_project_slug_open_idx").on(t.projectId, t.slug).where(sql33`${t.status} = 'open'`)
29594
29669
  ]
29595
29670
  );
29596
- var branchRowSyncs = pgTable104(
29671
+ var branchRowSyncs = pgTable106(
29597
29672
  "branch_row_syncs",
29598
29673
  {
29599
- workspaceId: text105("workspace_id").notNull(),
29600
- projectId: text105("project_id").notNull(),
29601
- branchId: text105("branch_id").notNull(),
29602
- kind: text105("kind").notNull(),
29603
- parentRowId: text105("parent_row_id").notNull(),
29604
- syncedAt: timestamp97("synced_at").notNull().defaultNow()
29674
+ workspaceId: text107("workspace_id").notNull(),
29675
+ projectId: text107("project_id").notNull(),
29676
+ branchId: text107("branch_id").notNull(),
29677
+ kind: text107("kind").notNull(),
29678
+ parentRowId: text107("parent_row_id").notNull(),
29679
+ syncedAt: timestamp99("synced_at").notNull().defaultNow()
29605
29680
  },
29606
29681
  (t) => [
29607
- primaryKey9({ columns: [t.branchId, t.kind, t.parentRowId] }),
29608
- index91("branch_row_syncs_project_idx").on(t.projectId)
29682
+ primaryKey10({ columns: [t.branchId, t.kind, t.parentRowId] }),
29683
+ index93("branch_row_syncs_project_idx").on(t.projectId)
29609
29684
  ]
29610
29685
  );
29611
29686
 
29612
29687
  // src/schema/branch_preview_share.ts
29613
- import { pgTable as pgTable105, text as text106, boolean as boolean32, timestamp as timestamp98, index as index92, uniqueIndex as uniqueIndex48 } from "drizzle-orm/pg-core";
29614
- var branchPreviewShares = pgTable105(
29688
+ import { pgTable as pgTable107, text as text108, boolean as boolean32, timestamp as timestamp100, index as index94, uniqueIndex as uniqueIndex49 } from "drizzle-orm/pg-core";
29689
+ var branchPreviewShares = pgTable107(
29615
29690
  "branch_preview_shares",
29616
29691
  {
29617
- id: text106("id").primaryKey(),
29618
- workspaceId: text106("workspace_id").notNull(),
29619
- projectId: text106("project_id").notNull(),
29620
- branchId: text106("branch_id").notNull(),
29692
+ id: text108("id").primaryKey(),
29693
+ workspaceId: text108("workspace_id").notNull(),
29694
+ projectId: text108("project_id").notNull(),
29695
+ branchId: text108("branch_id").notNull(),
29621
29696
  publicEnabled: boolean32("public_enabled").notNull().default(false),
29622
- publicToken: text106("public_token"),
29623
- createdBy: text106("created_by"),
29624
- createdAt: timestamp98("created_at").notNull().defaultNow(),
29625
- updatedAt: timestamp98("updated_at").notNull().defaultNow()
29697
+ publicToken: text108("public_token"),
29698
+ createdBy: text108("created_by"),
29699
+ createdAt: timestamp100("created_at").notNull().defaultNow(),
29700
+ updatedAt: timestamp100("updated_at").notNull().defaultNow()
29626
29701
  },
29627
29702
  (t) => [
29628
- uniqueIndex48("branch_preview_shares_branch_idx").on(t.branchId),
29629
- uniqueIndex48("branch_preview_shares_active_token_idx").on(t.publicToken),
29630
- index92("branch_preview_shares_project_idx").on(t.projectId),
29631
- index92("branch_preview_shares_workspace_idx").on(t.workspaceId)
29703
+ uniqueIndex49("branch_preview_shares_branch_idx").on(t.branchId),
29704
+ uniqueIndex49("branch_preview_shares_active_token_idx").on(t.publicToken),
29705
+ index94("branch_preview_shares_project_idx").on(t.projectId),
29706
+ index94("branch_preview_shares_workspace_idx").on(t.workspaceId)
29632
29707
  ]
29633
29708
  );
29634
- var branchPreviewGrants = pgTable105(
29709
+ var branchPreviewGrants = pgTable107(
29635
29710
  "branch_preview_grants",
29636
29711
  {
29637
- id: text106("id").primaryKey(),
29638
- workspaceId: text106("workspace_id").notNull(),
29639
- projectId: text106("project_id").notNull(),
29640
- branchId: text106("branch_id").notNull(),
29641
- email: text106("email").notNull(),
29642
- invitedBy: text106("invited_by"),
29643
- createdAt: timestamp98("created_at").notNull().defaultNow()
29712
+ id: text108("id").primaryKey(),
29713
+ workspaceId: text108("workspace_id").notNull(),
29714
+ projectId: text108("project_id").notNull(),
29715
+ branchId: text108("branch_id").notNull(),
29716
+ email: text108("email").notNull(),
29717
+ invitedBy: text108("invited_by"),
29718
+ createdAt: timestamp100("created_at").notNull().defaultNow()
29644
29719
  },
29645
29720
  (t) => [
29646
- uniqueIndex48("branch_preview_grants_branch_email_idx").on(t.branchId, t.email),
29647
- index92("branch_preview_grants_project_idx").on(t.projectId)
29721
+ uniqueIndex49("branch_preview_grants_branch_email_idx").on(t.branchId, t.email),
29722
+ index94("branch_preview_grants_project_idx").on(t.projectId)
29648
29723
  ]
29649
29724
  );
29650
29725
 
29651
29726
  // src/schema/share_links.ts
29652
- import { pgTable as pgTable106, text as text107, boolean as boolean33, timestamp as timestamp99, index as index93 } from "drizzle-orm/pg-core";
29653
- var shareLinks = pgTable106(
29727
+ import { pgTable as pgTable108, text as text109, boolean as boolean33, timestamp as timestamp101, index as index95 } from "drizzle-orm/pg-core";
29728
+ var shareLinks = pgTable108(
29654
29729
  "share_links",
29655
29730
  {
29656
- id: text107("id").primaryKey(),
29731
+ id: text109("id").primaryKey(),
29657
29732
  // nanoid
29658
- workspaceId: text107("workspace_id").notNull(),
29733
+ workspaceId: text109("workspace_id").notNull(),
29659
29734
  // FK → workspaces.id (RLS scope)
29660
- projectId: text107("project_id").notNull(),
29735
+ projectId: text109("project_id").notNull(),
29661
29736
  // FK → projects.id
29662
- token: text107("token").notNull(),
29737
+ token: text109("token").notNull(),
29663
29738
  // public share token (nanoid); unique among active links
29664
29739
  enabled: boolean33("enabled").notNull().default(true),
29665
- createdBy: text107("created_by"),
29740
+ createdBy: text109("created_by"),
29666
29741
  // FK → users(id); NULL = system-initiated
29667
- createdAt: timestamp99("created_at").notNull().defaultNow(),
29668
- updatedAt: timestamp99("updated_at").notNull().defaultNow(),
29669
- revokedAt: timestamp99("revoked_at")
29742
+ createdAt: timestamp101("created_at").notNull().defaultNow(),
29743
+ updatedAt: timestamp101("updated_at").notNull().defaultNow(),
29744
+ revokedAt: timestamp101("revoked_at")
29670
29745
  // set when the link is disabled
29671
29746
  },
29672
29747
  (t) => [
29673
- index93("share_links_project_idx").on(t.projectId),
29674
- index93("share_links_workspace_idx").on(t.workspaceId)
29748
+ index95("share_links_project_idx").on(t.projectId),
29749
+ index95("share_links_workspace_idx").on(t.workspaceId)
29675
29750
  ]
29676
29751
  );
29677
29752
 
29678
29753
  // src/schema/templates.ts
29679
29754
  import {
29680
- pgTable as pgTable107,
29681
- text as text108,
29682
- varchar as varchar78,
29683
- timestamp as timestamp100,
29684
- jsonb as jsonb62,
29685
- integer as integer54,
29686
- index as index94,
29687
- uniqueIndex as uniqueIndex49
29755
+ pgTable as pgTable109,
29756
+ text as text110,
29757
+ varchar as varchar79,
29758
+ timestamp as timestamp102,
29759
+ jsonb as jsonb64,
29760
+ integer as integer55,
29761
+ index as index96,
29762
+ uniqueIndex as uniqueIndex50
29688
29763
  } from "drizzle-orm/pg-core";
29689
29764
  import { relations as relations17 } from "drizzle-orm/relations";
29690
- import { sql as sql33 } from "drizzle-orm";
29691
- var templates = pgTable107(
29765
+ import { sql as sql34 } from "drizzle-orm";
29766
+ var templates = pgTable109(
29692
29767
  "templates",
29693
29768
  {
29694
- id: text108("id").primaryKey(),
29769
+ id: text110("id").primaryKey(),
29695
29770
  // nanoid
29696
- workspaceId: text108("workspace_id").notNull(),
29771
+ workspaceId: text110("workspace_id").notNull(),
29697
29772
  // FK to workspaces.id (RLS scope / owner)
29698
- slug: varchar78("slug", { length: 255 }).notNull(),
29773
+ slug: varchar79("slug", { length: 255 }).notNull(),
29699
29774
  // ^[a-z0-9-]+$, unique per workspace
29700
- name: varchar78("name", { length: 255 }).notNull(),
29701
- description: text108("description"),
29702
- scope: varchar78("scope", { length: 10 }).$type().notNull().default("project"),
29775
+ name: varchar79("name", { length: 255 }).notNull(),
29776
+ description: text110("description"),
29777
+ scope: varchar79("scope", { length: 10 }).$type().notNull().default("project"),
29703
29778
  // 'demo' ships seed content; 'starter-kit' is the same schema with the content blanked.
29704
29779
  // Defaults to 'demo' because a user template is a frozen snapshot of a real project,
29705
29780
  // which always carries its source's content. Migration 0187.
29706
- category: varchar78("category", { length: 20 }).$type().notNull().default("demo"),
29707
- framework: varchar78("framework", { length: 20 }).$type(),
29781
+ category: varchar79("category", { length: 20 }).$type().notNull().default("demo"),
29782
+ framework: varchar79("framework", { length: 20 }).$type(),
29708
29783
  // metadata hint
29709
- thumbnail: varchar78("thumbnail", { length: 2048 }),
29784
+ thumbnail: varchar79("thumbnail", { length: 2048 }),
29710
29785
  // Frozen snapshot manifest (stripped snapshot_project output). Never returned in
29711
29786
  // list/gallery responses — only read server-side to instantiate.
29712
- manifest: jsonb62("manifest").$type().notNull(),
29713
- visibility: varchar78("visibility", { length: 10 }).$type().notNull().default("private"),
29714
- sourceProjectId: text108("source_project_id"),
29787
+ manifest: jsonb64("manifest").$type().notNull(),
29788
+ visibility: varchar79("visibility", { length: 10 }).$type().notNull().default("private"),
29789
+ sourceProjectId: text110("source_project_id"),
29715
29790
  // provenance (nullable — source may be deleted later)
29716
- createdBy: text108("created_by"),
29791
+ createdBy: text110("created_by"),
29717
29792
  // user id, or null for a management-key create
29718
- optimisticVersion: integer54("optimistic_version").notNull().default(0),
29719
- createdAt: timestamp100("created_at").notNull().defaultNow(),
29720
- updatedAt: timestamp100("updated_at").notNull().defaultNow(),
29721
- deletedAt: timestamp100("deleted_at")
29793
+ optimisticVersion: integer55("optimistic_version").notNull().default(0),
29794
+ createdAt: timestamp102("created_at").notNull().defaultNow(),
29795
+ updatedAt: timestamp102("updated_at").notNull().defaultNow(),
29796
+ deletedAt: timestamp102("deleted_at")
29722
29797
  // soft-delete
29723
29798
  },
29724
29799
  (table) => [
29725
- index94("templates_workspace_idx").on(table.workspaceId),
29800
+ index96("templates_workspace_idx").on(table.workspaceId),
29726
29801
  // Partial: only live rows. A soft-deleted template frees its slug (mirrors
29727
29802
  // components_ws_proj_slug_idx / migration 0114).
29728
- uniqueIndex49("templates_ws_slug_idx").on(table.workspaceId, table.slug).where(sql33`${table.deletedAt} IS NULL`),
29803
+ uniqueIndex50("templates_ws_slug_idx").on(table.workspaceId, table.slug).where(sql34`${table.deletedAt} IS NULL`),
29729
29804
  // Public gallery scan (created_at DESC over live public rows).
29730
- index94("templates_public_idx").on(table.visibility).where(sql33`${table.visibility} = 'public' AND ${table.deletedAt} IS NULL`)
29805
+ index96("templates_public_idx").on(table.visibility).where(sql34`${table.visibility} = 'public' AND ${table.deletedAt} IS NULL`)
29731
29806
  ]
29732
29807
  );
29733
29808
  var templatesRelations = relations17(templates, ({ one }) => ({
@@ -29739,179 +29814,179 @@ var templatesRelations = relations17(templates, ({ one }) => ({
29739
29814
 
29740
29815
  // src/schema/payment_records.ts
29741
29816
  import {
29742
- pgTable as pgTable108,
29743
- text as text109,
29744
- varchar as varchar79,
29745
- integer as integer55,
29746
- timestamp as timestamp101,
29747
- index as index95
29817
+ pgTable as pgTable110,
29818
+ text as text111,
29819
+ varchar as varchar80,
29820
+ integer as integer56,
29821
+ timestamp as timestamp103,
29822
+ index as index97
29748
29823
  } from "drizzle-orm/pg-core";
29749
- var paymentRecords = pgTable108(
29824
+ var paymentRecords = pgTable110(
29750
29825
  "payment_records",
29751
29826
  {
29752
- id: text109("id").primaryKey(),
29827
+ id: text111("id").primaryKey(),
29753
29828
  // nanoid
29754
- workspaceId: text109("workspace_id").notNull(),
29829
+ workspaceId: text111("workspace_id").notNull(),
29755
29830
  // FK → workspaces.id
29756
- amountCents: integer55("amount_cents").notNull(),
29831
+ amountCents: integer56("amount_cents").notNull(),
29757
29832
  // store money as integer cents
29758
- currency: varchar79("currency", { length: 3 }).notNull().default("usd"),
29759
- method: varchar79("method", { length: 50 }).notNull().default("manual"),
29833
+ currency: varchar80("currency", { length: 3 }).notNull().default("usd"),
29834
+ method: varchar80("method", { length: 50 }).notNull().default("manual"),
29760
29835
  // manual | stripe | wire | ...
29761
- note: text109("note"),
29762
- recordedBy: text109("recorded_by"),
29836
+ note: text111("note"),
29837
+ recordedBy: text111("recorded_by"),
29763
29838
  // FK → users.id (the admin who entered it)
29764
- createdAt: timestamp101("created_at").notNull().defaultNow()
29839
+ createdAt: timestamp103("created_at").notNull().defaultNow()
29765
29840
  },
29766
29841
  (table) => [
29767
- index95("payment_records_workspace_idx").on(table.workspaceId, table.createdAt)
29842
+ index97("payment_records_workspace_idx").on(table.workspaceId, table.createdAt)
29768
29843
  ]
29769
29844
  );
29770
29845
 
29771
29846
  // src/schema/plan_changes.ts
29772
29847
  import {
29773
- pgTable as pgTable109,
29774
- text as text110,
29775
- timestamp as timestamp102,
29776
- index as index96
29848
+ pgTable as pgTable111,
29849
+ text as text112,
29850
+ timestamp as timestamp104,
29851
+ index as index98
29777
29852
  } from "drizzle-orm/pg-core";
29778
- var planChanges = pgTable109(
29853
+ var planChanges = pgTable111(
29779
29854
  "plan_changes",
29780
29855
  {
29781
- id: text110("id").primaryKey(),
29856
+ id: text112("id").primaryKey(),
29782
29857
  // nanoid
29783
- workspaceId: text110("workspace_id").notNull(),
29858
+ workspaceId: text112("workspace_id").notNull(),
29784
29859
  // FK → workspaces.id
29785
- fromPlan: text110("from_plan"),
29860
+ fromPlan: text112("from_plan"),
29786
29861
  // plan_limits.id before the change (null if unknown)
29787
- toPlan: text110("to_plan").notNull(),
29862
+ toPlan: text112("to_plan").notNull(),
29788
29863
  // plan_limits.id after the change
29789
- reason: text110("reason"),
29790
- changedBy: text110("changed_by"),
29864
+ reason: text112("reason"),
29865
+ changedBy: text112("changed_by"),
29791
29866
  // FK → users.id (the admin)
29792
- createdAt: timestamp102("created_at").notNull().defaultNow()
29867
+ createdAt: timestamp104("created_at").notNull().defaultNow()
29793
29868
  },
29794
29869
  (table) => [
29795
- index96("plan_changes_workspace_idx").on(table.workspaceId, table.createdAt)
29870
+ index98("plan_changes_workspace_idx").on(table.workspaceId, table.createdAt)
29796
29871
  ]
29797
29872
  );
29798
29873
 
29799
29874
  // src/schema/billing_addons.ts
29800
- import { pgTable as pgTable110, text as text111, varchar as varchar80, integer as integer56, boolean as boolean34, jsonb as jsonb63, index as index97 } from "drizzle-orm/pg-core";
29801
- var billingAddons = pgTable110(
29875
+ import { pgTable as pgTable112, text as text113, varchar as varchar81, integer as integer57, boolean as boolean34, jsonb as jsonb65, index as index99 } from "drizzle-orm/pg-core";
29876
+ var billingAddons = pgTable112(
29802
29877
  "billing_addons",
29803
29878
  {
29804
- id: text111("id").primaryKey(),
29879
+ id: text113("id").primaryKey(),
29805
29880
  // stable slug, e.g. "developer", "ai-1000", "localization"
29806
- kind: varchar80("kind", { length: 20 }).notNull(),
29881
+ kind: varchar81("kind", { length: 20 }).notNull(),
29807
29882
  // seat_role | ai_credits | localization | ab_testing
29808
- name: varchar80("name", { length: 100 }).notNull(),
29809
- dodoProductId: text111("dodo_product_id"),
29883
+ name: varchar81("name", { length: 100 }).notNull(),
29884
+ dodoProductId: text113("dodo_product_id"),
29810
29885
  // NULL until the Dodo product is created
29811
- unitPriceCents: integer56("unit_price_cents").notNull(),
29812
- currency: varchar80("currency", { length: 8 }).notNull().default("usd"),
29813
- credits: integer56("credits"),
29886
+ unitPriceCents: integer57("unit_price_cents").notNull(),
29887
+ currency: varchar81("currency", { length: 8 }).notNull().default("usd"),
29888
+ credits: integer57("credits"),
29814
29889
  // ai_credits packs only: credits granted per unit
29815
29890
  recurring: boolean34("recurring").notNull().default(false),
29816
29891
  // seats/localization/AB = true; credit packs = false
29817
- metadata: jsonb63("metadata").$type().default({})
29892
+ metadata: jsonb65("metadata").$type().default({})
29818
29893
  },
29819
- (t) => [index97("billing_addons_kind_idx").on(t.kind)]
29894
+ (t) => [index99("billing_addons_kind_idx").on(t.kind)]
29820
29895
  );
29821
29896
 
29822
29897
  // src/schema/billing_customers.ts
29823
- import { pgTable as pgTable111, text as text112, varchar as varchar81, timestamp as timestamp103, uniqueIndex as uniqueIndex50 } from "drizzle-orm/pg-core";
29824
- var billingCustomers = pgTable111(
29898
+ import { pgTable as pgTable113, text as text114, varchar as varchar82, timestamp as timestamp105, uniqueIndex as uniqueIndex51 } from "drizzle-orm/pg-core";
29899
+ var billingCustomers = pgTable113(
29825
29900
  "billing_customers",
29826
29901
  {
29827
- id: text112("id").primaryKey(),
29902
+ id: text114("id").primaryKey(),
29828
29903
  // nanoid
29829
- workspaceId: text112("workspace_id").notNull(),
29904
+ workspaceId: text114("workspace_id").notNull(),
29830
29905
  // FK → workspaces.id (RLS scope)
29831
- dodoCustomerId: text112("dodo_customer_id").notNull(),
29832
- email: varchar81("email", { length: 255 }),
29833
- createdAt: timestamp103("created_at").notNull().defaultNow(),
29834
- updatedAt: timestamp103("updated_at").notNull().defaultNow()
29906
+ dodoCustomerId: text114("dodo_customer_id").notNull(),
29907
+ email: varchar82("email", { length: 255 }),
29908
+ createdAt: timestamp105("created_at").notNull().defaultNow(),
29909
+ updatedAt: timestamp105("updated_at").notNull().defaultNow()
29835
29910
  },
29836
29911
  (t) => [
29837
- uniqueIndex50("billing_customers_workspace_idx").on(t.workspaceId),
29838
- uniqueIndex50("billing_customers_dodo_idx").on(t.dodoCustomerId)
29912
+ uniqueIndex51("billing_customers_workspace_idx").on(t.workspaceId),
29913
+ uniqueIndex51("billing_customers_dodo_idx").on(t.dodoCustomerId)
29839
29914
  ]
29840
29915
  );
29841
29916
 
29842
29917
  // src/schema/subscriptions.ts
29843
- import { pgTable as pgTable112, text as text113, varchar as varchar82, boolean as boolean35, timestamp as timestamp104, index as index98, uniqueIndex as uniqueIndex51 } from "drizzle-orm/pg-core";
29844
- import { sql as sql34 } from "drizzle-orm";
29845
- var subscriptions = pgTable112(
29918
+ import { pgTable as pgTable114, text as text115, varchar as varchar83, boolean as boolean35, timestamp as timestamp106, index as index100, uniqueIndex as uniqueIndex52 } from "drizzle-orm/pg-core";
29919
+ import { sql as sql35 } from "drizzle-orm";
29920
+ var subscriptions = pgTable114(
29846
29921
  "subscriptions",
29847
29922
  {
29848
- id: text113("id").primaryKey(),
29923
+ id: text115("id").primaryKey(),
29849
29924
  // nanoid
29850
- workspaceId: text113("workspace_id").notNull(),
29925
+ workspaceId: text115("workspace_id").notNull(),
29851
29926
  // FK → workspaces.id (RLS scope)
29852
- projectId: text113("project_id"),
29927
+ projectId: text115("project_id"),
29853
29928
  // NULL = workspace plan; set = site plan (FK → projects.id)
29854
- planId: text113("plan_id").notNull(),
29929
+ planId: text115("plan_id").notNull(),
29855
29930
  // FK → plan_limits.id
29856
- dodoSubscriptionId: text113("dodo_subscription_id"),
29857
- dodoCustomerId: text113("dodo_customer_id"),
29858
- status: varchar82("status", { length: 20 }).notNull().default("active"),
29931
+ dodoSubscriptionId: text115("dodo_subscription_id"),
29932
+ dodoCustomerId: text115("dodo_customer_id"),
29933
+ status: varchar83("status", { length: 20 }).notNull().default("active"),
29859
29934
  // active | on_hold | cancelled | expired | pending
29860
29935
  // Which of plan_limits' two prices this row is billed at. Without it the bill cannot tell
29861
29936
  // whether the owner pays price_cents or price_cents_yearly (0147).
29862
- interval: varchar82("interval", { length: 10 }).notNull().default("month"),
29937
+ interval: varchar83("interval", { length: 10 }).notNull().default("month"),
29863
29938
  // month | year
29864
- currentPeriodEnd: timestamp104("current_period_end"),
29939
+ currentPeriodEnd: timestamp106("current_period_end"),
29865
29940
  cancelAtPeriodEnd: boolean35("cancel_at_period_end").notNull().default(false),
29866
- createdAt: timestamp104("created_at").notNull().defaultNow(),
29867
- updatedAt: timestamp104("updated_at").notNull().defaultNow()
29941
+ createdAt: timestamp106("created_at").notNull().defaultNow(),
29942
+ updatedAt: timestamp106("updated_at").notNull().defaultNow()
29868
29943
  },
29869
29944
  (t) => [
29870
- index98("subscriptions_workspace_idx").on(t.workspaceId),
29871
- uniqueIndex51("subscriptions_dodo_idx").on(t.dodoSubscriptionId).where(sql34`${t.dodoSubscriptionId} IS NOT NULL`),
29945
+ index100("subscriptions_workspace_idx").on(t.workspaceId),
29946
+ uniqueIndex52("subscriptions_dodo_idx").on(t.dodoSubscriptionId).where(sql35`${t.dodoSubscriptionId} IS NOT NULL`),
29872
29947
  // At most one workspace-level subscription per workspace.
29873
- uniqueIndex51("subscriptions_workspace_plan_unique").on(t.workspaceId).where(sql34`${t.projectId} IS NULL`),
29948
+ uniqueIndex52("subscriptions_workspace_plan_unique").on(t.workspaceId).where(sql35`${t.projectId} IS NULL`),
29874
29949
  // At most one subscription per site.
29875
- uniqueIndex51("subscriptions_project_unique").on(t.projectId).where(sql34`${t.projectId} IS NOT NULL`)
29950
+ uniqueIndex52("subscriptions_project_unique").on(t.projectId).where(sql35`${t.projectId} IS NOT NULL`)
29876
29951
  ]
29877
29952
  );
29878
29953
 
29879
29954
  // src/schema/subscription_addons.ts
29880
- import { pgTable as pgTable113, text as text114, varchar as varchar83, integer as integer57, timestamp as timestamp105, index as index99, uniqueIndex as uniqueIndex52 } from "drizzle-orm/pg-core";
29881
- import { sql as sql35 } from "drizzle-orm";
29882
- var subscriptionAddons = pgTable113(
29955
+ import { pgTable as pgTable115, text as text116, varchar as varchar84, integer as integer58, timestamp as timestamp107, index as index101, uniqueIndex as uniqueIndex53 } from "drizzle-orm/pg-core";
29956
+ import { sql as sql36 } from "drizzle-orm";
29957
+ var subscriptionAddons = pgTable115(
29883
29958
  "subscription_addons",
29884
29959
  {
29885
- id: text114("id").primaryKey(),
29960
+ id: text116("id").primaryKey(),
29886
29961
  // nanoid
29887
- workspaceId: text114("workspace_id").notNull(),
29962
+ workspaceId: text116("workspace_id").notNull(),
29888
29963
  // FK → workspaces.id (RLS scope)
29889
- addonId: text114("addon_id").notNull(),
29964
+ addonId: text116("addon_id").notNull(),
29890
29965
  // FK → billing_addons.id
29891
- quantity: integer57("quantity").notNull().default(1),
29892
- dodoSubscriptionId: text114("dodo_subscription_id"),
29966
+ quantity: integer58("quantity").notNull().default(1),
29967
+ dodoSubscriptionId: text116("dodo_subscription_id"),
29893
29968
  // NULL for a manual/admin grant
29894
- status: varchar83("status", { length: 20 }).notNull().default("active"),
29969
+ status: varchar84("status", { length: 20 }).notNull().default("active"),
29895
29970
  // active | cancelled | expired
29896
- createdAt: timestamp105("created_at").notNull().defaultNow(),
29897
- updatedAt: timestamp105("updated_at").notNull().defaultNow()
29971
+ createdAt: timestamp107("created_at").notNull().defaultNow(),
29972
+ updatedAt: timestamp107("updated_at").notNull().defaultNow()
29898
29973
  },
29899
29974
  (t) => [
29900
- index99("subscription_addons_workspace_idx").on(t.workspaceId),
29901
- uniqueIndex52("subscription_addons_dodo_idx").on(t.dodoSubscriptionId).where(sql35`${t.dodoSubscriptionId} IS NOT NULL`)
29975
+ index101("subscription_addons_workspace_idx").on(t.workspaceId),
29976
+ uniqueIndex53("subscription_addons_dodo_idx").on(t.dodoSubscriptionId).where(sql36`${t.dodoSubscriptionId} IS NOT NULL`)
29902
29977
  ]
29903
29978
  );
29904
29979
 
29905
29980
  // src/schema/billing_alerts.ts
29906
- import { pgTable as pgTable114, text as text115, varchar as varchar84, timestamp as timestamp106, index as index100, uniqueIndex as uniqueIndex53 } from "drizzle-orm/pg-core";
29907
- var billingAlerts = pgTable114(
29981
+ import { pgTable as pgTable116, text as text117, varchar as varchar85, timestamp as timestamp108, index as index102, uniqueIndex as uniqueIndex54 } from "drizzle-orm/pg-core";
29982
+ var billingAlerts = pgTable116(
29908
29983
  "billing_alerts",
29909
29984
  {
29910
- id: text115("id").primaryKey(),
29985
+ id: text117("id").primaryKey(),
29911
29986
  // nanoid
29912
- workspaceId: text115("workspace_id").notNull(),
29987
+ workspaceId: text117("workspace_id").notNull(),
29913
29988
  // FK → workspaces.id (internal table, no RLS)
29914
- kind: varchar84("kind", { length: 32 }).notNull(),
29989
+ kind: varchar85("kind", { length: 32 }).notNull(),
29915
29990
  // renewal_due | bandwidth_80 | bandwidth_100
29916
29991
  /**
29917
29992
  * What "already sent" means for this alert, built by the caller (alerts.ts owns the spellings).
@@ -29919,104 +29994,104 @@ var billingAlerts = pgTable114(
29919
29994
  * period-end change. Bandwidth keys on the threshold + calendar month, matching the window
29920
29995
  * getUsage() measures — so the counter resetting on the 1st re-arms the alert.
29921
29996
  */
29922
- dedupeKey: text115("dedupe_key").notNull(),
29923
- sentAt: timestamp106("sent_at", { withTimezone: true }).notNull().defaultNow()
29997
+ dedupeKey: text117("dedupe_key").notNull(),
29998
+ sentAt: timestamp108("sent_at", { withTimezone: true }).notNull().defaultNow()
29924
29999
  },
29925
30000
  (t) => [
29926
- uniqueIndex53("billing_alerts_dedupe_idx").on(t.dedupeKey),
29927
- index100("billing_alerts_workspace_idx").on(t.workspaceId, t.sentAt)
30001
+ uniqueIndex54("billing_alerts_dedupe_idx").on(t.dedupeKey),
30002
+ index102("billing_alerts_workspace_idx").on(t.workspaceId, t.sentAt)
29928
30003
  ]
29929
30004
  );
29930
30005
 
29931
30006
  // src/schema/ai_credit_ledger.ts
29932
- import { pgTable as pgTable115, text as text116, varchar as varchar85, integer as integer58, timestamp as timestamp107, index as index101, uniqueIndex as uniqueIndex54 } from "drizzle-orm/pg-core";
29933
- import { sql as sql36 } from "drizzle-orm";
29934
- var aiCreditLedger = pgTable115(
30007
+ import { pgTable as pgTable117, text as text118, varchar as varchar86, integer as integer59, timestamp as timestamp109, index as index103, uniqueIndex as uniqueIndex55 } from "drizzle-orm/pg-core";
30008
+ import { sql as sql37 } from "drizzle-orm";
30009
+ var aiCreditLedger = pgTable117(
29935
30010
  "ai_credit_ledger",
29936
30011
  {
29937
- id: text116("id").primaryKey(),
30012
+ id: text118("id").primaryKey(),
29938
30013
  // nanoid
29939
- workspaceId: text116("workspace_id").notNull(),
30014
+ workspaceId: text118("workspace_id").notNull(),
29940
30015
  // FK → workspaces.id (RLS scope)
29941
- delta: integer58("delta").notNull(),
30016
+ delta: integer59("delta").notNull(),
29942
30017
  // signed: +purchase/grant, -consume/expire
29943
- reason: varchar85("reason", { length: 20 }).notNull(),
30018
+ reason: varchar86("reason", { length: 20 }).notNull(),
29944
30019
  // purchase | consume | grant | expire
29945
- dodoPaymentId: text116("dodo_payment_id"),
30020
+ dodoPaymentId: text118("dodo_payment_id"),
29946
30021
  // set for purchases
29947
- note: text116("note"),
29948
- createdAt: timestamp107("created_at").notNull().defaultNow()
30022
+ note: text118("note"),
30023
+ createdAt: timestamp109("created_at").notNull().defaultNow()
29949
30024
  },
29950
30025
  (t) => [
29951
- index101("ai_credit_ledger_workspace_idx").on(t.workspaceId, t.createdAt),
29952
- uniqueIndex54("ai_credit_ledger_custom_agent_run_unique").on(t.note).where(sql36`${t.reason} = 'consume' AND ${t.note} LIKE 'custom-agent-run:%'`)
30026
+ index103("ai_credit_ledger_workspace_idx").on(t.workspaceId, t.createdAt),
30027
+ uniqueIndex55("ai_credit_ledger_custom_agent_run_unique").on(t.note).where(sql37`${t.reason} = 'consume' AND ${t.note} LIKE 'custom-agent-run:%'`)
29953
30028
  ]
29954
30029
  );
29955
30030
 
29956
30031
  // src/schema/support_tickets.ts
29957
30032
  import {
29958
- pgTable as pgTable116,
29959
- text as text117,
29960
- varchar as varchar86,
29961
- timestamp as timestamp108,
30033
+ pgTable as pgTable118,
30034
+ text as text119,
30035
+ varchar as varchar87,
30036
+ timestamp as timestamp110,
29962
30037
  boolean as boolean36,
29963
- jsonb as jsonb64,
29964
- index as index102
30038
+ jsonb as jsonb66,
30039
+ index as index104
29965
30040
  } from "drizzle-orm/pg-core";
29966
- var supportTickets = pgTable116(
30041
+ var supportTickets = pgTable118(
29967
30042
  "support_tickets",
29968
30043
  {
29969
- id: text117("id").primaryKey(),
30044
+ id: text119("id").primaryKey(),
29970
30045
  // nanoid
29971
- workspaceId: text117("workspace_id"),
30046
+ workspaceId: text119("workspace_id"),
29972
30047
  // FK → workspaces.id (nullable: account-level tickets)
29973
30048
  // FK → users.id (the customer). NULL for a ticket Plain created: an email or Slack
29974
30049
  // sender has no BetterCMS account. visibleTicketWhere() compares this to the session
29975
30050
  // user, and NULL never matches, so those tickets stay invisible to every customer —
29976
30051
  // which is correct, since there is no dashboard reply transport for them.
29977
- userId: text117("user_id"),
30052
+ userId: text119("user_id"),
29978
30053
  // The only identity a Plain-origin ticket has. The staff list coalesces it with
29979
30054
  // users.email; NULL whenever userId is set.
29980
- customerEmail: text117("customer_email"),
29981
- customerName: text117("customer_name"),
29982
- subject: varchar86("subject", { length: 255 }).notNull(),
29983
- body: text117("body").notNull(),
29984
- status: varchar86("status", { length: 20 }).notNull().default("open"),
30055
+ customerEmail: text119("customer_email"),
30056
+ customerName: text119("customer_name"),
30057
+ subject: varchar87("subject", { length: 255 }).notNull(),
30058
+ body: text119("body").notNull(),
30059
+ status: varchar87("status", { length: 20 }).notNull().default("open"),
29985
30060
  // open | pending | closed
29986
- priority: varchar86("priority", { length: 20 }).notNull().default("normal"),
30061
+ priority: varchar87("priority", { length: 20 }).notNull().default("normal"),
29987
30062
  // low | normal | high | urgent
29988
- assigneeId: text117("assignee_id"),
30063
+ assigneeId: text119("assignee_id"),
29989
30064
  // FK → users.id (staff member handling it)
29990
30065
  // Plain's ThreadChannel, lowercased. 'api' is a ticket opened in the dashboard; the
29991
30066
  // rest arrive from Plain. The staff reply path branches on this: 'api' threads deliver
29992
30067
  // nothing to the customer so we send the email ourselves, every other channel is
29993
30068
  // delivered by Plain.
29994
- channel: text117("channel").notNull().default("api"),
30069
+ channel: text119("channel").notNull().default("api"),
29995
30070
  // The Plain thread this ticket mirrors. NULL until the first outbound sync succeeds,
29996
30071
  // hence the partial unique index rather than a unique column.
29997
- plainThreadId: text117("plain_thread_id"),
30072
+ plainThreadId: text119("plain_thread_id"),
29998
30073
  // Files attached when the case was opened, before any message row exists.
29999
- attachments: jsonb64("attachments").$type().notNull().default([]),
30000
- createdAt: timestamp108("created_at").notNull().defaultNow(),
30001
- updatedAt: timestamp108("updated_at").notNull().defaultNow()
30074
+ attachments: jsonb66("attachments").$type().notNull().default([]),
30075
+ createdAt: timestamp110("created_at").notNull().defaultNow(),
30076
+ updatedAt: timestamp110("updated_at").notNull().defaultNow()
30002
30077
  },
30003
30078
  (table) => [
30004
- index102("support_tickets_status_idx").on(table.status, table.updatedAt),
30005
- index102("support_tickets_workspace_idx").on(table.workspaceId),
30006
- index102("support_tickets_user_idx").on(table.userId),
30007
- index102("support_tickets_channel_idx").on(table.channel, table.updatedAt)
30079
+ index104("support_tickets_status_idx").on(table.status, table.updatedAt),
30080
+ index104("support_tickets_workspace_idx").on(table.workspaceId),
30081
+ index104("support_tickets_user_idx").on(table.userId),
30082
+ index104("support_tickets_channel_idx").on(table.channel, table.updatedAt)
30008
30083
  ]
30009
30084
  );
30010
- var supportTicketMessages = pgTable116(
30085
+ var supportTicketMessages = pgTable118(
30011
30086
  "support_ticket_messages",
30012
30087
  {
30013
- id: text117("id").primaryKey(),
30088
+ id: text119("id").primaryKey(),
30014
30089
  // nanoid
30015
- ticketId: text117("ticket_id").notNull(),
30090
+ ticketId: text119("ticket_id").notNull(),
30016
30091
  // FK → support_tickets.id
30017
- authorId: text117("author_id"),
30092
+ authorId: text119("author_id"),
30018
30093
  // FK → users.id (staff or customer)
30019
- body: text117("body").notNull(),
30094
+ body: text119("body").notNull(),
30020
30095
  isStaff: boolean36("is_staff").notNull().default(false),
30021
30096
  // true = team reply
30022
30097
  // Staff-only triage note. NEVER leaves the platform-admin lane: the customer read
@@ -30026,99 +30101,99 @@ var supportTicketMessages = pgTable116(
30026
30101
  // at-least-once webhook. NULL for anything Plain never saw, and for our own replies on
30027
30102
  // channels whose mutation returns no entry id — replyToThread returns only an error
30028
30103
  // slot, which is why the echo check keys on the actor and this is the backstop.
30029
- plainMessageId: text117("plain_message_id"),
30030
- attachments: jsonb64("attachments").$type().notNull().default([]),
30031
- createdAt: timestamp108("created_at").notNull().defaultNow()
30104
+ plainMessageId: text119("plain_message_id"),
30105
+ attachments: jsonb66("attachments").$type().notNull().default([]),
30106
+ createdAt: timestamp110("created_at").notNull().defaultNow()
30032
30107
  },
30033
30108
  (table) => [
30034
- index102("support_ticket_messages_ticket_idx").on(table.ticketId, table.createdAt)
30109
+ index104("support_ticket_messages_ticket_idx").on(table.ticketId, table.createdAt)
30035
30110
  ]
30036
30111
  );
30037
30112
 
30038
30113
  // src/schema/admin_action_logs.ts
30039
30114
  import {
30040
- pgTable as pgTable117,
30041
- text as text118,
30042
- varchar as varchar87,
30043
- jsonb as jsonb65,
30044
- timestamp as timestamp109,
30045
- index as index103
30115
+ pgTable as pgTable119,
30116
+ text as text120,
30117
+ varchar as varchar88,
30118
+ jsonb as jsonb67,
30119
+ timestamp as timestamp111,
30120
+ index as index105
30046
30121
  } from "drizzle-orm/pg-core";
30047
- var adminActionLogs = pgTable117(
30122
+ var adminActionLogs = pgTable119(
30048
30123
  "admin_action_logs",
30049
30124
  {
30050
- id: text118("id").primaryKey(),
30125
+ id: text120("id").primaryKey(),
30051
30126
  // nanoid
30052
- actorId: text118("actor_id"),
30127
+ actorId: text120("actor_id"),
30053
30128
  // FK → users.id (the staff member)
30054
- actorEmail: varchar87("actor_email", { length: 320 }),
30129
+ actorEmail: varchar88("actor_email", { length: 320 }),
30055
30130
  // denormalized for display
30056
- actorRole: varchar87("actor_role", { length: 40 }),
30131
+ actorRole: varchar88("actor_role", { length: 40 }),
30057
30132
  // admin_role at action time
30058
- action: varchar87("action", { length: 80 }).notNull(),
30133
+ action: varchar88("action", { length: 80 }).notNull(),
30059
30134
  // e.g. workspace.plan_change
30060
- targetType: varchar87("target_type", { length: 40 }),
30135
+ targetType: varchar88("target_type", { length: 40 }),
30061
30136
  // workspace | user | plan | ticket
30062
- targetId: text118("target_id"),
30063
- reason: text118("reason"),
30064
- metadata: jsonb65("metadata").$type().notNull().default({}),
30065
- ipAddress: text118("ip_address"),
30066
- createdAt: timestamp109("created_at").notNull().defaultNow()
30137
+ targetId: text120("target_id"),
30138
+ reason: text120("reason"),
30139
+ metadata: jsonb67("metadata").$type().notNull().default({}),
30140
+ ipAddress: text120("ip_address"),
30141
+ createdAt: timestamp111("created_at").notNull().defaultNow()
30067
30142
  },
30068
30143
  (table) => [
30069
- index103("admin_action_logs_created_idx").on(table.createdAt),
30070
- index103("admin_action_logs_action_idx").on(table.action, table.createdAt)
30144
+ index105("admin_action_logs_created_idx").on(table.createdAt),
30145
+ index105("admin_action_logs_action_idx").on(table.action, table.createdAt)
30071
30146
  ]
30072
30147
  );
30073
30148
 
30074
30149
  // src/schema/admin_notes.ts
30075
- import { pgTable as pgTable118, text as text119, varchar as varchar88, boolean as boolean37, timestamp as timestamp110, index as index104 } from "drizzle-orm/pg-core";
30076
- var adminNotes = pgTable118(
30150
+ import { pgTable as pgTable120, text as text121, varchar as varchar89, boolean as boolean37, timestamp as timestamp112, index as index106 } from "drizzle-orm/pg-core";
30151
+ var adminNotes = pgTable120(
30077
30152
  "admin_notes",
30078
30153
  {
30079
- id: text119("id").primaryKey(),
30154
+ id: text121("id").primaryKey(),
30080
30155
  // nanoid
30081
- targetType: varchar88("target_type", { length: 20 }).notNull(),
30156
+ targetType: varchar89("target_type", { length: 20 }).notNull(),
30082
30157
  // user | workspace | project
30083
- targetId: text119("target_id").notNull(),
30084
- body: text119("body").notNull(),
30085
- authorId: text119("author_id"),
30158
+ targetId: text121("target_id").notNull(),
30159
+ body: text121("body").notNull(),
30160
+ authorId: text121("author_id"),
30086
30161
  // FK → users.id (the staff member)
30087
- authorEmail: varchar88("author_email", { length: 320 }),
30162
+ authorEmail: varchar89("author_email", { length: 320 }),
30088
30163
  // denormalized for display
30089
30164
  pinned: boolean37("pinned").notNull().default(false),
30090
- createdAt: timestamp110("created_at").notNull().defaultNow(),
30091
- updatedAt: timestamp110("updated_at").notNull().defaultNow()
30165
+ createdAt: timestamp112("created_at").notNull().defaultNow(),
30166
+ updatedAt: timestamp112("updated_at").notNull().defaultNow()
30092
30167
  },
30093
30168
  (t) => [
30094
30169
  // Pinned first, then newest — the exact order the tab renders.
30095
- index104("admin_notes_target_idx").on(t.targetType, t.targetId, t.pinned, t.createdAt)
30170
+ index106("admin_notes_target_idx").on(t.targetType, t.targetId, t.pinned, t.createdAt)
30096
30171
  ]
30097
30172
  );
30098
30173
 
30099
30174
  // src/schema/admin_agent_sessions.ts
30100
- import { pgTable as pgTable119, text as text120, varchar as varchar89, doublePrecision as doublePrecision2, timestamp as timestamp111, index as index105 } from "drizzle-orm/pg-core";
30101
- var adminAgentSessions = pgTable119(
30175
+ import { pgTable as pgTable121, text as text122, varchar as varchar90, doublePrecision as doublePrecision2, timestamp as timestamp113, index as index107 } from "drizzle-orm/pg-core";
30176
+ var adminAgentSessions = pgTable121(
30102
30177
  "admin_agent_sessions",
30103
30178
  {
30104
- id: text120("id").primaryKey(),
30179
+ id: text122("id").primaryKey(),
30105
30180
  // nanoid
30106
- actorId: text120("actor_id").notNull(),
30181
+ actorId: text122("actor_id").notNull(),
30107
30182
  // FK → users.id (the staff member)
30108
- actorEmail: varchar89("actor_email", { length: 320 }),
30109
- title: varchar89("title", { length: 200 }),
30110
- status: varchar89("status", { length: 20 }).notNull().default("active"),
30183
+ actorEmail: varchar90("actor_email", { length: 320 }),
30184
+ title: varchar90("title", { length: 200 }),
30185
+ status: varchar90("status", { length: 20 }).notNull().default("active"),
30111
30186
  // active | error
30112
30187
  costUsd: doublePrecision2("cost_usd").notNull().default(0),
30113
- createdAt: timestamp111("created_at").notNull().defaultNow(),
30114
- updatedAt: timestamp111("updated_at").notNull().defaultNow(),
30115
- lastActiveAt: timestamp111("last_active_at").notNull().defaultNow()
30188
+ createdAt: timestamp113("created_at").notNull().defaultNow(),
30189
+ updatedAt: timestamp113("updated_at").notNull().defaultNow(),
30190
+ lastActiveAt: timestamp113("last_active_at").notNull().defaultNow()
30116
30191
  },
30117
- (t) => [index105("admin_agent_sessions_actor_idx").on(t.actorId, t.lastActiveAt)]
30192
+ (t) => [index107("admin_agent_sessions_actor_idx").on(t.actorId, t.lastActiveAt)]
30118
30193
  );
30119
30194
 
30120
30195
  // src/schema/crm_deals.ts
30121
- import { pgTable as pgTable120, text as text121, varchar as varchar90, integer as integer59, timestamp as timestamp112, index as index106, unique as unique13 } from "drizzle-orm/pg-core";
30196
+ import { pgTable as pgTable122, text as text123, varchar as varchar91, integer as integer60, timestamp as timestamp114, index as index108, unique as unique13 } from "drizzle-orm/pg-core";
30122
30197
  var CRM_STAGES = [
30123
30198
  "qualified",
30124
30199
  "conversation",
@@ -30126,206 +30201,206 @@ var CRM_STAGES = [
30126
30201
  "customer",
30127
30202
  "at_risk"
30128
30203
  ];
30129
- var crmDeals = pgTable120(
30204
+ var crmDeals = pgTable122(
30130
30205
  "crm_deals",
30131
30206
  {
30132
- id: text121("id").primaryKey(),
30207
+ id: text123("id").primaryKey(),
30133
30208
  // nanoid
30134
- workspaceId: text121("workspace_id").notNull(),
30209
+ workspaceId: text123("workspace_id").notNull(),
30135
30210
  // FK → workspaces.id
30136
- stage: varchar90("stage", { length: 20 }).notNull().default("qualified").$type(),
30137
- valueCents: integer59("value_cents"),
30211
+ stage: varchar91("stage", { length: 20 }).notNull().default("qualified").$type(),
30212
+ valueCents: integer60("value_cents"),
30138
30213
  // annual contract value the rep is working toward
30139
- ownerId: text121("owner_id"),
30214
+ ownerId: text123("owner_id"),
30140
30215
  // FK → users.id (the staff member on the account)
30141
- nextStep: text121("next_step"),
30142
- notes: text121("notes"),
30143
- lastTouchAt: timestamp112("last_touch_at"),
30144
- createdAt: timestamp112("created_at").notNull().defaultNow(),
30145
- updatedAt: timestamp112("updated_at").notNull().defaultNow()
30216
+ nextStep: text123("next_step"),
30217
+ notes: text123("notes"),
30218
+ lastTouchAt: timestamp114("last_touch_at"),
30219
+ createdAt: timestamp114("created_at").notNull().defaultNow(),
30220
+ updatedAt: timestamp114("updated_at").notNull().defaultNow()
30146
30221
  },
30147
30222
  (t) => [
30148
30223
  unique13("crm_deals_workspace_id_key").on(t.workspaceId),
30149
- index106("crm_deals_stage_idx").on(t.stage, t.lastTouchAt),
30150
- index106("crm_deals_owner_idx").on(t.ownerId)
30224
+ index108("crm_deals_stage_idx").on(t.stage, t.lastTouchAt),
30225
+ index108("crm_deals_owner_idx").on(t.ownerId)
30151
30226
  ]
30152
30227
  );
30153
30228
 
30154
30229
  // src/schema/project_env_vars.ts
30155
30230
  import {
30156
- pgTable as pgTable121,
30157
- text as text122,
30158
- varchar as varchar91,
30159
- timestamp as timestamp113,
30160
- index as index107,
30161
- uniqueIndex as uniqueIndex55
30231
+ pgTable as pgTable123,
30232
+ text as text124,
30233
+ varchar as varchar92,
30234
+ timestamp as timestamp115,
30235
+ index as index109,
30236
+ uniqueIndex as uniqueIndex56
30162
30237
  } from "drizzle-orm/pg-core";
30163
30238
  var ENV_VAR_SCOPES = ["production", "preview", "development"];
30164
- var projectEnvVars = pgTable121(
30239
+ var projectEnvVars = pgTable123(
30165
30240
  "project_env_vars",
30166
30241
  {
30167
- id: text122("id").primaryKey(),
30242
+ id: text124("id").primaryKey(),
30168
30243
  // nanoid
30169
- projectId: text122("project_id").notNull(),
30244
+ projectId: text124("project_id").notNull(),
30170
30245
  // FK to projects.id
30171
- workspaceId: text122("workspace_id").notNull(),
30246
+ workspaceId: text124("workspace_id").notNull(),
30172
30247
  // FK to workspaces.id — RLS scope
30173
- key: varchar91("key", { length: 128 }).notNull(),
30174
- valueEnc: text122("value_enc").notNull(),
30248
+ key: varchar92("key", { length: 128 }).notNull(),
30249
+ valueEnc: text124("value_enc").notNull(),
30175
30250
  // AES-256-GCM, `iv:tag:ciphertext` hex
30176
- scope: varchar91("scope", { length: 16 }).$type().notNull(),
30177
- updatedBy: text122("updated_by"),
30251
+ scope: varchar92("scope", { length: 16 }).$type().notNull(),
30252
+ updatedBy: text124("updated_by"),
30178
30253
  // FK to users.id, nullable
30179
- updatedAt: timestamp113("updated_at", { withTimezone: true }).notNull().defaultNow(),
30180
- createdAt: timestamp113("created_at", { withTimezone: true }).notNull().defaultNow()
30254
+ updatedAt: timestamp115("updated_at", { withTimezone: true }).notNull().defaultNow(),
30255
+ createdAt: timestamp115("created_at", { withTimezone: true }).notNull().defaultNow()
30181
30256
  },
30182
30257
  (table) => [
30183
30258
  // One value per key per scope — the same key MAY exist in production and preview.
30184
- uniqueIndex55("project_env_vars_project_key_scope_idx").on(
30259
+ uniqueIndex56("project_env_vars_project_key_scope_idx").on(
30185
30260
  table.projectId,
30186
30261
  table.key,
30187
30262
  table.scope
30188
30263
  ),
30189
- index107("project_env_vars_project_idx").on(table.projectId)
30264
+ index109("project_env_vars_project_idx").on(table.projectId)
30190
30265
  ]
30191
30266
  );
30192
30267
 
30193
30268
  // src/schema/mcp_connections.ts
30194
- import { pgTable as pgTable122, text as text123, varchar as varchar92, jsonb as jsonb66, timestamp as timestamp114, index as index108, uniqueIndex as uniqueIndex56 } from "drizzle-orm/pg-core";
30195
- import { sql as sql37 } from "drizzle-orm";
30196
- var mcpConnections = pgTable122(
30269
+ import { pgTable as pgTable124, text as text125, varchar as varchar93, jsonb as jsonb68, timestamp as timestamp116, index as index110, uniqueIndex as uniqueIndex57 } from "drizzle-orm/pg-core";
30270
+ import { sql as sql38 } from "drizzle-orm";
30271
+ var mcpConnections = pgTable124(
30197
30272
  "mcp_connections",
30198
30273
  {
30199
- id: text123("id").primaryKey(),
30274
+ id: text125("id").primaryKey(),
30200
30275
  // nanoid
30201
- workspaceId: text123("workspace_id").notNull(),
30276
+ workspaceId: text125("workspace_id").notNull(),
30202
30277
  // FK → workspaces.id (RLS scope)
30203
- projectId: text123("project_id").notNull(),
30278
+ projectId: text125("project_id").notNull(),
30204
30279
  // FK → projects.id (application-enforced)
30205
30280
  /** Catalog slug (`notion` | `linear` | `hubspot` | `figma`) or `custom` for a user-added server. */
30206
- providerSlug: varchar92("provider_slug", { length: 32 }).notNull(),
30281
+ providerSlug: varchar93("provider_slug", { length: 32 }).notNull(),
30207
30282
  /** Where tools come from. See the header note — NOT interchangeable with authMode. */
30208
- kind: varchar92("kind", { length: 16 }).notNull().$type(),
30283
+ kind: varchar93("kind", { length: 16 }).notNull().$type(),
30209
30284
  /** How the credential is obtained. See the header note. */
30210
- authMode: varchar92("auth_mode", { length: 24 }).notNull().$type(),
30285
+ authMode: varchar93("auth_mode", { length: 24 }).notNull().$type(),
30211
30286
  /** Display name. The catalog's name for a known provider; user-supplied for a custom one. */
30212
- name: varchar92("name", { length: 120 }).notNull(),
30287
+ name: varchar93("name", { length: 120 }).notNull(),
30213
30288
  /** Remote Streamable-HTTP endpoint. NULL for `kind: 'rest'`, which has no MCP server. */
30214
- serverUrl: text123("server_url"),
30289
+ serverUrl: text125("server_url"),
30215
30290
  /** Display only — the connected Notion workspace / Linear org / Figma account. */
30216
- accountLabel: varchar92("account_label", { length: 255 }),
30217
- accessTokenEnc: text123("access_token_enc"),
30218
- refreshTokenEnc: text123("refresh_token_enc"),
30219
- expiresAt: timestamp114("expires_at", { withTimezone: true }),
30291
+ accountLabel: varchar93("account_label", { length: 255 }),
30292
+ accessTokenEnc: text125("access_token_enc"),
30293
+ refreshTokenEnc: text125("refresh_token_enc"),
30294
+ expiresAt: timestamp116("expires_at", { withTimezone: true }),
30220
30295
  /** `custom_headers` mode only: the encrypted header map a gateway requires on every call. */
30221
- headersEnc: text123("headers_enc"),
30296
+ headersEnc: text125("headers_enc"),
30222
30297
  /** DCR-issued or statically configured — the same two columns serve both, deliberately. */
30223
- oauthClientId: varchar92("oauth_client_id", { length: 255 }),
30224
- oauthClientSecretEnc: text123("oauth_client_secret_enc"),
30298
+ oauthClientId: varchar93("oauth_client_id", { length: 255 }),
30299
+ oauthClientSecretEnc: text125("oauth_client_secret_enc"),
30225
30300
  /** Both cleared on a successful exchange; see the header note on why they must exist at all. */
30226
- oauthState: text123("oauth_state"),
30227
- pkceVerifierEnc: text123("pkce_verifier_enc"),
30301
+ oauthState: text125("oauth_state"),
30302
+ pkceVerifierEnc: text125("pkce_verifier_enc"),
30228
30303
  /** Discovery output: authorization server metadata, token endpoint, RFC 8707 resource. */
30229
- authMetadata: jsonb66("auth_metadata").$type(),
30230
- scopes: text123("scopes").array().$type(),
30304
+ authMetadata: jsonb68("auth_metadata").$type(),
30305
+ scopes: text125("scopes").array().$type(),
30231
30306
  /**
30232
30307
  * Full descriptors (name, description, inputSchema, annotations) — NOT just names. The
30233
30308
  * read-only boundary is decided from `annotations.readOnlyHint`, so the names alone would
30234
30309
  * force a live listTools on the turn path to answer a governance question.
30235
30310
  */
30236
- toolsCache: jsonb66("tools_cache").$type().notNull().default([]),
30237
- toolsCachedAt: timestamp114("tools_cached_at", { withTimezone: true }),
30311
+ toolsCache: jsonb68("tools_cache").$type().notNull().default([]),
30312
+ toolsCachedAt: timestamp116("tools_cached_at", { withTimezone: true }),
30238
30313
  /**
30239
30314
  * pending | ok | invalid | revoked. `pending` is the pre-consent row; `invalid` is set on a
30240
30315
  * provider 401 or a decrypt failure so the UI can say "reconnect" instead of replaying the
30241
30316
  * same auth error on every turn forever.
30242
30317
  */
30243
- status: varchar92("status", { length: 16 }).notNull().default("pending").$type(),
30318
+ status: varchar93("status", { length: 16 }).notNull().default("pending").$type(),
30244
30319
  /** Machine-readable companion to `status`, e.g. `decrypt_failed`, `provider_401`. */
30245
- statusReason: varchar92("status_reason", { length: 64 }),
30246
- lastError: text123("last_error"),
30247
- lastUsedAt: timestamp114("last_used_at", { withTimezone: true }),
30248
- connectedBy: text123("connected_by"),
30320
+ statusReason: varchar93("status_reason", { length: 64 }),
30321
+ lastError: text125("last_error"),
30322
+ lastUsedAt: timestamp116("last_used_at", { withTimezone: true }),
30323
+ connectedBy: text125("connected_by"),
30249
30324
  // FK → users(id), added in migration
30250
30325
  ...auditColumns,
30251
30326
  ...softDeleteColumn
30252
30327
  },
30253
30328
  (t) => [
30254
- index108("mcp_connections_workspace_idx").on(t.workspaceId),
30255
- index108("mcp_connections_project_idx").on(t.projectId),
30329
+ index110("mcp_connections_workspace_idx").on(t.workspaceId),
30330
+ index110("mcp_connections_project_idx").on(t.projectId),
30256
30331
  // Reconnecting a catalog provider UPDATEs rather than accumulating a second live credential.
30257
30332
  // Custom connectors are excluded: a project may legitimately add many distinct MCP servers.
30258
- uniqueIndex56("mcp_connections_project_provider_unique").on(t.projectId, t.providerSlug).where(sql37`deleted_at IS NULL AND provider_slug <> 'custom'`)
30333
+ uniqueIndex57("mcp_connections_project_provider_unique").on(t.projectId, t.providerSlug).where(sql38`deleted_at IS NULL AND provider_slug <> 'custom'`)
30259
30334
  ]
30260
30335
  );
30261
30336
 
30262
30337
  // src/schema/crm_connections.ts
30263
30338
  import {
30264
- pgTable as pgTable123,
30265
- text as text124,
30266
- timestamp as timestamp115,
30339
+ pgTable as pgTable125,
30340
+ text as text126,
30341
+ timestamp as timestamp117,
30267
30342
  boolean as boolean38,
30268
- jsonb as jsonb67,
30269
- integer as integer60,
30270
- uniqueIndex as uniqueIndex57
30343
+ jsonb as jsonb69,
30344
+ integer as integer61,
30345
+ uniqueIndex as uniqueIndex58
30271
30346
  } from "drizzle-orm/pg-core";
30272
- var crmConnections = pgTable123(
30347
+ var crmConnections = pgTable125(
30273
30348
  "crm_connections",
30274
30349
  {
30275
- id: text124("id").primaryKey(),
30276
- workspaceId: text124("workspace_id").notNull(),
30277
- provider: text124("provider").$type().notNull(),
30278
- accountId: text124("account_id").notNull(),
30279
- accountName: text124("account_name").notNull(),
30280
- instanceUrl: text124("instance_url").notNull(),
30350
+ id: text126("id").primaryKey(),
30351
+ workspaceId: text126("workspace_id").notNull(),
30352
+ provider: text126("provider").$type().notNull(),
30353
+ accountId: text126("account_id").notNull(),
30354
+ accountName: text126("account_name").notNull(),
30355
+ instanceUrl: text126("instance_url").notNull(),
30281
30356
  sandbox: boolean38("sandbox").notNull().default(false),
30282
- status: text124("status").notNull().default("connected"),
30283
- accessToken: text124("access_token").notNull(),
30284
- refreshToken: text124("refresh_token").notNull(),
30285
- expiresAt: timestamp115("expires_at").notNull(),
30286
- createdAt: timestamp115("created_at").notNull().defaultNow(),
30287
- updatedAt: timestamp115("updated_at").notNull().defaultNow()
30357
+ status: text126("status").notNull().default("connected"),
30358
+ accessToken: text126("access_token").notNull(),
30359
+ refreshToken: text126("refresh_token").notNull(),
30360
+ expiresAt: timestamp117("expires_at").notNull(),
30361
+ createdAt: timestamp117("created_at").notNull().defaultNow(),
30362
+ updatedAt: timestamp117("updated_at").notNull().defaultNow()
30288
30363
  },
30289
30364
  (t) => [
30290
- uniqueIndex57("crm_connection_account_uq").on(
30365
+ uniqueIndex58("crm_connection_account_uq").on(
30291
30366
  t.workspaceId,
30292
30367
  t.provider,
30293
30368
  t.accountId
30294
30369
  )
30295
30370
  ]
30296
30371
  );
30297
- var crmOauthStates = pgTable123("crm_oauth_states", {
30298
- id: text124("id").primaryKey(),
30299
- workspaceId: text124("workspace_id").notNull(),
30300
- userId: text124("user_id").notNull(),
30301
- provider: text124("provider").notNull(),
30302
- verifier: text124("verifier").notNull(),
30303
- returnPath: text124("return_path").notNull(),
30372
+ var crmOauthStates = pgTable125("crm_oauth_states", {
30373
+ id: text126("id").primaryKey(),
30374
+ workspaceId: text126("workspace_id").notNull(),
30375
+ userId: text126("user_id").notNull(),
30376
+ provider: text126("provider").notNull(),
30377
+ verifier: text126("verifier").notNull(),
30378
+ returnPath: text126("return_path").notNull(),
30304
30379
  sandbox: boolean38("sandbox").notNull(),
30305
- expiresAt: timestamp115("expires_at").notNull()
30380
+ expiresAt: timestamp117("expires_at").notNull()
30306
30381
  });
30307
- var formIntegrationDeliveries = pgTable123(
30382
+ var formIntegrationDeliveries = pgTable125(
30308
30383
  "form_integration_deliveries",
30309
30384
  {
30310
- id: text124("id").primaryKey(),
30311
- workspaceId: text124("workspace_id").notNull(),
30312
- formId: text124("form_id").notNull(),
30313
- integrationId: text124("integration_id").notNull(),
30314
- eventId: text124("event_id").notNull(),
30315
- submissionId: text124("submission_id").notNull(),
30316
- snapshot: jsonb67("snapshot").$type().notNull(),
30317
- data: jsonb67("data").$type().notNull(),
30318
- status: text124("status").notNull().default("queued"),
30319
- attempts: integer60("attempts").notNull().default(0),
30320
- lastError: text124("last_error"),
30321
- remoteRecordId: text124("remote_record_id"),
30322
- nextAttemptAt: timestamp115("next_attempt_at").notNull().defaultNow(),
30323
- leaseUntil: timestamp115("lease_until"),
30324
- createdAt: timestamp115("created_at").notNull().defaultNow(),
30325
- updatedAt: timestamp115("updated_at").notNull().defaultNow()
30385
+ id: text126("id").primaryKey(),
30386
+ workspaceId: text126("workspace_id").notNull(),
30387
+ formId: text126("form_id").notNull(),
30388
+ integrationId: text126("integration_id").notNull(),
30389
+ eventId: text126("event_id").notNull(),
30390
+ submissionId: text126("submission_id").notNull(),
30391
+ snapshot: jsonb69("snapshot").$type().notNull(),
30392
+ data: jsonb69("data").$type().notNull(),
30393
+ status: text126("status").notNull().default("queued"),
30394
+ attempts: integer61("attempts").notNull().default(0),
30395
+ lastError: text126("last_error"),
30396
+ remoteRecordId: text126("remote_record_id"),
30397
+ nextAttemptAt: timestamp117("next_attempt_at").notNull().defaultNow(),
30398
+ leaseUntil: timestamp117("lease_until"),
30399
+ createdAt: timestamp117("created_at").notNull().defaultNow(),
30400
+ updatedAt: timestamp117("updated_at").notNull().defaultNow()
30326
30401
  },
30327
30402
  (t) => [
30328
- uniqueIndex57("crm_delivery_event_uq").on(
30403
+ uniqueIndex58("crm_delivery_event_uq").on(
30329
30404
  t.workspaceId,
30330
30405
  t.eventId,
30331
30406
  t.integrationId
@@ -30334,105 +30409,105 @@ var formIntegrationDeliveries = pgTable123(
30334
30409
  );
30335
30410
 
30336
30411
  // src/schema/platform_incidents.ts
30337
- import { check as check12, integer as integer61, pgTable as pgTable124, smallint as smallint2, text as text125, timestamp as timestamp116, index as index109 } from "drizzle-orm/pg-core";
30338
- import { sql as sql38 } from "drizzle-orm";
30339
- var STATUS_IN = sql38.raw("('investigating', 'identified', 'monitoring', 'resolved')");
30340
- var platformIncidents = pgTable124(
30412
+ import { check as check12, integer as integer62, pgTable as pgTable126, smallint as smallint3, text as text127, timestamp as timestamp118, index as index111 } from "drizzle-orm/pg-core";
30413
+ import { sql as sql39 } from "drizzle-orm";
30414
+ var STATUS_IN = sql39.raw("('investigating', 'identified', 'monitoring', 'resolved')");
30415
+ var platformIncidents = pgTable126(
30341
30416
  "platform_incidents",
30342
30417
  {
30343
- id: text125("id").primaryKey(),
30344
- number: integer61("number").generatedAlwaysAsIdentity().notNull().unique("platform_incidents_number_key"),
30345
- title: text125("title").notNull(),
30346
- severity: smallint2("severity").notNull(),
30418
+ id: text127("id").primaryKey(),
30419
+ number: integer62("number").generatedAlwaysAsIdentity().notNull().unique("platform_incidents_number_key"),
30420
+ title: text127("title").notNull(),
30421
+ severity: smallint3("severity").notNull(),
30347
30422
  // 1 (worst) … 4
30348
- status: text125("status").notNull().default("investigating"),
30423
+ status: text127("status").notNull().default("investigating"),
30349
30424
  // investigating | identified | monitoring | resolved
30350
- services: text125("services").array().notNull().default([]),
30351
- commanderId: text125("commander_id"),
30352
- startedAt: timestamp116("started_at", { withTimezone: true }).notNull().defaultNow(),
30353
- resolvedAt: timestamp116("resolved_at", { withTimezone: true }),
30354
- createdBy: text125("created_by"),
30355
- createdAt: timestamp116("created_at", { withTimezone: true }).notNull().defaultNow(),
30356
- updatedAt: timestamp116("updated_at", { withTimezone: true }).notNull().defaultNow()
30425
+ services: text127("services").array().notNull().default([]),
30426
+ commanderId: text127("commander_id"),
30427
+ startedAt: timestamp118("started_at", { withTimezone: true }).notNull().defaultNow(),
30428
+ resolvedAt: timestamp118("resolved_at", { withTimezone: true }),
30429
+ createdBy: text127("created_by"),
30430
+ createdAt: timestamp118("created_at", { withTimezone: true }).notNull().defaultNow(),
30431
+ updatedAt: timestamp118("updated_at", { withTimezone: true }).notNull().defaultNow()
30357
30432
  },
30358
30433
  // Mirrors 0375 exactly: drizzle-kit push builds fresh DBs before the migration runs.
30359
30434
  (t) => [
30360
- index109("platform_incidents_started_idx").on(t.startedAt.desc()),
30361
- check12("platform_incidents_severity_check", sql38`${t.severity} BETWEEN 1 AND 4`),
30362
- check12("platform_incidents_status_check", sql38`${t.status} IN ${STATUS_IN}`)
30435
+ index111("platform_incidents_started_idx").on(t.startedAt.desc()),
30436
+ check12("platform_incidents_severity_check", sql39`${t.severity} BETWEEN 1 AND 4`),
30437
+ check12("platform_incidents_status_check", sql39`${t.status} IN ${STATUS_IN}`)
30363
30438
  ]
30364
30439
  );
30365
- var platformIncidentUpdates = pgTable124(
30440
+ var platformIncidentUpdates = pgTable126(
30366
30441
  "platform_incident_updates",
30367
30442
  {
30368
- id: text125("id").primaryKey(),
30369
- incidentId: text125("incident_id").notNull().references(() => platformIncidents.id, { onDelete: "cascade" }),
30370
- status: text125("status").notNull(),
30371
- note: text125("note").notNull(),
30372
- createdBy: text125("created_by"),
30373
- createdAt: timestamp116("created_at", { withTimezone: true }).notNull().defaultNow()
30443
+ id: text127("id").primaryKey(),
30444
+ incidentId: text127("incident_id").notNull().references(() => platformIncidents.id, { onDelete: "cascade" }),
30445
+ status: text127("status").notNull(),
30446
+ note: text127("note").notNull(),
30447
+ createdBy: text127("created_by"),
30448
+ createdAt: timestamp118("created_at", { withTimezone: true }).notNull().defaultNow()
30374
30449
  },
30375
30450
  (t) => [
30376
- index109("platform_incident_updates_incident_idx").on(t.incidentId, t.createdAt),
30377
- check12("platform_incident_updates_status_check", sql38`${t.status} IN ${STATUS_IN}`)
30451
+ index111("platform_incident_updates_incident_idx").on(t.incidentId, t.createdAt),
30452
+ check12("platform_incident_updates_status_check", sql39`${t.status} IN ${STATUS_IN}`)
30378
30453
  ]
30379
30454
  );
30380
30455
 
30381
30456
  // src/schema/platform_vendors.ts
30382
- import { date as date3, integer as integer62, pgTable as pgTable125, text as text126, timestamp as timestamp117, varchar as varchar93 } from "drizzle-orm/pg-core";
30383
- var platformVendors = pgTable125("platform_vendors", {
30384
- id: text126("id").primaryKey(),
30385
- name: text126("name").notNull(),
30386
- category: text126("category").notNull(),
30387
- billingCycle: text126("billing_cycle").notNull().default("monthly"),
30457
+ import { date as date3, integer as integer63, pgTable as pgTable127, text as text128, timestamp as timestamp119, varchar as varchar94 } from "drizzle-orm/pg-core";
30458
+ var platformVendors = pgTable127("platform_vendors", {
30459
+ id: text128("id").primaryKey(),
30460
+ name: text128("name").notNull(),
30461
+ category: text128("category").notNull(),
30462
+ billingCycle: text128("billing_cycle").notNull().default("monthly"),
30388
30463
  // monthly | yearly | usage
30389
- monthlyCents: integer62("monthly_cents").notNull().default(0),
30464
+ monthlyCents: integer63("monthly_cents").notNull().default(0),
30390
30465
  // normalised monthly cost
30391
- currency: varchar93("currency", { length: 3 }).notNull().default("usd"),
30466
+ currency: varchar94("currency", { length: 3 }).notNull().default("usd"),
30392
30467
  renewsOn: date3("renews_on"),
30393
30468
  // YYYY-MM-DD
30394
- status: text126("status").notNull().default("active"),
30469
+ status: text128("status").notNull().default("active"),
30395
30470
  // active | trial | cancelling | unused
30396
- ownerEmail: text126("owner_email"),
30397
- notes: text126("notes"),
30398
- createdBy: text126("created_by"),
30399
- createdAt: timestamp117("created_at", { withTimezone: true }).notNull().defaultNow(),
30400
- updatedAt: timestamp117("updated_at", { withTimezone: true }).notNull().defaultNow()
30471
+ ownerEmail: text128("owner_email"),
30472
+ notes: text128("notes"),
30473
+ createdBy: text128("created_by"),
30474
+ createdAt: timestamp119("created_at", { withTimezone: true }).notNull().defaultNow(),
30475
+ updatedAt: timestamp119("updated_at", { withTimezone: true }).notNull().defaultNow()
30401
30476
  });
30402
30477
 
30403
30478
  // src/schema/platform_tasks.ts
30404
- import { check as check13, date as date4, pgTable as pgTable126, text as text127, timestamp as timestamp118, index as index110 } from "drizzle-orm/pg-core";
30405
- import { sql as sql39 } from "drizzle-orm";
30406
- var platformTasks = pgTable126(
30479
+ import { check as check13, date as date4, pgTable as pgTable128, text as text129, timestamp as timestamp120, index as index112 } from "drizzle-orm/pg-core";
30480
+ import { sql as sql40 } from "drizzle-orm";
30481
+ var platformTasks = pgTable128(
30407
30482
  "platform_tasks",
30408
30483
  {
30409
- id: text127("id").primaryKey(),
30410
- title: text127("title").notNull(),
30411
- description: text127("description"),
30412
- status: text127("status").notNull().default("open"),
30484
+ id: text129("id").primaryKey(),
30485
+ title: text129("title").notNull(),
30486
+ description: text129("description"),
30487
+ status: text129("status").notNull().default("open"),
30413
30488
  // open | in_progress | done
30414
- priority: text127("priority").notNull().default("medium"),
30489
+ priority: text129("priority").notNull().default("medium"),
30415
30490
  // low | medium | high | urgent
30416
- assigneeId: text127("assignee_id"),
30491
+ assigneeId: text129("assignee_id"),
30417
30492
  dueOn: date4("due_on"),
30418
30493
  // YYYY-MM-DD
30419
- entityType: text127("entity_type"),
30494
+ entityType: text129("entity_type"),
30420
30495
  // user | workspace | incident | deal
30421
- entityId: text127("entity_id"),
30422
- entityLabel: text127("entity_label"),
30423
- completedAt: timestamp118("completed_at", { withTimezone: true }),
30424
- createdBy: text127("created_by"),
30425
- createdAt: timestamp118("created_at", { withTimezone: true }).notNull().defaultNow(),
30426
- updatedAt: timestamp118("updated_at", { withTimezone: true }).notNull().defaultNow()
30496
+ entityId: text129("entity_id"),
30497
+ entityLabel: text129("entity_label"),
30498
+ completedAt: timestamp120("completed_at", { withTimezone: true }),
30499
+ createdBy: text129("created_by"),
30500
+ createdAt: timestamp120("created_at", { withTimezone: true }).notNull().defaultNow(),
30501
+ updatedAt: timestamp120("updated_at", { withTimezone: true }).notNull().defaultNow()
30427
30502
  },
30428
30503
  // Mirrors 0377 exactly: drizzle-kit push builds fresh DBs before the migration runs.
30429
30504
  (t) => [
30430
- index110("platform_tasks_open_idx").on(t.status, t.dueOn),
30431
- index110("platform_tasks_entity_idx").on(t.entityType, t.entityId),
30432
- check13("platform_tasks_status_check", sql39`${t.status} IN ('open', 'in_progress', 'done')`),
30433
- check13("platform_tasks_priority_check", sql39`${t.priority} IN ('low', 'medium', 'high', 'urgent')`),
30434
- check13("platform_tasks_entity_type_check", sql39`${t.entityType} IN ('user', 'workspace', 'incident', 'deal')`),
30435
- check13("platform_tasks_entity_pair_check", sql39`(${t.entityType} IS NULL) = (${t.entityId} IS NULL)`)
30505
+ index112("platform_tasks_open_idx").on(t.status, t.dueOn),
30506
+ index112("platform_tasks_entity_idx").on(t.entityType, t.entityId),
30507
+ check13("platform_tasks_status_check", sql40`${t.status} IN ('open', 'in_progress', 'done')`),
30508
+ check13("platform_tasks_priority_check", sql40`${t.priority} IN ('low', 'medium', 'high', 'urgent')`),
30509
+ check13("platform_tasks_entity_type_check", sql40`${t.entityType} IN ('user', 'workspace', 'incident', 'deal')`),
30510
+ check13("platform_tasks_entity_pair_check", sql40`(${t.entityType} IS NULL) = (${t.entityId} IS NULL)`)
30436
30511
  ]
30437
30512
  );
30438
30513
 
@@ -30500,7 +30575,7 @@ async function reserveWithDeadline() {
30500
30575
  })
30501
30576
  ]);
30502
30577
  } catch (err) {
30503
- void pending.then((sql41) => sql41.release()).catch((cause) => console.error("[db-pool] orphaned acquire failed:", cause));
30578
+ void pending.then((sql42) => sql42.release()).catch((cause) => console.error("[db-pool] orphaned acquire failed:", cause));
30504
30579
  throw err;
30505
30580
  } finally {
30506
30581
  clearTimeout(timer);
@@ -30710,7 +30785,7 @@ var queries = {
30710
30785
  };
30711
30786
 
30712
30787
  // src/lib/workspace-context.ts
30713
- import { sql as sql40 } from "drizzle-orm";
30788
+ import { sql as sql41 } from "drizzle-orm";
30714
30789
  import { eq as eq2 } from "drizzle-orm";
30715
30790
  import { nanoid } from "nanoid";
30716
30791
  var writeOrigins = new Set(WRITE_ORIGINS);
@@ -30744,7 +30819,7 @@ async function getWorkspaceSlugById(workspaceId) {
30744
30819
  }
30745
30820
  async function lookupApiKeyByHash(keyHash) {
30746
30821
  const rows = await db.execute(
30747
- sql40`SELECT * FROM lookup_api_key_by_hash(${keyHash})`
30822
+ sql41`SELECT * FROM lookup_api_key_by_hash(${keyHash})`
30748
30823
  );
30749
30824
  const r = rows[0];
30750
30825
  if (!r) return null;
@@ -30775,7 +30850,7 @@ async function lookupApiKeyByHash(keyHash) {
30775
30850
  }
30776
30851
  async function publicWorkspaceBySlug(slug) {
30777
30852
  const rows = await db.execute(
30778
- sql40`SELECT id, slug FROM public_workspace_by_slug(${slug})`
30853
+ sql41`SELECT id, slug FROM public_workspace_by_slug(${slug})`
30779
30854
  );
30780
30855
  const r = rows[0];
30781
30856
  return r?.id ? { id: r.id, slug: r.slug ?? slug } : null;
@@ -30785,7 +30860,7 @@ async function getDefaultWorkspaceId(userId) {
30785
30860
  return row?.id ?? null;
30786
30861
  }
30787
30862
  async function resolveUserWorkspace(userId, workspaceId) {
30788
- const rows = await db.execute(sql40`
30863
+ const rows = await db.execute(sql41`
30789
30864
  SELECT workspace_id, role
30790
30865
  FROM resolve_user_workspace(${userId}, ${workspaceId ?? null})
30791
30866
  `);
@@ -30821,7 +30896,7 @@ async function ensureDefaultWorkspace(userId, name = "My Workspace", slug) {
30821
30896
  for (let attempt = 1; attempt <= MAX_SLUG_ATTEMPTS; attempt++) {
30822
30897
  console.log("[ensureDefaultWorkspace] Creating workspace + owner membership:", { workspaceId, slug: candidateSlug, attempt });
30823
30898
  try {
30824
- await db.execute(sql40`
30899
+ await db.execute(sql41`
30825
30900
  SELECT create_default_workspace(${workspaceId}, ${userId}, ${memberId}, ${name}, ${candidateSlug})
30826
30901
  `);
30827
30902
  console.log("[ensureDefaultWorkspace] Workspace + owner membership created with slug:", candidateSlug);
@@ -30955,6 +31030,8 @@ function extractEntryText(data) {
30955
31030
  var upsertEntry = upsertPage;
30956
31031
  var removeEntry = removePage;
30957
31032
  export {
31033
+ BINDING_DECISION_OPS,
31034
+ BINDING_DECISION_STATES,
30958
31035
  BUILD_TRIGGER_KINDS,
30959
31036
  COLLECTION_NAME,
30960
31037
  CONTENT_LOCK_MODES,
@@ -31028,6 +31105,7 @@ export {
31028
31105
  billingAddons,
31029
31106
  billingAlerts,
31030
31107
  billingCustomers,
31108
+ bindingDecisions,
31031
31109
  branchColumns,
31032
31110
  branchPreviewGrants,
31033
31111
  branchPreviewShares,
@@ -31082,6 +31160,7 @@ export {
31082
31160
  emailSuppressions,
31083
31161
  ensureCollection,
31084
31162
  ensureDefaultWorkspace,
31163
+ entrySlotModels,
31085
31164
  externalDeployments,
31086
31165
  extractBlockText,
31087
31166
  extractEntryText,