@columnus/api-cli 0.1.55 → 0.1.56
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 +754 -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,637 @@ 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 = 50;
|
|
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
|
+
|
|
7742
|
+
// ../api-codegen/src/generate-documents.ts
|
|
7743
|
+
function fieldTypeToTs(type) {
|
|
7744
|
+
switch (type.kind) {
|
|
7745
|
+
case "string":
|
|
7746
|
+
case "markdown":
|
|
7747
|
+
return "string";
|
|
7748
|
+
case "number":
|
|
7749
|
+
case "date":
|
|
7750
|
+
case "datetime":
|
|
7751
|
+
return "number";
|
|
7752
|
+
case "boolean":
|
|
7753
|
+
return "boolean";
|
|
7754
|
+
case "bigint":
|
|
7755
|
+
return "bigint";
|
|
7756
|
+
case "null":
|
|
7757
|
+
return "null";
|
|
7758
|
+
case "any":
|
|
7759
|
+
return "unknown";
|
|
7760
|
+
case "bytes":
|
|
7761
|
+
return "ArrayBuffer";
|
|
7762
|
+
case "file":
|
|
7763
|
+
case "image":
|
|
7764
|
+
return 'Id<"columnus_assets">';
|
|
7765
|
+
case "id":
|
|
7766
|
+
return `Id<${JSON.stringify(type.table)}>`;
|
|
7767
|
+
case "literal":
|
|
7768
|
+
return JSON.stringify(type.value);
|
|
7769
|
+
case "array":
|
|
7770
|
+
return `${fieldTypeToTs(type.element)}[]`;
|
|
7771
|
+
case "object": {
|
|
7772
|
+
if (type.fields.length === 0) return "Record<string, never>";
|
|
7773
|
+
const props = type.fields.map((f) => fieldToTsProperty(f));
|
|
7774
|
+
return `{ ${props.join("; ")} }`;
|
|
7775
|
+
}
|
|
7776
|
+
case "union":
|
|
7777
|
+
return type.options.map(fieldTypeToTs).join(" | ");
|
|
7778
|
+
default: {
|
|
7779
|
+
const _exhaustive = type;
|
|
7780
|
+
return _exhaustive;
|
|
7406
7781
|
}
|
|
7407
7782
|
}
|
|
7408
7783
|
}
|
|
@@ -7541,6 +7916,10 @@ ${getRefs}
|
|
|
7541
7916
|
}
|
|
7542
7917
|
|
|
7543
7918
|
// ../api-codegen/src/generate-client-pull.ts
|
|
7919
|
+
var ASSET_FAMILY_UNION = ASSET_FAMILIES.map((family) => JSON.stringify(family)).join(" | ");
|
|
7920
|
+
var ASSET_PROCESSING_STATUS_UNION = ASSET_PROCESSING_STATUSES.map(
|
|
7921
|
+
(status) => JSON.stringify(status)
|
|
7922
|
+
).join(" | ");
|
|
7544
7923
|
var READ_API_BANNER = `// AUTO-GENERATED by columnus-api pull. Do not edit by hand \u2014
|
|
7545
7924
|
// re-run \`columnus-api pull\` after profile or schema changes.
|
|
7546
7925
|
`;
|
|
@@ -7574,7 +7953,7 @@ function generateClientPullFiles(input) {
|
|
|
7574
7953
|
);
|
|
7575
7954
|
files.set("src/generated/cms-host-refs.ts", generateCmsHostRefsTs(manifest.tables, accesses));
|
|
7576
7955
|
files.set("src/generated/query.ts", emitQueryTs(READ_API_BANNER));
|
|
7577
|
-
files.set("src/generated/
|
|
7956
|
+
files.set("src/generated/asset-helpers.ts", generateAssetHelpersTs());
|
|
7578
7957
|
files.set(
|
|
7579
7958
|
"src/generated/read-api-meta.ts",
|
|
7580
7959
|
generateReadApiMetaTs(input.profileSlug, input.apiVersion, input.manifestHash)
|
|
@@ -7685,7 +8064,7 @@ function generateCmsHostRefsTs(tables, accesses) {
|
|
|
7685
8064
|
// (see @columnus/cms/server getConvexToken) \u2014 the public col_ token cannot
|
|
7686
8065
|
// call these. Patch tables require editorAccess; token propose ops /
|
|
7687
8066
|
// allowedFields do not apply. Anonymous site rendering keeps
|
|
7688
|
-
// columnus/read/<profile>.* and columnus/read/
|
|
8067
|
+
// columnus/read/<profile>.* and columnus/read/assets.* .
|
|
7689
8068
|
import { anyApi } from "convex/server";
|
|
7690
8069
|
import type { FunctionReference, PaginationOptions } from "convex/server";
|
|
7691
8070
|
import type { ListResult, Query } from "./query.js";
|
|
@@ -7737,18 +8116,86 @@ export const generateUploadUrlRef = anyApi.columnus.storage.generateUploadUrl as
|
|
|
7737
8116
|
string
|
|
7738
8117
|
>;
|
|
7739
8118
|
|
|
7740
|
-
export const
|
|
8119
|
+
export const deleteStorageFileRef = anyApi.columnus.storage.deleteStorageFile as FunctionReference<
|
|
8120
|
+
"mutation",
|
|
8121
|
+
"public",
|
|
8122
|
+
{ fileId: string },
|
|
8123
|
+
null
|
|
8124
|
+
>;
|
|
8125
|
+
|
|
8126
|
+
export const createAssetFromStorageRef = anyApi.columnus.assets.createAssetFromStorage as FunctionReference<
|
|
8127
|
+
"mutation",
|
|
8128
|
+
"public",
|
|
8129
|
+
{ storageId: string; filename: string; profile?: string },
|
|
8130
|
+
string
|
|
8131
|
+
>;
|
|
8132
|
+
|
|
8133
|
+
export const listAssetsRef = anyApi.columnus.assets.listAssets as FunctionReference<
|
|
8134
|
+
"query",
|
|
8135
|
+
"public",
|
|
8136
|
+
{
|
|
8137
|
+
paginationOpts: PaginationOptions;
|
|
8138
|
+
deleted?: boolean;
|
|
8139
|
+
search?: string;
|
|
8140
|
+
family?: ${ASSET_FAMILY_UNION};
|
|
8141
|
+
pickerKind?: "image" | "file";
|
|
8142
|
+
},
|
|
8143
|
+
{
|
|
8144
|
+
page: Array<{
|
|
8145
|
+
_id: string;
|
|
8146
|
+
filename: string;
|
|
8147
|
+
family: ${ASSET_FAMILY_UNION};
|
|
8148
|
+
contentType?: string;
|
|
8149
|
+
size?: number;
|
|
8150
|
+
profileSlugs: string[];
|
|
8151
|
+
}>;
|
|
8152
|
+
continueCursor: string;
|
|
8153
|
+
isDone: boolean;
|
|
8154
|
+
}
|
|
8155
|
+
>;
|
|
8156
|
+
|
|
8157
|
+
export const addProfileToAssetRef = anyApi.columnus.assets.addProfileToAsset as FunctionReference<
|
|
8158
|
+
"mutation",
|
|
8159
|
+
"public",
|
|
8160
|
+
{ assetId: string; profile: string },
|
|
8161
|
+
null
|
|
8162
|
+
>;
|
|
8163
|
+
|
|
8164
|
+
export const getAssetSettingsRef = anyApi.columnus.assets.getAssetSettings as FunctionReference<
|
|
7741
8165
|
"query",
|
|
7742
8166
|
"public",
|
|
7743
|
-
|
|
7744
|
-
|
|
8167
|
+
Record<string, never>,
|
|
8168
|
+
{ warnBytes: number; rejectBytes: number } | null
|
|
8169
|
+
>;
|
|
8170
|
+
|
|
8171
|
+
/** Original URL plus size \u2014 what a checkout or a download link needs, not a stamp. */
|
|
8172
|
+
export const resolveAssetOriginalsRef = anyApi.columnus.assets.resolveAssetOriginals as FunctionReference<
|
|
8173
|
+
"query",
|
|
8174
|
+
"public",
|
|
8175
|
+
{ assetIds: string[] },
|
|
8176
|
+
Array<{ assetId: string; url: string | null; contentType?: string; size?: number }>
|
|
7745
8177
|
>;
|
|
7746
8178
|
|
|
7747
|
-
|
|
8179
|
+
/** One resolved slot: a rendition url, or why there is not one to paint yet. */
|
|
8180
|
+
export type AssetSlotDisplay = {
|
|
8181
|
+
kind: "rendition" | "original" | "pending" | "failed";
|
|
8182
|
+
url: string | null;
|
|
8183
|
+
};
|
|
8184
|
+
|
|
8185
|
+
/** CMS stamps resolve the compact delivery slot (G13/G36), not the original. */
|
|
8186
|
+
export const resolveAssetDisplayRef = anyApi.columnus.assets.resolveAssetDisplay as FunctionReference<
|
|
7748
8187
|
"query",
|
|
7749
8188
|
"public",
|
|
7750
|
-
{
|
|
7751
|
-
Array<{
|
|
8189
|
+
{ assetIds: string[] },
|
|
8190
|
+
Array<{
|
|
8191
|
+
assetId: string;
|
|
8192
|
+
originalUrl: string | null;
|
|
8193
|
+
compact?: AssetSlotDisplay;
|
|
8194
|
+
preview?: AssetSlotDisplay;
|
|
8195
|
+
processingStatus?: ${ASSET_PROCESSING_STATUS_UNION};
|
|
8196
|
+
contentType?: string;
|
|
8197
|
+
size?: number;
|
|
8198
|
+
}>
|
|
7752
8199
|
>;
|
|
7753
8200
|
|
|
7754
8201
|
export const getDisplayValuesRef = anyApi.columnus.display.getDisplayValues as FunctionReference<
|
|
@@ -7785,8 +8232,12 @@ export const cmsHostRefs = {
|
|
|
7785
8232
|
publishMyProfileProposal: publishMyProfileProposalRef,
|
|
7786
8233
|
withdrawMyProfileProposal: withdrawMyProfileProposalRef,
|
|
7787
8234
|
generateUploadUrl: generateUploadUrlRef,
|
|
7788
|
-
|
|
7789
|
-
|
|
8235
|
+
deleteStorageFile: deleteStorageFileRef,
|
|
8236
|
+
createAssetFromStorage: createAssetFromStorageRef,
|
|
8237
|
+
listAssets: listAssetsRef,
|
|
8238
|
+
addProfileToAsset: addProfileToAssetRef,
|
|
8239
|
+
getAssetSettings: getAssetSettingsRef,
|
|
8240
|
+
resolveAssetDisplay: resolveAssetDisplayRef,
|
|
7790
8241
|
getDisplayValues: getDisplayValuesRef,
|
|
7791
8242
|
listRows: listRowsRef,
|
|
7792
8243
|
getRow: getRowRef,
|
|
@@ -7826,7 +8277,7 @@ export type ManifestTable = {
|
|
|
7826
8277
|
export type PulledManifest = { tables: ManifestTable[] };
|
|
7827
8278
|
`;
|
|
7828
8279
|
}
|
|
7829
|
-
function
|
|
8280
|
+
function generateAssetHelpersTs() {
|
|
7830
8281
|
return `${READ_API_BANNER}import type { ManifestField, ManifestFieldType } from "./manifest-types.js";
|
|
7831
8282
|
import type { DocByTable, TableName } from "./documents.js";
|
|
7832
8283
|
|
|
@@ -7835,29 +8286,29 @@ export function toDocumentId(value: unknown): string | undefined {
|
|
|
7835
8286
|
return typeof value === "string" ? value : String(value);
|
|
7836
8287
|
}
|
|
7837
8288
|
|
|
7838
|
-
function
|
|
7839
|
-
return type.kind === "file";
|
|
8289
|
+
function isAssetFieldType(type: ManifestFieldType): boolean {
|
|
8290
|
+
return type.kind === "file" || type.kind === "image";
|
|
7840
8291
|
}
|
|
7841
8292
|
|
|
7842
|
-
function
|
|
7843
|
-
return type.kind === "array" && type.element.kind === "file";
|
|
8293
|
+
function isAssetArrayFieldType(type: ManifestFieldType): boolean {
|
|
8294
|
+
return type.kind === "array" && (type.element.kind === "file" || type.element.kind === "image");
|
|
7844
8295
|
}
|
|
7845
8296
|
|
|
7846
|
-
function
|
|
7847
|
-
return
|
|
8297
|
+
function isAssetFieldOrArray(type: ManifestFieldType): boolean {
|
|
8298
|
+
return isAssetFieldType(type) || isAssetArrayFieldType(type);
|
|
7848
8299
|
}
|
|
7849
8300
|
|
|
7850
|
-
export function
|
|
8301
|
+
export function collectAssetIds(
|
|
7851
8302
|
value: unknown,
|
|
7852
8303
|
type: ManifestFieldType,
|
|
7853
8304
|
out: Set<string> = new Set(),
|
|
7854
8305
|
): Set<string> {
|
|
7855
|
-
if (
|
|
8306
|
+
if (isAssetFieldType(type)) {
|
|
7856
8307
|
const id = toDocumentId(value);
|
|
7857
8308
|
if (id) out.add(id);
|
|
7858
8309
|
return out;
|
|
7859
8310
|
}
|
|
7860
|
-
if (
|
|
8311
|
+
if (isAssetArrayFieldType(type) && Array.isArray(value)) {
|
|
7861
8312
|
for (const item of value) {
|
|
7862
8313
|
const id = toDocumentId(item);
|
|
7863
8314
|
if (id) out.add(id);
|
|
@@ -7866,7 +8317,7 @@ export function collectStorageIds(
|
|
|
7866
8317
|
return out;
|
|
7867
8318
|
}
|
|
7868
8319
|
|
|
7869
|
-
export function
|
|
8320
|
+
export function collectAssetIdsFromRow<T extends TableName>(
|
|
7870
8321
|
row: DocByTable[T] | undefined,
|
|
7871
8322
|
fields: readonly ManifestField[],
|
|
7872
8323
|
out: Set<string> = new Set(),
|
|
@@ -7874,8 +8325,8 @@ export function collectStorageIdsFromRow<T extends TableName>(
|
|
|
7874
8325
|
if (!row) return out;
|
|
7875
8326
|
const values = row as Record<string, unknown>;
|
|
7876
8327
|
for (const field of fields) {
|
|
7877
|
-
if (!
|
|
7878
|
-
|
|
8328
|
+
if (!isAssetFieldOrArray(field.type)) continue;
|
|
8329
|
+
collectAssetIds(values[field.name], field.type, out);
|
|
7879
8330
|
}
|
|
7880
8331
|
return out;
|
|
7881
8332
|
}
|
|
@@ -7939,22 +8390,22 @@ ${listHooks}
|
|
|
7939
8390
|
|
|
7940
8391
|
${getHooks}
|
|
7941
8392
|
|
|
7942
|
-
export function
|
|
8393
|
+
export function useAssetOriginals(assetIds: string[]) {
|
|
7943
8394
|
const apiToken = readApiToken();
|
|
7944
|
-
const ids =
|
|
8395
|
+
const ids = assetIds.filter(Boolean);
|
|
7945
8396
|
const results = useQuery(
|
|
7946
|
-
anyApi.columnus.read.
|
|
7947
|
-
ids.length > 0 ? { apiToken,
|
|
8397
|
+
anyApi.columnus.read.assets.getAssetOriginals,
|
|
8398
|
+
ids.length > 0 ? { apiToken, assetIds: ids } : "skip",
|
|
7948
8399
|
);
|
|
7949
8400
|
return results ?? [];
|
|
7950
8401
|
}
|
|
7951
8402
|
|
|
7952
|
-
export function
|
|
8403
|
+
export function useAssetExpansions(assetIds: string[]) {
|
|
7953
8404
|
const apiToken = readApiToken();
|
|
7954
|
-
const ids =
|
|
8405
|
+
const ids = assetIds.filter(Boolean);
|
|
7955
8406
|
const results = useQuery(
|
|
7956
|
-
anyApi.columnus.read.
|
|
7957
|
-
ids.length > 0 ? { apiToken,
|
|
8407
|
+
anyApi.columnus.read.assets.getAssetExpansions,
|
|
8408
|
+
ids.length > 0 ? { apiToken, assetIds: ids } : "skip",
|
|
7958
8409
|
);
|
|
7959
8410
|
return results ?? [];
|
|
7960
8411
|
}
|
|
@@ -7977,199 +8428,6 @@ function isApiTokenFormat(token) {
|
|
|
7977
8428
|
import { access, writeFile } from "node:fs/promises";
|
|
7978
8429
|
import path2 from "node:path";
|
|
7979
8430
|
|
|
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
8431
|
// ../shared/src/schemaShrinkValidators.ts
|
|
8174
8432
|
import { v } from "convex/values";
|
|
8175
8433
|
var cleanupStateValidator = v.object({
|
|
@@ -8197,6 +8455,14 @@ var cleanupStateValidator = v.object({
|
|
|
8197
8455
|
desiredManifestHash: v.string()
|
|
8198
8456
|
});
|
|
8199
8457
|
|
|
8458
|
+
// ../shared/src/assetJobs.ts
|
|
8459
|
+
var ASSET_JOB_LEASE_MS = 3 * 6e4;
|
|
8460
|
+
var ASSET_JOB_BACKOFF_MS = [15e3, 6e4, 5 * 6e4, 60 * 6e4];
|
|
8461
|
+
|
|
8462
|
+
// ../shared/src/assetSettings.ts
|
|
8463
|
+
var DEFAULT_MEDIA_WARN_BYTES = 10 * 1024 * 1024 * 1024;
|
|
8464
|
+
var DEFAULT_MEDIA_REJECT_BYTES = 100 * 1024 * 1024 * 1024;
|
|
8465
|
+
|
|
8200
8466
|
// ../shared/src/csv.ts
|
|
8201
8467
|
var import_papaparse = __toESM(require_papaparse(), 1);
|
|
8202
8468
|
|
|
@@ -8541,17 +8807,25 @@ var encoder = new TextEncoder();
|
|
|
8541
8807
|
|
|
8542
8808
|
// src/run-convex-codegen-project.ts
|
|
8543
8809
|
import { spawnSync } from "node:child_process";
|
|
8810
|
+
import { existsSync } from "node:fs";
|
|
8811
|
+
import { join } from "node:path";
|
|
8812
|
+
var CODEGEN_TIMEOUT_MS = 6e4;
|
|
8544
8813
|
function runConvexCodegenProject(projectDir, options) {
|
|
8814
|
+
if (!existsSync(join(projectDir, "convex"))) {
|
|
8815
|
+
return { ok: false, error: `no convex directory in ${projectDir}` };
|
|
8816
|
+
}
|
|
8545
8817
|
const baseEnv = { ...process.env, ...options?.env };
|
|
8546
8818
|
delete baseEnv.FORCE_COLOR;
|
|
8547
8819
|
baseEnv.NO_COLOR = "1";
|
|
8548
8820
|
const result = spawnSync("npx", ["convex", "codegen", "--typecheck", "disable"], {
|
|
8549
8821
|
cwd: projectDir,
|
|
8550
8822
|
env: baseEnv,
|
|
8551
|
-
encoding: "utf8"
|
|
8823
|
+
encoding: "utf8",
|
|
8824
|
+
timeout: CODEGEN_TIMEOUT_MS
|
|
8552
8825
|
});
|
|
8553
8826
|
if (result.status === 0) return { ok: true };
|
|
8554
|
-
const detail = `${result.
|
|
8827
|
+
const detail = `${result.error?.message ?? ""}
|
|
8828
|
+
${result.stderr ?? ""}
|
|
8555
8829
|
${result.stdout ?? ""}`.trim();
|
|
8556
8830
|
return { ok: false, error: detail || "convex codegen failed" };
|
|
8557
8831
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@columnus/api-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.56",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "columnus-api pull and dev — live-sync read API codegen for Columnus consumer apps",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"ws": "^8.21.3"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"convex": "^1.
|
|
27
|
+
"convex": "^1.44.0"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|