Skip to main content

apps/web/lib/workspace-resolution.ts

Metadata

Indexed Symbols

  • appendSearchValue (line 11, function) - Implements append search value for module behavior.
  • resolveWorkspaceId (line 23, function) - Implements resolve workspace id for module behavior.
  • suggestedWorkspaceIds (line 37, function) - Implements suggested workspace ids for module behavior.
  • withResolvedWorkspace (line 52, function) - Implements with resolved workspace for module behavior.

Markdown Headings (if applicable)

No markdown headings detected.

Source Preview

import "server-only";

import { getOperatorClaims, getPreferredOperatorWorkspaceId } from "./operator-auth";
import {
type SearchParamRecord,
WORKSPACE_QUERY_PARAM,
isWorkspaceId,
workspaceIdFromSearchParams
} from "./workspace-context";

function appendSearchValue(params: URLSearchParams, key: string, value: string | string[] | undefined): void {
if (Array.isArray(value)) {
for (const entry of value) {
params.append(key, entry);
}
return;
}
if (typeof value === "string") {
params.append(key, value);
}
}

export function resolveWorkspaceId(searchParams: SearchParamRecord): string | null {
const explicitWorkspaceId = workspaceIdFromSearchParams(searchParams);
if (explicitWorkspaceId) {