mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 22:37:04 +08:00
chore: update graphql support for fetching initial user status (#12905)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new context management system for intelligent features, enabling the collection and preparation of metadata from both web view and GraphQL sources. - Added a service for managing GraphQL API interactions, including user, workspace, subscription, and quota queries. - Enabled searching documents within a workspace using a new GraphQL query and input structure. - **Enhancements** - Expanded chat session and chat history search capabilities with additional filter and pagination options. - **Refactor** - Replaced the previous context management class with a more comprehensive and modular implementation. - Improved handling of cookies for network requests to ensure session continuity. - **Style** - Minor code style and formatting improvements for clarity and consistency. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
@_exported import ApolloAPI
|
||||
|
||||
public class IndexerSearchDocsQuery: GraphQLQuery {
|
||||
public static let operationName: String = "indexerSearchDocs"
|
||||
public static let operationDocument: ApolloAPI.OperationDocument = .init(
|
||||
definition: .init(
|
||||
#"query indexerSearchDocs($id: String!, $input: SearchDocsInput!) { workspace(id: $id) { __typename searchDocs(input: $input) { __typename docId title blockId highlight createdAt updatedAt createdByUser { __typename id name avatarUrl } updatedByUser { __typename id name avatarUrl } } } }"#
|
||||
))
|
||||
|
||||
public var id: String
|
||||
public var input: SearchDocsInput
|
||||
|
||||
public init(
|
||||
id: String,
|
||||
input: SearchDocsInput
|
||||
) {
|
||||
self.id = id
|
||||
self.input = input
|
||||
}
|
||||
|
||||
public var __variables: Variables? { [
|
||||
"id": id,
|
||||
"input": input
|
||||
] }
|
||||
|
||||
public struct Data: AffineGraphQL.SelectionSet {
|
||||
public let __data: DataDict
|
||||
public init(_dataDict: DataDict) { __data = _dataDict }
|
||||
|
||||
public static var __parentType: any ApolloAPI.ParentType { AffineGraphQL.Objects.Query }
|
||||
public static var __selections: [ApolloAPI.Selection] { [
|
||||
.field("workspace", Workspace.self, arguments: ["id": .variable("id")]),
|
||||
] }
|
||||
|
||||
/// Get workspace by id
|
||||
public var workspace: Workspace { __data["workspace"] }
|
||||
|
||||
/// Workspace
|
||||
///
|
||||
/// Parent Type: `WorkspaceType`
|
||||
public struct Workspace: AffineGraphQL.SelectionSet {
|
||||
public let __data: DataDict
|
||||
public init(_dataDict: DataDict) { __data = _dataDict }
|
||||
|
||||
public static var __parentType: any ApolloAPI.ParentType { AffineGraphQL.Objects.WorkspaceType }
|
||||
public static var __selections: [ApolloAPI.Selection] { [
|
||||
.field("__typename", String.self),
|
||||
.field("searchDocs", [SearchDoc].self, arguments: ["input": .variable("input")]),
|
||||
] }
|
||||
|
||||
/// Search docs by keyword
|
||||
public var searchDocs: [SearchDoc] { __data["searchDocs"] }
|
||||
|
||||
/// Workspace.SearchDoc
|
||||
///
|
||||
/// Parent Type: `SearchDocObjectType`
|
||||
public struct SearchDoc: AffineGraphQL.SelectionSet {
|
||||
public let __data: DataDict
|
||||
public init(_dataDict: DataDict) { __data = _dataDict }
|
||||
|
||||
public static var __parentType: any ApolloAPI.ParentType { AffineGraphQL.Objects.SearchDocObjectType }
|
||||
public static var __selections: [ApolloAPI.Selection] { [
|
||||
.field("__typename", String.self),
|
||||
.field("docId", String.self),
|
||||
.field("title", String.self),
|
||||
.field("blockId", String.self),
|
||||
.field("highlight", String.self),
|
||||
.field("createdAt", AffineGraphQL.DateTime.self),
|
||||
.field("updatedAt", AffineGraphQL.DateTime.self),
|
||||
.field("createdByUser", CreatedByUser?.self),
|
||||
.field("updatedByUser", UpdatedByUser?.self),
|
||||
] }
|
||||
|
||||
public var docId: String { __data["docId"] }
|
||||
public var title: String { __data["title"] }
|
||||
public var blockId: String { __data["blockId"] }
|
||||
public var highlight: String { __data["highlight"] }
|
||||
public var createdAt: AffineGraphQL.DateTime { __data["createdAt"] }
|
||||
public var updatedAt: AffineGraphQL.DateTime { __data["updatedAt"] }
|
||||
public var createdByUser: CreatedByUser? { __data["createdByUser"] }
|
||||
public var updatedByUser: UpdatedByUser? { __data["updatedByUser"] }
|
||||
|
||||
/// Workspace.SearchDoc.CreatedByUser
|
||||
///
|
||||
/// Parent Type: `PublicUserType`
|
||||
public struct CreatedByUser: AffineGraphQL.SelectionSet {
|
||||
public let __data: DataDict
|
||||
public init(_dataDict: DataDict) { __data = _dataDict }
|
||||
|
||||
public static var __parentType: any ApolloAPI.ParentType { AffineGraphQL.Objects.PublicUserType }
|
||||
public static var __selections: [ApolloAPI.Selection] { [
|
||||
.field("__typename", String.self),
|
||||
.field("id", String.self),
|
||||
.field("name", String.self),
|
||||
.field("avatarUrl", String?.self),
|
||||
] }
|
||||
|
||||
public var id: String { __data["id"] }
|
||||
public var name: String { __data["name"] }
|
||||
public var avatarUrl: String? { __data["avatarUrl"] }
|
||||
}
|
||||
|
||||
/// Workspace.SearchDoc.UpdatedByUser
|
||||
///
|
||||
/// Parent Type: `PublicUserType`
|
||||
public struct UpdatedByUser: AffineGraphQL.SelectionSet {
|
||||
public let __data: DataDict
|
||||
public init(_dataDict: DataDict) { __data = _dataDict }
|
||||
|
||||
public static var __parentType: any ApolloAPI.ParentType { AffineGraphQL.Objects.PublicUserType }
|
||||
public static var __selections: [ApolloAPI.Selection] { [
|
||||
.field("__typename", String.self),
|
||||
.field("id", String.self),
|
||||
.field("name", String.self),
|
||||
.field("avatarUrl", String?.self),
|
||||
] }
|
||||
|
||||
public var id: String { __data["id"] }
|
||||
public var name: String { __data["name"] }
|
||||
public var avatarUrl: String? { __data["avatarUrl"] }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ public struct QueryChatHistoriesInput: InputObject {
|
||||
fork: GraphQLNullable<Bool> = nil,
|
||||
limit: GraphQLNullable<Int> = nil,
|
||||
messageOrder: GraphQLNullable<GraphQLEnum<ChatHistoryOrder>> = nil,
|
||||
pinned: GraphQLNullable<Bool> = nil,
|
||||
sessionId: GraphQLNullable<String> = nil,
|
||||
sessionOrder: GraphQLNullable<GraphQLEnum<ChatHistoryOrder>> = nil,
|
||||
skip: GraphQLNullable<Int> = nil,
|
||||
@@ -25,6 +26,7 @@ public struct QueryChatHistoriesInput: InputObject {
|
||||
"fork": fork,
|
||||
"limit": limit,
|
||||
"messageOrder": messageOrder,
|
||||
"pinned": pinned,
|
||||
"sessionId": sessionId,
|
||||
"sessionOrder": sessionOrder,
|
||||
"skip": skip,
|
||||
@@ -52,6 +54,11 @@ public struct QueryChatHistoriesInput: InputObject {
|
||||
set { __data["messageOrder"] = newValue }
|
||||
}
|
||||
|
||||
public var pinned: GraphQLNullable<Bool> {
|
||||
get { __data["pinned"] }
|
||||
set { __data["pinned"] = newValue }
|
||||
}
|
||||
|
||||
public var sessionId: GraphQLNullable<String> {
|
||||
get { __data["sessionId"] }
|
||||
set { __data["sessionId"] = newValue }
|
||||
|
||||
@@ -11,10 +11,18 @@ public struct QueryChatSessionsInput: InputObject {
|
||||
}
|
||||
|
||||
public init(
|
||||
action: GraphQLNullable<Bool> = nil
|
||||
action: GraphQLNullable<Bool> = nil,
|
||||
fork: GraphQLNullable<Bool> = nil,
|
||||
limit: GraphQLNullable<Int> = nil,
|
||||
pinned: GraphQLNullable<Bool> = nil,
|
||||
skip: GraphQLNullable<Int> = nil
|
||||
) {
|
||||
__data = InputDict([
|
||||
"action": action
|
||||
"action": action,
|
||||
"fork": fork,
|
||||
"limit": limit,
|
||||
"pinned": pinned,
|
||||
"skip": skip
|
||||
])
|
||||
}
|
||||
|
||||
@@ -22,4 +30,24 @@ public struct QueryChatSessionsInput: InputObject {
|
||||
get { __data["action"] }
|
||||
set { __data["action"] = newValue }
|
||||
}
|
||||
|
||||
public var fork: GraphQLNullable<Bool> {
|
||||
get { __data["fork"] }
|
||||
set { __data["fork"] = newValue }
|
||||
}
|
||||
|
||||
public var limit: GraphQLNullable<Int> {
|
||||
get { __data["limit"] }
|
||||
set { __data["limit"] = newValue }
|
||||
}
|
||||
|
||||
public var pinned: GraphQLNullable<Bool> {
|
||||
get { __data["pinned"] }
|
||||
set { __data["pinned"] = newValue }
|
||||
}
|
||||
|
||||
public var skip: GraphQLNullable<Int> {
|
||||
get { __data["skip"] }
|
||||
set { __data["skip"] = newValue }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import ApolloAPI
|
||||
|
||||
public struct SearchDocsInput: InputObject {
|
||||
public private(set) var __data: InputDict
|
||||
|
||||
public init(_ data: InputDict) {
|
||||
__data = data
|
||||
}
|
||||
|
||||
public init(
|
||||
keyword: String,
|
||||
limit: GraphQLNullable<Int> = nil
|
||||
) {
|
||||
__data = InputDict([
|
||||
"keyword": keyword,
|
||||
"limit": limit
|
||||
])
|
||||
}
|
||||
|
||||
public var keyword: String {
|
||||
get { __data["keyword"] }
|
||||
set { __data["keyword"] = newValue }
|
||||
}
|
||||
|
||||
/// Limit the number of docs to return, default is 20
|
||||
public var limit: GraphQLNullable<Int> {
|
||||
get { __data["limit"] }
|
||||
set { __data["limit"] = newValue }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import ApolloAPI
|
||||
|
||||
public extension Objects {
|
||||
static let SearchDocObjectType = ApolloAPI.Object(
|
||||
typename: "SearchDocObjectType",
|
||||
implementedInterfaces: [],
|
||||
keyFields: nil
|
||||
)
|
||||
}
|
||||
@@ -77,6 +77,7 @@ public enum SchemaMetadata: ApolloAPI.SchemaMetadata {
|
||||
case "Query": return AffineGraphQL.Objects.Query
|
||||
case "ReleaseVersionType": return AffineGraphQL.Objects.ReleaseVersionType
|
||||
case "RemoveAvatar": return AffineGraphQL.Objects.RemoveAvatar
|
||||
case "SearchDocObjectType": return AffineGraphQL.Objects.SearchDocObjectType
|
||||
case "SearchNodeObjectType": return AffineGraphQL.Objects.SearchNodeObjectType
|
||||
case "SearchResultObjectType": return AffineGraphQL.Objects.SearchResultObjectType
|
||||
case "SearchResultPagination": return AffineGraphQL.Objects.SearchResultPagination
|
||||
|
||||
Reference in New Issue
Block a user