dodanie typu geoPoint

This commit is contained in:
2025-10-05 19:26:36 +02:00
parent ec9ef486c4
commit ea672a9d91

View File

@@ -46,6 +46,8 @@ export function stringifyContent(collections: CollectionModel[], opts: GenerateO
function stringifyField(field: CollectionField, collectionName: string) {
let schema: string;
// TODO:
console.log(`${collectionName}: ${field.type}`);
switch (field.type) {
case "bool":
schema = stringifyBoolField(field);
@@ -80,6 +82,9 @@ export function stringifyContent(collections: CollectionModel[], opts: GenerateO
case "url":
schema = stringifyUrlField(field);
break;
case "geoPoint":
schema = stringifyGeoPointField(field);
break;
default:
console.warn(`Unknown field type "${field.type}" for field "${field.name}". Using z.any() as fallback.`);
schema = "z.any()";
@@ -154,6 +159,10 @@ export function stringifyContent(collections: CollectionModel[], opts: GenerateO
return "z.string().url()";
}
function stringifyGeoPointField(_field: CollectionField) {
return "z.object({ lat: z.number().min(-90).max(90), lng: z.number().min(-180).max(180) })";
}
function stringifySchemasEntry({ name }: CollectionModel) {
return `["${name}", ${opts.nameRecordSchema(name)}]`;
}