@columnus/api-cli 0.1.55 → 0.1.58
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 +763 -480
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -3006,183 +3006,6 @@ function readApiAnyApiPath(profileSlug, kind, tableName) {
|
|
|
3006
3006
|
return `anyApi.columnus.read.${segment}.${exportName}.${exportName}`;
|
|
3007
3007
|
}
|
|
3008
3008
|
|
|
3009
|
-
// ../shared/src/schemaGenerator.ts
|
|
3010
|
-
var BANNER = `// AUTO-GENERATED by Columnus. Do not edit by hand \u2014
|
|
3011
|
-
// changes here will be overwritten when Columnus next saves the schema.
|
|
3012
|
-
`;
|
|
3013
|
-
var CONSUMER_BANNER = `// AUTO-GENERATED by columnus-schema-sync. Do not edit by hand \u2014
|
|
3014
|
-
// changes here will be overwritten when the schema sync CLI next runs.
|
|
3015
|
-
`;
|
|
3016
|
-
var HOST_SCHEMA_PROFILE = {
|
|
3017
|
-
includeColumnusTables: false
|
|
3018
|
-
};
|
|
3019
|
-
var AUDIT_TABLE_NAME = "columnus_audit_log";
|
|
3020
|
-
var SPACES_TABLE_NAME = "columnus_spaces";
|
|
3021
|
-
var MANIFEST_TABLE_NAME = "columnus_manifest";
|
|
3022
|
-
var DISPLAY_VALUES_TABLE_NAME = "columnus_display_values";
|
|
3023
|
-
var AUDIT_TABLE_SOURCE = ` ${AUDIT_TABLE_NAME}: defineTable({
|
|
3024
|
-
timestamp: v.number(),
|
|
3025
|
-
kind: v.union(v.literal("data"), v.literal("schema")),
|
|
3026
|
-
operation: v.string(),
|
|
3027
|
-
table: v.optional(v.string()),
|
|
3028
|
-
documentId: v.optional(v.string()),
|
|
3029
|
-
before: v.optional(v.any()),
|
|
3030
|
-
after: v.optional(v.any()),
|
|
3031
|
-
})
|
|
3032
|
-
.index("by_timestamp", ["timestamp"])
|
|
3033
|
-
.index("by_table", ["table", "timestamp"])
|
|
3034
|
-
.index("by_document", ["documentId", "timestamp"]),`;
|
|
3035
|
-
var SPACES_TABLE_SOURCE = ` ${SPACES_TABLE_NAME}: defineTable({
|
|
3036
|
-
name: v.string(),
|
|
3037
|
-
slug: v.string(),
|
|
3038
|
-
description: v.optional(v.string()),
|
|
3039
|
-
icon: v.optional(v.string()),
|
|
3040
|
-
order: v.number(),
|
|
3041
|
-
tables: v.array(v.string()),
|
|
3042
|
-
erdLayoutJson: v.optional(v.string()),
|
|
3043
|
-
createdAt: v.number(),
|
|
3044
|
-
updatedAt: v.number(),
|
|
3045
|
-
})
|
|
3046
|
-
.index("by_order", ["order"])
|
|
3047
|
-
.index("by_slug", ["slug"]),`;
|
|
3048
|
-
var MANIFEST_DEPLOY_STATUS_SOURCE = MANIFEST_DEPLOY_STATUSES.map(
|
|
3049
|
-
(status) => ` v.literal(${JSON.stringify(status)}),`
|
|
3050
|
-
).join("\n");
|
|
3051
|
-
var MANIFEST_TABLE_SOURCE = ` ${MANIFEST_TABLE_NAME}: defineTable({
|
|
3052
|
-
manifestJson: v.string(),
|
|
3053
|
-
draftManifestJson: v.optional(v.string()),
|
|
3054
|
-
draftUpdatedAt: v.optional(v.number()),
|
|
3055
|
-
erdLayoutJson: v.optional(v.string()),
|
|
3056
|
-
draftErdLayoutJson: v.optional(v.string()),
|
|
3057
|
-
deployStatus: v.union(
|
|
3058
|
-
${MANIFEST_DEPLOY_STATUS_SOURCE}
|
|
3059
|
-
),
|
|
3060
|
-
deployError: v.optional(v.string()),
|
|
3061
|
-
deployLogTail: v.optional(v.string()),
|
|
3062
|
-
deployedAt: v.optional(v.number()),
|
|
3063
|
-
lastSaveAt: v.number(),
|
|
3064
|
-
}),`;
|
|
3065
|
-
var DISPLAY_VALUES_TABLE_SOURCE = ` ${DISPLAY_VALUES_TABLE_NAME}: defineTable({
|
|
3066
|
-
table: v.string(),
|
|
3067
|
-
documentId: v.string(),
|
|
3068
|
-
type: v.union(v.literal("id"), v.literal("preview")),
|
|
3069
|
-
value: v.string(),
|
|
3070
|
-
updatedAt: v.number(),
|
|
3071
|
-
})
|
|
3072
|
-
.index("by_document", ["table", "documentId"])
|
|
3073
|
-
.index("by_table_type", ["table", "type"])
|
|
3074
|
-
.index("by_table_type_value", ["table", "type", "value"])
|
|
3075
|
-
.searchIndex("search_value", {
|
|
3076
|
-
searchField: "value",
|
|
3077
|
-
filterFields: ["table", "type"],
|
|
3078
|
-
}),`;
|
|
3079
|
-
function columnusTablesSource(opts) {
|
|
3080
|
-
const parts = [];
|
|
3081
|
-
if (opts.includeAuditTable) parts.push(AUDIT_TABLE_SOURCE);
|
|
3082
|
-
if (opts.includeSpacesTable) parts.push(SPACES_TABLE_SOURCE);
|
|
3083
|
-
if (opts.includeManifestTable) parts.push(MANIFEST_TABLE_SOURCE);
|
|
3084
|
-
if (opts.includeDisplayValuesTable) parts.push(DISPLAY_VALUES_TABLE_SOURCE);
|
|
3085
|
-
return parts.join("\n");
|
|
3086
|
-
}
|
|
3087
|
-
function generateSchemaTs(manifest, opts) {
|
|
3088
|
-
const includeColumnusTables = opts?.includeColumnusTables ?? opts?.includeStudioTables ?? false;
|
|
3089
|
-
const includeSpacesTable = opts?.includeSpacesTable ?? true;
|
|
3090
|
-
const includeManifestTable = opts?.includeManifestTable ?? true;
|
|
3091
|
-
const includeAuditTable = opts?.includeAuditTable ?? true;
|
|
3092
|
-
const includeDisplayValuesTable = opts?.includeDisplayValuesTable ?? true;
|
|
3093
|
-
const userTables = [...manifest.tables].sort((a, b) => a.name.localeCompare(b.name));
|
|
3094
|
-
const userBody = userTables.map((t) => ` ${t.name}: ${renderTable(t)},`).join("\n");
|
|
3095
|
-
let body;
|
|
3096
|
-
if (includeColumnusTables) {
|
|
3097
|
-
const columnusSource = columnusTablesSource({
|
|
3098
|
-
includeSpacesTable,
|
|
3099
|
-
includeManifestTable,
|
|
3100
|
-
includeAuditTable,
|
|
3101
|
-
includeDisplayValuesTable
|
|
3102
|
-
});
|
|
3103
|
-
body = userBody ? `${userBody}
|
|
3104
|
-
${columnusSource}` : columnusSource;
|
|
3105
|
-
} else {
|
|
3106
|
-
body = userBody || "";
|
|
3107
|
-
}
|
|
3108
|
-
const banner = includeColumnusTables ? BANNER : CONSUMER_BANNER;
|
|
3109
|
-
const schemaBody = body ? `${body}
|
|
3110
|
-
` : "";
|
|
3111
|
-
return `${banner}import { defineSchema, defineTable } from "convex/server";
|
|
3112
|
-
import { v } from "convex/values";
|
|
3113
|
-
|
|
3114
|
-
export default defineSchema({
|
|
3115
|
-
${schemaBody}});
|
|
3116
|
-
`;
|
|
3117
|
-
}
|
|
3118
|
-
function renderTable(t) {
|
|
3119
|
-
const fieldsBlock = t.fields.length ? `{
|
|
3120
|
-
${t.fields.map((f) => {
|
|
3121
|
-
const inner = renderType(f.type);
|
|
3122
|
-
const value = f.optional ? `v.optional(${inner})` : inner;
|
|
3123
|
-
return ` ${f.name}: ${value},`;
|
|
3124
|
-
}).join("\n")}
|
|
3125
|
-
}` : `{}`;
|
|
3126
|
-
let out = `defineTable(${fieldsBlock})`;
|
|
3127
|
-
const inlineSingleIndex = t.indexes.length === 1 && t.searchIndexes.length === 0;
|
|
3128
|
-
for (const idx of t.indexes) {
|
|
3129
|
-
const cols = idx.fields.map((c) => JSON.stringify(c)).join(", ");
|
|
3130
|
-
const sep = inlineSingleIndex ? "" : "\n ";
|
|
3131
|
-
out += `${sep}.index(${JSON.stringify(idx.name)}, [${cols}])`;
|
|
3132
|
-
}
|
|
3133
|
-
for (const sx of t.searchIndexes) {
|
|
3134
|
-
const cfg = [`searchField: ${JSON.stringify(sx.searchField)}`];
|
|
3135
|
-
if (sx.filterFields && sx.filterFields.length > 0) {
|
|
3136
|
-
cfg.push(`filterFields: [${sx.filterFields.map((c) => JSON.stringify(c)).join(", ")}]`);
|
|
3137
|
-
}
|
|
3138
|
-
out += `
|
|
3139
|
-
.searchIndex(${JSON.stringify(sx.name)}, { ${cfg.join(", ")} })`;
|
|
3140
|
-
}
|
|
3141
|
-
return out;
|
|
3142
|
-
}
|
|
3143
|
-
function renderType(t) {
|
|
3144
|
-
switch (t.kind) {
|
|
3145
|
-
case "string":
|
|
3146
|
-
case "markdown":
|
|
3147
|
-
return "v.string()";
|
|
3148
|
-
case "number":
|
|
3149
|
-
return "v.number()";
|
|
3150
|
-
case "date":
|
|
3151
|
-
case "datetime":
|
|
3152
|
-
return "v.number()";
|
|
3153
|
-
case "boolean":
|
|
3154
|
-
return "v.boolean()";
|
|
3155
|
-
case "bigint":
|
|
3156
|
-
return "v.int64()";
|
|
3157
|
-
case "null":
|
|
3158
|
-
return "v.null()";
|
|
3159
|
-
case "any":
|
|
3160
|
-
return "v.any()";
|
|
3161
|
-
case "bytes":
|
|
3162
|
-
return "v.bytes()";
|
|
3163
|
-
case "file":
|
|
3164
|
-
case "image":
|
|
3165
|
-
return 'v.id("_storage")';
|
|
3166
|
-
case "id":
|
|
3167
|
-
return `v.id(${JSON.stringify(t.table)})`;
|
|
3168
|
-
case "literal":
|
|
3169
|
-
return `v.literal(${JSON.stringify(t.value)})`;
|
|
3170
|
-
case "array":
|
|
3171
|
-
return `v.array(${renderType(t.element)})`;
|
|
3172
|
-
case "object": {
|
|
3173
|
-
if (t.fields.length === 0) return `v.object({})`;
|
|
3174
|
-
const inner = t.fields.map((f) => {
|
|
3175
|
-
const value = f.optional ? `v.optional(${renderType(f.type)})` : renderType(f.type);
|
|
3176
|
-
return `${f.name}: ${value}`;
|
|
3177
|
-
}).join(", ");
|
|
3178
|
-
return `v.object({ ${inner} })`;
|
|
3179
|
-
}
|
|
3180
|
-
case "union":
|
|
3181
|
-
return `v.union(${t.options.map(renderType).join(", ")})`;
|
|
3182
|
-
}
|
|
3183
|
-
throw new Error(`unknown field kind: ${t.kind}`);
|
|
3184
|
-
}
|
|
3185
|
-
|
|
3186
3009
|
// ../../../node_modules/zod/v3/external.js
|
|
3187
3010
|
var external_exports = {};
|
|
3188
3011
|
__export(external_exports, {
|
|
@@ -7324,85 +7147,638 @@ var listMetaSchema = external_exports.object({
|
|
|
7324
7147
|
truncated: external_exports.boolean().optional()
|
|
7325
7148
|
});
|
|
7326
7149
|
|
|
7327
|
-
// ../shared/src/
|
|
7328
|
-
var
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
}
|
|
7343
|
-
autoAccept: external_exports.boolean().optional(),
|
|
7344
|
-
/**
|
|
7345
|
-
* Opaque row clamp: AND-merged with caller Query on Read API / guest lists.
|
|
7346
|
-
* Sync membership uses `rowQuery.predicates` only (order/search ignored; maxScanLimit ignored).
|
|
7347
|
-
*/
|
|
7348
|
-
rowQuery: clampQuerySchema.optional(),
|
|
7349
|
-
/** Scan ceiling for Read/guest list plans; callers may only lower. Not applied to Sync/Resync. */
|
|
7350
|
-
maxScanLimit: external_exports.number().int().positive().optional()
|
|
7351
|
-
});
|
|
7352
|
-
var apiProfileSnapshotSchema = external_exports.object({
|
|
7353
|
-
id: external_exports.string(),
|
|
7354
|
-
name: external_exports.string(),
|
|
7355
|
-
slug: external_exports.string(),
|
|
7356
|
-
tables: external_exports.array(external_exports.string()),
|
|
7357
|
-
tableAccess: external_exports.array(apiTableAccessSchema).optional(),
|
|
7358
|
-
autoAcceptProposals: external_exports.boolean().optional(),
|
|
7359
|
-
apiVersion: external_exports.number(),
|
|
7360
|
-
updatedAt: external_exports.number()
|
|
7361
|
-
});
|
|
7362
|
-
var apiProfilesSchema = external_exports.array(apiProfileSnapshotSchema);
|
|
7363
|
-
function editorAccessEnabled(access2) {
|
|
7364
|
-
return access2.editorAccess === true;
|
|
7150
|
+
// ../shared/src/richDoc.ts
|
|
7151
|
+
var RICH_DOC_FORMAT = "blocknote";
|
|
7152
|
+
var RICH_DOC_VERSION = 1;
|
|
7153
|
+
var EMPTY_BLOCK_ID = "00000000-0000-4000-8000-000000000001";
|
|
7154
|
+
function emptyParagraphBlock() {
|
|
7155
|
+
return {
|
|
7156
|
+
id: EMPTY_BLOCK_ID,
|
|
7157
|
+
type: "paragraph",
|
|
7158
|
+
props: {
|
|
7159
|
+
backgroundColor: "default",
|
|
7160
|
+
textColor: "default",
|
|
7161
|
+
textAlignment: "left"
|
|
7162
|
+
},
|
|
7163
|
+
content: [],
|
|
7164
|
+
children: []
|
|
7165
|
+
};
|
|
7365
7166
|
}
|
|
7167
|
+
var EMPTY_RICH_DOC = JSON.stringify({
|
|
7168
|
+
format: RICH_DOC_FORMAT,
|
|
7169
|
+
version: RICH_DOC_VERSION,
|
|
7170
|
+
blocks: [emptyParagraphBlock()]
|
|
7171
|
+
});
|
|
7366
7172
|
|
|
7367
|
-
// ../
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7173
|
+
// ../shared/src/schemaTypes.ts
|
|
7174
|
+
var IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7175
|
+
var RESERVED_TABLE_NAMES = /* @__PURE__ */ new Set([
|
|
7176
|
+
"columnus_audit_log",
|
|
7177
|
+
"columnus_spaces",
|
|
7178
|
+
"columnus_manifest",
|
|
7179
|
+
"columnus_display_values",
|
|
7180
|
+
"columnus_api_profiles",
|
|
7181
|
+
"columnus_api_tokens",
|
|
7182
|
+
"columnus_api_outputs",
|
|
7183
|
+
"columnus_api_output_secrets",
|
|
7184
|
+
"columnus_api_sync_routes",
|
|
7185
|
+
"columnus_api_outbox",
|
|
7186
|
+
"columnus_api_delivery",
|
|
7187
|
+
"columnus_assets",
|
|
7188
|
+
"columnus_asset_versions",
|
|
7189
|
+
"columnus_asset_refs",
|
|
7190
|
+
"columnus_asset_profiles",
|
|
7191
|
+
"columnus_asset_settings",
|
|
7192
|
+
"columnus_asset_jobs"
|
|
7193
|
+
]);
|
|
7194
|
+
var displayTemplatesSchema = external_exports.object({
|
|
7195
|
+
id: external_exports.string().optional(),
|
|
7196
|
+
preview: external_exports.string().optional()
|
|
7197
|
+
});
|
|
7198
|
+
var TABLE_COLORS = [
|
|
7199
|
+
"brown",
|
|
7200
|
+
"muted-red",
|
|
7201
|
+
"red",
|
|
7202
|
+
"coral",
|
|
7203
|
+
"orange",
|
|
7204
|
+
"amber",
|
|
7205
|
+
"yellow",
|
|
7206
|
+
"gold",
|
|
7207
|
+
"blue",
|
|
7208
|
+
"light-blue",
|
|
7209
|
+
"cyan",
|
|
7210
|
+
"mint",
|
|
7211
|
+
"green",
|
|
7212
|
+
"dark-green",
|
|
7213
|
+
"lime",
|
|
7214
|
+
"light-green",
|
|
7215
|
+
"charcoal",
|
|
7216
|
+
"gray",
|
|
7217
|
+
"mauve",
|
|
7218
|
+
"pink",
|
|
7219
|
+
"purple",
|
|
7220
|
+
"deep-purple",
|
|
7221
|
+
"periwinkle",
|
|
7222
|
+
"lavender"
|
|
7223
|
+
];
|
|
7224
|
+
var tableColorSchema = external_exports.enum(TABLE_COLORS);
|
|
7225
|
+
var TABLE_KINDS = ["record", "asset"];
|
|
7226
|
+
var tableKindSchema = external_exports.enum(TABLE_KINDS);
|
|
7227
|
+
var assetBindingSchema = external_exports.object({
|
|
7228
|
+
profile: external_exports.string().min(1),
|
|
7229
|
+
enforced: external_exports.boolean().optional()
|
|
7230
|
+
});
|
|
7231
|
+
var fieldTypeSchema = external_exports.lazy(
|
|
7232
|
+
() => external_exports.discriminatedUnion("kind", [
|
|
7233
|
+
external_exports.object({ kind: external_exports.literal("string") }),
|
|
7234
|
+
external_exports.object({ kind: external_exports.literal("markdown") }),
|
|
7235
|
+
external_exports.object({ kind: external_exports.literal("number") }),
|
|
7236
|
+
external_exports.object({ kind: external_exports.literal("boolean") }),
|
|
7237
|
+
external_exports.object({ kind: external_exports.literal("bigint") }),
|
|
7238
|
+
external_exports.object({ kind: external_exports.literal("null") }),
|
|
7239
|
+
external_exports.object({ kind: external_exports.literal("any") }),
|
|
7240
|
+
external_exports.object({ kind: external_exports.literal("bytes") }),
|
|
7241
|
+
external_exports.object({ kind: external_exports.literal("file") }),
|
|
7242
|
+
external_exports.object({ kind: external_exports.literal("image") }),
|
|
7243
|
+
external_exports.object({ kind: external_exports.literal("date") }),
|
|
7244
|
+
external_exports.object({ kind: external_exports.literal("datetime") }),
|
|
7245
|
+
external_exports.object({ kind: external_exports.literal("id"), table: external_exports.string().regex(IDENT) }),
|
|
7246
|
+
external_exports.object({
|
|
7247
|
+
kind: external_exports.literal("literal"),
|
|
7248
|
+
value: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()])
|
|
7249
|
+
}),
|
|
7250
|
+
external_exports.object({ kind: external_exports.literal("array"), element: fieldTypeSchema }),
|
|
7251
|
+
external_exports.object({
|
|
7252
|
+
kind: external_exports.literal("object"),
|
|
7253
|
+
fields: external_exports.array(
|
|
7254
|
+
external_exports.object({
|
|
7255
|
+
name: external_exports.string().regex(IDENT),
|
|
7256
|
+
label: external_exports.string().optional(),
|
|
7257
|
+
type: fieldTypeSchema,
|
|
7258
|
+
optional: external_exports.boolean(),
|
|
7259
|
+
/** Nested image/file placements bind a Media profile like top-level ones. */
|
|
7260
|
+
asset: assetBindingSchema.optional()
|
|
7261
|
+
})
|
|
7262
|
+
)
|
|
7263
|
+
}),
|
|
7264
|
+
external_exports.object({
|
|
7265
|
+
kind: external_exports.literal("union"),
|
|
7266
|
+
options: external_exports.array(fieldTypeSchema).min(2)
|
|
7267
|
+
})
|
|
7268
|
+
])
|
|
7269
|
+
);
|
|
7270
|
+
var fieldSchema = external_exports.object({
|
|
7271
|
+
name: external_exports.string().regex(IDENT, "must be a valid identifier"),
|
|
7272
|
+
label: external_exports.string().optional(),
|
|
7273
|
+
type: fieldTypeSchema,
|
|
7274
|
+
optional: external_exports.boolean(),
|
|
7275
|
+
/** Image/file fields may pin a Media profile; existence is enforced at upload/pick. */
|
|
7276
|
+
asset: assetBindingSchema.optional()
|
|
7277
|
+
});
|
|
7278
|
+
var indexSchema = external_exports.object({
|
|
7279
|
+
name: external_exports.string().regex(IDENT),
|
|
7280
|
+
fields: external_exports.array(external_exports.string().regex(IDENT)).min(1)
|
|
7281
|
+
});
|
|
7282
|
+
var searchIndexSchema = external_exports.object({
|
|
7283
|
+
name: external_exports.string().regex(IDENT),
|
|
7284
|
+
searchField: external_exports.string().regex(IDENT),
|
|
7285
|
+
filterFields: external_exports.array(external_exports.string().regex(IDENT)).optional()
|
|
7286
|
+
});
|
|
7287
|
+
var tableSchema = external_exports.object({
|
|
7288
|
+
name: external_exports.string().regex(IDENT).refine((n) => !RESERVED_TABLE_NAMES.has(n), {
|
|
7289
|
+
message: "table name is reserved by the studio"
|
|
7290
|
+
}),
|
|
7291
|
+
label: external_exports.string().optional(),
|
|
7292
|
+
color: tableColorSchema.optional(),
|
|
7293
|
+
/** Asset metadata tables are typed root tables but never ordinary user records. */
|
|
7294
|
+
kind: tableKindSchema.optional().default("record"),
|
|
7295
|
+
fields: external_exports.array(fieldSchema),
|
|
7296
|
+
indexes: external_exports.array(indexSchema).default([]),
|
|
7297
|
+
searchIndexes: external_exports.array(searchIndexSchema).default([]),
|
|
7298
|
+
displayTemplates: displayTemplatesSchema.optional()
|
|
7299
|
+
});
|
|
7300
|
+
var manifestSchema = external_exports.object({
|
|
7301
|
+
tables: external_exports.array(tableSchema)
|
|
7302
|
+
}).superRefine((manifest, ctx) => {
|
|
7303
|
+
const tableNames = /* @__PURE__ */ new Set();
|
|
7304
|
+
const tablesByName = /* @__PURE__ */ new Map();
|
|
7305
|
+
for (const t of manifest.tables) {
|
|
7306
|
+
if (tableNames.has(t.name)) {
|
|
7307
|
+
ctx.addIssue({
|
|
7308
|
+
code: external_exports.ZodIssueCode.custom,
|
|
7309
|
+
message: `duplicate table: ${t.name}`,
|
|
7310
|
+
path: ["tables"]
|
|
7311
|
+
});
|
|
7312
|
+
}
|
|
7313
|
+
tableNames.add(t.name);
|
|
7314
|
+
tablesByName.set(t.name, t);
|
|
7315
|
+
if (tableKind(t) === "asset") {
|
|
7316
|
+
if (t.indexes.length > 0) {
|
|
7317
|
+
ctx.addIssue({
|
|
7318
|
+
code: external_exports.ZodIssueCode.custom,
|
|
7319
|
+
message: `${t.name} is an asset metadata table and cannot define indexes`,
|
|
7320
|
+
path: ["tables"]
|
|
7321
|
+
});
|
|
7322
|
+
}
|
|
7323
|
+
if (t.searchIndexes.length > 0) {
|
|
7324
|
+
ctx.addIssue({
|
|
7325
|
+
code: external_exports.ZodIssueCode.custom,
|
|
7326
|
+
message: `${t.name} is an asset metadata table and cannot define search indexes`,
|
|
7327
|
+
path: ["tables"]
|
|
7328
|
+
});
|
|
7329
|
+
}
|
|
7330
|
+
if (t.displayTemplates !== void 0) {
|
|
7331
|
+
ctx.addIssue({
|
|
7332
|
+
code: external_exports.ZodIssueCode.custom,
|
|
7333
|
+
message: `${t.name} is an asset metadata table and cannot define display templates`,
|
|
7334
|
+
path: ["tables"]
|
|
7335
|
+
});
|
|
7336
|
+
}
|
|
7337
|
+
if (t.color !== void 0) {
|
|
7338
|
+
ctx.addIssue({
|
|
7339
|
+
code: external_exports.ZodIssueCode.custom,
|
|
7340
|
+
message: `${t.name} is an asset metadata table and cannot define a color`,
|
|
7341
|
+
path: ["tables"]
|
|
7342
|
+
});
|
|
7343
|
+
}
|
|
7344
|
+
}
|
|
7345
|
+
const fieldNames = /* @__PURE__ */ new Set();
|
|
7346
|
+
for (const f of t.fields) {
|
|
7347
|
+
if (fieldNames.has(f.name)) {
|
|
7348
|
+
ctx.addIssue({
|
|
7349
|
+
code: external_exports.ZodIssueCode.custom,
|
|
7350
|
+
message: `duplicate field in ${t.name}: ${f.name}`,
|
|
7351
|
+
path: ["tables"]
|
|
7352
|
+
});
|
|
7353
|
+
}
|
|
7354
|
+
fieldNames.add(f.name);
|
|
7355
|
+
assertAssetBindingAllowed(ctx, t, f);
|
|
7356
|
+
}
|
|
7357
|
+
}
|
|
7358
|
+
for (const t of manifest.tables) {
|
|
7359
|
+
for (const f of t.fields) {
|
|
7360
|
+
const invalidRef = findInvalidReference(f.type, tablesByName);
|
|
7361
|
+
if (invalidRef) {
|
|
7362
|
+
ctx.addIssue({
|
|
7363
|
+
code: external_exports.ZodIssueCode.custom,
|
|
7364
|
+
message: `${t.name}.${f.name} ${invalidRef}`,
|
|
7365
|
+
path: ["tables"]
|
|
7366
|
+
});
|
|
7367
|
+
}
|
|
7368
|
+
}
|
|
7369
|
+
}
|
|
7370
|
+
});
|
|
7371
|
+
function findInvalidReference(t, tablesByName) {
|
|
7372
|
+
switch (t.kind) {
|
|
7373
|
+
case "id": {
|
|
7374
|
+
const target = tablesByName.get(t.table);
|
|
7375
|
+
if (!target) return `references unknown table: ${t.table}`;
|
|
7376
|
+
if (tableKind(target) === "asset") {
|
|
7377
|
+
return `cannot reference asset metadata table: ${t.table}`;
|
|
7378
|
+
}
|
|
7379
|
+
return null;
|
|
7380
|
+
}
|
|
7381
|
+
case "array":
|
|
7382
|
+
return findInvalidReference(t.element, tablesByName);
|
|
7383
|
+
case "object":
|
|
7384
|
+
for (const f of t.fields) {
|
|
7385
|
+
const r = findInvalidReference(f.type, tablesByName);
|
|
7386
|
+
if (r) return r;
|
|
7387
|
+
}
|
|
7388
|
+
return null;
|
|
7389
|
+
case "union":
|
|
7390
|
+
for (const o of t.options) {
|
|
7391
|
+
const r = findInvalidReference(o, tablesByName);
|
|
7392
|
+
if (r) return r;
|
|
7393
|
+
}
|
|
7394
|
+
return null;
|
|
7395
|
+
default:
|
|
7396
|
+
return null;
|
|
7397
|
+
}
|
|
7398
|
+
}
|
|
7399
|
+
function tableKind(table) {
|
|
7400
|
+
return table.kind ?? "record";
|
|
7401
|
+
}
|
|
7402
|
+
function isAssetTable(table) {
|
|
7403
|
+
return tableKind(table) === "asset";
|
|
7404
|
+
}
|
|
7405
|
+
function isFileFieldType(t) {
|
|
7406
|
+
return t.kind === "file" || t.kind === "image";
|
|
7407
|
+
}
|
|
7408
|
+
function isFileArrayFieldType(t) {
|
|
7409
|
+
return t.kind === "array" && (t.element.kind === "file" || t.element.kind === "image");
|
|
7410
|
+
}
|
|
7411
|
+
function isStorageFieldType(t) {
|
|
7412
|
+
return isFileFieldType(t) || isFileArrayFieldType(t);
|
|
7413
|
+
}
|
|
7414
|
+
function assertAssetBindingAllowed(ctx, table, field) {
|
|
7415
|
+
if (field.asset && tableKind(table) === "asset") {
|
|
7416
|
+
ctx.addIssue({
|
|
7417
|
+
code: external_exports.ZodIssueCode.custom,
|
|
7418
|
+
message: `${table.name}.${field.name} asset metadata fields cannot define a Media profile`,
|
|
7419
|
+
path: ["tables"]
|
|
7420
|
+
});
|
|
7421
|
+
} else if (field.asset && !isStorageFieldType(field.type)) {
|
|
7422
|
+
ctx.addIssue({
|
|
7423
|
+
code: external_exports.ZodIssueCode.custom,
|
|
7424
|
+
message: `${table.name}.${field.name} asset profile can only be set on image/file fields`,
|
|
7425
|
+
path: ["tables"]
|
|
7426
|
+
});
|
|
7427
|
+
}
|
|
7428
|
+
assertAssetBindingsInType(ctx, table, field.type);
|
|
7429
|
+
}
|
|
7430
|
+
function assertAssetBindingsInType(ctx, table, type) {
|
|
7431
|
+
switch (type.kind) {
|
|
7432
|
+
case "array":
|
|
7433
|
+
assertAssetBindingsInType(ctx, table, type.element);
|
|
7434
|
+
return;
|
|
7435
|
+
case "object":
|
|
7436
|
+
for (const field of type.fields) assertAssetBindingAllowed(ctx, table, field);
|
|
7437
|
+
return;
|
|
7438
|
+
case "union":
|
|
7439
|
+
for (const option of type.options) assertAssetBindingsInType(ctx, table, option);
|
|
7440
|
+
return;
|
|
7441
|
+
default:
|
|
7442
|
+
return;
|
|
7443
|
+
}
|
|
7444
|
+
}
|
|
7445
|
+
|
|
7446
|
+
// ../shared/src/assetFamily.ts
|
|
7447
|
+
var ASSET_FAMILIES = ["image", "document", "audio", "video", "vector", "other"];
|
|
7448
|
+
var ASSET_FAMILY_SET = new Set(ASSET_FAMILIES);
|
|
7449
|
+
var DISPLAYABLE_VECTOR_CONTENT_TYPES = ["image/svg+xml"];
|
|
7450
|
+
var DISPLAYABLE_VECTOR_CONTENT_TYPE_SET = new Set(
|
|
7451
|
+
DISPLAYABLE_VECTOR_CONTENT_TYPES
|
|
7452
|
+
);
|
|
7453
|
+
|
|
7454
|
+
// ../shared/src/assetGraph.ts
|
|
7455
|
+
var MAX_RENDER_MEGAPIXELS = 500;
|
|
7456
|
+
var MAX_RENDER_PIXELS = MAX_RENDER_MEGAPIXELS * 1e6;
|
|
7457
|
+
var ASSET_PROCESSING_STATUSES = ["ready", "pending", "failed", "dead_letter"];
|
|
7458
|
+
|
|
7459
|
+
// ../shared/src/schemaGenerator.ts
|
|
7460
|
+
var BANNER = `// AUTO-GENERATED by Columnus. Do not edit by hand \u2014
|
|
7461
|
+
// changes here will be overwritten when Columnus next saves the schema.
|
|
7462
|
+
`;
|
|
7463
|
+
var CONSUMER_BANNER = `// AUTO-GENERATED by columnus-schema-sync. Do not edit by hand \u2014
|
|
7464
|
+
// changes here will be overwritten when the schema sync CLI next runs.
|
|
7465
|
+
`;
|
|
7466
|
+
var HOST_SCHEMA_PROFILE = {
|
|
7467
|
+
includeColumnusTables: false
|
|
7468
|
+
};
|
|
7469
|
+
var AUDIT_TABLE_NAME = "columnus_audit_log";
|
|
7470
|
+
var SPACES_TABLE_NAME = "columnus_spaces";
|
|
7471
|
+
var MANIFEST_TABLE_NAME = "columnus_manifest";
|
|
7472
|
+
var DISPLAY_VALUES_TABLE_NAME = "columnus_display_values";
|
|
7473
|
+
var ASSETS_TABLE_NAME = "columnus_assets";
|
|
7474
|
+
var ASSET_FAMILY_LITERALS = ASSET_FAMILIES.map(
|
|
7475
|
+
(family) => ` v.literal(${JSON.stringify(family)}),`
|
|
7476
|
+
).join("\n");
|
|
7477
|
+
var ASSET_PROCESSING_STATUS_LITERALS = ASSET_PROCESSING_STATUSES.map(
|
|
7478
|
+
(status) => ` v.literal(${JSON.stringify(status)}),`
|
|
7479
|
+
).join("\n");
|
|
7480
|
+
var ASSETS_TABLE_SOURCE = ` ${ASSETS_TABLE_NAME}: defineTable({
|
|
7481
|
+
currentVersionId: v.optional(v.string()),
|
|
7482
|
+
currentOriginalStorageId: v.optional(v.id("_storage")),
|
|
7483
|
+
currentRenditionStorageIds: v.optional(v.record(v.string(), v.id("_storage"))),
|
|
7484
|
+
family: v.optional(
|
|
7485
|
+
v.union(
|
|
7486
|
+
${ASSET_FAMILY_LITERALS}
|
|
7487
|
+
),
|
|
7488
|
+
),
|
|
7489
|
+
profileSlugs: v.array(v.string()),
|
|
7490
|
+
focalPoint: v.optional(v.object({ x: v.number(), y: v.number() })),
|
|
7491
|
+
processingStatus: v.union(
|
|
7492
|
+
${ASSET_PROCESSING_STATUS_LITERALS}
|
|
7493
|
+
),
|
|
7494
|
+
contentType: v.optional(v.string()),
|
|
7495
|
+
filename: v.string(),
|
|
7496
|
+
size: v.optional(v.number()),
|
|
7497
|
+
isDeleted: v.boolean(),
|
|
7498
|
+
deletedAt: v.optional(v.number()),
|
|
7499
|
+
wipedAt: v.optional(v.number()),
|
|
7500
|
+
})
|
|
7501
|
+
.index("by_isDeleted_and_deletedAt", ["isDeleted", "deletedAt"])
|
|
7502
|
+
.index("by_isDeleted_and_family_and_wipedAt", ["isDeleted", "family", "wipedAt"])
|
|
7503
|
+
.index("by_isDeleted_and_wipedAt_and_deletedAt", ["isDeleted", "wipedAt", "deletedAt"])
|
|
7504
|
+
.searchIndex("search_filename", {
|
|
7505
|
+
searchField: "filename",
|
|
7506
|
+
filterFields: ["isDeleted", "family", "wipedAt"],
|
|
7507
|
+
}),`;
|
|
7508
|
+
var AUDIT_TABLE_SOURCE = ` ${AUDIT_TABLE_NAME}: defineTable({
|
|
7509
|
+
timestamp: v.number(),
|
|
7510
|
+
kind: v.union(v.literal("data"), v.literal("schema")),
|
|
7511
|
+
operation: v.string(),
|
|
7512
|
+
table: v.optional(v.string()),
|
|
7513
|
+
documentId: v.optional(v.string()),
|
|
7514
|
+
before: v.optional(v.any()),
|
|
7515
|
+
after: v.optional(v.any()),
|
|
7516
|
+
})
|
|
7517
|
+
.index("by_timestamp", ["timestamp"])
|
|
7518
|
+
.index("by_kind_and_timestamp", ["kind", "timestamp"])
|
|
7519
|
+
.index("by_table", ["table", "timestamp"])
|
|
7520
|
+
.index("by_document", ["documentId", "timestamp"]),`;
|
|
7521
|
+
var SPACES_TABLE_SOURCE = ` ${SPACES_TABLE_NAME}: defineTable({
|
|
7522
|
+
name: v.string(),
|
|
7523
|
+
slug: v.string(),
|
|
7524
|
+
description: v.optional(v.string()),
|
|
7525
|
+
icon: v.optional(v.string()),
|
|
7526
|
+
order: v.number(),
|
|
7527
|
+
tables: v.array(v.string()),
|
|
7528
|
+
erdLayoutJson: v.optional(v.string()),
|
|
7529
|
+
createdAt: v.number(),
|
|
7530
|
+
updatedAt: v.number(),
|
|
7531
|
+
})
|
|
7532
|
+
.index("by_order", ["order"])
|
|
7533
|
+
.index("by_slug", ["slug"]),`;
|
|
7534
|
+
var MANIFEST_DEPLOY_STATUS_SOURCE = MANIFEST_DEPLOY_STATUSES.map(
|
|
7535
|
+
(status) => ` v.literal(${JSON.stringify(status)}),`
|
|
7536
|
+
).join("\n");
|
|
7537
|
+
var MANIFEST_TABLE_SOURCE = ` ${MANIFEST_TABLE_NAME}: defineTable({
|
|
7538
|
+
manifestJson: v.string(),
|
|
7539
|
+
draftManifestJson: v.optional(v.string()),
|
|
7540
|
+
draftUpdatedAt: v.optional(v.number()),
|
|
7541
|
+
erdLayoutJson: v.optional(v.string()),
|
|
7542
|
+
draftErdLayoutJson: v.optional(v.string()),
|
|
7543
|
+
deployStatus: v.union(
|
|
7544
|
+
${MANIFEST_DEPLOY_STATUS_SOURCE}
|
|
7545
|
+
),
|
|
7546
|
+
deployError: v.optional(v.string()),
|
|
7547
|
+
deployLogTail: v.optional(v.string()),
|
|
7548
|
+
deployedAt: v.optional(v.number()),
|
|
7549
|
+
lastSaveAt: v.number(),
|
|
7550
|
+
}),`;
|
|
7551
|
+
var DISPLAY_VALUES_TABLE_SOURCE = ` ${DISPLAY_VALUES_TABLE_NAME}: defineTable({
|
|
7552
|
+
table: v.string(),
|
|
7553
|
+
documentId: v.string(),
|
|
7554
|
+
type: v.union(v.literal("id"), v.literal("preview")),
|
|
7555
|
+
value: v.string(),
|
|
7556
|
+
updatedAt: v.number(),
|
|
7557
|
+
})
|
|
7558
|
+
.index("by_document", ["table", "documentId"])
|
|
7559
|
+
.index("by_table_type", ["table", "type"])
|
|
7560
|
+
.index("by_table_type_value", ["table", "type", "value"])
|
|
7561
|
+
.searchIndex("search_value", {
|
|
7562
|
+
searchField: "value",
|
|
7563
|
+
filterFields: ["table", "type"],
|
|
7564
|
+
}),`;
|
|
7565
|
+
function columnusTablesSource(opts) {
|
|
7566
|
+
const parts = [];
|
|
7567
|
+
if (opts.includeAuditTable) parts.push(AUDIT_TABLE_SOURCE);
|
|
7568
|
+
if (opts.includeSpacesTable) parts.push(SPACES_TABLE_SOURCE);
|
|
7569
|
+
if (opts.includeManifestTable) parts.push(MANIFEST_TABLE_SOURCE);
|
|
7570
|
+
if (opts.includeDisplayValuesTable) parts.push(DISPLAY_VALUES_TABLE_SOURCE);
|
|
7571
|
+
return parts.join("\n");
|
|
7572
|
+
}
|
|
7573
|
+
function generateSchemaTs(manifest, opts) {
|
|
7574
|
+
const includeColumnusTables = opts?.includeColumnusTables ?? opts?.includeStudioTables ?? false;
|
|
7575
|
+
const includeSpacesTable = opts?.includeSpacesTable ?? true;
|
|
7576
|
+
const includeManifestTable = opts?.includeManifestTable ?? true;
|
|
7577
|
+
const includeAuditTable = opts?.includeAuditTable ?? true;
|
|
7578
|
+
const includeDisplayValuesTable = opts?.includeDisplayValuesTable ?? true;
|
|
7579
|
+
const assetFieldIds = opts?.assetFieldIds ?? "assets";
|
|
7580
|
+
const userTables = [...manifest.tables].sort((a, b) => a.name.localeCompare(b.name));
|
|
7581
|
+
const userBody = userTables.map((t) => ` ${t.name}: ${renderTable(t, assetFieldIds)},`).join("\n");
|
|
7582
|
+
let body;
|
|
7583
|
+
if (includeColumnusTables) {
|
|
7584
|
+
const columnusSource = columnusTablesSource({
|
|
7585
|
+
includeSpacesTable,
|
|
7586
|
+
includeManifestTable,
|
|
7587
|
+
includeAuditTable,
|
|
7588
|
+
includeDisplayValuesTable
|
|
7589
|
+
});
|
|
7590
|
+
body = [userBody, ASSETS_TABLE_SOURCE, columnusSource].filter(Boolean).join("\n");
|
|
7591
|
+
} else {
|
|
7592
|
+
body = [userBody, ASSETS_TABLE_SOURCE].filter(Boolean).join("\n");
|
|
7593
|
+
}
|
|
7594
|
+
const banner = includeColumnusTables ? BANNER : CONSUMER_BANNER;
|
|
7595
|
+
const schemaBody = body ? `${body}
|
|
7596
|
+
` : "";
|
|
7597
|
+
const schemaOpts = opts?.schemaValidation === false ? ", { schemaValidation: false }" : "";
|
|
7598
|
+
return `${banner}import { defineSchema, defineTable } from "convex/server";
|
|
7599
|
+
import { v } from "convex/values";
|
|
7600
|
+
|
|
7601
|
+
export default defineSchema({
|
|
7602
|
+
${schemaBody}}${schemaOpts});
|
|
7603
|
+
`;
|
|
7604
|
+
}
|
|
7605
|
+
function renderTable(t, assetFieldIds) {
|
|
7606
|
+
const fields = isAssetTable(t) ? [
|
|
7607
|
+
...t.fields,
|
|
7608
|
+
{
|
|
7609
|
+
name: "assetId",
|
|
7610
|
+
type: { kind: "id", table: ASSETS_TABLE_NAME },
|
|
7611
|
+
optional: false
|
|
7612
|
+
}
|
|
7613
|
+
] : t.fields;
|
|
7614
|
+
const fieldsBlock = fields.length ? `{
|
|
7615
|
+
${fields.map((f) => {
|
|
7616
|
+
const inner = renderType(f.type, assetFieldIds);
|
|
7617
|
+
const value = f.optional ? `v.optional(${inner})` : inner;
|
|
7618
|
+
return ` ${f.name}: ${value},`;
|
|
7619
|
+
}).join("\n")}
|
|
7620
|
+
}` : `{}`;
|
|
7621
|
+
let out = `defineTable(${fieldsBlock})`;
|
|
7622
|
+
const indexes = isAssetTable(t) ? [{ name: "by_assetId", fields: ["assetId"] }] : t.indexes;
|
|
7623
|
+
const searchIndexes = isAssetTable(t) ? [] : t.searchIndexes;
|
|
7624
|
+
const inlineSingleIndex = indexes.length === 1 && searchIndexes.length === 0;
|
|
7625
|
+
for (const idx of indexes) {
|
|
7626
|
+
const cols = idx.fields.map((c) => JSON.stringify(c)).join(", ");
|
|
7627
|
+
const sep = inlineSingleIndex ? "" : "\n ";
|
|
7628
|
+
out += `${sep}.index(${JSON.stringify(idx.name)}, [${cols}])`;
|
|
7629
|
+
}
|
|
7630
|
+
for (const sx of searchIndexes) {
|
|
7631
|
+
const cfg = [`searchField: ${JSON.stringify(sx.searchField)}`];
|
|
7632
|
+
if (sx.filterFields && sx.filterFields.length > 0) {
|
|
7633
|
+
cfg.push(`filterFields: [${sx.filterFields.map((c) => JSON.stringify(c)).join(", ")}]`);
|
|
7634
|
+
}
|
|
7635
|
+
out += `
|
|
7636
|
+
.searchIndex(${JSON.stringify(sx.name)}, { ${cfg.join(", ")} })`;
|
|
7637
|
+
}
|
|
7638
|
+
return out;
|
|
7639
|
+
}
|
|
7640
|
+
function renderAssetIdType(assetFieldIds) {
|
|
7641
|
+
const assetId = `v.id(${JSON.stringify(ASSETS_TABLE_NAME)})`;
|
|
7642
|
+
switch (assetFieldIds) {
|
|
7643
|
+
case "storage-or-assets":
|
|
7644
|
+
return `v.union(v.id("_storage"), ${assetId})`;
|
|
7645
|
+
case "assets":
|
|
7646
|
+
return assetId;
|
|
7647
|
+
default: {
|
|
7648
|
+
const _exhaustive = assetFieldIds;
|
|
7649
|
+
return _exhaustive;
|
|
7650
|
+
}
|
|
7651
|
+
}
|
|
7652
|
+
}
|
|
7653
|
+
function renderType(t, assetFieldIds) {
|
|
7654
|
+
switch (t.kind) {
|
|
7655
|
+
case "string":
|
|
7656
|
+
case "markdown":
|
|
7657
|
+
return "v.string()";
|
|
7658
|
+
case "number":
|
|
7659
|
+
return "v.number()";
|
|
7660
|
+
case "date":
|
|
7661
|
+
case "datetime":
|
|
7662
|
+
return "v.number()";
|
|
7663
|
+
case "boolean":
|
|
7664
|
+
return "v.boolean()";
|
|
7665
|
+
case "bigint":
|
|
7666
|
+
return "v.int64()";
|
|
7667
|
+
case "null":
|
|
7668
|
+
return "v.null()";
|
|
7669
|
+
case "any":
|
|
7670
|
+
return "v.any()";
|
|
7671
|
+
case "bytes":
|
|
7672
|
+
return "v.bytes()";
|
|
7673
|
+
case "file":
|
|
7674
|
+
case "image":
|
|
7675
|
+
return renderAssetIdType(assetFieldIds);
|
|
7676
|
+
case "id":
|
|
7677
|
+
return `v.id(${JSON.stringify(t.table)})`;
|
|
7678
|
+
case "literal":
|
|
7679
|
+
return `v.literal(${JSON.stringify(t.value)})`;
|
|
7680
|
+
case "array":
|
|
7681
|
+
return `v.array(${renderType(t.element, assetFieldIds)})`;
|
|
7682
|
+
case "object": {
|
|
7683
|
+
if (t.fields.length === 0) return `v.object({})`;
|
|
7684
|
+
const inner = t.fields.map((f) => {
|
|
7685
|
+
const inner2 = renderType(f.type, assetFieldIds);
|
|
7686
|
+
const value = f.optional ? `v.optional(${inner2})` : inner2;
|
|
7687
|
+
return `${f.name}: ${value}`;
|
|
7688
|
+
}).join(", ");
|
|
7689
|
+
return `v.object({ ${inner} })`;
|
|
7690
|
+
}
|
|
7691
|
+
case "union":
|
|
7692
|
+
return `v.union(${t.options.map((option) => renderType(option, assetFieldIds)).join(", ")})`;
|
|
7693
|
+
}
|
|
7694
|
+
throw new Error(`unknown field kind: ${t.kind}`);
|
|
7695
|
+
}
|
|
7696
|
+
|
|
7697
|
+
// ../shared/src/apiProfile.ts
|
|
7698
|
+
var apiTableAccessSchema = external_exports.object({
|
|
7699
|
+
table: external_exports.string(),
|
|
7700
|
+
read: external_exports.boolean(),
|
|
7701
|
+
/** Push to enabled webhook outputs. Missing/undefined = false (opt-in). */
|
|
7702
|
+
sync: external_exports.boolean().optional(),
|
|
7703
|
+
/**
|
|
7704
|
+
* Authenticated Studio/CMS editor write access for this table.
|
|
7705
|
+
* Missing/undefined = false (opt-in). Independent of public API-token propose.
|
|
7706
|
+
*/
|
|
7707
|
+
editorAccess: external_exports.boolean().optional(),
|
|
7708
|
+
propose: external_exports.object({
|
|
7709
|
+
ops: external_exports.object({ insert: external_exports.boolean(), update: external_exports.boolean(), delete: external_exports.boolean() }),
|
|
7710
|
+
allowedFields: external_exports.array(external_exports.string()).optional(),
|
|
7711
|
+
recordIds: external_exports.array(external_exports.string()).optional()
|
|
7712
|
+
}).optional(),
|
|
7713
|
+
autoAccept: external_exports.boolean().optional(),
|
|
7714
|
+
/**
|
|
7715
|
+
* Opaque row clamp: AND-merged with caller Query on Read API / guest lists.
|
|
7716
|
+
* Sync membership uses `rowQuery.predicates` only (order/search ignored; maxScanLimit ignored).
|
|
7717
|
+
*/
|
|
7718
|
+
rowQuery: clampQuerySchema.optional(),
|
|
7719
|
+
/** Scan ceiling for Read/guest list plans; callers may only lower. Not applied to Sync/Resync. */
|
|
7720
|
+
maxScanLimit: external_exports.number().int().positive().optional(),
|
|
7721
|
+
/**
|
|
7722
|
+
* Media source scope for the fixed `columnus_assets` source. Omit for all
|
|
7723
|
+
* live Media; an empty list intentionally grants no Media assets.
|
|
7724
|
+
*/
|
|
7725
|
+
assetProfiles: external_exports.array(external_exports.string().min(1)).max(100).optional()
|
|
7726
|
+
});
|
|
7727
|
+
var apiProfileSnapshotSchema = external_exports.object({
|
|
7728
|
+
id: external_exports.string(),
|
|
7729
|
+
name: external_exports.string(),
|
|
7730
|
+
slug: external_exports.string(),
|
|
7731
|
+
tables: external_exports.array(external_exports.string()),
|
|
7732
|
+
tableAccess: external_exports.array(apiTableAccessSchema).optional(),
|
|
7733
|
+
autoAcceptProposals: external_exports.boolean().optional(),
|
|
7734
|
+
apiVersion: external_exports.number(),
|
|
7735
|
+
updatedAt: external_exports.number()
|
|
7736
|
+
});
|
|
7737
|
+
var apiProfilesSchema = external_exports.array(apiProfileSnapshotSchema);
|
|
7738
|
+
function editorAccessEnabled(access2) {
|
|
7739
|
+
return access2.editorAccess === true;
|
|
7740
|
+
}
|
|
7741
|
+
var MEDIA_LIBRARY_JOURNAL_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
7742
|
+
|
|
7743
|
+
// ../api-codegen/src/generate-documents.ts
|
|
7744
|
+
function fieldTypeToTs(type) {
|
|
7745
|
+
switch (type.kind) {
|
|
7746
|
+
case "string":
|
|
7747
|
+
case "markdown":
|
|
7748
|
+
return "string";
|
|
7749
|
+
case "number":
|
|
7750
|
+
case "date":
|
|
7751
|
+
case "datetime":
|
|
7752
|
+
return "number";
|
|
7753
|
+
case "boolean":
|
|
7754
|
+
return "boolean";
|
|
7755
|
+
case "bigint":
|
|
7756
|
+
return "bigint";
|
|
7757
|
+
case "null":
|
|
7758
|
+
return "null";
|
|
7759
|
+
case "any":
|
|
7760
|
+
return "unknown";
|
|
7761
|
+
case "bytes":
|
|
7762
|
+
return "ArrayBuffer";
|
|
7763
|
+
case "file":
|
|
7764
|
+
case "image":
|
|
7765
|
+
return 'Id<"columnus_assets">';
|
|
7766
|
+
case "id":
|
|
7767
|
+
return `Id<${JSON.stringify(type.table)}>`;
|
|
7768
|
+
case "literal":
|
|
7769
|
+
return JSON.stringify(type.value);
|
|
7770
|
+
case "array":
|
|
7771
|
+
return `${fieldTypeToTs(type.element)}[]`;
|
|
7772
|
+
case "object": {
|
|
7773
|
+
if (type.fields.length === 0) return "Record<string, never>";
|
|
7774
|
+
const props = type.fields.map((f) => fieldToTsProperty(f));
|
|
7775
|
+
return `{ ${props.join("; ")} }`;
|
|
7776
|
+
}
|
|
7777
|
+
case "union":
|
|
7778
|
+
return type.options.map(fieldTypeToTs).join(" | ");
|
|
7779
|
+
default: {
|
|
7780
|
+
const _exhaustive = type;
|
|
7781
|
+
return _exhaustive;
|
|
7406
7782
|
}
|
|
7407
7783
|
}
|
|
7408
7784
|
}
|
|
@@ -7541,6 +7917,10 @@ ${getRefs}
|
|
|
7541
7917
|
}
|
|
7542
7918
|
|
|
7543
7919
|
// ../api-codegen/src/generate-client-pull.ts
|
|
7920
|
+
var ASSET_FAMILY_UNION = ASSET_FAMILIES.map((family) => JSON.stringify(family)).join(" | ");
|
|
7921
|
+
var ASSET_PROCESSING_STATUS_UNION = ASSET_PROCESSING_STATUSES.map(
|
|
7922
|
+
(status) => JSON.stringify(status)
|
|
7923
|
+
).join(" | ");
|
|
7544
7924
|
var READ_API_BANNER = `// AUTO-GENERATED by columnus-api pull. Do not edit by hand \u2014
|
|
7545
7925
|
// re-run \`columnus-api pull\` after profile or schema changes.
|
|
7546
7926
|
`;
|
|
@@ -7574,7 +7954,7 @@ function generateClientPullFiles(input) {
|
|
|
7574
7954
|
);
|
|
7575
7955
|
files.set("src/generated/cms-host-refs.ts", generateCmsHostRefsTs(manifest.tables, accesses));
|
|
7576
7956
|
files.set("src/generated/query.ts", emitQueryTs(READ_API_BANNER));
|
|
7577
|
-
files.set("src/generated/
|
|
7957
|
+
files.set("src/generated/asset-helpers.ts", generateAssetHelpersTs());
|
|
7578
7958
|
files.set(
|
|
7579
7959
|
"src/generated/read-api-meta.ts",
|
|
7580
7960
|
generateReadApiMetaTs(input.profileSlug, input.apiVersion, input.manifestHash)
|
|
@@ -7685,7 +8065,7 @@ function generateCmsHostRefsTs(tables, accesses) {
|
|
|
7685
8065
|
// (see @columnus/cms/server getConvexToken) \u2014 the public col_ token cannot
|
|
7686
8066
|
// call these. Patch tables require editorAccess; token propose ops /
|
|
7687
8067
|
// allowedFields do not apply. Anonymous site rendering keeps
|
|
7688
|
-
// columnus/read/<profile>.* and columnus/read/
|
|
8068
|
+
// columnus/read/<profile>.* and columnus/read/assets.* .
|
|
7689
8069
|
import { anyApi } from "convex/server";
|
|
7690
8070
|
import type { FunctionReference, PaginationOptions } from "convex/server";
|
|
7691
8071
|
import type { ListResult, Query } from "./query.js";
|
|
@@ -7737,18 +8117,93 @@ export const generateUploadUrlRef = anyApi.columnus.storage.generateUploadUrl as
|
|
|
7737
8117
|
string
|
|
7738
8118
|
>;
|
|
7739
8119
|
|
|
7740
|
-
export const
|
|
8120
|
+
export const deleteStorageFileRef = anyApi.columnus.storage.deleteStorageFile as FunctionReference<
|
|
8121
|
+
"mutation",
|
|
8122
|
+
"public",
|
|
8123
|
+
{ fileId: string },
|
|
8124
|
+
null
|
|
8125
|
+
>;
|
|
8126
|
+
|
|
8127
|
+
export const createAssetFromStorageRef = anyApi.columnus.assets.createAssetFromStorage as FunctionReference<
|
|
8128
|
+
"mutation",
|
|
8129
|
+
"public",
|
|
8130
|
+
{ storageId: string; filename: string; profile?: string },
|
|
8131
|
+
string
|
|
8132
|
+
>;
|
|
8133
|
+
|
|
8134
|
+
export const replaceAssetFromStorageRef = anyApi.columnus.assets.replaceAssetFromStorage as FunctionReference<
|
|
8135
|
+
"mutation",
|
|
8136
|
+
"public",
|
|
8137
|
+
{ assetId: string; storageId: string; filename: string },
|
|
8138
|
+
null
|
|
8139
|
+
>;
|
|
8140
|
+
|
|
8141
|
+
export const listAssetsRef = anyApi.columnus.assets.listAssets as FunctionReference<
|
|
8142
|
+
"query",
|
|
8143
|
+
"public",
|
|
8144
|
+
{
|
|
8145
|
+
paginationOpts: PaginationOptions;
|
|
8146
|
+
deleted?: boolean;
|
|
8147
|
+
search?: string;
|
|
8148
|
+
family?: ${ASSET_FAMILY_UNION};
|
|
8149
|
+
pickerKind?: "image" | "file";
|
|
8150
|
+
},
|
|
8151
|
+
{
|
|
8152
|
+
page: Array<{
|
|
8153
|
+
_id: string;
|
|
8154
|
+
filename: string;
|
|
8155
|
+
family: ${ASSET_FAMILY_UNION};
|
|
8156
|
+
contentType?: string;
|
|
8157
|
+
size?: number;
|
|
8158
|
+
profileSlugs: string[];
|
|
8159
|
+
}>;
|
|
8160
|
+
continueCursor: string;
|
|
8161
|
+
isDone: boolean;
|
|
8162
|
+
}
|
|
8163
|
+
>;
|
|
8164
|
+
|
|
8165
|
+
export const addProfileToAssetRef = anyApi.columnus.assets.addProfileToAsset as FunctionReference<
|
|
8166
|
+
"mutation",
|
|
8167
|
+
"public",
|
|
8168
|
+
{ assetId: string; profile: string },
|
|
8169
|
+
null
|
|
8170
|
+
>;
|
|
8171
|
+
|
|
8172
|
+
export const getAssetSettingsRef = anyApi.columnus.assets.getAssetSettings as FunctionReference<
|
|
7741
8173
|
"query",
|
|
7742
8174
|
"public",
|
|
7743
|
-
|
|
7744
|
-
|
|
8175
|
+
Record<string, never>,
|
|
8176
|
+
{ warnBytes: number; rejectBytes: number } | null
|
|
8177
|
+
>;
|
|
8178
|
+
|
|
8179
|
+
/** Original URL plus size \u2014 what a checkout or a download link needs, not a stamp. */
|
|
8180
|
+
export const resolveAssetOriginalsRef = anyApi.columnus.assets.resolveAssetOriginals as FunctionReference<
|
|
8181
|
+
"query",
|
|
8182
|
+
"public",
|
|
8183
|
+
{ assetIds: string[] },
|
|
8184
|
+
Array<{ assetId: string; url: string | null; contentType?: string; size?: number }>
|
|
7745
8185
|
>;
|
|
7746
8186
|
|
|
7747
|
-
|
|
8187
|
+
/** One resolved slot: a rendition url, or why there is not one to paint yet. */
|
|
8188
|
+
export type AssetSlotDisplay = {
|
|
8189
|
+
kind: "rendition" | "original" | "pending" | "failed";
|
|
8190
|
+
url: string | null;
|
|
8191
|
+
};
|
|
8192
|
+
|
|
8193
|
+
/** CMS stamps resolve the compact delivery slot (G13/G36), not the original. */
|
|
8194
|
+
export const resolveAssetDisplayRef = anyApi.columnus.assets.resolveAssetDisplay as FunctionReference<
|
|
7748
8195
|
"query",
|
|
7749
8196
|
"public",
|
|
7750
|
-
{
|
|
7751
|
-
Array<{
|
|
8197
|
+
{ assetIds: string[] },
|
|
8198
|
+
Array<{
|
|
8199
|
+
assetId: string;
|
|
8200
|
+
originalUrl: string | null;
|
|
8201
|
+
compact?: AssetSlotDisplay;
|
|
8202
|
+
preview?: AssetSlotDisplay;
|
|
8203
|
+
processingStatus?: ${ASSET_PROCESSING_STATUS_UNION};
|
|
8204
|
+
contentType?: string;
|
|
8205
|
+
size?: number;
|
|
8206
|
+
}>
|
|
7752
8207
|
>;
|
|
7753
8208
|
|
|
7754
8209
|
export const getDisplayValuesRef = anyApi.columnus.display.getDisplayValues as FunctionReference<
|
|
@@ -7785,8 +8240,13 @@ export const cmsHostRefs = {
|
|
|
7785
8240
|
publishMyProfileProposal: publishMyProfileProposalRef,
|
|
7786
8241
|
withdrawMyProfileProposal: withdrawMyProfileProposalRef,
|
|
7787
8242
|
generateUploadUrl: generateUploadUrlRef,
|
|
7788
|
-
|
|
7789
|
-
|
|
8243
|
+
deleteStorageFile: deleteStorageFileRef,
|
|
8244
|
+
createAssetFromStorage: createAssetFromStorageRef,
|
|
8245
|
+
replaceAssetFromStorage: replaceAssetFromStorageRef,
|
|
8246
|
+
listAssets: listAssetsRef,
|
|
8247
|
+
addProfileToAsset: addProfileToAssetRef,
|
|
8248
|
+
getAssetSettings: getAssetSettingsRef,
|
|
8249
|
+
resolveAssetDisplay: resolveAssetDisplayRef,
|
|
7790
8250
|
getDisplayValues: getDisplayValuesRef,
|
|
7791
8251
|
listRows: listRowsRef,
|
|
7792
8252
|
getRow: getRowRef,
|
|
@@ -7826,7 +8286,7 @@ export type ManifestTable = {
|
|
|
7826
8286
|
export type PulledManifest = { tables: ManifestTable[] };
|
|
7827
8287
|
`;
|
|
7828
8288
|
}
|
|
7829
|
-
function
|
|
8289
|
+
function generateAssetHelpersTs() {
|
|
7830
8290
|
return `${READ_API_BANNER}import type { ManifestField, ManifestFieldType } from "./manifest-types.js";
|
|
7831
8291
|
import type { DocByTable, TableName } from "./documents.js";
|
|
7832
8292
|
|
|
@@ -7835,29 +8295,29 @@ export function toDocumentId(value: unknown): string | undefined {
|
|
|
7835
8295
|
return typeof value === "string" ? value : String(value);
|
|
7836
8296
|
}
|
|
7837
8297
|
|
|
7838
|
-
function
|
|
7839
|
-
return type.kind === "file";
|
|
8298
|
+
function isAssetFieldType(type: ManifestFieldType): boolean {
|
|
8299
|
+
return type.kind === "file" || type.kind === "image";
|
|
7840
8300
|
}
|
|
7841
8301
|
|
|
7842
|
-
function
|
|
7843
|
-
return type.kind === "array" && type.element.kind === "file";
|
|
8302
|
+
function isAssetArrayFieldType(type: ManifestFieldType): boolean {
|
|
8303
|
+
return type.kind === "array" && (type.element.kind === "file" || type.element.kind === "image");
|
|
7844
8304
|
}
|
|
7845
8305
|
|
|
7846
|
-
function
|
|
7847
|
-
return
|
|
8306
|
+
function isAssetFieldOrArray(type: ManifestFieldType): boolean {
|
|
8307
|
+
return isAssetFieldType(type) || isAssetArrayFieldType(type);
|
|
7848
8308
|
}
|
|
7849
8309
|
|
|
7850
|
-
export function
|
|
8310
|
+
export function collectAssetIds(
|
|
7851
8311
|
value: unknown,
|
|
7852
8312
|
type: ManifestFieldType,
|
|
7853
8313
|
out: Set<string> = new Set(),
|
|
7854
8314
|
): Set<string> {
|
|
7855
|
-
if (
|
|
8315
|
+
if (isAssetFieldType(type)) {
|
|
7856
8316
|
const id = toDocumentId(value);
|
|
7857
8317
|
if (id) out.add(id);
|
|
7858
8318
|
return out;
|
|
7859
8319
|
}
|
|
7860
|
-
if (
|
|
8320
|
+
if (isAssetArrayFieldType(type) && Array.isArray(value)) {
|
|
7861
8321
|
for (const item of value) {
|
|
7862
8322
|
const id = toDocumentId(item);
|
|
7863
8323
|
if (id) out.add(id);
|
|
@@ -7866,7 +8326,7 @@ export function collectStorageIds(
|
|
|
7866
8326
|
return out;
|
|
7867
8327
|
}
|
|
7868
8328
|
|
|
7869
|
-
export function
|
|
8329
|
+
export function collectAssetIdsFromRow<T extends TableName>(
|
|
7870
8330
|
row: DocByTable[T] | undefined,
|
|
7871
8331
|
fields: readonly ManifestField[],
|
|
7872
8332
|
out: Set<string> = new Set(),
|
|
@@ -7874,8 +8334,8 @@ export function collectStorageIdsFromRow<T extends TableName>(
|
|
|
7874
8334
|
if (!row) return out;
|
|
7875
8335
|
const values = row as Record<string, unknown>;
|
|
7876
8336
|
for (const field of fields) {
|
|
7877
|
-
if (!
|
|
7878
|
-
|
|
8337
|
+
if (!isAssetFieldOrArray(field.type)) continue;
|
|
8338
|
+
collectAssetIds(values[field.name], field.type, out);
|
|
7879
8339
|
}
|
|
7880
8340
|
return out;
|
|
7881
8341
|
}
|
|
@@ -7939,22 +8399,22 @@ ${listHooks}
|
|
|
7939
8399
|
|
|
7940
8400
|
${getHooks}
|
|
7941
8401
|
|
|
7942
|
-
export function
|
|
8402
|
+
export function useAssetOriginals(assetIds: string[]) {
|
|
7943
8403
|
const apiToken = readApiToken();
|
|
7944
|
-
const ids =
|
|
8404
|
+
const ids = assetIds.filter(Boolean);
|
|
7945
8405
|
const results = useQuery(
|
|
7946
|
-
anyApi.columnus.read.
|
|
7947
|
-
ids.length > 0 ? { apiToken,
|
|
8406
|
+
anyApi.columnus.read.assets.getAssetOriginals,
|
|
8407
|
+
ids.length > 0 ? { apiToken, assetIds: ids } : "skip",
|
|
7948
8408
|
);
|
|
7949
8409
|
return results ?? [];
|
|
7950
8410
|
}
|
|
7951
8411
|
|
|
7952
|
-
export function
|
|
8412
|
+
export function useAssetExpansions(assetIds: string[]) {
|
|
7953
8413
|
const apiToken = readApiToken();
|
|
7954
|
-
const ids =
|
|
8414
|
+
const ids = assetIds.filter(Boolean);
|
|
7955
8415
|
const results = useQuery(
|
|
7956
|
-
anyApi.columnus.read.
|
|
7957
|
-
ids.length > 0 ? { apiToken,
|
|
8416
|
+
anyApi.columnus.read.assets.getAssetExpansions,
|
|
8417
|
+
ids.length > 0 ? { apiToken, assetIds: ids } : "skip",
|
|
7958
8418
|
);
|
|
7959
8419
|
return results ?? [];
|
|
7960
8420
|
}
|
|
@@ -7977,199 +8437,6 @@ function isApiTokenFormat(token) {
|
|
|
7977
8437
|
import { access, writeFile } from "node:fs/promises";
|
|
7978
8438
|
import path2 from "node:path";
|
|
7979
8439
|
|
|
7980
|
-
// ../shared/src/richDoc.ts
|
|
7981
|
-
var RICH_DOC_FORMAT = "blocknote";
|
|
7982
|
-
var RICH_DOC_VERSION = 1;
|
|
7983
|
-
var EMPTY_BLOCK_ID = "00000000-0000-4000-8000-000000000001";
|
|
7984
|
-
function emptyParagraphBlock() {
|
|
7985
|
-
return {
|
|
7986
|
-
id: EMPTY_BLOCK_ID,
|
|
7987
|
-
type: "paragraph",
|
|
7988
|
-
props: {
|
|
7989
|
-
backgroundColor: "default",
|
|
7990
|
-
textColor: "default",
|
|
7991
|
-
textAlignment: "left"
|
|
7992
|
-
},
|
|
7993
|
-
content: [],
|
|
7994
|
-
children: []
|
|
7995
|
-
};
|
|
7996
|
-
}
|
|
7997
|
-
var EMPTY_RICH_DOC = JSON.stringify({
|
|
7998
|
-
format: RICH_DOC_FORMAT,
|
|
7999
|
-
version: RICH_DOC_VERSION,
|
|
8000
|
-
blocks: [emptyParagraphBlock()]
|
|
8001
|
-
});
|
|
8002
|
-
|
|
8003
|
-
// ../shared/src/schemaTypes.ts
|
|
8004
|
-
var IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
8005
|
-
var RESERVED_TABLE_NAMES = /* @__PURE__ */ new Set([
|
|
8006
|
-
"columnus_audit_log",
|
|
8007
|
-
"columnus_spaces",
|
|
8008
|
-
"columnus_manifest",
|
|
8009
|
-
"columnus_display_values",
|
|
8010
|
-
"columnus_api_profiles",
|
|
8011
|
-
"columnus_api_tokens",
|
|
8012
|
-
"columnus_api_outputs",
|
|
8013
|
-
"columnus_api_output_secrets",
|
|
8014
|
-
"columnus_api_sync_routes",
|
|
8015
|
-
"columnus_api_outbox",
|
|
8016
|
-
"columnus_api_delivery"
|
|
8017
|
-
]);
|
|
8018
|
-
var displayTemplatesSchema = external_exports.object({
|
|
8019
|
-
id: external_exports.string().optional(),
|
|
8020
|
-
preview: external_exports.string().optional()
|
|
8021
|
-
});
|
|
8022
|
-
var TABLE_COLORS = [
|
|
8023
|
-
"brown",
|
|
8024
|
-
"muted-red",
|
|
8025
|
-
"red",
|
|
8026
|
-
"coral",
|
|
8027
|
-
"orange",
|
|
8028
|
-
"amber",
|
|
8029
|
-
"yellow",
|
|
8030
|
-
"gold",
|
|
8031
|
-
"blue",
|
|
8032
|
-
"light-blue",
|
|
8033
|
-
"cyan",
|
|
8034
|
-
"mint",
|
|
8035
|
-
"green",
|
|
8036
|
-
"dark-green",
|
|
8037
|
-
"lime",
|
|
8038
|
-
"light-green",
|
|
8039
|
-
"charcoal",
|
|
8040
|
-
"gray",
|
|
8041
|
-
"mauve",
|
|
8042
|
-
"pink",
|
|
8043
|
-
"purple",
|
|
8044
|
-
"deep-purple",
|
|
8045
|
-
"periwinkle",
|
|
8046
|
-
"lavender"
|
|
8047
|
-
];
|
|
8048
|
-
var tableColorSchema = external_exports.enum(TABLE_COLORS);
|
|
8049
|
-
var fieldTypeSchema = external_exports.lazy(
|
|
8050
|
-
() => external_exports.discriminatedUnion("kind", [
|
|
8051
|
-
external_exports.object({ kind: external_exports.literal("string") }),
|
|
8052
|
-
external_exports.object({ kind: external_exports.literal("markdown") }),
|
|
8053
|
-
external_exports.object({ kind: external_exports.literal("number") }),
|
|
8054
|
-
external_exports.object({ kind: external_exports.literal("boolean") }),
|
|
8055
|
-
external_exports.object({ kind: external_exports.literal("bigint") }),
|
|
8056
|
-
external_exports.object({ kind: external_exports.literal("null") }),
|
|
8057
|
-
external_exports.object({ kind: external_exports.literal("any") }),
|
|
8058
|
-
external_exports.object({ kind: external_exports.literal("bytes") }),
|
|
8059
|
-
external_exports.object({ kind: external_exports.literal("file") }),
|
|
8060
|
-
external_exports.object({ kind: external_exports.literal("image") }),
|
|
8061
|
-
external_exports.object({ kind: external_exports.literal("date") }),
|
|
8062
|
-
external_exports.object({ kind: external_exports.literal("datetime") }),
|
|
8063
|
-
external_exports.object({ kind: external_exports.literal("id"), table: external_exports.string().regex(IDENT) }),
|
|
8064
|
-
external_exports.object({
|
|
8065
|
-
kind: external_exports.literal("literal"),
|
|
8066
|
-
value: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()])
|
|
8067
|
-
}),
|
|
8068
|
-
external_exports.object({ kind: external_exports.literal("array"), element: fieldTypeSchema }),
|
|
8069
|
-
external_exports.object({
|
|
8070
|
-
kind: external_exports.literal("object"),
|
|
8071
|
-
fields: external_exports.array(
|
|
8072
|
-
external_exports.object({
|
|
8073
|
-
name: external_exports.string().regex(IDENT),
|
|
8074
|
-
label: external_exports.string().optional(),
|
|
8075
|
-
type: fieldTypeSchema,
|
|
8076
|
-
optional: external_exports.boolean()
|
|
8077
|
-
})
|
|
8078
|
-
)
|
|
8079
|
-
}),
|
|
8080
|
-
external_exports.object({
|
|
8081
|
-
kind: external_exports.literal("union"),
|
|
8082
|
-
options: external_exports.array(fieldTypeSchema).min(2)
|
|
8083
|
-
})
|
|
8084
|
-
])
|
|
8085
|
-
);
|
|
8086
|
-
var fieldSchema = external_exports.object({
|
|
8087
|
-
name: external_exports.string().regex(IDENT, "must be a valid identifier"),
|
|
8088
|
-
label: external_exports.string().optional(),
|
|
8089
|
-
type: fieldTypeSchema,
|
|
8090
|
-
optional: external_exports.boolean()
|
|
8091
|
-
});
|
|
8092
|
-
var indexSchema = external_exports.object({
|
|
8093
|
-
name: external_exports.string().regex(IDENT),
|
|
8094
|
-
fields: external_exports.array(external_exports.string().regex(IDENT)).min(1)
|
|
8095
|
-
});
|
|
8096
|
-
var searchIndexSchema = external_exports.object({
|
|
8097
|
-
name: external_exports.string().regex(IDENT),
|
|
8098
|
-
searchField: external_exports.string().regex(IDENT),
|
|
8099
|
-
filterFields: external_exports.array(external_exports.string().regex(IDENT)).optional()
|
|
8100
|
-
});
|
|
8101
|
-
var tableSchema = external_exports.object({
|
|
8102
|
-
name: external_exports.string().regex(IDENT).refine((n) => !RESERVED_TABLE_NAMES.has(n), {
|
|
8103
|
-
message: "table name is reserved by the studio"
|
|
8104
|
-
}),
|
|
8105
|
-
label: external_exports.string().optional(),
|
|
8106
|
-
color: tableColorSchema.optional(),
|
|
8107
|
-
fields: external_exports.array(fieldSchema),
|
|
8108
|
-
indexes: external_exports.array(indexSchema).default([]),
|
|
8109
|
-
searchIndexes: external_exports.array(searchIndexSchema).default([]),
|
|
8110
|
-
displayTemplates: displayTemplatesSchema.optional()
|
|
8111
|
-
});
|
|
8112
|
-
var manifestSchema = external_exports.object({
|
|
8113
|
-
tables: external_exports.array(tableSchema)
|
|
8114
|
-
}).superRefine((manifest, ctx) => {
|
|
8115
|
-
const tableNames = /* @__PURE__ */ new Set();
|
|
8116
|
-
for (const t of manifest.tables) {
|
|
8117
|
-
if (tableNames.has(t.name)) {
|
|
8118
|
-
ctx.addIssue({
|
|
8119
|
-
code: external_exports.ZodIssueCode.custom,
|
|
8120
|
-
message: `duplicate table: ${t.name}`,
|
|
8121
|
-
path: ["tables"]
|
|
8122
|
-
});
|
|
8123
|
-
}
|
|
8124
|
-
tableNames.add(t.name);
|
|
8125
|
-
const fieldNames = /* @__PURE__ */ new Set();
|
|
8126
|
-
for (const f of t.fields) {
|
|
8127
|
-
if (fieldNames.has(f.name)) {
|
|
8128
|
-
ctx.addIssue({
|
|
8129
|
-
code: external_exports.ZodIssueCode.custom,
|
|
8130
|
-
message: `duplicate field in ${t.name}: ${f.name}`,
|
|
8131
|
-
path: ["tables"]
|
|
8132
|
-
});
|
|
8133
|
-
}
|
|
8134
|
-
fieldNames.add(f.name);
|
|
8135
|
-
}
|
|
8136
|
-
}
|
|
8137
|
-
for (const t of manifest.tables) {
|
|
8138
|
-
for (const f of t.fields) {
|
|
8139
|
-
const danglingRef = findDanglingRef(f.type, tableNames);
|
|
8140
|
-
if (danglingRef) {
|
|
8141
|
-
ctx.addIssue({
|
|
8142
|
-
code: external_exports.ZodIssueCode.custom,
|
|
8143
|
-
message: `${t.name}.${f.name} references unknown table: ${danglingRef}`,
|
|
8144
|
-
path: ["tables"]
|
|
8145
|
-
});
|
|
8146
|
-
}
|
|
8147
|
-
}
|
|
8148
|
-
}
|
|
8149
|
-
});
|
|
8150
|
-
function findDanglingRef(t, known) {
|
|
8151
|
-
switch (t.kind) {
|
|
8152
|
-
case "id":
|
|
8153
|
-
return known.has(t.table) ? null : t.table;
|
|
8154
|
-
case "array":
|
|
8155
|
-
return findDanglingRef(t.element, known);
|
|
8156
|
-
case "object":
|
|
8157
|
-
for (const f of t.fields) {
|
|
8158
|
-
const r = findDanglingRef(f.type, known);
|
|
8159
|
-
if (r) return r;
|
|
8160
|
-
}
|
|
8161
|
-
return null;
|
|
8162
|
-
case "union":
|
|
8163
|
-
for (const o of t.options) {
|
|
8164
|
-
const r = findDanglingRef(o, known);
|
|
8165
|
-
if (r) return r;
|
|
8166
|
-
}
|
|
8167
|
-
return null;
|
|
8168
|
-
default:
|
|
8169
|
-
return null;
|
|
8170
|
-
}
|
|
8171
|
-
}
|
|
8172
|
-
|
|
8173
8440
|
// ../shared/src/schemaShrinkValidators.ts
|
|
8174
8441
|
import { v } from "convex/values";
|
|
8175
8442
|
var cleanupStateValidator = v.object({
|
|
@@ -8197,6 +8464,14 @@ var cleanupStateValidator = v.object({
|
|
|
8197
8464
|
desiredManifestHash: v.string()
|
|
8198
8465
|
});
|
|
8199
8466
|
|
|
8467
|
+
// ../shared/src/assetJobs.ts
|
|
8468
|
+
var ASSET_JOB_LEASE_MS = 15 * 6e4;
|
|
8469
|
+
var ASSET_JOB_BACKOFF_MS = [15e3, 6e4, 5 * 6e4, 60 * 6e4];
|
|
8470
|
+
|
|
8471
|
+
// ../shared/src/assetSettings.ts
|
|
8472
|
+
var DEFAULT_MEDIA_WARN_BYTES = 10 * 1024 * 1024 * 1024;
|
|
8473
|
+
var DEFAULT_MEDIA_REJECT_BYTES = 100 * 1024 * 1024 * 1024;
|
|
8474
|
+
|
|
8200
8475
|
// ../shared/src/csv.ts
|
|
8201
8476
|
var import_papaparse = __toESM(require_papaparse(), 1);
|
|
8202
8477
|
|
|
@@ -8541,17 +8816,25 @@ var encoder = new TextEncoder();
|
|
|
8541
8816
|
|
|
8542
8817
|
// src/run-convex-codegen-project.ts
|
|
8543
8818
|
import { spawnSync } from "node:child_process";
|
|
8819
|
+
import { existsSync } from "node:fs";
|
|
8820
|
+
import { join } from "node:path";
|
|
8821
|
+
var CODEGEN_TIMEOUT_MS = 6e4;
|
|
8544
8822
|
function runConvexCodegenProject(projectDir, options) {
|
|
8823
|
+
if (!existsSync(join(projectDir, "convex"))) {
|
|
8824
|
+
return { ok: false, error: `no convex directory in ${projectDir}` };
|
|
8825
|
+
}
|
|
8545
8826
|
const baseEnv = { ...process.env, ...options?.env };
|
|
8546
8827
|
delete baseEnv.FORCE_COLOR;
|
|
8547
8828
|
baseEnv.NO_COLOR = "1";
|
|
8548
8829
|
const result = spawnSync("npx", ["convex", "codegen", "--typecheck", "disable"], {
|
|
8549
8830
|
cwd: projectDir,
|
|
8550
8831
|
env: baseEnv,
|
|
8551
|
-
encoding: "utf8"
|
|
8832
|
+
encoding: "utf8",
|
|
8833
|
+
timeout: CODEGEN_TIMEOUT_MS
|
|
8552
8834
|
});
|
|
8553
8835
|
if (result.status === 0) return { ok: true };
|
|
8554
|
-
const detail = `${result.
|
|
8836
|
+
const detail = `${result.error?.message ?? ""}
|
|
8837
|
+
${result.stderr ?? ""}
|
|
8555
8838
|
${result.stdout ?? ""}`.trim();
|
|
8556
8839
|
return { ok: false, error: detail || "convex codegen failed" };
|
|
8557
8840
|
}
|