@columnus/api-cli 0.1.0 → 0.1.47
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 +1779 -1606
- package/package.json +3 -13
- package/README.md +0 -71
package/dist/cli.js
CHANGED
|
@@ -3043,6 +3043,22 @@ function apiProfileSlugToConvexModuleSegment(slug) {
|
|
|
3043
3043
|
return slug.replace(/-/g, "_");
|
|
3044
3044
|
}
|
|
3045
3045
|
|
|
3046
|
+
// ../shared/src/readApiQuery.ts
|
|
3047
|
+
function readApiQueryExportName(kind, tableName) {
|
|
3048
|
+
return `${kind}${tableName}`;
|
|
3049
|
+
}
|
|
3050
|
+
function proposeApiExportName(op, tableName) {
|
|
3051
|
+
return `propose${op[0].toUpperCase()}${op.slice(1)}${tableName}`;
|
|
3052
|
+
}
|
|
3053
|
+
function readApiQueryModuleSegment(profileSlug) {
|
|
3054
|
+
return apiProfileSlugToConvexModuleSegment(profileSlug);
|
|
3055
|
+
}
|
|
3056
|
+
function readApiAnyApiPath(profileSlug, kind, tableName) {
|
|
3057
|
+
const segment = readApiQueryModuleSegment(profileSlug);
|
|
3058
|
+
const exportName = readApiQueryExportName(kind, tableName);
|
|
3059
|
+
return `anyApi.columnus.read.${segment}.${exportName}.${exportName}`;
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3046
3062
|
// ../shared/src/schemaGenerator.ts
|
|
3047
3063
|
var BANNER = `// AUTO-GENERATED by Columnus. Do not edit by hand \u2014
|
|
3048
3064
|
// changes here will be overwritten when Columnus next saves the schema.
|
|
@@ -3220,1153 +3236,636 @@ function renderType(t) {
|
|
|
3220
3236
|
throw new Error(`unknown field kind: ${t.kind}`);
|
|
3221
3237
|
}
|
|
3222
3238
|
|
|
3223
|
-
//
|
|
3224
|
-
|
|
3225
|
-
|
|
3239
|
+
// ../../../node_modules/zod/v3/external.js
|
|
3240
|
+
var external_exports = {};
|
|
3241
|
+
__export(external_exports, {
|
|
3242
|
+
BRAND: () => BRAND,
|
|
3243
|
+
DIRTY: () => DIRTY,
|
|
3244
|
+
EMPTY_PATH: () => EMPTY_PATH,
|
|
3245
|
+
INVALID: () => INVALID,
|
|
3246
|
+
NEVER: () => NEVER,
|
|
3247
|
+
OK: () => OK,
|
|
3248
|
+
ParseStatus: () => ParseStatus,
|
|
3249
|
+
Schema: () => ZodType,
|
|
3250
|
+
ZodAny: () => ZodAny,
|
|
3251
|
+
ZodArray: () => ZodArray,
|
|
3252
|
+
ZodBigInt: () => ZodBigInt,
|
|
3253
|
+
ZodBoolean: () => ZodBoolean,
|
|
3254
|
+
ZodBranded: () => ZodBranded,
|
|
3255
|
+
ZodCatch: () => ZodCatch,
|
|
3256
|
+
ZodDate: () => ZodDate,
|
|
3257
|
+
ZodDefault: () => ZodDefault,
|
|
3258
|
+
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
|
|
3259
|
+
ZodEffects: () => ZodEffects,
|
|
3260
|
+
ZodEnum: () => ZodEnum,
|
|
3261
|
+
ZodError: () => ZodError,
|
|
3262
|
+
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
|
|
3263
|
+
ZodFunction: () => ZodFunction,
|
|
3264
|
+
ZodIntersection: () => ZodIntersection,
|
|
3265
|
+
ZodIssueCode: () => ZodIssueCode,
|
|
3266
|
+
ZodLazy: () => ZodLazy,
|
|
3267
|
+
ZodLiteral: () => ZodLiteral,
|
|
3268
|
+
ZodMap: () => ZodMap,
|
|
3269
|
+
ZodNaN: () => ZodNaN,
|
|
3270
|
+
ZodNativeEnum: () => ZodNativeEnum,
|
|
3271
|
+
ZodNever: () => ZodNever,
|
|
3272
|
+
ZodNull: () => ZodNull,
|
|
3273
|
+
ZodNullable: () => ZodNullable,
|
|
3274
|
+
ZodNumber: () => ZodNumber,
|
|
3275
|
+
ZodObject: () => ZodObject,
|
|
3276
|
+
ZodOptional: () => ZodOptional,
|
|
3277
|
+
ZodParsedType: () => ZodParsedType,
|
|
3278
|
+
ZodPipeline: () => ZodPipeline,
|
|
3279
|
+
ZodPromise: () => ZodPromise,
|
|
3280
|
+
ZodReadonly: () => ZodReadonly,
|
|
3281
|
+
ZodRecord: () => ZodRecord,
|
|
3282
|
+
ZodSchema: () => ZodType,
|
|
3283
|
+
ZodSet: () => ZodSet,
|
|
3284
|
+
ZodString: () => ZodString,
|
|
3285
|
+
ZodSymbol: () => ZodSymbol,
|
|
3286
|
+
ZodTransformer: () => ZodEffects,
|
|
3287
|
+
ZodTuple: () => ZodTuple,
|
|
3288
|
+
ZodType: () => ZodType,
|
|
3289
|
+
ZodUndefined: () => ZodUndefined,
|
|
3290
|
+
ZodUnion: () => ZodUnion,
|
|
3291
|
+
ZodUnknown: () => ZodUnknown,
|
|
3292
|
+
ZodVoid: () => ZodVoid,
|
|
3293
|
+
addIssueToContext: () => addIssueToContext,
|
|
3294
|
+
any: () => anyType,
|
|
3295
|
+
array: () => arrayType,
|
|
3296
|
+
bigint: () => bigIntType,
|
|
3297
|
+
boolean: () => booleanType,
|
|
3298
|
+
coerce: () => coerce,
|
|
3299
|
+
custom: () => custom,
|
|
3300
|
+
date: () => dateType,
|
|
3301
|
+
datetimeRegex: () => datetimeRegex,
|
|
3302
|
+
defaultErrorMap: () => en_default,
|
|
3303
|
+
discriminatedUnion: () => discriminatedUnionType,
|
|
3304
|
+
effect: () => effectsType,
|
|
3305
|
+
enum: () => enumType,
|
|
3306
|
+
function: () => functionType,
|
|
3307
|
+
getErrorMap: () => getErrorMap,
|
|
3308
|
+
getParsedType: () => getParsedType,
|
|
3309
|
+
instanceof: () => instanceOfType,
|
|
3310
|
+
intersection: () => intersectionType,
|
|
3311
|
+
isAborted: () => isAborted,
|
|
3312
|
+
isAsync: () => isAsync,
|
|
3313
|
+
isDirty: () => isDirty,
|
|
3314
|
+
isValid: () => isValid,
|
|
3315
|
+
late: () => late,
|
|
3316
|
+
lazy: () => lazyType,
|
|
3317
|
+
literal: () => literalType,
|
|
3318
|
+
makeIssue: () => makeIssue,
|
|
3319
|
+
map: () => mapType,
|
|
3320
|
+
nan: () => nanType,
|
|
3321
|
+
nativeEnum: () => nativeEnumType,
|
|
3322
|
+
never: () => neverType,
|
|
3323
|
+
null: () => nullType,
|
|
3324
|
+
nullable: () => nullableType,
|
|
3325
|
+
number: () => numberType,
|
|
3326
|
+
object: () => objectType,
|
|
3327
|
+
objectUtil: () => objectUtil,
|
|
3328
|
+
oboolean: () => oboolean,
|
|
3329
|
+
onumber: () => onumber,
|
|
3330
|
+
optional: () => optionalType,
|
|
3331
|
+
ostring: () => ostring,
|
|
3332
|
+
pipeline: () => pipelineType,
|
|
3333
|
+
preprocess: () => preprocessType,
|
|
3334
|
+
promise: () => promiseType,
|
|
3335
|
+
quotelessJson: () => quotelessJson,
|
|
3336
|
+
record: () => recordType,
|
|
3337
|
+
set: () => setType,
|
|
3338
|
+
setErrorMap: () => setErrorMap,
|
|
3339
|
+
strictObject: () => strictObjectType,
|
|
3340
|
+
string: () => stringType,
|
|
3341
|
+
symbol: () => symbolType,
|
|
3342
|
+
transformer: () => effectsType,
|
|
3343
|
+
tuple: () => tupleType,
|
|
3344
|
+
undefined: () => undefinedType,
|
|
3345
|
+
union: () => unionType,
|
|
3346
|
+
unknown: () => unknownType,
|
|
3347
|
+
util: () => util,
|
|
3348
|
+
void: () => voidType
|
|
3349
|
+
});
|
|
3350
|
+
|
|
3351
|
+
// ../../../node_modules/zod/v3/helpers/util.js
|
|
3352
|
+
var util;
|
|
3353
|
+
(function(util2) {
|
|
3354
|
+
util2.assertEqual = (_) => {
|
|
3355
|
+
};
|
|
3356
|
+
function assertIs(_arg) {
|
|
3357
|
+
}
|
|
3358
|
+
util2.assertIs = assertIs;
|
|
3359
|
+
function assertNever(_x) {
|
|
3360
|
+
throw new Error();
|
|
3361
|
+
}
|
|
3362
|
+
util2.assertNever = assertNever;
|
|
3363
|
+
util2.arrayToEnum = (items) => {
|
|
3364
|
+
const obj = {};
|
|
3365
|
+
for (const item of items) {
|
|
3366
|
+
obj[item] = item;
|
|
3367
|
+
}
|
|
3368
|
+
return obj;
|
|
3369
|
+
};
|
|
3370
|
+
util2.getValidEnumValues = (obj) => {
|
|
3371
|
+
const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
3372
|
+
const filtered = {};
|
|
3373
|
+
for (const k of validKeys) {
|
|
3374
|
+
filtered[k] = obj[k];
|
|
3375
|
+
}
|
|
3376
|
+
return util2.objectValues(filtered);
|
|
3377
|
+
};
|
|
3378
|
+
util2.objectValues = (obj) => {
|
|
3379
|
+
return util2.objectKeys(obj).map(function(e) {
|
|
3380
|
+
return obj[e];
|
|
3381
|
+
});
|
|
3382
|
+
};
|
|
3383
|
+
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
3384
|
+
const keys = [];
|
|
3385
|
+
for (const key in object) {
|
|
3386
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
3387
|
+
keys.push(key);
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
return keys;
|
|
3391
|
+
};
|
|
3392
|
+
util2.find = (arr, checker) => {
|
|
3393
|
+
for (const item of arr) {
|
|
3394
|
+
if (checker(item))
|
|
3395
|
+
return item;
|
|
3396
|
+
}
|
|
3397
|
+
return void 0;
|
|
3398
|
+
};
|
|
3399
|
+
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
3400
|
+
function joinValues(array, separator = " | ") {
|
|
3401
|
+
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
3402
|
+
}
|
|
3403
|
+
util2.joinValues = joinValues;
|
|
3404
|
+
util2.jsonStringifyReplacer = (_, value) => {
|
|
3405
|
+
if (typeof value === "bigint") {
|
|
3406
|
+
return value.toString();
|
|
3407
|
+
}
|
|
3408
|
+
return value;
|
|
3409
|
+
};
|
|
3410
|
+
})(util || (util = {}));
|
|
3411
|
+
var objectUtil;
|
|
3412
|
+
(function(objectUtil2) {
|
|
3413
|
+
objectUtil2.mergeShapes = (first, second) => {
|
|
3414
|
+
return {
|
|
3415
|
+
...first,
|
|
3416
|
+
...second
|
|
3417
|
+
// second overwrites first
|
|
3418
|
+
};
|
|
3419
|
+
};
|
|
3420
|
+
})(objectUtil || (objectUtil = {}));
|
|
3421
|
+
var ZodParsedType = util.arrayToEnum([
|
|
3422
|
+
"string",
|
|
3423
|
+
"nan",
|
|
3424
|
+
"number",
|
|
3425
|
+
"integer",
|
|
3426
|
+
"float",
|
|
3427
|
+
"boolean",
|
|
3428
|
+
"date",
|
|
3429
|
+
"bigint",
|
|
3430
|
+
"symbol",
|
|
3431
|
+
"function",
|
|
3432
|
+
"undefined",
|
|
3433
|
+
"null",
|
|
3434
|
+
"array",
|
|
3435
|
+
"object",
|
|
3436
|
+
"unknown",
|
|
3437
|
+
"promise",
|
|
3438
|
+
"void",
|
|
3439
|
+
"never",
|
|
3440
|
+
"map",
|
|
3441
|
+
"set"
|
|
3442
|
+
]);
|
|
3443
|
+
var getParsedType = (data) => {
|
|
3444
|
+
const t = typeof data;
|
|
3445
|
+
switch (t) {
|
|
3446
|
+
case "undefined":
|
|
3447
|
+
return ZodParsedType.undefined;
|
|
3226
3448
|
case "string":
|
|
3227
|
-
|
|
3228
|
-
return "string";
|
|
3449
|
+
return ZodParsedType.string;
|
|
3229
3450
|
case "number":
|
|
3230
|
-
|
|
3231
|
-
case "datetime":
|
|
3232
|
-
return "number";
|
|
3451
|
+
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
3233
3452
|
case "boolean":
|
|
3234
|
-
return
|
|
3453
|
+
return ZodParsedType.boolean;
|
|
3454
|
+
case "function":
|
|
3455
|
+
return ZodParsedType.function;
|
|
3235
3456
|
case "bigint":
|
|
3236
|
-
return
|
|
3237
|
-
case "
|
|
3238
|
-
return
|
|
3239
|
-
case "
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
return
|
|
3259
|
-
default:
|
|
3260
|
-
|
|
3261
|
-
return _exhaustive;
|
|
3262
|
-
}
|
|
3457
|
+
return ZodParsedType.bigint;
|
|
3458
|
+
case "symbol":
|
|
3459
|
+
return ZodParsedType.symbol;
|
|
3460
|
+
case "object":
|
|
3461
|
+
if (Array.isArray(data)) {
|
|
3462
|
+
return ZodParsedType.array;
|
|
3463
|
+
}
|
|
3464
|
+
if (data === null) {
|
|
3465
|
+
return ZodParsedType.null;
|
|
3466
|
+
}
|
|
3467
|
+
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
|
3468
|
+
return ZodParsedType.promise;
|
|
3469
|
+
}
|
|
3470
|
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
3471
|
+
return ZodParsedType.map;
|
|
3472
|
+
}
|
|
3473
|
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
3474
|
+
return ZodParsedType.set;
|
|
3475
|
+
}
|
|
3476
|
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
3477
|
+
return ZodParsedType.date;
|
|
3478
|
+
}
|
|
3479
|
+
return ZodParsedType.object;
|
|
3480
|
+
default:
|
|
3481
|
+
return ZodParsedType.unknown;
|
|
3263
3482
|
}
|
|
3264
|
-
}
|
|
3265
|
-
function fieldToTsProperty(field) {
|
|
3266
|
-
const optional = field.optional ? "?" : "";
|
|
3267
|
-
return `${field.name}${optional}: ${fieldTypeToTs(field.type)}`;
|
|
3268
|
-
}
|
|
3269
|
-
function docTypeName(tableName) {
|
|
3270
|
-
return `${tableName}Doc`;
|
|
3271
|
-
}
|
|
3272
|
-
function generateDocumentsTs(banner, tables) {
|
|
3273
|
-
const sorted = [...tables].sort((a, b) => a.name.localeCompare(b.name));
|
|
3274
|
-
const tableNames = sorted.map((t) => t.name);
|
|
3275
|
-
const docTypes = sorted.map((table) => {
|
|
3276
|
-
const name = docTypeName(table.name);
|
|
3277
|
-
const fields = table.fields.map((f) => ` ${fieldToTsProperty(f)};`).join("\n");
|
|
3278
|
-
return `export type ${name} = {
|
|
3279
|
-
_id: Id<${JSON.stringify(table.name)}>;
|
|
3280
|
-
_creationTime: number;
|
|
3281
|
-
${fields}
|
|
3282
|
-
};`;
|
|
3283
|
-
}).join("\n\n");
|
|
3284
|
-
const docByTableEntries = sorted.map((t) => ` ${JSON.stringify(t.name)}: ${docTypeName(t.name)};`).join("\n");
|
|
3285
|
-
const metaConstants = `export const PULLED_TABLE_NAMES = [${tableNames.map((n) => JSON.stringify(n)).join(", ")}] as const;
|
|
3286
|
-
export type TableName = (typeof PULLED_TABLE_NAMES)[number];
|
|
3287
|
-
`;
|
|
3288
|
-
return `${banner}import type { Id } from "../../convex/_generated/dataModel.js";
|
|
3289
|
-
|
|
3290
|
-
${metaConstants}
|
|
3291
|
-
${docTypes}
|
|
3292
|
-
|
|
3293
|
-
export type DocByTable = {
|
|
3294
|
-
${docByTableEntries}
|
|
3295
3483
|
};
|
|
3296
|
-
`;
|
|
3297
|
-
}
|
|
3298
3484
|
|
|
3299
|
-
//
|
|
3300
|
-
var
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3485
|
+
// ../../../node_modules/zod/v3/ZodError.js
|
|
3486
|
+
var ZodIssueCode = util.arrayToEnum([
|
|
3487
|
+
"invalid_type",
|
|
3488
|
+
"invalid_literal",
|
|
3489
|
+
"custom",
|
|
3490
|
+
"invalid_union",
|
|
3491
|
+
"invalid_union_discriminator",
|
|
3492
|
+
"invalid_enum_value",
|
|
3493
|
+
"unrecognized_keys",
|
|
3494
|
+
"invalid_arguments",
|
|
3495
|
+
"invalid_return_type",
|
|
3496
|
+
"invalid_date",
|
|
3497
|
+
"invalid_string",
|
|
3498
|
+
"too_small",
|
|
3499
|
+
"too_big",
|
|
3500
|
+
"invalid_intersection_types",
|
|
3501
|
+
"not_multiple_of",
|
|
3502
|
+
"not_finite"
|
|
3503
|
+
]);
|
|
3504
|
+
var quotelessJson = (obj) => {
|
|
3505
|
+
const json = JSON.stringify(obj, null, 2);
|
|
3506
|
+
return json.replace(/"([^"]+)":/g, "$1:");
|
|
3507
|
+
};
|
|
3508
|
+
var ZodError = class _ZodError extends Error {
|
|
3509
|
+
get errors() {
|
|
3510
|
+
return this.issues;
|
|
3511
|
+
}
|
|
3512
|
+
constructor(issues) {
|
|
3513
|
+
super();
|
|
3514
|
+
this.issues = [];
|
|
3515
|
+
this.addIssue = (sub) => {
|
|
3516
|
+
this.issues = [...this.issues, sub];
|
|
3517
|
+
};
|
|
3518
|
+
this.addIssues = (subs = []) => {
|
|
3519
|
+
this.issues = [...this.issues, ...subs];
|
|
3520
|
+
};
|
|
3521
|
+
const actualProto = new.target.prototype;
|
|
3522
|
+
if (Object.setPrototypeOf) {
|
|
3523
|
+
Object.setPrototypeOf(this, actualProto);
|
|
3524
|
+
} else {
|
|
3525
|
+
this.__proto__ = actualProto;
|
|
3526
|
+
}
|
|
3527
|
+
this.name = "ZodError";
|
|
3528
|
+
this.issues = issues;
|
|
3529
|
+
}
|
|
3530
|
+
format(_mapper) {
|
|
3531
|
+
const mapper = _mapper || function(issue) {
|
|
3532
|
+
return issue.message;
|
|
3533
|
+
};
|
|
3534
|
+
const fieldErrors = { _errors: [] };
|
|
3535
|
+
const processError = (error) => {
|
|
3536
|
+
for (const issue of error.issues) {
|
|
3537
|
+
if (issue.code === "invalid_union") {
|
|
3538
|
+
issue.unionErrors.map(processError);
|
|
3539
|
+
} else if (issue.code === "invalid_return_type") {
|
|
3540
|
+
processError(issue.returnTypeError);
|
|
3541
|
+
} else if (issue.code === "invalid_arguments") {
|
|
3542
|
+
processError(issue.argumentsError);
|
|
3543
|
+
} else if (issue.path.length === 0) {
|
|
3544
|
+
fieldErrors._errors.push(mapper(issue));
|
|
3545
|
+
} else {
|
|
3546
|
+
let curr = fieldErrors;
|
|
3547
|
+
let i = 0;
|
|
3548
|
+
while (i < issue.path.length) {
|
|
3549
|
+
const el = issue.path[i];
|
|
3550
|
+
const terminal = i === issue.path.length - 1;
|
|
3551
|
+
if (!terminal) {
|
|
3552
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
3553
|
+
} else {
|
|
3554
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
3555
|
+
curr[el]._errors.push(mapper(issue));
|
|
3556
|
+
}
|
|
3557
|
+
curr = curr[el];
|
|
3558
|
+
i++;
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
};
|
|
3563
|
+
processError(this);
|
|
3564
|
+
return fieldErrors;
|
|
3565
|
+
}
|
|
3566
|
+
static assert(value) {
|
|
3567
|
+
if (!(value instanceof _ZodError)) {
|
|
3568
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
toString() {
|
|
3572
|
+
return this.message;
|
|
3573
|
+
}
|
|
3574
|
+
get message() {
|
|
3575
|
+
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
|
|
3576
|
+
}
|
|
3577
|
+
get isEmpty() {
|
|
3578
|
+
return this.issues.length === 0;
|
|
3579
|
+
}
|
|
3580
|
+
flatten(mapper = (issue) => issue.message) {
|
|
3581
|
+
const fieldErrors = {};
|
|
3582
|
+
const formErrors = [];
|
|
3583
|
+
for (const sub of this.issues) {
|
|
3584
|
+
if (sub.path.length > 0) {
|
|
3585
|
+
const firstEl = sub.path[0];
|
|
3586
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
3587
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
3588
|
+
} else {
|
|
3589
|
+
formErrors.push(mapper(sub));
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
return { formErrors, fieldErrors };
|
|
3593
|
+
}
|
|
3594
|
+
get formErrors() {
|
|
3595
|
+
return this.flatten();
|
|
3322
3596
|
}
|
|
3323
|
-
];
|
|
3324
|
-
var PREDICATE_OPS = PREDICATE_VARIANTS.flatMap(
|
|
3325
|
-
(variant) => variant.ops.map(({ op }) => op)
|
|
3326
|
-
);
|
|
3327
|
-
var PREDICATE_OP_LABELS = new Map(
|
|
3328
|
-
PREDICATE_VARIANTS.flatMap((variant) => variant.ops.map(({ op, label }) => [op, label]))
|
|
3329
|
-
);
|
|
3330
|
-
|
|
3331
|
-
// ../api-codegen/src/generate-query-types.ts
|
|
3332
|
-
function quotedUnion(values) {
|
|
3333
|
-
return values.map((value) => JSON.stringify(value)).join(" | ");
|
|
3334
|
-
}
|
|
3335
|
-
function multilineUnion(values) {
|
|
3336
|
-
return values.map((value) => ` | ${JSON.stringify(value)}`).join("\n");
|
|
3337
|
-
}
|
|
3338
|
-
function emitQueryTs(banner) {
|
|
3339
|
-
const predicate = PREDICATE_VARIANTS.map((variant) => {
|
|
3340
|
-
const value = variant.value === "unknownArray" ? "unknown[]" : variant.value === "between" ? "{ min: unknown; max: unknown }" : "unknown";
|
|
3341
|
-
return ` | { field: string; op: ${quotedUnion(variant.ops.map(({ op }) => op))}; value: ${value} }`;
|
|
3342
|
-
}).join("\n");
|
|
3343
|
-
return `${banner}export type PredicateOp =
|
|
3344
|
-
${multilineUnion(PREDICATE_OPS)};
|
|
3345
|
-
|
|
3346
|
-
export type Predicate =
|
|
3347
|
-
${predicate};
|
|
3348
|
-
|
|
3349
|
-
export type QueryOrder = { field: string; direction: "asc" | "desc" };
|
|
3350
|
-
|
|
3351
|
-
export type QuerySearch = { index: string; query: string };
|
|
3352
|
-
|
|
3353
|
-
export type Query = {
|
|
3354
|
-
predicates?: Predicate[];
|
|
3355
|
-
order?: QueryOrder;
|
|
3356
|
-
search?: QuerySearch;
|
|
3357
|
-
maxScan?: number;
|
|
3358
|
-
indexHint?: string;
|
|
3359
|
-
vector?: unknown;
|
|
3360
3597
|
};
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
page: "paginate" | "boundedSort";
|
|
3365
|
-
order?: QueryOrder | { kind: "relevance" };
|
|
3366
|
-
indexName?: string;
|
|
3367
|
-
searchIndexName?: string;
|
|
3368
|
-
scanned?: number;
|
|
3369
|
-
truncated?: boolean;
|
|
3598
|
+
ZodError.create = (issues) => {
|
|
3599
|
+
const error = new ZodError(issues);
|
|
3600
|
+
return error;
|
|
3370
3601
|
};
|
|
3371
3602
|
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
}
|
|
3603
|
+
// ../../../node_modules/zod/v3/locales/en.js
|
|
3604
|
+
var errorMap = (issue, _ctx) => {
|
|
3605
|
+
let message;
|
|
3606
|
+
switch (issue.code) {
|
|
3607
|
+
case ZodIssueCode.invalid_type:
|
|
3608
|
+
if (issue.received === ZodParsedType.undefined) {
|
|
3609
|
+
message = "Required";
|
|
3610
|
+
} else {
|
|
3611
|
+
message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
3612
|
+
}
|
|
3613
|
+
break;
|
|
3614
|
+
case ZodIssueCode.invalid_literal:
|
|
3615
|
+
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
|
|
3616
|
+
break;
|
|
3617
|
+
case ZodIssueCode.unrecognized_keys:
|
|
3618
|
+
message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
|
|
3619
|
+
break;
|
|
3620
|
+
case ZodIssueCode.invalid_union:
|
|
3621
|
+
message = `Invalid input`;
|
|
3622
|
+
break;
|
|
3623
|
+
case ZodIssueCode.invalid_union_discriminator:
|
|
3624
|
+
message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
|
|
3625
|
+
break;
|
|
3626
|
+
case ZodIssueCode.invalid_enum_value:
|
|
3627
|
+
message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
|
|
3628
|
+
break;
|
|
3629
|
+
case ZodIssueCode.invalid_arguments:
|
|
3630
|
+
message = `Invalid function arguments`;
|
|
3631
|
+
break;
|
|
3632
|
+
case ZodIssueCode.invalid_return_type:
|
|
3633
|
+
message = `Invalid function return type`;
|
|
3634
|
+
break;
|
|
3635
|
+
case ZodIssueCode.invalid_date:
|
|
3636
|
+
message = `Invalid date`;
|
|
3637
|
+
break;
|
|
3638
|
+
case ZodIssueCode.invalid_string:
|
|
3639
|
+
if (typeof issue.validation === "object") {
|
|
3640
|
+
if ("includes" in issue.validation) {
|
|
3641
|
+
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
3642
|
+
if (typeof issue.validation.position === "number") {
|
|
3643
|
+
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
3644
|
+
}
|
|
3645
|
+
} else if ("startsWith" in issue.validation) {
|
|
3646
|
+
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
3647
|
+
} else if ("endsWith" in issue.validation) {
|
|
3648
|
+
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
3649
|
+
} else {
|
|
3650
|
+
util.assertNever(issue.validation);
|
|
3651
|
+
}
|
|
3652
|
+
} else if (issue.validation !== "regex") {
|
|
3653
|
+
message = `Invalid ${issue.validation}`;
|
|
3654
|
+
} else {
|
|
3655
|
+
message = "Invalid";
|
|
3656
|
+
}
|
|
3657
|
+
break;
|
|
3658
|
+
case ZodIssueCode.too_small:
|
|
3659
|
+
if (issue.type === "array")
|
|
3660
|
+
message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
|
3661
|
+
else if (issue.type === "string")
|
|
3662
|
+
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
3663
|
+
else if (issue.type === "number")
|
|
3664
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
3665
|
+
else if (issue.type === "bigint")
|
|
3666
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
3667
|
+
else if (issue.type === "date")
|
|
3668
|
+
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
3669
|
+
else
|
|
3670
|
+
message = "Invalid input";
|
|
3671
|
+
break;
|
|
3672
|
+
case ZodIssueCode.too_big:
|
|
3673
|
+
if (issue.type === "array")
|
|
3674
|
+
message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
|
3675
|
+
else if (issue.type === "string")
|
|
3676
|
+
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
3677
|
+
else if (issue.type === "number")
|
|
3678
|
+
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
3679
|
+
else if (issue.type === "bigint")
|
|
3680
|
+
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
3681
|
+
else if (issue.type === "date")
|
|
3682
|
+
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
3683
|
+
else
|
|
3684
|
+
message = "Invalid input";
|
|
3685
|
+
break;
|
|
3686
|
+
case ZodIssueCode.custom:
|
|
3687
|
+
message = `Invalid input`;
|
|
3688
|
+
break;
|
|
3689
|
+
case ZodIssueCode.invalid_intersection_types:
|
|
3690
|
+
message = `Intersection results could not be merged`;
|
|
3691
|
+
break;
|
|
3692
|
+
case ZodIssueCode.not_multiple_of:
|
|
3693
|
+
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
3694
|
+
break;
|
|
3695
|
+
case ZodIssueCode.not_finite:
|
|
3696
|
+
message = "Number must be finite";
|
|
3697
|
+
break;
|
|
3698
|
+
default:
|
|
3699
|
+
message = _ctx.defaultError;
|
|
3700
|
+
util.assertNever(issue);
|
|
3701
|
+
}
|
|
3702
|
+
return { message };
|
|
3703
|
+
};
|
|
3704
|
+
var en_default = errorMap;
|
|
3380
3705
|
|
|
3381
|
-
//
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
function readApiQueryModuleSegment(profileSlug) {
|
|
3386
|
-
return apiProfileSlugToConvexModuleSegment(profileSlug);
|
|
3706
|
+
// ../../../node_modules/zod/v3/errors.js
|
|
3707
|
+
var overrideErrorMap = en_default;
|
|
3708
|
+
function setErrorMap(map) {
|
|
3709
|
+
overrideErrorMap = map;
|
|
3387
3710
|
}
|
|
3388
|
-
function
|
|
3389
|
-
|
|
3390
|
-
const exportName = readApiQueryExportName(kind, tableName);
|
|
3391
|
-
return `anyApi.columnus.read.${segment}.${exportName}.${exportName}`;
|
|
3711
|
+
function getErrorMap() {
|
|
3712
|
+
return overrideErrorMap;
|
|
3392
3713
|
}
|
|
3393
3714
|
|
|
3394
|
-
//
|
|
3395
|
-
|
|
3396
|
-
const
|
|
3397
|
-
const
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
import { anyApi } from "convex/server";
|
|
3420
|
-
import type { ListResult, Query } from "./query.js";
|
|
3421
|
-
import type {
|
|
3422
|
-
${sorted.map((t) => ` ${docTypeName(t.name)},`).join("\n")}
|
|
3423
|
-
TableName,
|
|
3424
|
-
} from "./documents.js";
|
|
3425
|
-
|
|
3426
|
-
export type ListRef = FunctionReference<
|
|
3427
|
-
"query",
|
|
3428
|
-
"public",
|
|
3429
|
-
{ apiToken: string; query?: Query; paginationOpts: PaginationOptions },
|
|
3430
|
-
ListResult<Record<string, unknown>>
|
|
3431
|
-
>;
|
|
3432
|
-
|
|
3433
|
-
${listRefs}
|
|
3434
|
-
|
|
3435
|
-
/** Readable tables only \u2014 propose-only allowlist entries are omitted. */
|
|
3436
|
-
export const listRefByTable: Partial<Record<TableName, ListRef>> = {
|
|
3437
|
-
${listRefMap}
|
|
3715
|
+
// ../../../node_modules/zod/v3/helpers/parseUtil.js
|
|
3716
|
+
var makeIssue = (params) => {
|
|
3717
|
+
const { data, path: path5, errorMaps, issueData } = params;
|
|
3718
|
+
const fullPath = [...path5, ...issueData.path || []];
|
|
3719
|
+
const fullIssue = {
|
|
3720
|
+
...issueData,
|
|
3721
|
+
path: fullPath
|
|
3722
|
+
};
|
|
3723
|
+
if (issueData.message !== void 0) {
|
|
3724
|
+
return {
|
|
3725
|
+
...issueData,
|
|
3726
|
+
path: fullPath,
|
|
3727
|
+
message: issueData.message
|
|
3728
|
+
};
|
|
3729
|
+
}
|
|
3730
|
+
let errorMessage = "";
|
|
3731
|
+
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
3732
|
+
for (const map of maps) {
|
|
3733
|
+
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
|
|
3734
|
+
}
|
|
3735
|
+
return {
|
|
3736
|
+
...issueData,
|
|
3737
|
+
path: fullPath,
|
|
3738
|
+
message: errorMessage
|
|
3739
|
+
};
|
|
3438
3740
|
};
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3741
|
+
var EMPTY_PATH = [];
|
|
3742
|
+
function addIssueToContext(ctx, issueData) {
|
|
3743
|
+
const overrideMap = getErrorMap();
|
|
3744
|
+
const issue = makeIssue({
|
|
3745
|
+
issueData,
|
|
3746
|
+
data: ctx.data,
|
|
3747
|
+
path: ctx.path,
|
|
3748
|
+
errorMaps: [
|
|
3749
|
+
ctx.common.contextualErrorMap,
|
|
3750
|
+
// contextual error map is first priority
|
|
3751
|
+
ctx.schemaErrorMap,
|
|
3752
|
+
// then schema-bound map if available
|
|
3753
|
+
overrideMap,
|
|
3754
|
+
// then global override map
|
|
3755
|
+
overrideMap === en_default ? void 0 : en_default
|
|
3756
|
+
// then global default map
|
|
3757
|
+
].filter((x) => !!x)
|
|
3758
|
+
});
|
|
3759
|
+
ctx.common.issues.push(issue);
|
|
3442
3760
|
}
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
// re-run \`columnus-api pull\` after profile or schema changes.
|
|
3447
|
-
`;
|
|
3448
|
-
var DEFAULT_LIST_PAGE_SIZE = 50;
|
|
3449
|
-
function generateClientPullFiles(input) {
|
|
3450
|
-
const manifest = { tables: [...input.tables] };
|
|
3451
|
-
const tableNames = manifest.tables.map((t) => t.name).sort((a, b) => a.localeCompare(b));
|
|
3452
|
-
const accesses = input.tableAccess ?? input.tables.map((table) => ({ table: table.name, read: true }));
|
|
3453
|
-
const readableTables = manifest.tables.filter(
|
|
3454
|
-
(table) => accesses.some((access2) => access2.table === table.name && access2.read)
|
|
3455
|
-
);
|
|
3456
|
-
const files = /* @__PURE__ */ new Map();
|
|
3457
|
-
const schemaTs = generateSchemaTs(manifest, HOST_SCHEMA_PROFILE).replace(
|
|
3458
|
-
/^\/\/ AUTO-GENERATED[^\n]*\n/,
|
|
3459
|
-
READ_API_BANNER
|
|
3460
|
-
);
|
|
3461
|
-
files.set("convex/schema.ts", schemaTs);
|
|
3462
|
-
files.set("convex.json", "{}\n");
|
|
3463
|
-
files.set("src/generated/manifest.json", `${JSON.stringify(manifest, null, 2)}
|
|
3464
|
-
`);
|
|
3465
|
-
files.set("src/generated/manifest-types.ts", generateManifestTypesTs());
|
|
3466
|
-
files.set("src/generated/documents.ts", generateDocumentsTs(READ_API_BANNER, manifest.tables));
|
|
3467
|
-
files.set(
|
|
3468
|
-
"src/generated/read-api-refs.ts",
|
|
3469
|
-
generateReadApiRefsTs(READ_API_BANNER, input.profileSlug, readableTables)
|
|
3470
|
-
);
|
|
3471
|
-
files.set("src/generated/read-api-token.ts", generateReadApiTokenTs());
|
|
3472
|
-
files.set(
|
|
3473
|
-
"src/generated/proposal-api-refs.ts",
|
|
3474
|
-
generateProposalApiRefsTs(input.profileSlug, manifest.tables, accesses)
|
|
3475
|
-
);
|
|
3476
|
-
files.set("src/generated/query.ts", emitQueryTs(READ_API_BANNER));
|
|
3477
|
-
files.set("src/generated/storage-helpers.ts", generateStorageHelpersTs());
|
|
3478
|
-
files.set(
|
|
3479
|
-
"src/generated/read-api-meta.ts",
|
|
3480
|
-
generateReadApiMetaTs(input.profileSlug, input.apiVersion, input.manifestHash)
|
|
3481
|
-
);
|
|
3482
|
-
files.set("src/generated/hooks.ts", generateHooksTs(readableTables, DEFAULT_LIST_PAGE_SIZE));
|
|
3483
|
-
files.set("src/generated/proposal-hooks.ts", generateProposalHooksTs(manifest.tables, accesses));
|
|
3484
|
-
files.set(
|
|
3485
|
-
"src/generated/read-api-meta.json",
|
|
3486
|
-
`${JSON.stringify(
|
|
3487
|
-
{
|
|
3488
|
-
convexUrl: input.convexUrl,
|
|
3489
|
-
profileSlug: input.profileSlug,
|
|
3490
|
-
apiVersion: input.apiVersion,
|
|
3491
|
-
manifestHash: input.manifestHash,
|
|
3492
|
-
tables: tableNames,
|
|
3493
|
-
tableAccess: accesses
|
|
3494
|
-
},
|
|
3495
|
-
null,
|
|
3496
|
-
2
|
|
3497
|
-
)}
|
|
3498
|
-
`
|
|
3499
|
-
);
|
|
3500
|
-
files.set(".env.example", generateEnvExample(input.convexUrl));
|
|
3501
|
-
return files;
|
|
3502
|
-
}
|
|
3503
|
-
function generateProposalApiRefsTs(profileSlug, tables, accesses) {
|
|
3504
|
-
const byName = new Map(tables.map((table) => [table.name, table]));
|
|
3505
|
-
const refs = [];
|
|
3506
|
-
for (const access2 of accesses) {
|
|
3507
|
-
const table = byName.get(access2.table);
|
|
3508
|
-
if (!table || !access2.propose) continue;
|
|
3509
|
-
const segment = profileSlug.replace(/-/g, "_");
|
|
3510
|
-
const doc = docTypeName(table.name);
|
|
3511
|
-
if (access2.propose.ops.insert)
|
|
3512
|
-
refs.push(
|
|
3513
|
-
`export const proposeInsert${table.name}Ref = anyApi.columnus.propose.${segment}.proposeInsert${table.name}.proposeInsert${table.name} as FunctionReference<"mutation", "public", { apiToken: string; doc: Omit<${doc}, "_id" | "_creationTime"> }, ProposalResult>;`
|
|
3514
|
-
);
|
|
3515
|
-
if (access2.propose.ops.update)
|
|
3516
|
-
refs.push(
|
|
3517
|
-
`export const proposeUpdate${table.name}Ref = anyApi.columnus.propose.${segment}.proposeUpdate${table.name}.proposeUpdate${table.name} as FunctionReference<"mutation", "public", { apiToken: string; id: string; patch: Partial<Omit<${doc}, "_id" | "_creationTime">> }, ProposalResult>;`
|
|
3518
|
-
);
|
|
3519
|
-
if (access2.propose.ops.delete)
|
|
3520
|
-
refs.push(
|
|
3521
|
-
`export const proposeDelete${table.name}Ref = anyApi.columnus.propose.${segment}.proposeDelete${table.name}.proposeDelete${table.name} as FunctionReference<"mutation", "public", { apiToken: string; id: string }, ProposalResult>;`
|
|
3522
|
-
);
|
|
3761
|
+
var ParseStatus = class _ParseStatus {
|
|
3762
|
+
constructor() {
|
|
3763
|
+
this.value = "valid";
|
|
3523
3764
|
}
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
const doc = docTypeName(table.name);
|
|
3541
|
-
for (const op of ["insert", "update", "delete"]) {
|
|
3542
|
-
if (!access2.propose.ops[op]) continue;
|
|
3543
|
-
const pascal = `${op[0].toUpperCase()}${op.slice(1)}`;
|
|
3544
|
-
imports.push(`propose${pascal}${table.name}Ref`);
|
|
3545
|
-
const args = op === "insert" ? `doc: Omit<${doc}, "_id" | "_creationTime">` : op === "update" ? `id: string, patch: Partial<Omit<${doc}, "_id" | "_creationTime">>` : "id: string";
|
|
3546
|
-
const call = op === "insert" ? "{ apiToken: readApiToken(), doc }" : op === "update" ? "{ apiToken: readApiToken(), id, patch }" : "{ apiToken: readApiToken(), id }";
|
|
3547
|
-
hooks.push(
|
|
3548
|
-
`export function usePropose${pascal}${table.name}() { const mutate = useMutation(propose${pascal}${table.name}Ref); return (${args}) => mutate(${call}); }`
|
|
3549
|
-
);
|
|
3765
|
+
dirty() {
|
|
3766
|
+
if (this.value === "valid")
|
|
3767
|
+
this.value = "dirty";
|
|
3768
|
+
}
|
|
3769
|
+
abort() {
|
|
3770
|
+
if (this.value !== "aborted")
|
|
3771
|
+
this.value = "aborted";
|
|
3772
|
+
}
|
|
3773
|
+
static mergeArray(status, results) {
|
|
3774
|
+
const arrayValue = [];
|
|
3775
|
+
for (const s of results) {
|
|
3776
|
+
if (s.status === "aborted")
|
|
3777
|
+
return INVALID;
|
|
3778
|
+
if (s.status === "dirty")
|
|
3779
|
+
status.dirty();
|
|
3780
|
+
arrayValue.push(s.value);
|
|
3550
3781
|
}
|
|
3782
|
+
return { status: status.value, value: arrayValue };
|
|
3783
|
+
}
|
|
3784
|
+
static async mergeObjectAsync(status, pairs) {
|
|
3785
|
+
const syncPairs = [];
|
|
3786
|
+
for (const pair of pairs) {
|
|
3787
|
+
const key = await pair.key;
|
|
3788
|
+
const value = await pair.value;
|
|
3789
|
+
syncPairs.push({
|
|
3790
|
+
key,
|
|
3791
|
+
value
|
|
3792
|
+
});
|
|
3793
|
+
}
|
|
3794
|
+
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
3795
|
+
}
|
|
3796
|
+
static mergeObjectSync(status, pairs) {
|
|
3797
|
+
const finalObject = {};
|
|
3798
|
+
for (const pair of pairs) {
|
|
3799
|
+
const { key, value } = pair;
|
|
3800
|
+
if (key.status === "aborted")
|
|
3801
|
+
return INVALID;
|
|
3802
|
+
if (value.status === "aborted")
|
|
3803
|
+
return INVALID;
|
|
3804
|
+
if (key.status === "dirty")
|
|
3805
|
+
status.dirty();
|
|
3806
|
+
if (value.status === "dirty")
|
|
3807
|
+
status.dirty();
|
|
3808
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
3809
|
+
finalObject[key.value] = value.value;
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
return { status: status.value, value: finalObject };
|
|
3551
3813
|
}
|
|
3552
|
-
return `${READ_API_BANNER}import { useMutation } from "convex/react";
|
|
3553
|
-
import type { ${tables.map((table) => docTypeName(table.name)).join(", ")} } from "./documents.js";
|
|
3554
|
-
import { ${imports.join(", ")} } from "./proposal-api-refs.js";
|
|
3555
|
-
import { readApiToken } from "./read-api-token.js";
|
|
3556
|
-
|
|
3557
|
-
${hooks.join("\n\n")}
|
|
3558
|
-
`;
|
|
3559
|
-
}
|
|
3560
|
-
function generateManifestTypesTs() {
|
|
3561
|
-
return `${READ_API_BANNER}/** Manifest field/index shapes for pulled consumer apps (no @columnus/shared). */
|
|
3562
|
-
export type ManifestIndex = { name: string; fields: string[] };
|
|
3563
|
-
|
|
3564
|
-
export type ManifestFieldType =
|
|
3565
|
-
| { kind: "string" }
|
|
3566
|
-
| { kind: "number" }
|
|
3567
|
-
| { kind: "boolean" }
|
|
3568
|
-
| { kind: "file" }
|
|
3569
|
-
| { kind: "id"; table: string }
|
|
3570
|
-
| { kind: "array"; element: ManifestFieldType }
|
|
3571
|
-
| { kind: "object"; fields: Record<string, ManifestFieldType> };
|
|
3572
|
-
|
|
3573
|
-
export type ManifestField = {
|
|
3574
|
-
name: string;
|
|
3575
|
-
type: ManifestFieldType;
|
|
3576
|
-
optional: boolean;
|
|
3577
|
-
};
|
|
3578
|
-
|
|
3579
|
-
export type ManifestTable = {
|
|
3580
|
-
name: string;
|
|
3581
|
-
fields: ManifestField[];
|
|
3582
|
-
indexes: ManifestIndex[];
|
|
3583
|
-
searchIndexes: unknown[];
|
|
3584
3814
|
};
|
|
3815
|
+
var INVALID = Object.freeze({
|
|
3816
|
+
status: "aborted"
|
|
3817
|
+
});
|
|
3818
|
+
var DIRTY = (value) => ({ status: "dirty", value });
|
|
3819
|
+
var OK = (value) => ({ status: "valid", value });
|
|
3820
|
+
var isAborted = (x) => x.status === "aborted";
|
|
3821
|
+
var isDirty = (x) => x.status === "dirty";
|
|
3822
|
+
var isValid = (x) => x.status === "valid";
|
|
3823
|
+
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
3585
3824
|
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
export function toDocumentId(value: unknown): string | undefined {
|
|
3594
|
-
if (value === undefined || value === null || value === "") return undefined;
|
|
3595
|
-
return typeof value === "string" ? value : String(value);
|
|
3596
|
-
}
|
|
3597
|
-
|
|
3598
|
-
function isFileFieldType(type: ManifestFieldType): boolean {
|
|
3599
|
-
return type.kind === "file";
|
|
3600
|
-
}
|
|
3601
|
-
|
|
3602
|
-
function isFileArrayFieldType(type: ManifestFieldType): boolean {
|
|
3603
|
-
return type.kind === "array" && type.element.kind === "file";
|
|
3604
|
-
}
|
|
3605
|
-
|
|
3606
|
-
function isStorageFieldType(type: ManifestFieldType): boolean {
|
|
3607
|
-
return isFileFieldType(type) || isFileArrayFieldType(type);
|
|
3608
|
-
}
|
|
3825
|
+
// ../../../node_modules/zod/v3/helpers/errorUtil.js
|
|
3826
|
+
var errorUtil;
|
|
3827
|
+
(function(errorUtil2) {
|
|
3828
|
+
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
3829
|
+
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
3830
|
+
})(errorUtil || (errorUtil = {}));
|
|
3609
3831
|
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
return out;
|
|
3832
|
+
// ../../../node_modules/zod/v3/types.js
|
|
3833
|
+
var ParseInputLazyPath = class {
|
|
3834
|
+
constructor(parent, value, path5, key) {
|
|
3835
|
+
this._cachedPath = [];
|
|
3836
|
+
this.parent = parent;
|
|
3837
|
+
this.data = value;
|
|
3838
|
+
this._path = path5;
|
|
3839
|
+
this._key = key;
|
|
3619
3840
|
}
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3841
|
+
get path() {
|
|
3842
|
+
if (!this._cachedPath.length) {
|
|
3843
|
+
if (Array.isArray(this._key)) {
|
|
3844
|
+
this._cachedPath.push(...this._path, ...this._key);
|
|
3845
|
+
} else {
|
|
3846
|
+
this._cachedPath.push(...this._path, this._key);
|
|
3847
|
+
}
|
|
3624
3848
|
}
|
|
3849
|
+
return this._cachedPath;
|
|
3625
3850
|
}
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
}
|
|
3644
|
-
function generateReadApiMetaTs(profileSlug, apiVersion, manifestHash) {
|
|
3645
|
-
return `${READ_API_BANNER}/** Compile-time snapshot from the last \`columnus-api pull\`. */
|
|
3646
|
-
export const PULLED_PROFILE_SLUG = ${JSON.stringify(profileSlug)} as const;
|
|
3647
|
-
export const PULLED_API_VERSION = ${apiVersion} as const;
|
|
3648
|
-
export const PULLED_MANIFEST_HASH = ${JSON.stringify(manifestHash)} as const;
|
|
3649
|
-
`;
|
|
3650
|
-
}
|
|
3651
|
-
function generateReadApiTokenTs() {
|
|
3652
|
-
return `${READ_API_BANNER}export function readApiToken(): string {
|
|
3653
|
-
const token = import.meta.env.VITE_COLUMNUS_API_TOKEN;
|
|
3654
|
-
if (!token || typeof token !== "string") {
|
|
3655
|
-
throw new Error("VITE_COLUMNUS_API_TOKEN is required");
|
|
3656
|
-
}
|
|
3657
|
-
return token;
|
|
3658
|
-
}
|
|
3659
|
-
`;
|
|
3660
|
-
}
|
|
3661
|
-
function generateHooksTs(tables, pageSize) {
|
|
3662
|
-
const sorted = [...tables].sort((a, b) => a.name.localeCompare(b.name));
|
|
3663
|
-
const listHooks = sorted.map((table) => {
|
|
3664
|
-
const hookName = `use${table.name}List`;
|
|
3665
|
-
const ref = `list${table.name}Ref`;
|
|
3666
|
-
return `
|
|
3667
|
-
export function ${hookName}(query?: Query | null) {
|
|
3668
|
-
const apiToken = readApiToken();
|
|
3669
|
-
return usePaginatedQuery(
|
|
3670
|
-
${ref},
|
|
3671
|
-
query ? { apiToken, query } : { apiToken },
|
|
3672
|
-
{ initialNumItems: ${pageSize} },
|
|
3673
|
-
);
|
|
3674
|
-
}`;
|
|
3675
|
-
}).join("\n");
|
|
3676
|
-
const getHooks = sorted.map((table) => {
|
|
3677
|
-
const hookName = `use${table.name}ById`;
|
|
3678
|
-
const doc = docTypeName(table.name);
|
|
3679
|
-
const ref = `get${table.name}Ref`;
|
|
3680
|
-
return `
|
|
3681
|
-
export function ${hookName}(id: ${doc}["_id"] | undefined) {
|
|
3682
|
-
const apiToken = readApiToken();
|
|
3683
|
-
return useQuery(${ref}, id ? { apiToken, id } : "skip");
|
|
3684
|
-
}`;
|
|
3685
|
-
}).join("\n");
|
|
3686
|
-
const docImports = sorted.map((t) => ` ${docTypeName(t.name)},`).join("\n");
|
|
3687
|
-
const refImports = sorted.flatMap((t) => [` list${t.name}Ref,`, ` get${t.name}Ref,`]).join("\n");
|
|
3688
|
-
return `${READ_API_BANNER}import { usePaginatedQuery, useQuery } from "convex/react";
|
|
3689
|
-
import { anyApi } from "convex/server";
|
|
3690
|
-
import type { Query } from "./query.js";
|
|
3691
|
-
import type {
|
|
3692
|
-
${docImports}
|
|
3693
|
-
} from "./documents.js";
|
|
3694
|
-
import {
|
|
3695
|
-
${refImports}
|
|
3696
|
-
} from "./read-api-refs.js";
|
|
3697
|
-
import { readApiToken } from "./read-api-token.js";
|
|
3698
|
-
${listHooks}
|
|
3699
|
-
|
|
3700
|
-
${getHooks}
|
|
3701
|
-
|
|
3702
|
-
export function useStorageUrls(fileIds: string[]) {
|
|
3703
|
-
const apiToken = readApiToken();
|
|
3704
|
-
const ids = fileIds.filter(Boolean);
|
|
3705
|
-
const results = useQuery(
|
|
3706
|
-
anyApi.columnus.read.storage.getStorageUrls,
|
|
3707
|
-
ids.length > 0 ? { apiToken, fileIds: ids } : "skip",
|
|
3708
|
-
);
|
|
3709
|
-
return results ?? [];
|
|
3710
|
-
}
|
|
3711
|
-
|
|
3712
|
-
export function useStorageMetadata(fileIds: string[]) {
|
|
3713
|
-
const apiToken = readApiToken();
|
|
3714
|
-
const ids = fileIds.filter(Boolean);
|
|
3715
|
-
const results = useQuery(
|
|
3716
|
-
anyApi.columnus.read.storage.getStorageMetadata,
|
|
3717
|
-
ids.length > 0 ? { apiToken, fileIds: ids } : "skip",
|
|
3718
|
-
);
|
|
3719
|
-
return results ?? [];
|
|
3720
|
-
}
|
|
3721
|
-
`;
|
|
3722
|
-
}
|
|
3723
|
-
function generateEnvExample(convexUrl) {
|
|
3724
|
-
return `# Copy to .env.local and fill in your read API token from Columnus /api.
|
|
3725
|
-
VITE_CONVEX_URL=${convexUrl}
|
|
3726
|
-
VITE_COLUMNUS_API_TOKEN=col_your_token_here
|
|
3727
|
-
`;
|
|
3728
|
-
}
|
|
3729
|
-
|
|
3730
|
-
// ../shared/src/apiToken.ts
|
|
3731
|
-
var TOKEN_BODY_RE = /^col_[A-Za-z0-9_-]{20,}$/;
|
|
3732
|
-
function isApiTokenFormat(token) {
|
|
3733
|
-
return TOKEN_BODY_RE.test(token.trim());
|
|
3734
|
-
}
|
|
3735
|
-
|
|
3736
|
-
// src/pull-codegen.ts
|
|
3737
|
-
import { access, writeFile } from "node:fs/promises";
|
|
3738
|
-
import path2 from "node:path";
|
|
3739
|
-
|
|
3740
|
-
// ../../../node_modules/zod/v3/external.js
|
|
3741
|
-
var external_exports = {};
|
|
3742
|
-
__export(external_exports, {
|
|
3743
|
-
BRAND: () => BRAND,
|
|
3744
|
-
DIRTY: () => DIRTY,
|
|
3745
|
-
EMPTY_PATH: () => EMPTY_PATH,
|
|
3746
|
-
INVALID: () => INVALID,
|
|
3747
|
-
NEVER: () => NEVER,
|
|
3748
|
-
OK: () => OK,
|
|
3749
|
-
ParseStatus: () => ParseStatus,
|
|
3750
|
-
Schema: () => ZodType,
|
|
3751
|
-
ZodAny: () => ZodAny,
|
|
3752
|
-
ZodArray: () => ZodArray,
|
|
3753
|
-
ZodBigInt: () => ZodBigInt,
|
|
3754
|
-
ZodBoolean: () => ZodBoolean,
|
|
3755
|
-
ZodBranded: () => ZodBranded,
|
|
3756
|
-
ZodCatch: () => ZodCatch,
|
|
3757
|
-
ZodDate: () => ZodDate,
|
|
3758
|
-
ZodDefault: () => ZodDefault,
|
|
3759
|
-
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
|
|
3760
|
-
ZodEffects: () => ZodEffects,
|
|
3761
|
-
ZodEnum: () => ZodEnum,
|
|
3762
|
-
ZodError: () => ZodError,
|
|
3763
|
-
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
|
|
3764
|
-
ZodFunction: () => ZodFunction,
|
|
3765
|
-
ZodIntersection: () => ZodIntersection,
|
|
3766
|
-
ZodIssueCode: () => ZodIssueCode,
|
|
3767
|
-
ZodLazy: () => ZodLazy,
|
|
3768
|
-
ZodLiteral: () => ZodLiteral,
|
|
3769
|
-
ZodMap: () => ZodMap,
|
|
3770
|
-
ZodNaN: () => ZodNaN,
|
|
3771
|
-
ZodNativeEnum: () => ZodNativeEnum,
|
|
3772
|
-
ZodNever: () => ZodNever,
|
|
3773
|
-
ZodNull: () => ZodNull,
|
|
3774
|
-
ZodNullable: () => ZodNullable,
|
|
3775
|
-
ZodNumber: () => ZodNumber,
|
|
3776
|
-
ZodObject: () => ZodObject,
|
|
3777
|
-
ZodOptional: () => ZodOptional,
|
|
3778
|
-
ZodParsedType: () => ZodParsedType,
|
|
3779
|
-
ZodPipeline: () => ZodPipeline,
|
|
3780
|
-
ZodPromise: () => ZodPromise,
|
|
3781
|
-
ZodReadonly: () => ZodReadonly,
|
|
3782
|
-
ZodRecord: () => ZodRecord,
|
|
3783
|
-
ZodSchema: () => ZodType,
|
|
3784
|
-
ZodSet: () => ZodSet,
|
|
3785
|
-
ZodString: () => ZodString,
|
|
3786
|
-
ZodSymbol: () => ZodSymbol,
|
|
3787
|
-
ZodTransformer: () => ZodEffects,
|
|
3788
|
-
ZodTuple: () => ZodTuple,
|
|
3789
|
-
ZodType: () => ZodType,
|
|
3790
|
-
ZodUndefined: () => ZodUndefined,
|
|
3791
|
-
ZodUnion: () => ZodUnion,
|
|
3792
|
-
ZodUnknown: () => ZodUnknown,
|
|
3793
|
-
ZodVoid: () => ZodVoid,
|
|
3794
|
-
addIssueToContext: () => addIssueToContext,
|
|
3795
|
-
any: () => anyType,
|
|
3796
|
-
array: () => arrayType,
|
|
3797
|
-
bigint: () => bigIntType,
|
|
3798
|
-
boolean: () => booleanType,
|
|
3799
|
-
coerce: () => coerce,
|
|
3800
|
-
custom: () => custom,
|
|
3801
|
-
date: () => dateType,
|
|
3802
|
-
datetimeRegex: () => datetimeRegex,
|
|
3803
|
-
defaultErrorMap: () => en_default,
|
|
3804
|
-
discriminatedUnion: () => discriminatedUnionType,
|
|
3805
|
-
effect: () => effectsType,
|
|
3806
|
-
enum: () => enumType,
|
|
3807
|
-
function: () => functionType,
|
|
3808
|
-
getErrorMap: () => getErrorMap,
|
|
3809
|
-
getParsedType: () => getParsedType,
|
|
3810
|
-
instanceof: () => instanceOfType,
|
|
3811
|
-
intersection: () => intersectionType,
|
|
3812
|
-
isAborted: () => isAborted,
|
|
3813
|
-
isAsync: () => isAsync,
|
|
3814
|
-
isDirty: () => isDirty,
|
|
3815
|
-
isValid: () => isValid,
|
|
3816
|
-
late: () => late,
|
|
3817
|
-
lazy: () => lazyType,
|
|
3818
|
-
literal: () => literalType,
|
|
3819
|
-
makeIssue: () => makeIssue,
|
|
3820
|
-
map: () => mapType,
|
|
3821
|
-
nan: () => nanType,
|
|
3822
|
-
nativeEnum: () => nativeEnumType,
|
|
3823
|
-
never: () => neverType,
|
|
3824
|
-
null: () => nullType,
|
|
3825
|
-
nullable: () => nullableType,
|
|
3826
|
-
number: () => numberType,
|
|
3827
|
-
object: () => objectType,
|
|
3828
|
-
objectUtil: () => objectUtil,
|
|
3829
|
-
oboolean: () => oboolean,
|
|
3830
|
-
onumber: () => onumber,
|
|
3831
|
-
optional: () => optionalType,
|
|
3832
|
-
ostring: () => ostring,
|
|
3833
|
-
pipeline: () => pipelineType,
|
|
3834
|
-
preprocess: () => preprocessType,
|
|
3835
|
-
promise: () => promiseType,
|
|
3836
|
-
quotelessJson: () => quotelessJson,
|
|
3837
|
-
record: () => recordType,
|
|
3838
|
-
set: () => setType,
|
|
3839
|
-
setErrorMap: () => setErrorMap,
|
|
3840
|
-
strictObject: () => strictObjectType,
|
|
3841
|
-
string: () => stringType,
|
|
3842
|
-
symbol: () => symbolType,
|
|
3843
|
-
transformer: () => effectsType,
|
|
3844
|
-
tuple: () => tupleType,
|
|
3845
|
-
undefined: () => undefinedType,
|
|
3846
|
-
union: () => unionType,
|
|
3847
|
-
unknown: () => unknownType,
|
|
3848
|
-
util: () => util,
|
|
3849
|
-
void: () => voidType
|
|
3850
|
-
});
|
|
3851
|
-
|
|
3852
|
-
// ../../../node_modules/zod/v3/helpers/util.js
|
|
3853
|
-
var util;
|
|
3854
|
-
(function(util2) {
|
|
3855
|
-
util2.assertEqual = (_) => {
|
|
3856
|
-
};
|
|
3857
|
-
function assertIs(_arg) {
|
|
3858
|
-
}
|
|
3859
|
-
util2.assertIs = assertIs;
|
|
3860
|
-
function assertNever(_x) {
|
|
3861
|
-
throw new Error();
|
|
3862
|
-
}
|
|
3863
|
-
util2.assertNever = assertNever;
|
|
3864
|
-
util2.arrayToEnum = (items) => {
|
|
3865
|
-
const obj = {};
|
|
3866
|
-
for (const item of items) {
|
|
3867
|
-
obj[item] = item;
|
|
3868
|
-
}
|
|
3869
|
-
return obj;
|
|
3870
|
-
};
|
|
3871
|
-
util2.getValidEnumValues = (obj) => {
|
|
3872
|
-
const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
3873
|
-
const filtered = {};
|
|
3874
|
-
for (const k of validKeys) {
|
|
3875
|
-
filtered[k] = obj[k];
|
|
3876
|
-
}
|
|
3877
|
-
return util2.objectValues(filtered);
|
|
3878
|
-
};
|
|
3879
|
-
util2.objectValues = (obj) => {
|
|
3880
|
-
return util2.objectKeys(obj).map(function(e) {
|
|
3881
|
-
return obj[e];
|
|
3882
|
-
});
|
|
3883
|
-
};
|
|
3884
|
-
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
3885
|
-
const keys = [];
|
|
3886
|
-
for (const key in object) {
|
|
3887
|
-
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
3888
|
-
keys.push(key);
|
|
3889
|
-
}
|
|
3890
|
-
}
|
|
3891
|
-
return keys;
|
|
3892
|
-
};
|
|
3893
|
-
util2.find = (arr, checker) => {
|
|
3894
|
-
for (const item of arr) {
|
|
3895
|
-
if (checker(item))
|
|
3896
|
-
return item;
|
|
3897
|
-
}
|
|
3898
|
-
return void 0;
|
|
3899
|
-
};
|
|
3900
|
-
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
3901
|
-
function joinValues(array, separator = " | ") {
|
|
3902
|
-
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
3903
|
-
}
|
|
3904
|
-
util2.joinValues = joinValues;
|
|
3905
|
-
util2.jsonStringifyReplacer = (_, value) => {
|
|
3906
|
-
if (typeof value === "bigint") {
|
|
3907
|
-
return value.toString();
|
|
3908
|
-
}
|
|
3909
|
-
return value;
|
|
3910
|
-
};
|
|
3911
|
-
})(util || (util = {}));
|
|
3912
|
-
var objectUtil;
|
|
3913
|
-
(function(objectUtil2) {
|
|
3914
|
-
objectUtil2.mergeShapes = (first, second) => {
|
|
3915
|
-
return {
|
|
3916
|
-
...first,
|
|
3917
|
-
...second
|
|
3918
|
-
// second overwrites first
|
|
3919
|
-
};
|
|
3920
|
-
};
|
|
3921
|
-
})(objectUtil || (objectUtil = {}));
|
|
3922
|
-
var ZodParsedType = util.arrayToEnum([
|
|
3923
|
-
"string",
|
|
3924
|
-
"nan",
|
|
3925
|
-
"number",
|
|
3926
|
-
"integer",
|
|
3927
|
-
"float",
|
|
3928
|
-
"boolean",
|
|
3929
|
-
"date",
|
|
3930
|
-
"bigint",
|
|
3931
|
-
"symbol",
|
|
3932
|
-
"function",
|
|
3933
|
-
"undefined",
|
|
3934
|
-
"null",
|
|
3935
|
-
"array",
|
|
3936
|
-
"object",
|
|
3937
|
-
"unknown",
|
|
3938
|
-
"promise",
|
|
3939
|
-
"void",
|
|
3940
|
-
"never",
|
|
3941
|
-
"map",
|
|
3942
|
-
"set"
|
|
3943
|
-
]);
|
|
3944
|
-
var getParsedType = (data) => {
|
|
3945
|
-
const t = typeof data;
|
|
3946
|
-
switch (t) {
|
|
3947
|
-
case "undefined":
|
|
3948
|
-
return ZodParsedType.undefined;
|
|
3949
|
-
case "string":
|
|
3950
|
-
return ZodParsedType.string;
|
|
3951
|
-
case "number":
|
|
3952
|
-
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
3953
|
-
case "boolean":
|
|
3954
|
-
return ZodParsedType.boolean;
|
|
3955
|
-
case "function":
|
|
3956
|
-
return ZodParsedType.function;
|
|
3957
|
-
case "bigint":
|
|
3958
|
-
return ZodParsedType.bigint;
|
|
3959
|
-
case "symbol":
|
|
3960
|
-
return ZodParsedType.symbol;
|
|
3961
|
-
case "object":
|
|
3962
|
-
if (Array.isArray(data)) {
|
|
3963
|
-
return ZodParsedType.array;
|
|
3964
|
-
}
|
|
3965
|
-
if (data === null) {
|
|
3966
|
-
return ZodParsedType.null;
|
|
3967
|
-
}
|
|
3968
|
-
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
|
3969
|
-
return ZodParsedType.promise;
|
|
3970
|
-
}
|
|
3971
|
-
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
3972
|
-
return ZodParsedType.map;
|
|
3973
|
-
}
|
|
3974
|
-
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
3975
|
-
return ZodParsedType.set;
|
|
3976
|
-
}
|
|
3977
|
-
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
3978
|
-
return ZodParsedType.date;
|
|
3979
|
-
}
|
|
3980
|
-
return ZodParsedType.object;
|
|
3981
|
-
default:
|
|
3982
|
-
return ZodParsedType.unknown;
|
|
3983
|
-
}
|
|
3984
|
-
};
|
|
3985
|
-
|
|
3986
|
-
// ../../../node_modules/zod/v3/ZodError.js
|
|
3987
|
-
var ZodIssueCode = util.arrayToEnum([
|
|
3988
|
-
"invalid_type",
|
|
3989
|
-
"invalid_literal",
|
|
3990
|
-
"custom",
|
|
3991
|
-
"invalid_union",
|
|
3992
|
-
"invalid_union_discriminator",
|
|
3993
|
-
"invalid_enum_value",
|
|
3994
|
-
"unrecognized_keys",
|
|
3995
|
-
"invalid_arguments",
|
|
3996
|
-
"invalid_return_type",
|
|
3997
|
-
"invalid_date",
|
|
3998
|
-
"invalid_string",
|
|
3999
|
-
"too_small",
|
|
4000
|
-
"too_big",
|
|
4001
|
-
"invalid_intersection_types",
|
|
4002
|
-
"not_multiple_of",
|
|
4003
|
-
"not_finite"
|
|
4004
|
-
]);
|
|
4005
|
-
var quotelessJson = (obj) => {
|
|
4006
|
-
const json = JSON.stringify(obj, null, 2);
|
|
4007
|
-
return json.replace(/"([^"]+)":/g, "$1:");
|
|
4008
|
-
};
|
|
4009
|
-
var ZodError = class _ZodError extends Error {
|
|
4010
|
-
get errors() {
|
|
4011
|
-
return this.issues;
|
|
4012
|
-
}
|
|
4013
|
-
constructor(issues) {
|
|
4014
|
-
super();
|
|
4015
|
-
this.issues = [];
|
|
4016
|
-
this.addIssue = (sub) => {
|
|
4017
|
-
this.issues = [...this.issues, sub];
|
|
4018
|
-
};
|
|
4019
|
-
this.addIssues = (subs = []) => {
|
|
4020
|
-
this.issues = [...this.issues, ...subs];
|
|
4021
|
-
};
|
|
4022
|
-
const actualProto = new.target.prototype;
|
|
4023
|
-
if (Object.setPrototypeOf) {
|
|
4024
|
-
Object.setPrototypeOf(this, actualProto);
|
|
4025
|
-
} else {
|
|
4026
|
-
this.__proto__ = actualProto;
|
|
4027
|
-
}
|
|
4028
|
-
this.name = "ZodError";
|
|
4029
|
-
this.issues = issues;
|
|
4030
|
-
}
|
|
4031
|
-
format(_mapper) {
|
|
4032
|
-
const mapper = _mapper || function(issue) {
|
|
4033
|
-
return issue.message;
|
|
4034
|
-
};
|
|
4035
|
-
const fieldErrors = { _errors: [] };
|
|
4036
|
-
const processError = (error) => {
|
|
4037
|
-
for (const issue of error.issues) {
|
|
4038
|
-
if (issue.code === "invalid_union") {
|
|
4039
|
-
issue.unionErrors.map(processError);
|
|
4040
|
-
} else if (issue.code === "invalid_return_type") {
|
|
4041
|
-
processError(issue.returnTypeError);
|
|
4042
|
-
} else if (issue.code === "invalid_arguments") {
|
|
4043
|
-
processError(issue.argumentsError);
|
|
4044
|
-
} else if (issue.path.length === 0) {
|
|
4045
|
-
fieldErrors._errors.push(mapper(issue));
|
|
4046
|
-
} else {
|
|
4047
|
-
let curr = fieldErrors;
|
|
4048
|
-
let i = 0;
|
|
4049
|
-
while (i < issue.path.length) {
|
|
4050
|
-
const el = issue.path[i];
|
|
4051
|
-
const terminal = i === issue.path.length - 1;
|
|
4052
|
-
if (!terminal) {
|
|
4053
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
4054
|
-
} else {
|
|
4055
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
4056
|
-
curr[el]._errors.push(mapper(issue));
|
|
4057
|
-
}
|
|
4058
|
-
curr = curr[el];
|
|
4059
|
-
i++;
|
|
4060
|
-
}
|
|
4061
|
-
}
|
|
4062
|
-
}
|
|
4063
|
-
};
|
|
4064
|
-
processError(this);
|
|
4065
|
-
return fieldErrors;
|
|
4066
|
-
}
|
|
4067
|
-
static assert(value) {
|
|
4068
|
-
if (!(value instanceof _ZodError)) {
|
|
4069
|
-
throw new Error(`Not a ZodError: ${value}`);
|
|
4070
|
-
}
|
|
4071
|
-
}
|
|
4072
|
-
toString() {
|
|
4073
|
-
return this.message;
|
|
4074
|
-
}
|
|
4075
|
-
get message() {
|
|
4076
|
-
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
|
|
4077
|
-
}
|
|
4078
|
-
get isEmpty() {
|
|
4079
|
-
return this.issues.length === 0;
|
|
4080
|
-
}
|
|
4081
|
-
flatten(mapper = (issue) => issue.message) {
|
|
4082
|
-
const fieldErrors = {};
|
|
4083
|
-
const formErrors = [];
|
|
4084
|
-
for (const sub of this.issues) {
|
|
4085
|
-
if (sub.path.length > 0) {
|
|
4086
|
-
const firstEl = sub.path[0];
|
|
4087
|
-
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
4088
|
-
fieldErrors[firstEl].push(mapper(sub));
|
|
4089
|
-
} else {
|
|
4090
|
-
formErrors.push(mapper(sub));
|
|
4091
|
-
}
|
|
4092
|
-
}
|
|
4093
|
-
return { formErrors, fieldErrors };
|
|
4094
|
-
}
|
|
4095
|
-
get formErrors() {
|
|
4096
|
-
return this.flatten();
|
|
4097
|
-
}
|
|
4098
|
-
};
|
|
4099
|
-
ZodError.create = (issues) => {
|
|
4100
|
-
const error = new ZodError(issues);
|
|
4101
|
-
return error;
|
|
4102
|
-
};
|
|
4103
|
-
|
|
4104
|
-
// ../../../node_modules/zod/v3/locales/en.js
|
|
4105
|
-
var errorMap = (issue, _ctx) => {
|
|
4106
|
-
let message;
|
|
4107
|
-
switch (issue.code) {
|
|
4108
|
-
case ZodIssueCode.invalid_type:
|
|
4109
|
-
if (issue.received === ZodParsedType.undefined) {
|
|
4110
|
-
message = "Required";
|
|
4111
|
-
} else {
|
|
4112
|
-
message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
4113
|
-
}
|
|
4114
|
-
break;
|
|
4115
|
-
case ZodIssueCode.invalid_literal:
|
|
4116
|
-
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
|
|
4117
|
-
break;
|
|
4118
|
-
case ZodIssueCode.unrecognized_keys:
|
|
4119
|
-
message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
|
|
4120
|
-
break;
|
|
4121
|
-
case ZodIssueCode.invalid_union:
|
|
4122
|
-
message = `Invalid input`;
|
|
4123
|
-
break;
|
|
4124
|
-
case ZodIssueCode.invalid_union_discriminator:
|
|
4125
|
-
message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
|
|
4126
|
-
break;
|
|
4127
|
-
case ZodIssueCode.invalid_enum_value:
|
|
4128
|
-
message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
|
|
4129
|
-
break;
|
|
4130
|
-
case ZodIssueCode.invalid_arguments:
|
|
4131
|
-
message = `Invalid function arguments`;
|
|
4132
|
-
break;
|
|
4133
|
-
case ZodIssueCode.invalid_return_type:
|
|
4134
|
-
message = `Invalid function return type`;
|
|
4135
|
-
break;
|
|
4136
|
-
case ZodIssueCode.invalid_date:
|
|
4137
|
-
message = `Invalid date`;
|
|
4138
|
-
break;
|
|
4139
|
-
case ZodIssueCode.invalid_string:
|
|
4140
|
-
if (typeof issue.validation === "object") {
|
|
4141
|
-
if ("includes" in issue.validation) {
|
|
4142
|
-
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
4143
|
-
if (typeof issue.validation.position === "number") {
|
|
4144
|
-
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
4145
|
-
}
|
|
4146
|
-
} else if ("startsWith" in issue.validation) {
|
|
4147
|
-
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
4148
|
-
} else if ("endsWith" in issue.validation) {
|
|
4149
|
-
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
4150
|
-
} else {
|
|
4151
|
-
util.assertNever(issue.validation);
|
|
4152
|
-
}
|
|
4153
|
-
} else if (issue.validation !== "regex") {
|
|
4154
|
-
message = `Invalid ${issue.validation}`;
|
|
4155
|
-
} else {
|
|
4156
|
-
message = "Invalid";
|
|
4157
|
-
}
|
|
4158
|
-
break;
|
|
4159
|
-
case ZodIssueCode.too_small:
|
|
4160
|
-
if (issue.type === "array")
|
|
4161
|
-
message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
|
4162
|
-
else if (issue.type === "string")
|
|
4163
|
-
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
4164
|
-
else if (issue.type === "number")
|
|
4165
|
-
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
4166
|
-
else if (issue.type === "bigint")
|
|
4167
|
-
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
4168
|
-
else if (issue.type === "date")
|
|
4169
|
-
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
4170
|
-
else
|
|
4171
|
-
message = "Invalid input";
|
|
4172
|
-
break;
|
|
4173
|
-
case ZodIssueCode.too_big:
|
|
4174
|
-
if (issue.type === "array")
|
|
4175
|
-
message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
|
4176
|
-
else if (issue.type === "string")
|
|
4177
|
-
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
4178
|
-
else if (issue.type === "number")
|
|
4179
|
-
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
4180
|
-
else if (issue.type === "bigint")
|
|
4181
|
-
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
4182
|
-
else if (issue.type === "date")
|
|
4183
|
-
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
4184
|
-
else
|
|
4185
|
-
message = "Invalid input";
|
|
4186
|
-
break;
|
|
4187
|
-
case ZodIssueCode.custom:
|
|
4188
|
-
message = `Invalid input`;
|
|
4189
|
-
break;
|
|
4190
|
-
case ZodIssueCode.invalid_intersection_types:
|
|
4191
|
-
message = `Intersection results could not be merged`;
|
|
4192
|
-
break;
|
|
4193
|
-
case ZodIssueCode.not_multiple_of:
|
|
4194
|
-
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
4195
|
-
break;
|
|
4196
|
-
case ZodIssueCode.not_finite:
|
|
4197
|
-
message = "Number must be finite";
|
|
4198
|
-
break;
|
|
4199
|
-
default:
|
|
4200
|
-
message = _ctx.defaultError;
|
|
4201
|
-
util.assertNever(issue);
|
|
4202
|
-
}
|
|
4203
|
-
return { message };
|
|
4204
|
-
};
|
|
4205
|
-
var en_default = errorMap;
|
|
4206
|
-
|
|
4207
|
-
// ../../../node_modules/zod/v3/errors.js
|
|
4208
|
-
var overrideErrorMap = en_default;
|
|
4209
|
-
function setErrorMap(map) {
|
|
4210
|
-
overrideErrorMap = map;
|
|
4211
|
-
}
|
|
4212
|
-
function getErrorMap() {
|
|
4213
|
-
return overrideErrorMap;
|
|
4214
|
-
}
|
|
4215
|
-
|
|
4216
|
-
// ../../../node_modules/zod/v3/helpers/parseUtil.js
|
|
4217
|
-
var makeIssue = (params) => {
|
|
4218
|
-
const { data, path: path5, errorMaps, issueData } = params;
|
|
4219
|
-
const fullPath = [...path5, ...issueData.path || []];
|
|
4220
|
-
const fullIssue = {
|
|
4221
|
-
...issueData,
|
|
4222
|
-
path: fullPath
|
|
4223
|
-
};
|
|
4224
|
-
if (issueData.message !== void 0) {
|
|
4225
|
-
return {
|
|
4226
|
-
...issueData,
|
|
4227
|
-
path: fullPath,
|
|
4228
|
-
message: issueData.message
|
|
4229
|
-
};
|
|
4230
|
-
}
|
|
4231
|
-
let errorMessage = "";
|
|
4232
|
-
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
4233
|
-
for (const map of maps) {
|
|
4234
|
-
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
|
|
4235
|
-
}
|
|
4236
|
-
return {
|
|
4237
|
-
...issueData,
|
|
4238
|
-
path: fullPath,
|
|
4239
|
-
message: errorMessage
|
|
4240
|
-
};
|
|
4241
|
-
};
|
|
4242
|
-
var EMPTY_PATH = [];
|
|
4243
|
-
function addIssueToContext(ctx, issueData) {
|
|
4244
|
-
const overrideMap = getErrorMap();
|
|
4245
|
-
const issue = makeIssue({
|
|
4246
|
-
issueData,
|
|
4247
|
-
data: ctx.data,
|
|
4248
|
-
path: ctx.path,
|
|
4249
|
-
errorMaps: [
|
|
4250
|
-
ctx.common.contextualErrorMap,
|
|
4251
|
-
// contextual error map is first priority
|
|
4252
|
-
ctx.schemaErrorMap,
|
|
4253
|
-
// then schema-bound map if available
|
|
4254
|
-
overrideMap,
|
|
4255
|
-
// then global override map
|
|
4256
|
-
overrideMap === en_default ? void 0 : en_default
|
|
4257
|
-
// then global default map
|
|
4258
|
-
].filter((x) => !!x)
|
|
4259
|
-
});
|
|
4260
|
-
ctx.common.issues.push(issue);
|
|
4261
|
-
}
|
|
4262
|
-
var ParseStatus = class _ParseStatus {
|
|
4263
|
-
constructor() {
|
|
4264
|
-
this.value = "valid";
|
|
4265
|
-
}
|
|
4266
|
-
dirty() {
|
|
4267
|
-
if (this.value === "valid")
|
|
4268
|
-
this.value = "dirty";
|
|
4269
|
-
}
|
|
4270
|
-
abort() {
|
|
4271
|
-
if (this.value !== "aborted")
|
|
4272
|
-
this.value = "aborted";
|
|
4273
|
-
}
|
|
4274
|
-
static mergeArray(status, results) {
|
|
4275
|
-
const arrayValue = [];
|
|
4276
|
-
for (const s of results) {
|
|
4277
|
-
if (s.status === "aborted")
|
|
4278
|
-
return INVALID;
|
|
4279
|
-
if (s.status === "dirty")
|
|
4280
|
-
status.dirty();
|
|
4281
|
-
arrayValue.push(s.value);
|
|
4282
|
-
}
|
|
4283
|
-
return { status: status.value, value: arrayValue };
|
|
4284
|
-
}
|
|
4285
|
-
static async mergeObjectAsync(status, pairs) {
|
|
4286
|
-
const syncPairs = [];
|
|
4287
|
-
for (const pair of pairs) {
|
|
4288
|
-
const key = await pair.key;
|
|
4289
|
-
const value = await pair.value;
|
|
4290
|
-
syncPairs.push({
|
|
4291
|
-
key,
|
|
4292
|
-
value
|
|
4293
|
-
});
|
|
4294
|
-
}
|
|
4295
|
-
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
4296
|
-
}
|
|
4297
|
-
static mergeObjectSync(status, pairs) {
|
|
4298
|
-
const finalObject = {};
|
|
4299
|
-
for (const pair of pairs) {
|
|
4300
|
-
const { key, value } = pair;
|
|
4301
|
-
if (key.status === "aborted")
|
|
4302
|
-
return INVALID;
|
|
4303
|
-
if (value.status === "aborted")
|
|
4304
|
-
return INVALID;
|
|
4305
|
-
if (key.status === "dirty")
|
|
4306
|
-
status.dirty();
|
|
4307
|
-
if (value.status === "dirty")
|
|
4308
|
-
status.dirty();
|
|
4309
|
-
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
4310
|
-
finalObject[key.value] = value.value;
|
|
4311
|
-
}
|
|
4312
|
-
}
|
|
4313
|
-
return { status: status.value, value: finalObject };
|
|
4314
|
-
}
|
|
4315
|
-
};
|
|
4316
|
-
var INVALID = Object.freeze({
|
|
4317
|
-
status: "aborted"
|
|
4318
|
-
});
|
|
4319
|
-
var DIRTY = (value) => ({ status: "dirty", value });
|
|
4320
|
-
var OK = (value) => ({ status: "valid", value });
|
|
4321
|
-
var isAborted = (x) => x.status === "aborted";
|
|
4322
|
-
var isDirty = (x) => x.status === "dirty";
|
|
4323
|
-
var isValid = (x) => x.status === "valid";
|
|
4324
|
-
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
4325
|
-
|
|
4326
|
-
// ../../../node_modules/zod/v3/helpers/errorUtil.js
|
|
4327
|
-
var errorUtil;
|
|
4328
|
-
(function(errorUtil2) {
|
|
4329
|
-
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
4330
|
-
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
4331
|
-
})(errorUtil || (errorUtil = {}));
|
|
4332
|
-
|
|
4333
|
-
// ../../../node_modules/zod/v3/types.js
|
|
4334
|
-
var ParseInputLazyPath = class {
|
|
4335
|
-
constructor(parent, value, path5, key) {
|
|
4336
|
-
this._cachedPath = [];
|
|
4337
|
-
this.parent = parent;
|
|
4338
|
-
this.data = value;
|
|
4339
|
-
this._path = path5;
|
|
4340
|
-
this._key = key;
|
|
4341
|
-
}
|
|
4342
|
-
get path() {
|
|
4343
|
-
if (!this._cachedPath.length) {
|
|
4344
|
-
if (Array.isArray(this._key)) {
|
|
4345
|
-
this._cachedPath.push(...this._path, ...this._key);
|
|
4346
|
-
} else {
|
|
4347
|
-
this._cachedPath.push(...this._path, this._key);
|
|
4348
|
-
}
|
|
4349
|
-
}
|
|
4350
|
-
return this._cachedPath;
|
|
4351
|
-
}
|
|
4352
|
-
};
|
|
4353
|
-
var handleResult = (ctx, result) => {
|
|
4354
|
-
if (isValid(result)) {
|
|
4355
|
-
return { success: true, data: result.value };
|
|
4356
|
-
} else {
|
|
4357
|
-
if (!ctx.common.issues.length) {
|
|
4358
|
-
throw new Error("Validation failed but no issues detected.");
|
|
4359
|
-
}
|
|
4360
|
-
return {
|
|
4361
|
-
success: false,
|
|
4362
|
-
get error() {
|
|
4363
|
-
if (this._error)
|
|
4364
|
-
return this._error;
|
|
4365
|
-
const error = new ZodError(ctx.common.issues);
|
|
4366
|
-
this._error = error;
|
|
4367
|
-
return this._error;
|
|
4368
|
-
}
|
|
4369
|
-
};
|
|
3851
|
+
};
|
|
3852
|
+
var handleResult = (ctx, result) => {
|
|
3853
|
+
if (isValid(result)) {
|
|
3854
|
+
return { success: true, data: result.value };
|
|
3855
|
+
} else {
|
|
3856
|
+
if (!ctx.common.issues.length) {
|
|
3857
|
+
throw new Error("Validation failed but no issues detected.");
|
|
3858
|
+
}
|
|
3859
|
+
return {
|
|
3860
|
+
success: false,
|
|
3861
|
+
get error() {
|
|
3862
|
+
if (this._error)
|
|
3863
|
+
return this._error;
|
|
3864
|
+
const error = new ZodError(ctx.common.issues);
|
|
3865
|
+
this._error = error;
|
|
3866
|
+
return this._error;
|
|
3867
|
+
}
|
|
3868
|
+
};
|
|
4370
3869
|
}
|
|
4371
3870
|
};
|
|
4372
3871
|
function processCreateParams(params) {
|
|
@@ -7366,485 +6865,1163 @@ var ZodEffects = class extends ZodType {
|
|
|
7366
6865
|
path: ctx.path,
|
|
7367
6866
|
parent: ctx
|
|
7368
6867
|
});
|
|
7369
|
-
if (inner.status === "aborted")
|
|
7370
|
-
return INVALID;
|
|
7371
|
-
if (inner.status === "dirty")
|
|
7372
|
-
status.dirty();
|
|
7373
|
-
executeRefinement(inner.value);
|
|
7374
|
-
return { status: status.value, value: inner.value };
|
|
7375
|
-
} else {
|
|
7376
|
-
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
|
|
7377
|
-
if (inner.status === "aborted")
|
|
7378
|
-
return INVALID;
|
|
7379
|
-
if (inner.status === "dirty")
|
|
7380
|
-
status.dirty();
|
|
7381
|
-
return executeRefinement(inner.value).then(() => {
|
|
7382
|
-
return { status: status.value, value: inner.value };
|
|
7383
|
-
});
|
|
6868
|
+
if (inner.status === "aborted")
|
|
6869
|
+
return INVALID;
|
|
6870
|
+
if (inner.status === "dirty")
|
|
6871
|
+
status.dirty();
|
|
6872
|
+
executeRefinement(inner.value);
|
|
6873
|
+
return { status: status.value, value: inner.value };
|
|
6874
|
+
} else {
|
|
6875
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
|
|
6876
|
+
if (inner.status === "aborted")
|
|
6877
|
+
return INVALID;
|
|
6878
|
+
if (inner.status === "dirty")
|
|
6879
|
+
status.dirty();
|
|
6880
|
+
return executeRefinement(inner.value).then(() => {
|
|
6881
|
+
return { status: status.value, value: inner.value };
|
|
6882
|
+
});
|
|
6883
|
+
});
|
|
6884
|
+
}
|
|
6885
|
+
}
|
|
6886
|
+
if (effect.type === "transform") {
|
|
6887
|
+
if (ctx.common.async === false) {
|
|
6888
|
+
const base = this._def.schema._parseSync({
|
|
6889
|
+
data: ctx.data,
|
|
6890
|
+
path: ctx.path,
|
|
6891
|
+
parent: ctx
|
|
6892
|
+
});
|
|
6893
|
+
if (!isValid(base))
|
|
6894
|
+
return INVALID;
|
|
6895
|
+
const result = effect.transform(base.value, checkCtx);
|
|
6896
|
+
if (result instanceof Promise) {
|
|
6897
|
+
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
6898
|
+
}
|
|
6899
|
+
return { status: status.value, value: result };
|
|
6900
|
+
} else {
|
|
6901
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
|
6902
|
+
if (!isValid(base))
|
|
6903
|
+
return INVALID;
|
|
6904
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
6905
|
+
status: status.value,
|
|
6906
|
+
value: result
|
|
6907
|
+
}));
|
|
6908
|
+
});
|
|
6909
|
+
}
|
|
6910
|
+
}
|
|
6911
|
+
util.assertNever(effect);
|
|
6912
|
+
}
|
|
6913
|
+
};
|
|
6914
|
+
ZodEffects.create = (schema, effect, params) => {
|
|
6915
|
+
return new ZodEffects({
|
|
6916
|
+
schema,
|
|
6917
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
6918
|
+
effect,
|
|
6919
|
+
...processCreateParams(params)
|
|
6920
|
+
});
|
|
6921
|
+
};
|
|
6922
|
+
ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
|
|
6923
|
+
return new ZodEffects({
|
|
6924
|
+
schema,
|
|
6925
|
+
effect: { type: "preprocess", transform: preprocess },
|
|
6926
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
6927
|
+
...processCreateParams(params)
|
|
6928
|
+
});
|
|
6929
|
+
};
|
|
6930
|
+
var ZodOptional = class extends ZodType {
|
|
6931
|
+
_parse(input) {
|
|
6932
|
+
const parsedType = this._getType(input);
|
|
6933
|
+
if (parsedType === ZodParsedType.undefined) {
|
|
6934
|
+
return OK(void 0);
|
|
6935
|
+
}
|
|
6936
|
+
return this._def.innerType._parse(input);
|
|
6937
|
+
}
|
|
6938
|
+
unwrap() {
|
|
6939
|
+
return this._def.innerType;
|
|
6940
|
+
}
|
|
6941
|
+
};
|
|
6942
|
+
ZodOptional.create = (type, params) => {
|
|
6943
|
+
return new ZodOptional({
|
|
6944
|
+
innerType: type,
|
|
6945
|
+
typeName: ZodFirstPartyTypeKind.ZodOptional,
|
|
6946
|
+
...processCreateParams(params)
|
|
6947
|
+
});
|
|
6948
|
+
};
|
|
6949
|
+
var ZodNullable = class extends ZodType {
|
|
6950
|
+
_parse(input) {
|
|
6951
|
+
const parsedType = this._getType(input);
|
|
6952
|
+
if (parsedType === ZodParsedType.null) {
|
|
6953
|
+
return OK(null);
|
|
6954
|
+
}
|
|
6955
|
+
return this._def.innerType._parse(input);
|
|
6956
|
+
}
|
|
6957
|
+
unwrap() {
|
|
6958
|
+
return this._def.innerType;
|
|
6959
|
+
}
|
|
6960
|
+
};
|
|
6961
|
+
ZodNullable.create = (type, params) => {
|
|
6962
|
+
return new ZodNullable({
|
|
6963
|
+
innerType: type,
|
|
6964
|
+
typeName: ZodFirstPartyTypeKind.ZodNullable,
|
|
6965
|
+
...processCreateParams(params)
|
|
6966
|
+
});
|
|
6967
|
+
};
|
|
6968
|
+
var ZodDefault = class extends ZodType {
|
|
6969
|
+
_parse(input) {
|
|
6970
|
+
const { ctx } = this._processInputParams(input);
|
|
6971
|
+
let data = ctx.data;
|
|
6972
|
+
if (ctx.parsedType === ZodParsedType.undefined) {
|
|
6973
|
+
data = this._def.defaultValue();
|
|
6974
|
+
}
|
|
6975
|
+
return this._def.innerType._parse({
|
|
6976
|
+
data,
|
|
6977
|
+
path: ctx.path,
|
|
6978
|
+
parent: ctx
|
|
6979
|
+
});
|
|
6980
|
+
}
|
|
6981
|
+
removeDefault() {
|
|
6982
|
+
return this._def.innerType;
|
|
6983
|
+
}
|
|
6984
|
+
};
|
|
6985
|
+
ZodDefault.create = (type, params) => {
|
|
6986
|
+
return new ZodDefault({
|
|
6987
|
+
innerType: type,
|
|
6988
|
+
typeName: ZodFirstPartyTypeKind.ZodDefault,
|
|
6989
|
+
defaultValue: typeof params.default === "function" ? params.default : () => params.default,
|
|
6990
|
+
...processCreateParams(params)
|
|
6991
|
+
});
|
|
6992
|
+
};
|
|
6993
|
+
var ZodCatch = class extends ZodType {
|
|
6994
|
+
_parse(input) {
|
|
6995
|
+
const { ctx } = this._processInputParams(input);
|
|
6996
|
+
const newCtx = {
|
|
6997
|
+
...ctx,
|
|
6998
|
+
common: {
|
|
6999
|
+
...ctx.common,
|
|
7000
|
+
issues: []
|
|
7001
|
+
}
|
|
7002
|
+
};
|
|
7003
|
+
const result = this._def.innerType._parse({
|
|
7004
|
+
data: newCtx.data,
|
|
7005
|
+
path: newCtx.path,
|
|
7006
|
+
parent: {
|
|
7007
|
+
...newCtx
|
|
7008
|
+
}
|
|
7009
|
+
});
|
|
7010
|
+
if (isAsync(result)) {
|
|
7011
|
+
return result.then((result2) => {
|
|
7012
|
+
return {
|
|
7013
|
+
status: "valid",
|
|
7014
|
+
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
|
7015
|
+
get error() {
|
|
7016
|
+
return new ZodError(newCtx.common.issues);
|
|
7017
|
+
},
|
|
7018
|
+
input: newCtx.data
|
|
7019
|
+
})
|
|
7020
|
+
};
|
|
7021
|
+
});
|
|
7022
|
+
} else {
|
|
7023
|
+
return {
|
|
7024
|
+
status: "valid",
|
|
7025
|
+
value: result.status === "valid" ? result.value : this._def.catchValue({
|
|
7026
|
+
get error() {
|
|
7027
|
+
return new ZodError(newCtx.common.issues);
|
|
7028
|
+
},
|
|
7029
|
+
input: newCtx.data
|
|
7030
|
+
})
|
|
7031
|
+
};
|
|
7032
|
+
}
|
|
7033
|
+
}
|
|
7034
|
+
removeCatch() {
|
|
7035
|
+
return this._def.innerType;
|
|
7036
|
+
}
|
|
7037
|
+
};
|
|
7038
|
+
ZodCatch.create = (type, params) => {
|
|
7039
|
+
return new ZodCatch({
|
|
7040
|
+
innerType: type,
|
|
7041
|
+
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
|
7042
|
+
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
|
7043
|
+
...processCreateParams(params)
|
|
7044
|
+
});
|
|
7045
|
+
};
|
|
7046
|
+
var ZodNaN = class extends ZodType {
|
|
7047
|
+
_parse(input) {
|
|
7048
|
+
const parsedType = this._getType(input);
|
|
7049
|
+
if (parsedType !== ZodParsedType.nan) {
|
|
7050
|
+
const ctx = this._getOrReturnCtx(input);
|
|
7051
|
+
addIssueToContext(ctx, {
|
|
7052
|
+
code: ZodIssueCode.invalid_type,
|
|
7053
|
+
expected: ZodParsedType.nan,
|
|
7054
|
+
received: ctx.parsedType
|
|
7055
|
+
});
|
|
7056
|
+
return INVALID;
|
|
7057
|
+
}
|
|
7058
|
+
return { status: "valid", value: input.data };
|
|
7059
|
+
}
|
|
7060
|
+
};
|
|
7061
|
+
ZodNaN.create = (params) => {
|
|
7062
|
+
return new ZodNaN({
|
|
7063
|
+
typeName: ZodFirstPartyTypeKind.ZodNaN,
|
|
7064
|
+
...processCreateParams(params)
|
|
7065
|
+
});
|
|
7066
|
+
};
|
|
7067
|
+
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
|
|
7068
|
+
var ZodBranded = class extends ZodType {
|
|
7069
|
+
_parse(input) {
|
|
7070
|
+
const { ctx } = this._processInputParams(input);
|
|
7071
|
+
const data = ctx.data;
|
|
7072
|
+
return this._def.type._parse({
|
|
7073
|
+
data,
|
|
7074
|
+
path: ctx.path,
|
|
7075
|
+
parent: ctx
|
|
7076
|
+
});
|
|
7077
|
+
}
|
|
7078
|
+
unwrap() {
|
|
7079
|
+
return this._def.type;
|
|
7080
|
+
}
|
|
7081
|
+
};
|
|
7082
|
+
var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
7083
|
+
_parse(input) {
|
|
7084
|
+
const { status, ctx } = this._processInputParams(input);
|
|
7085
|
+
if (ctx.common.async) {
|
|
7086
|
+
const handleAsync = async () => {
|
|
7087
|
+
const inResult = await this._def.in._parseAsync({
|
|
7088
|
+
data: ctx.data,
|
|
7089
|
+
path: ctx.path,
|
|
7090
|
+
parent: ctx
|
|
7091
|
+
});
|
|
7092
|
+
if (inResult.status === "aborted")
|
|
7093
|
+
return INVALID;
|
|
7094
|
+
if (inResult.status === "dirty") {
|
|
7095
|
+
status.dirty();
|
|
7096
|
+
return DIRTY(inResult.value);
|
|
7097
|
+
} else {
|
|
7098
|
+
return this._def.out._parseAsync({
|
|
7099
|
+
data: inResult.value,
|
|
7100
|
+
path: ctx.path,
|
|
7101
|
+
parent: ctx
|
|
7102
|
+
});
|
|
7103
|
+
}
|
|
7104
|
+
};
|
|
7105
|
+
return handleAsync();
|
|
7106
|
+
} else {
|
|
7107
|
+
const inResult = this._def.in._parseSync({
|
|
7108
|
+
data: ctx.data,
|
|
7109
|
+
path: ctx.path,
|
|
7110
|
+
parent: ctx
|
|
7111
|
+
});
|
|
7112
|
+
if (inResult.status === "aborted")
|
|
7113
|
+
return INVALID;
|
|
7114
|
+
if (inResult.status === "dirty") {
|
|
7115
|
+
status.dirty();
|
|
7116
|
+
return {
|
|
7117
|
+
status: "dirty",
|
|
7118
|
+
value: inResult.value
|
|
7119
|
+
};
|
|
7120
|
+
} else {
|
|
7121
|
+
return this._def.out._parseSync({
|
|
7122
|
+
data: inResult.value,
|
|
7123
|
+
path: ctx.path,
|
|
7124
|
+
parent: ctx
|
|
7125
|
+
});
|
|
7126
|
+
}
|
|
7127
|
+
}
|
|
7128
|
+
}
|
|
7129
|
+
static create(a, b) {
|
|
7130
|
+
return new _ZodPipeline({
|
|
7131
|
+
in: a,
|
|
7132
|
+
out: b,
|
|
7133
|
+
typeName: ZodFirstPartyTypeKind.ZodPipeline
|
|
7134
|
+
});
|
|
7135
|
+
}
|
|
7136
|
+
};
|
|
7137
|
+
var ZodReadonly = class extends ZodType {
|
|
7138
|
+
_parse(input) {
|
|
7139
|
+
const result = this._def.innerType._parse(input);
|
|
7140
|
+
const freeze = (data) => {
|
|
7141
|
+
if (isValid(data)) {
|
|
7142
|
+
data.value = Object.freeze(data.value);
|
|
7143
|
+
}
|
|
7144
|
+
return data;
|
|
7145
|
+
};
|
|
7146
|
+
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
7147
|
+
}
|
|
7148
|
+
unwrap() {
|
|
7149
|
+
return this._def.innerType;
|
|
7150
|
+
}
|
|
7151
|
+
};
|
|
7152
|
+
ZodReadonly.create = (type, params) => {
|
|
7153
|
+
return new ZodReadonly({
|
|
7154
|
+
innerType: type,
|
|
7155
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
7156
|
+
...processCreateParams(params)
|
|
7157
|
+
});
|
|
7158
|
+
};
|
|
7159
|
+
function cleanParams(params, data) {
|
|
7160
|
+
const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
|
|
7161
|
+
const p2 = typeof p === "string" ? { message: p } : p;
|
|
7162
|
+
return p2;
|
|
7163
|
+
}
|
|
7164
|
+
function custom(check, _params = {}, fatal) {
|
|
7165
|
+
if (check)
|
|
7166
|
+
return ZodAny.create().superRefine((data, ctx) => {
|
|
7167
|
+
const r = check(data);
|
|
7168
|
+
if (r instanceof Promise) {
|
|
7169
|
+
return r.then((r2) => {
|
|
7170
|
+
if (!r2) {
|
|
7171
|
+
const params = cleanParams(_params, data);
|
|
7172
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
7173
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
7174
|
+
}
|
|
7384
7175
|
});
|
|
7385
7176
|
}
|
|
7177
|
+
if (!r) {
|
|
7178
|
+
const params = cleanParams(_params, data);
|
|
7179
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
7180
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
7181
|
+
}
|
|
7182
|
+
return;
|
|
7183
|
+
});
|
|
7184
|
+
return ZodAny.create();
|
|
7185
|
+
}
|
|
7186
|
+
var late = {
|
|
7187
|
+
object: ZodObject.lazycreate
|
|
7188
|
+
};
|
|
7189
|
+
var ZodFirstPartyTypeKind;
|
|
7190
|
+
(function(ZodFirstPartyTypeKind2) {
|
|
7191
|
+
ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
|
|
7192
|
+
ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
|
|
7193
|
+
ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
|
|
7194
|
+
ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
|
|
7195
|
+
ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
|
|
7196
|
+
ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
|
|
7197
|
+
ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
|
|
7198
|
+
ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
|
|
7199
|
+
ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
|
|
7200
|
+
ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
|
|
7201
|
+
ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
|
|
7202
|
+
ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
|
|
7203
|
+
ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
|
|
7204
|
+
ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
|
|
7205
|
+
ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
|
|
7206
|
+
ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
|
|
7207
|
+
ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
7208
|
+
ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
|
|
7209
|
+
ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
|
|
7210
|
+
ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
|
|
7211
|
+
ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
|
|
7212
|
+
ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
|
|
7213
|
+
ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
|
|
7214
|
+
ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
|
|
7215
|
+
ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
|
|
7216
|
+
ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
|
|
7217
|
+
ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
|
|
7218
|
+
ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
|
|
7219
|
+
ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
|
|
7220
|
+
ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
|
|
7221
|
+
ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
|
|
7222
|
+
ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
|
|
7223
|
+
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
|
7224
|
+
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
|
7225
|
+
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
7226
|
+
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
7227
|
+
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
7228
|
+
var instanceOfType = (cls, params = {
|
|
7229
|
+
message: `Input not instance of ${cls.name}`
|
|
7230
|
+
}) => custom((data) => data instanceof cls, params);
|
|
7231
|
+
var stringType = ZodString.create;
|
|
7232
|
+
var numberType = ZodNumber.create;
|
|
7233
|
+
var nanType = ZodNaN.create;
|
|
7234
|
+
var bigIntType = ZodBigInt.create;
|
|
7235
|
+
var booleanType = ZodBoolean.create;
|
|
7236
|
+
var dateType = ZodDate.create;
|
|
7237
|
+
var symbolType = ZodSymbol.create;
|
|
7238
|
+
var undefinedType = ZodUndefined.create;
|
|
7239
|
+
var nullType = ZodNull.create;
|
|
7240
|
+
var anyType = ZodAny.create;
|
|
7241
|
+
var unknownType = ZodUnknown.create;
|
|
7242
|
+
var neverType = ZodNever.create;
|
|
7243
|
+
var voidType = ZodVoid.create;
|
|
7244
|
+
var arrayType = ZodArray.create;
|
|
7245
|
+
var objectType = ZodObject.create;
|
|
7246
|
+
var strictObjectType = ZodObject.strictCreate;
|
|
7247
|
+
var unionType = ZodUnion.create;
|
|
7248
|
+
var discriminatedUnionType = ZodDiscriminatedUnion.create;
|
|
7249
|
+
var intersectionType = ZodIntersection.create;
|
|
7250
|
+
var tupleType = ZodTuple.create;
|
|
7251
|
+
var recordType = ZodRecord.create;
|
|
7252
|
+
var mapType = ZodMap.create;
|
|
7253
|
+
var setType = ZodSet.create;
|
|
7254
|
+
var functionType = ZodFunction.create;
|
|
7255
|
+
var lazyType = ZodLazy.create;
|
|
7256
|
+
var literalType = ZodLiteral.create;
|
|
7257
|
+
var enumType = ZodEnum.create;
|
|
7258
|
+
var nativeEnumType = ZodNativeEnum.create;
|
|
7259
|
+
var promiseType = ZodPromise.create;
|
|
7260
|
+
var effectsType = ZodEffects.create;
|
|
7261
|
+
var optionalType = ZodOptional.create;
|
|
7262
|
+
var nullableType = ZodNullable.create;
|
|
7263
|
+
var preprocessType = ZodEffects.createWithPreprocess;
|
|
7264
|
+
var pipelineType = ZodPipeline.create;
|
|
7265
|
+
var ostring = () => stringType().optional();
|
|
7266
|
+
var onumber = () => numberType().optional();
|
|
7267
|
+
var oboolean = () => booleanType().optional();
|
|
7268
|
+
var coerce = {
|
|
7269
|
+
string: ((arg) => ZodString.create({ ...arg, coerce: true })),
|
|
7270
|
+
number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
|
|
7271
|
+
boolean: ((arg) => ZodBoolean.create({
|
|
7272
|
+
...arg,
|
|
7273
|
+
coerce: true
|
|
7274
|
+
})),
|
|
7275
|
+
bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
|
|
7276
|
+
date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
|
|
7277
|
+
};
|
|
7278
|
+
var NEVER = INVALID;
|
|
7279
|
+
|
|
7280
|
+
// ../shared/src/queryFieldOps.ts
|
|
7281
|
+
var PREDICATE_VARIANTS = [
|
|
7282
|
+
{
|
|
7283
|
+
value: "unknown",
|
|
7284
|
+
ops: [
|
|
7285
|
+
{ op: "eq", label: "=" },
|
|
7286
|
+
{ op: "neq", label: "\u2260" }
|
|
7287
|
+
]
|
|
7288
|
+
},
|
|
7289
|
+
{ value: "unknownArray", ops: [{ op: "in", label: "in" }] },
|
|
7290
|
+
{
|
|
7291
|
+
value: "unknown",
|
|
7292
|
+
ops: [
|
|
7293
|
+
{ op: "gt", label: ">" },
|
|
7294
|
+
{ op: "gte", label: "\u2265" },
|
|
7295
|
+
{ op: "lt", label: "<" },
|
|
7296
|
+
{ op: "lte", label: "\u2264" }
|
|
7297
|
+
]
|
|
7298
|
+
},
|
|
7299
|
+
{ value: "between", ops: [{ op: "between", label: "between" }] },
|
|
7300
|
+
{
|
|
7301
|
+
value: "unknownArray",
|
|
7302
|
+
ops: [{ op: "containsAll", label: "contains all" }]
|
|
7303
|
+
}
|
|
7304
|
+
];
|
|
7305
|
+
var PREDICATE_OPS = PREDICATE_VARIANTS.flatMap(
|
|
7306
|
+
(variant) => variant.ops.map(({ op }) => op)
|
|
7307
|
+
);
|
|
7308
|
+
var PREDICATE_OP_LABELS = new Map(
|
|
7309
|
+
PREDICATE_VARIANTS.flatMap((variant) => variant.ops.map(({ op, label }) => [op, label]))
|
|
7310
|
+
);
|
|
7311
|
+
|
|
7312
|
+
// ../shared/src/queryTypes.ts
|
|
7313
|
+
var listAccessKindSchema = external_exports.enum(["table", "index", "search", "idList"]);
|
|
7314
|
+
var listPageKindSchema = external_exports.enum(["paginate", "boundedSort"]);
|
|
7315
|
+
var queryErrorCodeSchema = external_exports.enum([
|
|
7316
|
+
"query_invalid",
|
|
7317
|
+
"query_unsupported",
|
|
7318
|
+
"query_unsatisfiable"
|
|
7319
|
+
]);
|
|
7320
|
+
var predicateOpSchema = external_exports.enum(PREDICATE_OPS);
|
|
7321
|
+
var betweenValueSchema = external_exports.object({
|
|
7322
|
+
min: external_exports.unknown(),
|
|
7323
|
+
max: external_exports.unknown()
|
|
7324
|
+
}).refine(
|
|
7325
|
+
(value) => Object.hasOwn(value, "min") && Object.hasOwn(value, "max"),
|
|
7326
|
+
"Between requires min and max"
|
|
7327
|
+
);
|
|
7328
|
+
var predicateSchemas = PREDICATE_VARIANTS.flatMap(
|
|
7329
|
+
(variant) => variant.ops.map(
|
|
7330
|
+
({ op }) => external_exports.object({
|
|
7331
|
+
field: external_exports.string().min(1),
|
|
7332
|
+
op: external_exports.literal(op),
|
|
7333
|
+
value: variant.value === "unknownArray" ? external_exports.array(external_exports.unknown()) : variant.value === "between" ? betweenValueSchema : external_exports.unknown()
|
|
7334
|
+
})
|
|
7335
|
+
)
|
|
7336
|
+
);
|
|
7337
|
+
var predicateSchema = external_exports.discriminatedUnion(
|
|
7338
|
+
"op",
|
|
7339
|
+
predicateSchemas
|
|
7340
|
+
).refine(
|
|
7341
|
+
(predicate) => Object.hasOwn(predicate, "value"),
|
|
7342
|
+
"Predicate value is required"
|
|
7343
|
+
);
|
|
7344
|
+
var queryOrderSchema = external_exports.object({
|
|
7345
|
+
field: external_exports.string().min(1),
|
|
7346
|
+
direction: external_exports.enum(["asc", "desc"])
|
|
7347
|
+
});
|
|
7348
|
+
var querySearchSchema = external_exports.object({
|
|
7349
|
+
index: external_exports.string().min(1),
|
|
7350
|
+
query: external_exports.string()
|
|
7351
|
+
});
|
|
7352
|
+
var querySchema = external_exports.object({
|
|
7353
|
+
predicates: external_exports.array(predicateSchema).optional(),
|
|
7354
|
+
order: queryOrderSchema.optional(),
|
|
7355
|
+
search: querySearchSchema.optional(),
|
|
7356
|
+
/** Reserved — rejected by the planner until vector indexes exist in the manifest. */
|
|
7357
|
+
vector: external_exports.unknown().optional(),
|
|
7358
|
+
maxScan: external_exports.number().int().positive().optional(),
|
|
7359
|
+
indexHint: external_exports.string().min(1).optional()
|
|
7360
|
+
});
|
|
7361
|
+
var clampQuerySchema = external_exports.object({
|
|
7362
|
+
predicates: external_exports.array(predicateSchema).optional(),
|
|
7363
|
+
order: queryOrderSchema.optional(),
|
|
7364
|
+
search: querySearchSchema.optional()
|
|
7365
|
+
});
|
|
7366
|
+
var listMetaOrderSchema = external_exports.union([
|
|
7367
|
+
queryOrderSchema,
|
|
7368
|
+
external_exports.object({ kind: external_exports.literal("relevance") })
|
|
7369
|
+
]);
|
|
7370
|
+
var listMetaSchema = external_exports.object({
|
|
7371
|
+
access: listAccessKindSchema,
|
|
7372
|
+
page: listPageKindSchema,
|
|
7373
|
+
order: listMetaOrderSchema.optional(),
|
|
7374
|
+
indexName: external_exports.string().optional(),
|
|
7375
|
+
searchIndexName: external_exports.string().optional(),
|
|
7376
|
+
scanned: external_exports.number().int().nonnegative().optional(),
|
|
7377
|
+
truncated: external_exports.boolean().optional()
|
|
7378
|
+
});
|
|
7379
|
+
|
|
7380
|
+
// ../shared/src/apiProfile.ts
|
|
7381
|
+
var apiTableAccessSchema = external_exports.object({
|
|
7382
|
+
table: external_exports.string(),
|
|
7383
|
+
read: external_exports.boolean(),
|
|
7384
|
+
/** Push to enabled webhook outputs. Missing/undefined = false (opt-in). */
|
|
7385
|
+
sync: external_exports.boolean().optional(),
|
|
7386
|
+
/**
|
|
7387
|
+
* Authenticated Studio/CMS editor write access for this table.
|
|
7388
|
+
* Missing/undefined = false (opt-in). Independent of public API-token propose.
|
|
7389
|
+
*/
|
|
7390
|
+
editorAccess: external_exports.boolean().optional(),
|
|
7391
|
+
propose: external_exports.object({
|
|
7392
|
+
ops: external_exports.object({ insert: external_exports.boolean(), update: external_exports.boolean(), delete: external_exports.boolean() }),
|
|
7393
|
+
allowedFields: external_exports.array(external_exports.string()).optional(),
|
|
7394
|
+
recordIds: external_exports.array(external_exports.string()).optional()
|
|
7395
|
+
}).optional(),
|
|
7396
|
+
autoAccept: external_exports.boolean().optional(),
|
|
7397
|
+
/**
|
|
7398
|
+
* Opaque row clamp: AND-merged with caller Query on Read API / guest lists.
|
|
7399
|
+
* Sync membership uses `rowQuery.predicates` only (order/search ignored; maxScanLimit ignored).
|
|
7400
|
+
*/
|
|
7401
|
+
rowQuery: clampQuerySchema.optional(),
|
|
7402
|
+
/** Scan ceiling for Read/guest list plans; callers may only lower. Not applied to Sync/Resync. */
|
|
7403
|
+
maxScanLimit: external_exports.number().int().positive().optional()
|
|
7404
|
+
});
|
|
7405
|
+
var apiProfileSnapshotSchema = external_exports.object({
|
|
7406
|
+
id: external_exports.string(),
|
|
7407
|
+
name: external_exports.string(),
|
|
7408
|
+
slug: external_exports.string(),
|
|
7409
|
+
tables: external_exports.array(external_exports.string()),
|
|
7410
|
+
tableAccess: external_exports.array(apiTableAccessSchema).optional(),
|
|
7411
|
+
autoAcceptProposals: external_exports.boolean().optional(),
|
|
7412
|
+
apiVersion: external_exports.number(),
|
|
7413
|
+
updatedAt: external_exports.number()
|
|
7414
|
+
});
|
|
7415
|
+
var apiProfilesSchema = external_exports.array(apiProfileSnapshotSchema);
|
|
7416
|
+
function editorAccessEnabled(access2) {
|
|
7417
|
+
return access2.editorAccess === true;
|
|
7418
|
+
}
|
|
7419
|
+
|
|
7420
|
+
// ../api-codegen/src/generate-documents.ts
|
|
7421
|
+
function fieldTypeToTs(type) {
|
|
7422
|
+
switch (type.kind) {
|
|
7423
|
+
case "string":
|
|
7424
|
+
case "markdown":
|
|
7425
|
+
return "string";
|
|
7426
|
+
case "number":
|
|
7427
|
+
case "date":
|
|
7428
|
+
case "datetime":
|
|
7429
|
+
return "number";
|
|
7430
|
+
case "boolean":
|
|
7431
|
+
return "boolean";
|
|
7432
|
+
case "bigint":
|
|
7433
|
+
return "bigint";
|
|
7434
|
+
case "null":
|
|
7435
|
+
return "null";
|
|
7436
|
+
case "any":
|
|
7437
|
+
return "unknown";
|
|
7438
|
+
case "bytes":
|
|
7439
|
+
return "ArrayBuffer";
|
|
7440
|
+
case "file":
|
|
7441
|
+
case "image":
|
|
7442
|
+
return 'Id<"_storage">';
|
|
7443
|
+
case "id":
|
|
7444
|
+
return `Id<${JSON.stringify(type.table)}>`;
|
|
7445
|
+
case "literal":
|
|
7446
|
+
return JSON.stringify(type.value);
|
|
7447
|
+
case "array":
|
|
7448
|
+
return `${fieldTypeToTs(type.element)}[]`;
|
|
7449
|
+
case "object": {
|
|
7450
|
+
if (type.fields.length === 0) return "Record<string, never>";
|
|
7451
|
+
const props = type.fields.map((f) => fieldToTsProperty(f));
|
|
7452
|
+
return `{ ${props.join("; ")} }`;
|
|
7386
7453
|
}
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
parent: ctx
|
|
7393
|
-
});
|
|
7394
|
-
if (!isValid(base))
|
|
7395
|
-
return INVALID;
|
|
7396
|
-
const result = effect.transform(base.value, checkCtx);
|
|
7397
|
-
if (result instanceof Promise) {
|
|
7398
|
-
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
7399
|
-
}
|
|
7400
|
-
return { status: status.value, value: result };
|
|
7401
|
-
} else {
|
|
7402
|
-
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
|
7403
|
-
if (!isValid(base))
|
|
7404
|
-
return INVALID;
|
|
7405
|
-
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
7406
|
-
status: status.value,
|
|
7407
|
-
value: result
|
|
7408
|
-
}));
|
|
7409
|
-
});
|
|
7410
|
-
}
|
|
7454
|
+
case "union":
|
|
7455
|
+
return type.options.map(fieldTypeToTs).join(" | ");
|
|
7456
|
+
default: {
|
|
7457
|
+
const _exhaustive = type;
|
|
7458
|
+
return _exhaustive;
|
|
7411
7459
|
}
|
|
7412
|
-
util.assertNever(effect);
|
|
7413
7460
|
}
|
|
7461
|
+
}
|
|
7462
|
+
function fieldToTsProperty(field) {
|
|
7463
|
+
const optional = field.optional ? "?" : "";
|
|
7464
|
+
return `${field.name}${optional}: ${fieldTypeToTs(field.type)}`;
|
|
7465
|
+
}
|
|
7466
|
+
function docTypeName(tableName) {
|
|
7467
|
+
return `${tableName}Doc`;
|
|
7468
|
+
}
|
|
7469
|
+
function generateDocumentsTs(banner, tables) {
|
|
7470
|
+
const sorted = [...tables].sort((a, b) => a.name.localeCompare(b.name));
|
|
7471
|
+
const tableNames = sorted.map((t) => t.name);
|
|
7472
|
+
const docTypes = sorted.map((table) => {
|
|
7473
|
+
const name = docTypeName(table.name);
|
|
7474
|
+
const fields = table.fields.map((f) => ` ${fieldToTsProperty(f)};`).join("\n");
|
|
7475
|
+
return `export type ${name} = {
|
|
7476
|
+
_id: Id<${JSON.stringify(table.name)}>;
|
|
7477
|
+
_creationTime: number;
|
|
7478
|
+
${fields}
|
|
7479
|
+
};`;
|
|
7480
|
+
}).join("\n\n");
|
|
7481
|
+
const docByTableEntries = sorted.map((t) => ` ${JSON.stringify(t.name)}: ${docTypeName(t.name)};`).join("\n");
|
|
7482
|
+
const metaConstants = `export const PULLED_TABLE_NAMES = [${tableNames.map((n) => JSON.stringify(n)).join(", ")}] as const;
|
|
7483
|
+
export type TableName = (typeof PULLED_TABLE_NAMES)[number];
|
|
7484
|
+
`;
|
|
7485
|
+
return `${banner}import type { Id } from "../../convex/_generated/dataModel.js";
|
|
7486
|
+
|
|
7487
|
+
${metaConstants}
|
|
7488
|
+
${docTypes}
|
|
7489
|
+
|
|
7490
|
+
export type DocByTable = {
|
|
7491
|
+
${docByTableEntries}
|
|
7414
7492
|
};
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7493
|
+
`;
|
|
7494
|
+
}
|
|
7495
|
+
|
|
7496
|
+
// ../api-codegen/src/generate-query-types.ts
|
|
7497
|
+
function quotedUnion(values) {
|
|
7498
|
+
return values.map((value) => JSON.stringify(value)).join(" | ");
|
|
7499
|
+
}
|
|
7500
|
+
function multilineUnion(values) {
|
|
7501
|
+
return values.map((value) => ` | ${JSON.stringify(value)}`).join("\n");
|
|
7502
|
+
}
|
|
7503
|
+
function emitQueryTs(banner) {
|
|
7504
|
+
const predicate = PREDICATE_VARIANTS.map((variant) => {
|
|
7505
|
+
const value = variant.value === "unknownArray" ? "unknown[]" : variant.value === "between" ? "{ min: unknown; max: unknown }" : "unknown";
|
|
7506
|
+
return ` | { field: string; op: ${quotedUnion(variant.ops.map(({ op }) => op))}; value: ${value} }`;
|
|
7507
|
+
}).join("\n");
|
|
7508
|
+
return `${banner}export type PredicateOp =
|
|
7509
|
+
${multilineUnion(PREDICATE_OPS)};
|
|
7510
|
+
|
|
7511
|
+
export type Predicate =
|
|
7512
|
+
${predicate};
|
|
7513
|
+
|
|
7514
|
+
export type QueryOrder = { field: string; direction: "asc" | "desc" };
|
|
7515
|
+
|
|
7516
|
+
export type QuerySearch = { index: string; query: string };
|
|
7517
|
+
|
|
7518
|
+
export type Query = {
|
|
7519
|
+
predicates?: Predicate[];
|
|
7520
|
+
order?: QueryOrder;
|
|
7521
|
+
search?: QuerySearch;
|
|
7522
|
+
maxScan?: number;
|
|
7523
|
+
indexHint?: string;
|
|
7524
|
+
vector?: unknown;
|
|
7422
7525
|
};
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7526
|
+
|
|
7527
|
+
export type ListMeta = {
|
|
7528
|
+
access: "table" | "index" | "search" | "idList";
|
|
7529
|
+
page: "paginate" | "boundedSort";
|
|
7530
|
+
order?: QueryOrder | { kind: "relevance" };
|
|
7531
|
+
indexName?: string;
|
|
7532
|
+
searchIndexName?: string;
|
|
7533
|
+
scanned?: number;
|
|
7534
|
+
truncated?: boolean;
|
|
7430
7535
|
};
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
return this._def.innerType._parse(input);
|
|
7438
|
-
}
|
|
7439
|
-
unwrap() {
|
|
7440
|
-
return this._def.innerType;
|
|
7441
|
-
}
|
|
7536
|
+
|
|
7537
|
+
export type ListResult<T> = {
|
|
7538
|
+
page: T[];
|
|
7539
|
+
isDone: boolean;
|
|
7540
|
+
continueCursor: string;
|
|
7541
|
+
meta: ListMeta;
|
|
7442
7542
|
};
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7543
|
+
`;
|
|
7544
|
+
}
|
|
7545
|
+
|
|
7546
|
+
// ../api-codegen/src/generate-read-api-refs.ts
|
|
7547
|
+
function generateReadApiRefsTs(banner, profileSlug, tables) {
|
|
7548
|
+
const sorted = [...tables].sort((a, b) => a.name.localeCompare(b.name));
|
|
7549
|
+
const listRefs = sorted.map((table) => {
|
|
7550
|
+
const doc = docTypeName(table.name);
|
|
7551
|
+
const path5 = readApiAnyApiPath(profileSlug, "list", table.name);
|
|
7552
|
+
return `export const list${table.name}Ref = ${path5} as FunctionReference<
|
|
7553
|
+
"query",
|
|
7554
|
+
"public",
|
|
7555
|
+
{ apiToken: string; query?: Query; paginationOpts: PaginationOptions },
|
|
7556
|
+
ListResult<${doc}>
|
|
7557
|
+
>;`;
|
|
7558
|
+
}).join("\n\n");
|
|
7559
|
+
const getRefs = sorted.map((table) => {
|
|
7560
|
+
const doc = docTypeName(table.name);
|
|
7561
|
+
const path5 = readApiAnyApiPath(profileSlug, "get", table.name);
|
|
7562
|
+
return `export const get${table.name}Ref = ${path5} as FunctionReference<
|
|
7563
|
+
"query",
|
|
7564
|
+
"public",
|
|
7565
|
+
{ apiToken: string; id: string },
|
|
7566
|
+
${doc} | null
|
|
7567
|
+
>;`;
|
|
7568
|
+
}).join("\n");
|
|
7569
|
+
const listRefMap = sorted.map((table) => ` ${JSON.stringify(table.name)}: list${table.name}Ref as ListRef,`).join("\n");
|
|
7570
|
+
return `${banner}import type { FunctionReference, PaginationOptions } from "convex/server";
|
|
7571
|
+
import { anyApi } from "convex/server";
|
|
7572
|
+
import type { ListResult, Query } from "./query.js";
|
|
7573
|
+
import type {
|
|
7574
|
+
${sorted.map((t) => ` ${docTypeName(t.name)},`).join("\n")}
|
|
7575
|
+
TableName,
|
|
7576
|
+
} from "./documents.js";
|
|
7577
|
+
|
|
7578
|
+
export type ListRef = FunctionReference<
|
|
7579
|
+
"query",
|
|
7580
|
+
"public",
|
|
7581
|
+
{ apiToken: string; query?: Query; paginationOpts: PaginationOptions },
|
|
7582
|
+
ListResult<Record<string, unknown>>
|
|
7583
|
+
>;
|
|
7584
|
+
|
|
7585
|
+
${listRefs}
|
|
7586
|
+
|
|
7587
|
+
/** Readable tables only \u2014 propose-only allowlist entries are omitted. */
|
|
7588
|
+
export const listRefByTable: Partial<Record<TableName, ListRef>> = {
|
|
7589
|
+
${listRefMap}
|
|
7449
7590
|
};
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7591
|
+
|
|
7592
|
+
${getRefs}
|
|
7593
|
+
`;
|
|
7594
|
+
}
|
|
7595
|
+
|
|
7596
|
+
// ../api-codegen/src/generate-client-pull.ts
|
|
7597
|
+
var READ_API_BANNER = `// AUTO-GENERATED by columnus-api pull. Do not edit by hand \u2014
|
|
7598
|
+
// re-run \`columnus-api pull\` after profile or schema changes.
|
|
7599
|
+
`;
|
|
7600
|
+
var DEFAULT_LIST_PAGE_SIZE = 50;
|
|
7601
|
+
function generateClientPullFiles(input) {
|
|
7602
|
+
const manifest = { tables: [...input.tables] };
|
|
7603
|
+
const tableNames = manifest.tables.map((t) => t.name).sort((a, b) => a.localeCompare(b));
|
|
7604
|
+
const accesses = input.tableAccess ?? input.tables.map((table) => ({ table: table.name, read: true }));
|
|
7605
|
+
const readableTables = manifest.tables.filter(
|
|
7606
|
+
(table) => accesses.some((access2) => access2.table === table.name && access2.read)
|
|
7607
|
+
);
|
|
7608
|
+
const files = /* @__PURE__ */ new Map();
|
|
7609
|
+
const schemaTs = generateSchemaTs(manifest, HOST_SCHEMA_PROFILE).replace(
|
|
7610
|
+
/^\/\/ AUTO-GENERATED[^\n]*\n/,
|
|
7611
|
+
READ_API_BANNER
|
|
7612
|
+
);
|
|
7613
|
+
files.set("convex/schema.ts", schemaTs);
|
|
7614
|
+
files.set("convex.json", "{}\n");
|
|
7615
|
+
files.set("src/generated/manifest.json", `${JSON.stringify(manifest, null, 2)}
|
|
7616
|
+
`);
|
|
7617
|
+
files.set("src/generated/manifest-types.ts", generateManifestTypesTs());
|
|
7618
|
+
files.set("src/generated/documents.ts", generateDocumentsTs(READ_API_BANNER, manifest.tables));
|
|
7619
|
+
files.set(
|
|
7620
|
+
"src/generated/read-api-refs.ts",
|
|
7621
|
+
generateReadApiRefsTs(READ_API_BANNER, input.profileSlug, readableTables)
|
|
7622
|
+
);
|
|
7623
|
+
files.set("src/generated/read-api-token.ts", generateReadApiTokenTs());
|
|
7624
|
+
files.set(
|
|
7625
|
+
"src/generated/proposal-api-refs.ts",
|
|
7626
|
+
generateProposalApiRefsTs(input.profileSlug, manifest.tables, accesses)
|
|
7627
|
+
);
|
|
7628
|
+
files.set(
|
|
7629
|
+
"src/generated/profile-proposal-refs.ts",
|
|
7630
|
+
generateProfileProposalRefsTs(manifest.tables, accesses)
|
|
7631
|
+
);
|
|
7632
|
+
files.set("src/generated/editor-row-refs.ts", generateEditorRowRefsTs());
|
|
7633
|
+
files.set("src/generated/editor-storage-refs.ts", generateEditorStorageRefsTs());
|
|
7634
|
+
files.set("src/generated/query.ts", emitQueryTs(READ_API_BANNER));
|
|
7635
|
+
files.set("src/generated/storage-helpers.ts", generateStorageHelpersTs());
|
|
7636
|
+
files.set(
|
|
7637
|
+
"src/generated/read-api-meta.ts",
|
|
7638
|
+
generateReadApiMetaTs(input.profileSlug, input.apiVersion, input.manifestHash)
|
|
7639
|
+
);
|
|
7640
|
+
files.set("src/generated/hooks.ts", generateHooksTs(readableTables, DEFAULT_LIST_PAGE_SIZE));
|
|
7641
|
+
files.set("src/generated/proposal-hooks.ts", generateProposalHooksTs(manifest.tables, accesses));
|
|
7642
|
+
files.set(
|
|
7643
|
+
"src/generated/read-api-meta.json",
|
|
7644
|
+
`${JSON.stringify(
|
|
7645
|
+
{
|
|
7646
|
+
convexUrl: input.convexUrl,
|
|
7647
|
+
profileSlug: input.profileSlug,
|
|
7648
|
+
apiVersion: input.apiVersion,
|
|
7649
|
+
manifestHash: input.manifestHash,
|
|
7650
|
+
tables: tableNames,
|
|
7651
|
+
tableAccess: accesses
|
|
7652
|
+
},
|
|
7653
|
+
null,
|
|
7654
|
+
2
|
|
7655
|
+
)}
|
|
7656
|
+
`
|
|
7657
|
+
);
|
|
7658
|
+
files.set(".env.example", generateEnvExample(input.convexUrl));
|
|
7659
|
+
return files;
|
|
7660
|
+
}
|
|
7661
|
+
function generateProposalApiRefsTs(profileSlug, tables, accesses) {
|
|
7662
|
+
const byName = new Map(tables.map((table) => [table.name, table]));
|
|
7663
|
+
const refs = [];
|
|
7664
|
+
for (const access2 of accesses) {
|
|
7665
|
+
const table = byName.get(access2.table);
|
|
7666
|
+
if (!table || !access2.propose) continue;
|
|
7667
|
+
const segment = profileSlug.replace(/-/g, "_");
|
|
7668
|
+
const doc = docTypeName(table.name);
|
|
7669
|
+
if (access2.propose.ops.insert)
|
|
7670
|
+
refs.push(
|
|
7671
|
+
`export const proposeInsert${table.name}Ref = anyApi.columnus.propose.${segment}.${proposeApiExportName("insert", table.name)}.${proposeApiExportName("insert", table.name)} as FunctionReference<"mutation", "public", { apiToken: string; doc: Omit<${doc}, "_id" | "_creationTime"> }, ProposalResult>;`
|
|
7672
|
+
);
|
|
7673
|
+
if (access2.propose.ops.update)
|
|
7674
|
+
refs.push(
|
|
7675
|
+
`export const proposeUpdate${table.name}Ref = anyApi.columnus.propose.${segment}.${proposeApiExportName("update", table.name)}.${proposeApiExportName("update", table.name)} as FunctionReference<"mutation", "public", { apiToken: string; id: string; patch: Partial<Omit<${doc}, "_id" | "_creationTime">> }, ProposalResult>;`
|
|
7676
|
+
);
|
|
7677
|
+
if (access2.propose.ops.delete)
|
|
7678
|
+
refs.push(
|
|
7679
|
+
`export const proposeDelete${table.name}Ref = anyApi.columnus.propose.${segment}.${proposeApiExportName("delete", table.name)}.${proposeApiExportName("delete", table.name)} as FunctionReference<"mutation", "public", { apiToken: string; id: string }, ProposalResult>;`
|
|
7680
|
+
);
|
|
7460
7681
|
}
|
|
7461
|
-
};
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7682
|
+
return `${READ_API_BANNER}import { anyApi } from "convex/server";
|
|
7683
|
+
import type { FunctionReference } from "convex/server";
|
|
7684
|
+
import type { ${tables.map((table) => docTypeName(table.name)).join(", ")} } from "./documents.js";
|
|
7685
|
+
|
|
7686
|
+
export type ProposalResult = { proposalId: string; status: "active" | "accepted" };
|
|
7687
|
+
|
|
7688
|
+
${refs.join("\n\n")}
|
|
7689
|
+
`;
|
|
7690
|
+
}
|
|
7691
|
+
function generateProposalHooksTs(tables, accesses) {
|
|
7692
|
+
const byName = new Map(tables.map((table) => [table.name, table]));
|
|
7693
|
+
const imports = [];
|
|
7694
|
+
const hooks = [];
|
|
7695
|
+
for (const access2 of accesses) {
|
|
7696
|
+
const table = byName.get(access2.table);
|
|
7697
|
+
if (!table || !access2.propose) continue;
|
|
7698
|
+
const doc = docTypeName(table.name);
|
|
7699
|
+
for (const op of ["insert", "update", "delete"]) {
|
|
7700
|
+
if (!access2.propose.ops[op]) continue;
|
|
7701
|
+
const pascal = `${op[0].toUpperCase()}${op.slice(1)}`;
|
|
7702
|
+
imports.push(`propose${pascal}${table.name}Ref`);
|
|
7703
|
+
const args = op === "insert" ? `doc: Omit<${doc}, "_id" | "_creationTime">` : op === "update" ? `id: string, patch: Partial<Omit<${doc}, "_id" | "_creationTime">>` : "id: string";
|
|
7704
|
+
const call = op === "insert" ? "{ apiToken: readApiToken(), doc }" : op === "update" ? "{ apiToken: readApiToken(), id, patch }" : "{ apiToken: readApiToken(), id }";
|
|
7705
|
+
hooks.push(
|
|
7706
|
+
`export function usePropose${pascal}${table.name}() { const mutate = useMutation(propose${pascal}${table.name}Ref); return (${args}) => mutate(${call}); }`
|
|
7707
|
+
);
|
|
7475
7708
|
}
|
|
7476
|
-
return this._def.innerType._parse({
|
|
7477
|
-
data,
|
|
7478
|
-
path: ctx.path,
|
|
7479
|
-
parent: ctx
|
|
7480
|
-
});
|
|
7481
|
-
}
|
|
7482
|
-
removeDefault() {
|
|
7483
|
-
return this._def.innerType;
|
|
7484
7709
|
}
|
|
7710
|
+
return `${READ_API_BANNER}import { useMutation } from "convex/react";
|
|
7711
|
+
import type { ${tables.map((table) => docTypeName(table.name)).join(", ")} } from "./documents.js";
|
|
7712
|
+
import { ${imports.join(", ")} } from "./proposal-api-refs.js";
|
|
7713
|
+
import { readApiToken } from "./read-api-token.js";
|
|
7714
|
+
|
|
7715
|
+
${hooks.join("\n\n")}
|
|
7716
|
+
`;
|
|
7717
|
+
}
|
|
7718
|
+
function generateProfileProposalRefsTs(tables, accesses) {
|
|
7719
|
+
const byName = new Map(tables.map((table) => [table.name, table]));
|
|
7720
|
+
const arms = [];
|
|
7721
|
+
const docsUsed = /* @__PURE__ */ new Set();
|
|
7722
|
+
for (const access2 of accesses) {
|
|
7723
|
+
const table = byName.get(access2.table);
|
|
7724
|
+
if (!table || !editorAccessEnabled(access2)) continue;
|
|
7725
|
+
const doc = docTypeName(table.name);
|
|
7726
|
+
docsUsed.add(doc);
|
|
7727
|
+
const base = `Omit<${doc}, "_id" | "_creationTime">`;
|
|
7728
|
+
const name = JSON.stringify(table.name);
|
|
7729
|
+
arms.push(`| { table: ${name}; op: "insert"; rowId?: \`new:\${string}\`; fields: ${base} }`);
|
|
7730
|
+
arms.push(`| { table: ${name}; op: "update"; rowId: string; fields: Partial<${base}> }`);
|
|
7731
|
+
arms.push(`| { table: ${name}; op: "delete"; rowId: string; fields: Record<string, never> }`);
|
|
7732
|
+
}
|
|
7733
|
+
const union = arms.length ? `
|
|
7734
|
+
${arms.join("\n ")};` : " never;";
|
|
7735
|
+
const docImport = docsUsed.size ? `import type { ${[...docsUsed].sort().join(", ")} } from "./documents.js";
|
|
7736
|
+
` : "";
|
|
7737
|
+
return `${READ_API_BANNER}// Editor-session proposal API (plan 051 PR 10f): authenticate with the editor's
|
|
7738
|
+
// Convex JWT (see @columnus/cms/server getConvexToken) from server code \u2014
|
|
7739
|
+
// the public col_ token cannot call these. Patch tables require editorAccess;
|
|
7740
|
+
// token propose ops / allowedFields do not apply.
|
|
7741
|
+
import { anyApi } from "convex/server";
|
|
7742
|
+
import type { FunctionReference } from "convex/server";
|
|
7743
|
+
${docImport}
|
|
7744
|
+
export type ProfileProposalPatch =${union}
|
|
7745
|
+
|
|
7746
|
+
export type ProfileProposalPatchSummary = {
|
|
7747
|
+
id: string;
|
|
7748
|
+
table: string;
|
|
7749
|
+
rowId: string;
|
|
7750
|
+
op: "insert" | "update" | "delete";
|
|
7751
|
+
fields: Record<string, unknown>;
|
|
7752
|
+
/** Live values of the touched fields at propose time; accept blocks when they drift. */
|
|
7753
|
+
baseFields?: Record<string, unknown> | null;
|
|
7754
|
+
/** Current live values, resolved at list time for overlay display. */
|
|
7755
|
+
baseline?: Record<string, unknown> | null;
|
|
7756
|
+
seq: number;
|
|
7485
7757
|
};
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
const { ctx } = this._processInputParams(input);
|
|
7497
|
-
const newCtx = {
|
|
7498
|
-
...ctx,
|
|
7499
|
-
common: {
|
|
7500
|
-
...ctx.common,
|
|
7501
|
-
issues: []
|
|
7502
|
-
}
|
|
7503
|
-
};
|
|
7504
|
-
const result = this._def.innerType._parse({
|
|
7505
|
-
data: newCtx.data,
|
|
7506
|
-
path: newCtx.path,
|
|
7507
|
-
parent: {
|
|
7508
|
-
...newCtx
|
|
7509
|
-
}
|
|
7510
|
-
});
|
|
7511
|
-
if (isAsync(result)) {
|
|
7512
|
-
return result.then((result2) => {
|
|
7513
|
-
return {
|
|
7514
|
-
status: "valid",
|
|
7515
|
-
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
|
7516
|
-
get error() {
|
|
7517
|
-
return new ZodError(newCtx.common.issues);
|
|
7518
|
-
},
|
|
7519
|
-
input: newCtx.data
|
|
7520
|
-
})
|
|
7521
|
-
};
|
|
7522
|
-
});
|
|
7523
|
-
} else {
|
|
7524
|
-
return {
|
|
7525
|
-
status: "valid",
|
|
7526
|
-
value: result.status === "valid" ? result.value : this._def.catchValue({
|
|
7527
|
-
get error() {
|
|
7528
|
-
return new ZodError(newCtx.common.issues);
|
|
7529
|
-
},
|
|
7530
|
-
input: newCtx.data
|
|
7531
|
-
})
|
|
7532
|
-
};
|
|
7533
|
-
}
|
|
7534
|
-
}
|
|
7535
|
-
removeCatch() {
|
|
7536
|
-
return this._def.innerType;
|
|
7537
|
-
}
|
|
7758
|
+
|
|
7759
|
+
export type ProfileProposalSummary = {
|
|
7760
|
+
id: string;
|
|
7761
|
+
source: "share" | "api" | "editor";
|
|
7762
|
+
status: "active" | "accepted" | "rejected" | "superseded" | "withdrawn";
|
|
7763
|
+
apiProfileId?: string;
|
|
7764
|
+
createdByUserId?: string;
|
|
7765
|
+
baselineManifestHash: string;
|
|
7766
|
+
createdAt: number;
|
|
7767
|
+
patches: ProfileProposalPatchSummary[];
|
|
7538
7768
|
};
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
...processCreateParams(params)
|
|
7545
|
-
});
|
|
7769
|
+
|
|
7770
|
+
export type ProfileProposalOutcome = {
|
|
7771
|
+
id: string;
|
|
7772
|
+
outcome: "accepted" | "rejected" | "skipped_stale" | "skipped_overlap";
|
|
7773
|
+
message?: string;
|
|
7546
7774
|
};
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7775
|
+
|
|
7776
|
+
export const proposeProfileBatchRef = anyApi.columnus.share.proposeProfileBatch as FunctionReference<"mutation", "public", { profileSlug: string; patches: ProfileProposalPatch[] }, { proposalId: string; status: "active" }>;
|
|
7777
|
+
|
|
7778
|
+
export const listProfileProposalsRef = anyApi.columnus.share.listProfileProposals as FunctionReference<"query", "public", { profileSlug: string }, ProfileProposalSummary[]>;
|
|
7779
|
+
|
|
7780
|
+
export const publishMyProfileProposalRef = anyApi.columnus.share.publishMyProfileProposal as FunctionReference<"mutation", "public", { profileSlug: string }, ProfileProposalOutcome[]>;
|
|
7781
|
+
|
|
7782
|
+
export const withdrawMyProfileProposalRef = anyApi.columnus.share.withdrawMyProfileProposal as FunctionReference<"mutation", "public", { profileSlug: string }, { id: string; status: "withdrawn" }>;
|
|
7783
|
+
`;
|
|
7784
|
+
}
|
|
7785
|
+
function generateEditorRowRefsTs() {
|
|
7786
|
+
return `${READ_API_BANNER}// Editor-session row reads (plan 051 X9): authenticate with the
|
|
7787
|
+
// editor Convex JWT (useCmsEditorAuth / getConvexToken) \u2014 the public col_ token
|
|
7788
|
+
// cannot call these. Prefer these refs for CMS editor lists / get-by-id;
|
|
7789
|
+
// anonymous site rendering keeps columnus/read/<profile>.* .
|
|
7790
|
+
import { anyApi } from "convex/server";
|
|
7791
|
+
import type { FunctionReference, PaginationOptions } from "convex/server";
|
|
7792
|
+
import type { ListResult, Query } from "./query.js";
|
|
7793
|
+
|
|
7794
|
+
export const listRowsRef = anyApi.columnus.rows.listRows as FunctionReference<
|
|
7795
|
+
"query",
|
|
7796
|
+
"public",
|
|
7797
|
+
{ table: string; paginationOpts: PaginationOptions; query?: Query },
|
|
7798
|
+
ListResult<Record<string, unknown>>
|
|
7799
|
+
>;
|
|
7800
|
+
|
|
7801
|
+
export const getRowRef = anyApi.columnus.rows.getRow as FunctionReference<
|
|
7802
|
+
"query",
|
|
7803
|
+
"public",
|
|
7804
|
+
{ table: string; id: string },
|
|
7805
|
+
Record<string, unknown> | null
|
|
7806
|
+
>;
|
|
7807
|
+
|
|
7808
|
+
export const getRowsByIdsRef = anyApi.columnus.rows.getRowsByIds as FunctionReference<
|
|
7809
|
+
"query",
|
|
7810
|
+
"public",
|
|
7811
|
+
{ ids: string[] },
|
|
7812
|
+
Record<string, Record<string, unknown>>
|
|
7813
|
+
>;
|
|
7814
|
+
`;
|
|
7815
|
+
}
|
|
7816
|
+
function generateEditorStorageRefsTs() {
|
|
7817
|
+
return `${READ_API_BANNER}// Editor-session storage (plan 051 PR 10d): authenticate with the
|
|
7818
|
+
// editor Convex JWT (useCmsEditorAuth / getConvexToken) \u2014 the public col_ token
|
|
7819
|
+
// cannot call these. Prefer these refs for CMS stamp upload + draft media preview;
|
|
7820
|
+
// anonymous site rendering keeps columnus/read/storage.* .
|
|
7821
|
+
import { anyApi } from "convex/server";
|
|
7822
|
+
import type { FunctionReference } from "convex/server";
|
|
7823
|
+
|
|
7824
|
+
export const generateUploadUrlRef = anyApi.columnus.storage.generateUploadUrl as FunctionReference<
|
|
7825
|
+
"mutation",
|
|
7826
|
+
"public",
|
|
7827
|
+
Record<string, never>,
|
|
7828
|
+
string
|
|
7829
|
+
>;
|
|
7830
|
+
|
|
7831
|
+
export const getStorageUrlsRef = anyApi.columnus.storage.getStorageUrls as FunctionReference<
|
|
7832
|
+
"query",
|
|
7833
|
+
"public",
|
|
7834
|
+
{ fileIds: string[] },
|
|
7835
|
+
Array<{ fileId: string; url: string | null }>
|
|
7836
|
+
>;
|
|
7837
|
+
|
|
7838
|
+
export const getStorageMetadataRef = anyApi.columnus.storage.getStorageMetadata as FunctionReference<
|
|
7839
|
+
"query",
|
|
7840
|
+
"public",
|
|
7841
|
+
{ fileIds: string[] },
|
|
7842
|
+
Array<{ fileId: string; contentType?: string; size: number }>
|
|
7843
|
+
>;
|
|
7844
|
+
`;
|
|
7845
|
+
}
|
|
7846
|
+
function generateManifestTypesTs() {
|
|
7847
|
+
return `${READ_API_BANNER}/** Manifest field/index shapes for pulled consumer apps (no @columnus/shared). */
|
|
7848
|
+
export type ManifestIndex = { name: string; fields: string[] };
|
|
7849
|
+
|
|
7850
|
+
export type ManifestFieldType =
|
|
7851
|
+
| { kind: "string" }
|
|
7852
|
+
| { kind: "number" }
|
|
7853
|
+
| { kind: "boolean" }
|
|
7854
|
+
| { kind: "file" }
|
|
7855
|
+
| { kind: "id"; table: string }
|
|
7856
|
+
| { kind: "array"; element: ManifestFieldType }
|
|
7857
|
+
| { kind: "object"; fields: Record<string, ManifestFieldType> };
|
|
7858
|
+
|
|
7859
|
+
export type ManifestField = {
|
|
7860
|
+
name: string;
|
|
7861
|
+
type: ManifestFieldType;
|
|
7862
|
+
optional: boolean;
|
|
7561
7863
|
};
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7864
|
+
|
|
7865
|
+
export type ManifestTable = {
|
|
7866
|
+
name: string;
|
|
7867
|
+
fields: ManifestField[];
|
|
7868
|
+
indexes: ManifestIndex[];
|
|
7869
|
+
searchIndexes: unknown[];
|
|
7567
7870
|
};
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7871
|
+
|
|
7872
|
+
export type PulledManifest = { tables: ManifestTable[] };
|
|
7873
|
+
`;
|
|
7874
|
+
}
|
|
7875
|
+
function generateStorageHelpersTs() {
|
|
7876
|
+
return `${READ_API_BANNER}import type { ManifestField, ManifestFieldType } from "./manifest-types.js";
|
|
7877
|
+
import type { DocByTable, TableName } from "./documents.js";
|
|
7878
|
+
|
|
7879
|
+
export function toDocumentId(value: unknown): string | undefined {
|
|
7880
|
+
if (value === undefined || value === null || value === "") return undefined;
|
|
7881
|
+
return typeof value === "string" ? value : String(value);
|
|
7882
|
+
}
|
|
7883
|
+
|
|
7884
|
+
function isFileFieldType(type: ManifestFieldType): boolean {
|
|
7885
|
+
return type.kind === "file";
|
|
7886
|
+
}
|
|
7887
|
+
|
|
7888
|
+
function isFileArrayFieldType(type: ManifestFieldType): boolean {
|
|
7889
|
+
return type.kind === "array" && type.element.kind === "file";
|
|
7890
|
+
}
|
|
7891
|
+
|
|
7892
|
+
function isStorageFieldType(type: ManifestFieldType): boolean {
|
|
7893
|
+
return isFileFieldType(type) || isFileArrayFieldType(type);
|
|
7894
|
+
}
|
|
7895
|
+
|
|
7896
|
+
export function collectStorageIds(
|
|
7897
|
+
value: unknown,
|
|
7898
|
+
type: ManifestFieldType,
|
|
7899
|
+
out: Set<string> = new Set(),
|
|
7900
|
+
): Set<string> {
|
|
7901
|
+
if (isFileFieldType(type)) {
|
|
7902
|
+
const id = toDocumentId(value);
|
|
7903
|
+
if (id) out.add(id);
|
|
7904
|
+
return out;
|
|
7581
7905
|
}
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
if (ctx.common.async) {
|
|
7587
|
-
const handleAsync = async () => {
|
|
7588
|
-
const inResult = await this._def.in._parseAsync({
|
|
7589
|
-
data: ctx.data,
|
|
7590
|
-
path: ctx.path,
|
|
7591
|
-
parent: ctx
|
|
7592
|
-
});
|
|
7593
|
-
if (inResult.status === "aborted")
|
|
7594
|
-
return INVALID;
|
|
7595
|
-
if (inResult.status === "dirty") {
|
|
7596
|
-
status.dirty();
|
|
7597
|
-
return DIRTY(inResult.value);
|
|
7598
|
-
} else {
|
|
7599
|
-
return this._def.out._parseAsync({
|
|
7600
|
-
data: inResult.value,
|
|
7601
|
-
path: ctx.path,
|
|
7602
|
-
parent: ctx
|
|
7603
|
-
});
|
|
7604
|
-
}
|
|
7605
|
-
};
|
|
7606
|
-
return handleAsync();
|
|
7607
|
-
} else {
|
|
7608
|
-
const inResult = this._def.in._parseSync({
|
|
7609
|
-
data: ctx.data,
|
|
7610
|
-
path: ctx.path,
|
|
7611
|
-
parent: ctx
|
|
7612
|
-
});
|
|
7613
|
-
if (inResult.status === "aborted")
|
|
7614
|
-
return INVALID;
|
|
7615
|
-
if (inResult.status === "dirty") {
|
|
7616
|
-
status.dirty();
|
|
7617
|
-
return {
|
|
7618
|
-
status: "dirty",
|
|
7619
|
-
value: inResult.value
|
|
7620
|
-
};
|
|
7621
|
-
} else {
|
|
7622
|
-
return this._def.out._parseSync({
|
|
7623
|
-
data: inResult.value,
|
|
7624
|
-
path: ctx.path,
|
|
7625
|
-
parent: ctx
|
|
7626
|
-
});
|
|
7627
|
-
}
|
|
7906
|
+
if (isFileArrayFieldType(type) && Array.isArray(value)) {
|
|
7907
|
+
for (const item of value) {
|
|
7908
|
+
const id = toDocumentId(item);
|
|
7909
|
+
if (id) out.add(id);
|
|
7628
7910
|
}
|
|
7629
7911
|
}
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
data.value = Object.freeze(data.value);
|
|
7644
|
-
}
|
|
7645
|
-
return data;
|
|
7646
|
-
};
|
|
7647
|
-
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
7912
|
+
return out;
|
|
7913
|
+
}
|
|
7914
|
+
|
|
7915
|
+
export function collectStorageIdsFromRow<T extends TableName>(
|
|
7916
|
+
row: DocByTable[T] | undefined,
|
|
7917
|
+
fields: readonly ManifestField[],
|
|
7918
|
+
out: Set<string> = new Set(),
|
|
7919
|
+
): Set<string> {
|
|
7920
|
+
if (!row) return out;
|
|
7921
|
+
const values = row as Record<string, unknown>;
|
|
7922
|
+
for (const field of fields) {
|
|
7923
|
+
if (!isStorageFieldType(field.type)) continue;
|
|
7924
|
+
collectStorageIds(values[field.name], field.type, out);
|
|
7648
7925
|
}
|
|
7649
|
-
|
|
7650
|
-
|
|
7926
|
+
return out;
|
|
7927
|
+
}
|
|
7928
|
+
`;
|
|
7929
|
+
}
|
|
7930
|
+
function generateReadApiMetaTs(profileSlug, apiVersion, manifestHash) {
|
|
7931
|
+
return `${READ_API_BANNER}/** Compile-time snapshot from the last \`columnus-api pull\`. */
|
|
7932
|
+
export const PULLED_PROFILE_SLUG = ${JSON.stringify(profileSlug)} as const;
|
|
7933
|
+
export const PULLED_API_VERSION = ${apiVersion} as const;
|
|
7934
|
+
export const PULLED_MANIFEST_HASH = ${JSON.stringify(manifestHash)} as const;
|
|
7935
|
+
`;
|
|
7936
|
+
}
|
|
7937
|
+
function generateReadApiTokenTs() {
|
|
7938
|
+
return `${READ_API_BANNER}export function readApiToken(): string {
|
|
7939
|
+
const token = import.meta.env.VITE_COLUMNUS_API_TOKEN;
|
|
7940
|
+
if (!token || typeof token !== "string") {
|
|
7941
|
+
throw new Error("VITE_COLUMNUS_API_TOKEN is required");
|
|
7651
7942
|
}
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
}
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7943
|
+
return token;
|
|
7944
|
+
}
|
|
7945
|
+
`;
|
|
7946
|
+
}
|
|
7947
|
+
function generateHooksTs(tables, pageSize) {
|
|
7948
|
+
const sorted = [...tables].sort((a, b) => a.name.localeCompare(b.name));
|
|
7949
|
+
const listHooks = sorted.map((table) => {
|
|
7950
|
+
const hookName = `use${table.name}List`;
|
|
7951
|
+
const ref = `list${table.name}Ref`;
|
|
7952
|
+
return `
|
|
7953
|
+
export function ${hookName}(query?: Query | null) {
|
|
7954
|
+
const apiToken = readApiToken();
|
|
7955
|
+
return usePaginatedQuery(
|
|
7956
|
+
${ref},
|
|
7957
|
+
query ? { apiToken, query } : { apiToken },
|
|
7958
|
+
{ initialNumItems: ${pageSize} },
|
|
7959
|
+
);
|
|
7960
|
+
}`;
|
|
7961
|
+
}).join("\n");
|
|
7962
|
+
const getHooks = sorted.map((table) => {
|
|
7963
|
+
const hookName = `use${table.name}ById`;
|
|
7964
|
+
const doc = docTypeName(table.name);
|
|
7965
|
+
const ref = `get${table.name}Ref`;
|
|
7966
|
+
return `
|
|
7967
|
+
export function ${hookName}(id: ${doc}["_id"] | undefined) {
|
|
7968
|
+
const apiToken = readApiToken();
|
|
7969
|
+
return useQuery(${ref}, id ? { apiToken, id } : "skip");
|
|
7970
|
+
}`;
|
|
7971
|
+
}).join("\n");
|
|
7972
|
+
const docImports = sorted.map((t) => ` ${docTypeName(t.name)},`).join("\n");
|
|
7973
|
+
const refImports = sorted.flatMap((t) => [` list${t.name}Ref,`, ` get${t.name}Ref,`]).join("\n");
|
|
7974
|
+
return `${READ_API_BANNER}import { usePaginatedQuery, useQuery } from "convex/react";
|
|
7975
|
+
import { anyApi } from "convex/server";
|
|
7976
|
+
import type { Query } from "./query.js";
|
|
7977
|
+
import type {
|
|
7978
|
+
${docImports}
|
|
7979
|
+
} from "./documents.js";
|
|
7980
|
+
import {
|
|
7981
|
+
${refImports}
|
|
7982
|
+
} from "./read-api-refs.js";
|
|
7983
|
+
import { readApiToken } from "./read-api-token.js";
|
|
7984
|
+
${listHooks}
|
|
7985
|
+
|
|
7986
|
+
${getHooks}
|
|
7987
|
+
|
|
7988
|
+
export function useStorageUrls(fileIds: string[]) {
|
|
7989
|
+
const apiToken = readApiToken();
|
|
7990
|
+
const ids = fileIds.filter(Boolean);
|
|
7991
|
+
const results = useQuery(
|
|
7992
|
+
anyApi.columnus.read.storage.getStorageUrls,
|
|
7993
|
+
ids.length > 0 ? { apiToken, fileIds: ids } : "skip",
|
|
7994
|
+
);
|
|
7995
|
+
return results ?? [];
|
|
7664
7996
|
}
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
}
|
|
7683
|
-
return;
|
|
7684
|
-
});
|
|
7685
|
-
return ZodAny.create();
|
|
7997
|
+
|
|
7998
|
+
export function useStorageMetadata(fileIds: string[]) {
|
|
7999
|
+
const apiToken = readApiToken();
|
|
8000
|
+
const ids = fileIds.filter(Boolean);
|
|
8001
|
+
const results = useQuery(
|
|
8002
|
+
anyApi.columnus.read.storage.getStorageMetadata,
|
|
8003
|
+
ids.length > 0 ? { apiToken, fileIds: ids } : "skip",
|
|
8004
|
+
);
|
|
8005
|
+
return results ?? [];
|
|
8006
|
+
}
|
|
8007
|
+
`;
|
|
8008
|
+
}
|
|
8009
|
+
function generateEnvExample(convexUrl) {
|
|
8010
|
+
return `# Copy to .env.local and fill in your read API token from Columnus /api.
|
|
8011
|
+
VITE_CONVEX_URL=${convexUrl}
|
|
8012
|
+
VITE_COLUMNUS_API_TOKEN=col_your_token_here
|
|
8013
|
+
`;
|
|
7686
8014
|
}
|
|
7687
|
-
var late = {
|
|
7688
|
-
object: ZodObject.lazycreate
|
|
7689
|
-
};
|
|
7690
|
-
var ZodFirstPartyTypeKind;
|
|
7691
|
-
(function(ZodFirstPartyTypeKind2) {
|
|
7692
|
-
ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
|
|
7693
|
-
ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
|
|
7694
|
-
ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
|
|
7695
|
-
ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
|
|
7696
|
-
ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
|
|
7697
|
-
ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
|
|
7698
|
-
ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
|
|
7699
|
-
ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
|
|
7700
|
-
ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
|
|
7701
|
-
ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
|
|
7702
|
-
ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
|
|
7703
|
-
ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
|
|
7704
|
-
ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
|
|
7705
|
-
ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
|
|
7706
|
-
ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
|
|
7707
|
-
ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
|
|
7708
|
-
ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
7709
|
-
ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
|
|
7710
|
-
ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
|
|
7711
|
-
ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
|
|
7712
|
-
ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
|
|
7713
|
-
ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
|
|
7714
|
-
ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
|
|
7715
|
-
ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
|
|
7716
|
-
ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
|
|
7717
|
-
ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
|
|
7718
|
-
ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
|
|
7719
|
-
ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
|
|
7720
|
-
ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
|
|
7721
|
-
ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
|
|
7722
|
-
ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
|
|
7723
|
-
ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
|
|
7724
|
-
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
|
7725
|
-
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
|
7726
|
-
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
7727
|
-
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
7728
|
-
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
7729
|
-
var instanceOfType = (cls, params = {
|
|
7730
|
-
message: `Input not instance of ${cls.name}`
|
|
7731
|
-
}) => custom((data) => data instanceof cls, params);
|
|
7732
|
-
var stringType = ZodString.create;
|
|
7733
|
-
var numberType = ZodNumber.create;
|
|
7734
|
-
var nanType = ZodNaN.create;
|
|
7735
|
-
var bigIntType = ZodBigInt.create;
|
|
7736
|
-
var booleanType = ZodBoolean.create;
|
|
7737
|
-
var dateType = ZodDate.create;
|
|
7738
|
-
var symbolType = ZodSymbol.create;
|
|
7739
|
-
var undefinedType = ZodUndefined.create;
|
|
7740
|
-
var nullType = ZodNull.create;
|
|
7741
|
-
var anyType = ZodAny.create;
|
|
7742
|
-
var unknownType = ZodUnknown.create;
|
|
7743
|
-
var neverType = ZodNever.create;
|
|
7744
|
-
var voidType = ZodVoid.create;
|
|
7745
|
-
var arrayType = ZodArray.create;
|
|
7746
|
-
var objectType = ZodObject.create;
|
|
7747
|
-
var strictObjectType = ZodObject.strictCreate;
|
|
7748
|
-
var unionType = ZodUnion.create;
|
|
7749
|
-
var discriminatedUnionType = ZodDiscriminatedUnion.create;
|
|
7750
|
-
var intersectionType = ZodIntersection.create;
|
|
7751
|
-
var tupleType = ZodTuple.create;
|
|
7752
|
-
var recordType = ZodRecord.create;
|
|
7753
|
-
var mapType = ZodMap.create;
|
|
7754
|
-
var setType = ZodSet.create;
|
|
7755
|
-
var functionType = ZodFunction.create;
|
|
7756
|
-
var lazyType = ZodLazy.create;
|
|
7757
|
-
var literalType = ZodLiteral.create;
|
|
7758
|
-
var enumType = ZodEnum.create;
|
|
7759
|
-
var nativeEnumType = ZodNativeEnum.create;
|
|
7760
|
-
var promiseType = ZodPromise.create;
|
|
7761
|
-
var effectsType = ZodEffects.create;
|
|
7762
|
-
var optionalType = ZodOptional.create;
|
|
7763
|
-
var nullableType = ZodNullable.create;
|
|
7764
|
-
var preprocessType = ZodEffects.createWithPreprocess;
|
|
7765
|
-
var pipelineType = ZodPipeline.create;
|
|
7766
|
-
var ostring = () => stringType().optional();
|
|
7767
|
-
var onumber = () => numberType().optional();
|
|
7768
|
-
var oboolean = () => booleanType().optional();
|
|
7769
|
-
var coerce = {
|
|
7770
|
-
string: ((arg) => ZodString.create({ ...arg, coerce: true })),
|
|
7771
|
-
number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
|
|
7772
|
-
boolean: ((arg) => ZodBoolean.create({
|
|
7773
|
-
...arg,
|
|
7774
|
-
coerce: true
|
|
7775
|
-
})),
|
|
7776
|
-
bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
|
|
7777
|
-
date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
|
|
7778
|
-
};
|
|
7779
|
-
var NEVER = INVALID;
|
|
7780
8015
|
|
|
7781
|
-
// ../shared/src/
|
|
7782
|
-
var
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
var betweenValueSchema = external_exports.object({
|
|
7791
|
-
min: external_exports.unknown(),
|
|
7792
|
-
max: external_exports.unknown()
|
|
7793
|
-
}).refine(
|
|
7794
|
-
(value) => Object.hasOwn(value, "min") && Object.hasOwn(value, "max"),
|
|
7795
|
-
"Between requires min and max"
|
|
7796
|
-
);
|
|
7797
|
-
var predicateSchemas = PREDICATE_VARIANTS.flatMap(
|
|
7798
|
-
(variant) => variant.ops.map(
|
|
7799
|
-
({ op }) => external_exports.object({
|
|
7800
|
-
field: external_exports.string().min(1),
|
|
7801
|
-
op: external_exports.literal(op),
|
|
7802
|
-
value: variant.value === "unknownArray" ? external_exports.array(external_exports.unknown()) : variant.value === "between" ? betweenValueSchema : external_exports.unknown()
|
|
7803
|
-
})
|
|
7804
|
-
)
|
|
7805
|
-
);
|
|
7806
|
-
var predicateSchema = external_exports.discriminatedUnion(
|
|
7807
|
-
"op",
|
|
7808
|
-
predicateSchemas
|
|
7809
|
-
).refine(
|
|
7810
|
-
(predicate) => Object.hasOwn(predicate, "value"),
|
|
7811
|
-
"Predicate value is required"
|
|
7812
|
-
);
|
|
7813
|
-
var queryOrderSchema = external_exports.object({
|
|
7814
|
-
field: external_exports.string().min(1),
|
|
7815
|
-
direction: external_exports.enum(["asc", "desc"])
|
|
7816
|
-
});
|
|
7817
|
-
var querySearchSchema = external_exports.object({
|
|
7818
|
-
index: external_exports.string().min(1),
|
|
7819
|
-
query: external_exports.string()
|
|
7820
|
-
});
|
|
7821
|
-
var querySchema = external_exports.object({
|
|
7822
|
-
predicates: external_exports.array(predicateSchema).optional(),
|
|
7823
|
-
order: queryOrderSchema.optional(),
|
|
7824
|
-
search: querySearchSchema.optional(),
|
|
7825
|
-
/** Reserved — rejected by the planner until vector indexes exist in the manifest. */
|
|
7826
|
-
vector: external_exports.unknown().optional(),
|
|
7827
|
-
maxScan: external_exports.number().int().positive().optional(),
|
|
7828
|
-
indexHint: external_exports.string().min(1).optional()
|
|
7829
|
-
});
|
|
7830
|
-
var clampQuerySchema = external_exports.object({
|
|
7831
|
-
predicates: external_exports.array(predicateSchema).optional(),
|
|
7832
|
-
order: queryOrderSchema.optional(),
|
|
7833
|
-
search: querySearchSchema.optional()
|
|
7834
|
-
});
|
|
7835
|
-
var listMetaOrderSchema = external_exports.union([
|
|
7836
|
-
queryOrderSchema,
|
|
7837
|
-
external_exports.object({ kind: external_exports.literal("relevance") })
|
|
7838
|
-
]);
|
|
7839
|
-
var listMetaSchema = external_exports.object({
|
|
7840
|
-
access: listAccessKindSchema,
|
|
7841
|
-
page: listPageKindSchema,
|
|
7842
|
-
order: listMetaOrderSchema.optional(),
|
|
7843
|
-
indexName: external_exports.string().optional(),
|
|
7844
|
-
searchIndexName: external_exports.string().optional(),
|
|
7845
|
-
scanned: external_exports.number().int().nonnegative().optional(),
|
|
7846
|
-
truncated: external_exports.boolean().optional()
|
|
7847
|
-
});
|
|
8016
|
+
// ../shared/src/apiToken.ts
|
|
8017
|
+
var TOKEN_BODY_RE = /^col_[A-Za-z0-9_-]{20,}$/;
|
|
8018
|
+
function isApiTokenFormat(token) {
|
|
8019
|
+
return TOKEN_BODY_RE.test(token.trim());
|
|
8020
|
+
}
|
|
8021
|
+
|
|
8022
|
+
// src/pull-codegen.ts
|
|
8023
|
+
import { access, writeFile } from "node:fs/promises";
|
|
8024
|
+
import path2 from "node:path";
|
|
7848
8025
|
|
|
7849
8026
|
// ../shared/src/richDoc.ts
|
|
7850
8027
|
var RICH_DOC_FORMAT = "blocknote";
|
|
@@ -7888,6 +8065,33 @@ var displayTemplatesSchema = external_exports.object({
|
|
|
7888
8065
|
id: external_exports.string().optional(),
|
|
7889
8066
|
preview: external_exports.string().optional()
|
|
7890
8067
|
});
|
|
8068
|
+
var TABLE_COLORS = [
|
|
8069
|
+
"brown",
|
|
8070
|
+
"muted-red",
|
|
8071
|
+
"red",
|
|
8072
|
+
"coral",
|
|
8073
|
+
"orange",
|
|
8074
|
+
"amber",
|
|
8075
|
+
"yellow",
|
|
8076
|
+
"gold",
|
|
8077
|
+
"blue",
|
|
8078
|
+
"light-blue",
|
|
8079
|
+
"cyan",
|
|
8080
|
+
"mint",
|
|
8081
|
+
"green",
|
|
8082
|
+
"dark-green",
|
|
8083
|
+
"lime",
|
|
8084
|
+
"light-green",
|
|
8085
|
+
"charcoal",
|
|
8086
|
+
"gray",
|
|
8087
|
+
"mauve",
|
|
8088
|
+
"pink",
|
|
8089
|
+
"purple",
|
|
8090
|
+
"deep-purple",
|
|
8091
|
+
"periwinkle",
|
|
8092
|
+
"lavender"
|
|
8093
|
+
];
|
|
8094
|
+
var tableColorSchema = external_exports.enum(TABLE_COLORS);
|
|
7891
8095
|
var fieldTypeSchema = external_exports.lazy(
|
|
7892
8096
|
() => external_exports.discriminatedUnion("kind", [
|
|
7893
8097
|
external_exports.object({ kind: external_exports.literal("string") }),
|
|
@@ -7945,6 +8149,7 @@ var tableSchema = external_exports.object({
|
|
|
7945
8149
|
message: "table name is reserved by the studio"
|
|
7946
8150
|
}),
|
|
7947
8151
|
label: external_exports.string().optional(),
|
|
8152
|
+
color: tableColorSchema.optional(),
|
|
7948
8153
|
fields: external_exports.array(fieldSchema),
|
|
7949
8154
|
indexes: external_exports.array(indexSchema).default([]),
|
|
7950
8155
|
searchIndexes: external_exports.array(searchIndexSchema).default([]),
|
|
@@ -8098,38 +8303,6 @@ function deriveConvexDeploymentFromCloudUrl(cloudUrl) {
|
|
|
8098
8303
|
return slug ? `dev:${slug}` : void 0;
|
|
8099
8304
|
}
|
|
8100
8305
|
|
|
8101
|
-
// ../shared/src/apiProfile.ts
|
|
8102
|
-
var apiTableAccessSchema = external_exports.object({
|
|
8103
|
-
table: external_exports.string(),
|
|
8104
|
-
read: external_exports.boolean(),
|
|
8105
|
-
/** Push to enabled webhook outputs. Missing/undefined = false (opt-in). */
|
|
8106
|
-
sync: external_exports.boolean().optional(),
|
|
8107
|
-
propose: external_exports.object({
|
|
8108
|
-
ops: external_exports.object({ insert: external_exports.boolean(), update: external_exports.boolean(), delete: external_exports.boolean() }),
|
|
8109
|
-
allowedFields: external_exports.array(external_exports.string()).optional(),
|
|
8110
|
-
recordIds: external_exports.array(external_exports.string()).optional()
|
|
8111
|
-
}).optional(),
|
|
8112
|
-
autoAccept: external_exports.boolean().optional(),
|
|
8113
|
-
/**
|
|
8114
|
-
* Opaque row clamp: AND-merged with caller Query on Read API / guest lists.
|
|
8115
|
-
* Sync membership uses `rowQuery.predicates` only (order/search ignored; maxScanLimit ignored).
|
|
8116
|
-
*/
|
|
8117
|
-
rowQuery: clampQuerySchema.optional(),
|
|
8118
|
-
/** Scan ceiling for Read/guest list plans; callers may only lower. Not applied to Sync/Resync. */
|
|
8119
|
-
maxScanLimit: external_exports.number().int().positive().optional()
|
|
8120
|
-
});
|
|
8121
|
-
var apiProfileSnapshotSchema = external_exports.object({
|
|
8122
|
-
id: external_exports.string(),
|
|
8123
|
-
name: external_exports.string(),
|
|
8124
|
-
slug: external_exports.string(),
|
|
8125
|
-
tables: external_exports.array(external_exports.string()),
|
|
8126
|
-
tableAccess: external_exports.array(apiTableAccessSchema).optional(),
|
|
8127
|
-
autoAcceptProposals: external_exports.boolean().optional(),
|
|
8128
|
-
apiVersion: external_exports.number(),
|
|
8129
|
-
updatedAt: external_exports.number()
|
|
8130
|
-
});
|
|
8131
|
-
var apiProfilesSchema = external_exports.array(apiProfileSnapshotSchema);
|
|
8132
|
-
|
|
8133
8306
|
// ../shared/src/refsRecompute.ts
|
|
8134
8307
|
var REFS_RECOMPUTE_STALE_MS = 10 * 60 * 1e3;
|
|
8135
8308
|
|