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