Skip to content
Merged
417 changes: 409 additions & 8 deletions apps/api/src/routes/chats.ts

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion apps/api/src/routes/public-chat-shares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ publicChatShares.openapi(listSharedChats, async (c) => {
.from(tables.chatShare)
.innerJoin(tables.chat, eq(tables.chatShare.chatId, tables.chat.id))
.where(
and(isNull(tables.chatShare.deletedAt), eq(tables.chat.status, "active")),
and(
isNull(tables.chatShare.deletedAt),
isNull(tables.chatShare.organizationId),
eq(tables.chat.status, "active"),
),
)
.orderBy(desc(tables.chatShare.updatedAt))
.limit(limit ?? 5000);
Expand Down Expand Up @@ -128,6 +132,7 @@ publicChatShares.openapi(getSharedChat, async (c) => {
and(
eq(tables.chatShare.id, shareId),
isNull(tables.chatShare.deletedAt),
isNull(tables.chatShare.organizationId),
eq(tables.chat.status, "active"),
),
)
Expand Down
160 changes: 159 additions & 1 deletion apps/code/src/lib/api/v1.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7406,6 +7406,10 @@ export interface paths {
shareId: string | null;
/** Format: date-time */
sharedAt: string | null;
orgShares: {
id: string;
organizationId: string;
}[];
/** Format: date-time */
createdAt: string;
/** Format: date-time */
Expand Down Expand Up @@ -7453,6 +7457,10 @@ export interface paths {
shareId: string | null;
/** Format: date-time */
sharedAt: string | null;
orgShares: {
id: string;
organizationId: string;
}[];
/** Format: date-time */
createdAt: string;
/** Format: date-time */
Expand Down Expand Up @@ -7518,6 +7526,10 @@ export interface paths {
shareId: string | null;
/** Format: date-time */
sharedAt: string | null;
orgShares: {
id: string;
organizationId: string;
}[];
/** Format: date-time */
createdAt: string;
/** Format: date-time */
Expand Down Expand Up @@ -7573,6 +7585,10 @@ export interface paths {
shareId: string | null;
/** Format: date-time */
sharedAt: string | null;
orgShares: {
id: string;
organizationId: string;
}[];
/** Format: date-time */
createdAt: string;
/** Format: date-time */
Expand Down Expand Up @@ -7675,6 +7691,10 @@ export interface paths {
shareId: string | null;
/** Format: date-time */
sharedAt: string | null;
orgShares: {
id: string;
organizationId: string;
}[];
/** Format: date-time */
createdAt: string;
/** Format: date-time */
Expand Down Expand Up @@ -7706,7 +7726,13 @@ export interface paths {
};
cookie?: never;
};
requestBody?: never;
requestBody?: {
content: {
"application/json": {
organizationId?: string;
};
};
};
responses: {
/** @description Chat share snapshot. */
200: {
Expand All @@ -7720,6 +7746,7 @@ export interface paths {
url: string;
/** Format: date-time */
createdAt: string;
organizationId?: string | null;
};
};
};
Expand Down Expand Up @@ -7755,6 +7782,137 @@ export interface paths {
patch?: never;
trace?: never;
};
"/chats/org/{organizationId}/shares": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: {
parameters: {
query?: never;
header?: never;
path: {
organizationId: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Organization shared chat snapshots. */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
shares: {
id: string;
title: string;
model: string;
/** Format: date-time */
createdAt: string;
/** Format: date-time */
updatedAt: string;
}[];
};
};
};
};
};
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/chats/org-share/{shareId}": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: {
parameters: {
query?: never;
header?: never;
path: {
shareId: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Organization shared chat snapshot. */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
share: {
id: string;
title: string;
model: string;
/** Format: date-time */
createdAt: string;
messages: {
id: string;
/** @enum {string} */
role: "user" | "assistant" | "system";
content: string | null;
images: string | null;
audios?: string | null;
reasoning: string | null;
tools: string | null;
metadata?: {
[key: string]: unknown;
} | null;
sequence: number;
/** Format: date-time */
createdAt: string;
}[];
};
};
};
};
};
};
put?: never;
post?: never;
delete: {
parameters: {
query?: never;
header?: never;
path: {
shareId: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Organization share deleted successfully. */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
message: string;
};
};
};
};
};
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/chats/share/{shareId}/fork": {
parameters: {
query?: never;
Expand Down
25 changes: 25 additions & 0 deletions apps/playground/src/app/org/[orgId]/chat/[shareId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { renderPlaygroundShell } from "@/app/playground-shell";

export default async function OrgSharedChatPage({
params,
searchParams,
}: {
params: Promise<{ orgId: string; shareId: string }>;
searchParams: Promise<{
orgId?: string;
projectId?: string;
q?: string;
hints?: string;
model?: string;
}>;
}) {
const [{ orgId, shareId }, resolvedSearchParams] = await Promise.all([
params,
searchParams,
]);

return await renderPlaygroundShell({
searchParams: resolvedSearchParams,
orgShareView: { organizationId: orgId, shareId },
});
}
25 changes: 25 additions & 0 deletions apps/playground/src/app/org/[orgId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { renderPlaygroundShell } from "@/app/playground-shell";

export default async function OrgSharedChatsPage({
params,
searchParams,
}: {
params: Promise<{ orgId: string }>;
searchParams: Promise<{
orgId?: string;
projectId?: string;
q?: string;
hints?: string;
model?: string;
}>;
}) {
const [{ orgId }, resolvedSearchParams] = await Promise.all([
params,
searchParams,
]);

return await renderPlaygroundShell({
searchParams: resolvedSearchParams,
orgShareView: { organizationId: orgId },
});
}
Loading
Loading