mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 08:36:22 +08:00
refactor(infra): refactor copilot client (#8813)
This commit is contained in:
@@ -13,6 +13,7 @@ export { WebSocketAuthProvider } from './provider/websocket-auth';
|
||||
export { AccountChanged, AuthService } from './services/auth';
|
||||
export { CaptchaService } from './services/captcha';
|
||||
export { DefaultServerService } from './services/default-server';
|
||||
export { EventSourceService } from './services/eventsource';
|
||||
export { FetchService } from './services/fetch';
|
||||
export { GraphQLService } from './services/graphql';
|
||||
export { InvoicesService } from './services/invoices';
|
||||
@@ -53,6 +54,7 @@ import { AuthService } from './services/auth';
|
||||
import { CaptchaService } from './services/captcha';
|
||||
import { CloudDocMetaService } from './services/cloud-doc-meta';
|
||||
import { DefaultServerService } from './services/default-server';
|
||||
import { EventSourceService } from './services/eventsource';
|
||||
import { FetchService } from './services/fetch';
|
||||
import { GraphQLService } from './services/graphql';
|
||||
import { InvoicesService } from './services/invoices';
|
||||
@@ -84,6 +86,7 @@ export function configureCloudModule(framework: Framework) {
|
||||
.scope(ServerScope)
|
||||
.service(ServerService, [ServerScope])
|
||||
.service(FetchService, [RawFetchProvider, ServerService])
|
||||
.service(EventSourceService, [ServerService])
|
||||
.service(GraphQLService, [FetchService])
|
||||
.service(
|
||||
WebSocketService,
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Service } from '@toeverything/infra';
|
||||
|
||||
import type { ServerService } from './server';
|
||||
|
||||
export class EventSourceService extends Service {
|
||||
constructor(private readonly serverService: ServerService) {
|
||||
super();
|
||||
}
|
||||
|
||||
eventSource = (url: string, eventSourceInitDict?: EventSourceInit) => {
|
||||
return new EventSource(
|
||||
new URL(url, this.serverService.server.baseUrl),
|
||||
eventSourceInitDict
|
||||
);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user