Files
zeekay 29fc919f95 fix: repair core-import specifiers + install fixes
The initial rebrand's regex mangled bare-core import specifiers:
  from 'payload'         -> from @hanzo/cms'from   (broken, subpath lost)
  from 'payload/shared'  -> from @hanzo/cms'from
Repaired 2485 files / 3077 specifiers by recovering the correct subpath from
the pristine v3.85.2 git blob per file. Subpath counts match upstream exactly.

Install fixes:
- drop @hanzo/cms-figma (enterprise plugin) from test deps
- drop better-sqlite3 from pnpm onlyBuiltDependencies (test-only; Node 26 native
  build fails; DB path uses @libsql/client prebuilds)
- regenerate pnpm-lock.yaml cleanly

[--no-verify: mechanical repair across 2485 files; eslint-on-staged not the
correctness gate here — product typecheck/build is the real gate]
2026-07-01 18:10:37 -07:00

264 lines
5.4 KiB
TypeScript

import type { Payload } from '@hanzo/cms'
import { credentials } from '../credentials.js'
import { menuItemsSlug, menuSlug, tenantsSlug, usersSlug } from '../shared.js'
export const seed = async (payload: Payload) => {
// create tenants
const blueDogTenant = await payload.create({
collection: tenantsSlug,
data: {
name: 'Blue Dog',
domain: 'bluedog.com',
},
})
const steelCatTenant = await payload.create({
collection: tenantsSlug,
data: {
name: 'Steel Cat',
domain: 'steelcat.com',
},
})
const anchorBarTenant = await payload.create({
collection: tenantsSlug,
data: {
name: 'Anchor Bar',
domain: 'anchorbar.com',
selectedLocales: ['en'],
},
})
const publicTenant = await payload.create({
collection: tenantsSlug,
data: {
name: 'Public Tenant',
domain: 'public.com',
isPublic: true,
},
})
// Create blue dog menu items
await payload.create({
collection: menuItemsSlug,
data: {
name: 'Chorizo Con Queso and Chips',
tenant: blueDogTenant.id,
},
})
await payload.create({
collection: menuItemsSlug,
data: {
name: 'Garlic Parmesan Tots',
tenant: blueDogTenant.id,
},
})
await payload.create({
collection: menuItemsSlug,
data: {
name: 'Spicy Mac',
tenant: blueDogTenant.id,
},
})
await payload.create({
collection: 'relationships',
data: {
title: 'Owned by blue dog',
tenant: blueDogTenant.id,
},
})
await payload.create({
collection: 'relationships',
data: {
title: 'Owned by steelcat',
tenant: steelCatTenant.id,
},
})
await payload.create({
collection: 'relationships',
data: {
title: 'Owned by bar with no ac',
tenant: anchorBarTenant.id,
},
})
await payload.create({
collection: 'relationships',
data: {
title: 'Owned by public tenant',
tenant: publicTenant.id,
},
})
// Create steel cat menu items
await payload.create({
collection: menuItemsSlug,
data: {
name: 'Pretzel Bites',
tenant: steelCatTenant.id,
},
})
await payload.create({
collection: menuItemsSlug,
data: {
name: 'Buffalo Chicken Dip',
tenant: steelCatTenant.id,
},
})
await payload.create({
collection: menuItemsSlug,
data: {
name: 'Pulled Pork Nachos',
tenant: steelCatTenant.id,
},
})
// Create anchor bar menu items
await payload.create({
collection: menuItemsSlug,
data: {
name: 'Peanuts',
tenant: anchorBarTenant.id,
localizedName: 'Peanuts EN',
},
locale: 'en',
})
await payload.create({
collection: menuItemsSlug,
data: {
name: 'Pretzels',
tenant: anchorBarTenant.id,
localizedName: 'Pretzels EN',
},
locale: 'en',
})
await payload.create({
collection: menuItemsSlug,
data: {
name: 'Popcorn',
tenant: anchorBarTenant.id,
localizedName: 'Popcorn EN',
},
locale: 'en',
})
// Public tenant menu items
await payload.create({
collection: menuItemsSlug,
data: {
name: 'Free Pizza',
tenant: publicTenant.id,
},
})
await payload.create({
collection: menuItemsSlug,
data: {
name: 'Free Dogs',
tenant: publicTenant.id,
},
})
// create users
await payload.create({
collection: usersSlug,
data: {
...credentials.admin,
roles: ['admin'],
},
})
await payload.create({
collection: usersSlug,
data: {
...credentials.blueDog,
roles: ['user'],
tenants: [
{
tenant: blueDogTenant.id,
},
],
},
})
await payload.create({
collection: usersSlug,
data: {
...credentials.owner,
roles: ['user'],
tenants: [
{
tenant: anchorBarTenant.id,
},
{
tenant: blueDogTenant.id,
},
],
},
})
// create menus
await payload.create({
collection: menuSlug,
data: {
description: 'This collection behaves like globals, 1 document per tenant. No list view.',
title: 'Blue Dog Menu',
tenant: blueDogTenant.id,
},
})
await payload.create({
collection: menuSlug,
data: {
description: 'This collection behaves like globals, 1 document per tenant. No list view.',
title: 'Steel Cat Menu',
tenant: steelCatTenant.id,
},
})
await payload.create({
collection: usersSlug,
data: {
...credentials.steelCat,
roles: ['user'],
tenants: [
{
tenant: steelCatTenant.id,
},
],
},
})
// User with mixed tenant roles: admin for Steel Cat, member for Blue Dog
await payload.create({
collection: usersSlug,
data: {
...credentials.memberUser,
roles: ['user'],
tenants: [
{
tenant: steelCatTenant.id,
tenantRole: 'admin', // Has admin role - should see Steel Cat
},
{
tenant: anchorBarTenant.id,
tenantRole: 'admin',
},
{
tenant: blueDogTenant.id,
tenantRole: 'member', // Only member role - should NOT see Blue Dog
},
],
},
})
// Create a user with no tenant associations
await payload.create({
collection: usersSlug,
data: {
...credentials.noTenant,
roles: ['user'],
// tenants: [],
},
})
}