@columnus/api-cli 0.1.62 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1078 -991
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3033,129 +3033,6 @@ async function fetchIntrospect(convexUrl, apiToken, options) {
|
|
|
3033
3033
|
import { promises as fs } from "node:fs";
|
|
3034
3034
|
import path3 from "node:path";
|
|
3035
3035
|
|
|
3036
|
-
// ../shared/src/apiProfileSlug.ts
|
|
3037
|
-
function apiProfileSlugToConvexModuleSegment(slug) {
|
|
3038
|
-
return slug.replace(/-/g, "_");
|
|
3039
|
-
}
|
|
3040
|
-
|
|
3041
|
-
// ../shared/src/readApiQuery.ts
|
|
3042
|
-
function readApiQueryExportName(kind, tableName) {
|
|
3043
|
-
return `${kind}${tableName}`;
|
|
3044
|
-
}
|
|
3045
|
-
function proposeApiExportName(op, tableName) {
|
|
3046
|
-
return `propose${op[0].toUpperCase()}${op.slice(1)}${tableName}`;
|
|
3047
|
-
}
|
|
3048
|
-
function readApiQueryModuleSegment(profileSlug) {
|
|
3049
|
-
return apiProfileSlugToConvexModuleSegment(profileSlug);
|
|
3050
|
-
}
|
|
3051
|
-
function readApiAnyApiPath(profileSlug, kind, tableName) {
|
|
3052
|
-
const segment = readApiQueryModuleSegment(profileSlug);
|
|
3053
|
-
const exportName = readApiQueryExportName(kind, tableName);
|
|
3054
|
-
return `anyApi.columnus.read.${segment}.${exportName}.${exportName}`;
|
|
3055
|
-
}
|
|
3056
|
-
|
|
3057
|
-
// ../shared/src/fieldValueShape.ts
|
|
3058
|
-
function enumOptions(type) {
|
|
3059
|
-
if (type.kind !== "union") return null;
|
|
3060
|
-
const values = [];
|
|
3061
|
-
for (const option of type.options) {
|
|
3062
|
-
if (option.kind !== "literal") return null;
|
|
3063
|
-
values.push(option.value);
|
|
3064
|
-
}
|
|
3065
|
-
return values;
|
|
3066
|
-
}
|
|
3067
|
-
|
|
3068
|
-
// ../shared/src/fieldTypeMeta.ts
|
|
3069
|
-
function leafOnly(_type) {
|
|
3070
|
-
}
|
|
3071
|
-
function fieldShape(type) {
|
|
3072
|
-
if (enumOptions(type)) return "enum";
|
|
3073
|
-
if (type.kind === "array" && type.element.kind === "id") return "idList";
|
|
3074
|
-
if (type.kind === "array" && hasKindTrait(type.element, "chipItem")) return "scalarList";
|
|
3075
|
-
return type.kind;
|
|
3076
|
-
}
|
|
3077
|
-
var SHAPE_TRAITS = {
|
|
3078
|
-
string: ["inline", "editable", "textScalar", "previewLabel", "chipItem"],
|
|
3079
|
-
markdown: ["editable", "previewLabel"],
|
|
3080
|
-
number: ["inline", "editable", "textScalar", "commitsOnChange", "previewLabel", "chipItem"],
|
|
3081
|
-
boolean: ["inline", "editable", "commitsOnChange"],
|
|
3082
|
-
bigint: ["inline", "editable", "textScalar", "previewLabel", "chipItem"],
|
|
3083
|
-
null: ["inline"],
|
|
3084
|
-
any: ["inline", "editable"],
|
|
3085
|
-
bytes: ["inline", "editable"],
|
|
3086
|
-
file: ["editable", "storage", "tallEditor"],
|
|
3087
|
-
image: ["editable", "storage", "tallEditor"],
|
|
3088
|
-
date: ["inline", "editable", "commitsOnChange", "previewLabel", "chipItem"],
|
|
3089
|
-
datetime: ["inline", "editable", "commitsOnChange", "previewLabel", "chipItem"],
|
|
3090
|
-
id: ["inline", "editable", "textScalar", "commitsOnChange"],
|
|
3091
|
-
literal: ["inline", "previewLabel"],
|
|
3092
|
-
array: ["editable", "tallEditor"],
|
|
3093
|
-
// Edited through a summary popover / variant picker, so edits commit as they happen.
|
|
3094
|
-
object: ["editable", "commitsOnChange"],
|
|
3095
|
-
union: ["editable", "commitsOnChange"],
|
|
3096
|
-
enum: ["inline", "editable", "commitsOnChange", "chipItem"],
|
|
3097
|
-
idList: ["editable", "commitsOnChange", "wrapsInline"],
|
|
3098
|
-
scalarList: ["editable", "wrapsInline"]
|
|
3099
|
-
};
|
|
3100
|
-
function hasKindTrait(type, trait) {
|
|
3101
|
-
return SHAPE_TRAITS[fieldShape(type)].includes(trait);
|
|
3102
|
-
}
|
|
3103
|
-
|
|
3104
|
-
// ../shared/src/refGraph.ts
|
|
3105
|
-
function isLeaf(type, leaf) {
|
|
3106
|
-
return leaf === "document" ? type.kind === "id" : hasKindTrait(type, "storage");
|
|
3107
|
-
}
|
|
3108
|
-
function typeLeaves(type, leaf, at, out) {
|
|
3109
|
-
if (isLeaf(type, leaf)) {
|
|
3110
|
-
out.push({ type, ...at });
|
|
3111
|
-
return out;
|
|
3112
|
-
}
|
|
3113
|
-
switch (type.kind) {
|
|
3114
|
-
case "array":
|
|
3115
|
-
typeLeaves(type.element, leaf, { ...at, path: `${at.path}[]`, many: true }, out);
|
|
3116
|
-
break;
|
|
3117
|
-
case "object":
|
|
3118
|
-
for (const f of type.fields) {
|
|
3119
|
-
const path5 = `${at.path}.${f.name}`;
|
|
3120
|
-
typeLeaves(f.type, leaf, { ...at, path: path5, depth: at.depth + 1, binding: f.asset }, out);
|
|
3121
|
-
}
|
|
3122
|
-
break;
|
|
3123
|
-
case "union":
|
|
3124
|
-
for (const option of type.options)
|
|
3125
|
-
typeLeaves(option, leaf, { ...at, depth: at.depth + 1 }, out);
|
|
3126
|
-
break;
|
|
3127
|
-
default:
|
|
3128
|
-
leafOnly(type);
|
|
3129
|
-
}
|
|
3130
|
-
return out;
|
|
3131
|
-
}
|
|
3132
|
-
var ROOT = { path: "", depth: 0, many: false, binding: void 0 };
|
|
3133
|
-
function compareEdges(a, b) {
|
|
3134
|
-
return a.field.localeCompare(b.field) || a.path.localeCompare(b.path) || a.targetTable.localeCompare(b.targetTable);
|
|
3135
|
-
}
|
|
3136
|
-
function fieldEdges(field) {
|
|
3137
|
-
return typeLeaves(field.type, "document", ROOT, []).map(({ type, path: path5, depth, many }) => ({
|
|
3138
|
-
field: field.name,
|
|
3139
|
-
path: path5,
|
|
3140
|
-
targetTable: type.table,
|
|
3141
|
-
many,
|
|
3142
|
-
depth
|
|
3143
|
-
}));
|
|
3144
|
-
}
|
|
3145
|
-
function refEdges(table) {
|
|
3146
|
-
const seen = /* @__PURE__ */ new Set();
|
|
3147
|
-
const edges = [];
|
|
3148
|
-
for (const field of table.fields) {
|
|
3149
|
-
for (const edge of fieldEdges(field)) {
|
|
3150
|
-
const key = `${edge.field}\0${edge.path}\0${edge.targetTable}`;
|
|
3151
|
-
if (seen.has(key)) continue;
|
|
3152
|
-
seen.add(key);
|
|
3153
|
-
edges.push(edge);
|
|
3154
|
-
}
|
|
3155
|
-
}
|
|
3156
|
-
return edges.sort(compareEdges);
|
|
3157
|
-
}
|
|
3158
|
-
|
|
3159
3036
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
3160
3037
|
var external_exports = {};
|
|
3161
3038
|
__export(external_exports, {
|
|
@@ -3832,8 +3709,8 @@ function assertNever(_x) {
|
|
|
3832
3709
|
function assert(_) {
|
|
3833
3710
|
}
|
|
3834
3711
|
function getEnumValues(entries) {
|
|
3835
|
-
const numericValues = Object.values(entries).filter((
|
|
3836
|
-
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_,
|
|
3712
|
+
const numericValues = Object.values(entries).filter((v4) => typeof v4 === "number");
|
|
3713
|
+
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v4]) => v4);
|
|
3837
3714
|
return values;
|
|
3838
3715
|
}
|
|
3839
3716
|
function joinValues(array2, separator = "|") {
|
|
@@ -3891,9 +3768,9 @@ function defineLazy(object2, key, getter) {
|
|
|
3891
3768
|
}
|
|
3892
3769
|
return value;
|
|
3893
3770
|
},
|
|
3894
|
-
set(
|
|
3771
|
+
set(v4) {
|
|
3895
3772
|
Object.defineProperty(object2, key, {
|
|
3896
|
-
value:
|
|
3773
|
+
value: v4
|
|
3897
3774
|
// configurable: true,
|
|
3898
3775
|
});
|
|
3899
3776
|
},
|
|
@@ -5920,10 +5797,10 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
|
5920
5797
|
v7: 7,
|
|
5921
5798
|
v8: 8
|
|
5922
5799
|
};
|
|
5923
|
-
const
|
|
5924
|
-
if (
|
|
5800
|
+
const v4 = versionMap[def.version];
|
|
5801
|
+
if (v4 === void 0)
|
|
5925
5802
|
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
5926
|
-
def.pattern ?? (def.pattern = uuid(
|
|
5803
|
+
def.pattern ?? (def.pattern = uuid(v4));
|
|
5927
5804
|
} else
|
|
5928
5805
|
def.pattern ?? (def.pattern = uuid());
|
|
5929
5806
|
$ZodStringFormat.init(inst, def);
|
|
@@ -6671,8 +6548,8 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
6671
6548
|
if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
|
|
6672
6549
|
assignProp(propValues, key, /* @__PURE__ */ new Set());
|
|
6673
6550
|
}
|
|
6674
|
-
for (const
|
|
6675
|
-
propValues[key].add(
|
|
6551
|
+
for (const v4 of field.values)
|
|
6552
|
+
propValues[key].add(v4);
|
|
6676
6553
|
if (field.optin !== void 0)
|
|
6677
6554
|
propValues[key].add(void 0);
|
|
6678
6555
|
}
|
|
@@ -7018,11 +6895,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
7018
6895
|
throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
7019
6896
|
if (pv[zod.def.discriminator]?.has(void 0))
|
|
7020
6897
|
undefinedCount++;
|
|
7021
|
-
for (const [k,
|
|
6898
|
+
for (const [k, v4] of Object.entries(pv)) {
|
|
7022
6899
|
if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
|
|
7023
6900
|
assignProp(propValues, k, /* @__PURE__ */ new Set());
|
|
7024
6901
|
}
|
|
7025
|
-
for (const val of
|
|
6902
|
+
for (const val of v4) {
|
|
7026
6903
|
propValues[k].add(val);
|
|
7027
6904
|
}
|
|
7028
6905
|
}
|
|
@@ -7752,8 +7629,8 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
|
7752
7629
|
var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
7753
7630
|
$ZodType.init(inst, def);
|
|
7754
7631
|
defineLazyInternal(inst, "values", (zod) => {
|
|
7755
|
-
const
|
|
7756
|
-
return
|
|
7632
|
+
const v4 = zod.def.innerType._zod.values;
|
|
7633
|
+
return v4 ? new Set([...v4].filter((x) => x !== void 0)) : void 0;
|
|
7757
7634
|
});
|
|
7758
7635
|
inst._zod.parse = (payload, ctx) => {
|
|
7759
7636
|
const result = def.innerType._zod.run(payload, ctx);
|
|
@@ -10930,7 +10807,7 @@ var error20 = () => {
|
|
|
10930
10807
|
if (issue2.values.length === 1) {
|
|
10931
10808
|
return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${stringifyPrimitive(issue2.values[0])}`;
|
|
10932
10809
|
}
|
|
10933
|
-
const stringified = issue2.values.map((
|
|
10810
|
+
const stringified = issue2.values.map((v4) => stringifyPrimitive(v4));
|
|
10934
10811
|
if (issue2.values.length === 2) {
|
|
10935
10812
|
return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${stringified[0]} \u05D0\u05D5 ${stringified[1]}`;
|
|
10936
10813
|
}
|
|
@@ -16188,8 +16065,8 @@ ${code}
|
|
|
16188
16065
|
return fn;
|
|
16189
16066
|
}
|
|
16190
16067
|
function addConstant(ctx, value) {
|
|
16191
|
-
for (const [name2,
|
|
16192
|
-
if (
|
|
16068
|
+
for (const [name2, v4] of ctx.constants) {
|
|
16069
|
+
if (v4 === value)
|
|
16193
16070
|
return name2;
|
|
16194
16071
|
}
|
|
16195
16072
|
const name = `c${ctx.constantCounter++}`;
|
|
@@ -16332,9 +16209,9 @@ function generateChecks(doc, ctx, schema, accessor) {
|
|
|
16332
16209
|
}
|
|
16333
16210
|
function codePointLengthVar(doc, ctx, accessor, inDoubt) {
|
|
16334
16211
|
const cpLen = addConstant(ctx, codePointLength);
|
|
16335
|
-
const
|
|
16336
|
-
doc.write(`const ${
|
|
16337
|
-
return
|
|
16212
|
+
const v4 = newVar(ctx);
|
|
16213
|
+
doc.write(`const ${v4} = typeof ${accessor} === "string" && ${inDoubt} ? ${cpLen}(${accessor}) : ${accessor}.length;`);
|
|
16214
|
+
return v4;
|
|
16338
16215
|
}
|
|
16339
16216
|
function numericOperand(value, label) {
|
|
16340
16217
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
@@ -18447,7 +18324,7 @@ function _set(Class2, valueType, params) {
|
|
|
18447
18324
|
}
|
|
18448
18325
|
// @__NO_SIDE_EFFECTS__
|
|
18449
18326
|
function _enum(Class2, values, params) {
|
|
18450
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((
|
|
18327
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v4) => [v4, v4])) : values;
|
|
18451
18328
|
return new Class2({
|
|
18452
18329
|
type: "enum",
|
|
18453
18330
|
entries,
|
|
@@ -18653,8 +18530,8 @@ function _stringbool(Classes, _params) {
|
|
|
18653
18530
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
18654
18531
|
let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
|
|
18655
18532
|
if (params.case !== "sensitive") {
|
|
18656
|
-
truthyArray = truthyArray.map((
|
|
18657
|
-
falsyArray = falsyArray.map((
|
|
18533
|
+
truthyArray = truthyArray.map((v4) => typeof v4 === "string" ? v4.toLowerCase() : v4);
|
|
18534
|
+
falsyArray = falsyArray.map((v4) => typeof v4 === "string" ? v4.toLowerCase() : v4);
|
|
18658
18535
|
}
|
|
18659
18536
|
const truthySet = new Set(truthyArray);
|
|
18660
18537
|
const falsySet = new Set(falsyArray);
|
|
@@ -19465,9 +19342,9 @@ var enumProcessor = (schema, _ctx, json2, _params) => {
|
|
|
19465
19342
|
json2.not = {};
|
|
19466
19343
|
return;
|
|
19467
19344
|
}
|
|
19468
|
-
if (values.every((
|
|
19345
|
+
if (values.every((v4) => typeof v4 === "number"))
|
|
19469
19346
|
json2.type = "number";
|
|
19470
|
-
if (values.every((
|
|
19347
|
+
if (values.every((v4) => typeof v4 === "string"))
|
|
19471
19348
|
json2.type = "string";
|
|
19472
19349
|
json2.enum = values;
|
|
19473
19350
|
};
|
|
@@ -19500,13 +19377,13 @@ var literalProcessor = (schema, ctx, json2, params) => {
|
|
|
19500
19377
|
json2.const = val;
|
|
19501
19378
|
}
|
|
19502
19379
|
} else {
|
|
19503
|
-
if (vals.every((
|
|
19380
|
+
if (vals.every((v4) => typeof v4 === "number"))
|
|
19504
19381
|
json2.type = "number";
|
|
19505
|
-
if (vals.every((
|
|
19382
|
+
if (vals.every((v4) => typeof v4 === "string"))
|
|
19506
19383
|
json2.type = "string";
|
|
19507
|
-
if (vals.every((
|
|
19384
|
+
if (vals.every((v4) => typeof v4 === "boolean"))
|
|
19508
19385
|
json2.type = "boolean";
|
|
19509
|
-
if (vals.every((
|
|
19386
|
+
if (vals.every((v4) => v4 === null))
|
|
19510
19387
|
json2.type = "null";
|
|
19511
19388
|
json2.enum = vals;
|
|
19512
19389
|
}
|
|
@@ -19738,11 +19615,11 @@ function stringifyKeyNames(bySchema, json2, visited) {
|
|
|
19738
19615
|
const types = Array.isArray(json2.type) ? json2.type : [json2.type];
|
|
19739
19616
|
const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
|
|
19740
19617
|
const values = json2.enum ?? (json2.const !== void 0 ? [json2.const] : void 0);
|
|
19741
|
-
if (!numericType && !values?.some((
|
|
19618
|
+
if (!numericType && !values?.some((v4) => typeof v4 === "number"))
|
|
19742
19619
|
return json2;
|
|
19743
19620
|
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json2;
|
|
19744
19621
|
if (rest.enum)
|
|
19745
|
-
rest.enum = rest.enum.map((
|
|
19622
|
+
rest.enum = rest.enum.map((v4) => typeof v4 === "number" ? String(v4) : v4);
|
|
19746
19623
|
else if (typeof rest.const === "number")
|
|
19747
19624
|
rest.const = String(rest.const);
|
|
19748
19625
|
if (!numericType)
|
|
@@ -19816,7 +19693,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
19816
19693
|
const keyValues = keyType._zod.values;
|
|
19817
19694
|
const omittableOnInput = ctx.io === "input" && inputOptin(def.valueType) !== void 0;
|
|
19818
19695
|
if (keyValues && !def.partial && !omittableOnInput) {
|
|
19819
|
-
const validKeyValues = [...keyValues].filter((
|
|
19696
|
+
const validKeyValues = [...keyValues].filter((v4) => typeof v4 === "string" || typeof v4 === "number");
|
|
19820
19697
|
if (validKeyValues.length > 0) {
|
|
19821
19698
|
json2.required = validKeyValues.map(String);
|
|
19822
19699
|
}
|
|
@@ -21441,7 +21318,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
21441
21318
|
};
|
|
21442
21319
|
});
|
|
21443
21320
|
function _enum2(values, params) {
|
|
21444
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((
|
|
21321
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v4) => [v4, v4])) : values;
|
|
21445
21322
|
return new ZodEnum({
|
|
21446
21323
|
type: "enum",
|
|
21447
21324
|
entries,
|
|
@@ -22225,10 +22102,10 @@ function convertBaseSchema(schema, ctx) {
|
|
|
22225
22102
|
if (enumValues.length === 1) {
|
|
22226
22103
|
return z.literal(enumValues[0]);
|
|
22227
22104
|
}
|
|
22228
|
-
if (enumValues.every((
|
|
22105
|
+
if (enumValues.every((v4) => typeof v4 === "string")) {
|
|
22229
22106
|
return z.enum(enumValues);
|
|
22230
22107
|
}
|
|
22231
|
-
const literalSchemas = enumValues.map((
|
|
22108
|
+
const literalSchemas = enumValues.map((v4) => z.literal(v4));
|
|
22232
22109
|
if (literalSchemas.length < 2) {
|
|
22233
22110
|
return literalSchemas[0];
|
|
22234
22111
|
}
|
|
@@ -22824,6 +22701,53 @@ function date4(params) {
|
|
|
22824
22701
|
return _coercedDate(ZodDate, params);
|
|
22825
22702
|
}
|
|
22826
22703
|
|
|
22704
|
+
// ../shared/src/fieldValueShape.ts
|
|
22705
|
+
function enumOptions(type) {
|
|
22706
|
+
if (type.kind !== "union") return null;
|
|
22707
|
+
const values = [];
|
|
22708
|
+
for (const option of type.options) {
|
|
22709
|
+
if (option.kind !== "literal") return null;
|
|
22710
|
+
values.push(option.value);
|
|
22711
|
+
}
|
|
22712
|
+
return values;
|
|
22713
|
+
}
|
|
22714
|
+
|
|
22715
|
+
// ../shared/src/fieldTypeMeta.ts
|
|
22716
|
+
function leafOnly(_type) {
|
|
22717
|
+
}
|
|
22718
|
+
function fieldShape(type) {
|
|
22719
|
+
if (enumOptions(type)) return "enum";
|
|
22720
|
+
if (type.kind === "array" && type.element.kind === "id") return "idList";
|
|
22721
|
+
if (type.kind === "array" && hasKindTrait(type.element, "chipItem")) return "scalarList";
|
|
22722
|
+
return type.kind;
|
|
22723
|
+
}
|
|
22724
|
+
var SHAPE_TRAITS = {
|
|
22725
|
+
string: ["inline", "editable", "textScalar", "previewLabel", "chipItem"],
|
|
22726
|
+
markdown: ["editable", "previewLabel"],
|
|
22727
|
+
number: ["inline", "editable", "textScalar", "commitsOnChange", "previewLabel", "chipItem"],
|
|
22728
|
+
boolean: ["inline", "editable", "commitsOnChange"],
|
|
22729
|
+
bigint: ["inline", "editable", "textScalar", "previewLabel", "chipItem"],
|
|
22730
|
+
null: ["inline"],
|
|
22731
|
+
any: ["inline", "editable"],
|
|
22732
|
+
bytes: ["inline", "editable"],
|
|
22733
|
+
file: ["editable", "storage", "tallEditor"],
|
|
22734
|
+
image: ["editable", "storage", "tallEditor"],
|
|
22735
|
+
date: ["inline", "editable", "commitsOnChange", "previewLabel", "chipItem"],
|
|
22736
|
+
datetime: ["inline", "editable", "commitsOnChange", "previewLabel", "chipItem"],
|
|
22737
|
+
id: ["inline", "editable", "textScalar", "commitsOnChange"],
|
|
22738
|
+
literal: ["inline", "previewLabel"],
|
|
22739
|
+
array: ["editable", "tallEditor"],
|
|
22740
|
+
// Edited through a summary popover / variant picker, so edits commit as they happen.
|
|
22741
|
+
object: ["editable", "commitsOnChange"],
|
|
22742
|
+
union: ["editable", "commitsOnChange"],
|
|
22743
|
+
enum: ["inline", "editable", "commitsOnChange", "chipItem"],
|
|
22744
|
+
idList: ["editable", "commitsOnChange", "wrapsInline"],
|
|
22745
|
+
scalarList: ["editable", "wrapsInline"]
|
|
22746
|
+
};
|
|
22747
|
+
function hasKindTrait(type, trait) {
|
|
22748
|
+
return SHAPE_TRAITS[fieldShape(type)].includes(trait);
|
|
22749
|
+
}
|
|
22750
|
+
|
|
22827
22751
|
// ../shared/src/queryFieldOps.ts
|
|
22828
22752
|
var PREDICATE_VARIANTS = [
|
|
22829
22753
|
{
|
|
@@ -22946,297 +22870,708 @@ var listMetaSchema = external_exports.object({
|
|
|
22946
22870
|
truncated: external_exports.boolean().optional()
|
|
22947
22871
|
});
|
|
22948
22872
|
|
|
22949
|
-
// ../shared/src/
|
|
22950
|
-
var
|
|
22951
|
-
|
|
22952
|
-
|
|
22953
|
-
|
|
22954
|
-
|
|
22955
|
-
|
|
22956
|
-
|
|
22957
|
-
|
|
22958
|
-
|
|
22959
|
-
|
|
22960
|
-
|
|
22961
|
-
},
|
|
22962
|
-
|
|
22963
|
-
|
|
22964
|
-
}
|
|
22965
|
-
|
|
22966
|
-
|
|
22967
|
-
|
|
22968
|
-
|
|
22969
|
-
|
|
22873
|
+
// ../shared/src/apiProfile.ts
|
|
22874
|
+
var apiTableAccessSchema = external_exports.object({
|
|
22875
|
+
table: external_exports.string(),
|
|
22876
|
+
read: external_exports.boolean(),
|
|
22877
|
+
/** Push to enabled webhook outputs. Missing/undefined = false (opt-in). */
|
|
22878
|
+
sync: external_exports.boolean().optional(),
|
|
22879
|
+
/**
|
|
22880
|
+
* Authenticated Studio/CMS editor write access for this table.
|
|
22881
|
+
* Missing/undefined = false (opt-in). Independent of public API-token propose.
|
|
22882
|
+
*/
|
|
22883
|
+
editorAccess: external_exports.boolean().optional(),
|
|
22884
|
+
propose: external_exports.object({
|
|
22885
|
+
ops: external_exports.object({ insert: external_exports.boolean(), update: external_exports.boolean(), delete: external_exports.boolean() }),
|
|
22886
|
+
allowedFields: external_exports.array(external_exports.string()).optional(),
|
|
22887
|
+
recordIds: external_exports.array(external_exports.string()).optional()
|
|
22888
|
+
}).optional(),
|
|
22889
|
+
autoAccept: external_exports.boolean().optional(),
|
|
22890
|
+
/**
|
|
22891
|
+
* Opaque row clamp: AND-merged with caller Query on Read API / guest lists.
|
|
22892
|
+
* Sync membership uses `rowQuery.predicates` only (order/search ignored; maxScanLimit ignored).
|
|
22893
|
+
*/
|
|
22894
|
+
rowQuery: clampQuerySchema.optional(),
|
|
22895
|
+
/** Scan ceiling for Read/guest list plans; callers may only lower. Not applied to Sync/Resync. */
|
|
22896
|
+
maxScanLimit: external_exports.number().int().positive().optional(),
|
|
22897
|
+
/**
|
|
22898
|
+
* Media source scope for the fixed `columnus_assets` source. Omit for all
|
|
22899
|
+
* live Media; an empty list intentionally grants no Media assets.
|
|
22900
|
+
*/
|
|
22901
|
+
assetProfiles: external_exports.array(external_exports.string().min(1)).max(100).optional(),
|
|
22902
|
+
/**
|
|
22903
|
+
* Media profiles an API token may attach to in-scope Media items
|
|
22904
|
+
* (`columnus_assets` only). Missing/empty = no token assignment.
|
|
22905
|
+
*/
|
|
22906
|
+
assignProfiles: external_exports.array(external_exports.string().min(1)).max(100).optional(),
|
|
22907
|
+
/**
|
|
22908
|
+
* Create new Media assets (upload/import) on the fixed `columnus_assets`
|
|
22909
|
+
* source. Missing/undefined = false. Does not imply Read, deletion, same-id
|
|
22910
|
+
* replacement, metadata edits, or assigning existing assets.
|
|
22911
|
+
*/
|
|
22912
|
+
write: external_exports.boolean().optional()
|
|
22913
|
+
});
|
|
22914
|
+
var apiProfileSnapshotSchema = external_exports.object({
|
|
22915
|
+
id: external_exports.string(),
|
|
22916
|
+
name: external_exports.string(),
|
|
22917
|
+
slug: external_exports.string(),
|
|
22918
|
+
tables: external_exports.array(external_exports.string()),
|
|
22919
|
+
tableAccess: external_exports.array(apiTableAccessSchema).optional(),
|
|
22920
|
+
autoAcceptProposals: external_exports.boolean().optional(),
|
|
22921
|
+
/** Hosted MCP endpoint for this profile. Missing/undefined = disabled (opt-in). */
|
|
22922
|
+
mcpEnabled: external_exports.boolean().optional(),
|
|
22923
|
+
apiVersion: external_exports.number(),
|
|
22924
|
+
updatedAt: external_exports.number()
|
|
22970
22925
|
});
|
|
22926
|
+
var apiProfilesSchema = external_exports.array(apiProfileSnapshotSchema);
|
|
22927
|
+
function editorAccessEnabled(access2) {
|
|
22928
|
+
return access2.editorAccess === true;
|
|
22929
|
+
}
|
|
22930
|
+
var MEDIA_LIBRARY_JOURNAL_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
22971
22931
|
|
|
22972
|
-
// ../shared/src/
|
|
22973
|
-
var
|
|
22974
|
-
|
|
22975
|
-
|
|
22976
|
-
|
|
22977
|
-
"
|
|
22978
|
-
"columnus_display_values",
|
|
22979
|
-
"columnus_api_profiles",
|
|
22980
|
-
"columnus_api_tokens",
|
|
22981
|
-
"columnus_api_outputs",
|
|
22982
|
-
"columnus_api_output_secrets",
|
|
22983
|
-
"columnus_api_sync_routes",
|
|
22984
|
-
"columnus_api_outbox",
|
|
22985
|
-
"columnus_api_delivery",
|
|
22986
|
-
"columnus_assets",
|
|
22987
|
-
"columnus_asset_versions",
|
|
22988
|
-
"columnus_asset_refs",
|
|
22989
|
-
"columnus_asset_profiles",
|
|
22990
|
-
"columnus_asset_settings",
|
|
22991
|
-
"columnus_asset_jobs"
|
|
22992
|
-
]);
|
|
22993
|
-
var displayTemplatesSchema = external_exports.object({
|
|
22994
|
-
id: external_exports.string().optional(),
|
|
22995
|
-
preview: external_exports.string().optional()
|
|
22996
|
-
});
|
|
22997
|
-
var TABLE_COLORS = [
|
|
22998
|
-
"brown",
|
|
22999
|
-
"muted-red",
|
|
23000
|
-
"red",
|
|
23001
|
-
"coral",
|
|
23002
|
-
"orange",
|
|
23003
|
-
"amber",
|
|
23004
|
-
"yellow",
|
|
23005
|
-
"gold",
|
|
23006
|
-
"blue",
|
|
23007
|
-
"light-blue",
|
|
23008
|
-
"cyan",
|
|
23009
|
-
"mint",
|
|
23010
|
-
"green",
|
|
23011
|
-
"dark-green",
|
|
23012
|
-
"lime",
|
|
23013
|
-
"light-green",
|
|
23014
|
-
"charcoal",
|
|
23015
|
-
"gray",
|
|
23016
|
-
"mauve",
|
|
23017
|
-
"pink",
|
|
23018
|
-
"purple",
|
|
23019
|
-
"deep-purple",
|
|
23020
|
-
"periwinkle",
|
|
23021
|
-
"lavender"
|
|
23022
|
-
];
|
|
23023
|
-
var tableColorSchema = external_exports.enum(TABLE_COLORS);
|
|
23024
|
-
var TABLE_KINDS = ["record", "asset"];
|
|
23025
|
-
var tableKindSchema = external_exports.enum(TABLE_KINDS);
|
|
23026
|
-
var assetBindingSchema = external_exports.object({
|
|
23027
|
-
profile: external_exports.string().min(1),
|
|
23028
|
-
enforced: external_exports.boolean().optional()
|
|
23029
|
-
});
|
|
23030
|
-
var fieldTypeSchema = external_exports.lazy(
|
|
23031
|
-
() => external_exports.discriminatedUnion("kind", [
|
|
23032
|
-
external_exports.object({ kind: external_exports.literal("string") }),
|
|
23033
|
-
external_exports.object({ kind: external_exports.literal("markdown") }),
|
|
23034
|
-
external_exports.object({ kind: external_exports.literal("number") }),
|
|
23035
|
-
external_exports.object({ kind: external_exports.literal("boolean") }),
|
|
23036
|
-
external_exports.object({ kind: external_exports.literal("bigint") }),
|
|
23037
|
-
external_exports.object({ kind: external_exports.literal("null") }),
|
|
23038
|
-
external_exports.object({ kind: external_exports.literal("any") }),
|
|
23039
|
-
external_exports.object({ kind: external_exports.literal("bytes") }),
|
|
23040
|
-
external_exports.object({ kind: external_exports.literal("file") }),
|
|
23041
|
-
external_exports.object({ kind: external_exports.literal("image") }),
|
|
23042
|
-
external_exports.object({ kind: external_exports.literal("date") }),
|
|
23043
|
-
external_exports.object({ kind: external_exports.literal("datetime") }),
|
|
23044
|
-
external_exports.object({ kind: external_exports.literal("id"), table: external_exports.string().regex(IDENT) }),
|
|
23045
|
-
external_exports.object({
|
|
23046
|
-
kind: external_exports.literal("literal"),
|
|
23047
|
-
value: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()])
|
|
23048
|
-
}),
|
|
23049
|
-
external_exports.object({ kind: external_exports.literal("array"), element: fieldTypeSchema }),
|
|
23050
|
-
external_exports.object({
|
|
23051
|
-
kind: external_exports.literal("object"),
|
|
23052
|
-
fields: external_exports.array(
|
|
23053
|
-
external_exports.object({
|
|
23054
|
-
name: external_exports.string().regex(IDENT),
|
|
23055
|
-
label: external_exports.string().optional(),
|
|
23056
|
-
type: fieldTypeSchema,
|
|
23057
|
-
optional: external_exports.boolean(),
|
|
23058
|
-
/** Nested image/file placements bind a Media profile like top-level ones. */
|
|
23059
|
-
asset: assetBindingSchema.optional()
|
|
23060
|
-
})
|
|
23061
|
-
)
|
|
23062
|
-
}),
|
|
23063
|
-
external_exports.object({
|
|
23064
|
-
kind: external_exports.literal("union"),
|
|
23065
|
-
options: external_exports.array(fieldTypeSchema).min(2)
|
|
23066
|
-
})
|
|
23067
|
-
])
|
|
23068
|
-
);
|
|
23069
|
-
var fieldSchema = external_exports.object({
|
|
23070
|
-
name: external_exports.string().regex(IDENT, "must be a valid identifier"),
|
|
23071
|
-
label: external_exports.string().optional(),
|
|
23072
|
-
type: fieldTypeSchema,
|
|
23073
|
-
optional: external_exports.boolean(),
|
|
23074
|
-
/** Image/file fields may pin a Media profile; existence is enforced at upload/pick. */
|
|
23075
|
-
asset: assetBindingSchema.optional()
|
|
23076
|
-
});
|
|
23077
|
-
var indexSchema = external_exports.object({
|
|
23078
|
-
name: external_exports.string().regex(IDENT),
|
|
23079
|
-
fields: external_exports.array(external_exports.string().regex(IDENT)).min(1)
|
|
23080
|
-
});
|
|
23081
|
-
var searchIndexSchema = external_exports.object({
|
|
23082
|
-
name: external_exports.string().regex(IDENT),
|
|
23083
|
-
searchField: external_exports.string().regex(IDENT),
|
|
23084
|
-
filterFields: external_exports.array(external_exports.string().regex(IDENT)).optional()
|
|
23085
|
-
});
|
|
23086
|
-
var tableSchema = external_exports.object({
|
|
23087
|
-
name: external_exports.string().regex(IDENT).refine((n) => !RESERVED_TABLE_NAMES.has(n), {
|
|
23088
|
-
message: "table name is reserved by the studio"
|
|
23089
|
-
}),
|
|
23090
|
-
label: external_exports.string().optional(),
|
|
23091
|
-
color: tableColorSchema.optional(),
|
|
23092
|
-
/** Asset metadata tables are typed root tables but never ordinary user records. */
|
|
23093
|
-
kind: tableKindSchema.optional().default("record"),
|
|
23094
|
-
fields: external_exports.array(fieldSchema),
|
|
23095
|
-
indexes: external_exports.array(indexSchema).default([]),
|
|
23096
|
-
searchIndexes: external_exports.array(searchIndexSchema).default([]),
|
|
23097
|
-
displayTemplates: displayTemplatesSchema.optional()
|
|
23098
|
-
});
|
|
23099
|
-
var manifestSchema = external_exports.object({
|
|
23100
|
-
tables: external_exports.array(tableSchema)
|
|
23101
|
-
}).superRefine((manifest, ctx) => {
|
|
23102
|
-
const tableNames = /* @__PURE__ */ new Set();
|
|
23103
|
-
const tablesByName = /* @__PURE__ */ new Map();
|
|
23104
|
-
for (const t of manifest.tables) {
|
|
23105
|
-
if (tableNames.has(t.name)) {
|
|
23106
|
-
ctx.addIssue({
|
|
23107
|
-
code: external_exports.ZodIssueCode.custom,
|
|
23108
|
-
message: `duplicate table: ${t.name}`,
|
|
23109
|
-
path: ["tables"]
|
|
23110
|
-
});
|
|
23111
|
-
}
|
|
23112
|
-
tableNames.add(t.name);
|
|
23113
|
-
tablesByName.set(t.name, t);
|
|
23114
|
-
if (tableKind(t) === "asset") {
|
|
23115
|
-
if (t.indexes.length > 0) {
|
|
23116
|
-
ctx.addIssue({
|
|
23117
|
-
code: external_exports.ZodIssueCode.custom,
|
|
23118
|
-
message: `${t.name} is an asset metadata table and cannot define indexes`,
|
|
23119
|
-
path: ["tables"]
|
|
23120
|
-
});
|
|
23121
|
-
}
|
|
23122
|
-
if (t.searchIndexes.length > 0) {
|
|
23123
|
-
ctx.addIssue({
|
|
23124
|
-
code: external_exports.ZodIssueCode.custom,
|
|
23125
|
-
message: `${t.name} is an asset metadata table and cannot define search indexes`,
|
|
23126
|
-
path: ["tables"]
|
|
23127
|
-
});
|
|
23128
|
-
}
|
|
23129
|
-
if (t.displayTemplates !== void 0) {
|
|
23130
|
-
ctx.addIssue({
|
|
23131
|
-
code: external_exports.ZodIssueCode.custom,
|
|
23132
|
-
message: `${t.name} is an asset metadata table and cannot define display templates`,
|
|
23133
|
-
path: ["tables"]
|
|
23134
|
-
});
|
|
23135
|
-
}
|
|
23136
|
-
if (t.color !== void 0) {
|
|
23137
|
-
ctx.addIssue({
|
|
23138
|
-
code: external_exports.ZodIssueCode.custom,
|
|
23139
|
-
message: `${t.name} is an asset metadata table and cannot define a color`,
|
|
23140
|
-
path: ["tables"]
|
|
23141
|
-
});
|
|
23142
|
-
}
|
|
23143
|
-
}
|
|
23144
|
-
const fieldNames = /* @__PURE__ */ new Set();
|
|
23145
|
-
for (const f of t.fields) {
|
|
23146
|
-
if (fieldNames.has(f.name)) {
|
|
23147
|
-
ctx.addIssue({
|
|
23148
|
-
code: external_exports.ZodIssueCode.custom,
|
|
23149
|
-
message: `duplicate field in ${t.name}: ${f.name}`,
|
|
23150
|
-
path: ["tables"]
|
|
23151
|
-
});
|
|
23152
|
-
}
|
|
23153
|
-
fieldNames.add(f.name);
|
|
23154
|
-
assertAssetBindingAllowed(ctx, t, f);
|
|
23155
|
-
}
|
|
23156
|
-
}
|
|
23157
|
-
for (const t of manifest.tables) {
|
|
23158
|
-
for (const f of t.fields) {
|
|
23159
|
-
const invalidRef = findInvalidReference(f, tablesByName);
|
|
23160
|
-
if (invalidRef) {
|
|
23161
|
-
ctx.addIssue({
|
|
23162
|
-
code: external_exports.ZodIssueCode.custom,
|
|
23163
|
-
message: `${t.name}.${f.name} ${invalidRef}`,
|
|
23164
|
-
path: ["tables"]
|
|
23165
|
-
});
|
|
23166
|
-
}
|
|
23167
|
-
}
|
|
23168
|
-
}
|
|
23169
|
-
});
|
|
23170
|
-
function findInvalidReference(field, tablesByName) {
|
|
23171
|
-
for (const { targetTable } of refEdges({ fields: [field] })) {
|
|
23172
|
-
const target = tablesByName.get(targetTable);
|
|
23173
|
-
if (!target) return `references unknown table: ${targetTable}`;
|
|
23174
|
-
if (tableKind(target) === "asset") {
|
|
23175
|
-
return `cannot reference asset metadata table: ${targetTable}`;
|
|
23176
|
-
}
|
|
23177
|
-
}
|
|
23178
|
-
return null;
|
|
23179
|
-
}
|
|
23180
|
-
function tableKind(table) {
|
|
23181
|
-
return table.kind ?? "record";
|
|
23182
|
-
}
|
|
23183
|
-
function isAssetTable(table) {
|
|
23184
|
-
return tableKind(table) === "asset";
|
|
23185
|
-
}
|
|
23186
|
-
function mediaKind(t) {
|
|
23187
|
-
const leaf = t.kind === "array" ? t.element : t;
|
|
23188
|
-
return leaf.kind === "file" || leaf.kind === "image" ? leaf.kind : null;
|
|
23189
|
-
}
|
|
23190
|
-
function isStorageFieldType(t) {
|
|
23191
|
-
return mediaKind(t) !== null;
|
|
22932
|
+
// ../shared/src/previewDeployName.ts
|
|
22933
|
+
var PREVIEW_DEPLOY_NAME_RE = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/;
|
|
22934
|
+
|
|
22935
|
+
// ../shared/src/refGraph.ts
|
|
22936
|
+
function isLeaf(type, leaf) {
|
|
22937
|
+
return leaf === "document" ? type.kind === "id" : hasKindTrait(type, "storage");
|
|
23192
22938
|
}
|
|
23193
|
-
function
|
|
23194
|
-
if (
|
|
23195
|
-
|
|
23196
|
-
|
|
23197
|
-
message: `${table.name}.${field.name} asset metadata fields cannot define a Media profile`,
|
|
23198
|
-
path: ["tables"]
|
|
23199
|
-
});
|
|
23200
|
-
} else if (field.asset && !isStorageFieldType(field.type)) {
|
|
23201
|
-
ctx.addIssue({
|
|
23202
|
-
code: external_exports.ZodIssueCode.custom,
|
|
23203
|
-
message: `${table.name}.${field.name} asset profile can only be set on image/file fields`,
|
|
23204
|
-
path: ["tables"]
|
|
23205
|
-
});
|
|
22939
|
+
function typeLeaves(type, leaf, at, out) {
|
|
22940
|
+
if (isLeaf(type, leaf)) {
|
|
22941
|
+
out.push({ type, ...at });
|
|
22942
|
+
return out;
|
|
23206
22943
|
}
|
|
23207
|
-
assertAssetBindingsInType(ctx, table, field.type);
|
|
23208
|
-
}
|
|
23209
|
-
function assertAssetBindingsInType(ctx, table, type) {
|
|
23210
22944
|
switch (type.kind) {
|
|
23211
22945
|
case "array":
|
|
23212
|
-
|
|
22946
|
+
typeLeaves(type.element, leaf, { ...at, path: `${at.path}[]`, many: true }, out);
|
|
23213
22947
|
break;
|
|
23214
22948
|
case "object":
|
|
23215
|
-
for (const f of type.fields)
|
|
22949
|
+
for (const f of type.fields) {
|
|
22950
|
+
const path5 = `${at.path}.${f.name}`;
|
|
22951
|
+
typeLeaves(f.type, leaf, { ...at, path: path5, depth: at.depth + 1, binding: f.asset }, out);
|
|
22952
|
+
}
|
|
23216
22953
|
break;
|
|
23217
22954
|
case "union":
|
|
23218
|
-
for (const
|
|
22955
|
+
for (const option of type.options)
|
|
22956
|
+
typeLeaves(option, leaf, { ...at, depth: at.depth + 1 }, out);
|
|
23219
22957
|
break;
|
|
23220
22958
|
default:
|
|
23221
22959
|
leafOnly(type);
|
|
23222
22960
|
}
|
|
22961
|
+
return out;
|
|
23223
22962
|
}
|
|
23224
|
-
|
|
23225
|
-
|
|
23226
|
-
|
|
23227
|
-
|
|
23228
|
-
|
|
23229
|
-
|
|
23230
|
-
|
|
23231
|
-
|
|
23232
|
-
|
|
23233
|
-
|
|
23234
|
-
|
|
23235
|
-
|
|
23236
|
-
|
|
23237
|
-
|
|
23238
|
-
|
|
23239
|
-
|
|
22963
|
+
var ROOT = { path: "", depth: 0, many: false, binding: void 0 };
|
|
22964
|
+
function compareEdges(a, b) {
|
|
22965
|
+
return a.field.localeCompare(b.field) || a.path.localeCompare(b.path) || a.targetTable.localeCompare(b.targetTable);
|
|
22966
|
+
}
|
|
22967
|
+
function fieldEdges(field) {
|
|
22968
|
+
return typeLeaves(field.type, "document", ROOT, []).map(({ type, path: path5, depth, many }) => ({
|
|
22969
|
+
field: field.name,
|
|
22970
|
+
path: path5,
|
|
22971
|
+
targetTable: type.table,
|
|
22972
|
+
many,
|
|
22973
|
+
depth
|
|
22974
|
+
}));
|
|
22975
|
+
}
|
|
22976
|
+
function refEdges(table) {
|
|
22977
|
+
const seen = /* @__PURE__ */ new Set();
|
|
22978
|
+
const edges = [];
|
|
22979
|
+
for (const field of table.fields) {
|
|
22980
|
+
for (const edge of fieldEdges(field)) {
|
|
22981
|
+
const key = `${edge.field}\0${edge.path}\0${edge.targetTable}`;
|
|
22982
|
+
if (seen.has(key)) continue;
|
|
22983
|
+
seen.add(key);
|
|
22984
|
+
edges.push(edge);
|
|
22985
|
+
}
|
|
22986
|
+
}
|
|
22987
|
+
return edges.sort(compareEdges);
|
|
22988
|
+
}
|
|
22989
|
+
|
|
22990
|
+
// ../shared/src/dataTransfer.ts
|
|
22991
|
+
var COLUMNUS_DATA_TRANSFER_VERSION = 1;
|
|
22992
|
+
var MAX_TRANSFER_BYTES = 50 * 1024 * 1024;
|
|
22993
|
+
function isProtectedTransferTable(table) {
|
|
22994
|
+
return table.startsWith("_") || table.startsWith("columnus_") || table.startsWith("studio_");
|
|
22995
|
+
}
|
|
22996
|
+
|
|
22997
|
+
// ../shared/src/bffProtocol.ts
|
|
22998
|
+
var COLUMNUS_BFF_PROTOCOL_VERSION = 1;
|
|
22999
|
+
var COLUMNUS_BFF_API_PREFIX = "/api/columnus/v1";
|
|
23000
|
+
var OPERATION_ID_RE = /^[A-Za-z0-9_-]{16,128}$/;
|
|
23001
|
+
var TRANSFER_ID_RE = /^[A-Za-z0-9_-]{16,64}$/;
|
|
23002
|
+
var MANIFEST_HASH_RE = /^[0-9a-f]{64}$/;
|
|
23003
|
+
var TABLE_NAME_RE = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
23004
|
+
var operationIdSchema = external_exports.string().regex(OPERATION_ID_RE);
|
|
23005
|
+
var transferIdSchema = external_exports.string().regex(TRANSFER_ID_RE);
|
|
23006
|
+
var manifestHashSchema = external_exports.string().regex(MANIFEST_HASH_RE);
|
|
23007
|
+
var bffPrepareOperationTypeSchema = external_exports.enum([
|
|
23008
|
+
"schemaDeploy",
|
|
23009
|
+
"dataExport",
|
|
23010
|
+
"dataImportPrepare",
|
|
23011
|
+
"dataImportCommit"
|
|
23012
|
+
]);
|
|
23013
|
+
var transferOperationSchema = external_exports.enum(["export", "import"]);
|
|
23014
|
+
var transferSessionStateSchema = external_exports.enum([
|
|
23015
|
+
"exportReady",
|
|
23016
|
+
"importAwaitingUpload",
|
|
23017
|
+
"importUploaded",
|
|
23018
|
+
"importCommitted",
|
|
23019
|
+
"importFailed",
|
|
23020
|
+
"expired"
|
|
23021
|
+
]);
|
|
23022
|
+
var schemaDeployPhaseSchema = external_exports.enum([
|
|
23023
|
+
"cleaning",
|
|
23024
|
+
"ready",
|
|
23025
|
+
"deploying",
|
|
23026
|
+
"succeeded",
|
|
23027
|
+
"failed"
|
|
23028
|
+
]);
|
|
23029
|
+
var SCHEMA_DEPLOY_OPERATION_LEASE_MS = 20 * 60 * 1e3;
|
|
23030
|
+
var transferTableSchema = external_exports.string().regex(TABLE_NAME_RE).refine((name) => !isProtectedTransferTable(name), {
|
|
23031
|
+
message: "Protected table cannot be transferred"
|
|
23032
|
+
});
|
|
23033
|
+
var dataTransferManifestSchema = external_exports.object({
|
|
23034
|
+
version: external_exports.literal(COLUMNUS_DATA_TRANSFER_VERSION),
|
|
23035
|
+
tables: external_exports.array(transferTableSchema).min(1),
|
|
23036
|
+
schemaHash: manifestHashSchema,
|
|
23037
|
+
includeFileStorage: external_exports.boolean()
|
|
23038
|
+
}).superRefine((value, ctx) => {
|
|
23039
|
+
if (new Set(value.tables).size !== value.tables.length) {
|
|
23040
|
+
ctx.addIssue({
|
|
23041
|
+
code: external_exports.ZodIssueCode.custom,
|
|
23042
|
+
message: "dataTransfer.tables must not contain duplicates",
|
|
23043
|
+
path: ["tables"]
|
|
23044
|
+
});
|
|
23045
|
+
}
|
|
23046
|
+
});
|
|
23047
|
+
var bffSchemaDeployRequestSchema = external_exports.object({
|
|
23048
|
+
operationId: operationIdSchema,
|
|
23049
|
+
manifestJson: external_exports.string().min(2).max(2e6)
|
|
23050
|
+
});
|
|
23051
|
+
var bffTransferScopeRequestSchema = external_exports.object({
|
|
23052
|
+
operationId: operationIdSchema,
|
|
23053
|
+
tables: external_exports.array(transferTableSchema).min(1),
|
|
23054
|
+
schemaHash: manifestHashSchema,
|
|
23055
|
+
includeFileStorage: external_exports.boolean()
|
|
23056
|
+
});
|
|
23057
|
+
var bffTransferCommitRequestSchema = external_exports.object({
|
|
23058
|
+
operationId: operationIdSchema,
|
|
23059
|
+
/** Client echo; server also rechecks the transfer-bound hash. */
|
|
23060
|
+
schemaHash: manifestHashSchema
|
|
23061
|
+
});
|
|
23062
|
+
var bffHealthResponseSchema = external_exports.object({
|
|
23063
|
+
ok: external_exports.boolean(),
|
|
23064
|
+
commit: external_exports.string(),
|
|
23065
|
+
executor: external_exports.object({
|
|
23066
|
+
ok: external_exports.boolean(),
|
|
23067
|
+
commit: external_exports.string().optional(),
|
|
23068
|
+
error: external_exports.string().optional()
|
|
23069
|
+
})
|
|
23070
|
+
});
|
|
23071
|
+
var bffActiveOperationMetaSchema = external_exports.object({
|
|
23072
|
+
operationId: operationIdSchema,
|
|
23073
|
+
desiredManifestHash: manifestHashSchema.optional(),
|
|
23074
|
+
phase: schemaDeployPhaseSchema.optional(),
|
|
23075
|
+
startedAt: external_exports.number().optional()
|
|
23076
|
+
});
|
|
23077
|
+
var bffSchemaDeployResponseSchema = external_exports.object({
|
|
23078
|
+
ok: external_exports.boolean(),
|
|
23079
|
+
operationId: operationIdSchema,
|
|
23080
|
+
phase: schemaDeployPhaseSchema,
|
|
23081
|
+
desiredManifestHash: manifestHashSchema.optional(),
|
|
23082
|
+
deployedManifestHash: manifestHashSchema.optional(),
|
|
23083
|
+
error: external_exports.string().optional(),
|
|
23084
|
+
logTail: external_exports.string().optional(),
|
|
23085
|
+
activeOperation: bffActiveOperationMetaSchema.optional()
|
|
23086
|
+
});
|
|
23087
|
+
var bffTransferCreateResponseSchema = external_exports.object({
|
|
23088
|
+
ok: external_exports.literal(true),
|
|
23089
|
+
transferId: transferIdSchema,
|
|
23090
|
+
expiresAt: external_exports.number().int().positive(),
|
|
23091
|
+
bytes: external_exports.number().int().nonnegative().optional()
|
|
23092
|
+
});
|
|
23093
|
+
var bffTransferCommitResponseSchema = external_exports.object({
|
|
23094
|
+
ok: external_exports.boolean(),
|
|
23095
|
+
transferId: transferIdSchema,
|
|
23096
|
+
error: external_exports.string().optional(),
|
|
23097
|
+
logTail: external_exports.string().optional()
|
|
23098
|
+
});
|
|
23099
|
+
var bffTransferUploadResponseSchema = external_exports.object({
|
|
23100
|
+
ok: external_exports.literal(true),
|
|
23101
|
+
bytes: external_exports.number().int().nonnegative()
|
|
23102
|
+
});
|
|
23103
|
+
var bffErrorCodeSchema = external_exports.enum([
|
|
23104
|
+
"unauthorized",
|
|
23105
|
+
"forbidden",
|
|
23106
|
+
"unknown_host",
|
|
23107
|
+
"disabled_host",
|
|
23108
|
+
"conflict",
|
|
23109
|
+
"executor_mismatch",
|
|
23110
|
+
"executor_unavailable",
|
|
23111
|
+
"validation_error",
|
|
23112
|
+
"not_found",
|
|
23113
|
+
"payload_too_large",
|
|
23114
|
+
"gone",
|
|
23115
|
+
"internal_error"
|
|
23116
|
+
]);
|
|
23117
|
+
var bffErrorResponseSchema = external_exports.object({
|
|
23118
|
+
ok: external_exports.literal(false),
|
|
23119
|
+
error: external_exports.string(),
|
|
23120
|
+
code: bffErrorCodeSchema.optional(),
|
|
23121
|
+
logTail: external_exports.string().optional(),
|
|
23122
|
+
activeOperation: bffActiveOperationMetaSchema.optional()
|
|
23123
|
+
});
|
|
23124
|
+
var bffPrepareOperationSchema = external_exports.discriminatedUnion("type", [
|
|
23125
|
+
external_exports.object({
|
|
23126
|
+
type: external_exports.literal("schemaDeploy"),
|
|
23127
|
+
operationId: operationIdSchema,
|
|
23128
|
+
manifestJson: external_exports.string().min(2).max(2e6)
|
|
23129
|
+
}),
|
|
23130
|
+
external_exports.object({
|
|
23131
|
+
type: external_exports.literal("dataExport"),
|
|
23132
|
+
operationId: operationIdSchema,
|
|
23133
|
+
transferManifest: dataTransferManifestSchema
|
|
23134
|
+
}),
|
|
23135
|
+
external_exports.object({
|
|
23136
|
+
type: external_exports.literal("dataImportPrepare"),
|
|
23137
|
+
operationId: operationIdSchema,
|
|
23138
|
+
transferManifest: dataTransferManifestSchema
|
|
23139
|
+
}),
|
|
23140
|
+
external_exports.object({
|
|
23141
|
+
type: external_exports.literal("dataImportCommit"),
|
|
23142
|
+
operationId: operationIdSchema,
|
|
23143
|
+
transferId: transferIdSchema,
|
|
23144
|
+
schemaHash: manifestHashSchema
|
|
23145
|
+
})
|
|
23146
|
+
]);
|
|
23147
|
+
var bffPrepareRequestSchema = external_exports.object({
|
|
23148
|
+
protocolVersion: external_exports.literal(COLUMNUS_BFF_PROTOCOL_VERSION),
|
|
23149
|
+
/** Trusted hostname only (already extracted by BFF). */
|
|
23150
|
+
host: external_exports.string().min(1),
|
|
23151
|
+
correlationId: external_exports.string().min(1).max(128).optional(),
|
|
23152
|
+
operation: bffPrepareOperationSchema
|
|
23153
|
+
});
|
|
23154
|
+
var bffPreparedTenantSchema = external_exports.object({
|
|
23155
|
+
slug: external_exports.string().min(1),
|
|
23156
|
+
convexUrl: external_exports.string().url(),
|
|
23157
|
+
authIssuer: external_exports.string().url().optional(),
|
|
23158
|
+
deploymentName: external_exports.string().optional()
|
|
23159
|
+
});
|
|
23160
|
+
var deployInternalSchemaDeployPayloadSchema = external_exports.object({
|
|
23161
|
+
manifestJson: external_exports.string().min(2),
|
|
23162
|
+
convexDeployKey: external_exports.string().min(1),
|
|
23163
|
+
convexUrl: external_exports.string().url(),
|
|
23164
|
+
authIssuer: external_exports.string().url().optional(),
|
|
23165
|
+
previewName: external_exports.string().nullable().optional(),
|
|
23166
|
+
operationId: operationIdSchema.optional()
|
|
23167
|
+
});
|
|
23168
|
+
var deployInternalTransferExportPayloadSchema = external_exports.object({
|
|
23169
|
+
transferManifest: dataTransferManifestSchema,
|
|
23170
|
+
convexDeployKey: external_exports.string().min(1),
|
|
23171
|
+
convexUrl: external_exports.string().url(),
|
|
23172
|
+
tenantSlug: external_exports.string().min(1),
|
|
23173
|
+
operationId: operationIdSchema
|
|
23174
|
+
});
|
|
23175
|
+
var deployInternalTransferImportPreparePayloadSchema = external_exports.object({
|
|
23176
|
+
transferManifest: dataTransferManifestSchema,
|
|
23177
|
+
convexDeployKey: external_exports.string().min(1),
|
|
23178
|
+
convexUrl: external_exports.string().url(),
|
|
23179
|
+
tenantSlug: external_exports.string().min(1),
|
|
23180
|
+
operationId: operationIdSchema
|
|
23181
|
+
});
|
|
23182
|
+
var deployInternalTransferCommitPayloadSchema = external_exports.object({
|
|
23183
|
+
transferId: transferIdSchema,
|
|
23184
|
+
convexDeployKey: external_exports.string().min(1),
|
|
23185
|
+
convexUrl: external_exports.string().url(),
|
|
23186
|
+
tenantSlug: external_exports.string().min(1),
|
|
23187
|
+
operationId: operationIdSchema,
|
|
23188
|
+
schemaHash: manifestHashSchema
|
|
23189
|
+
});
|
|
23190
|
+
var bffPreparedBodyEnvelopeBaseSchema = external_exports.object({
|
|
23191
|
+
protocolVersion: external_exports.literal(COLUMNUS_BFF_PROTOCOL_VERSION),
|
|
23192
|
+
tenant: bffPreparedTenantSchema,
|
|
23193
|
+
correlationId: external_exports.string().min(1).max(128).optional()
|
|
23194
|
+
});
|
|
23195
|
+
var bffPreparedBodyEnvelopeSchema = external_exports.discriminatedUnion("operation", [
|
|
23196
|
+
bffPreparedBodyEnvelopeBaseSchema.extend({
|
|
23197
|
+
operation: external_exports.literal("schemaDeploy"),
|
|
23198
|
+
payload: deployInternalSchemaDeployPayloadSchema
|
|
23199
|
+
}),
|
|
23200
|
+
bffPreparedBodyEnvelopeBaseSchema.extend({
|
|
23201
|
+
operation: external_exports.literal("dataExport"),
|
|
23202
|
+
payload: deployInternalTransferExportPayloadSchema
|
|
23203
|
+
}),
|
|
23204
|
+
bffPreparedBodyEnvelopeBaseSchema.extend({
|
|
23205
|
+
operation: external_exports.literal("dataImportPrepare"),
|
|
23206
|
+
payload: deployInternalTransferImportPreparePayloadSchema
|
|
23207
|
+
}),
|
|
23208
|
+
bffPreparedBodyEnvelopeBaseSchema.extend({
|
|
23209
|
+
operation: external_exports.literal("dataImportCommit"),
|
|
23210
|
+
payload: deployInternalTransferCommitPayloadSchema
|
|
23211
|
+
})
|
|
23212
|
+
]);
|
|
23213
|
+
var bffPreviewRegisterRequestSchema = external_exports.object({
|
|
23214
|
+
previewName: external_exports.string().regex(PREVIEW_DEPLOY_NAME_RE).optional(),
|
|
23215
|
+
hostname: external_exports.string().min(1),
|
|
23216
|
+
convexUrl: external_exports.string().url(),
|
|
23217
|
+
deployKey: external_exports.string().min(1),
|
|
23218
|
+
expectedCommit: external_exports.string().min(7).max(64),
|
|
23219
|
+
expiresAt: external_exports.number().int().positive()
|
|
23220
|
+
});
|
|
23221
|
+
var bffPreviewRemoveRequestSchema = external_exports.object({
|
|
23222
|
+
hostname: external_exports.string().min(1)
|
|
23223
|
+
});
|
|
23224
|
+
var transferSessionRecordSchema = external_exports.object({
|
|
23225
|
+
transferId: transferIdSchema,
|
|
23226
|
+
tenantSlug: external_exports.string().min(1),
|
|
23227
|
+
convexUrl: external_exports.string().url(),
|
|
23228
|
+
operation: transferOperationSchema,
|
|
23229
|
+
tables: external_exports.array(transferTableSchema).min(1),
|
|
23230
|
+
schemaHash: manifestHashSchema,
|
|
23231
|
+
includeFileStorage: external_exports.boolean(),
|
|
23232
|
+
maxBytes: external_exports.number().int().positive().max(MAX_TRANSFER_BYTES),
|
|
23233
|
+
expiresAt: external_exports.number().int().positive(),
|
|
23234
|
+
state: transferSessionStateSchema,
|
|
23235
|
+
operationId: operationIdSchema.optional(),
|
|
23236
|
+
bytes: external_exports.number().int().nonnegative().optional(),
|
|
23237
|
+
commitResult: external_exports.object({
|
|
23238
|
+
ok: external_exports.boolean(),
|
|
23239
|
+
error: external_exports.string().optional(),
|
|
23240
|
+
logTail: external_exports.string().optional()
|
|
23241
|
+
}).optional()
|
|
23242
|
+
});
|
|
23243
|
+
var deployInternalTransferCreateResponseSchema = external_exports.object({
|
|
23244
|
+
ok: external_exports.literal(true),
|
|
23245
|
+
transferId: transferIdSchema,
|
|
23246
|
+
expiresAt: external_exports.number().int().positive(),
|
|
23247
|
+
bytes: external_exports.number().int().nonnegative().optional()
|
|
23248
|
+
});
|
|
23249
|
+
var deployInternalSchemaDeployResponseSchema = external_exports.object({
|
|
23250
|
+
ok: external_exports.boolean(),
|
|
23251
|
+
durationMs: external_exports.number(),
|
|
23252
|
+
prepareMs: external_exports.number().optional(),
|
|
23253
|
+
cliMs: external_exports.number().optional(),
|
|
23254
|
+
kernelCommit: external_exports.string().optional(),
|
|
23255
|
+
error: external_exports.string().optional(),
|
|
23256
|
+
logTail: external_exports.string().optional()
|
|
23257
|
+
});
|
|
23258
|
+
var deployHealthResponseSchema = external_exports.object({
|
|
23259
|
+
ok: external_exports.boolean(),
|
|
23260
|
+
commit: external_exports.string().optional(),
|
|
23261
|
+
/** ISO-8601 deployment/image bake time (BRU-76 preview supersede). */
|
|
23262
|
+
deployedAt: external_exports.string().optional()
|
|
23263
|
+
});
|
|
23264
|
+
var BFF_JSON_BODY_LIMIT_BYTES = 2 * 1024 * 1024;
|
|
23265
|
+
|
|
23266
|
+
// ../shared/src/apiProfileSlug.ts
|
|
23267
|
+
function apiProfileSlugToConvexModuleSegment(slug) {
|
|
23268
|
+
return slug.replace(/-/g, "_");
|
|
23269
|
+
}
|
|
23270
|
+
|
|
23271
|
+
// ../shared/src/mcpOAuth.ts
|
|
23272
|
+
var MINUTE = 6e4;
|
|
23273
|
+
var MCP_OAUTH_REQUEST_TTL_MS = 10 * MINUTE;
|
|
23274
|
+
var MCP_OAUTH_CODE_TTL_MS = 10 * MINUTE;
|
|
23275
|
+
var MCP_OAUTH_ACCESS_TOKEN_TTL_MS = 60 * MINUTE;
|
|
23276
|
+
var MCP_OAUTH_REFRESH_TOKEN_TTL_MS = 30 * 24 * 60 * MINUTE;
|
|
23277
|
+
var MCP_OAUTH_UNUSED_CLIENT_TTL_MS = 7 * 24 * 60 * MINUTE;
|
|
23278
|
+
var MCP_ENDPOINT_PATH_PREFIX = `${COLUMNUS_BFF_API_PREFIX}/mcp/`;
|
|
23279
|
+
var MCP_OAUTH_PATH_PREFIX = `${COLUMNUS_BFF_API_PREFIX}/oauth`;
|
|
23280
|
+
|
|
23281
|
+
// ../shared/src/queryPlan.ts
|
|
23282
|
+
import { compareValues } from "convex/values";
|
|
23283
|
+
|
|
23284
|
+
// ../shared/src/richDoc.ts
|
|
23285
|
+
var RICH_DOC_FORMAT = "blocknote";
|
|
23286
|
+
var RICH_DOC_VERSION = 1;
|
|
23287
|
+
var EMPTY_BLOCK_ID = "00000000-0000-4000-8000-000000000001";
|
|
23288
|
+
function emptyParagraphBlock() {
|
|
23289
|
+
return {
|
|
23290
|
+
id: EMPTY_BLOCK_ID,
|
|
23291
|
+
type: "paragraph",
|
|
23292
|
+
props: {
|
|
23293
|
+
backgroundColor: "default",
|
|
23294
|
+
textColor: "default",
|
|
23295
|
+
textAlignment: "left"
|
|
23296
|
+
},
|
|
23297
|
+
content: [],
|
|
23298
|
+
children: []
|
|
23299
|
+
};
|
|
23300
|
+
}
|
|
23301
|
+
var EMPTY_RICH_DOC = JSON.stringify({
|
|
23302
|
+
format: RICH_DOC_FORMAT,
|
|
23303
|
+
version: RICH_DOC_VERSION,
|
|
23304
|
+
blocks: [emptyParagraphBlock()]
|
|
23305
|
+
});
|
|
23306
|
+
|
|
23307
|
+
// ../shared/src/schemaTypes.ts
|
|
23308
|
+
var IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
23309
|
+
var RESERVED_TABLE_NAMES = /* @__PURE__ */ new Set([
|
|
23310
|
+
"columnus_audit_log",
|
|
23311
|
+
"columnus_spaces",
|
|
23312
|
+
"columnus_manifest",
|
|
23313
|
+
"columnus_display_values",
|
|
23314
|
+
"columnus_api_profiles",
|
|
23315
|
+
"columnus_api_tokens",
|
|
23316
|
+
"columnus_api_outputs",
|
|
23317
|
+
"columnus_api_output_secrets",
|
|
23318
|
+
"columnus_api_sync_routes",
|
|
23319
|
+
"columnus_api_outbox",
|
|
23320
|
+
"columnus_api_delivery",
|
|
23321
|
+
"columnus_assets",
|
|
23322
|
+
"columnus_asset_versions",
|
|
23323
|
+
"columnus_asset_refs",
|
|
23324
|
+
"columnus_asset_profiles",
|
|
23325
|
+
"columnus_asset_settings",
|
|
23326
|
+
"columnus_asset_jobs"
|
|
23327
|
+
]);
|
|
23328
|
+
var displayTemplatesSchema = external_exports.object({
|
|
23329
|
+
id: external_exports.string().optional(),
|
|
23330
|
+
preview: external_exports.string().optional()
|
|
23331
|
+
});
|
|
23332
|
+
var TABLE_COLORS = [
|
|
23333
|
+
"brown",
|
|
23334
|
+
"muted-red",
|
|
23335
|
+
"red",
|
|
23336
|
+
"coral",
|
|
23337
|
+
"orange",
|
|
23338
|
+
"amber",
|
|
23339
|
+
"yellow",
|
|
23340
|
+
"gold",
|
|
23341
|
+
"blue",
|
|
23342
|
+
"light-blue",
|
|
23343
|
+
"cyan",
|
|
23344
|
+
"mint",
|
|
23345
|
+
"green",
|
|
23346
|
+
"dark-green",
|
|
23347
|
+
"lime",
|
|
23348
|
+
"light-green",
|
|
23349
|
+
"charcoal",
|
|
23350
|
+
"gray",
|
|
23351
|
+
"mauve",
|
|
23352
|
+
"pink",
|
|
23353
|
+
"purple",
|
|
23354
|
+
"deep-purple",
|
|
23355
|
+
"periwinkle",
|
|
23356
|
+
"lavender"
|
|
23357
|
+
];
|
|
23358
|
+
var tableColorSchema = external_exports.enum(TABLE_COLORS);
|
|
23359
|
+
var TABLE_KINDS = ["record", "asset"];
|
|
23360
|
+
var tableKindSchema = external_exports.enum(TABLE_KINDS);
|
|
23361
|
+
var assetBindingSchema = external_exports.object({
|
|
23362
|
+
profile: external_exports.string().min(1),
|
|
23363
|
+
enforced: external_exports.boolean().optional()
|
|
23364
|
+
});
|
|
23365
|
+
var fieldTypeSchema = external_exports.lazy(
|
|
23366
|
+
() => external_exports.discriminatedUnion("kind", [
|
|
23367
|
+
external_exports.object({ kind: external_exports.literal("string") }),
|
|
23368
|
+
external_exports.object({ kind: external_exports.literal("markdown") }),
|
|
23369
|
+
external_exports.object({ kind: external_exports.literal("number") }),
|
|
23370
|
+
external_exports.object({ kind: external_exports.literal("boolean") }),
|
|
23371
|
+
external_exports.object({ kind: external_exports.literal("bigint") }),
|
|
23372
|
+
external_exports.object({ kind: external_exports.literal("null") }),
|
|
23373
|
+
external_exports.object({ kind: external_exports.literal("any") }),
|
|
23374
|
+
external_exports.object({ kind: external_exports.literal("bytes") }),
|
|
23375
|
+
external_exports.object({ kind: external_exports.literal("file") }),
|
|
23376
|
+
external_exports.object({ kind: external_exports.literal("image") }),
|
|
23377
|
+
external_exports.object({ kind: external_exports.literal("date") }),
|
|
23378
|
+
external_exports.object({ kind: external_exports.literal("datetime") }),
|
|
23379
|
+
external_exports.object({ kind: external_exports.literal("id"), table: external_exports.string().regex(IDENT) }),
|
|
23380
|
+
external_exports.object({
|
|
23381
|
+
kind: external_exports.literal("literal"),
|
|
23382
|
+
value: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()])
|
|
23383
|
+
}),
|
|
23384
|
+
external_exports.object({ kind: external_exports.literal("array"), element: fieldTypeSchema }),
|
|
23385
|
+
external_exports.object({
|
|
23386
|
+
kind: external_exports.literal("object"),
|
|
23387
|
+
fields: external_exports.array(
|
|
23388
|
+
external_exports.object({
|
|
23389
|
+
name: external_exports.string().regex(IDENT),
|
|
23390
|
+
label: external_exports.string().optional(),
|
|
23391
|
+
type: fieldTypeSchema,
|
|
23392
|
+
optional: external_exports.boolean(),
|
|
23393
|
+
/** Nested image/file placements bind a Media profile like top-level ones. */
|
|
23394
|
+
asset: assetBindingSchema.optional()
|
|
23395
|
+
})
|
|
23396
|
+
)
|
|
23397
|
+
}),
|
|
23398
|
+
external_exports.object({
|
|
23399
|
+
kind: external_exports.literal("union"),
|
|
23400
|
+
options: external_exports.array(fieldTypeSchema).min(2)
|
|
23401
|
+
})
|
|
23402
|
+
])
|
|
23403
|
+
);
|
|
23404
|
+
var fieldSchema = external_exports.object({
|
|
23405
|
+
name: external_exports.string().regex(IDENT, "must be a valid identifier"),
|
|
23406
|
+
label: external_exports.string().optional(),
|
|
23407
|
+
type: fieldTypeSchema,
|
|
23408
|
+
optional: external_exports.boolean(),
|
|
23409
|
+
/** Image/file fields may pin a Media profile; existence is enforced at upload/pick. */
|
|
23410
|
+
asset: assetBindingSchema.optional()
|
|
23411
|
+
});
|
|
23412
|
+
var indexSchema = external_exports.object({
|
|
23413
|
+
name: external_exports.string().regex(IDENT),
|
|
23414
|
+
fields: external_exports.array(external_exports.string().regex(IDENT)).min(1)
|
|
23415
|
+
});
|
|
23416
|
+
var searchIndexSchema = external_exports.object({
|
|
23417
|
+
name: external_exports.string().regex(IDENT),
|
|
23418
|
+
searchField: external_exports.string().regex(IDENT),
|
|
23419
|
+
filterFields: external_exports.array(external_exports.string().regex(IDENT)).optional()
|
|
23420
|
+
});
|
|
23421
|
+
var tableSchema = external_exports.object({
|
|
23422
|
+
name: external_exports.string().regex(IDENT).refine((n) => !RESERVED_TABLE_NAMES.has(n), {
|
|
23423
|
+
message: "table name is reserved by the studio"
|
|
23424
|
+
}),
|
|
23425
|
+
label: external_exports.string().optional(),
|
|
23426
|
+
color: tableColorSchema.optional(),
|
|
23427
|
+
/** Asset metadata tables are typed root tables but never ordinary user records. */
|
|
23428
|
+
kind: tableKindSchema.optional().default("record"),
|
|
23429
|
+
fields: external_exports.array(fieldSchema),
|
|
23430
|
+
indexes: external_exports.array(indexSchema).default([]),
|
|
23431
|
+
searchIndexes: external_exports.array(searchIndexSchema).default([]),
|
|
23432
|
+
displayTemplates: displayTemplatesSchema.optional()
|
|
23433
|
+
});
|
|
23434
|
+
var manifestSchema = external_exports.object({
|
|
23435
|
+
tables: external_exports.array(tableSchema)
|
|
23436
|
+
}).superRefine((manifest, ctx) => {
|
|
23437
|
+
const tableNames = /* @__PURE__ */ new Set();
|
|
23438
|
+
const tablesByName = /* @__PURE__ */ new Map();
|
|
23439
|
+
for (const t of manifest.tables) {
|
|
23440
|
+
if (tableNames.has(t.name)) {
|
|
23441
|
+
ctx.addIssue({
|
|
23442
|
+
code: external_exports.ZodIssueCode.custom,
|
|
23443
|
+
message: `duplicate table: ${t.name}`,
|
|
23444
|
+
path: ["tables"]
|
|
23445
|
+
});
|
|
23446
|
+
}
|
|
23447
|
+
tableNames.add(t.name);
|
|
23448
|
+
tablesByName.set(t.name, t);
|
|
23449
|
+
if (tableKind(t) === "asset") {
|
|
23450
|
+
if (t.indexes.length > 0) {
|
|
23451
|
+
ctx.addIssue({
|
|
23452
|
+
code: external_exports.ZodIssueCode.custom,
|
|
23453
|
+
message: `${t.name} is an asset metadata table and cannot define indexes`,
|
|
23454
|
+
path: ["tables"]
|
|
23455
|
+
});
|
|
23456
|
+
}
|
|
23457
|
+
if (t.searchIndexes.length > 0) {
|
|
23458
|
+
ctx.addIssue({
|
|
23459
|
+
code: external_exports.ZodIssueCode.custom,
|
|
23460
|
+
message: `${t.name} is an asset metadata table and cannot define search indexes`,
|
|
23461
|
+
path: ["tables"]
|
|
23462
|
+
});
|
|
23463
|
+
}
|
|
23464
|
+
if (t.displayTemplates !== void 0) {
|
|
23465
|
+
ctx.addIssue({
|
|
23466
|
+
code: external_exports.ZodIssueCode.custom,
|
|
23467
|
+
message: `${t.name} is an asset metadata table and cannot define display templates`,
|
|
23468
|
+
path: ["tables"]
|
|
23469
|
+
});
|
|
23470
|
+
}
|
|
23471
|
+
if (t.color !== void 0) {
|
|
23472
|
+
ctx.addIssue({
|
|
23473
|
+
code: external_exports.ZodIssueCode.custom,
|
|
23474
|
+
message: `${t.name} is an asset metadata table and cannot define a color`,
|
|
23475
|
+
path: ["tables"]
|
|
23476
|
+
});
|
|
23477
|
+
}
|
|
23478
|
+
}
|
|
23479
|
+
const fieldNames = /* @__PURE__ */ new Set();
|
|
23480
|
+
for (const f of t.fields) {
|
|
23481
|
+
if (fieldNames.has(f.name)) {
|
|
23482
|
+
ctx.addIssue({
|
|
23483
|
+
code: external_exports.ZodIssueCode.custom,
|
|
23484
|
+
message: `duplicate field in ${t.name}: ${f.name}`,
|
|
23485
|
+
path: ["tables"]
|
|
23486
|
+
});
|
|
23487
|
+
}
|
|
23488
|
+
fieldNames.add(f.name);
|
|
23489
|
+
assertAssetBindingAllowed(ctx, t, f);
|
|
23490
|
+
}
|
|
23491
|
+
}
|
|
23492
|
+
for (const t of manifest.tables) {
|
|
23493
|
+
for (const f of t.fields) {
|
|
23494
|
+
const invalidRef = findInvalidReference(f, tablesByName);
|
|
23495
|
+
if (invalidRef) {
|
|
23496
|
+
ctx.addIssue({
|
|
23497
|
+
code: external_exports.ZodIssueCode.custom,
|
|
23498
|
+
message: `${t.name}.${f.name} ${invalidRef}`,
|
|
23499
|
+
path: ["tables"]
|
|
23500
|
+
});
|
|
23501
|
+
}
|
|
23502
|
+
}
|
|
23503
|
+
}
|
|
23504
|
+
});
|
|
23505
|
+
function findInvalidReference(field, tablesByName) {
|
|
23506
|
+
for (const { targetTable } of refEdges({ fields: [field] })) {
|
|
23507
|
+
const target = tablesByName.get(targetTable);
|
|
23508
|
+
if (!target) return `references unknown table: ${targetTable}`;
|
|
23509
|
+
if (tableKind(target) === "asset") {
|
|
23510
|
+
return `cannot reference asset metadata table: ${targetTable}`;
|
|
23511
|
+
}
|
|
23512
|
+
}
|
|
23513
|
+
return null;
|
|
23514
|
+
}
|
|
23515
|
+
function tableKind(table) {
|
|
23516
|
+
return table.kind ?? "record";
|
|
23517
|
+
}
|
|
23518
|
+
function isAssetTable(table) {
|
|
23519
|
+
return tableKind(table) === "asset";
|
|
23520
|
+
}
|
|
23521
|
+
function mediaKind(t) {
|
|
23522
|
+
const leaf = t.kind === "array" ? t.element : t;
|
|
23523
|
+
return leaf.kind === "file" || leaf.kind === "image" ? leaf.kind : null;
|
|
23524
|
+
}
|
|
23525
|
+
function isStorageFieldType(t) {
|
|
23526
|
+
return mediaKind(t) !== null;
|
|
23527
|
+
}
|
|
23528
|
+
function assertAssetBindingAllowed(ctx, table, field) {
|
|
23529
|
+
if (field.asset && tableKind(table) === "asset") {
|
|
23530
|
+
ctx.addIssue({
|
|
23531
|
+
code: external_exports.ZodIssueCode.custom,
|
|
23532
|
+
message: `${table.name}.${field.name} asset metadata fields cannot define a Media profile`,
|
|
23533
|
+
path: ["tables"]
|
|
23534
|
+
});
|
|
23535
|
+
} else if (field.asset && !isStorageFieldType(field.type)) {
|
|
23536
|
+
ctx.addIssue({
|
|
23537
|
+
code: external_exports.ZodIssueCode.custom,
|
|
23538
|
+
message: `${table.name}.${field.name} asset profile can only be set on image/file fields`,
|
|
23539
|
+
path: ["tables"]
|
|
23540
|
+
});
|
|
23541
|
+
}
|
|
23542
|
+
assertAssetBindingsInType(ctx, table, field.type);
|
|
23543
|
+
}
|
|
23544
|
+
function assertAssetBindingsInType(ctx, table, type) {
|
|
23545
|
+
switch (type.kind) {
|
|
23546
|
+
case "array":
|
|
23547
|
+
assertAssetBindingsInType(ctx, table, type.element);
|
|
23548
|
+
break;
|
|
23549
|
+
case "object":
|
|
23550
|
+
for (const f of type.fields) assertAssetBindingAllowed(ctx, table, f);
|
|
23551
|
+
break;
|
|
23552
|
+
case "union":
|
|
23553
|
+
for (const o of type.options) assertAssetBindingsInType(ctx, table, o);
|
|
23554
|
+
break;
|
|
23555
|
+
default:
|
|
23556
|
+
leafOnly(type);
|
|
23557
|
+
}
|
|
23558
|
+
}
|
|
23559
|
+
|
|
23560
|
+
// ../shared/src/fieldTypeText.ts
|
|
23561
|
+
function foldFieldType(type, fold) {
|
|
23562
|
+
switch (type.kind) {
|
|
23563
|
+
case "array":
|
|
23564
|
+
return fold.array(foldFieldType(type.element, fold), type);
|
|
23565
|
+
case "object":
|
|
23566
|
+
return fold.object(
|
|
23567
|
+
type.fields.map((field) => ({ field, value: foldFieldType(field.type, fold) })),
|
|
23568
|
+
type
|
|
23569
|
+
);
|
|
23570
|
+
case "union":
|
|
23571
|
+
return fold.union(
|
|
23572
|
+
type.options.map((option) => foldFieldType(option, fold)),
|
|
23573
|
+
type
|
|
23574
|
+
);
|
|
23240
23575
|
default:
|
|
23241
23576
|
return fold.leaf(type);
|
|
23242
23577
|
}
|
|
@@ -23534,56 +23869,21 @@ function renderType(t) {
|
|
|
23534
23869
|
});
|
|
23535
23870
|
}
|
|
23536
23871
|
|
|
23537
|
-
// ../shared/src/
|
|
23538
|
-
|
|
23539
|
-
|
|
23540
|
-
|
|
23541
|
-
|
|
23542
|
-
|
|
23543
|
-
|
|
23544
|
-
|
|
23545
|
-
|
|
23546
|
-
|
|
23547
|
-
|
|
23548
|
-
|
|
23549
|
-
|
|
23550
|
-
|
|
23551
|
-
recordIds: external_exports.array(external_exports.string()).optional()
|
|
23552
|
-
}).optional(),
|
|
23553
|
-
autoAccept: external_exports.boolean().optional(),
|
|
23554
|
-
/**
|
|
23555
|
-
* Opaque row clamp: AND-merged with caller Query on Read API / guest lists.
|
|
23556
|
-
* Sync membership uses `rowQuery.predicates` only (order/search ignored; maxScanLimit ignored).
|
|
23557
|
-
*/
|
|
23558
|
-
rowQuery: clampQuerySchema.optional(),
|
|
23559
|
-
/** Scan ceiling for Read/guest list plans; callers may only lower. Not applied to Sync/Resync. */
|
|
23560
|
-
maxScanLimit: external_exports.number().int().positive().optional(),
|
|
23561
|
-
/**
|
|
23562
|
-
* Media source scope for the fixed `columnus_assets` source. Omit for all
|
|
23563
|
-
* live Media; an empty list intentionally grants no Media assets.
|
|
23564
|
-
*/
|
|
23565
|
-
assetProfiles: external_exports.array(external_exports.string().min(1)).max(100).optional(),
|
|
23566
|
-
/**
|
|
23567
|
-
* Media profiles an API token may attach to in-scope Media items
|
|
23568
|
-
* (`columnus_assets` only). Missing/empty = no token assignment.
|
|
23569
|
-
*/
|
|
23570
|
-
assignProfiles: external_exports.array(external_exports.string().min(1)).max(100).optional()
|
|
23571
|
-
});
|
|
23572
|
-
var apiProfileSnapshotSchema = external_exports.object({
|
|
23573
|
-
id: external_exports.string(),
|
|
23574
|
-
name: external_exports.string(),
|
|
23575
|
-
slug: external_exports.string(),
|
|
23576
|
-
tables: external_exports.array(external_exports.string()),
|
|
23577
|
-
tableAccess: external_exports.array(apiTableAccessSchema).optional(),
|
|
23578
|
-
autoAcceptProposals: external_exports.boolean().optional(),
|
|
23579
|
-
apiVersion: external_exports.number(),
|
|
23580
|
-
updatedAt: external_exports.number()
|
|
23581
|
-
});
|
|
23582
|
-
var apiProfilesSchema = external_exports.array(apiProfileSnapshotSchema);
|
|
23583
|
-
function editorAccessEnabled(access2) {
|
|
23584
|
-
return access2.editorAccess === true;
|
|
23872
|
+
// ../shared/src/readApiQuery.ts
|
|
23873
|
+
function readApiQueryExportName(kind, tableName) {
|
|
23874
|
+
return `${kind}${tableName}`;
|
|
23875
|
+
}
|
|
23876
|
+
function proposeApiExportName(op, tableName) {
|
|
23877
|
+
return `propose${op[0].toUpperCase()}${op.slice(1)}${tableName}`;
|
|
23878
|
+
}
|
|
23879
|
+
function readApiQueryModuleSegment(profileSlug) {
|
|
23880
|
+
return apiProfileSlugToConvexModuleSegment(profileSlug);
|
|
23881
|
+
}
|
|
23882
|
+
function readApiAnyApiPath(profileSlug, kind, tableName) {
|
|
23883
|
+
const segment = readApiQueryModuleSegment(profileSlug);
|
|
23884
|
+
const exportName = readApiQueryExportName(kind, tableName);
|
|
23885
|
+
return `anyApi.columnus.read.${segment}.${exportName}.${exportName}`;
|
|
23585
23886
|
}
|
|
23586
|
-
var MEDIA_LIBRARY_JOURNAL_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
23587
23887
|
|
|
23588
23888
|
// ../api-codegen/src/generate-documents.ts
|
|
23589
23889
|
function fieldToTsProperty(field) {
|
|
@@ -23897,20 +24197,31 @@ export type ProfileProposalSummary = {
|
|
|
23897
24197
|
createdByUserId?: string;
|
|
23898
24198
|
baselineManifestHash: string;
|
|
23899
24199
|
createdAt: number;
|
|
24200
|
+
/** Revision of a protected shared draft; pass it back when publishing. */
|
|
24201
|
+
draftRevision?: number;
|
|
23900
24202
|
patches: ProfileProposalPatchSummary[];
|
|
23901
24203
|
};
|
|
23902
24204
|
|
|
24205
|
+
export type ProfileDraftSaveResult = {
|
|
24206
|
+
proposalId: string;
|
|
24207
|
+
status: "active" | "withdrawn";
|
|
24208
|
+
revision?: number;
|
|
24209
|
+
};
|
|
24210
|
+
|
|
23903
24211
|
export type ProfileProposalOutcome = {
|
|
23904
24212
|
id: string;
|
|
23905
24213
|
outcome: "accepted" | "rejected" | "skipped_stale" | "skipped_overlap";
|
|
23906
24214
|
message?: string;
|
|
23907
24215
|
};
|
|
23908
24216
|
|
|
23909
|
-
export const proposeProfileBatchRef = anyApi.columnus.share.proposeProfileBatch as FunctionReference<"mutation", "public", { profileSlug: string; patches: ProfileProposalPatch[]
|
|
24217
|
+
export const proposeProfileBatchRef = anyApi.columnus.share.proposeProfileBatch as FunctionReference<"mutation", "public", { profileSlug: string; patches: ProfileProposalPatch[]; expectedRevision?: number }, ProfileDraftSaveResult>;
|
|
24218
|
+
|
|
24219
|
+
/** Merge changed rows into the caller's shared draft (concurrent-safe Save). */
|
|
24220
|
+
export const saveMyProfileDraftRef = anyApi.columnus.share.saveMyProfileDraft as FunctionReference<"mutation", "public", { profileSlug: string; patches: Array<ProfileProposalPatch & { clearFields?: string[] }>; discard?: Array<{ table: string; rowId: string }> }, ProfileDraftSaveResult>;
|
|
23910
24221
|
|
|
23911
24222
|
export const listProfileProposalsRef = anyApi.columnus.share.listProfileProposals as FunctionReference<"query", "public", { profileSlug: string }, ProfileProposalSummary[]>;
|
|
23912
24223
|
|
|
23913
|
-
export const publishMyProfileProposalRef = anyApi.columnus.share.publishMyProfileProposal as FunctionReference<"mutation", "public", { profileSlug: string }, ProfileProposalOutcome[]>;
|
|
24224
|
+
export const publishMyProfileProposalRef = anyApi.columnus.share.publishMyProfileProposal as FunctionReference<"mutation", "public", { profileSlug: string; expectedRevision?: number }, ProfileProposalOutcome[]>;
|
|
23914
24225
|
|
|
23915
24226
|
export const withdrawMyProfileProposalRef = anyApi.columnus.share.withdrawMyProfileProposal as FunctionReference<"mutation", "public", { profileSlug: string }, { id: string; status: "withdrawn" }>;
|
|
23916
24227
|
|
|
@@ -24040,6 +24351,7 @@ export const getRowsByIdsRef = anyApi.columnus.rows.getRowsByIds as FunctionRefe
|
|
|
24040
24351
|
|
|
24041
24352
|
export const cmsHostRefs = {
|
|
24042
24353
|
proposeProfileBatch: proposeProfileBatchRef,
|
|
24354
|
+
saveMyProfileDraft: saveMyProfileDraftRef,
|
|
24043
24355
|
listProfileProposals: listProfileProposalsRef,
|
|
24044
24356
|
publishMyProfileProposal: publishMyProfileProposalRef,
|
|
24045
24357
|
withdrawMyProfileProposal: withdrawMyProfileProposalRef,
|
|
@@ -24110,530 +24422,305 @@ import type { DocByTable, TableName } from "./documents.js";
|
|
|
24110
24422
|
|
|
24111
24423
|
export function toDocumentId(value: unknown): string | undefined {
|
|
24112
24424
|
if (value === undefined || value === null || value === "") return undefined;
|
|
24113
|
-
return typeof value === "string" ? value : String(value);
|
|
24114
|
-
}
|
|
24115
|
-
|
|
24116
|
-
function isAssetFieldType(type: ManifestFieldType): boolean {
|
|
24117
|
-
return type.kind === "file" || type.kind === "image";
|
|
24118
|
-
}
|
|
24119
|
-
|
|
24120
|
-
function isAssetArrayFieldType(type: ManifestFieldType): boolean {
|
|
24121
|
-
return type.kind === "array" && (type.element.kind === "file" || type.element.kind === "image");
|
|
24122
|
-
}
|
|
24123
|
-
|
|
24124
|
-
function isAssetFieldOrArray(type: ManifestFieldType): boolean {
|
|
24125
|
-
return isAssetFieldType(type) || isAssetArrayFieldType(type);
|
|
24126
|
-
}
|
|
24127
|
-
|
|
24128
|
-
export function collectAssetIds(
|
|
24129
|
-
value: unknown,
|
|
24130
|
-
type: ManifestFieldType,
|
|
24131
|
-
out: Set<string> = new Set(),
|
|
24132
|
-
): Set<string> {
|
|
24133
|
-
if (isAssetFieldType(type)) {
|
|
24134
|
-
const id = toDocumentId(value);
|
|
24135
|
-
if (id) out.add(id);
|
|
24136
|
-
return out;
|
|
24137
|
-
}
|
|
24138
|
-
if (isAssetArrayFieldType(type) && Array.isArray(value)) {
|
|
24139
|
-
for (const item of value) {
|
|
24140
|
-
const id = toDocumentId(item);
|
|
24141
|
-
if (id) out.add(id);
|
|
24142
|
-
}
|
|
24143
|
-
}
|
|
24144
|
-
return out;
|
|
24145
|
-
}
|
|
24146
|
-
|
|
24147
|
-
export function collectAssetIdsFromRow<T extends TableName>(
|
|
24148
|
-
row: DocByTable[T] | undefined,
|
|
24149
|
-
fields: readonly ManifestField[],
|
|
24150
|
-
out: Set<string> = new Set(),
|
|
24151
|
-
): Set<string> {
|
|
24152
|
-
if (!row) return out;
|
|
24153
|
-
const values = row as Record<string, unknown>;
|
|
24154
|
-
for (const field of fields) {
|
|
24155
|
-
if (!isAssetFieldOrArray(field.type)) continue;
|
|
24156
|
-
collectAssetIds(values[field.name], field.type, out);
|
|
24157
|
-
}
|
|
24158
|
-
return out;
|
|
24159
|
-
}
|
|
24160
|
-
`;
|
|
24161
|
-
}
|
|
24162
|
-
function generateReadApiMetaTs(profileSlug, apiVersion, manifestHash) {
|
|
24163
|
-
return `${READ_API_BANNER}/** Compile-time snapshot from the last \`columnus-api pull\`. */
|
|
24164
|
-
export const PULLED_PROFILE_SLUG = ${JSON.stringify(profileSlug)} as const;
|
|
24165
|
-
export const PULLED_API_VERSION = ${apiVersion} as const;
|
|
24166
|
-
export const PULLED_MANIFEST_HASH = ${JSON.stringify(manifestHash)} as const;
|
|
24167
|
-
`;
|
|
24168
|
-
}
|
|
24169
|
-
function generateReadApiTokenTs() {
|
|
24170
|
-
return `${READ_API_BANNER}export function readApiToken(): string {
|
|
24171
|
-
const token = import.meta.env.VITE_COLUMNUS_API_TOKEN;
|
|
24172
|
-
if (!token || typeof token !== "string") {
|
|
24173
|
-
throw new Error("VITE_COLUMNUS_API_TOKEN is required");
|
|
24174
|
-
}
|
|
24175
|
-
return token;
|
|
24176
|
-
}
|
|
24177
|
-
`;
|
|
24178
|
-
}
|
|
24179
|
-
function generateHooksTs(tables, pageSize) {
|
|
24180
|
-
const sorted = [...tables].sort((a, b) => a.name.localeCompare(b.name));
|
|
24181
|
-
const listHooks = sorted.map((table) => {
|
|
24182
|
-
const hookName = `use${table.name}List`;
|
|
24183
|
-
const ref = `list${table.name}Ref`;
|
|
24184
|
-
return `
|
|
24185
|
-
export function ${hookName}(query?: Query | null) {
|
|
24186
|
-
const apiToken = readApiToken();
|
|
24187
|
-
return usePaginatedQuery(
|
|
24188
|
-
${ref},
|
|
24189
|
-
query ? { apiToken, query } : { apiToken },
|
|
24190
|
-
{ initialNumItems: ${pageSize} },
|
|
24191
|
-
);
|
|
24192
|
-
}`;
|
|
24193
|
-
}).join("\n");
|
|
24194
|
-
const getHooks = sorted.map((table) => {
|
|
24195
|
-
const hookName = `use${table.name}ById`;
|
|
24196
|
-
const doc = docTypeName(table.name);
|
|
24197
|
-
const ref = `get${table.name}Ref`;
|
|
24198
|
-
return `
|
|
24199
|
-
export function ${hookName}(id: ${doc}["_id"] | undefined) {
|
|
24200
|
-
const apiToken = readApiToken();
|
|
24201
|
-
return useQuery(${ref}, id ? { apiToken, id } : "skip");
|
|
24202
|
-
}`;
|
|
24203
|
-
}).join("\n");
|
|
24204
|
-
const docImports = sorted.map((t) => ` ${docTypeName(t.name)},`).join("\n");
|
|
24205
|
-
const refImports = sorted.flatMap((t) => [` list${t.name}Ref,`, ` get${t.name}Ref,`]).join("\n");
|
|
24206
|
-
return `${READ_API_BANNER}import { usePaginatedQuery, useQuery } from "convex/react";
|
|
24207
|
-
import { anyApi } from "convex/server";
|
|
24208
|
-
import type { Query } from "./query.js";
|
|
24209
|
-
import type {
|
|
24210
|
-
${docImports}
|
|
24211
|
-
} from "./documents.js";
|
|
24212
|
-
import {
|
|
24213
|
-
${refImports}
|
|
24214
|
-
} from "./read-api-refs.js";
|
|
24215
|
-
import { readApiToken } from "./read-api-token.js";
|
|
24216
|
-
${listHooks}
|
|
24217
|
-
|
|
24218
|
-
${getHooks}
|
|
24219
|
-
|
|
24220
|
-
export function useAssetOriginals(assetIds: string[]) {
|
|
24221
|
-
const apiToken = readApiToken();
|
|
24222
|
-
const ids = assetIds.filter(Boolean);
|
|
24223
|
-
const results = useQuery(
|
|
24224
|
-
anyApi.columnus.read.assets.getAssetOriginals,
|
|
24225
|
-
ids.length > 0 ? { apiToken, assetIds: ids } : "skip",
|
|
24226
|
-
);
|
|
24227
|
-
return results ?? [];
|
|
24228
|
-
}
|
|
24229
|
-
|
|
24230
|
-
export function useAssetExpansions(assetIds: string[]) {
|
|
24231
|
-
const apiToken = readApiToken();
|
|
24232
|
-
const ids = assetIds.filter(Boolean);
|
|
24233
|
-
const results = useQuery(
|
|
24234
|
-
anyApi.columnus.read.assets.getAssetExpansions,
|
|
24235
|
-
ids.length > 0 ? { apiToken, assetIds: ids } : "skip",
|
|
24236
|
-
);
|
|
24237
|
-
return results ?? [];
|
|
24238
|
-
}
|
|
24239
|
-
`;
|
|
24240
|
-
}
|
|
24241
|
-
function generateEnvExample(convexUrl) {
|
|
24242
|
-
return `# Copy to .env.local and fill in your read API token from Columnus /api.
|
|
24243
|
-
VITE_CONVEX_URL=${convexUrl}
|
|
24244
|
-
VITE_COLUMNUS_API_TOKEN=col_your_token_here
|
|
24245
|
-
`;
|
|
24246
|
-
}
|
|
24247
|
-
|
|
24248
|
-
// ../shared/src/apiToken.ts
|
|
24249
|
-
var TOKEN_BODY_RE = /^col_[A-Za-z0-9_-]{20,}$/;
|
|
24250
|
-
function isApiTokenFormat(token) {
|
|
24251
|
-
return TOKEN_BODY_RE.test(token.trim());
|
|
24252
|
-
}
|
|
24253
|
-
|
|
24254
|
-
// src/pull-codegen.ts
|
|
24255
|
-
import { access, writeFile } from "node:fs/promises";
|
|
24256
|
-
import path2 from "node:path";
|
|
24257
|
-
|
|
24258
|
-
// ../shared/src/fieldValueText.ts
|
|
24259
|
-
var INT64_MIN = -(2n ** 63n);
|
|
24260
|
-
var INT64_MAX = 2n ** 63n - 1n;
|
|
24261
|
-
|
|
24262
|
-
// ../shared/src/schemaShrinkValidators.ts
|
|
24263
|
-
import { v } from "convex/values";
|
|
24264
|
-
var cleanupStateValidator = v.object({
|
|
24265
|
-
targetManifestJson: v.string(),
|
|
24266
|
-
beforeManifestJson: v.string(),
|
|
24267
|
-
tasks: v.array(
|
|
24268
|
-
v.union(
|
|
24269
|
-
v.object({ kind: v.literal("delete_table"), table: v.string() }),
|
|
24270
|
-
v.object({
|
|
24271
|
-
kind: v.literal("strip_field"),
|
|
24272
|
-
table: v.string(),
|
|
24273
|
-
field: v.string(),
|
|
24274
|
-
fieldType: v.any()
|
|
24275
|
-
})
|
|
24276
|
-
)
|
|
24277
|
-
),
|
|
24278
|
-
taskIndex: v.number(),
|
|
24279
|
-
cursor: v.union(v.string(), v.null()),
|
|
24280
|
-
stats: v.object({
|
|
24281
|
-
rowsDeleted: v.number(),
|
|
24282
|
-
fieldsStripped: v.number(),
|
|
24283
|
-
storageDeleted: v.number()
|
|
24284
|
-
}),
|
|
24285
|
-
bffOperationId: v.string(),
|
|
24286
|
-
desiredManifestHash: v.string()
|
|
24287
|
-
});
|
|
24288
|
-
|
|
24289
|
-
// ../shared/src/assetJobs.ts
|
|
24290
|
-
var ASSET_JOB_LEASE_MS = 15 * 6e4;
|
|
24291
|
-
var ASSET_JOB_BACKOFF_MS = [15e3, 6e4, 5 * 6e4, 60 * 6e4];
|
|
24292
|
-
|
|
24293
|
-
// ../shared/src/assetSettings.ts
|
|
24294
|
-
var DEFAULT_MEDIA_WARN_BYTES = 10 * 1024 * 1024 * 1024;
|
|
24295
|
-
var DEFAULT_MEDIA_REJECT_BYTES = 100 * 1024 * 1024 * 1024;
|
|
24296
|
-
|
|
24297
|
-
// ../shared/src/csv.ts
|
|
24298
|
-
var import_papaparse = __toESM(require_papaparse(), 1);
|
|
24299
|
-
|
|
24300
|
-
// ../shared/src/queryValidators.ts
|
|
24301
|
-
import { v as v2 } from "convex/values";
|
|
24302
|
-
var predicateValidators = PREDICATE_VARIANTS.flatMap(
|
|
24303
|
-
(variant) => variant.ops.map(
|
|
24304
|
-
({ op }) => v2.object({
|
|
24305
|
-
field: v2.string(),
|
|
24306
|
-
op: v2.literal(op),
|
|
24307
|
-
value: variant.value === "unknownArray" ? v2.array(v2.any()) : variant.value === "between" ? v2.object({ min: v2.any(), max: v2.any() }) : variant.value === "none" ? v2.null() : v2.any()
|
|
24308
|
-
})
|
|
24309
|
-
)
|
|
24310
|
-
);
|
|
24311
|
-
var predicateValidator = v2.union(
|
|
24312
|
-
...predicateValidators
|
|
24313
|
-
);
|
|
24314
|
-
var queryOrderValidator = v2.object({
|
|
24315
|
-
field: v2.string(),
|
|
24316
|
-
direction: v2.union(v2.literal("asc"), v2.literal("desc"))
|
|
24317
|
-
});
|
|
24318
|
-
var querySearchValidator = v2.object({
|
|
24319
|
-
index: v2.string(),
|
|
24320
|
-
query: v2.string()
|
|
24321
|
-
});
|
|
24322
|
-
var queryValidator = v2.object({
|
|
24323
|
-
predicates: v2.optional(v2.array(predicateValidator)),
|
|
24324
|
-
order: v2.optional(queryOrderValidator),
|
|
24325
|
-
search: v2.optional(querySearchValidator),
|
|
24326
|
-
maxScan: v2.optional(v2.number()),
|
|
24327
|
-
indexHint: v2.optional(v2.string()),
|
|
24328
|
-
vector: v2.optional(v2.any())
|
|
24329
|
-
});
|
|
24330
|
-
var clampQueryValidator = v2.object({
|
|
24331
|
-
predicates: v2.optional(v2.array(predicateValidator)),
|
|
24332
|
-
order: v2.optional(queryOrderValidator),
|
|
24333
|
-
search: v2.optional(querySearchValidator)
|
|
24334
|
-
});
|
|
24335
|
-
var queryArgValidator = v2.optional(queryValidator);
|
|
24336
|
-
var maxScanLimitValidator = v2.optional(v2.number());
|
|
24337
|
-
|
|
24338
|
-
// ../shared/src/useDebouncedValue.ts
|
|
24339
|
-
var import_react = __toESM(require_react(), 1);
|
|
24340
|
-
|
|
24341
|
-
// ../shared/src/useDebouncedCommit.ts
|
|
24342
|
-
var import_react2 = __toESM(require_react(), 1);
|
|
24343
|
-
|
|
24344
|
-
// ../shared/src/useModifierHeld.ts
|
|
24345
|
-
var import_react3 = __toESM(require_react(), 1);
|
|
24346
|
-
|
|
24347
|
-
// ../shared/src/convexSiteUrl.ts
|
|
24348
|
-
function convexDeploymentSlug(url2) {
|
|
24349
|
-
const match = url2.match(/https:\/\/([^.]+)\.convex\.(?:cloud|site)/);
|
|
24350
|
-
return match?.[1];
|
|
24425
|
+
return typeof value === "string" ? value : String(value);
|
|
24351
24426
|
}
|
|
24352
|
-
|
|
24353
|
-
|
|
24354
|
-
return
|
|
24427
|
+
|
|
24428
|
+
function isAssetFieldType(type: ManifestFieldType): boolean {
|
|
24429
|
+
return type.kind === "file" || type.kind === "image";
|
|
24355
24430
|
}
|
|
24356
24431
|
|
|
24357
|
-
|
|
24358
|
-
|
|
24432
|
+
function isAssetArrayFieldType(type: ManifestFieldType): boolean {
|
|
24433
|
+
return type.kind === "array" && (type.element.kind === "file" || type.element.kind === "image");
|
|
24434
|
+
}
|
|
24359
24435
|
|
|
24360
|
-
|
|
24361
|
-
|
|
24362
|
-
var MAX_TRANSFER_BYTES = 50 * 1024 * 1024;
|
|
24363
|
-
function isProtectedTransferTable(table) {
|
|
24364
|
-
return table.startsWith("_") || table.startsWith("columnus_") || table.startsWith("studio_");
|
|
24436
|
+
function isAssetFieldOrArray(type: ManifestFieldType): boolean {
|
|
24437
|
+
return isAssetFieldType(type) || isAssetArrayFieldType(type);
|
|
24365
24438
|
}
|
|
24366
24439
|
|
|
24367
|
-
|
|
24368
|
-
|
|
24369
|
-
|
|
24440
|
+
export function collectAssetIds(
|
|
24441
|
+
value: unknown,
|
|
24442
|
+
type: ManifestFieldType,
|
|
24443
|
+
out: Set<string> = new Set(),
|
|
24444
|
+
): Set<string> {
|
|
24445
|
+
if (isAssetFieldType(type)) {
|
|
24446
|
+
const id = toDocumentId(value);
|
|
24447
|
+
if (id) out.add(id);
|
|
24448
|
+
return out;
|
|
24449
|
+
}
|
|
24450
|
+
if (isAssetArrayFieldType(type) && Array.isArray(value)) {
|
|
24451
|
+
for (const item of value) {
|
|
24452
|
+
const id = toDocumentId(item);
|
|
24453
|
+
if (id) out.add(id);
|
|
24454
|
+
}
|
|
24455
|
+
}
|
|
24456
|
+
return out;
|
|
24457
|
+
}
|
|
24370
24458
|
|
|
24371
|
-
|
|
24372
|
-
|
|
24373
|
-
|
|
24374
|
-
|
|
24375
|
-
|
|
24376
|
-
|
|
24377
|
-
|
|
24378
|
-
|
|
24379
|
-
|
|
24380
|
-
|
|
24381
|
-
"schemaDeploy",
|
|
24382
|
-
"dataExport",
|
|
24383
|
-
"dataImportPrepare",
|
|
24384
|
-
"dataImportCommit"
|
|
24385
|
-
]);
|
|
24386
|
-
var transferOperationSchema = external_exports.enum(["export", "import"]);
|
|
24387
|
-
var transferSessionStateSchema = external_exports.enum([
|
|
24388
|
-
"exportReady",
|
|
24389
|
-
"importAwaitingUpload",
|
|
24390
|
-
"importUploaded",
|
|
24391
|
-
"importCommitted",
|
|
24392
|
-
"importFailed",
|
|
24393
|
-
"expired"
|
|
24394
|
-
]);
|
|
24395
|
-
var schemaDeployPhaseSchema = external_exports.enum([
|
|
24396
|
-
"cleaning",
|
|
24397
|
-
"ready",
|
|
24398
|
-
"deploying",
|
|
24399
|
-
"succeeded",
|
|
24400
|
-
"failed"
|
|
24401
|
-
]);
|
|
24402
|
-
var SCHEMA_DEPLOY_OPERATION_LEASE_MS = 20 * 60 * 1e3;
|
|
24403
|
-
var transferTableSchema = external_exports.string().regex(TABLE_NAME_RE).refine((name) => !isProtectedTransferTable(name), {
|
|
24404
|
-
message: "Protected table cannot be transferred"
|
|
24405
|
-
});
|
|
24406
|
-
var dataTransferManifestSchema = external_exports.object({
|
|
24407
|
-
version: external_exports.literal(COLUMNUS_DATA_TRANSFER_VERSION),
|
|
24408
|
-
tables: external_exports.array(transferTableSchema).min(1),
|
|
24409
|
-
schemaHash: manifestHashSchema,
|
|
24410
|
-
includeFileStorage: external_exports.boolean()
|
|
24411
|
-
}).superRefine((value, ctx) => {
|
|
24412
|
-
if (new Set(value.tables).size !== value.tables.length) {
|
|
24413
|
-
ctx.addIssue({
|
|
24414
|
-
code: external_exports.ZodIssueCode.custom,
|
|
24415
|
-
message: "dataTransfer.tables must not contain duplicates",
|
|
24416
|
-
path: ["tables"]
|
|
24417
|
-
});
|
|
24459
|
+
export function collectAssetIdsFromRow<T extends TableName>(
|
|
24460
|
+
row: DocByTable[T] | undefined,
|
|
24461
|
+
fields: readonly ManifestField[],
|
|
24462
|
+
out: Set<string> = new Set(),
|
|
24463
|
+
): Set<string> {
|
|
24464
|
+
if (!row) return out;
|
|
24465
|
+
const values = row as Record<string, unknown>;
|
|
24466
|
+
for (const field of fields) {
|
|
24467
|
+
if (!isAssetFieldOrArray(field.type)) continue;
|
|
24468
|
+
collectAssetIds(values[field.name], field.type, out);
|
|
24418
24469
|
}
|
|
24419
|
-
|
|
24420
|
-
|
|
24421
|
-
|
|
24422
|
-
|
|
24423
|
-
|
|
24424
|
-
|
|
24425
|
-
|
|
24426
|
-
|
|
24427
|
-
|
|
24428
|
-
|
|
24429
|
-
}
|
|
24430
|
-
|
|
24431
|
-
|
|
24432
|
-
|
|
24433
|
-
|
|
24434
|
-
|
|
24435
|
-
|
|
24436
|
-
|
|
24437
|
-
|
|
24438
|
-
|
|
24439
|
-
|
|
24440
|
-
|
|
24441
|
-
|
|
24442
|
-
|
|
24443
|
-
}
|
|
24444
|
-
|
|
24445
|
-
|
|
24446
|
-
|
|
24447
|
-
|
|
24448
|
-
|
|
24449
|
-
}
|
|
24450
|
-
|
|
24451
|
-
|
|
24452
|
-
|
|
24453
|
-
|
|
24454
|
-
|
|
24455
|
-
|
|
24456
|
-
|
|
24457
|
-
|
|
24458
|
-
|
|
24459
|
-
|
|
24460
|
-
|
|
24461
|
-
|
|
24462
|
-
|
|
24463
|
-
|
|
24464
|
-
|
|
24465
|
-
});
|
|
24466
|
-
|
|
24467
|
-
|
|
24468
|
-
|
|
24469
|
-
|
|
24470
|
-
|
|
24471
|
-
}
|
|
24472
|
-
|
|
24473
|
-
|
|
24474
|
-
|
|
24475
|
-
}
|
|
24476
|
-
|
|
24477
|
-
|
|
24478
|
-
|
|
24479
|
-
|
|
24480
|
-
|
|
24481
|
-
|
|
24482
|
-
|
|
24483
|
-
|
|
24484
|
-
|
|
24485
|
-
|
|
24486
|
-
|
|
24487
|
-
|
|
24488
|
-
|
|
24489
|
-
|
|
24490
|
-
|
|
24491
|
-
|
|
24492
|
-
|
|
24493
|
-
|
|
24494
|
-
|
|
24495
|
-
|
|
24496
|
-
}
|
|
24497
|
-
|
|
24498
|
-
|
|
24499
|
-
|
|
24500
|
-
|
|
24501
|
-
|
|
24502
|
-
|
|
24503
|
-
|
|
24504
|
-
|
|
24505
|
-
|
|
24506
|
-
|
|
24507
|
-
|
|
24508
|
-
|
|
24509
|
-
|
|
24510
|
-
|
|
24511
|
-
|
|
24470
|
+
return out;
|
|
24471
|
+
}
|
|
24472
|
+
`;
|
|
24473
|
+
}
|
|
24474
|
+
function generateReadApiMetaTs(profileSlug, apiVersion, manifestHash) {
|
|
24475
|
+
return `${READ_API_BANNER}/** Compile-time snapshot from the last \`columnus-api pull\`. */
|
|
24476
|
+
export const PULLED_PROFILE_SLUG = ${JSON.stringify(profileSlug)} as const;
|
|
24477
|
+
export const PULLED_API_VERSION = ${apiVersion} as const;
|
|
24478
|
+
export const PULLED_MANIFEST_HASH = ${JSON.stringify(manifestHash)} as const;
|
|
24479
|
+
`;
|
|
24480
|
+
}
|
|
24481
|
+
function generateReadApiTokenTs() {
|
|
24482
|
+
return `${READ_API_BANNER}export function readApiToken(): string {
|
|
24483
|
+
const token = import.meta.env.VITE_COLUMNUS_API_TOKEN;
|
|
24484
|
+
if (!token || typeof token !== "string") {
|
|
24485
|
+
throw new Error("VITE_COLUMNUS_API_TOKEN is required");
|
|
24486
|
+
}
|
|
24487
|
+
return token;
|
|
24488
|
+
}
|
|
24489
|
+
`;
|
|
24490
|
+
}
|
|
24491
|
+
function generateHooksTs(tables, pageSize) {
|
|
24492
|
+
const sorted = [...tables].sort((a, b) => a.name.localeCompare(b.name));
|
|
24493
|
+
const listHooks = sorted.map((table) => {
|
|
24494
|
+
const hookName = `use${table.name}List`;
|
|
24495
|
+
const ref = `list${table.name}Ref`;
|
|
24496
|
+
return `
|
|
24497
|
+
export function ${hookName}(query?: Query | null) {
|
|
24498
|
+
const apiToken = readApiToken();
|
|
24499
|
+
return usePaginatedQuery(
|
|
24500
|
+
${ref},
|
|
24501
|
+
query ? { apiToken, query } : { apiToken },
|
|
24502
|
+
{ initialNumItems: ${pageSize} },
|
|
24503
|
+
);
|
|
24504
|
+
}`;
|
|
24505
|
+
}).join("\n");
|
|
24506
|
+
const getHooks = sorted.map((table) => {
|
|
24507
|
+
const hookName = `use${table.name}ById`;
|
|
24508
|
+
const doc = docTypeName(table.name);
|
|
24509
|
+
const ref = `get${table.name}Ref`;
|
|
24510
|
+
return `
|
|
24511
|
+
export function ${hookName}(id: ${doc}["_id"] | undefined) {
|
|
24512
|
+
const apiToken = readApiToken();
|
|
24513
|
+
return useQuery(${ref}, id ? { apiToken, id } : "skip");
|
|
24514
|
+
}`;
|
|
24515
|
+
}).join("\n");
|
|
24516
|
+
const docImports = sorted.map((t) => ` ${docTypeName(t.name)},`).join("\n");
|
|
24517
|
+
const refImports = sorted.flatMap((t) => [` list${t.name}Ref,`, ` get${t.name}Ref,`]).join("\n");
|
|
24518
|
+
return `${READ_API_BANNER}import { usePaginatedQuery, useQuery } from "convex/react";
|
|
24519
|
+
import { anyApi } from "convex/server";
|
|
24520
|
+
import type { Query } from "./query.js";
|
|
24521
|
+
import type {
|
|
24522
|
+
${docImports}
|
|
24523
|
+
} from "./documents.js";
|
|
24524
|
+
import {
|
|
24525
|
+
${refImports}
|
|
24526
|
+
} from "./read-api-refs.js";
|
|
24527
|
+
import { readApiToken } from "./read-api-token.js";
|
|
24528
|
+
${listHooks}
|
|
24529
|
+
|
|
24530
|
+
${getHooks}
|
|
24531
|
+
|
|
24532
|
+
export function useAssetOriginals(assetIds: string[]) {
|
|
24533
|
+
const apiToken = readApiToken();
|
|
24534
|
+
const ids = assetIds.filter(Boolean);
|
|
24535
|
+
const results = useQuery(
|
|
24536
|
+
anyApi.columnus.read.assets.getAssetOriginals,
|
|
24537
|
+
ids.length > 0 ? { apiToken, assetIds: ids } : "skip",
|
|
24538
|
+
);
|
|
24539
|
+
return results ?? [];
|
|
24540
|
+
}
|
|
24541
|
+
|
|
24542
|
+
export function useAssetExpansions(assetIds: string[]) {
|
|
24543
|
+
const apiToken = readApiToken();
|
|
24544
|
+
const ids = assetIds.filter(Boolean);
|
|
24545
|
+
const results = useQuery(
|
|
24546
|
+
anyApi.columnus.read.assets.getAssetExpansions,
|
|
24547
|
+
ids.length > 0 ? { apiToken, assetIds: ids } : "skip",
|
|
24548
|
+
);
|
|
24549
|
+
return results ?? [];
|
|
24550
|
+
}
|
|
24551
|
+
`;
|
|
24552
|
+
}
|
|
24553
|
+
function generateEnvExample(convexUrl) {
|
|
24554
|
+
return `# Copy to .env.local and fill in your read API token from Columnus /api.
|
|
24555
|
+
VITE_CONVEX_URL=${convexUrl}
|
|
24556
|
+
VITE_COLUMNUS_API_TOKEN=col_your_token_here
|
|
24557
|
+
`;
|
|
24558
|
+
}
|
|
24559
|
+
|
|
24560
|
+
// ../shared/src/apiToken.ts
|
|
24561
|
+
var TOKEN_BODY_RE = /^col_[A-Za-z0-9_-]{20,}$/;
|
|
24562
|
+
function isApiTokenFormat(token) {
|
|
24563
|
+
return TOKEN_BODY_RE.test(token.trim());
|
|
24564
|
+
}
|
|
24565
|
+
|
|
24566
|
+
// src/pull-codegen.ts
|
|
24567
|
+
import { access, writeFile } from "node:fs/promises";
|
|
24568
|
+
import path2 from "node:path";
|
|
24569
|
+
|
|
24570
|
+
// ../shared/src/fieldValueText.ts
|
|
24571
|
+
var INT64_MIN = -(2n ** 63n);
|
|
24572
|
+
var INT64_MAX = 2n ** 63n - 1n;
|
|
24573
|
+
|
|
24574
|
+
// ../shared/src/schemaShrinkValidators.ts
|
|
24575
|
+
import { v } from "convex/values";
|
|
24576
|
+
var cleanupStateValidator = v.object({
|
|
24577
|
+
targetManifestJson: v.string(),
|
|
24578
|
+
beforeManifestJson: v.string(),
|
|
24579
|
+
tasks: v.array(
|
|
24580
|
+
v.union(
|
|
24581
|
+
v.object({ kind: v.literal("delete_table"), table: v.string() }),
|
|
24582
|
+
v.object({
|
|
24583
|
+
kind: v.literal("strip_field"),
|
|
24584
|
+
table: v.string(),
|
|
24585
|
+
field: v.string(),
|
|
24586
|
+
fieldType: v.any()
|
|
24587
|
+
})
|
|
24588
|
+
)
|
|
24589
|
+
),
|
|
24590
|
+
taskIndex: v.number(),
|
|
24591
|
+
cursor: v.union(v.string(), v.null()),
|
|
24592
|
+
stats: v.object({
|
|
24593
|
+
rowsDeleted: v.number(),
|
|
24594
|
+
fieldsStripped: v.number(),
|
|
24595
|
+
storageDeleted: v.number()
|
|
24512
24596
|
}),
|
|
24513
|
-
|
|
24514
|
-
|
|
24515
|
-
operationId: operationIdSchema,
|
|
24516
|
-
transferId: transferIdSchema,
|
|
24517
|
-
schemaHash: manifestHashSchema
|
|
24518
|
-
})
|
|
24519
|
-
]);
|
|
24520
|
-
var bffPrepareRequestSchema = external_exports.object({
|
|
24521
|
-
protocolVersion: external_exports.literal(COLUMNUS_BFF_PROTOCOL_VERSION),
|
|
24522
|
-
/** Trusted hostname only (already extracted by BFF). */
|
|
24523
|
-
host: external_exports.string().min(1),
|
|
24524
|
-
correlationId: external_exports.string().min(1).max(128).optional(),
|
|
24525
|
-
operation: bffPrepareOperationSchema
|
|
24597
|
+
bffOperationId: v.string(),
|
|
24598
|
+
desiredManifestHash: v.string()
|
|
24526
24599
|
});
|
|
24527
|
-
|
|
24528
|
-
|
|
24529
|
-
|
|
24530
|
-
|
|
24531
|
-
|
|
24600
|
+
|
|
24601
|
+
// ../shared/src/assetJobs.ts
|
|
24602
|
+
var ASSET_JOB_LEASE_MS = 15 * 6e4;
|
|
24603
|
+
var ASSET_JOB_BACKOFF_MS = [15e3, 6e4, 5 * 6e4, 60 * 6e4];
|
|
24604
|
+
|
|
24605
|
+
// ../shared/src/assetSettings.ts
|
|
24606
|
+
var DEFAULT_MEDIA_WARN_BYTES = 10 * 1024 * 1024 * 1024;
|
|
24607
|
+
var DEFAULT_MEDIA_REJECT_BYTES = 100 * 1024 * 1024 * 1024;
|
|
24608
|
+
|
|
24609
|
+
// ../shared/src/csv.ts
|
|
24610
|
+
var import_papaparse = __toESM(require_papaparse(), 1);
|
|
24611
|
+
|
|
24612
|
+
// ../shared/src/queryValidators.ts
|
|
24613
|
+
import { v as v2 } from "convex/values";
|
|
24614
|
+
var predicateValidators = PREDICATE_VARIANTS.flatMap(
|
|
24615
|
+
(variant) => variant.ops.map(
|
|
24616
|
+
({ op }) => v2.object({
|
|
24617
|
+
field: v2.string(),
|
|
24618
|
+
op: v2.literal(op),
|
|
24619
|
+
value: variant.value === "unknownArray" ? v2.array(v2.any()) : variant.value === "between" ? v2.object({ min: v2.any(), max: v2.any() }) : variant.value === "none" ? v2.null() : v2.any()
|
|
24620
|
+
})
|
|
24621
|
+
)
|
|
24622
|
+
);
|
|
24623
|
+
var predicateValidator = v2.union(
|
|
24624
|
+
...predicateValidators
|
|
24625
|
+
);
|
|
24626
|
+
var queryOrderValidator = v2.object({
|
|
24627
|
+
field: v2.string(),
|
|
24628
|
+
direction: v2.union(v2.literal("asc"), v2.literal("desc"))
|
|
24532
24629
|
});
|
|
24533
|
-
var
|
|
24534
|
-
|
|
24535
|
-
|
|
24536
|
-
convexUrl: external_exports.string().url(),
|
|
24537
|
-
authIssuer: external_exports.string().url().optional(),
|
|
24538
|
-
previewName: external_exports.string().nullable().optional(),
|
|
24539
|
-
operationId: operationIdSchema.optional()
|
|
24630
|
+
var querySearchValidator = v2.object({
|
|
24631
|
+
index: v2.string(),
|
|
24632
|
+
query: v2.string()
|
|
24540
24633
|
});
|
|
24541
|
-
var
|
|
24542
|
-
|
|
24543
|
-
|
|
24544
|
-
|
|
24545
|
-
|
|
24546
|
-
|
|
24634
|
+
var queryValidator = v2.object({
|
|
24635
|
+
predicates: v2.optional(v2.array(predicateValidator)),
|
|
24636
|
+
order: v2.optional(queryOrderValidator),
|
|
24637
|
+
search: v2.optional(querySearchValidator),
|
|
24638
|
+
maxScan: v2.optional(v2.number()),
|
|
24639
|
+
indexHint: v2.optional(v2.string()),
|
|
24640
|
+
vector: v2.optional(v2.any())
|
|
24547
24641
|
});
|
|
24548
|
-
var
|
|
24549
|
-
|
|
24550
|
-
|
|
24551
|
-
|
|
24552
|
-
tenantSlug: external_exports.string().min(1),
|
|
24553
|
-
operationId: operationIdSchema
|
|
24642
|
+
var clampQueryValidator = v2.object({
|
|
24643
|
+
predicates: v2.optional(v2.array(predicateValidator)),
|
|
24644
|
+
order: v2.optional(queryOrderValidator),
|
|
24645
|
+
search: v2.optional(querySearchValidator)
|
|
24554
24646
|
});
|
|
24555
|
-
var
|
|
24556
|
-
|
|
24557
|
-
|
|
24558
|
-
|
|
24559
|
-
|
|
24560
|
-
|
|
24561
|
-
|
|
24647
|
+
var queryArgValidator = v2.optional(queryValidator);
|
|
24648
|
+
var maxScanLimitValidator = v2.optional(v2.number());
|
|
24649
|
+
|
|
24650
|
+
// ../shared/src/useDebouncedValue.ts
|
|
24651
|
+
var import_react = __toESM(require_react(), 1);
|
|
24652
|
+
|
|
24653
|
+
// ../shared/src/useDebouncedCommit.ts
|
|
24654
|
+
var import_react2 = __toESM(require_react(), 1);
|
|
24655
|
+
|
|
24656
|
+
// ../shared/src/useModifierHeld.ts
|
|
24657
|
+
var import_react3 = __toESM(require_react(), 1);
|
|
24658
|
+
|
|
24659
|
+
// ../shared/src/convexSiteUrl.ts
|
|
24660
|
+
function convexDeploymentSlug(url2) {
|
|
24661
|
+
const match = url2.match(/https:\/\/([^.]+)\.convex\.(?:cloud|site)/);
|
|
24662
|
+
return match?.[1];
|
|
24663
|
+
}
|
|
24664
|
+
function deriveConvexDeploymentFromCloudUrl(cloudUrl) {
|
|
24665
|
+
const slug = convexDeploymentSlug(cloudUrl);
|
|
24666
|
+
return slug ? `dev:${slug}` : void 0;
|
|
24667
|
+
}
|
|
24668
|
+
|
|
24669
|
+
// ../shared/src/proposeRateLimit.ts
|
|
24670
|
+
var DEFAULT_PROPOSE_RATE_LIMITS = {
|
|
24671
|
+
api_token: { max: 30, windowMs: 6e4 },
|
|
24672
|
+
share_invite: { max: 120, windowMs: 6e4 },
|
|
24673
|
+
public_form: { max: 10, windowMs: 6e4 },
|
|
24674
|
+
client_key: { max: 60, windowMs: 6e4 },
|
|
24675
|
+
oauth_register: { max: 60, windowMs: 60 * 6e4 }
|
|
24676
|
+
};
|
|
24677
|
+
|
|
24678
|
+
// ../shared/src/apiProfileValidators.ts
|
|
24679
|
+
import { v as v3 } from "convex/values";
|
|
24680
|
+
var apiProposeAccessValidator = v3.object({
|
|
24681
|
+
ops: v3.object({ insert: v3.boolean(), update: v3.boolean(), delete: v3.boolean() }),
|
|
24682
|
+
allowedFields: v3.optional(v3.array(v3.string())),
|
|
24683
|
+
recordIds: v3.optional(v3.array(v3.string()))
|
|
24562
24684
|
});
|
|
24563
|
-
var
|
|
24564
|
-
|
|
24565
|
-
|
|
24566
|
-
|
|
24685
|
+
var apiTableAccessValidator = v3.object({
|
|
24686
|
+
table: v3.string(),
|
|
24687
|
+
read: v3.boolean(),
|
|
24688
|
+
sync: v3.optional(v3.boolean()),
|
|
24689
|
+
propose: v3.optional(apiProposeAccessValidator),
|
|
24690
|
+
autoAccept: v3.optional(v3.boolean()),
|
|
24691
|
+
editorAccess: v3.optional(v3.boolean()),
|
|
24692
|
+
rowQuery: v3.optional(clampQueryValidator),
|
|
24693
|
+
maxScanLimit: maxScanLimitValidator,
|
|
24694
|
+
assetProfiles: v3.optional(v3.array(v3.string())),
|
|
24695
|
+
assignProfiles: v3.optional(v3.array(v3.string())),
|
|
24696
|
+
write: v3.optional(v3.boolean())
|
|
24567
24697
|
});
|
|
24568
|
-
var
|
|
24569
|
-
|
|
24570
|
-
|
|
24571
|
-
|
|
24572
|
-
|
|
24573
|
-
bffPreparedBodyEnvelopeBaseSchema.extend({
|
|
24574
|
-
operation: external_exports.literal("dataExport"),
|
|
24575
|
-
payload: deployInternalTransferExportPayloadSchema
|
|
24576
|
-
}),
|
|
24577
|
-
bffPreparedBodyEnvelopeBaseSchema.extend({
|
|
24578
|
-
operation: external_exports.literal("dataImportPrepare"),
|
|
24579
|
-
payload: deployInternalTransferImportPreparePayloadSchema
|
|
24580
|
-
}),
|
|
24581
|
-
bffPreparedBodyEnvelopeBaseSchema.extend({
|
|
24582
|
-
operation: external_exports.literal("dataImportCommit"),
|
|
24583
|
-
payload: deployInternalTransferCommitPayloadSchema
|
|
24698
|
+
var stagedApiAccessValidator = v3.array(
|
|
24699
|
+
v3.object({
|
|
24700
|
+
profile: v3.string(),
|
|
24701
|
+
profileId: v3.optional(v3.string()),
|
|
24702
|
+
tableAccess: v3.array(apiTableAccessValidator)
|
|
24584
24703
|
})
|
|
24585
|
-
|
|
24586
|
-
|
|
24587
|
-
|
|
24588
|
-
|
|
24589
|
-
|
|
24590
|
-
|
|
24591
|
-
|
|
24592
|
-
|
|
24593
|
-
|
|
24594
|
-
|
|
24595
|
-
})
|
|
24596
|
-
|
|
24597
|
-
|
|
24598
|
-
|
|
24599
|
-
|
|
24600
|
-
|
|
24601
|
-
|
|
24602
|
-
|
|
24603
|
-
|
|
24604
|
-
|
|
24605
|
-
expiresAt: external_exports.number().int().positive(),
|
|
24606
|
-
state: transferSessionStateSchema,
|
|
24607
|
-
operationId: operationIdSchema.optional(),
|
|
24608
|
-
bytes: external_exports.number().int().nonnegative().optional(),
|
|
24609
|
-
commitResult: external_exports.object({
|
|
24610
|
-
ok: external_exports.boolean(),
|
|
24611
|
-
error: external_exports.string().optional(),
|
|
24612
|
-
logTail: external_exports.string().optional()
|
|
24613
|
-
}).optional()
|
|
24614
|
-
});
|
|
24615
|
-
var deployInternalTransferCreateResponseSchema = external_exports.object({
|
|
24616
|
-
ok: external_exports.literal(true),
|
|
24617
|
-
transferId: transferIdSchema,
|
|
24618
|
-
expiresAt: external_exports.number().int().positive(),
|
|
24619
|
-
bytes: external_exports.number().int().nonnegative().optional()
|
|
24620
|
-
});
|
|
24621
|
-
var deployInternalSchemaDeployResponseSchema = external_exports.object({
|
|
24622
|
-
ok: external_exports.boolean(),
|
|
24623
|
-
durationMs: external_exports.number(),
|
|
24624
|
-
prepareMs: external_exports.number().optional(),
|
|
24625
|
-
cliMs: external_exports.number().optional(),
|
|
24626
|
-
kernelCommit: external_exports.string().optional(),
|
|
24627
|
-
error: external_exports.string().optional(),
|
|
24628
|
-
logTail: external_exports.string().optional()
|
|
24629
|
-
});
|
|
24630
|
-
var deployHealthResponseSchema = external_exports.object({
|
|
24631
|
-
ok: external_exports.boolean(),
|
|
24632
|
-
commit: external_exports.string().optional(),
|
|
24633
|
-
/** ISO-8601 Coolify/image bake time (BRU-76 preview supersede). */
|
|
24634
|
-
deployedAt: external_exports.string().optional()
|
|
24635
|
-
});
|
|
24636
|
-
var BFF_JSON_BODY_LIMIT_BYTES = 2 * 1024 * 1024;
|
|
24704
|
+
);
|
|
24705
|
+
|
|
24706
|
+
// ../shared/src/refsRecompute.ts
|
|
24707
|
+
var REFS_RECOMPUTE_STALE_MS = 10 * 60 * 1e3;
|
|
24708
|
+
|
|
24709
|
+
// ../shared/src/stagedApiAccess.ts
|
|
24710
|
+
var stagedApiAccessSchema = external_exports.array(
|
|
24711
|
+
external_exports.object({
|
|
24712
|
+
profile: external_exports.string().min(1),
|
|
24713
|
+
tableAccess: external_exports.array(apiTableAccessSchema).min(1)
|
|
24714
|
+
}).strict()
|
|
24715
|
+
);
|
|
24716
|
+
|
|
24717
|
+
// ../shared/src/tenantHosts.ts
|
|
24718
|
+
var RESERVED_TENANT_SLUGS = ["manage", "deploy", "www"];
|
|
24719
|
+
var RESERVED_SLUG_SET = new Set(RESERVED_TENANT_SLUGS);
|
|
24720
|
+
|
|
24721
|
+
// ../shared/src/studioBoot.ts
|
|
24722
|
+
import { makeFunctionReference } from "convex/server";
|
|
24723
|
+
var resolveTenantByHostRef = makeFunctionReference("tenants:resolveTenantByHost");
|
|
24637
24724
|
|
|
24638
24725
|
// ../shared/src/bffRedact.ts
|
|
24639
24726
|
var encoder = new TextEncoder();
|