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