-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestDataSource.ts
34 lines (28 loc) · 964 Bytes
/
TestDataSource.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { DataContentType, DataItem, DataSource, DataSourceConfig, DataSourceRegisterInfo, DataSourceTypeInfo } from '../../src';
import { Static, Type } from '@sinclair/typebox';
const typeInfo = new DataSourceTypeInfo('bilibili', 'test', 1);
const configSchema = Type.Object({
uid: Type.String(),
});
export type TestDataSourceConfig = DataSourceConfig & Static<typeof configSchema>;
export class TestDataSource extends DataSource {
constructor(config: TestDataSourceConfig) {
super(typeInfo, config.uid, config);
}
protected async fetchOnce(): Promise<DataItem[]> {
await this.sendGet('https://localhost/test');
return [
this.createDataItem({
type: DataContentType.COMMON,
id: Math.random().toString(),
rawContent: Math.random().toString(),
}),
];
}
}
export const testDataSourceRegisterInfo: DataSourceRegisterInfo = {
id: typeInfo.id,
ctor: TestDataSource,
typeInfo,
configSchema,
};