Path-A first task: get the repo's two repo-wide quality gates passing.
Both were failing from a clean clone in ways that were silently hiding
each other.
Headline fixes:
* apps/web: add an eslint 9 flat config (eslint.config.mjs) using
FlatCompat against next/core-web-vitals + next/typescript, and switch
the `lint` script from `next lint` to `eslint .`. Previously `next
lint` fell into its interactive setup prompt because there was no
config at all in apps/web, which made `pnpm lint` permanently fail
before any rule ever ran.
* packages/shared/src/utils/id.ts: replace `randomUUID` from `node:crypto`
with `globalThis.crypto.randomUUID`. `@tasks/shared` is forbidden from
using Node-only APIs (per AGENTS.md / repo-overview.mdc) because it
has to be importable from the browser bundle.
Adjacent fixes pulled in to make the gates actually green:
* apps/mcp-server/tsconfig.json: drop vestigial rootDir / declaration*
/ outDir / sourceMap (build is via tsup, not tsc emit) and add
allowImportingTsExtensions. The MCP server uses `.ts`-extension
re-export shims (db.ts / schema.ts / shared-types.ts) so tsup can
inline workspace .ts sources into the bundle.
* apps/collab-server/tsconfig.json: same simplification.
* apps/mcp-server/package.json: add @types/node so `process.env` in
packages/database/src/client.ts (transitively pulled into the MCP
server's type-check) resolves.
* apps/web/components/ui/input.tsx: empty `interface InputProps extends
React.InputHTMLAttributes<HTMLInputElement> {}` -> `type` alias.
* apps/web/server/lib/workspace-guard.ts: `from(args.table as any)` ->
`as unknown as PgTable` with a comment. Standard drizzle escape
hatch for structural generic tables.
* apps/web/components/whiteboard/shapes/{document,project,task}-card.tsx:
`BaseBoxShapeUtil<any>` -> `BaseBoxShapeUtil<{Shape}>` plus inline
`declare module "@tldraw/tlschema"` augmentation of
TLGlobalShapePropsMap. Required adding @tldraw/tlschema as a direct
devDep of apps/web so the augmentation target resolves; previously
it was only present transitively under tldraw's own deps.
Result: `pnpm lint && pnpm type-check` exits 0 across all 6 packages.
16 unused-import / exhaustive-deps warnings remain; they're pre-existing
housekeeping and out of scope for this task.
Closes plans/Plan-daily-driver-finish/Epic-shipping-the-shell/
Task-fix-lint-and-shared-types.md (status: done).
Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { TRPCError } from "@trpc/server";
|
|
import { and, eq } from "drizzle-orm";
|
|
import type { PgTable } from "drizzle-orm/pg-core";
|
|
import {
|
|
objects,
|
|
forms,
|
|
propertyDefinitions,
|
|
templates,
|
|
objectTypeDefs,
|
|
} from "@tasks/database/schema";
|
|
import type { db as defaultDb } from "@tasks/database";
|
|
|
|
type Db = typeof defaultDb;
|
|
|
|
/**
|
|
* Generic "this row belongs to this workspace" guard used by tenant-scoped
|
|
* routers when a mutation targets a specific row by id. Throws NOT_FOUND if the
|
|
* row either doesn't exist or lives in a different workspace, so callers can't
|
|
* use the error code to probe IDs across tenants.
|
|
*
|
|
* The `table` parameter is constrained structurally to having `id` and
|
|
* `workspaceId` columns; the `as PgTable` cast inside the body is the
|
|
* standard drizzle escape hatch when a structural generic table can't be
|
|
* proven equivalent to drizzle's nominal `PgTable` shape.
|
|
*/
|
|
export async function assertRowInWorkspace<
|
|
T extends { id: typeof objects.id; workspaceId: typeof objects.workspaceId },
|
|
>(args: {
|
|
db: Db;
|
|
table: T;
|
|
rowId: string;
|
|
workspaceId: string;
|
|
notFoundMessage?: string;
|
|
}): Promise<void> {
|
|
const [row] = await args.db
|
|
.select({ id: args.table.id })
|
|
.from(args.table as unknown as PgTable)
|
|
.where(and(eq(args.table.id, args.rowId), eq(args.table.workspaceId, args.workspaceId)))
|
|
.limit(1);
|
|
if (!row) {
|
|
throw new TRPCError({
|
|
code: "NOT_FOUND",
|
|
message: args.notFoundMessage ?? "Resource not found",
|
|
});
|
|
}
|
|
}
|
|
|
|
export const tableForms = forms;
|
|
export const tablePropertyDefs = propertyDefinitions;
|
|
export const tableTemplates = templates;
|
|
export const tableObjectTypeDefs = objectTypeDefs;
|
|
export const tableObjects = objects;
|