refactor: add auth and header fields coll in sh
This commit is contained in:
@@ -89,6 +89,8 @@ type ExportedUserCollectionREST = {
|
|||||||
folders: ExportedUserCollectionREST[]
|
folders: ExportedUserCollectionREST[]
|
||||||
requests: Array<HoppRESTRequest & { id: string }>
|
requests: Array<HoppRESTRequest & { id: string }>
|
||||||
name: string
|
name: string
|
||||||
|
auth: HoppRESTRequest["auth"]
|
||||||
|
headers: HoppRESTRequest["headers"]
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExportedUserCollectionGQL = {
|
type ExportedUserCollectionGQL = {
|
||||||
@@ -96,6 +98,8 @@ type ExportedUserCollectionGQL = {
|
|||||||
folders: ExportedUserCollectionGQL[]
|
folders: ExportedUserCollectionGQL[]
|
||||||
requests: Array<HoppGQLRequest & { id: string }>
|
requests: Array<HoppGQLRequest & { id: string }>
|
||||||
name: string
|
name: string
|
||||||
|
auth: HoppGQLRequest["auth"]
|
||||||
|
headers: HoppGQLRequest["headers"]
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportedCollectionToHoppCollection(
|
function exportedCollectionToHoppCollection(
|
||||||
@@ -104,7 +108,7 @@ function exportedCollectionToHoppCollection(
|
|||||||
): HoppCollection<HoppRESTRequest | HoppGQLRequest> {
|
): HoppCollection<HoppRESTRequest | HoppGQLRequest> {
|
||||||
if (collectionType == "REST") {
|
if (collectionType == "REST") {
|
||||||
const restCollection = collection as ExportedUserCollectionREST
|
const restCollection = collection as ExportedUserCollectionREST
|
||||||
|
console.log("restCollection", restCollection)
|
||||||
return {
|
return {
|
||||||
id: restCollection.id,
|
id: restCollection.id,
|
||||||
v: 1,
|
v: 1,
|
||||||
@@ -139,6 +143,8 @@ function exportedCollectionToHoppCollection(
|
|||||||
testScript,
|
testScript,
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
auth: restCollection.auth,
|
||||||
|
headers: restCollection.headers,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const gqlCollection = collection as ExportedUserCollectionGQL
|
const gqlCollection = collection as ExportedUserCollectionGQL
|
||||||
@@ -159,6 +165,8 @@ function exportedCollectionToHoppCollection(
|
|||||||
name,
|
name,
|
||||||
})
|
})
|
||||||
) as HoppGQLRequest[],
|
) as HoppGQLRequest[],
|
||||||
|
auth: gqlCollection.auth,
|
||||||
|
headers: gqlCollection.headers,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,7 +176,6 @@ async function loadUserCollections(collectionType: "REST" | "GQL") {
|
|||||||
undefined,
|
undefined,
|
||||||
collectionType == "REST" ? ReqType.Rest : ReqType.Gql
|
collectionType == "REST" ? ReqType.Rest : ReqType.Gql
|
||||||
)
|
)
|
||||||
|
|
||||||
if (E.isRight(res)) {
|
if (E.isRight(res)) {
|
||||||
const collectionsJSONString =
|
const collectionsJSONString =
|
||||||
res.right.exportUserCollectionsToJSON.exportedCollection
|
res.right.exportUserCollectionsToJSON.exportedCollection
|
||||||
@@ -177,7 +184,6 @@ async function loadUserCollections(collectionType: "REST" | "GQL") {
|
|||||||
ExportedUserCollectionGQL | ExportedUserCollectionREST
|
ExportedUserCollectionGQL | ExportedUserCollectionREST
|
||||||
>
|
>
|
||||||
).map((collection) => ({ v: 1, ...collection }))
|
).map((collection) => ({ v: 1, ...collection }))
|
||||||
|
|
||||||
runDispatchWithOutSyncing(() => {
|
runDispatchWithOutSyncing(() => {
|
||||||
collectionType == "REST"
|
collectionType == "REST"
|
||||||
? setRESTCollections(
|
? setRESTCollections(
|
||||||
@@ -299,12 +305,22 @@ function setupUserCollectionCreatedSubscription() {
|
|||||||
folders: [],
|
folders: [],
|
||||||
requests: [],
|
requests: [],
|
||||||
v: 1,
|
v: 1,
|
||||||
|
auth: {
|
||||||
|
authType: "none",
|
||||||
|
authActive: false,
|
||||||
|
},
|
||||||
|
headers: [],
|
||||||
})
|
})
|
||||||
: addRESTCollection({
|
: addRESTCollection({
|
||||||
name: res.right.userCollectionCreated.title,
|
name: res.right.userCollectionCreated.title,
|
||||||
folders: [],
|
folders: [],
|
||||||
requests: [],
|
requests: [],
|
||||||
v: 1,
|
v: 1,
|
||||||
|
auth: {
|
||||||
|
authType: "none",
|
||||||
|
authActive: false,
|
||||||
|
},
|
||||||
|
headers: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
const localIndex = collectionStore.value.state.length - 1
|
const localIndex = collectionStore.value.state.length - 1
|
||||||
|
|||||||
Reference in New Issue
Block a user