Generated files

Every file listed here is emitted by scripts/generate-packages.ts and is gitignored in the app shell. Running npm run packages:generate rebuilds them from tinycld.packages.ts and each linked sibling’s manifest. npm run dev and npm run build:web run the generator first via lifecycle hooks - you rarely run it directly.

lib/generated/package-collections.ts

Registers every linked package’s collections with pbtsdb. Intersects the core Schema with each package’s {PascalSlug}Schema to produce MergedSchema, and exports a packageStores(pb, queryClient, coreStores) function that returns all package collections in one object. Consumed by createReactProvider in @tinycld/core/lib/pocketbase.

lib/generated/package-registry.ts

An array of {packageName, manifest} entries for every linked package. Consumed by usePackages() and usePackage(slug) in @tinycld/core/lib/packages/use-packages. This is the runtime source of truth for feature gating across packages.

lib/generated/package-settings.ts

Imports every package’s settings panel components and exports an array of {package, slug, component, label} entries. Consumed by the Personal Settings screen to render the per-package links and panels.

lib/generated/package-sidebars.ts

Imports every package that declares sidebar: { component } in its manifest and exports a map from slug to component. The org workspace renders the appropriate sidebar when a package’s routes are active.

lib/generated/package-providers.ts

Imports every package that declares provider: { component } and wraps the org workspace tree with the composed chain of providers. Packages use this to set up per-package React context (e.g. Drive’s upload state).

lib/generated/package-seeds.ts

Imports every package that declares seed: { script } and exports a record from slug to default-exported seed function. Consumed by scripts/seed-db.ts after it creates the test user and org.

app/a/[orgSlug]/<slug>/** - org-scoped route re-exports

One file per source file in each package’s routes.directory. Each is a thin re-export:

export { default } from '@tinycld/mail/screens/index'

Nested folders and layout files are preserved. Expo Router treats them as normal routes. The app shell’s app/a/[orgSlug]/_layout.tsx is force-added to git (the only non-generated file in that tree); everything beneath it is generated.

app/<publicPath> - public route re-exports

One file per source file in each package’s publicRoutes.directory, mounted directly under app/ with no org prefix. drive/public-screens/share/[token].tsx becomes app/share/[token].tsx. Cross-package path collisions cause the generator to throw with both package names listed.

One symlink per file in each package’s pb-migrations/ directory. PocketBase picks them up from this directory on boot; the generator rewrites stale symlinks that point at an old location. The app shell’s own migrations (under packages/@tinycld/core/server/pb_migrations/) are similarly symlinked in.

One symlink per file in each package’s pb-hooks/ directory (for packages that declare hooks: { directory } in their manifest). PocketBase loads .pb.js files from here automatically.

server/package_extensions.go

A generated Go file whose init() calls each linked package server’s Register(app *pocketbase.PocketBase) in manifest order. Imported by the app shell’s main.go. Only emitted if at least one package declares server.

server/go.mod

The generator rewrites two blocks (tagged with // --- package extensions --- markers) with require and replace directives for every package that declares server. Hand-written content outside the tagged blocks is preserved.

server/bundled-packages.json

A JSON manifest listing every linked package’s {slug, name, version, description}. PocketBase seeds its pkg_registry collection from this file on first boot and on subsequent registry refreshes.

.package-links.json

Internal tracking manifest listing every file and symlink the generator emitted on the last run. On the next run, the generator reads this file and removes everything from the previous run before regenerating - cleanup is automatic. Not consumed at runtime.

Regenerating

npm run packages:generate

Running the generator is idempotent. The first thing it does is delete every file listed in .package-links.json, so a stale run cannot leak state into a fresh one. If the tracking manifest is lost for some reason, git clean -fdx on the listed generated directories is a safe nuclear option.