Execute oxfmt (#1166)
Ran pnpm oxfmt . This should get the web repo aligned so that we can better enforce oxfmt going forward.
This commit is contained in:
@@ -42,7 +42,9 @@ describe("makeChannelSchema", () => {
|
||||
expect(result.success).toBe(false);
|
||||
if (!result.success) {
|
||||
expect(
|
||||
result.error.issues.some((i) => i.path.includes("settings") && i.path.includes("psk")),
|
||||
result.error.issues.some(
|
||||
(i) => i.path.includes("settings") && i.path.includes("psk"),
|
||||
),
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
@@ -57,7 +59,9 @@ describe("makeChannelSchema", () => {
|
||||
expect(result.success).toBe(false);
|
||||
if (!result.success) {
|
||||
expect(
|
||||
result.error.issues.some((i) => i.path.includes("settings") && i.path.includes("psk")),
|
||||
result.error.issues.some(
|
||||
(i) => i.path.includes("settings") && i.path.includes("psk"),
|
||||
),
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
@@ -72,7 +76,9 @@ describe("makeChannelSchema", () => {
|
||||
expect(result.success).toBe(false);
|
||||
if (!result.success) {
|
||||
expect(
|
||||
result.error.issues.some((i) => i.path.includes("settings") && i.path.includes("name")),
|
||||
result.error.issues.some(
|
||||
(i) => i.path.includes("settings") && i.path.includes("name"),
|
||||
),
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Protobuf } from "@meshtastic/sdk";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
const PairingModeEnum = z.enum(Protobuf.Config.Config_BluetoothConfig_PairingMode);
|
||||
const PairingModeEnum = z.enum(
|
||||
Protobuf.Config.Config_BluetoothConfig_PairingMode,
|
||||
);
|
||||
|
||||
export const BluetoothValidationSchema = z.object({
|
||||
enabled: z.boolean(),
|
||||
|
||||
@@ -2,7 +2,9 @@ import { Protobuf } from "@meshtastic/sdk";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
const RoleEnum = z.enum(Protobuf.Config.Config_DeviceConfig_Role);
|
||||
const RebroadcastModeEnum = z.enum(Protobuf.Config.Config_DeviceConfig_RebroadcastMode);
|
||||
const RebroadcastModeEnum = z.enum(
|
||||
Protobuf.Config.Config_DeviceConfig_RebroadcastMode,
|
||||
);
|
||||
|
||||
export const DeviceValidationSchema = z.object({
|
||||
role: RoleEnum,
|
||||
|
||||
@@ -4,10 +4,16 @@ import { z } from "zod/v4";
|
||||
const GpsCoordinateEnum = z.enum(
|
||||
Protobuf.Config.Config_DisplayConfig_DeprecatedGpsCoordinateFormat,
|
||||
);
|
||||
const DisplayUnitsEnum = z.enum(Protobuf.Config.Config_DisplayConfig_DisplayUnits);
|
||||
const DisplayUnitsEnum = z.enum(
|
||||
Protobuf.Config.Config_DisplayConfig_DisplayUnits,
|
||||
);
|
||||
const OledTypeEnum = z.enum(Protobuf.Config.Config_DisplayConfig_OledType);
|
||||
const DisplayModeEnum = z.enum(Protobuf.Config.Config_DisplayConfig_DisplayMode);
|
||||
const CompassOrientationEnum = z.enum(Protobuf.Config.Config_DisplayConfig_CompassOrientation);
|
||||
const DisplayModeEnum = z.enum(
|
||||
Protobuf.Config.Config_DisplayConfig_DisplayMode,
|
||||
);
|
||||
const CompassOrientationEnum = z.enum(
|
||||
Protobuf.Config.Config_DisplayConfig_CompassOrientation,
|
||||
);
|
||||
|
||||
export const DisplayValidationSchema = z.object({
|
||||
screenOnSecs: z.coerce.number().int().min(0),
|
||||
|
||||
@@ -19,9 +19,11 @@ export const LoRaValidationSchema = z.object({
|
||||
channelNum: z.coerce.number().int(),
|
||||
overrideDutyCycle: z.boolean(),
|
||||
sx126xRxBoostedGain: z.boolean(),
|
||||
overrideFrequency: z.coerce.number().refine((val) => val === 0 || (val >= 410 && val <= 930), {
|
||||
message: "formValidation.invalidOverrideFreq.number",
|
||||
}),
|
||||
overrideFrequency: z.coerce
|
||||
.number()
|
||||
.refine((val) => val === 0 || (val >= 410 && val <= 930), {
|
||||
message: "formValidation.invalidOverrideFreq.number",
|
||||
}),
|
||||
ignoreIncoming: z.coerce.number().array(),
|
||||
ignoreMqtt: z.boolean(),
|
||||
configOkToMqtt: z.boolean(),
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { Protobuf } from "@meshtastic/sdk";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
const AddressModeEnum = z.enum(Protobuf.Config.Config_NetworkConfig_AddressMode);
|
||||
const ProtocolFlagsEnum = z.enum(Protobuf.Config.Config_NetworkConfig_ProtocolFlags);
|
||||
const AddressModeEnum = z.enum(
|
||||
Protobuf.Config.Config_NetworkConfig_AddressMode,
|
||||
);
|
||||
const ProtocolFlagsEnum = z.enum(
|
||||
Protobuf.Config.Config_NetworkConfig_ProtocolFlags,
|
||||
);
|
||||
|
||||
export const NetworkValidationIpV4ConfigSchema = z.object({
|
||||
ip: z.ipv4(),
|
||||
|
||||
@@ -34,7 +34,9 @@ describe("RawSecuritySchema", () => {
|
||||
});
|
||||
expect(result.success).toBe(false);
|
||||
if (!result.success) {
|
||||
expect(result.error.issues.some((i) => i.path.includes("privateKey"))).toBe(true);
|
||||
expect(
|
||||
result.error.issues.some((i) => i.path.includes("privateKey")),
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -50,9 +52,11 @@ describe("RawSecuritySchema", () => {
|
||||
});
|
||||
expect(result.success).toBe(false);
|
||||
if (!result.success) {
|
||||
expect(result.error.issues.some((i) => i.message === "formValidation.required.managed")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
result.error.issues.some(
|
||||
(i) => i.message === "formValidation.required.managed",
|
||||
),
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -98,9 +102,11 @@ describe("ParsedSecuritySchema", () => {
|
||||
});
|
||||
expect(result.success).toBe(false);
|
||||
if (!result.success) {
|
||||
expect(result.error.issues.some((i) => i.message === "formValidation.required.managed")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
result.error.issues.some(
|
||||
(i) => i.message === "formValidation.required.managed",
|
||||
),
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,7 +5,9 @@ const { stringSchema, bytesSchema, isValidKey } = makePskHelpers([32]); // 256-b
|
||||
|
||||
const isManagedRequiredMsg = "formValidation.required.managed";
|
||||
|
||||
function makeSecuritySchema<KeyT>(keyMaker: (optional: boolean) => ZodType<KeyT>) {
|
||||
function makeSecuritySchema<KeyT>(
|
||||
keyMaker: (optional: boolean) => ZodType<KeyT>,
|
||||
) {
|
||||
return z
|
||||
.object({
|
||||
isManaged: z.boolean(),
|
||||
|
||||
@@ -8,4 +8,6 @@ export const AmbientLightingValidationSchema = z.object({
|
||||
blue: z.coerce.number().int().min(0).max(255),
|
||||
});
|
||||
|
||||
export type AmbientLightingValidation = z.infer<typeof AmbientLightingValidationSchema>;
|
||||
export type AmbientLightingValidation = z.infer<
|
||||
typeof AmbientLightingValidationSchema
|
||||
>;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Protobuf } from "@meshtastic/sdk";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
const Audio_BaudEnum = z.enum(Protobuf.ModuleConfig.ModuleConfig_AudioConfig_Audio_Baud);
|
||||
const Audio_BaudEnum = z.enum(
|
||||
Protobuf.ModuleConfig.ModuleConfig_AudioConfig_Audio_Baud,
|
||||
);
|
||||
|
||||
export const AudioValidationSchema = z.object({
|
||||
codec2Enabled: z.boolean(),
|
||||
|
||||
@@ -19,4 +19,6 @@ export const CannedMessageValidationSchema = z.object({
|
||||
sendBell: z.boolean(),
|
||||
});
|
||||
|
||||
export type CannedMessageValidation = z.infer<typeof CannedMessageValidationSchema>;
|
||||
export type CannedMessageValidation = z.infer<
|
||||
typeof CannedMessageValidationSchema
|
||||
>;
|
||||
|
||||
@@ -16,4 +16,6 @@ export const DetectionSensorValidationSchema = z.object({
|
||||
usePullup: z.boolean(),
|
||||
});
|
||||
|
||||
export type DetectionSensorValidation = z.infer<typeof DetectionSensorValidationSchema>;
|
||||
export type DetectionSensorValidation = z.infer<
|
||||
typeof DetectionSensorValidationSchema
|
||||
>;
|
||||
|
||||
@@ -18,4 +18,6 @@ export const ExternalNotificationValidationSchema = z.object({
|
||||
useI2sAsBuzzer: z.boolean(),
|
||||
});
|
||||
|
||||
export type ExternalNotificationValidation = z.infer<typeof ExternalNotificationValidationSchema>;
|
||||
export type ExternalNotificationValidation = z.infer<
|
||||
typeof ExternalNotificationValidationSchema
|
||||
>;
|
||||
|
||||
@@ -6,4 +6,6 @@ export const NeighborInfoValidationSchema = z.object({
|
||||
transmitOverLora: z.boolean(),
|
||||
});
|
||||
|
||||
export type NeighborInfoValidation = z.infer<typeof NeighborInfoValidationSchema>;
|
||||
export type NeighborInfoValidation = z.infer<
|
||||
typeof NeighborInfoValidationSchema
|
||||
>;
|
||||
|
||||
@@ -8,4 +8,6 @@ export const RemoteHardwareValidationSchema = z.object({
|
||||
availablePins: z.array(z.any()),
|
||||
});
|
||||
|
||||
export type RemoteHardwareValidation = z.infer<typeof RemoteHardwareValidationSchema>;
|
||||
export type RemoteHardwareValidation = z.infer<
|
||||
typeof RemoteHardwareValidationSchema
|
||||
>;
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { Protobuf } from "@meshtastic/sdk";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
const Serial_BaudEnum = z.enum(Protobuf.ModuleConfig.ModuleConfig_SerialConfig_Serial_Baud);
|
||||
const Serial_ModeEnum = z.enum(Protobuf.ModuleConfig.ModuleConfig_SerialConfig_Serial_Mode);
|
||||
const Serial_BaudEnum = z.enum(
|
||||
Protobuf.ModuleConfig.ModuleConfig_SerialConfig_Serial_Baud,
|
||||
);
|
||||
const Serial_ModeEnum = z.enum(
|
||||
Protobuf.ModuleConfig.ModuleConfig_SerialConfig_Serial_Mode,
|
||||
);
|
||||
|
||||
export const SerialValidationSchema = z.object({
|
||||
enabled: z.boolean(),
|
||||
|
||||
@@ -4,4 +4,6 @@ export const StatusMessageValidationSchema = z.object({
|
||||
nodeStatus: z.string().max(200),
|
||||
});
|
||||
|
||||
export type StatusMessageValidation = z.infer<typeof StatusMessageValidationSchema>;
|
||||
export type StatusMessageValidation = z.infer<
|
||||
typeof StatusMessageValidationSchema
|
||||
>;
|
||||
|
||||
@@ -9,4 +9,6 @@ export const StoreForwardValidationSchema = z.object({
|
||||
isServer: z.boolean(),
|
||||
});
|
||||
|
||||
export type StoreForwardValidation = z.infer<typeof StoreForwardValidationSchema>;
|
||||
export type StoreForwardValidation = z.infer<
|
||||
typeof StoreForwardValidationSchema
|
||||
>;
|
||||
|
||||
@@ -17,4 +17,6 @@ export const TrafficManagementValidationSchema = z.object({
|
||||
routerPreserveHops: z.boolean(),
|
||||
});
|
||||
|
||||
export type TrafficManagementValidation = z.infer<typeof TrafficManagementValidationSchema>;
|
||||
export type TrafficManagementValidation = z.infer<
|
||||
typeof TrafficManagementValidationSchema
|
||||
>;
|
||||
|
||||
@@ -35,9 +35,13 @@ export function makePskHelpers(allowedByteLengths: readonly number[]) {
|
||||
const stringSchema = (optional = false) =>
|
||||
z
|
||||
.string()
|
||||
.refine((s) => optional || s !== "" || (s === "" && allowedByteLengths.includes(0)), {
|
||||
message: msgs.required,
|
||||
})
|
||||
.refine(
|
||||
(s) =>
|
||||
optional || s !== "" || (s === "" && allowedByteLengths.includes(0)),
|
||||
{
|
||||
message: msgs.required,
|
||||
},
|
||||
)
|
||||
.refine((s) => s === "" || tryParse(s) !== null, { message: msgs.format })
|
||||
.refine((s) => s === "" || isValidString(s), {
|
||||
message: msgs.length,
|
||||
@@ -47,13 +51,20 @@ export function makePskHelpers(allowedByteLengths: readonly number[]) {
|
||||
const bytesSchema = (optional = false): ZodType<Uint8Array> =>
|
||||
z
|
||||
.instanceof(Uint8Array)
|
||||
.refine((arr) => optional || arr.byteLength !== 0 || allowedByteLengths.includes(0), {
|
||||
message: msgs.required,
|
||||
})
|
||||
.refine((arr) => optional || allowedByteLengths.includes(arr.byteLength), {
|
||||
message: msgs.length,
|
||||
params: { bits: bitsLabel },
|
||||
});
|
||||
.refine(
|
||||
(arr) =>
|
||||
optional || arr.byteLength !== 0 || allowedByteLengths.includes(0),
|
||||
{
|
||||
message: msgs.required,
|
||||
},
|
||||
)
|
||||
.refine(
|
||||
(arr) => optional || allowedByteLengths.includes(arr.byteLength),
|
||||
{
|
||||
message: msgs.length,
|
||||
params: { bits: bitsLabel },
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
allowedByteLengths,
|
||||
|
||||
Reference in New Issue
Block a user