Allows for the creation of user accounts. A few notes on the specifics: - Experiments are the main access control objects. If you can view an experiment, you can view all its prompts/scenarios/evals. If you can edit it, you can edit or delete all of those as well. - Experiments are owned by Organizations in the database. Organizations can have multiple members and members can have roles of ADMIN, MEMBER or VIEWER. - Organizations can either be "personal" or general. Each user has a "personal" organization created as soon as they try to create an experiment. There's currently no UI support for creating general orgs or adding users to them; they're just in the database to future-proof all the ACL logic. - You can require that a user is signed-in to see a route using the `protectedProcedure` helper. When you use `protectedProcedure`, you also have to call `ctx.markAccessControlRun()` (or delegate to a function that does it for you; see accessControl.ts). This is to remind us to actually check for access control when we define a new endpoint.
180 lines
5.3 KiB
TypeScript
180 lines
5.3 KiB
TypeScript
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
// This file will be automatically regenerated when your Next.js server is running.
|
|
// nextjs-routes version: 2.0.1
|
|
/* eslint-disable */
|
|
|
|
// prettier-ignore
|
|
declare module "nextjs-routes" {
|
|
import type {
|
|
GetServerSidePropsContext as NextGetServerSidePropsContext,
|
|
GetServerSidePropsResult as NextGetServerSidePropsResult
|
|
} from "next";
|
|
|
|
export type Route =
|
|
| StaticRoute<"/account/signin">
|
|
| DynamicRoute<"/api/auth/[...nextauth]", { "nextauth": string[] }>
|
|
| DynamicRoute<"/api/trpc/[trpc]", { "trpc": string }>
|
|
| DynamicRoute<"/experiments/[id]", { "id": string }>
|
|
| StaticRoute<"/experiments">
|
|
| StaticRoute<"/">;
|
|
|
|
interface StaticRoute<Pathname> {
|
|
pathname: Pathname;
|
|
query?: Query | undefined;
|
|
hash?: string | null | undefined;
|
|
}
|
|
|
|
interface DynamicRoute<Pathname, Parameters> {
|
|
pathname: Pathname;
|
|
query: Parameters & Query;
|
|
hash?: string | null | undefined;
|
|
}
|
|
|
|
interface Query {
|
|
[key: string]: string | string[] | undefined;
|
|
};
|
|
|
|
export type RoutedQuery<P extends Route["pathname"]> = Extract<
|
|
Route,
|
|
{ pathname: P }
|
|
>["query"];
|
|
|
|
export type Locale =
|
|
| "en";
|
|
|
|
/**
|
|
* A typesafe utility function for generating paths in your application.
|
|
*
|
|
* route({ pathname: "/foos/[foo]", query: { foo: "bar" }}) will produce "/foos/bar".
|
|
*/
|
|
export declare function route(r: Route): string;
|
|
|
|
/**
|
|
* Nearly identical to GetServerSidePropsContext from next, but further narrows
|
|
* types based on nextjs-route's route data.
|
|
*/
|
|
export type GetServerSidePropsContext<
|
|
Pathname extends Route["pathname"] = Route["pathname"],
|
|
Preview extends NextGetServerSidePropsContext["previewData"] = NextGetServerSidePropsContext["previewData"]
|
|
> = Omit<NextGetServerSidePropsContext, 'params' | 'query' | 'defaultLocale' | 'locale' | 'locales'> & {
|
|
params: Extract<Route, { pathname: Pathname }>["query"];
|
|
query: Query;
|
|
defaultLocale: "en";
|
|
locale: Locale;
|
|
locales: [
|
|
"en"
|
|
];
|
|
};
|
|
|
|
/**
|
|
* Nearly identical to GetServerSideProps from next, but further narrows
|
|
* types based on nextjs-route's route data.
|
|
*/
|
|
export type GetServerSideProps<
|
|
Props extends { [key: string]: any } = { [key: string]: any },
|
|
Pathname extends Route["pathname"] = Route["pathname"],
|
|
Preview extends NextGetServerSideProps["previewData"] = NextGetServerSideProps["previewData"]
|
|
> = (
|
|
context: GetServerSidePropsContext<Pathname, Preview>
|
|
) => Promise<NextGetServerSidePropsResult<Props>>
|
|
}
|
|
|
|
// prettier-ignore
|
|
declare module "next/link" {
|
|
import type { Route } from "nextjs-routes";
|
|
import type { LinkProps as NextLinkProps } from "next/dist/client/link";
|
|
import type {
|
|
AnchorHTMLAttributes,
|
|
DetailedReactHTMLElement,
|
|
MouseEventHandler,
|
|
PropsWithChildren,
|
|
} from "react";
|
|
export * from "next/dist/client/link";
|
|
|
|
type StaticRoute = Exclude<Route, { query: any }>["pathname"];
|
|
|
|
export interface LinkProps
|
|
extends Omit<NextLinkProps, "href" | "locale">,
|
|
AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
href: Route | StaticRoute | Omit<Route, "pathname">
|
|
locale?: Locale | false;
|
|
}
|
|
|
|
type LinkReactElement = DetailedReactHTMLElement<
|
|
{
|
|
onMouseEnter?: MouseEventHandler<Element> | undefined;
|
|
onClick: MouseEventHandler;
|
|
href?: string | undefined;
|
|
ref?: any;
|
|
},
|
|
HTMLElement
|
|
>;
|
|
|
|
declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
|
|
|
|
export default Link;
|
|
}
|
|
|
|
// prettier-ignore
|
|
declare module "next/router" {
|
|
import type { Locale, Route, RoutedQuery } from "nextjs-routes";
|
|
import type { NextRouter as Router } from "next/dist/client/router";
|
|
export * from "next/dist/client/router";
|
|
export { default } from "next/dist/client/router";
|
|
|
|
type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
|
|
type StaticRoute = Exclude<Route, { query: any }>["pathname"];
|
|
|
|
interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
|
|
locale?: Locale | false;
|
|
}
|
|
|
|
type PathnameAndQuery<Pathname> = Required<
|
|
Pick<Extract<Route, { pathname: Pathname }>, "pathname" | "query">
|
|
>;
|
|
|
|
type AutomaticStaticOptimizedQuery<PaQ> = Omit<PaQ, "query"> & {
|
|
query: Partial<PaQ["query"]>;
|
|
};
|
|
|
|
type BaseRouter<PaQ> =
|
|
| ({ isReady: false } & AutomaticStaticOptimizedQuery<PaQ>)
|
|
| ({ isReady: true } & PaQ);
|
|
|
|
export type NextRouter<P extends Route["pathname"] = Route["pathname"]> =
|
|
BaseRouter<PathnameAndQuery<P>> &
|
|
Omit<
|
|
Router,
|
|
| "defaultLocale"
|
|
| "domainLocales"
|
|
| "isReady"
|
|
| "locale"
|
|
| "locales"
|
|
| "pathname"
|
|
| "push"
|
|
| "query"
|
|
| "replace"
|
|
| "route"
|
|
> & {
|
|
defaultLocale: "en";
|
|
domainLocales?: undefined;
|
|
locale: Locale;
|
|
locales: [
|
|
"en"
|
|
];
|
|
push(
|
|
url: Route | StaticRoute | Omit<Route, "pathname">,
|
|
as?: string,
|
|
options?: TransitionOptions
|
|
): Promise<boolean>;
|
|
replace(
|
|
url: Route | StaticRoute | Omit<Route, "pathname">,
|
|
as?: string,
|
|
options?: TransitionOptions
|
|
): Promise<boolean>;
|
|
route: P;
|
|
};
|
|
|
|
export function useRouter<P extends Route["pathname"]>(): NextRouter<P>;
|
|
}
|