mirror of https://github.com/zulip/zulip.git
zform: Move zod schema to avoid dependency cycle.
We need to validate the events array in 'submessage.js' using zod. One of the schema needed is 'zform_widget_extra_data_schema' in zform. If we import it inside 'submessage', it creates a dependency cycle ; zform.js=>transmit.js=>server_events.js=>server_events_dispatch.js. server_events_dispatch.js=>submessage.js=>zform.js Hence I have moved the schema inside 'submessage' and imported it inside 'zform.js'.
This commit is contained in:
parent
3eb1a11725
commit
195bb4d13b
|
@ -1,8 +1,23 @@
|
|||
import z from "zod";
|
||||
|
||||
import * as blueslip from "./blueslip";
|
||||
import * as channel from "./channel";
|
||||
import * as message_store from "./message_store";
|
||||
import * as widgetize from "./widgetize";
|
||||
|
||||
export const zform_widget_extra_data_schema = z.object({
|
||||
choices: z.array(
|
||||
z.object({
|
||||
type: z.string(),
|
||||
long_name: z.string(),
|
||||
reply: z.string(),
|
||||
short_name: z.string(),
|
||||
}),
|
||||
),
|
||||
heading: z.string(),
|
||||
type: z.literal("choices"),
|
||||
});
|
||||
|
||||
export function get_message_events(message) {
|
||||
if (message.locally_echoed) {
|
||||
return undefined;
|
||||
|
|
|
@ -1,24 +1,11 @@
|
|||
import $ from "jquery";
|
||||
import {z} from "zod";
|
||||
|
||||
import render_widgets_zform_choices from "../templates/widgets/zform_choices.hbs";
|
||||
|
||||
import * as blueslip from "./blueslip";
|
||||
import {zform_widget_extra_data_schema} from "./submessage";
|
||||
import * as transmit from "./transmit";
|
||||
|
||||
const zform_widget_extra_data_schema = z.object({
|
||||
choices: z.array(
|
||||
z.object({
|
||||
type: z.string(),
|
||||
long_name: z.string(),
|
||||
reply: z.string(),
|
||||
short_name: z.string(),
|
||||
}),
|
||||
),
|
||||
heading: z.string(),
|
||||
type: z.literal("choices"),
|
||||
});
|
||||
|
||||
export function activate(opts) {
|
||||
const self = {};
|
||||
|
||||
|
|
Loading…
Reference in New Issue