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