Skip to content

Commit

Permalink
Apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
PopDaph committed Jan 2, 2025
1 parent 2f833cb commit 5c1a305
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
11 changes: 7 additions & 4 deletions front/lib/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
Result,
UserMetadataType,
UserType,
UserTypeWithExtensionWorkspaces,
UserTypeWithWorkspaces,
} from "@dust-tt/types";
import { Err, Ok } from "@dust-tt/types";
Expand Down Expand Up @@ -142,7 +143,7 @@ export async function fetchRevokedWorkspace(
export async function getUserWithWorkspaces(
user: UserResource,
populateExtensionConfig = false
): Promise<UserTypeWithWorkspaces> {
): Promise<UserTypeWithWorkspaces | UserTypeWithExtensionWorkspaces> {
const { memberships } = await MembershipResource.getActiveMemberships({
users: [user],
});
Expand Down Expand Up @@ -170,9 +171,11 @@ export async function getUserWithWorkspaces(
segmentation: w.segmentation || null,
whiteListedProviders: w.whiteListedProviders,
defaultEmbeddingProvider: w.defaultEmbeddingProvider,
extensionBlacklistedDomains:
configs.find((c) => c.workspaceId === w.id)?.blacklistedDomains ??
undefined,
...(populateExtensionConfig && {
blacklistedDomains:
configs.find((c) => c.workspaceId === w.id)?.blacklistedDomains ??
null,
}),
};
}),
};
Expand Down
11 changes: 9 additions & 2 deletions sdks/js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,10 @@ export type LightWorkspaceType = z.infer<typeof LightWorkspaceSchema>;

const WorkspaceSchema = LightWorkspaceSchema.extend({
ssoEnforced: z.boolean().optional(),
extensionBlacklistedDomains: z.array(z.string()).optional(),
});

const ExtensionWorkspaceSchema = WorkspaceSchema.extend({
blacklistedDomains: z.array(z.string()).optional(),
});

const UserProviderSchema = FlexibleEnumSchema<
Expand Down Expand Up @@ -2200,7 +2203,11 @@ export type FileUploadedRequestResponseType = z.infer<
>;

export const MeResponseSchema = z.object({
user: UserSchema.and(z.object({ workspaces: WorkspaceSchema.array() })),
user: UserSchema.and(
z.object({
workspaces: WorkspaceSchema.array().or(ExtensionWorkspaceSchema.array()),
})
),
});

export type MeResponseType = z.infer<typeof MeResponseSchema>;
Expand Down
9 changes: 8 additions & 1 deletion types/src/front/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export type LightWorkspaceType = {

export type WorkspaceType = LightWorkspaceType & {
ssoEnforced?: boolean;
extensionBlacklistedDomains?: string[];
};

export type ExtensionWorkspaceType = WorkspaceType & {
blacklistedDomains?: string[];
};

export type UserProviderType =
Expand Down Expand Up @@ -73,6 +76,10 @@ export type UserTypeWithWorkspaces = UserType & {
workspaces: WorkspaceType[];
};

export type UserTypeWithExtensionWorkspaces = UserType & {
workspaces: ExtensionWorkspaceType[];
};

export type UserMetadataType = {
key: string;
value: string;
Expand Down

0 comments on commit 5c1a305

Please sign in to comment.