Added additional enum fixes

This commit is contained in:
Nate Kelley 2025-09-17 17:22:26 -06:00
parent 3fd6afa544
commit 9d60c74732
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
28 changed files with 54 additions and 645 deletions

View File

@ -1,12 +1,6 @@
import type { User } from '@buster/database';
import type { Shortcut } from '@buster/server-shared/shortcuts';
export type UserOrganizationRole =
| 'workspace_admin'
| 'data_admin'
| 'querier'
| 'restricted_querier'
| 'viewer';
import type { UserOrganizationRole } from '@buster/server-shared/user';
export interface UserOrganization {
organizationId: string;

View File

@ -19,4 +19,5 @@ export const AssetPermissionRoleSchema = z.enum([
'can_edit',
'full_access',
]);
export type AssetPermissionRole = z.infer<typeof AssetPermissionRoleSchema>;

View File

@ -61,32 +61,7 @@ organization/
└── user.types.ts
```
### Enum Pattern for Database Parity
When creating enums that mirror database enums, use frozen objects to maintain type safety:
```typescript
import type { userOrganizationRoleEnum } from '@buster/database';
type OrganizationRoleBase = (typeof userOrganizationRoleEnum.enumValues)[number];
// Create a frozen object that mirrors the database enum
export const OrganizationRoleEnum: Record<OrganizationRoleBase, OrganizationRoleBase> =
Object.freeze({
viewer: 'viewer',
workspace_admin: 'workspace_admin',
data_admin: 'data_admin',
querier: 'querier',
restricted_querier: 'restricted_querier',
});
// Create Zod schema from the enum
export const OrganizationRoleSchema = z.enum(
Object.values(OrganizationRoleEnum) as [OrganizationRoleBase, ...OrganizationRoleBase[]]
);
export type OrganizationRole = z.infer<typeof OrganizationRoleSchema>;
```
### Database Type Parity

View File

@ -67,8 +67,6 @@ export const CancelChatParamsSchema = z.object({
chat_id: z.string().uuid(),
});
// Infer types from schemas
export type AssetPermissionRole = z.infer<typeof AssetPermissionRoleSchema>;
export type ChatWithMessages = z.infer<typeof ChatWithMessagesSchema>;
export type ChatCreateRequest = z.infer<typeof ChatCreateRequestSchema>;
export type ChatCreateHandlerRequest = z.infer<typeof ChatCreateHandlerRequestSchema>;

View File

@ -1,7 +1,5 @@
import type { organizations } from '@buster/database';
import { z } from 'zod';
import type { Equal, Expect } from '../type-utilities';
import { OrganizationRoleSchema } from './roles.types';
import { UserOrganizationRoleSchema } from './roles.types';
// Hex color validation schema for 3 or 6 digit hex codes
const HexColorSchema = z
@ -33,12 +31,10 @@ export const OrganizationSchema = z.object({
paymentRequired: z.boolean(),
domains: z.array(z.string()).nullable(),
restrictNewUserInvitations: z.boolean(),
defaultRole: OrganizationRoleSchema,
defaultRole: UserOrganizationRoleSchema,
organizationColorPalettes: OrganizationColorPaletteSchema,
});
export type Organization = z.infer<typeof OrganizationSchema>;
export type OrganizationColorPalette = z.infer<typeof OrganizationColorPaletteSchema>;
export type ColorPalette = z.infer<typeof ColorPalettesSchema>;
type _OrganizationEqualityCheck = Expect<Equal<Organization, typeof organizations.$inferSelect>>;

View File

@ -1,21 +1,6 @@
import type { userOrganizationRoleEnum } from '@buster/database'; //we import as type to avoid postgres dependency in the frontend ☹️
import { z } from 'zod';
import { UserOrganizationRoleSchema } from '@buster/database/schema-types'; //we import as type to avoid postgres dependency in the frontend ☹️
import type { z } from 'zod';
type OrganizationRoleBase = (typeof userOrganizationRoleEnum.enumValues)[number];
export { UserOrganizationRoleSchema };
//We need this to avoid postgres dependency in the frontend ☹️
export const OrganizationRoleEnum: Record<OrganizationRoleBase, OrganizationRoleBase> =
Object.freeze({
// Got rid of none becauase it's not a valid role.
viewer: 'viewer',
workspace_admin: 'workspace_admin',
data_admin: 'data_admin',
querier: 'querier',
restricted_querier: 'restricted_querier',
});
export const OrganizationRoleSchema = z.enum(
Object.values(OrganizationRoleEnum) as [OrganizationRoleBase, ...OrganizationRoleBase[]]
);
export type OrganizationRole = z.infer<typeof OrganizationRoleSchema>;
export type UserOrganizationRole = z.infer<typeof UserOrganizationRoleSchema>;

View File

@ -1,16 +1,6 @@
import type { userOrganizationStatusEnum } from '@buster/database';
import { z } from 'zod';
import { UserOrganizationStatusSchema } from '@buster/database/schema-types';
import type { z } from 'zod';
type OrganizationStatusBase = (typeof userOrganizationStatusEnum.enumValues)[number];
export { UserOrganizationStatusSchema };
export const OrganizationStatusEnum: Record<OrganizationStatusBase, OrganizationStatusBase> =
Object.freeze({
active: 'active',
inactive: 'inactive',
pending: 'pending',
guest: 'guest',
});
export const OrganizationStatusSchema = z.enum(
Object.values(OrganizationStatusEnum) as [OrganizationStatusBase, ...OrganizationStatusBase[]]
);
export type UserOrganizationStatus = z.infer<typeof UserOrganizationStatusSchema>;

View File

@ -1,5 +1,5 @@
import { z } from 'zod';
import { OrganizationRoleSchema } from './roles.types';
import { UserOrganizationRoleSchema } from './roles.types';
export const LineageUserItemTypeSchema = z.enum(['user', 'datasets', 'permissionGroups']);
@ -25,7 +25,7 @@ export const OrganizationUserSchema = z.object({
name: z.string(),
avatar_url: z.string().nullable(),
status: z.enum(['active', 'inactive']),
role: OrganizationRoleSchema,
role: UserOrganizationRoleSchema,
datasets: z.array(OrganizationUserDatasetSchema),
});

View File

@ -1,89 +0,0 @@
# Welcome to the Plate Playground!
Experience a modern rich-text editor built with [Slate](https://slatejs.org) and [React](https://reactjs.org). This playground showcases just a part of Plate's capabilities. [Explore the documentation](/docs) to discover more.
## Collaborative Editing
Review and refine content seamlessly. Use [](/docs/suggestion) or to . Discuss changes using [comments](/docs/comment) on many text segments. You can even have annotations!
## AI-Powered Editing
Boost your productivity with integrated [AI SDK](/docs/ai). Press <kbd>⌘+J</kbd> or <kbd>Space</kbd> in an empty line to:
* Generate content (continue writing, summarize, explain)
* Edit existing text (improve, fix grammar, change tone)
## Rich Content Editing
Structure your content with [headings](/docs/heading), [lists](/docs/list), and [quotes](/docs/blockquote). Apply [marks](/docs/basic-marks) like **bold**, _italic_, <u>underline</u>, ~~strikethrough~~, and `code`. Use [autoformatting](/docs/autoformat) for [Markdown](/docs/markdown)-like shortcuts (e.g., <kbd>\*</kbd> for lists, <kbd>#</kbd> for H1).
> Blockquotes are great for highlighting important information.
```javascript
function hello() {
console.info('Code blocks are supported!');
}
```
Create [links](/docs/link), [@mention](/docs/mention) users like [Alice](mention:Alice), or insert [emojis](/docs/emoji) ✨. Use the [slash command](/docs/slash-command) (/) for quick access to elements.
* Check
* [ ] Check 2
* [ ] Check 3
<callout icon="💡">
This is a good callout
</callout>
<column_group>
<column width="33.333333333333336%">
Column 1
</column>
<column width="33.333333333333336%">
Column 2
</column>
<column width="33.333333333333336%">
Column 3
</column>
</column_group>
### How Plate Compares
Plate offers many features out-of-the-box as free, open-source plugins.
| **Feature** | **Plate (Free & OSS)** | **Tiptap** |
| ------------------- | ---------------------- | --------------------- |
| AI | ✅ | Paid Extension |
| Comments | ✅ | Paid Extension |
| Suggestions | ✅ | Paid (Comments Pro) |
| Emoji Picker | ✅ | Paid Extension |
| Table of Contents | ✅ | Paid Extension |
| Drag Handle | ✅ | Paid Extension |
| Collaboration (Yjs) | ✅ | Hocuspocus (OSS/Paid) |
### Images and Media
Embed rich media like images directly in your content. Supports [Media uploads](/docs/media) and [drag & drop](/docs/dnd) for a smooth experience.
![](https://images.unsplash.com/photo-1712688930249-98e1963af7bd?q=80\&w=600\&auto=format\&fit=crop\&ixlib=rb-4.0.3\&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D)
<file isUpload="true" name="sample.pdf" src="https://s26.q4cdn.com/900411403/files/doc_downloads/test.pdf" />
<audio src="https://samplelib.com/lib/preview/mp3/sample-3s.mp3" />
<metric metricId="123-456-789" />
### Table of Contents
<toc />

View File

@ -1,293 +0,0 @@
import type { ReportElement } from '@buster/database';
export const SAMPLE_REPORT_ELEMENTS = [
{
type: 'h1', // This will now error if you use 'h1xs'
children: [{ text: 'Welcome to the Report Editor' }],
},
{
type: 'p',
children: [
{ text: 'This is a sample paragraph with ' },
{ text: 'bold text', bold: true },
{ text: ' and ' },
{ text: 'italic text', italic: true },
{ text: '.' },
{ text: 'hilight', highlight: true },
],
},
{
type: 'h2',
children: [{ text: 'Features' }],
},
{
type: 'ul',
children: [
{ type: 'li', children: [{ text: 'Rich text editing' }] },
{ type: 'li', children: [{ text: 'Multiple block types' }] },
{ type: 'li', children: [{ text: 'Customizable appearance' }] },
],
},
{
type: 'callout',
variant: 'info',
children: [{ text: 'This is an info callout with custom styling!' }],
},
{
type: 'h3', // This is now valid - TypeScript knows this is a valid HeadingType
children: [{ text: 'Title' }],
},
// Uncommenting this would cause a TypeScript error:
// {
// type: 'xxxh3', // Error: Type '"xxxh3"' is not assignable to type ReportElementType
// children: [{ text: 'Invalid' }]
// },
{
type: 'blockquote',
children: [
{ text: 'This is a blockquote. It can contain styled text and other inline elements.' },
],
},
{
type: 'code_block',
lang: 'javascript',
children: [
{
type: 'code_line',
children: [{ text: 'const greeting = "Hello, World!";' }],
},
{
type: 'code_line',
children: [{ text: 'console.log(greeting);' }],
},
{
type: 'code_line',
children: [{ text: '}' }],
},
],
},
{
children: [
{ children: [{ text: 'function hello() {' }], type: 'code_line' },
{
children: [{ text: " console.info('Code blocks are supported!');" }],
type: 'code_line',
},
{ children: [{ text: '}' }], type: 'code_line' },
],
lang: 'javascript',
type: 'code_block',
},
{
type: 'h1',
children: [{ text: 'Hello' }],
},
// Table Section
{
children: [{ text: 'How Plate Compares' }],
type: 'h3',
},
{
children: [
{
text: 'Plate offers many features out-of-the-box as free, open-source plugins.',
},
],
type: 'p',
},
{
type: 'table',
children: [
{
children: [
{
children: [{ bold: true, text: 'Feature' }],
type: 'th',
},
{
children: [
{
children: [{ bold: true, text: 'Plate (Free & OSS)' }],
type: 'p',
},
],
type: 'th',
},
{
children: [{ children: [{ bold: true, text: 'Tiptap' }], type: 'p' }],
type: 'th',
},
],
type: 'tr',
},
{
children: [
{
children: [{ children: [{ text: 'AI' }], type: 'p' }],
type: 'td',
},
{
children: [
{
attributes: { align: 'center' },
children: [{ text: '✅' }],
type: 'p',
},
],
type: 'td',
},
{
children: [{ children: [{ text: 'Paid Extension' }], type: 'p' }],
type: 'td',
},
],
type: 'tr',
},
{
children: [
{
children: [{ children: [{ text: 'Comments' }], type: 'p' }],
type: 'td',
},
{
children: [
{
attributes: { align: 'center' },
children: [{ text: '✅' }],
type: 'p',
},
],
type: 'td',
},
{
children: [{ children: [{ text: 'Paid Extension' }], type: 'p' }],
type: 'td',
},
],
type: 'tr',
},
{
children: [
{
children: [{ children: [{ text: 'Suggestions' }], type: 'p' }],
type: 'td',
},
{
children: [
{
attributes: { align: 'center' },
children: [{ text: '✅' }],
type: 'p',
},
],
type: 'td',
},
{
children: [{ children: [{ text: 'Paid (Comments Pro)' }], type: 'p' }],
type: 'td',
},
],
type: 'tr',
},
{
children: [
{
children: [{ children: [{ text: 'Emoji Picker' }], type: 'p' }],
type: 'td',
},
{
children: [
{
attributes: { align: 'center' },
children: [{ text: '✅' }],
type: 'p',
},
],
type: 'td',
},
{
children: [{ children: [{ text: 'Paid Extension' }], type: 'p' }],
type: 'td',
},
],
type: 'tr',
},
{
children: [
{
children: [{ children: [{ text: 'Table of Contents' }], type: 'p' }],
type: 'td',
},
{
children: [
{
attributes: { align: 'center' },
children: [{ text: '✅' }],
type: 'p',
},
],
type: 'td',
},
{
children: [{ children: [{ text: 'Paid Extension' }], type: 'p' }],
type: 'td',
},
],
type: 'tr',
},
{
children: [
{
children: [{ children: [{ text: 'Drag Handle' }], type: 'p' }],
type: 'td',
},
{
children: [
{
attributes: { align: 'center' },
children: [{ text: '✅' }],
type: 'p',
},
],
type: 'td',
},
{
children: [{ children: [{ text: 'Paid Extension' }], type: 'p' }],
type: 'td',
},
],
type: 'tr',
},
{
children: [
{
children: [{ children: [{ text: 'Collaboration (Yjs)' }], type: 'p' }],
type: 'td',
},
{
children: [
{
attributes: { align: 'center' },
children: [{ text: '✅' }],
type: 'p',
},
],
type: 'td',
},
{
children: [{ children: [{ text: 'Hocuspocus (OSS/Paid)' }], type: 'p' }],
type: 'td',
},
],
type: 'tr',
},
],
},
{
type: 'metric',
metricId: '123',
children: [{ text: '' }],
caption: [{ text: 'This is a metric' }],
},
] satisfies ReportElement[];

View File

@ -2,4 +2,3 @@ export * from './reports.types';
export * from './requests';
export * from './responses';
export * from './reports.types';
export * from './report-elements';

View File

@ -1,17 +0,0 @@
import type {
MetricElement,
ReportElement,
ReportElementWithId,
ReportElements,
ReportElementsWithIds,
TextElement,
} from '@buster/database';
export type {
ReportElement,
ReportElements,
ReportElementsWithIds,
ReportElementWithId,
MetricElement,
TextElement,
};

View File

@ -1,5 +1,5 @@
import { z } from 'zod';
import { OrganizationRoleSchema } from '../organization';
import { UserOrganizationRoleSchema } from '../organization';
export const UpdateInviteLinkRequestSchema = z.object({
enabled: z.boolean().optional(),
@ -41,7 +41,7 @@ export type RemoveApprovedDomainRequest = z.infer<typeof RemoveApprovedDomainReq
export const UpdateWorkspaceSettingsRequestSchema = z.object({
restrict_new_user_invitations: z.boolean().optional(),
default_role: OrganizationRoleSchema.optional(),
default_role: UserOrganizationRoleSchema.optional(),
// this can either be a uuid or "all"
default_datasets_ids: z.array(z.union([z.string(), z.literal('all')])).optional(),
});

View File

@ -1,5 +1,5 @@
import { z } from 'zod';
import { OrganizationRoleSchema } from '../organization';
import { UserOrganizationRoleSchema } from '../organization';
export const GetInviteLinkResponseSchema = z.object({
link: z.string(),
@ -20,7 +20,7 @@ export const RemoveApprovedDomainsResponseSchema = GetApprovedDomainsResponseSch
export const GetWorkspaceSettingsResponseSchema = z.object({
restrict_new_user_invitations: z.boolean(),
default_role: OrganizationRoleSchema,
default_role: UserOrganizationRoleSchema,
default_datasets: z.array(
z.object({
id: z.string(),

View File

@ -1,17 +1,6 @@
import type { assetPermissionRoleEnum } from '@buster/database';
import { z } from 'zod';
import { AssetPermissionRoleSchema } from '@buster/database/schema-types';
import type { z } from 'zod';
type AssetPermissionRoleBase = (typeof assetPermissionRoleEnum.enumValues)[number];
const AssetPermissionRoleEnums: Record<AssetPermissionRoleBase, AssetPermissionRoleBase> =
Object.freeze({
owner: 'owner',
viewer: 'viewer',
full_access: 'full_access',
can_edit: 'can_edit',
can_filter: 'can_filter',
can_view: 'can_view',
});
export { AssetPermissionRoleSchema };
export const AssetPermissionRoleSchema = z.enum(
Object.values(AssetPermissionRoleEnums) as [AssetPermissionRoleBase, ...AssetPermissionRoleBase[]]
);
export type AssetPermissionRole = z.infer<typeof AssetPermissionRoleSchema>;

View File

@ -1,42 +1,15 @@
import type { assetPermissionRoleEnum, workspaceSharingEnum } from '@buster/database';
import { AssetPermissionRoleSchema, WorkspaceSharingSchema } from '@buster/database/schema-types';
import { z } from 'zod';
import { AssetTypeSchema } from '../assets/asset-types.types';
type ShareRoleBase = (typeof assetPermissionRoleEnum.enumValues)[number];
export const ShareRoleEnumsConversions: Record<ShareRoleBase, ShareRoleBase> = Object.freeze({
owner: 'owner',
full_access: 'full_access',
can_edit: 'can_edit',
can_view: 'can_view',
viewer: 'viewer',
can_filter: 'can_filter',
});
export const ShareRoleSchema = z.enum(
Object.values(ShareRoleEnumsConversions) as [ShareRoleBase, ...ShareRoleBase[]]
);
//type TeamRoleBase = (typeof teamRoleEnum.enumValues)[number] | 'none';
type WorkspaceShareRoleBase = (typeof workspaceSharingEnum.enumValues)[number];
const WorkspaceShareRoleEnumsConversions: Record<WorkspaceShareRoleBase, WorkspaceShareRoleBase> =
Object.freeze({
full_access: 'full_access',
can_edit: 'can_edit',
can_view: 'can_view',
none: 'none',
});
export const WorkspaceShareRoleSchema = z.enum(
Object.values(WorkspaceShareRoleEnumsConversions) as [
WorkspaceShareRoleBase,
...WorkspaceShareRoleBase[],
]
);
export { AssetPermissionRoleSchema, WorkspaceSharingSchema };
export const ShareRoleSchema = AssetPermissionRoleSchema;
export const WorkspaceShareRoleSchema = WorkspaceSharingSchema;
export const ShareAssetTypeSchema = AssetTypeSchema;
export const ShareIndividualSchema = z.object({
email: z.string(),
role: ShareRoleSchema,
role: AssetPermissionRoleSchema,
name: z.string().nullable().optional(),
avatar_url: z.string().nullable().optional(),
});
@ -47,8 +20,8 @@ export const ShareConfigSchema = z.object({
public_enabled_by: z.string().nullable(),
publicly_accessible: z.boolean(),
public_password: z.string().nullable(),
permission: ShareRoleSchema, //this is the permission the user has to the metric, dashboard or collection
workspace_sharing: WorkspaceShareRoleSchema.nullable(),
permission: AssetPermissionRoleSchema, //this is the permission the user has to the metric, dashboard or collection
workspace_sharing: WorkspaceSharingSchema.nullable(),
workspace_member_count: z.number().nullable(),
});

View File

@ -1,19 +1,6 @@
import type { verificationEnum } from '@buster/database';
import { z } from 'zod';
import { VerificationSchema } from '@buster/database/schema-types';
import type { z } from 'zod';
type VerificationStatusBase = (typeof verificationEnum.enumValues)[number] | 'notVerified';
const VerificationStatusEnums: Record<VerificationStatusBase, VerificationStatusBase> =
Object.freeze({
notRequested: 'notRequested',
requested: 'requested',
inReview: 'inReview',
verified: 'verified',
backlogged: 'backlogged',
notVerified: 'notVerified',
});
export const VerificationStatusSchema = z.enum(
Object.values(VerificationStatusEnums) as [VerificationStatusBase, ...VerificationStatusBase[]]
);
export const VerificationStatusSchema = VerificationSchema;
export type VerificationStatus = z.infer<typeof VerificationStatusSchema>;

View File

@ -1,15 +1,6 @@
import type { slackSharingPermissionEnum } from '@buster/database'; //we import as type to avoid postgres dependency in the frontend ☹️
import { SlackSharingPermissionSchema } from '@buster/database/schema-types'; //we import as type to avoid postgres dependency in the frontend ☹️
import { z } from 'zod';
type SlackSharingPermissionBase = (typeof slackSharingPermissionEnum.enumValues)[number];
const SlackSharingPermissionEnum: Record<SlackSharingPermissionBase, SlackSharingPermissionBase> =
Object.freeze({
shareWithWorkspace: 'shareWithWorkspace',
shareWithChannel: 'shareWithChannel',
noSharing: 'noSharing',
});
// POST /api/v2/slack/auth/init
export const InitiateOAuthSchema = z
.object({
@ -41,14 +32,7 @@ export const UpdateIntegrationSchema = z.object({
id: z.string().min(1),
})
.optional(),
default_sharing_permissions: z
.enum(
Object.values(SlackSharingPermissionEnum) as [
SlackSharingPermissionBase,
...SlackSharingPermissionBase[],
]
)
.optional(),
default_sharing_permissions: SlackSharingPermissionSchema.optional(),
});
export type UpdateIntegrationRequest = z.infer<typeof UpdateIntegrationSchema>;

View File

@ -1,15 +1,6 @@
import type { slackSharingPermissionEnum } from '@buster/database'; //we import as type to avoid postgres dependency in the frontend ☹️
import { SlackSharingPermissionSchema } from '@buster/database/schema-types'; //we import as type to avoid postgres dependency in the frontend ☹️
import { z } from 'zod';
type SlackSharingPermissionBase = (typeof slackSharingPermissionEnum.enumValues)[number];
const SlackSharingPermissionEnum: Record<SlackSharingPermissionBase, SlackSharingPermissionBase> =
Object.freeze({
shareWithWorkspace: 'shareWithWorkspace',
shareWithChannel: 'shareWithChannel',
noSharing: 'noSharing',
});
// Error response schema
export const SlackErrorResponseSchema = z.object({
error: z.string(),
@ -46,14 +37,7 @@ export const GetIntegrationResponseSchema = z.object({
name: z.string(),
})
.optional(),
default_sharing_permissions: z
.enum(
Object.values(SlackSharingPermissionEnum) as [
SlackSharingPermissionBase,
...SlackSharingPermissionBase[],
]
)
.optional(),
default_sharing_permissions: SlackSharingPermissionSchema.optional(),
})
.optional(),
});
@ -76,14 +60,7 @@ export const UpdateIntegrationResponseSchema = z.object({
id: z.string(),
})
.optional(),
default_sharing_permissions: z
.enum(
Object.values(SlackSharingPermissionEnum) as [
SlackSharingPermissionBase,
...SlackSharingPermissionBase[],
]
)
.optional(),
default_sharing_permissions: SlackSharingPermissionSchema.optional(),
});
export type UpdateIntegrationResponse = z.infer<typeof UpdateIntegrationResponseSchema>;

View File

@ -1,16 +1,8 @@
import type { teamRoleEnum } from '@buster/database'; //we import as type to avoid postgres dependency in the frontend ☹️
import { TeamRoleSchema } from '@buster/database/schema-types'; //we import as type to avoid postgres dependency in the frontend ☹️
import { z } from 'zod';
import { SharingSettingSchema } from '../user/sharing-setting.types';
type TeamRoleBase = (typeof teamRoleEnum.enumValues)[number] | 'none';
const TeamRoleEnums: Record<TeamRoleBase, TeamRoleBase> = Object.freeze({
none: 'none',
manager: 'manager',
member: 'member',
});
export const TeamRoleSchema = z.enum(
Object.values(TeamRoleEnums) as [TeamRoleBase, ...TeamRoleBase[]]
);
export { TeamRoleSchema };
export type TeamRole = z.infer<typeof TeamRoleSchema>;

View File

@ -1,7 +1,6 @@
export * from './request.types';
export * from './responses.types';
export * from './users.types';
export * from './roles.types';
export * from '../teams/teams.types';
export * from './sharing-setting.types';
export * from './favorites.types';

View File

@ -1,13 +1,13 @@
import { z } from 'zod';
import { OrganizationRoleSchema, OrganizationStatusSchema } from '../organization';
import { UserOrganizationRoleSchema, UserOrganizationStatusSchema } from '../organization';
export const OrganizationUserSchema = z.object({
email: z.string(),
id: z.string(),
name: z.string().nullable(),
role: OrganizationRoleSchema.nullable(),
role: UserOrganizationRoleSchema.nullable(),
avatarUrl: z.string().nullable(),
status: OrganizationStatusSchema,
status: UserOrganizationStatusSchema,
});
export type OrganizationUser = z.infer<typeof OrganizationUserSchema>;

View File

@ -1,7 +1,7 @@
import { z } from 'zod';
import { AssetTypeSchema } from '../assets';
import { OrganizationStatusSchema } from '../organization';
import { OrganizationRoleSchema } from '../organization/roles.types';
import { UserOrganizationStatusSchema } from '../organization';
import { UserOrganizationRoleSchema } from '../organization/roles.types';
import { createOptionalQueryArrayPreprocessor } from '../type-utilities';
export const UserRequestSchema = z.object({
@ -13,7 +13,7 @@ export type UserRequest = z.infer<typeof UserRequestSchema>;
export const UserUpdateRequestSchema = z.object({
user_id: z.string(),
name: z.string().optional(),
role: OrganizationRoleSchema.optional(),
role: UserOrganizationRoleSchema.optional(),
});
export type UserUpdateRequest = z.infer<typeof UserUpdateRequestSchema>;
@ -56,9 +56,9 @@ export const GetUserToOrganizationRequestSchema = z.object({
user_name: z.string().optional(),
email: z.string().optional(),
//We need this because the frontend sends the roles as a comma-separated string in the query params
role: createOptionalQueryArrayPreprocessor(OrganizationRoleSchema).optional(),
role: createOptionalQueryArrayPreprocessor(UserOrganizationRoleSchema).optional(),
//We need this because the frontend sends the status as a comma-separated string in the query params
status: createOptionalQueryArrayPreprocessor(OrganizationStatusSchema)
status: createOptionalQueryArrayPreprocessor(UserOrganizationStatusSchema)
.default(['active'])
.optional(),
});

View File

@ -1,6 +1,6 @@
import { z } from 'zod';
import { OrganizationSchema } from '../organization/organization.types';
import { OrganizationRoleSchema } from '../organization/roles.types';
import { UserOrganizationRoleSchema } from '../organization/roles.types';
import { TeamSchema } from '../teams/teams.types';
import { PaginatedResponseSchema } from '../type-utilities/pagination';
import { UserFavoriteSchema } from './favorites.types';
@ -8,7 +8,7 @@ import { OrganizationUserSchema } from './organization-user.types';
import { UserSchema } from './users.types';
const OrganizationWithUserRoleSchema = OrganizationSchema.extend({
role: OrganizationRoleSchema,
role: UserOrganizationRoleSchema,
});
export const UserResponseSchema = z.object({

View File

@ -1,22 +0,0 @@
import type { userOrganizationRoleEnum } from '@buster/database/schema-types'; //we import as type to avoid postgres dependency in the frontend ☹️
import { z } from 'zod';
type UserOrganizationRoleBase = (typeof userOrganizationRoleEnum.enumValues)[number];
const UserOrganizationRoleEnums: Record<UserOrganizationRoleBase, UserOrganizationRoleBase> =
Object.freeze({
viewer: 'viewer',
workspace_admin: 'workspace_admin',
data_admin: 'data_admin',
querier: 'querier',
restricted_querier: 'restricted_querier',
});
export const UserOrganizationRoleSchema = z.enum(
Object.values(UserOrganizationRoleEnums) as [
UserOrganizationRoleBase,
...UserOrganizationRoleBase[],
]
);
export type UserOrganizationRole = z.infer<typeof UserOrganizationRoleSchema>;

View File

@ -1,17 +1,8 @@
import type { sharingSettingEnum } from '@buster/database'; //we import as type to avoid postgres dependency in the frontend ☹️
import { SharingSettingSchema as SharingSettingSchemaDatabase } from '@buster/database/schema-types'; //we import as type to avoid postgres dependency in the frontend ☹️
import { z } from 'zod';
type SharingSettingBase = (typeof sharingSettingEnum.enumValues)[number] | 'none';
const SharingSettingSchema = z.union([SharingSettingSchemaDatabase, z.literal('none')]);
const SharingSettingEnums: Record<SharingSettingBase, SharingSettingBase> = Object.freeze({
none: 'none',
public: 'public',
team: 'team',
organization: 'organization',
});
const test = Object.values(SharingSettingEnums) as [SharingSettingBase, ...SharingSettingBase[]];
export const SharingSettingSchema = z.enum(test);
export { SharingSettingSchema };
export type SharingSetting = z.infer<typeof SharingSettingSchema>;

View File

@ -1,4 +1,4 @@
import type { UserSuggestedPromptsType } from '@buster/database';
import type { UserSuggestedPromptsType } from '@buster/database/schema-types';
import { z } from 'zod';

View File

@ -1,5 +1,5 @@
import type { UpdateUserResponse, UserInfoByIdResponse } from '@buster/database';
import { UserPersonalizationConfigSchema } from '@buster/database';
import { UserPersonalizationConfigSchema } from '@buster/database/schema-types';
import { z } from 'zod';
import type { UserFavorite } from './favorites.types';
import type { UserOrganizationRole } from './roles.types';