mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
fix any types in parameters.ts
This commit is contained in:
parent
deae57a16c
commit
5a6e7c5a11
1 changed files with 6 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
import { PolicyParam } from '@/utils/policies/mod.ts';
|
||||||
|
|
||||||
type FieldType = 'string' | 'multi_string' | 'number' | 'multi_number' | 'boolean' | 'unknown';
|
type FieldType = 'string' | 'multi_string' | 'number' | 'multi_number' | 'boolean' | 'unknown';
|
||||||
|
|
||||||
|
|
@ -6,13 +7,13 @@ export interface FieldItem {
|
||||||
type: FieldType;
|
type: FieldType;
|
||||||
description?: string;
|
description?: string;
|
||||||
optional?: boolean;
|
optional?: boolean;
|
||||||
default?: any;
|
default?: PolicyParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UnwrappedZodType {
|
interface UnwrappedZodType {
|
||||||
baseType: z.ZodTypeAny;
|
baseType: z.ZodTypeAny;
|
||||||
optional?: boolean;
|
optional?: boolean;
|
||||||
defaultValue?: any;
|
defaultValue?: PolicyParam;
|
||||||
description?: string;
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -21,7 +22,7 @@ interface UnwrappedZodType {
|
||||||
*/
|
*/
|
||||||
function unwrapZodType(field: z.ZodTypeAny): UnwrappedZodType {
|
function unwrapZodType(field: z.ZodTypeAny): UnwrappedZodType {
|
||||||
let optional = false;
|
let optional = false;
|
||||||
let defaultValue: any = undefined;
|
let defaultValue: PolicyParam | undefined = undefined;
|
||||||
let description: string | undefined = undefined;
|
let description: string | undefined = undefined;
|
||||||
|
|
||||||
description = field.description;
|
description = field.description;
|
||||||
|
|
@ -63,6 +64,8 @@ function unwrapZodType(field: z.ZodTypeAny): UnwrappedZodType {
|
||||||
*
|
*
|
||||||
* Special-cases NIP-01 filters as `multi_string`.
|
* Special-cases NIP-01 filters as `multi_string`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
export function zodSchemaToFields(schema: z.ZodObject<any>): Record<string, FieldItem> {
|
export function zodSchemaToFields(schema: z.ZodObject<any>): Record<string, FieldItem> {
|
||||||
const result: Record<string, FieldItem> = {};
|
const result: Record<string, FieldItem> = {};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue