feat: scaffold supabase multi-tenant backend

This commit is contained in:
Codex
2026-06-21 21:54:43 +08:00
commit c9c767c7bd
99 changed files with 36660 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import { readPocketBaseSchema, fieldsOf } from './pb-schema.js';
const { absPath, collections, byId } = readPocketBaseSchema();
const businessCollections = collections.filter(c => !c.name.startsWith('_'));
const authCollections = collections.filter(c => c.type === 'auth');
const relationCount = collections.reduce(
(count, collection) => count + fieldsOf(collection).filter(field => field.type === 'relation').length,
0,
);
console.log(`PocketBase schema: ${absPath}`);
console.log(`Collections: ${collections.length}`);
console.log(`Business collections: ${businessCollections.length}`);
console.log(`Auth collections: ${authCollections.map(c => c.name).join(', ') || 'none'}`);
console.log(`Relation fields: ${relationCount}`);
console.log('');
for (const collection of businessCollections.sort((a, b) => a.name.localeCompare(b.name))) {
const fields = fieldsOf(collection);
const relationFields = fields.filter(field => field.type === 'relation');
const relationSummary = relationFields
.map(field => {
const target = field.collectionId ? byId.get(field.collectionId)?.name || field.collectionId : '?';
return `${field.name}->${target}`;
})
.join(', ');
console.log(`${collection.name.padEnd(24)} ${collection.type.padEnd(6)} fields=${String(fields.length).padStart(2)} relations=${relationSummary || '-'}`);
}