Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

realm_playground: Extract realm_playground_schema.

Anders Kaseorg8dd3fffeb0a6
diff --git a/web/src/realm_playground.ts b/web/src/realm_playground.ts
index af593a6367c..b50a8b1aa0d 100644
--- a/web/src/realm_playground.ts
+++ b/web/src/realm_playground.ts
@@ -1,16 +1,13 @@
import assert from "minimalistic-assert";
+import type {z} from "zod";
import * as typeahead from "../shared/src/typeahead.ts";
import {$t} from "./i18n.ts";
import * as pygments_data from "./pygments_data.ts";
+import type {realm_playground_schema} from "./state_data.ts";
-export type RealmPlayground = {
- id: number;
- name: string;
- pygments_language: string;
- url_template: string;
-};
+export type RealmPlayground = z.output<typeof realm_playground_schema>;
const map_language_to_playground_info = new Map<string, RealmPlayground[]>();
const map_pygments_pretty_name_to_aliases = new Map<string, string[]>();
diff --git a/web/src/state_data.ts b/web/src/state_data.ts
index 6732f94fedc..ee2e4633905 100644
--- a/web/src/state_data.ts
+++ b/web/src/state_data.ts
@@ -238,6 +238,13 @@ const custom_profile_field_types_schema = z.object({
export type CustomProfileFieldTypes = z.infer<typeof custom_profile_field_types_schema>;
+export const realm_playground_schema = z.object({
+ id: z.number(),
+ name: z.string(),
+ pygments_language: z.string(),
+ url_template: z.string(),
+});
+
export const realm_linkifier_schema = z.object({
pattern: z.string(),
url_template: z.string(),
@@ -373,14 +380,7 @@ export const realm_schema = z.object({
realm_org_type: z.number(),
realm_password_auth_enabled: z.boolean(),
realm_plan_type: z.number(),
- realm_playgrounds: z.array(
- z.object({
- id: z.number(),
- name: z.string(),
- pygments_language: z.string(),
- url_template: z.string(),
- }),
- ),
+ realm_playgrounds: z.array(realm_playground_schema),
realm_presence_disabled: z.boolean(),
realm_push_notifications_enabled: z.boolean(),
realm_push_notifications_enabled_end_timestamp: z.number().nullable(),