refactor: update localpersistance schema
This commit is contained in:
@@ -3,7 +3,9 @@ import {
|
|||||||
GQLHeader,
|
GQLHeader,
|
||||||
HoppGQLAuth,
|
HoppGQLAuth,
|
||||||
HoppGQLRequest,
|
HoppGQLRequest,
|
||||||
|
HoppRESTAuth,
|
||||||
HoppRESTRequest,
|
HoppRESTRequest,
|
||||||
|
HoppRESTHeaders,
|
||||||
} from "@hoppscotch/data"
|
} from "@hoppscotch/data"
|
||||||
import { entityReference } from "verzod"
|
import { entityReference } from "verzod"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
@@ -62,12 +64,18 @@ const HoppGQLRequestSchema = entityReference(HoppGQLRequest)
|
|||||||
const HoppRESTCollectionSchema = HoppCollectionSchemaCommonProps.extend({
|
const HoppRESTCollectionSchema = HoppCollectionSchemaCommonProps.extend({
|
||||||
folders: z.array(z.lazy(() => HoppRESTCollectionSchema)),
|
folders: z.array(z.lazy(() => HoppRESTCollectionSchema)),
|
||||||
requests: z.optional(z.array(HoppRESTRequestSchema)),
|
requests: z.optional(z.array(HoppRESTRequestSchema)),
|
||||||
|
|
||||||
|
auth: z.optional(HoppRESTAuth),
|
||||||
|
headers: z.optional(HoppRESTHeaders),
|
||||||
}).strict()
|
}).strict()
|
||||||
|
|
||||||
// @ts-expect-error recursive schema
|
// @ts-expect-error recursive schema
|
||||||
const HoppGQLCollectionSchema = HoppCollectionSchemaCommonProps.extend({
|
const HoppGQLCollectionSchema = HoppCollectionSchemaCommonProps.extend({
|
||||||
folders: z.array(z.lazy(() => HoppGQLCollectionSchema)),
|
folders: z.array(z.lazy(() => HoppGQLCollectionSchema)),
|
||||||
requests: z.optional(z.array(HoppGQLRequestSchema)),
|
requests: z.optional(z.array(HoppGQLRequestSchema)),
|
||||||
|
|
||||||
|
auth: z.optional(HoppGQLAuth),
|
||||||
|
headers: z.optional(z.array(GQLHeader)),
|
||||||
}).strict()
|
}).strict()
|
||||||
|
|
||||||
export const VUEX_SCHEMA = z.object({
|
export const VUEX_SCHEMA = z.object({
|
||||||
@@ -276,6 +284,23 @@ const validGqlOperations = [
|
|||||||
"authorization",
|
"authorization",
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
|
const HoppInheritedPropertySchema = z
|
||||||
|
.object({
|
||||||
|
auth: z.object({
|
||||||
|
parentID: z.string(),
|
||||||
|
parentName: z.string(),
|
||||||
|
inheritedAuth: z.union([HoppRESTAuth, HoppGQLAuth]),
|
||||||
|
}),
|
||||||
|
headers: z.array(
|
||||||
|
z.object({
|
||||||
|
parentID: z.string(),
|
||||||
|
parentName: z.string(),
|
||||||
|
inheritedHeader: z.union([HoppRESTHeaders, GQLHeader]),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
})
|
||||||
|
.strict()
|
||||||
|
|
||||||
export const GQL_TAB_STATE_SCHEMA = z
|
export const GQL_TAB_STATE_SCHEMA = z
|
||||||
.object({
|
.object({
|
||||||
lastActiveTabID: z.string(),
|
lastActiveTabID: z.string(),
|
||||||
@@ -291,6 +316,7 @@ export const GQL_TAB_STATE_SCHEMA = z
|
|||||||
response: z.optional(z.nullable(GQLResponseEventSchema)),
|
response: z.optional(z.nullable(GQLResponseEventSchema)),
|
||||||
responseTabPreference: z.optional(z.string()),
|
responseTabPreference: z.optional(z.string()),
|
||||||
optionTabPreference: z.optional(z.enum(validGqlOperations)),
|
optionTabPreference: z.optional(z.enum(validGqlOperations)),
|
||||||
|
inheritedProperties: z.optional(HoppInheritedPropertySchema),
|
||||||
})
|
})
|
||||||
.strict(),
|
.strict(),
|
||||||
})
|
})
|
||||||
@@ -462,6 +488,7 @@ export const REST_TAB_STATE_SCHEMA = z
|
|||||||
testResults: z.optional(z.nullable(HoppTestResultSchema)),
|
testResults: z.optional(z.nullable(HoppTestResultSchema)),
|
||||||
responseTabPreference: z.optional(z.string()),
|
responseTabPreference: z.optional(z.string()),
|
||||||
optionTabPreference: z.optional(z.enum(validRestOperations)),
|
optionTabPreference: z.optional(z.enum(validRestOperations)),
|
||||||
|
inheritedProperties: z.optional(HoppInheritedPropertySchema),
|
||||||
})
|
})
|
||||||
.strict(),
|
.strict(),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user