mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
user_groups: Generate UserGroup type from a schema.
This will be useful for later when we'll need the schema for converting settings_org to typescript.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import assert from "minimalistic-assert";
|
||||
import type {z} from "zod";
|
||||
import {z} from "zod";
|
||||
|
||||
import * as blueslip from "./blueslip";
|
||||
import {FoldDict} from "./fold_dict";
|
||||
@@ -7,24 +7,20 @@ import * as group_permission_settings from "./group_permission_settings";
|
||||
import {$t} from "./i18n";
|
||||
import {page_params} from "./page_params";
|
||||
import * as settings_config from "./settings_config";
|
||||
import type {
|
||||
GroupPermissionSetting,
|
||||
GroupSettingValue,
|
||||
StateData,
|
||||
user_group_schema,
|
||||
} from "./state_data";
|
||||
import {current_user, realm} from "./state_data";
|
||||
import type {GroupPermissionSetting, GroupSettingValue, StateData} from "./state_data";
|
||||
import {current_user, raw_user_group_schema, realm} from "./state_data";
|
||||
import type {UserOrMention} from "./typeahead_helper";
|
||||
import type {UserGroupUpdateEvent} from "./types";
|
||||
|
||||
type UserGroupRaw = z.infer<typeof user_group_schema>;
|
||||
type UserGroupRaw = z.infer<typeof raw_user_group_schema>;
|
||||
|
||||
// The members field is a number array which we convert
|
||||
// to a Set in the initialize function.
|
||||
export type UserGroup = Omit<UserGroupRaw, "members" | "direct_subgroup_ids"> & {
|
||||
members: Set<number>;
|
||||
direct_subgroup_ids: Set<number>;
|
||||
};
|
||||
export const user_group_schema = raw_user_group_schema.extend({
|
||||
members: z.set(z.number()),
|
||||
direct_subgroup_ids: z.set(z.number()),
|
||||
});
|
||||
export type UserGroup = z.infer<typeof user_group_schema>;
|
||||
|
||||
type UserGroupForDropdownListWidget = {
|
||||
name: string;
|
||||
|
||||
Reference in New Issue
Block a user