Remove the generic $lib/svelte-admin CRUD layer and AdminTable.svelte; each admin route now owns its own form/modal logic. Add DataTable.svelte, superform-errors.ts, and profile-specific modal/field components. Flatten proclamation categories/groups and drop subscription levels; add the v2 groups API; update v1/v2 endpoints, serializers, auth, and regenerated Prisma client with the new migrations. Document the overhaul plan in docs/ADMIN_OVERHAUL.md.
152 lines
4.2 KiB
TypeScript
152 lines
4.2 KiB
TypeScript
import 'dotenv/config';
|
|
import pg from 'pg';
|
|
import { PrismaPg } from '@prisma/adapter-pg';
|
|
import { PrismaClient } from '../src/lib/generated/prisma/client';
|
|
|
|
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
|
|
const adapter = new PrismaPg(pool);
|
|
const prisma = new PrismaClient({ adapter });
|
|
|
|
const userRoles = [
|
|
{ id: 1, name: 'Super' },
|
|
{ id: 2, name: 'Admin' },
|
|
{ id: 3, name: 'Staff' },
|
|
{ id: 4, name: 'User' }
|
|
];
|
|
|
|
const solfeggioFrequencies = [
|
|
{ id: 1, name: 'Crown', value: 936 },
|
|
{ id: 2, name: '3rd Eye', value: 852 },
|
|
{ id: 3, name: 'Throat', value: 741 },
|
|
{ id: 4, name: 'Heart', value: 639 },
|
|
{ id: 5, name: 'Solar Plexus', value: 528 },
|
|
{ id: 6, name: 'Sacral', value: 417 },
|
|
{ id: 7, name: 'Root', value: 396 },
|
|
// Canonical frequencies missing from the original 7-row set. Kept as
|
|
// separate rows (with distinct unique names) so the canonical id mapping
|
|
// in v2-serializers.ts can resolve 1-9 without renumbering v1 rows.
|
|
{ id: 8, name: 'Grounding / Relief', value: 174 },
|
|
{ id: 9, name: 'Relief', value: 285 },
|
|
{ id: 10, name: 'Clarity / Wellbeing', value: 432 },
|
|
{ id: 11, name: 'Crown 963', value: 963 }
|
|
];
|
|
|
|
// Canonical id -> 7-color palette, matching the kiosk's
|
|
// DatabaseManager::seedColorPalettes() (radiantwave-rebuild).
|
|
const colorPalettes: { solfeggioFrequencyId: number; colors: string[] }[] = [
|
|
{
|
|
solfeggioFrequencyId: 1,
|
|
colors: ['#8B6914', '#B8860B', '#DAA520', '#E8B64C', '#FFD700', '#FFE9A8', '#FFF4CC']
|
|
},
|
|
{
|
|
solfeggioFrequencyId: 2,
|
|
colors: ['#8B0000', '#B22222', '#DC143C', '#FF6347', '#FF8C69', '#FFA500', '#FFDAB9']
|
|
},
|
|
{
|
|
solfeggioFrequencyId: 3,
|
|
colors: ['#FF4500', '#FF7F50', '#FF8C00', '#FFA500', '#FFC87F', '#FFDFBA', '#FFEBCD']
|
|
},
|
|
{
|
|
solfeggioFrequencyId: 4,
|
|
colors: ['#8B2252', '#CD3278', '#DB7093', '#FF69B4', '#FFB6C1', '#FFC0CB', '#FFE4E1']
|
|
},
|
|
{
|
|
solfeggioFrequencyId: 5,
|
|
colors: ['#32CD32', '#3CB371', '#90EE90', '#98FB98', '#ADFFA9', '#C8FFD2', '#F0FFF0']
|
|
},
|
|
{
|
|
solfeggioFrequencyId: 6,
|
|
colors: ['#00FF7F', '#00CED1', '#40E0D0', '#5F9EA0', '#7FFFD4', '#AFEEEE', '#E0FFFF']
|
|
},
|
|
{
|
|
solfeggioFrequencyId: 7,
|
|
colors: ['#00BFFF', '#1E90FF', '#4169E1', '#6495ED', '#87CEEB', '#ADD8E6', '#F0F8FF']
|
|
},
|
|
{
|
|
solfeggioFrequencyId: 8,
|
|
colors: ['#4B0082', '#9370DB', '#8A2BE2', '#7B68EE', '#DA70D6', '#D8BFD8', '#E6E6FA']
|
|
},
|
|
{
|
|
solfeggioFrequencyId: 9,
|
|
colors: ['#9400D3', '#BA55D3', '#C71585', '#DDA0DD', '#EE82EE', '#FFF0F5', '#FAF0FA']
|
|
}
|
|
];
|
|
|
|
const proclamationGroups = [
|
|
{ name: 'General', sortOrder: 0 },
|
|
{ name: 'Specific', sortOrder: 1 },
|
|
{ name: 'Precise', sortOrder: 2 },
|
|
{ name: 'Prayers', sortOrder: 3 },
|
|
{ name: 'Scripture', sortOrder: 4 }
|
|
];
|
|
|
|
// Flat category list (formerly hierarchical parents).
|
|
const proclamationCategories = [
|
|
{ id: 4, name: 'Spiritual' },
|
|
{ id: 2, name: 'Physical' },
|
|
{ id: 16, name: 'Mental' },
|
|
{ id: 17, name: 'Custom (Client Specific)' },
|
|
{ id: 19, name: 'Financial' },
|
|
{ id: 20, name: 'Emotional' },
|
|
{ id: 21, name: 'Social' },
|
|
{ id: 41, name: 'Biblical' },
|
|
{ id: 42, name: 'Personal Growth & Development' },
|
|
{ id: 46, name: 'Sports' }
|
|
];
|
|
|
|
async function main() {
|
|
console.log('Seeding UserRole...');
|
|
for (const role of userRoles) {
|
|
await prisma.userRole.upsert({
|
|
where: { id: role.id },
|
|
create: role,
|
|
update: role
|
|
});
|
|
}
|
|
|
|
console.log('Seeding SolfeggioFrequency...');
|
|
for (const freq of solfeggioFrequencies) {
|
|
await prisma.solfeggioFrequency.upsert({
|
|
where: { id: freq.id },
|
|
create: freq,
|
|
update: freq
|
|
});
|
|
}
|
|
|
|
console.log('Seeding ProclamationGroup...');
|
|
for (const group of proclamationGroups) {
|
|
await prisma.proclamationGroup.upsert({
|
|
where: { name: group.name },
|
|
create: group,
|
|
update: group
|
|
});
|
|
}
|
|
|
|
console.log('Seeding ProclamationCategory...');
|
|
for (const cat of proclamationCategories) {
|
|
await prisma.proclamationCategory.upsert({
|
|
where: { id: cat.id },
|
|
create: cat,
|
|
update: cat
|
|
});
|
|
}
|
|
|
|
console.log('Seeding ColorPalette...');
|
|
for (const palette of colorPalettes) {
|
|
await prisma.colorPalette.upsert({
|
|
where: { solfeggioFrequencyId: palette.solfeggioFrequencyId },
|
|
create: palette,
|
|
update: palette
|
|
});
|
|
}
|
|
|
|
console.log('Seed complete.');
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error('Seed failed:', e);
|
|
process.exit(1);
|
|
})
|
|
.finally(() => prisma.$disconnect());
|