mirror of
https://github.com/outline/outline.git
synced 2026-11-26 07:33:19 +03:00
* chore: Rename APIContext to Context and flatten its fields Auth and transaction now live directly on the context instead of in ctx.state and a nested ctx.context, and model helpers read them directly. APIContext remains as a deprecated alias. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MJXFeUxvU46KyvKnP8sXf * chore: Remove deprecated APIContext alias Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MJXFeUxvU46KyvKnP8sXf * fix: Read auth from context in OAuth provider callbacks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MJXFeUxvU46KyvKnP8sXf * chore: Add withUser and withTransaction context helpers Replaces manual createContext rebuilds that copy fields from an existing context. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MJXFeUxvU46KyvKnP8sXf * chore: Remove arbitrary property access from Koa context types AppContext and Context no longer inherit the any index signature from Koa's DefaultContext, custom fields are declared explicitly, and importing Koa's loose Context type is disallowed by lint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MJXFeUxvU46KyvKnP8sXf --------- Co-authored-by: Claude <noreply@anthropic.com>
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import type { InferCreationAttributes } from "sequelize";
|
|
import { traceFunction } from "@server/logging/tracing";
|
|
import { Team } from "@server/models";
|
|
import type { Context } from "@server/types";
|
|
|
|
type Props = {
|
|
/** The displayed name of the team */
|
|
name: string;
|
|
/** The domain name from the email of the user logging in */
|
|
domain?: string;
|
|
/** The preferred subdomain to provision for the team if not yet created */
|
|
subdomain: string;
|
|
/** The public url of an image representing the team */
|
|
avatarUrl?: string | null;
|
|
/** Details of the authentication provider being used */
|
|
authenticationProviders: {
|
|
/** The name of the authentication provider, eg "google" */
|
|
name: string;
|
|
/** External identifier of the authentication provider */
|
|
providerId: string;
|
|
}[];
|
|
};
|
|
|
|
async function teamCreator(
|
|
ctx: Context,
|
|
{ name, subdomain, avatarUrl, authenticationProviders }: Props
|
|
): Promise<Team> {
|
|
if (!avatarUrl?.startsWith("http")) {
|
|
avatarUrl = null;
|
|
}
|
|
|
|
const availableSubdomain = await Team.findAvailableSubdomain(subdomain, {
|
|
transaction: ctx.transaction,
|
|
});
|
|
return await Team.createWithCtx(
|
|
ctx,
|
|
{
|
|
name,
|
|
subdomain: availableSubdomain,
|
|
avatarUrl,
|
|
authenticationProviders,
|
|
} as Partial<InferCreationAttributes<Team>>,
|
|
undefined,
|
|
{
|
|
include: ["authenticationProviders"],
|
|
}
|
|
);
|
|
}
|
|
|
|
export default traceFunction({
|
|
spanName: "teamCreator",
|
|
})(teamCreator);
|